Lines Matching refs:bp

46 static inline u16 bnx2x_get_port_stats_dma_len(struct bnx2x *bp)  in bnx2x_get_port_stats_dma_len()  argument
51 if (SHMEM2_HAS(bp, sizeof_port_stats)) { in bnx2x_get_port_stats_dma_len()
52 u32 size = SHMEM2_RD(bp, sizeof_port_stats); in bnx2x_get_port_stats_dma_len()
68 if (bp->flags & BC_SUPPORTS_PFC_STATS) { in bnx2x_get_port_stats_dma_len()
86 static void bnx2x_dp_stats(struct bnx2x *bp) in bnx2x_dp_stats() argument
98 bp->fw_stats_req->hdr.cmd_num, in bnx2x_dp_stats()
99 bp->fw_stats_req->hdr.reserved0, in bnx2x_dp_stats()
100 bp->fw_stats_req->hdr.drv_stats_counter, in bnx2x_dp_stats()
101 bp->fw_stats_req->hdr.reserved1, in bnx2x_dp_stats()
102 bp->fw_stats_req->hdr.stats_counters_addrs.hi, in bnx2x_dp_stats()
103 bp->fw_stats_req->hdr.stats_counters_addrs.lo); in bnx2x_dp_stats()
105 for (i = 0; i < bp->fw_stats_req->hdr.cmd_num; i++) { in bnx2x_dp_stats()
113 i, bp->fw_stats_req->query[i].kind, in bnx2x_dp_stats()
114 bp->fw_stats_req->query[i].index, in bnx2x_dp_stats()
115 bp->fw_stats_req->query[i].funcID, in bnx2x_dp_stats()
116 bp->fw_stats_req->query[i].reserved, in bnx2x_dp_stats()
117 bp->fw_stats_req->query[i].address.hi, in bnx2x_dp_stats()
118 bp->fw_stats_req->query[i].address.lo); in bnx2x_dp_stats()
128 static void bnx2x_storm_stats_post(struct bnx2x *bp) in bnx2x_storm_stats_post() argument
132 if (bp->stats_pending) in bnx2x_storm_stats_post()
135 bp->fw_stats_req->hdr.drv_stats_counter = in bnx2x_storm_stats_post()
136 cpu_to_le16(bp->stats_counter++); in bnx2x_storm_stats_post()
139 le16_to_cpu(bp->fw_stats_req->hdr.drv_stats_counter)); in bnx2x_storm_stats_post()
142 bnx2x_iov_adjust_stats_req(bp); in bnx2x_storm_stats_post()
143 bnx2x_dp_stats(bp); in bnx2x_storm_stats_post()
146 rc = bnx2x_sp_post(bp, RAMROD_CMD_ID_COMMON_STAT_QUERY, 0, in bnx2x_storm_stats_post()
147 U64_HI(bp->fw_stats_req_mapping), in bnx2x_storm_stats_post()
148 U64_LO(bp->fw_stats_req_mapping), in bnx2x_storm_stats_post()
151 bp->stats_pending = 1; in bnx2x_storm_stats_post()
154 static void bnx2x_hw_stats_post(struct bnx2x *bp) in bnx2x_hw_stats_post() argument
156 struct dmae_command *dmae = &bp->stats_dmae; in bnx2x_hw_stats_post()
157 u32 *stats_comp = bnx2x_sp(bp, stats_comp); in bnx2x_hw_stats_post()
160 if (CHIP_REV_IS_SLOW(bp)) in bnx2x_hw_stats_post()
164 if (bp->func_stx) in bnx2x_hw_stats_post()
165 memcpy(bnx2x_sp(bp, func_stats), &bp->func_stats, in bnx2x_hw_stats_post()
166 sizeof(bp->func_stats)); in bnx2x_hw_stats_post()
169 if (bp->executer_idx) { in bnx2x_hw_stats_post()
170 int loader_idx = PMF_DMAE_C(bp); in bnx2x_hw_stats_post()
171 u32 opcode = bnx2x_dmae_opcode(bp, DMAE_SRC_PCI, DMAE_DST_GRC, in bnx2x_hw_stats_post()
177 dmae->src_addr_lo = U64_LO(bnx2x_sp_mapping(bp, dmae[0])); in bnx2x_hw_stats_post()
178 dmae->src_addr_hi = U64_HI(bnx2x_sp_mapping(bp, dmae[0])); in bnx2x_hw_stats_post()
184 if (CHIP_IS_E1(bp)) in bnx2x_hw_stats_post()
191 bnx2x_post_dmae(bp, dmae, loader_idx); in bnx2x_hw_stats_post()
193 } else if (bp->func_stx) { in bnx2x_hw_stats_post()
195 bnx2x_issue_dmae_with_comp(bp, dmae, stats_comp); in bnx2x_hw_stats_post()
199 static void bnx2x_stats_comp(struct bnx2x *bp) in bnx2x_stats_comp() argument
201 u32 *stats_comp = bnx2x_sp(bp, stats_comp); in bnx2x_stats_comp()
220 static void bnx2x_stats_pmf_update(struct bnx2x *bp) in bnx2x_stats_pmf_update() argument
224 int loader_idx = PMF_DMAE_C(bp); in bnx2x_stats_pmf_update()
225 u32 *stats_comp = bnx2x_sp(bp, stats_comp); in bnx2x_stats_pmf_update()
228 if (!bp->port.pmf || !bp->port.port_stx) { in bnx2x_stats_pmf_update()
233 bp->executer_idx = 0; in bnx2x_stats_pmf_update()
235 opcode = bnx2x_dmae_opcode(bp, DMAE_SRC_GRC, DMAE_DST_PCI, false, 0); in bnx2x_stats_pmf_update()
237 dmae = bnx2x_sp(bp, dmae[bp->executer_idx++]); in bnx2x_stats_pmf_update()
239 dmae->src_addr_lo = bp->port.port_stx >> 2; in bnx2x_stats_pmf_update()
241 dmae->dst_addr_lo = U64_LO(bnx2x_sp_mapping(bp, port_stats)); in bnx2x_stats_pmf_update()
242 dmae->dst_addr_hi = U64_HI(bnx2x_sp_mapping(bp, port_stats)); in bnx2x_stats_pmf_update()
248 dmae = bnx2x_sp(bp, dmae[bp->executer_idx++]); in bnx2x_stats_pmf_update()
250 dmae->src_addr_lo = (bp->port.port_stx >> 2) + DMAE_LEN32_RD_MAX; in bnx2x_stats_pmf_update()
252 dmae->dst_addr_lo = U64_LO(bnx2x_sp_mapping(bp, port_stats) + in bnx2x_stats_pmf_update()
254 dmae->dst_addr_hi = U64_HI(bnx2x_sp_mapping(bp, port_stats) + in bnx2x_stats_pmf_update()
256 dmae->len = bnx2x_get_port_stats_dma_len(bp) - DMAE_LEN32_RD_MAX; in bnx2x_stats_pmf_update()
258 dmae->comp_addr_lo = U64_LO(bnx2x_sp_mapping(bp, stats_comp)); in bnx2x_stats_pmf_update()
259 dmae->comp_addr_hi = U64_HI(bnx2x_sp_mapping(bp, stats_comp)); in bnx2x_stats_pmf_update()
263 bnx2x_hw_stats_post(bp); in bnx2x_stats_pmf_update()
264 bnx2x_stats_comp(bp); in bnx2x_stats_pmf_update()
267 static void bnx2x_port_stats_init(struct bnx2x *bp) in bnx2x_port_stats_init() argument
270 int port = BP_PORT(bp); in bnx2x_port_stats_init()
272 int loader_idx = PMF_DMAE_C(bp); in bnx2x_port_stats_init()
274 u32 *stats_comp = bnx2x_sp(bp, stats_comp); in bnx2x_port_stats_init()
277 if (!bp->link_vars.link_up || !bp->port.pmf) { in bnx2x_port_stats_init()
282 bp->executer_idx = 0; in bnx2x_port_stats_init()
285 opcode = bnx2x_dmae_opcode(bp, DMAE_SRC_PCI, DMAE_DST_GRC, in bnx2x_port_stats_init()
288 if (bp->port.port_stx) { in bnx2x_port_stats_init()
290 dmae = bnx2x_sp(bp, dmae[bp->executer_idx++]); in bnx2x_port_stats_init()
292 dmae->src_addr_lo = U64_LO(bnx2x_sp_mapping(bp, port_stats)); in bnx2x_port_stats_init()
293 dmae->src_addr_hi = U64_HI(bnx2x_sp_mapping(bp, port_stats)); in bnx2x_port_stats_init()
294 dmae->dst_addr_lo = bp->port.port_stx >> 2; in bnx2x_port_stats_init()
296 dmae->len = bnx2x_get_port_stats_dma_len(bp); in bnx2x_port_stats_init()
302 if (bp->func_stx) { in bnx2x_port_stats_init()
304 dmae = bnx2x_sp(bp, dmae[bp->executer_idx++]); in bnx2x_port_stats_init()
306 dmae->src_addr_lo = U64_LO(bnx2x_sp_mapping(bp, func_stats)); in bnx2x_port_stats_init()
307 dmae->src_addr_hi = U64_HI(bnx2x_sp_mapping(bp, func_stats)); in bnx2x_port_stats_init()
308 dmae->dst_addr_lo = bp->func_stx >> 2; in bnx2x_port_stats_init()
317 opcode = bnx2x_dmae_opcode(bp, DMAE_SRC_GRC, DMAE_DST_PCI, in bnx2x_port_stats_init()
321 if (bp->link_vars.mac_type == MAC_TYPE_EMAC) { in bnx2x_port_stats_init()
325 dmae = bnx2x_sp(bp, dmae[bp->executer_idx++]); in bnx2x_port_stats_init()
330 dmae->dst_addr_lo = U64_LO(bnx2x_sp_mapping(bp, mac_stats)); in bnx2x_port_stats_init()
331 dmae->dst_addr_hi = U64_HI(bnx2x_sp_mapping(bp, mac_stats)); in bnx2x_port_stats_init()
338 dmae = bnx2x_sp(bp, dmae[bp->executer_idx++]); in bnx2x_port_stats_init()
343 dmae->dst_addr_lo = U64_LO(bnx2x_sp_mapping(bp, mac_stats) + in bnx2x_port_stats_init()
345 dmae->dst_addr_hi = U64_HI(bnx2x_sp_mapping(bp, mac_stats) + in bnx2x_port_stats_init()
353 dmae = bnx2x_sp(bp, dmae[bp->executer_idx++]); in bnx2x_port_stats_init()
358 dmae->dst_addr_lo = U64_LO(bnx2x_sp_mapping(bp, mac_stats) + in bnx2x_port_stats_init()
360 dmae->dst_addr_hi = U64_HI(bnx2x_sp_mapping(bp, mac_stats) + in bnx2x_port_stats_init()
371 switch (bp->link_vars.mac_type) { in bnx2x_port_stats_init()
378 if (CHIP_IS_E1x(bp)) { in bnx2x_port_stats_init()
407 tx_len = sizeof(bp->slowpath-> in bnx2x_port_stats_init()
409 rx_len = sizeof(bp->slowpath-> in bnx2x_port_stats_init()
415 dmae = bnx2x_sp(bp, dmae[bp->executer_idx++]); in bnx2x_port_stats_init()
420 dmae->dst_addr_lo = U64_LO(bnx2x_sp_mapping(bp, mac_stats)); in bnx2x_port_stats_init()
421 dmae->dst_addr_hi = U64_HI(bnx2x_sp_mapping(bp, mac_stats)); in bnx2x_port_stats_init()
427 dmae = bnx2x_sp(bp, dmae[bp->executer_idx++]); in bnx2x_port_stats_init()
432 U64_LO(bnx2x_sp_mapping(bp, mac_stats) + (tx_len << 2)); in bnx2x_port_stats_init()
434 U64_HI(bnx2x_sp_mapping(bp, mac_stats) + (tx_len << 2)); in bnx2x_port_stats_init()
442 if (!CHIP_IS_E3(bp)) { in bnx2x_port_stats_init()
443 dmae = bnx2x_sp(bp, dmae[bp->executer_idx++]); in bnx2x_port_stats_init()
448 dmae->dst_addr_lo = U64_LO(bnx2x_sp_mapping(bp, nig_stats) + in bnx2x_port_stats_init()
450 dmae->dst_addr_hi = U64_HI(bnx2x_sp_mapping(bp, nig_stats) + in bnx2x_port_stats_init()
457 dmae = bnx2x_sp(bp, dmae[bp->executer_idx++]); in bnx2x_port_stats_init()
462 dmae->dst_addr_lo = U64_LO(bnx2x_sp_mapping(bp, nig_stats) + in bnx2x_port_stats_init()
464 dmae->dst_addr_hi = U64_HI(bnx2x_sp_mapping(bp, nig_stats) + in bnx2x_port_stats_init()
472 dmae = bnx2x_sp(bp, dmae[bp->executer_idx++]); in bnx2x_port_stats_init()
473 dmae->opcode = bnx2x_dmae_opcode(bp, DMAE_SRC_GRC, DMAE_DST_PCI, in bnx2x_port_stats_init()
478 dmae->dst_addr_lo = U64_LO(bnx2x_sp_mapping(bp, nig_stats)); in bnx2x_port_stats_init()
479 dmae->dst_addr_hi = U64_HI(bnx2x_sp_mapping(bp, nig_stats)); in bnx2x_port_stats_init()
482 dmae->comp_addr_lo = U64_LO(bnx2x_sp_mapping(bp, stats_comp)); in bnx2x_port_stats_init()
483 dmae->comp_addr_hi = U64_HI(bnx2x_sp_mapping(bp, stats_comp)); in bnx2x_port_stats_init()
489 static void bnx2x_func_stats_init(struct bnx2x *bp) in bnx2x_func_stats_init() argument
491 struct dmae_command *dmae = &bp->stats_dmae; in bnx2x_func_stats_init()
492 u32 *stats_comp = bnx2x_sp(bp, stats_comp); in bnx2x_func_stats_init()
495 if (!bp->func_stx) { in bnx2x_func_stats_init()
500 bp->executer_idx = 0; in bnx2x_func_stats_init()
503 dmae->opcode = bnx2x_dmae_opcode(bp, DMAE_SRC_PCI, DMAE_DST_GRC, in bnx2x_func_stats_init()
505 dmae->src_addr_lo = U64_LO(bnx2x_sp_mapping(bp, func_stats)); in bnx2x_func_stats_init()
506 dmae->src_addr_hi = U64_HI(bnx2x_sp_mapping(bp, func_stats)); in bnx2x_func_stats_init()
507 dmae->dst_addr_lo = bp->func_stx >> 2; in bnx2x_func_stats_init()
510 dmae->comp_addr_lo = U64_LO(bnx2x_sp_mapping(bp, stats_comp)); in bnx2x_func_stats_init()
511 dmae->comp_addr_hi = U64_HI(bnx2x_sp_mapping(bp, stats_comp)); in bnx2x_func_stats_init()
518 static void bnx2x_stats_start(struct bnx2x *bp) in bnx2x_stats_start() argument
520 if (IS_PF(bp)) { in bnx2x_stats_start()
521 if (bp->port.pmf) in bnx2x_stats_start()
522 bnx2x_port_stats_init(bp); in bnx2x_stats_start()
524 else if (bp->func_stx) in bnx2x_stats_start()
525 bnx2x_func_stats_init(bp); in bnx2x_stats_start()
527 bnx2x_hw_stats_post(bp); in bnx2x_stats_start()
528 bnx2x_storm_stats_post(bp); in bnx2x_stats_start()
532 static void bnx2x_stats_pmf_start(struct bnx2x *bp) in bnx2x_stats_pmf_start() argument
534 bnx2x_stats_comp(bp); in bnx2x_stats_pmf_start()
535 bnx2x_stats_pmf_update(bp); in bnx2x_stats_pmf_start()
536 bnx2x_stats_start(bp); in bnx2x_stats_pmf_start()
539 static void bnx2x_stats_restart(struct bnx2x *bp) in bnx2x_stats_restart() argument
544 if (IS_VF(bp)) in bnx2x_stats_restart()
547 bnx2x_stats_comp(bp); in bnx2x_stats_restart()
548 bnx2x_stats_start(bp); in bnx2x_stats_restart()
551 static void bnx2x_bmac_stats_update(struct bnx2x *bp) in bnx2x_bmac_stats_update() argument
553 struct host_port_stats *pstats = bnx2x_sp(bp, port_stats); in bnx2x_bmac_stats_update()
554 struct bnx2x_eth_stats *estats = &bp->eth_stats; in bnx2x_bmac_stats_update()
560 if (CHIP_IS_E1x(bp)) { in bnx2x_bmac_stats_update()
561 struct bmac1_stats *new = bnx2x_sp(bp, mac_stats.bmac1_stats); in bnx2x_bmac_stats_update()
596 struct bmac2_stats *new = bnx2x_sp(bp, mac_stats.bmac2_stats); in bnx2x_bmac_stats_update()
657 static void bnx2x_mstat_stats_update(struct bnx2x *bp) in bnx2x_mstat_stats_update() argument
659 struct host_port_stats *pstats = bnx2x_sp(bp, port_stats); in bnx2x_mstat_stats_update()
660 struct bnx2x_eth_stats *estats = &bp->eth_stats; in bnx2x_mstat_stats_update()
662 struct mstat_stats *new = bnx2x_sp(bp, mac_stats.mstat_stats); in bnx2x_mstat_stats_update()
747 static void bnx2x_emac_stats_update(struct bnx2x *bp) in bnx2x_emac_stats_update() argument
749 struct emac_stats *new = bnx2x_sp(bp, mac_stats.emac_stats); in bnx2x_emac_stats_update()
750 struct host_port_stats *pstats = bnx2x_sp(bp, port_stats); in bnx2x_emac_stats_update()
751 struct bnx2x_eth_stats *estats = &bp->eth_stats; in bnx2x_emac_stats_update()
804 static int bnx2x_hw_stats_update(struct bnx2x *bp) in bnx2x_hw_stats_update() argument
806 struct nig_stats *new = bnx2x_sp(bp, nig_stats); in bnx2x_hw_stats_update()
807 struct nig_stats *old = &(bp->port.old_nig_stats); in bnx2x_hw_stats_update()
808 struct host_port_stats *pstats = bnx2x_sp(bp, port_stats); in bnx2x_hw_stats_update()
809 struct bnx2x_eth_stats *estats = &bp->eth_stats; in bnx2x_hw_stats_update()
815 switch (bp->link_vars.mac_type) { in bnx2x_hw_stats_update()
817 bnx2x_bmac_stats_update(bp); in bnx2x_hw_stats_update()
821 bnx2x_emac_stats_update(bp); in bnx2x_hw_stats_update()
826 bnx2x_mstat_stats_update(bp); in bnx2x_hw_stats_update()
843 if (!CHIP_IS_E3(bp)) { in bnx2x_hw_stats_update()
860 if (CHIP_IS_E3(bp)) { in bnx2x_hw_stats_update()
861 u32 lpi_reg = BP_PORT(bp) ? MISC_REG_CPMU_LP_SM_ENT_CNT_P1 in bnx2x_hw_stats_update()
863 estats->eee_tx_lpi += REG_RD(bp, lpi_reg); in bnx2x_hw_stats_update()
866 if (!BP_NOMCP(bp)) { in bnx2x_hw_stats_update()
868 SHMEM_RD(bp, port_mb[BP_PORT(bp)].stat_nig_timer); in bnx2x_hw_stats_update()
879 static int bnx2x_storm_stats_validate_counters(struct bnx2x *bp) in bnx2x_storm_stats_validate_counters() argument
881 struct stats_counter *counters = &bp->fw_stats_data->storm_counters; in bnx2x_storm_stats_validate_counters()
886 cur_stats_counter = bp->stats_counter - 1; in bnx2x_storm_stats_validate_counters()
892 le16_to_cpu(counters->xstats_counter), bp->stats_counter); in bnx2x_storm_stats_validate_counters()
899 le16_to_cpu(counters->ustats_counter), bp->stats_counter); in bnx2x_storm_stats_validate_counters()
906 le16_to_cpu(counters->cstats_counter), bp->stats_counter); in bnx2x_storm_stats_validate_counters()
913 le16_to_cpu(counters->tstats_counter), bp->stats_counter); in bnx2x_storm_stats_validate_counters()
919 static int bnx2x_storm_stats_update(struct bnx2x *bp) in bnx2x_storm_stats_update() argument
922 &bp->fw_stats_data->port.tstorm_port_statistics; in bnx2x_storm_stats_update()
924 &bp->fw_stats_data->pf.tstorm_pf_statistics; in bnx2x_storm_stats_update()
925 struct host_func_stats *fstats = &bp->func_stats; in bnx2x_storm_stats_update()
926 struct bnx2x_eth_stats *estats = &bp->eth_stats; in bnx2x_storm_stats_update()
927 struct bnx2x_eth_stats_old *estats_old = &bp->eth_stats_old; in bnx2x_storm_stats_update()
931 if (IS_PF(bp) && bnx2x_storm_stats_validate_counters(bp)) in bnx2x_storm_stats_update()
937 for_each_eth_queue(bp, i) { in bnx2x_storm_stats_update()
938 struct bnx2x_fastpath *fp = &bp->fp[i]; in bnx2x_storm_stats_update()
940 &bp->fw_stats_data->queue_stats[i]. in bnx2x_storm_stats_update()
943 &bnx2x_fp_stats(bp, fp)->old_tclient; in bnx2x_storm_stats_update()
945 &bp->fw_stats_data->queue_stats[i]. in bnx2x_storm_stats_update()
948 &bnx2x_fp_stats(bp, fp)->old_uclient; in bnx2x_storm_stats_update()
950 &bp->fw_stats_data->queue_stats[i]. in bnx2x_storm_stats_update()
953 &bnx2x_fp_stats(bp, fp)->old_xclient; in bnx2x_storm_stats_update()
955 &bnx2x_fp_stats(bp, fp)->eth_q_stats; in bnx2x_storm_stats_update()
957 &bnx2x_fp_stats(bp, fp)->eth_q_stats_old; in bnx2x_storm_stats_update()
1102 if (bp->port.pmf) { in bnx2x_storm_stats_update()
1103 struct bnx2x_fw_port_stats_old *fwstats = &bp->fw_stats_old; in bnx2x_storm_stats_update()
1112 bp->stats_pending = 0; in bnx2x_storm_stats_update()
1117 static void bnx2x_net_stats_update(struct bnx2x *bp) in bnx2x_net_stats_update() argument
1119 struct bnx2x_eth_stats *estats = &bp->eth_stats; in bnx2x_net_stats_update()
1120 struct net_device_stats *nstats = &bp->dev->stats; in bnx2x_net_stats_update()
1139 for_each_rx_queue(bp, i) { in bnx2x_net_stats_update()
1141 &bp->fp_stats[i].old_tclient; in bnx2x_net_stats_update()
1144 nstats->rx_dropped = tmp + bp->net_stats_old.rx_dropped; in bnx2x_net_stats_update()
1187 static void bnx2x_drv_stats_update(struct bnx2x *bp) in bnx2x_drv_stats_update() argument
1189 struct bnx2x_eth_stats *estats = &bp->eth_stats; in bnx2x_drv_stats_update()
1192 for_each_queue(bp, i) { in bnx2x_drv_stats_update()
1193 struct bnx2x_eth_q_stats *qstats = &bp->fp_stats[i].eth_q_stats; in bnx2x_drv_stats_update()
1195 &bp->fp_stats[i].eth_q_stats_old; in bnx2x_drv_stats_update()
1205 static bool bnx2x_edebug_stats_stopped(struct bnx2x *bp) in bnx2x_edebug_stats_stopped() argument
1209 if (SHMEM2_HAS(bp, edebug_driver_if[1])) { in bnx2x_edebug_stats_stopped()
1210 val = SHMEM2_RD(bp, edebug_driver_if[1]); in bnx2x_edebug_stats_stopped()
1219 static void bnx2x_stats_update(struct bnx2x *bp) in bnx2x_stats_update() argument
1221 u32 *stats_comp = bnx2x_sp(bp, stats_comp); in bnx2x_stats_update()
1223 if (bnx2x_edebug_stats_stopped(bp)) in bnx2x_stats_update()
1226 if (IS_PF(bp)) { in bnx2x_stats_update()
1230 if (bp->port.pmf) in bnx2x_stats_update()
1231 bnx2x_hw_stats_update(bp); in bnx2x_stats_update()
1233 if (bnx2x_storm_stats_update(bp)) { in bnx2x_stats_update()
1234 if (bp->stats_pending++ == 3) { in bnx2x_stats_update()
1244 bnx2x_storm_stats_update(bp); in bnx2x_stats_update()
1247 bnx2x_net_stats_update(bp); in bnx2x_stats_update()
1248 bnx2x_drv_stats_update(bp); in bnx2x_stats_update()
1251 if (IS_VF(bp)) in bnx2x_stats_update()
1254 if (netif_msg_timer(bp)) { in bnx2x_stats_update()
1255 struct bnx2x_eth_stats *estats = &bp->eth_stats; in bnx2x_stats_update()
1257 netdev_dbg(bp->dev, "brb drops %u brb truncate %u\n", in bnx2x_stats_update()
1261 bnx2x_hw_stats_post(bp); in bnx2x_stats_update()
1262 bnx2x_storm_stats_post(bp); in bnx2x_stats_update()
1265 static void bnx2x_port_stats_stop(struct bnx2x *bp) in bnx2x_port_stats_stop() argument
1269 int loader_idx = PMF_DMAE_C(bp); in bnx2x_port_stats_stop()
1270 u32 *stats_comp = bnx2x_sp(bp, stats_comp); in bnx2x_port_stats_stop()
1272 bp->executer_idx = 0; in bnx2x_port_stats_stop()
1274 opcode = bnx2x_dmae_opcode(bp, DMAE_SRC_PCI, DMAE_DST_GRC, false, 0); in bnx2x_port_stats_stop()
1276 if (bp->port.port_stx) { in bnx2x_port_stats_stop()
1278 dmae = bnx2x_sp(bp, dmae[bp->executer_idx++]); in bnx2x_port_stats_stop()
1279 if (bp->func_stx) in bnx2x_port_stats_stop()
1286 dmae->src_addr_lo = U64_LO(bnx2x_sp_mapping(bp, port_stats)); in bnx2x_port_stats_stop()
1287 dmae->src_addr_hi = U64_HI(bnx2x_sp_mapping(bp, port_stats)); in bnx2x_port_stats_stop()
1288 dmae->dst_addr_lo = bp->port.port_stx >> 2; in bnx2x_port_stats_stop()
1290 dmae->len = bnx2x_get_port_stats_dma_len(bp); in bnx2x_port_stats_stop()
1291 if (bp->func_stx) { in bnx2x_port_stats_stop()
1297 U64_LO(bnx2x_sp_mapping(bp, stats_comp)); in bnx2x_port_stats_stop()
1299 U64_HI(bnx2x_sp_mapping(bp, stats_comp)); in bnx2x_port_stats_stop()
1306 if (bp->func_stx) { in bnx2x_port_stats_stop()
1308 dmae = bnx2x_sp(bp, dmae[bp->executer_idx++]); in bnx2x_port_stats_stop()
1311 dmae->src_addr_lo = U64_LO(bnx2x_sp_mapping(bp, func_stats)); in bnx2x_port_stats_stop()
1312 dmae->src_addr_hi = U64_HI(bnx2x_sp_mapping(bp, func_stats)); in bnx2x_port_stats_stop()
1313 dmae->dst_addr_lo = bp->func_stx >> 2; in bnx2x_port_stats_stop()
1316 dmae->comp_addr_lo = U64_LO(bnx2x_sp_mapping(bp, stats_comp)); in bnx2x_port_stats_stop()
1317 dmae->comp_addr_hi = U64_HI(bnx2x_sp_mapping(bp, stats_comp)); in bnx2x_port_stats_stop()
1324 static void bnx2x_stats_stop(struct bnx2x *bp) in bnx2x_stats_stop() argument
1328 bnx2x_stats_comp(bp); in bnx2x_stats_stop()
1330 if (bp->port.pmf) in bnx2x_stats_stop()
1331 update = (bnx2x_hw_stats_update(bp) == 0); in bnx2x_stats_stop()
1333 update |= (bnx2x_storm_stats_update(bp) == 0); in bnx2x_stats_stop()
1336 bnx2x_net_stats_update(bp); in bnx2x_stats_stop()
1338 if (bp->port.pmf) in bnx2x_stats_stop()
1339 bnx2x_port_stats_stop(bp); in bnx2x_stats_stop()
1341 bnx2x_hw_stats_post(bp); in bnx2x_stats_stop()
1342 bnx2x_stats_comp(bp); in bnx2x_stats_stop()
1346 static void bnx2x_stats_do_nothing(struct bnx2x *bp) in bnx2x_stats_do_nothing() argument
1351 void (*action)(struct bnx2x *bp);
1369 void bnx2x_stats_handle(struct bnx2x *bp, enum bnx2x_stats_event event) in bnx2x_stats_handle() argument
1371 enum bnx2x_stats_state state = bp->stats_state; in bnx2x_stats_handle()
1373 if (unlikely(bp->panic)) in bnx2x_stats_handle()
1380 if (down_trylock(&bp->stats_lock)) { in bnx2x_stats_handle()
1386 if (unlikely(down_timeout(&bp->stats_lock, HZ / 10))) { in bnx2x_stats_handle()
1393 bnx2x_stats_stm[state][event].action(bp); in bnx2x_stats_handle()
1394 bp->stats_state = bnx2x_stats_stm[state][event].next_state; in bnx2x_stats_handle()
1396 up(&bp->stats_lock); in bnx2x_stats_handle()
1398 if ((event != STATS_EVENT_UPDATE) || netif_msg_timer(bp)) in bnx2x_stats_handle()
1400 state, event, bp->stats_state); in bnx2x_stats_handle()
1403 static void bnx2x_port_stats_base_init(struct bnx2x *bp) in bnx2x_port_stats_base_init() argument
1406 u32 *stats_comp = bnx2x_sp(bp, stats_comp); in bnx2x_port_stats_base_init()
1409 if (!bp->port.pmf || !bp->port.port_stx) { in bnx2x_port_stats_base_init()
1414 bp->executer_idx = 0; in bnx2x_port_stats_base_init()
1416 dmae = bnx2x_sp(bp, dmae[bp->executer_idx++]); in bnx2x_port_stats_base_init()
1417 dmae->opcode = bnx2x_dmae_opcode(bp, DMAE_SRC_PCI, DMAE_DST_GRC, in bnx2x_port_stats_base_init()
1419 dmae->src_addr_lo = U64_LO(bnx2x_sp_mapping(bp, port_stats)); in bnx2x_port_stats_base_init()
1420 dmae->src_addr_hi = U64_HI(bnx2x_sp_mapping(bp, port_stats)); in bnx2x_port_stats_base_init()
1421 dmae->dst_addr_lo = bp->port.port_stx >> 2; in bnx2x_port_stats_base_init()
1423 dmae->len = bnx2x_get_port_stats_dma_len(bp); in bnx2x_port_stats_base_init()
1424 dmae->comp_addr_lo = U64_LO(bnx2x_sp_mapping(bp, stats_comp)); in bnx2x_port_stats_base_init()
1425 dmae->comp_addr_hi = U64_HI(bnx2x_sp_mapping(bp, stats_comp)); in bnx2x_port_stats_base_init()
1429 bnx2x_hw_stats_post(bp); in bnx2x_port_stats_base_init()
1430 bnx2x_stats_comp(bp); in bnx2x_port_stats_base_init()
1437 static void bnx2x_prep_fw_stats_req(struct bnx2x *bp) in bnx2x_prep_fw_stats_req() argument
1441 struct stats_query_header *stats_hdr = &bp->fw_stats_req->hdr; in bnx2x_prep_fw_stats_req()
1446 stats_hdr->cmd_num = bp->fw_stats_num; in bnx2x_prep_fw_stats_req()
1455 cur_data_offset = bp->fw_stats_data_mapping + in bnx2x_prep_fw_stats_req()
1466 memset(&bp->fw_stats_data->storm_counters, 0xff, in bnx2x_prep_fw_stats_req()
1470 cur_data_offset = bp->fw_stats_data_mapping + in bnx2x_prep_fw_stats_req()
1473 cur_query_entry = &bp->fw_stats_req->query[BNX2X_PORT_QUERY_IDX]; in bnx2x_prep_fw_stats_req()
1477 cur_query_entry->index = BP_PORT(bp); in bnx2x_prep_fw_stats_req()
1479 cur_query_entry->funcID = cpu_to_le16(BP_FUNC(bp)); in bnx2x_prep_fw_stats_req()
1484 cur_data_offset = bp->fw_stats_data_mapping + in bnx2x_prep_fw_stats_req()
1487 cur_query_entry = &bp->fw_stats_req->query[BNX2X_PF_QUERY_IDX]; in bnx2x_prep_fw_stats_req()
1491 cur_query_entry->index = BP_PORT(bp); in bnx2x_prep_fw_stats_req()
1492 cur_query_entry->funcID = cpu_to_le16(BP_FUNC(bp)); in bnx2x_prep_fw_stats_req()
1497 if (!NO_FCOE(bp)) { in bnx2x_prep_fw_stats_req()
1498 cur_data_offset = bp->fw_stats_data_mapping + in bnx2x_prep_fw_stats_req()
1502 &bp->fw_stats_req->query[BNX2X_FCOE_QUERY_IDX]; in bnx2x_prep_fw_stats_req()
1506 cur_query_entry->index = BP_PORT(bp); in bnx2x_prep_fw_stats_req()
1507 cur_query_entry->funcID = cpu_to_le16(BP_FUNC(bp)); in bnx2x_prep_fw_stats_req()
1515 cur_data_offset = bp->fw_stats_data_mapping + in bnx2x_prep_fw_stats_req()
1521 if (!NO_FCOE(bp)) in bnx2x_prep_fw_stats_req()
1526 for_each_eth_queue(bp, i) { in bnx2x_prep_fw_stats_req()
1528 &bp->fw_stats_req-> in bnx2x_prep_fw_stats_req()
1532 cur_query_entry->index = bnx2x_stats_id(&bp->fp[i]); in bnx2x_prep_fw_stats_req()
1533 cur_query_entry->funcID = cpu_to_le16(BP_FUNC(bp)); in bnx2x_prep_fw_stats_req()
1543 if (!NO_FCOE(bp)) { in bnx2x_prep_fw_stats_req()
1545 &bp->fw_stats_req-> in bnx2x_prep_fw_stats_req()
1549 cur_query_entry->index = bnx2x_stats_id(&bp->fp[FCOE_IDX(bp)]); in bnx2x_prep_fw_stats_req()
1550 cur_query_entry->funcID = cpu_to_le16(BP_FUNC(bp)); in bnx2x_prep_fw_stats_req()
1558 void bnx2x_memset_stats(struct bnx2x *bp) in bnx2x_memset_stats() argument
1563 for_each_queue(bp, i) { in bnx2x_memset_stats()
1564 struct bnx2x_fp_stats *fp_stats = &bp->fp_stats[i]; in bnx2x_memset_stats()
1572 if (bp->stats_init) { in bnx2x_memset_stats()
1580 memset(&bp->dev->stats, 0, sizeof(bp->dev->stats)); in bnx2x_memset_stats()
1582 if (bp->stats_init) { in bnx2x_memset_stats()
1583 memset(&bp->net_stats_old, 0, sizeof(bp->net_stats_old)); in bnx2x_memset_stats()
1584 memset(&bp->fw_stats_old, 0, sizeof(bp->fw_stats_old)); in bnx2x_memset_stats()
1585 memset(&bp->eth_stats_old, 0, sizeof(bp->eth_stats_old)); in bnx2x_memset_stats()
1586 memset(&bp->eth_stats, 0, sizeof(bp->eth_stats)); in bnx2x_memset_stats()
1587 memset(&bp->func_stats, 0, sizeof(bp->func_stats)); in bnx2x_memset_stats()
1590 bp->stats_state = STATS_STATE_DISABLED; in bnx2x_memset_stats()
1592 if (bp->port.pmf && bp->port.port_stx) in bnx2x_memset_stats()
1593 bnx2x_port_stats_base_init(bp); in bnx2x_memset_stats()
1596 bp->stats_init = false; in bnx2x_memset_stats()
1599 void bnx2x_stats_init(struct bnx2x *bp) in bnx2x_stats_init() argument
1601 int /*abs*/port = BP_PORT(bp); in bnx2x_stats_init()
1602 int mb_idx = BP_FW_MB_IDX(bp); in bnx2x_stats_init()
1604 if (IS_VF(bp)) { in bnx2x_stats_init()
1605 bnx2x_memset_stats(bp); in bnx2x_stats_init()
1609 bp->stats_pending = 0; in bnx2x_stats_init()
1610 bp->executer_idx = 0; in bnx2x_stats_init()
1611 bp->stats_counter = 0; in bnx2x_stats_init()
1614 if (!BP_NOMCP(bp)) { in bnx2x_stats_init()
1615 bp->port.port_stx = SHMEM_RD(bp, port_mb[port].port_stx); in bnx2x_stats_init()
1616 bp->func_stx = SHMEM_RD(bp, func_mb[mb_idx].fw_mb_param); in bnx2x_stats_init()
1619 bp->port.port_stx = 0; in bnx2x_stats_init()
1620 bp->func_stx = 0; in bnx2x_stats_init()
1623 bp->port.port_stx, bp->func_stx); in bnx2x_stats_init()
1626 if (!bp->stats_init && bp->port.pmf && bp->port.port_stx) in bnx2x_stats_init()
1627 bnx2x_stats_handle(bp, STATS_EVENT_PMF); in bnx2x_stats_init()
1629 port = BP_PORT(bp); in bnx2x_stats_init()
1631 memset(&(bp->port.old_nig_stats), 0, sizeof(struct nig_stats)); in bnx2x_stats_init()
1632 bp->port.old_nig_stats.brb_discard = in bnx2x_stats_init()
1633 REG_RD(bp, NIG_REG_STAT0_BRB_DISCARD + port*0x38); in bnx2x_stats_init()
1634 bp->port.old_nig_stats.brb_truncate = in bnx2x_stats_init()
1635 REG_RD(bp, NIG_REG_STAT0_BRB_TRUNCATE + port*0x38); in bnx2x_stats_init()
1636 if (!CHIP_IS_E3(bp)) { in bnx2x_stats_init()
1637 REG_RD_DMAE(bp, NIG_REG_STAT0_EGRESS_MAC_PKT0 + port*0x50, in bnx2x_stats_init()
1638 &(bp->port.old_nig_stats.egress_mac_pkt0), 2); in bnx2x_stats_init()
1639 REG_RD_DMAE(bp, NIG_REG_STAT0_EGRESS_MAC_PKT1 + port*0x50, in bnx2x_stats_init()
1640 &(bp->port.old_nig_stats.egress_mac_pkt1), 2); in bnx2x_stats_init()
1644 bnx2x_prep_fw_stats_req(bp); in bnx2x_stats_init()
1647 if (bp->stats_init) { in bnx2x_stats_init()
1648 if (bp->func_stx) { in bnx2x_stats_init()
1649 memset(bnx2x_sp(bp, func_stats), 0, in bnx2x_stats_init()
1651 bnx2x_func_stats_init(bp); in bnx2x_stats_init()
1652 bnx2x_hw_stats_post(bp); in bnx2x_stats_init()
1653 bnx2x_stats_comp(bp); in bnx2x_stats_init()
1657 bnx2x_memset_stats(bp); in bnx2x_stats_init()
1660 void bnx2x_save_statistics(struct bnx2x *bp) in bnx2x_save_statistics() argument
1663 struct net_device_stats *nstats = &bp->dev->stats; in bnx2x_save_statistics()
1666 for_each_eth_queue(bp, i) { in bnx2x_save_statistics()
1667 struct bnx2x_fastpath *fp = &bp->fp[i]; in bnx2x_save_statistics()
1669 &bnx2x_fp_stats(bp, fp)->eth_q_stats; in bnx2x_save_statistics()
1671 &bnx2x_fp_stats(bp, fp)->eth_q_stats_old; in bnx2x_save_statistics()
1690 bp->net_stats_old.rx_dropped = nstats->rx_dropped; in bnx2x_save_statistics()
1693 if (bp->port.pmf && IS_MF(bp)) { in bnx2x_save_statistics()
1694 struct bnx2x_eth_stats *estats = &bp->eth_stats; in bnx2x_save_statistics()
1695 struct bnx2x_fw_port_stats_old *fwstats = &bp->fw_stats_old; in bnx2x_save_statistics()
1703 void bnx2x_afex_collect_stats(struct bnx2x *bp, void *void_afex_stats, in bnx2x_afex_collect_stats() argument
1708 struct bnx2x_eth_stats *estats = &bp->eth_stats; in bnx2x_afex_collect_stats()
1710 &bp->fw_stats_data->queue_stats[FCOE_IDX(bp)]; in bnx2x_afex_collect_stats()
1722 &bp->fw_stats_data->fcoe; in bnx2x_afex_collect_stats()
1726 for_each_eth_queue(bp, i) { in bnx2x_afex_collect_stats()
1727 struct bnx2x_eth_q_stats *qstats = &bp->fp_stats[i].eth_q_stats; in bnx2x_afex_collect_stats()
1821 if (!NO_FCOE(bp)) { in bnx2x_afex_collect_stats()
1957 if ((bp->port.pmf) && (stats_type == VICSTATST_UIF_INDEX)) { in bnx2x_afex_collect_stats()
1973 int bnx2x_stats_safe_exec(struct bnx2x *bp, in bnx2x_stats_safe_exec() argument
1982 rc = down_timeout(&bp->stats_lock, HZ / 10); in bnx2x_stats_safe_exec()
1988 bnx2x_stats_comp(bp); in bnx2x_stats_safe_exec()
1989 while (bp->stats_pending && cnt--) in bnx2x_stats_safe_exec()
1990 if (bnx2x_storm_stats_update(bp)) in bnx2x_stats_safe_exec()
1992 if (bp->stats_pending) { in bnx2x_stats_safe_exec()
2004 up(&bp->stats_lock); in bnx2x_stats_safe_exec()