Lines Matching refs:bp

44 static inline u16 bnx2x_get_port_stats_dma_len(struct bnx2x *bp)  in bnx2x_get_port_stats_dma_len()  argument
49 if (SHMEM2_HAS(bp, sizeof_port_stats)) { in bnx2x_get_port_stats_dma_len()
50 u32 size = SHMEM2_RD(bp, sizeof_port_stats); in bnx2x_get_port_stats_dma_len()
66 if (bp->flags & BC_SUPPORTS_PFC_STATS) { in bnx2x_get_port_stats_dma_len()
84 static void bnx2x_dp_stats(struct bnx2x *bp) in bnx2x_dp_stats() argument
96 bp->fw_stats_req->hdr.cmd_num, in bnx2x_dp_stats()
97 bp->fw_stats_req->hdr.reserved0, in bnx2x_dp_stats()
98 bp->fw_stats_req->hdr.drv_stats_counter, in bnx2x_dp_stats()
99 bp->fw_stats_req->hdr.reserved1, in bnx2x_dp_stats()
100 bp->fw_stats_req->hdr.stats_counters_addrs.hi, in bnx2x_dp_stats()
101 bp->fw_stats_req->hdr.stats_counters_addrs.lo); in bnx2x_dp_stats()
103 for (i = 0; i < bp->fw_stats_req->hdr.cmd_num; i++) { in bnx2x_dp_stats()
111 i, bp->fw_stats_req->query[i].kind, in bnx2x_dp_stats()
112 bp->fw_stats_req->query[i].index, in bnx2x_dp_stats()
113 bp->fw_stats_req->query[i].funcID, in bnx2x_dp_stats()
114 bp->fw_stats_req->query[i].reserved, in bnx2x_dp_stats()
115 bp->fw_stats_req->query[i].address.hi, in bnx2x_dp_stats()
116 bp->fw_stats_req->query[i].address.lo); in bnx2x_dp_stats()
126 static void bnx2x_storm_stats_post(struct bnx2x *bp) in bnx2x_storm_stats_post() argument
130 if (bp->stats_pending) in bnx2x_storm_stats_post()
133 bp->fw_stats_req->hdr.drv_stats_counter = in bnx2x_storm_stats_post()
134 cpu_to_le16(bp->stats_counter++); in bnx2x_storm_stats_post()
137 le16_to_cpu(bp->fw_stats_req->hdr.drv_stats_counter)); in bnx2x_storm_stats_post()
140 bnx2x_iov_adjust_stats_req(bp); in bnx2x_storm_stats_post()
141 bnx2x_dp_stats(bp); in bnx2x_storm_stats_post()
144 rc = bnx2x_sp_post(bp, RAMROD_CMD_ID_COMMON_STAT_QUERY, 0, in bnx2x_storm_stats_post()
145 U64_HI(bp->fw_stats_req_mapping), in bnx2x_storm_stats_post()
146 U64_LO(bp->fw_stats_req_mapping), in bnx2x_storm_stats_post()
149 bp->stats_pending = 1; in bnx2x_storm_stats_post()
152 static void bnx2x_hw_stats_post(struct bnx2x *bp) in bnx2x_hw_stats_post() argument
154 struct dmae_command *dmae = &bp->stats_dmae; in bnx2x_hw_stats_post()
155 u32 *stats_comp = bnx2x_sp(bp, stats_comp); in bnx2x_hw_stats_post()
158 if (CHIP_REV_IS_SLOW(bp)) in bnx2x_hw_stats_post()
162 if (bp->func_stx) in bnx2x_hw_stats_post()
163 memcpy(bnx2x_sp(bp, func_stats), &bp->func_stats, in bnx2x_hw_stats_post()
164 sizeof(bp->func_stats)); in bnx2x_hw_stats_post()
167 if (bp->executer_idx) { in bnx2x_hw_stats_post()
168 int loader_idx = PMF_DMAE_C(bp); in bnx2x_hw_stats_post()
169 u32 opcode = bnx2x_dmae_opcode(bp, DMAE_SRC_PCI, DMAE_DST_GRC, in bnx2x_hw_stats_post()
175 dmae->src_addr_lo = U64_LO(bnx2x_sp_mapping(bp, dmae[0])); in bnx2x_hw_stats_post()
176 dmae->src_addr_hi = U64_HI(bnx2x_sp_mapping(bp, dmae[0])); in bnx2x_hw_stats_post()
182 if (CHIP_IS_E1(bp)) in bnx2x_hw_stats_post()
189 bnx2x_post_dmae(bp, dmae, loader_idx); in bnx2x_hw_stats_post()
191 } else if (bp->func_stx) { in bnx2x_hw_stats_post()
193 bnx2x_issue_dmae_with_comp(bp, dmae, stats_comp); in bnx2x_hw_stats_post()
197 static void bnx2x_stats_comp(struct bnx2x *bp) in bnx2x_stats_comp() argument
199 u32 *stats_comp = bnx2x_sp(bp, stats_comp); in bnx2x_stats_comp()
218 static void bnx2x_stats_pmf_update(struct bnx2x *bp) in bnx2x_stats_pmf_update() argument
222 int loader_idx = PMF_DMAE_C(bp); in bnx2x_stats_pmf_update()
223 u32 *stats_comp = bnx2x_sp(bp, stats_comp); in bnx2x_stats_pmf_update()
226 if (!bp->port.pmf || !bp->port.port_stx) { in bnx2x_stats_pmf_update()
231 bp->executer_idx = 0; in bnx2x_stats_pmf_update()
233 opcode = bnx2x_dmae_opcode(bp, DMAE_SRC_GRC, DMAE_DST_PCI, false, 0); in bnx2x_stats_pmf_update()
235 dmae = bnx2x_sp(bp, dmae[bp->executer_idx++]); in bnx2x_stats_pmf_update()
237 dmae->src_addr_lo = bp->port.port_stx >> 2; in bnx2x_stats_pmf_update()
239 dmae->dst_addr_lo = U64_LO(bnx2x_sp_mapping(bp, port_stats)); in bnx2x_stats_pmf_update()
240 dmae->dst_addr_hi = U64_HI(bnx2x_sp_mapping(bp, port_stats)); in bnx2x_stats_pmf_update()
246 dmae = bnx2x_sp(bp, dmae[bp->executer_idx++]); in bnx2x_stats_pmf_update()
248 dmae->src_addr_lo = (bp->port.port_stx >> 2) + DMAE_LEN32_RD_MAX; in bnx2x_stats_pmf_update()
250 dmae->dst_addr_lo = U64_LO(bnx2x_sp_mapping(bp, port_stats) + in bnx2x_stats_pmf_update()
252 dmae->dst_addr_hi = U64_HI(bnx2x_sp_mapping(bp, port_stats) + in bnx2x_stats_pmf_update()
254 dmae->len = bnx2x_get_port_stats_dma_len(bp) - DMAE_LEN32_RD_MAX; in bnx2x_stats_pmf_update()
256 dmae->comp_addr_lo = U64_LO(bnx2x_sp_mapping(bp, stats_comp)); in bnx2x_stats_pmf_update()
257 dmae->comp_addr_hi = U64_HI(bnx2x_sp_mapping(bp, stats_comp)); in bnx2x_stats_pmf_update()
261 bnx2x_hw_stats_post(bp); in bnx2x_stats_pmf_update()
262 bnx2x_stats_comp(bp); in bnx2x_stats_pmf_update()
265 static void bnx2x_port_stats_init(struct bnx2x *bp) in bnx2x_port_stats_init() argument
268 int port = BP_PORT(bp); in bnx2x_port_stats_init()
270 int loader_idx = PMF_DMAE_C(bp); in bnx2x_port_stats_init()
272 u32 *stats_comp = bnx2x_sp(bp, stats_comp); in bnx2x_port_stats_init()
275 if (!bp->link_vars.link_up || !bp->port.pmf) { in bnx2x_port_stats_init()
280 bp->executer_idx = 0; in bnx2x_port_stats_init()
283 opcode = bnx2x_dmae_opcode(bp, DMAE_SRC_PCI, DMAE_DST_GRC, in bnx2x_port_stats_init()
286 if (bp->port.port_stx) { in bnx2x_port_stats_init()
288 dmae = bnx2x_sp(bp, dmae[bp->executer_idx++]); in bnx2x_port_stats_init()
290 dmae->src_addr_lo = U64_LO(bnx2x_sp_mapping(bp, port_stats)); in bnx2x_port_stats_init()
291 dmae->src_addr_hi = U64_HI(bnx2x_sp_mapping(bp, port_stats)); in bnx2x_port_stats_init()
292 dmae->dst_addr_lo = bp->port.port_stx >> 2; in bnx2x_port_stats_init()
294 dmae->len = bnx2x_get_port_stats_dma_len(bp); in bnx2x_port_stats_init()
300 if (bp->func_stx) { in bnx2x_port_stats_init()
302 dmae = bnx2x_sp(bp, dmae[bp->executer_idx++]); in bnx2x_port_stats_init()
304 dmae->src_addr_lo = U64_LO(bnx2x_sp_mapping(bp, func_stats)); in bnx2x_port_stats_init()
305 dmae->src_addr_hi = U64_HI(bnx2x_sp_mapping(bp, func_stats)); in bnx2x_port_stats_init()
306 dmae->dst_addr_lo = bp->func_stx >> 2; in bnx2x_port_stats_init()
315 opcode = bnx2x_dmae_opcode(bp, DMAE_SRC_GRC, DMAE_DST_PCI, in bnx2x_port_stats_init()
319 if (bp->link_vars.mac_type == MAC_TYPE_EMAC) { in bnx2x_port_stats_init()
323 dmae = bnx2x_sp(bp, dmae[bp->executer_idx++]); in bnx2x_port_stats_init()
328 dmae->dst_addr_lo = U64_LO(bnx2x_sp_mapping(bp, mac_stats)); in bnx2x_port_stats_init()
329 dmae->dst_addr_hi = U64_HI(bnx2x_sp_mapping(bp, mac_stats)); in bnx2x_port_stats_init()
336 dmae = bnx2x_sp(bp, dmae[bp->executer_idx++]); in bnx2x_port_stats_init()
341 dmae->dst_addr_lo = U64_LO(bnx2x_sp_mapping(bp, mac_stats) + in bnx2x_port_stats_init()
343 dmae->dst_addr_hi = U64_HI(bnx2x_sp_mapping(bp, mac_stats) + in bnx2x_port_stats_init()
351 dmae = bnx2x_sp(bp, dmae[bp->executer_idx++]); in bnx2x_port_stats_init()
356 dmae->dst_addr_lo = U64_LO(bnx2x_sp_mapping(bp, mac_stats) + in bnx2x_port_stats_init()
358 dmae->dst_addr_hi = U64_HI(bnx2x_sp_mapping(bp, mac_stats) + in bnx2x_port_stats_init()
369 switch (bp->link_vars.mac_type) { in bnx2x_port_stats_init()
376 if (CHIP_IS_E1x(bp)) { in bnx2x_port_stats_init()
405 tx_len = sizeof(bp->slowpath-> in bnx2x_port_stats_init()
407 rx_len = sizeof(bp->slowpath-> in bnx2x_port_stats_init()
413 dmae = bnx2x_sp(bp, dmae[bp->executer_idx++]); in bnx2x_port_stats_init()
418 dmae->dst_addr_lo = U64_LO(bnx2x_sp_mapping(bp, mac_stats)); in bnx2x_port_stats_init()
419 dmae->dst_addr_hi = U64_HI(bnx2x_sp_mapping(bp, mac_stats)); in bnx2x_port_stats_init()
425 dmae = bnx2x_sp(bp, dmae[bp->executer_idx++]); in bnx2x_port_stats_init()
430 U64_LO(bnx2x_sp_mapping(bp, mac_stats) + (tx_len << 2)); in bnx2x_port_stats_init()
432 U64_HI(bnx2x_sp_mapping(bp, mac_stats) + (tx_len << 2)); in bnx2x_port_stats_init()
440 if (!CHIP_IS_E3(bp)) { in bnx2x_port_stats_init()
441 dmae = bnx2x_sp(bp, dmae[bp->executer_idx++]); in bnx2x_port_stats_init()
446 dmae->dst_addr_lo = U64_LO(bnx2x_sp_mapping(bp, nig_stats) + in bnx2x_port_stats_init()
448 dmae->dst_addr_hi = U64_HI(bnx2x_sp_mapping(bp, nig_stats) + in bnx2x_port_stats_init()
455 dmae = bnx2x_sp(bp, dmae[bp->executer_idx++]); in bnx2x_port_stats_init()
460 dmae->dst_addr_lo = U64_LO(bnx2x_sp_mapping(bp, nig_stats) + in bnx2x_port_stats_init()
462 dmae->dst_addr_hi = U64_HI(bnx2x_sp_mapping(bp, nig_stats) + in bnx2x_port_stats_init()
470 dmae = bnx2x_sp(bp, dmae[bp->executer_idx++]); in bnx2x_port_stats_init()
471 dmae->opcode = bnx2x_dmae_opcode(bp, DMAE_SRC_GRC, DMAE_DST_PCI, in bnx2x_port_stats_init()
476 dmae->dst_addr_lo = U64_LO(bnx2x_sp_mapping(bp, nig_stats)); in bnx2x_port_stats_init()
477 dmae->dst_addr_hi = U64_HI(bnx2x_sp_mapping(bp, nig_stats)); in bnx2x_port_stats_init()
480 dmae->comp_addr_lo = U64_LO(bnx2x_sp_mapping(bp, stats_comp)); in bnx2x_port_stats_init()
481 dmae->comp_addr_hi = U64_HI(bnx2x_sp_mapping(bp, stats_comp)); in bnx2x_port_stats_init()
487 static void bnx2x_func_stats_init(struct bnx2x *bp) in bnx2x_func_stats_init() argument
489 struct dmae_command *dmae = &bp->stats_dmae; in bnx2x_func_stats_init()
490 u32 *stats_comp = bnx2x_sp(bp, stats_comp); in bnx2x_func_stats_init()
493 if (!bp->func_stx) { in bnx2x_func_stats_init()
498 bp->executer_idx = 0; in bnx2x_func_stats_init()
501 dmae->opcode = bnx2x_dmae_opcode(bp, DMAE_SRC_PCI, DMAE_DST_GRC, in bnx2x_func_stats_init()
503 dmae->src_addr_lo = U64_LO(bnx2x_sp_mapping(bp, func_stats)); in bnx2x_func_stats_init()
504 dmae->src_addr_hi = U64_HI(bnx2x_sp_mapping(bp, func_stats)); in bnx2x_func_stats_init()
505 dmae->dst_addr_lo = bp->func_stx >> 2; in bnx2x_func_stats_init()
508 dmae->comp_addr_lo = U64_LO(bnx2x_sp_mapping(bp, stats_comp)); in bnx2x_func_stats_init()
509 dmae->comp_addr_hi = U64_HI(bnx2x_sp_mapping(bp, stats_comp)); in bnx2x_func_stats_init()
516 static void bnx2x_stats_start(struct bnx2x *bp) in bnx2x_stats_start() argument
518 if (IS_PF(bp)) { in bnx2x_stats_start()
519 if (bp->port.pmf) in bnx2x_stats_start()
520 bnx2x_port_stats_init(bp); in bnx2x_stats_start()
522 else if (bp->func_stx) in bnx2x_stats_start()
523 bnx2x_func_stats_init(bp); in bnx2x_stats_start()
525 bnx2x_hw_stats_post(bp); in bnx2x_stats_start()
526 bnx2x_storm_stats_post(bp); in bnx2x_stats_start()
530 static void bnx2x_stats_pmf_start(struct bnx2x *bp) in bnx2x_stats_pmf_start() argument
532 bnx2x_stats_comp(bp); in bnx2x_stats_pmf_start()
533 bnx2x_stats_pmf_update(bp); in bnx2x_stats_pmf_start()
534 bnx2x_stats_start(bp); in bnx2x_stats_pmf_start()
537 static void bnx2x_stats_restart(struct bnx2x *bp) in bnx2x_stats_restart() argument
542 if (IS_VF(bp)) in bnx2x_stats_restart()
545 bnx2x_stats_comp(bp); in bnx2x_stats_restart()
546 bnx2x_stats_start(bp); in bnx2x_stats_restart()
549 static void bnx2x_bmac_stats_update(struct bnx2x *bp) in bnx2x_bmac_stats_update() argument
551 struct host_port_stats *pstats = bnx2x_sp(bp, port_stats); in bnx2x_bmac_stats_update()
552 struct bnx2x_eth_stats *estats = &bp->eth_stats; in bnx2x_bmac_stats_update()
558 if (CHIP_IS_E1x(bp)) { in bnx2x_bmac_stats_update()
559 struct bmac1_stats *new = bnx2x_sp(bp, mac_stats.bmac1_stats); in bnx2x_bmac_stats_update()
594 struct bmac2_stats *new = bnx2x_sp(bp, mac_stats.bmac2_stats); in bnx2x_bmac_stats_update()
655 static void bnx2x_mstat_stats_update(struct bnx2x *bp) in bnx2x_mstat_stats_update() argument
657 struct host_port_stats *pstats = bnx2x_sp(bp, port_stats); in bnx2x_mstat_stats_update()
658 struct bnx2x_eth_stats *estats = &bp->eth_stats; in bnx2x_mstat_stats_update()
660 struct mstat_stats *new = bnx2x_sp(bp, mac_stats.mstat_stats); in bnx2x_mstat_stats_update()
745 static void bnx2x_emac_stats_update(struct bnx2x *bp) in bnx2x_emac_stats_update() argument
747 struct emac_stats *new = bnx2x_sp(bp, mac_stats.emac_stats); in bnx2x_emac_stats_update()
748 struct host_port_stats *pstats = bnx2x_sp(bp, port_stats); in bnx2x_emac_stats_update()
749 struct bnx2x_eth_stats *estats = &bp->eth_stats; in bnx2x_emac_stats_update()
802 static int bnx2x_hw_stats_update(struct bnx2x *bp) in bnx2x_hw_stats_update() argument
804 struct nig_stats *new = bnx2x_sp(bp, nig_stats); in bnx2x_hw_stats_update()
805 struct nig_stats *old = &(bp->port.old_nig_stats); in bnx2x_hw_stats_update()
806 struct host_port_stats *pstats = bnx2x_sp(bp, port_stats); in bnx2x_hw_stats_update()
807 struct bnx2x_eth_stats *estats = &bp->eth_stats; in bnx2x_hw_stats_update()
813 switch (bp->link_vars.mac_type) { in bnx2x_hw_stats_update()
815 bnx2x_bmac_stats_update(bp); in bnx2x_hw_stats_update()
819 bnx2x_emac_stats_update(bp); in bnx2x_hw_stats_update()
824 bnx2x_mstat_stats_update(bp); in bnx2x_hw_stats_update()
841 if (!CHIP_IS_E3(bp)) { in bnx2x_hw_stats_update()
858 if (CHIP_IS_E3(bp)) { in bnx2x_hw_stats_update()
859 u32 lpi_reg = BP_PORT(bp) ? MISC_REG_CPMU_LP_SM_ENT_CNT_P1 in bnx2x_hw_stats_update()
861 estats->eee_tx_lpi += REG_RD(bp, lpi_reg); in bnx2x_hw_stats_update()
864 if (!BP_NOMCP(bp)) { in bnx2x_hw_stats_update()
866 SHMEM_RD(bp, port_mb[BP_PORT(bp)].stat_nig_timer); in bnx2x_hw_stats_update()
877 static int bnx2x_storm_stats_validate_counters(struct bnx2x *bp) in bnx2x_storm_stats_validate_counters() argument
879 struct stats_counter *counters = &bp->fw_stats_data->storm_counters; in bnx2x_storm_stats_validate_counters()
884 cur_stats_counter = bp->stats_counter - 1; in bnx2x_storm_stats_validate_counters()
890 le16_to_cpu(counters->xstats_counter), bp->stats_counter); in bnx2x_storm_stats_validate_counters()
897 le16_to_cpu(counters->ustats_counter), bp->stats_counter); in bnx2x_storm_stats_validate_counters()
904 le16_to_cpu(counters->cstats_counter), bp->stats_counter); in bnx2x_storm_stats_validate_counters()
911 le16_to_cpu(counters->tstats_counter), bp->stats_counter); in bnx2x_storm_stats_validate_counters()
917 static int bnx2x_storm_stats_update(struct bnx2x *bp) in bnx2x_storm_stats_update() argument
920 &bp->fw_stats_data->port.tstorm_port_statistics; in bnx2x_storm_stats_update()
922 &bp->fw_stats_data->pf.tstorm_pf_statistics; in bnx2x_storm_stats_update()
923 struct host_func_stats *fstats = &bp->func_stats; in bnx2x_storm_stats_update()
924 struct bnx2x_eth_stats *estats = &bp->eth_stats; in bnx2x_storm_stats_update()
925 struct bnx2x_eth_stats_old *estats_old = &bp->eth_stats_old; in bnx2x_storm_stats_update()
929 if (IS_PF(bp) && bnx2x_storm_stats_validate_counters(bp)) in bnx2x_storm_stats_update()
935 for_each_eth_queue(bp, i) { in bnx2x_storm_stats_update()
936 struct bnx2x_fastpath *fp = &bp->fp[i]; in bnx2x_storm_stats_update()
938 &bp->fw_stats_data->queue_stats[i]. in bnx2x_storm_stats_update()
941 &bnx2x_fp_stats(bp, fp)->old_tclient; in bnx2x_storm_stats_update()
943 &bp->fw_stats_data->queue_stats[i]. in bnx2x_storm_stats_update()
946 &bnx2x_fp_stats(bp, fp)->old_uclient; in bnx2x_storm_stats_update()
948 &bp->fw_stats_data->queue_stats[i]. in bnx2x_storm_stats_update()
951 &bnx2x_fp_stats(bp, fp)->old_xclient; in bnx2x_storm_stats_update()
953 &bnx2x_fp_stats(bp, fp)->eth_q_stats; in bnx2x_storm_stats_update()
955 &bnx2x_fp_stats(bp, fp)->eth_q_stats_old; in bnx2x_storm_stats_update()
1100 if (bp->port.pmf) { in bnx2x_storm_stats_update()
1101 struct bnx2x_fw_port_stats_old *fwstats = &bp->fw_stats_old; in bnx2x_storm_stats_update()
1110 bp->stats_pending = 0; in bnx2x_storm_stats_update()
1115 static void bnx2x_net_stats_update(struct bnx2x *bp) in bnx2x_net_stats_update() argument
1117 struct bnx2x_eth_stats *estats = &bp->eth_stats; in bnx2x_net_stats_update()
1118 struct net_device_stats *nstats = &bp->dev->stats; in bnx2x_net_stats_update()
1137 for_each_rx_queue(bp, i) { in bnx2x_net_stats_update()
1139 &bp->fp_stats[i].old_tclient; in bnx2x_net_stats_update()
1142 nstats->rx_dropped = tmp + bp->net_stats_old.rx_dropped; in bnx2x_net_stats_update()
1185 static void bnx2x_drv_stats_update(struct bnx2x *bp) in bnx2x_drv_stats_update() argument
1187 struct bnx2x_eth_stats *estats = &bp->eth_stats; in bnx2x_drv_stats_update()
1190 for_each_queue(bp, i) { in bnx2x_drv_stats_update()
1191 struct bnx2x_eth_q_stats *qstats = &bp->fp_stats[i].eth_q_stats; in bnx2x_drv_stats_update()
1193 &bp->fp_stats[i].eth_q_stats_old; in bnx2x_drv_stats_update()
1203 static bool bnx2x_edebug_stats_stopped(struct bnx2x *bp) in bnx2x_edebug_stats_stopped() argument
1207 if (SHMEM2_HAS(bp, edebug_driver_if[1])) { in bnx2x_edebug_stats_stopped()
1208 val = SHMEM2_RD(bp, edebug_driver_if[1]); in bnx2x_edebug_stats_stopped()
1217 static void bnx2x_stats_update(struct bnx2x *bp) in bnx2x_stats_update() argument
1219 u32 *stats_comp = bnx2x_sp(bp, stats_comp); in bnx2x_stats_update()
1221 if (bnx2x_edebug_stats_stopped(bp)) in bnx2x_stats_update()
1224 if (IS_PF(bp)) { in bnx2x_stats_update()
1228 if (bp->port.pmf) in bnx2x_stats_update()
1229 bnx2x_hw_stats_update(bp); in bnx2x_stats_update()
1231 if (bnx2x_storm_stats_update(bp)) { in bnx2x_stats_update()
1232 if (bp->stats_pending++ == 3) { in bnx2x_stats_update()
1242 bnx2x_storm_stats_update(bp); in bnx2x_stats_update()
1245 bnx2x_net_stats_update(bp); in bnx2x_stats_update()
1246 bnx2x_drv_stats_update(bp); in bnx2x_stats_update()
1249 if (IS_VF(bp)) in bnx2x_stats_update()
1252 if (netif_msg_timer(bp)) { in bnx2x_stats_update()
1253 struct bnx2x_eth_stats *estats = &bp->eth_stats; in bnx2x_stats_update()
1255 netdev_dbg(bp->dev, "brb drops %u brb truncate %u\n", in bnx2x_stats_update()
1259 bnx2x_hw_stats_post(bp); in bnx2x_stats_update()
1260 bnx2x_storm_stats_post(bp); in bnx2x_stats_update()
1263 static void bnx2x_port_stats_stop(struct bnx2x *bp) in bnx2x_port_stats_stop() argument
1267 int loader_idx = PMF_DMAE_C(bp); in bnx2x_port_stats_stop()
1268 u32 *stats_comp = bnx2x_sp(bp, stats_comp); in bnx2x_port_stats_stop()
1270 bp->executer_idx = 0; in bnx2x_port_stats_stop()
1272 opcode = bnx2x_dmae_opcode(bp, DMAE_SRC_PCI, DMAE_DST_GRC, false, 0); in bnx2x_port_stats_stop()
1274 if (bp->port.port_stx) { in bnx2x_port_stats_stop()
1276 dmae = bnx2x_sp(bp, dmae[bp->executer_idx++]); in bnx2x_port_stats_stop()
1277 if (bp->func_stx) in bnx2x_port_stats_stop()
1284 dmae->src_addr_lo = U64_LO(bnx2x_sp_mapping(bp, port_stats)); in bnx2x_port_stats_stop()
1285 dmae->src_addr_hi = U64_HI(bnx2x_sp_mapping(bp, port_stats)); in bnx2x_port_stats_stop()
1286 dmae->dst_addr_lo = bp->port.port_stx >> 2; in bnx2x_port_stats_stop()
1288 dmae->len = bnx2x_get_port_stats_dma_len(bp); in bnx2x_port_stats_stop()
1289 if (bp->func_stx) { in bnx2x_port_stats_stop()
1295 U64_LO(bnx2x_sp_mapping(bp, stats_comp)); in bnx2x_port_stats_stop()
1297 U64_HI(bnx2x_sp_mapping(bp, stats_comp)); in bnx2x_port_stats_stop()
1304 if (bp->func_stx) { in bnx2x_port_stats_stop()
1306 dmae = bnx2x_sp(bp, dmae[bp->executer_idx++]); in bnx2x_port_stats_stop()
1309 dmae->src_addr_lo = U64_LO(bnx2x_sp_mapping(bp, func_stats)); in bnx2x_port_stats_stop()
1310 dmae->src_addr_hi = U64_HI(bnx2x_sp_mapping(bp, func_stats)); in bnx2x_port_stats_stop()
1311 dmae->dst_addr_lo = bp->func_stx >> 2; in bnx2x_port_stats_stop()
1314 dmae->comp_addr_lo = U64_LO(bnx2x_sp_mapping(bp, stats_comp)); in bnx2x_port_stats_stop()
1315 dmae->comp_addr_hi = U64_HI(bnx2x_sp_mapping(bp, stats_comp)); in bnx2x_port_stats_stop()
1322 static void bnx2x_stats_stop(struct bnx2x *bp) in bnx2x_stats_stop() argument
1326 bnx2x_stats_comp(bp); in bnx2x_stats_stop()
1328 if (bp->port.pmf) in bnx2x_stats_stop()
1329 update = (bnx2x_hw_stats_update(bp) == 0); in bnx2x_stats_stop()
1331 update |= (bnx2x_storm_stats_update(bp) == 0); in bnx2x_stats_stop()
1334 bnx2x_net_stats_update(bp); in bnx2x_stats_stop()
1336 if (bp->port.pmf) in bnx2x_stats_stop()
1337 bnx2x_port_stats_stop(bp); in bnx2x_stats_stop()
1339 bnx2x_hw_stats_post(bp); in bnx2x_stats_stop()
1340 bnx2x_stats_comp(bp); in bnx2x_stats_stop()
1344 static void bnx2x_stats_do_nothing(struct bnx2x *bp) in bnx2x_stats_do_nothing() argument
1349 void (*action)(struct bnx2x *bp);
1367 void bnx2x_stats_handle(struct bnx2x *bp, enum bnx2x_stats_event event) in bnx2x_stats_handle() argument
1369 enum bnx2x_stats_state state = bp->stats_state; in bnx2x_stats_handle()
1371 if (unlikely(bp->panic)) in bnx2x_stats_handle()
1378 if (down_trylock(&bp->stats_lock)) { in bnx2x_stats_handle()
1384 if (unlikely(down_timeout(&bp->stats_lock, HZ / 10))) { in bnx2x_stats_handle()
1391 bnx2x_stats_stm[state][event].action(bp); in bnx2x_stats_handle()
1392 bp->stats_state = bnx2x_stats_stm[state][event].next_state; in bnx2x_stats_handle()
1394 up(&bp->stats_lock); in bnx2x_stats_handle()
1396 if ((event != STATS_EVENT_UPDATE) || netif_msg_timer(bp)) in bnx2x_stats_handle()
1398 state, event, bp->stats_state); in bnx2x_stats_handle()
1401 static void bnx2x_port_stats_base_init(struct bnx2x *bp) in bnx2x_port_stats_base_init() argument
1404 u32 *stats_comp = bnx2x_sp(bp, stats_comp); in bnx2x_port_stats_base_init()
1407 if (!bp->port.pmf || !bp->port.port_stx) { in bnx2x_port_stats_base_init()
1412 bp->executer_idx = 0; in bnx2x_port_stats_base_init()
1414 dmae = bnx2x_sp(bp, dmae[bp->executer_idx++]); in bnx2x_port_stats_base_init()
1415 dmae->opcode = bnx2x_dmae_opcode(bp, DMAE_SRC_PCI, DMAE_DST_GRC, in bnx2x_port_stats_base_init()
1417 dmae->src_addr_lo = U64_LO(bnx2x_sp_mapping(bp, port_stats)); in bnx2x_port_stats_base_init()
1418 dmae->src_addr_hi = U64_HI(bnx2x_sp_mapping(bp, port_stats)); in bnx2x_port_stats_base_init()
1419 dmae->dst_addr_lo = bp->port.port_stx >> 2; in bnx2x_port_stats_base_init()
1421 dmae->len = bnx2x_get_port_stats_dma_len(bp); in bnx2x_port_stats_base_init()
1422 dmae->comp_addr_lo = U64_LO(bnx2x_sp_mapping(bp, stats_comp)); in bnx2x_port_stats_base_init()
1423 dmae->comp_addr_hi = U64_HI(bnx2x_sp_mapping(bp, stats_comp)); in bnx2x_port_stats_base_init()
1427 bnx2x_hw_stats_post(bp); in bnx2x_port_stats_base_init()
1428 bnx2x_stats_comp(bp); in bnx2x_port_stats_base_init()
1435 static void bnx2x_prep_fw_stats_req(struct bnx2x *bp) in bnx2x_prep_fw_stats_req() argument
1439 struct stats_query_header *stats_hdr = &bp->fw_stats_req->hdr; in bnx2x_prep_fw_stats_req()
1444 stats_hdr->cmd_num = bp->fw_stats_num; in bnx2x_prep_fw_stats_req()
1453 cur_data_offset = bp->fw_stats_data_mapping + in bnx2x_prep_fw_stats_req()
1464 memset(&bp->fw_stats_data->storm_counters, 0xff, in bnx2x_prep_fw_stats_req()
1468 cur_data_offset = bp->fw_stats_data_mapping + in bnx2x_prep_fw_stats_req()
1471 cur_query_entry = &bp->fw_stats_req->query[BNX2X_PORT_QUERY_IDX]; in bnx2x_prep_fw_stats_req()
1475 cur_query_entry->index = BP_PORT(bp); in bnx2x_prep_fw_stats_req()
1477 cur_query_entry->funcID = cpu_to_le16(BP_FUNC(bp)); in bnx2x_prep_fw_stats_req()
1482 cur_data_offset = bp->fw_stats_data_mapping + in bnx2x_prep_fw_stats_req()
1485 cur_query_entry = &bp->fw_stats_req->query[BNX2X_PF_QUERY_IDX]; in bnx2x_prep_fw_stats_req()
1489 cur_query_entry->index = BP_PORT(bp); in bnx2x_prep_fw_stats_req()
1490 cur_query_entry->funcID = cpu_to_le16(BP_FUNC(bp)); in bnx2x_prep_fw_stats_req()
1495 if (!NO_FCOE(bp)) { in bnx2x_prep_fw_stats_req()
1496 cur_data_offset = bp->fw_stats_data_mapping + in bnx2x_prep_fw_stats_req()
1500 &bp->fw_stats_req->query[BNX2X_FCOE_QUERY_IDX]; in bnx2x_prep_fw_stats_req()
1504 cur_query_entry->index = BP_PORT(bp); in bnx2x_prep_fw_stats_req()
1505 cur_query_entry->funcID = cpu_to_le16(BP_FUNC(bp)); in bnx2x_prep_fw_stats_req()
1513 cur_data_offset = bp->fw_stats_data_mapping + in bnx2x_prep_fw_stats_req()
1519 if (!NO_FCOE(bp)) in bnx2x_prep_fw_stats_req()
1524 for_each_eth_queue(bp, i) { in bnx2x_prep_fw_stats_req()
1526 &bp->fw_stats_req-> in bnx2x_prep_fw_stats_req()
1530 cur_query_entry->index = bnx2x_stats_id(&bp->fp[i]); in bnx2x_prep_fw_stats_req()
1531 cur_query_entry->funcID = cpu_to_le16(BP_FUNC(bp)); in bnx2x_prep_fw_stats_req()
1541 if (!NO_FCOE(bp)) { in bnx2x_prep_fw_stats_req()
1543 &bp->fw_stats_req-> in bnx2x_prep_fw_stats_req()
1547 cur_query_entry->index = bnx2x_stats_id(&bp->fp[FCOE_IDX(bp)]); in bnx2x_prep_fw_stats_req()
1548 cur_query_entry->funcID = cpu_to_le16(BP_FUNC(bp)); in bnx2x_prep_fw_stats_req()
1556 void bnx2x_memset_stats(struct bnx2x *bp) in bnx2x_memset_stats() argument
1561 for_each_queue(bp, i) { in bnx2x_memset_stats()
1562 struct bnx2x_fp_stats *fp_stats = &bp->fp_stats[i]; in bnx2x_memset_stats()
1570 if (bp->stats_init) { in bnx2x_memset_stats()
1578 memset(&bp->dev->stats, 0, sizeof(bp->dev->stats)); in bnx2x_memset_stats()
1580 if (bp->stats_init) { in bnx2x_memset_stats()
1581 memset(&bp->net_stats_old, 0, sizeof(bp->net_stats_old)); in bnx2x_memset_stats()
1582 memset(&bp->fw_stats_old, 0, sizeof(bp->fw_stats_old)); in bnx2x_memset_stats()
1583 memset(&bp->eth_stats_old, 0, sizeof(bp->eth_stats_old)); in bnx2x_memset_stats()
1584 memset(&bp->eth_stats, 0, sizeof(bp->eth_stats)); in bnx2x_memset_stats()
1585 memset(&bp->func_stats, 0, sizeof(bp->func_stats)); in bnx2x_memset_stats()
1588 bp->stats_state = STATS_STATE_DISABLED; in bnx2x_memset_stats()
1590 if (bp->port.pmf && bp->port.port_stx) in bnx2x_memset_stats()
1591 bnx2x_port_stats_base_init(bp); in bnx2x_memset_stats()
1594 bp->stats_init = false; in bnx2x_memset_stats()
1597 void bnx2x_stats_init(struct bnx2x *bp) in bnx2x_stats_init() argument
1599 int /*abs*/port = BP_PORT(bp); in bnx2x_stats_init()
1600 int mb_idx = BP_FW_MB_IDX(bp); in bnx2x_stats_init()
1602 if (IS_VF(bp)) { in bnx2x_stats_init()
1603 bnx2x_memset_stats(bp); in bnx2x_stats_init()
1607 bp->stats_pending = 0; in bnx2x_stats_init()
1608 bp->executer_idx = 0; in bnx2x_stats_init()
1609 bp->stats_counter = 0; in bnx2x_stats_init()
1612 if (!BP_NOMCP(bp)) { in bnx2x_stats_init()
1613 bp->port.port_stx = SHMEM_RD(bp, port_mb[port].port_stx); in bnx2x_stats_init()
1614 bp->func_stx = SHMEM_RD(bp, func_mb[mb_idx].fw_mb_param); in bnx2x_stats_init()
1617 bp->port.port_stx = 0; in bnx2x_stats_init()
1618 bp->func_stx = 0; in bnx2x_stats_init()
1621 bp->port.port_stx, bp->func_stx); in bnx2x_stats_init()
1624 if (!bp->stats_init && bp->port.pmf && bp->port.port_stx) in bnx2x_stats_init()
1625 bnx2x_stats_handle(bp, STATS_EVENT_PMF); in bnx2x_stats_init()
1627 port = BP_PORT(bp); in bnx2x_stats_init()
1629 memset(&(bp->port.old_nig_stats), 0, sizeof(struct nig_stats)); in bnx2x_stats_init()
1630 bp->port.old_nig_stats.brb_discard = in bnx2x_stats_init()
1631 REG_RD(bp, NIG_REG_STAT0_BRB_DISCARD + port*0x38); in bnx2x_stats_init()
1632 bp->port.old_nig_stats.brb_truncate = in bnx2x_stats_init()
1633 REG_RD(bp, NIG_REG_STAT0_BRB_TRUNCATE + port*0x38); in bnx2x_stats_init()
1634 if (!CHIP_IS_E3(bp)) { in bnx2x_stats_init()
1635 REG_RD_DMAE(bp, NIG_REG_STAT0_EGRESS_MAC_PKT0 + port*0x50, in bnx2x_stats_init()
1636 &(bp->port.old_nig_stats.egress_mac_pkt0), 2); in bnx2x_stats_init()
1637 REG_RD_DMAE(bp, NIG_REG_STAT0_EGRESS_MAC_PKT1 + port*0x50, in bnx2x_stats_init()
1638 &(bp->port.old_nig_stats.egress_mac_pkt1), 2); in bnx2x_stats_init()
1642 bnx2x_prep_fw_stats_req(bp); in bnx2x_stats_init()
1645 if (bp->stats_init) { in bnx2x_stats_init()
1646 if (bp->func_stx) { in bnx2x_stats_init()
1647 memset(bnx2x_sp(bp, func_stats), 0, in bnx2x_stats_init()
1649 bnx2x_func_stats_init(bp); in bnx2x_stats_init()
1650 bnx2x_hw_stats_post(bp); in bnx2x_stats_init()
1651 bnx2x_stats_comp(bp); in bnx2x_stats_init()
1655 bnx2x_memset_stats(bp); in bnx2x_stats_init()
1658 void bnx2x_save_statistics(struct bnx2x *bp) in bnx2x_save_statistics() argument
1661 struct net_device_stats *nstats = &bp->dev->stats; in bnx2x_save_statistics()
1664 for_each_eth_queue(bp, i) { in bnx2x_save_statistics()
1665 struct bnx2x_fastpath *fp = &bp->fp[i]; in bnx2x_save_statistics()
1667 &bnx2x_fp_stats(bp, fp)->eth_q_stats; in bnx2x_save_statistics()
1669 &bnx2x_fp_stats(bp, fp)->eth_q_stats_old; in bnx2x_save_statistics()
1688 bp->net_stats_old.rx_dropped = nstats->rx_dropped; in bnx2x_save_statistics()
1691 if (bp->port.pmf && IS_MF(bp)) { in bnx2x_save_statistics()
1692 struct bnx2x_eth_stats *estats = &bp->eth_stats; in bnx2x_save_statistics()
1693 struct bnx2x_fw_port_stats_old *fwstats = &bp->fw_stats_old; in bnx2x_save_statistics()
1701 void bnx2x_afex_collect_stats(struct bnx2x *bp, void *void_afex_stats, in bnx2x_afex_collect_stats() argument
1706 struct bnx2x_eth_stats *estats = &bp->eth_stats; in bnx2x_afex_collect_stats()
1708 &bp->fw_stats_data->queue_stats[FCOE_IDX(bp)]; in bnx2x_afex_collect_stats()
1720 &bp->fw_stats_data->fcoe; in bnx2x_afex_collect_stats()
1724 for_each_eth_queue(bp, i) { in bnx2x_afex_collect_stats()
1725 struct bnx2x_eth_q_stats *qstats = &bp->fp_stats[i].eth_q_stats; in bnx2x_afex_collect_stats()
1819 if (!NO_FCOE(bp)) { in bnx2x_afex_collect_stats()
1955 if ((bp->port.pmf) && (stats_type == VICSTATST_UIF_INDEX)) { in bnx2x_afex_collect_stats()
1971 int bnx2x_stats_safe_exec(struct bnx2x *bp, in bnx2x_stats_safe_exec() argument
1980 rc = down_timeout(&bp->stats_lock, HZ / 10); in bnx2x_stats_safe_exec()
1986 bnx2x_stats_comp(bp); in bnx2x_stats_safe_exec()
1987 while (bp->stats_pending && cnt--) in bnx2x_stats_safe_exec()
1988 if (bnx2x_storm_stats_update(bp)) in bnx2x_stats_safe_exec()
1990 if (bp->stats_pending) { in bnx2x_stats_safe_exec()
2002 up(&bp->stats_lock); in bnx2x_stats_safe_exec()