1 /* bnx2x_stats.c: Broadcom Everest network driver.
3 * Copyright (c) 2007-2012 Broadcom Corporation
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation.
9 * Maintained by: Eilon Greenstein <eilong@broadcom.com>
10 * Written by: Eliezer Tamir
11 * Based on code from Michael Chan's bnx2 driver
12 * UDP CSUM errata workaround by Arik Gendelman
13 * Slowpath and fastpath rework by Vladislav Zolotarov
14 * Statistics and Link management by Yitchak Gertner
18 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
20 #include "bnx2x_stats.h"
21 #include "bnx2x_cmn.h"
27 * General service functions
30 static inline long bnx2x_hilo(u32 *hiref)
32 u32 lo = *(hiref + 1);
33 #if (BITS_PER_LONG == 64)
36 return HILO_U64(hi, lo);
42 static u16 bnx2x_get_port_stats_dma_len(struct bnx2x *bp)
44 u16 res = sizeof(struct host_port_stats) >> 2;
46 /* if PFC stats are not supported by the MFW, don't DMA them */
47 if (!(bp->flags & BC_SUPPORTS_PFC_STATS))
48 res -= (sizeof(u32)*4) >> 2;
54 * Init service functions
57 /* Post the next statistics ramrod. Protect it with the spin in
58 * order to ensure the strict order between statistics ramrods
59 * (each ramrod has a sequence number passed in a
60 * bp->fw_stats_req->hdr.drv_stats_counter and ramrods must be
63 static void bnx2x_storm_stats_post(struct bnx2x *bp)
65 if (!bp->stats_pending) {
68 spin_lock_bh(&bp->stats_lock);
70 if (bp->stats_pending) {
71 spin_unlock_bh(&bp->stats_lock);
75 bp->fw_stats_req->hdr.drv_stats_counter =
76 cpu_to_le16(bp->stats_counter++);
78 DP(BNX2X_MSG_STATS, "Sending statistics ramrod %d\n",
79 bp->fw_stats_req->hdr.drv_stats_counter);
83 /* send FW stats ramrod */
84 rc = bnx2x_sp_post(bp, RAMROD_CMD_ID_COMMON_STAT_QUERY, 0,
85 U64_HI(bp->fw_stats_req_mapping),
86 U64_LO(bp->fw_stats_req_mapping),
87 NONE_CONNECTION_TYPE);
89 bp->stats_pending = 1;
91 spin_unlock_bh(&bp->stats_lock);
95 static void bnx2x_hw_stats_post(struct bnx2x *bp)
97 struct dmae_command *dmae = &bp->stats_dmae;
98 u32 *stats_comp = bnx2x_sp(bp, stats_comp);
100 *stats_comp = DMAE_COMP_VAL;
101 if (CHIP_REV_IS_SLOW(bp))
105 if (bp->executer_idx) {
106 int loader_idx = PMF_DMAE_C(bp);
107 u32 opcode = bnx2x_dmae_opcode(bp, DMAE_SRC_PCI, DMAE_DST_GRC,
108 true, DMAE_COMP_GRC);
109 opcode = bnx2x_dmae_opcode_clr_src_reset(opcode);
111 memset(dmae, 0, sizeof(struct dmae_command));
112 dmae->opcode = opcode;
113 dmae->src_addr_lo = U64_LO(bnx2x_sp_mapping(bp, dmae[0]));
114 dmae->src_addr_hi = U64_HI(bnx2x_sp_mapping(bp, dmae[0]));
115 dmae->dst_addr_lo = (DMAE_REG_CMD_MEM +
116 sizeof(struct dmae_command) *
117 (loader_idx + 1)) >> 2;
118 dmae->dst_addr_hi = 0;
119 dmae->len = sizeof(struct dmae_command) >> 2;
122 dmae->comp_addr_lo = dmae_reg_go_c[loader_idx + 1] >> 2;
123 dmae->comp_addr_hi = 0;
127 bnx2x_post_dmae(bp, dmae, loader_idx);
129 } else if (bp->func_stx) {
131 memcpy(bnx2x_sp(bp, func_stats), &bp->func_stats,
132 sizeof(bp->func_stats));
133 bnx2x_post_dmae(bp, dmae, INIT_DMAE_C(bp));
137 static int bnx2x_stats_comp(struct bnx2x *bp)
139 u32 *stats_comp = bnx2x_sp(bp, stats_comp);
143 while (*stats_comp != DMAE_COMP_VAL) {
145 BNX2X_ERR("timeout waiting for stats finished\n");
149 usleep_range(1000, 1000);
155 * Statistics service functions
158 static void bnx2x_stats_pmf_update(struct bnx2x *bp)
160 struct dmae_command *dmae;
162 int loader_idx = PMF_DMAE_C(bp);
163 u32 *stats_comp = bnx2x_sp(bp, stats_comp);
166 if (!bp->port.pmf || !bp->port.port_stx) {
171 bp->executer_idx = 0;
173 opcode = bnx2x_dmae_opcode(bp, DMAE_SRC_GRC, DMAE_DST_PCI, false, 0);
175 dmae = bnx2x_sp(bp, dmae[bp->executer_idx++]);
176 dmae->opcode = bnx2x_dmae_opcode_add_comp(opcode, DMAE_COMP_GRC);
177 dmae->src_addr_lo = bp->port.port_stx >> 2;
178 dmae->src_addr_hi = 0;
179 dmae->dst_addr_lo = U64_LO(bnx2x_sp_mapping(bp, port_stats));
180 dmae->dst_addr_hi = U64_HI(bnx2x_sp_mapping(bp, port_stats));
181 dmae->len = DMAE_LEN32_RD_MAX;
182 dmae->comp_addr_lo = dmae_reg_go_c[loader_idx] >> 2;
183 dmae->comp_addr_hi = 0;
186 dmae = bnx2x_sp(bp, dmae[bp->executer_idx++]);
187 dmae->opcode = bnx2x_dmae_opcode_add_comp(opcode, DMAE_COMP_PCI);
188 dmae->src_addr_lo = (bp->port.port_stx >> 2) + DMAE_LEN32_RD_MAX;
189 dmae->src_addr_hi = 0;
190 dmae->dst_addr_lo = U64_LO(bnx2x_sp_mapping(bp, port_stats) +
191 DMAE_LEN32_RD_MAX * 4);
192 dmae->dst_addr_hi = U64_HI(bnx2x_sp_mapping(bp, port_stats) +
193 DMAE_LEN32_RD_MAX * 4);
194 dmae->len = bnx2x_get_port_stats_dma_len(bp) - DMAE_LEN32_RD_MAX;
196 dmae->comp_addr_lo = U64_LO(bnx2x_sp_mapping(bp, stats_comp));
197 dmae->comp_addr_hi = U64_HI(bnx2x_sp_mapping(bp, stats_comp));
198 dmae->comp_val = DMAE_COMP_VAL;
201 bnx2x_hw_stats_post(bp);
202 bnx2x_stats_comp(bp);
205 static void bnx2x_port_stats_init(struct bnx2x *bp)
207 struct dmae_command *dmae;
208 int port = BP_PORT(bp);
210 int loader_idx = PMF_DMAE_C(bp);
212 u32 *stats_comp = bnx2x_sp(bp, stats_comp);
215 if (!bp->link_vars.link_up || !bp->port.pmf) {
220 bp->executer_idx = 0;
223 opcode = bnx2x_dmae_opcode(bp, DMAE_SRC_PCI, DMAE_DST_GRC,
224 true, DMAE_COMP_GRC);
226 if (bp->port.port_stx) {
228 dmae = bnx2x_sp(bp, dmae[bp->executer_idx++]);
229 dmae->opcode = opcode;
230 dmae->src_addr_lo = U64_LO(bnx2x_sp_mapping(bp, port_stats));
231 dmae->src_addr_hi = U64_HI(bnx2x_sp_mapping(bp, port_stats));
232 dmae->dst_addr_lo = bp->port.port_stx >> 2;
233 dmae->dst_addr_hi = 0;
234 dmae->len = bnx2x_get_port_stats_dma_len(bp);
235 dmae->comp_addr_lo = dmae_reg_go_c[loader_idx] >> 2;
236 dmae->comp_addr_hi = 0;
242 dmae = bnx2x_sp(bp, dmae[bp->executer_idx++]);
243 dmae->opcode = opcode;
244 dmae->src_addr_lo = U64_LO(bnx2x_sp_mapping(bp, func_stats));
245 dmae->src_addr_hi = U64_HI(bnx2x_sp_mapping(bp, func_stats));
246 dmae->dst_addr_lo = bp->func_stx >> 2;
247 dmae->dst_addr_hi = 0;
248 dmae->len = sizeof(struct host_func_stats) >> 2;
249 dmae->comp_addr_lo = dmae_reg_go_c[loader_idx] >> 2;
250 dmae->comp_addr_hi = 0;
255 opcode = bnx2x_dmae_opcode(bp, DMAE_SRC_GRC, DMAE_DST_PCI,
256 true, DMAE_COMP_GRC);
258 /* EMAC is special */
259 if (bp->link_vars.mac_type == MAC_TYPE_EMAC) {
260 mac_addr = (port ? GRCBASE_EMAC1 : GRCBASE_EMAC0);
262 /* EMAC_REG_EMAC_RX_STAT_AC (EMAC_REG_EMAC_RX_STAT_AC_COUNT)*/
263 dmae = bnx2x_sp(bp, dmae[bp->executer_idx++]);
264 dmae->opcode = opcode;
265 dmae->src_addr_lo = (mac_addr +
266 EMAC_REG_EMAC_RX_STAT_AC) >> 2;
267 dmae->src_addr_hi = 0;
268 dmae->dst_addr_lo = U64_LO(bnx2x_sp_mapping(bp, mac_stats));
269 dmae->dst_addr_hi = U64_HI(bnx2x_sp_mapping(bp, mac_stats));
270 dmae->len = EMAC_REG_EMAC_RX_STAT_AC_COUNT;
271 dmae->comp_addr_lo = dmae_reg_go_c[loader_idx] >> 2;
272 dmae->comp_addr_hi = 0;
275 /* EMAC_REG_EMAC_RX_STAT_AC_28 */
276 dmae = bnx2x_sp(bp, dmae[bp->executer_idx++]);
277 dmae->opcode = opcode;
278 dmae->src_addr_lo = (mac_addr +
279 EMAC_REG_EMAC_RX_STAT_AC_28) >> 2;
280 dmae->src_addr_hi = 0;
281 dmae->dst_addr_lo = U64_LO(bnx2x_sp_mapping(bp, mac_stats) +
282 offsetof(struct emac_stats, rx_stat_falsecarriererrors));
283 dmae->dst_addr_hi = U64_HI(bnx2x_sp_mapping(bp, mac_stats) +
284 offsetof(struct emac_stats, rx_stat_falsecarriererrors));
286 dmae->comp_addr_lo = dmae_reg_go_c[loader_idx] >> 2;
287 dmae->comp_addr_hi = 0;
290 /* EMAC_REG_EMAC_TX_STAT_AC (EMAC_REG_EMAC_TX_STAT_AC_COUNT)*/
291 dmae = bnx2x_sp(bp, dmae[bp->executer_idx++]);
292 dmae->opcode = opcode;
293 dmae->src_addr_lo = (mac_addr +
294 EMAC_REG_EMAC_TX_STAT_AC) >> 2;
295 dmae->src_addr_hi = 0;
296 dmae->dst_addr_lo = U64_LO(bnx2x_sp_mapping(bp, mac_stats) +
297 offsetof(struct emac_stats, tx_stat_ifhcoutoctets));
298 dmae->dst_addr_hi = U64_HI(bnx2x_sp_mapping(bp, mac_stats) +
299 offsetof(struct emac_stats, tx_stat_ifhcoutoctets));
300 dmae->len = EMAC_REG_EMAC_TX_STAT_AC_COUNT;
301 dmae->comp_addr_lo = dmae_reg_go_c[loader_idx] >> 2;
302 dmae->comp_addr_hi = 0;
305 u32 tx_src_addr_lo, rx_src_addr_lo;
308 /* configure the params according to MAC type */
309 switch (bp->link_vars.mac_type) {
311 mac_addr = (port ? NIG_REG_INGRESS_BMAC1_MEM :
312 NIG_REG_INGRESS_BMAC0_MEM);
314 /* BIGMAC_REGISTER_TX_STAT_GTPKT ..
315 BIGMAC_REGISTER_TX_STAT_GTBYT */
316 if (CHIP_IS_E1x(bp)) {
317 tx_src_addr_lo = (mac_addr +
318 BIGMAC_REGISTER_TX_STAT_GTPKT) >> 2;
319 tx_len = (8 + BIGMAC_REGISTER_TX_STAT_GTBYT -
320 BIGMAC_REGISTER_TX_STAT_GTPKT) >> 2;
321 rx_src_addr_lo = (mac_addr +
322 BIGMAC_REGISTER_RX_STAT_GR64) >> 2;
323 rx_len = (8 + BIGMAC_REGISTER_RX_STAT_GRIPJ -
324 BIGMAC_REGISTER_RX_STAT_GR64) >> 2;
326 tx_src_addr_lo = (mac_addr +
327 BIGMAC2_REGISTER_TX_STAT_GTPOK) >> 2;
328 tx_len = (8 + BIGMAC2_REGISTER_TX_STAT_GTBYT -
329 BIGMAC2_REGISTER_TX_STAT_GTPOK) >> 2;
330 rx_src_addr_lo = (mac_addr +
331 BIGMAC2_REGISTER_RX_STAT_GR64) >> 2;
332 rx_len = (8 + BIGMAC2_REGISTER_RX_STAT_GRIPJ -
333 BIGMAC2_REGISTER_RX_STAT_GR64) >> 2;
337 case MAC_TYPE_UMAC: /* handled by MSTAT */
338 case MAC_TYPE_XMAC: /* handled by MSTAT */
340 mac_addr = port ? GRCBASE_MSTAT1 : GRCBASE_MSTAT0;
341 tx_src_addr_lo = (mac_addr +
342 MSTAT_REG_TX_STAT_GTXPOK_LO) >> 2;
343 rx_src_addr_lo = (mac_addr +
344 MSTAT_REG_RX_STAT_GR64_LO) >> 2;
345 tx_len = sizeof(bp->slowpath->
346 mac_stats.mstat_stats.stats_tx) >> 2;
347 rx_len = sizeof(bp->slowpath->
348 mac_stats.mstat_stats.stats_rx) >> 2;
353 dmae = bnx2x_sp(bp, dmae[bp->executer_idx++]);
354 dmae->opcode = opcode;
355 dmae->src_addr_lo = tx_src_addr_lo;
356 dmae->src_addr_hi = 0;
358 dmae->dst_addr_lo = U64_LO(bnx2x_sp_mapping(bp, mac_stats));
359 dmae->dst_addr_hi = U64_HI(bnx2x_sp_mapping(bp, mac_stats));
360 dmae->comp_addr_lo = dmae_reg_go_c[loader_idx] >> 2;
361 dmae->comp_addr_hi = 0;
365 dmae = bnx2x_sp(bp, dmae[bp->executer_idx++]);
366 dmae->opcode = opcode;
367 dmae->src_addr_hi = 0;
368 dmae->src_addr_lo = rx_src_addr_lo;
370 U64_LO(bnx2x_sp_mapping(bp, mac_stats) + (tx_len << 2));
372 U64_HI(bnx2x_sp_mapping(bp, mac_stats) + (tx_len << 2));
374 dmae->comp_addr_lo = dmae_reg_go_c[loader_idx] >> 2;
375 dmae->comp_addr_hi = 0;
380 if (!CHIP_IS_E3(bp)) {
381 dmae = bnx2x_sp(bp, dmae[bp->executer_idx++]);
382 dmae->opcode = opcode;
383 dmae->src_addr_lo = (port ? NIG_REG_STAT1_EGRESS_MAC_PKT0 :
384 NIG_REG_STAT0_EGRESS_MAC_PKT0) >> 2;
385 dmae->src_addr_hi = 0;
386 dmae->dst_addr_lo = U64_LO(bnx2x_sp_mapping(bp, nig_stats) +
387 offsetof(struct nig_stats, egress_mac_pkt0_lo));
388 dmae->dst_addr_hi = U64_HI(bnx2x_sp_mapping(bp, nig_stats) +
389 offsetof(struct nig_stats, egress_mac_pkt0_lo));
390 dmae->len = (2*sizeof(u32)) >> 2;
391 dmae->comp_addr_lo = dmae_reg_go_c[loader_idx] >> 2;
392 dmae->comp_addr_hi = 0;
395 dmae = bnx2x_sp(bp, dmae[bp->executer_idx++]);
396 dmae->opcode = opcode;
397 dmae->src_addr_lo = (port ? NIG_REG_STAT1_EGRESS_MAC_PKT1 :
398 NIG_REG_STAT0_EGRESS_MAC_PKT1) >> 2;
399 dmae->src_addr_hi = 0;
400 dmae->dst_addr_lo = U64_LO(bnx2x_sp_mapping(bp, nig_stats) +
401 offsetof(struct nig_stats, egress_mac_pkt1_lo));
402 dmae->dst_addr_hi = U64_HI(bnx2x_sp_mapping(bp, nig_stats) +
403 offsetof(struct nig_stats, egress_mac_pkt1_lo));
404 dmae->len = (2*sizeof(u32)) >> 2;
405 dmae->comp_addr_lo = dmae_reg_go_c[loader_idx] >> 2;
406 dmae->comp_addr_hi = 0;
410 dmae = bnx2x_sp(bp, dmae[bp->executer_idx++]);
411 dmae->opcode = bnx2x_dmae_opcode(bp, DMAE_SRC_GRC, DMAE_DST_PCI,
412 true, DMAE_COMP_PCI);
413 dmae->src_addr_lo = (port ? NIG_REG_STAT1_BRB_DISCARD :
414 NIG_REG_STAT0_BRB_DISCARD) >> 2;
415 dmae->src_addr_hi = 0;
416 dmae->dst_addr_lo = U64_LO(bnx2x_sp_mapping(bp, nig_stats));
417 dmae->dst_addr_hi = U64_HI(bnx2x_sp_mapping(bp, nig_stats));
418 dmae->len = (sizeof(struct nig_stats) - 4*sizeof(u32)) >> 2;
420 dmae->comp_addr_lo = U64_LO(bnx2x_sp_mapping(bp, stats_comp));
421 dmae->comp_addr_hi = U64_HI(bnx2x_sp_mapping(bp, stats_comp));
422 dmae->comp_val = DMAE_COMP_VAL;
427 static void bnx2x_func_stats_init(struct bnx2x *bp)
429 struct dmae_command *dmae = &bp->stats_dmae;
430 u32 *stats_comp = bnx2x_sp(bp, stats_comp);
438 bp->executer_idx = 0;
439 memset(dmae, 0, sizeof(struct dmae_command));
441 dmae->opcode = bnx2x_dmae_opcode(bp, DMAE_SRC_PCI, DMAE_DST_GRC,
442 true, DMAE_COMP_PCI);
443 dmae->src_addr_lo = U64_LO(bnx2x_sp_mapping(bp, func_stats));
444 dmae->src_addr_hi = U64_HI(bnx2x_sp_mapping(bp, func_stats));
445 dmae->dst_addr_lo = bp->func_stx >> 2;
446 dmae->dst_addr_hi = 0;
447 dmae->len = sizeof(struct host_func_stats) >> 2;
448 dmae->comp_addr_lo = U64_LO(bnx2x_sp_mapping(bp, stats_comp));
449 dmae->comp_addr_hi = U64_HI(bnx2x_sp_mapping(bp, stats_comp));
450 dmae->comp_val = DMAE_COMP_VAL;
455 static void bnx2x_stats_start(struct bnx2x *bp)
458 bnx2x_port_stats_init(bp);
460 else if (bp->func_stx)
461 bnx2x_func_stats_init(bp);
463 bnx2x_hw_stats_post(bp);
464 bnx2x_storm_stats_post(bp);
467 static void bnx2x_stats_pmf_start(struct bnx2x *bp)
469 bnx2x_stats_comp(bp);
470 bnx2x_stats_pmf_update(bp);
471 bnx2x_stats_start(bp);
474 static void bnx2x_stats_restart(struct bnx2x *bp)
476 bnx2x_stats_comp(bp);
477 bnx2x_stats_start(bp);
480 static void bnx2x_bmac_stats_update(struct bnx2x *bp)
482 struct host_port_stats *pstats = bnx2x_sp(bp, port_stats);
483 struct bnx2x_eth_stats *estats = &bp->eth_stats;
489 if (CHIP_IS_E1x(bp)) {
490 struct bmac1_stats *new = bnx2x_sp(bp, mac_stats.bmac1_stats);
492 /* the macros below will use "bmac1_stats" type */
493 UPDATE_STAT64(rx_stat_grerb, rx_stat_ifhcinbadoctets);
494 UPDATE_STAT64(rx_stat_grfcs, rx_stat_dot3statsfcserrors);
495 UPDATE_STAT64(rx_stat_grund, rx_stat_etherstatsundersizepkts);
496 UPDATE_STAT64(rx_stat_grovr, rx_stat_dot3statsframestoolong);
497 UPDATE_STAT64(rx_stat_grfrg, rx_stat_etherstatsfragments);
498 UPDATE_STAT64(rx_stat_grjbr, rx_stat_etherstatsjabbers);
499 UPDATE_STAT64(rx_stat_grxcf, rx_stat_maccontrolframesreceived);
500 UPDATE_STAT64(rx_stat_grxpf, rx_stat_xoffstateentered);
501 UPDATE_STAT64(rx_stat_grxpf, rx_stat_mac_xpf);
503 UPDATE_STAT64(tx_stat_gtxpf, tx_stat_outxoffsent);
504 UPDATE_STAT64(tx_stat_gtxpf, tx_stat_flowcontroldone);
505 UPDATE_STAT64(tx_stat_gt64, tx_stat_etherstatspkts64octets);
506 UPDATE_STAT64(tx_stat_gt127,
507 tx_stat_etherstatspkts65octetsto127octets);
508 UPDATE_STAT64(tx_stat_gt255,
509 tx_stat_etherstatspkts128octetsto255octets);
510 UPDATE_STAT64(tx_stat_gt511,
511 tx_stat_etherstatspkts256octetsto511octets);
512 UPDATE_STAT64(tx_stat_gt1023,
513 tx_stat_etherstatspkts512octetsto1023octets);
514 UPDATE_STAT64(tx_stat_gt1518,
515 tx_stat_etherstatspkts1024octetsto1522octets);
516 UPDATE_STAT64(tx_stat_gt2047, tx_stat_mac_2047);
517 UPDATE_STAT64(tx_stat_gt4095, tx_stat_mac_4095);
518 UPDATE_STAT64(tx_stat_gt9216, tx_stat_mac_9216);
519 UPDATE_STAT64(tx_stat_gt16383, tx_stat_mac_16383);
520 UPDATE_STAT64(tx_stat_gterr,
521 tx_stat_dot3statsinternalmactransmiterrors);
522 UPDATE_STAT64(tx_stat_gtufl, tx_stat_mac_ufl);
525 struct bmac2_stats *new = bnx2x_sp(bp, mac_stats.bmac2_stats);
527 /* the macros below will use "bmac2_stats" type */
528 UPDATE_STAT64(rx_stat_grerb, rx_stat_ifhcinbadoctets);
529 UPDATE_STAT64(rx_stat_grfcs, rx_stat_dot3statsfcserrors);
530 UPDATE_STAT64(rx_stat_grund, rx_stat_etherstatsundersizepkts);
531 UPDATE_STAT64(rx_stat_grovr, rx_stat_dot3statsframestoolong);
532 UPDATE_STAT64(rx_stat_grfrg, rx_stat_etherstatsfragments);
533 UPDATE_STAT64(rx_stat_grjbr, rx_stat_etherstatsjabbers);
534 UPDATE_STAT64(rx_stat_grxcf, rx_stat_maccontrolframesreceived);
535 UPDATE_STAT64(rx_stat_grxpf, rx_stat_xoffstateentered);
536 UPDATE_STAT64(rx_stat_grxpf, rx_stat_mac_xpf);
537 UPDATE_STAT64(tx_stat_gtxpf, tx_stat_outxoffsent);
538 UPDATE_STAT64(tx_stat_gtxpf, tx_stat_flowcontroldone);
539 UPDATE_STAT64(tx_stat_gt64, tx_stat_etherstatspkts64octets);
540 UPDATE_STAT64(tx_stat_gt127,
541 tx_stat_etherstatspkts65octetsto127octets);
542 UPDATE_STAT64(tx_stat_gt255,
543 tx_stat_etherstatspkts128octetsto255octets);
544 UPDATE_STAT64(tx_stat_gt511,
545 tx_stat_etherstatspkts256octetsto511octets);
546 UPDATE_STAT64(tx_stat_gt1023,
547 tx_stat_etherstatspkts512octetsto1023octets);
548 UPDATE_STAT64(tx_stat_gt1518,
549 tx_stat_etherstatspkts1024octetsto1522octets);
550 UPDATE_STAT64(tx_stat_gt2047, tx_stat_mac_2047);
551 UPDATE_STAT64(tx_stat_gt4095, tx_stat_mac_4095);
552 UPDATE_STAT64(tx_stat_gt9216, tx_stat_mac_9216);
553 UPDATE_STAT64(tx_stat_gt16383, tx_stat_mac_16383);
554 UPDATE_STAT64(tx_stat_gterr,
555 tx_stat_dot3statsinternalmactransmiterrors);
556 UPDATE_STAT64(tx_stat_gtufl, tx_stat_mac_ufl);
558 /* collect PFC stats */
559 pstats->pfc_frames_tx_hi = new->tx_stat_gtpp_hi;
560 pstats->pfc_frames_tx_lo = new->tx_stat_gtpp_lo;
562 pstats->pfc_frames_rx_hi = new->rx_stat_grpp_hi;
563 pstats->pfc_frames_rx_lo = new->rx_stat_grpp_lo;
566 estats->pause_frames_received_hi =
567 pstats->mac_stx[1].rx_stat_mac_xpf_hi;
568 estats->pause_frames_received_lo =
569 pstats->mac_stx[1].rx_stat_mac_xpf_lo;
571 estats->pause_frames_sent_hi =
572 pstats->mac_stx[1].tx_stat_outxoffsent_hi;
573 estats->pause_frames_sent_lo =
574 pstats->mac_stx[1].tx_stat_outxoffsent_lo;
576 estats->pfc_frames_received_hi =
577 pstats->pfc_frames_rx_hi;
578 estats->pfc_frames_received_lo =
579 pstats->pfc_frames_rx_lo;
580 estats->pfc_frames_sent_hi =
581 pstats->pfc_frames_tx_hi;
582 estats->pfc_frames_sent_lo =
583 pstats->pfc_frames_tx_lo;
586 static void bnx2x_mstat_stats_update(struct bnx2x *bp)
588 struct host_port_stats *pstats = bnx2x_sp(bp, port_stats);
589 struct bnx2x_eth_stats *estats = &bp->eth_stats;
591 struct mstat_stats *new = bnx2x_sp(bp, mac_stats.mstat_stats);
593 ADD_STAT64(stats_rx.rx_grerb, rx_stat_ifhcinbadoctets);
594 ADD_STAT64(stats_rx.rx_grfcs, rx_stat_dot3statsfcserrors);
595 ADD_STAT64(stats_rx.rx_grund, rx_stat_etherstatsundersizepkts);
596 ADD_STAT64(stats_rx.rx_grovr, rx_stat_dot3statsframestoolong);
597 ADD_STAT64(stats_rx.rx_grfrg, rx_stat_etherstatsfragments);
598 ADD_STAT64(stats_rx.rx_grxcf, rx_stat_maccontrolframesreceived);
599 ADD_STAT64(stats_rx.rx_grxpf, rx_stat_xoffstateentered);
600 ADD_STAT64(stats_rx.rx_grxpf, rx_stat_mac_xpf);
601 ADD_STAT64(stats_tx.tx_gtxpf, tx_stat_outxoffsent);
602 ADD_STAT64(stats_tx.tx_gtxpf, tx_stat_flowcontroldone);
604 /* collect pfc stats */
605 ADD_64(pstats->pfc_frames_tx_hi, new->stats_tx.tx_gtxpp_hi,
606 pstats->pfc_frames_tx_lo, new->stats_tx.tx_gtxpp_lo);
607 ADD_64(pstats->pfc_frames_rx_hi, new->stats_rx.rx_grxpp_hi,
608 pstats->pfc_frames_rx_lo, new->stats_rx.rx_grxpp_lo);
610 ADD_STAT64(stats_tx.tx_gt64, tx_stat_etherstatspkts64octets);
611 ADD_STAT64(stats_tx.tx_gt127,
612 tx_stat_etherstatspkts65octetsto127octets);
613 ADD_STAT64(stats_tx.tx_gt255,
614 tx_stat_etherstatspkts128octetsto255octets);
615 ADD_STAT64(stats_tx.tx_gt511,
616 tx_stat_etherstatspkts256octetsto511octets);
617 ADD_STAT64(stats_tx.tx_gt1023,
618 tx_stat_etherstatspkts512octetsto1023octets);
619 ADD_STAT64(stats_tx.tx_gt1518,
620 tx_stat_etherstatspkts1024octetsto1522octets);
621 ADD_STAT64(stats_tx.tx_gt2047, tx_stat_mac_2047);
623 ADD_STAT64(stats_tx.tx_gt4095, tx_stat_mac_4095);
624 ADD_STAT64(stats_tx.tx_gt9216, tx_stat_mac_9216);
625 ADD_STAT64(stats_tx.tx_gt16383, tx_stat_mac_16383);
627 ADD_STAT64(stats_tx.tx_gterr,
628 tx_stat_dot3statsinternalmactransmiterrors);
629 ADD_STAT64(stats_tx.tx_gtufl, tx_stat_mac_ufl);
631 estats->etherstatspkts1024octetsto1522octets_hi =
632 pstats->mac_stx[1].tx_stat_etherstatspkts1024octetsto1522octets_hi;
633 estats->etherstatspkts1024octetsto1522octets_lo =
634 pstats->mac_stx[1].tx_stat_etherstatspkts1024octetsto1522octets_lo;
636 estats->etherstatspktsover1522octets_hi =
637 pstats->mac_stx[1].tx_stat_mac_2047_hi;
638 estats->etherstatspktsover1522octets_lo =
639 pstats->mac_stx[1].tx_stat_mac_2047_lo;
641 ADD_64(estats->etherstatspktsover1522octets_hi,
642 pstats->mac_stx[1].tx_stat_mac_4095_hi,
643 estats->etherstatspktsover1522octets_lo,
644 pstats->mac_stx[1].tx_stat_mac_4095_lo);
646 ADD_64(estats->etherstatspktsover1522octets_hi,
647 pstats->mac_stx[1].tx_stat_mac_9216_hi,
648 estats->etherstatspktsover1522octets_lo,
649 pstats->mac_stx[1].tx_stat_mac_9216_lo);
651 ADD_64(estats->etherstatspktsover1522octets_hi,
652 pstats->mac_stx[1].tx_stat_mac_16383_hi,
653 estats->etherstatspktsover1522octets_lo,
654 pstats->mac_stx[1].tx_stat_mac_16383_lo);
656 estats->pause_frames_received_hi =
657 pstats->mac_stx[1].rx_stat_mac_xpf_hi;
658 estats->pause_frames_received_lo =
659 pstats->mac_stx[1].rx_stat_mac_xpf_lo;
661 estats->pause_frames_sent_hi =
662 pstats->mac_stx[1].tx_stat_outxoffsent_hi;
663 estats->pause_frames_sent_lo =
664 pstats->mac_stx[1].tx_stat_outxoffsent_lo;
666 estats->pfc_frames_received_hi =
667 pstats->pfc_frames_rx_hi;
668 estats->pfc_frames_received_lo =
669 pstats->pfc_frames_rx_lo;
670 estats->pfc_frames_sent_hi =
671 pstats->pfc_frames_tx_hi;
672 estats->pfc_frames_sent_lo =
673 pstats->pfc_frames_tx_lo;
676 static void bnx2x_emac_stats_update(struct bnx2x *bp)
678 struct emac_stats *new = bnx2x_sp(bp, mac_stats.emac_stats);
679 struct host_port_stats *pstats = bnx2x_sp(bp, port_stats);
680 struct bnx2x_eth_stats *estats = &bp->eth_stats;
682 UPDATE_EXTEND_STAT(rx_stat_ifhcinbadoctets);
683 UPDATE_EXTEND_STAT(tx_stat_ifhcoutbadoctets);
684 UPDATE_EXTEND_STAT(rx_stat_dot3statsfcserrors);
685 UPDATE_EXTEND_STAT(rx_stat_dot3statsalignmenterrors);
686 UPDATE_EXTEND_STAT(rx_stat_dot3statscarriersenseerrors);
687 UPDATE_EXTEND_STAT(rx_stat_falsecarriererrors);
688 UPDATE_EXTEND_STAT(rx_stat_etherstatsundersizepkts);
689 UPDATE_EXTEND_STAT(rx_stat_dot3statsframestoolong);
690 UPDATE_EXTEND_STAT(rx_stat_etherstatsfragments);
691 UPDATE_EXTEND_STAT(rx_stat_etherstatsjabbers);
692 UPDATE_EXTEND_STAT(rx_stat_maccontrolframesreceived);
693 UPDATE_EXTEND_STAT(rx_stat_xoffstateentered);
694 UPDATE_EXTEND_STAT(rx_stat_xonpauseframesreceived);
695 UPDATE_EXTEND_STAT(rx_stat_xoffpauseframesreceived);
696 UPDATE_EXTEND_STAT(tx_stat_outxonsent);
697 UPDATE_EXTEND_STAT(tx_stat_outxoffsent);
698 UPDATE_EXTEND_STAT(tx_stat_flowcontroldone);
699 UPDATE_EXTEND_STAT(tx_stat_etherstatscollisions);
700 UPDATE_EXTEND_STAT(tx_stat_dot3statssinglecollisionframes);
701 UPDATE_EXTEND_STAT(tx_stat_dot3statsmultiplecollisionframes);
702 UPDATE_EXTEND_STAT(tx_stat_dot3statsdeferredtransmissions);
703 UPDATE_EXTEND_STAT(tx_stat_dot3statsexcessivecollisions);
704 UPDATE_EXTEND_STAT(tx_stat_dot3statslatecollisions);
705 UPDATE_EXTEND_STAT(tx_stat_etherstatspkts64octets);
706 UPDATE_EXTEND_STAT(tx_stat_etherstatspkts65octetsto127octets);
707 UPDATE_EXTEND_STAT(tx_stat_etherstatspkts128octetsto255octets);
708 UPDATE_EXTEND_STAT(tx_stat_etherstatspkts256octetsto511octets);
709 UPDATE_EXTEND_STAT(tx_stat_etherstatspkts512octetsto1023octets);
710 UPDATE_EXTEND_STAT(tx_stat_etherstatspkts1024octetsto1522octets);
711 UPDATE_EXTEND_STAT(tx_stat_etherstatspktsover1522octets);
712 UPDATE_EXTEND_STAT(tx_stat_dot3statsinternalmactransmiterrors);
714 estats->pause_frames_received_hi =
715 pstats->mac_stx[1].rx_stat_xonpauseframesreceived_hi;
716 estats->pause_frames_received_lo =
717 pstats->mac_stx[1].rx_stat_xonpauseframesreceived_lo;
718 ADD_64(estats->pause_frames_received_hi,
719 pstats->mac_stx[1].rx_stat_xoffpauseframesreceived_hi,
720 estats->pause_frames_received_lo,
721 pstats->mac_stx[1].rx_stat_xoffpauseframesreceived_lo);
723 estats->pause_frames_sent_hi =
724 pstats->mac_stx[1].tx_stat_outxonsent_hi;
725 estats->pause_frames_sent_lo =
726 pstats->mac_stx[1].tx_stat_outxonsent_lo;
727 ADD_64(estats->pause_frames_sent_hi,
728 pstats->mac_stx[1].tx_stat_outxoffsent_hi,
729 estats->pause_frames_sent_lo,
730 pstats->mac_stx[1].tx_stat_outxoffsent_lo);
733 static int bnx2x_hw_stats_update(struct bnx2x *bp)
735 struct nig_stats *new = bnx2x_sp(bp, nig_stats);
736 struct nig_stats *old = &(bp->port.old_nig_stats);
737 struct host_port_stats *pstats = bnx2x_sp(bp, port_stats);
738 struct bnx2x_eth_stats *estats = &bp->eth_stats;
744 switch (bp->link_vars.mac_type) {
746 bnx2x_bmac_stats_update(bp);
750 bnx2x_emac_stats_update(bp);
755 bnx2x_mstat_stats_update(bp);
758 case MAC_TYPE_NONE: /* unreached */
760 "stats updated by DMAE but no MAC active\n");
763 default: /* unreached */
764 BNX2X_ERR("Unknown MAC type\n");
767 ADD_EXTEND_64(pstats->brb_drop_hi, pstats->brb_drop_lo,
768 new->brb_discard - old->brb_discard);
769 ADD_EXTEND_64(estats->brb_truncate_hi, estats->brb_truncate_lo,
770 new->brb_truncate - old->brb_truncate);
772 if (!CHIP_IS_E3(bp)) {
773 UPDATE_STAT64_NIG(egress_mac_pkt0,
774 etherstatspkts1024octetsto1522octets);
775 UPDATE_STAT64_NIG(egress_mac_pkt1,
776 etherstatspktsover1522octets);
779 memcpy(old, new, sizeof(struct nig_stats));
781 memcpy(&(estats->rx_stat_ifhcinbadoctets_hi), &(pstats->mac_stx[1]),
782 sizeof(struct mac_stx));
783 estats->brb_drop_hi = pstats->brb_drop_hi;
784 estats->brb_drop_lo = pstats->brb_drop_lo;
786 pstats->host_port_stats_counter++;
789 estats->eee_tx_lpi += REG_RD(bp,
790 MISC_REG_CPMU_LP_SM_ENT_CNT_P0);
794 SHMEM_RD(bp, port_mb[BP_PORT(bp)].stat_nig_timer);
795 if (nig_timer_max != estats->nig_timer_max) {
796 estats->nig_timer_max = nig_timer_max;
797 BNX2X_ERR("NIG timer max (%u)\n",
798 estats->nig_timer_max);
805 static int bnx2x_storm_stats_update(struct bnx2x *bp)
807 struct tstorm_per_port_stats *tport =
808 &bp->fw_stats_data->port.tstorm_port_statistics;
809 struct tstorm_per_pf_stats *tfunc =
810 &bp->fw_stats_data->pf.tstorm_pf_statistics;
811 struct host_func_stats *fstats = &bp->func_stats;
812 struct bnx2x_eth_stats *estats = &bp->eth_stats;
813 struct bnx2x_eth_stats_old *estats_old = &bp->eth_stats_old;
814 struct stats_counter *counters = &bp->fw_stats_data->storm_counters;
816 u16 cur_stats_counter;
818 /* Make sure we use the value of the counter
819 * used for sending the last stats ramrod.
821 spin_lock_bh(&bp->stats_lock);
822 cur_stats_counter = bp->stats_counter - 1;
823 spin_unlock_bh(&bp->stats_lock);
825 /* are storm stats valid? */
826 if (le16_to_cpu(counters->xstats_counter) != cur_stats_counter) {
828 "stats not updated by xstorm xstorm counter (0x%x) != stats_counter (0x%x)\n",
829 le16_to_cpu(counters->xstats_counter), bp->stats_counter);
833 if (le16_to_cpu(counters->ustats_counter) != cur_stats_counter) {
835 "stats not updated by ustorm ustorm counter (0x%x) != stats_counter (0x%x)\n",
836 le16_to_cpu(counters->ustats_counter), bp->stats_counter);
840 if (le16_to_cpu(counters->cstats_counter) != cur_stats_counter) {
842 "stats not updated by cstorm cstorm counter (0x%x) != stats_counter (0x%x)\n",
843 le16_to_cpu(counters->cstats_counter), bp->stats_counter);
847 if (le16_to_cpu(counters->tstats_counter) != cur_stats_counter) {
849 "stats not updated by tstorm tstorm counter (0x%x) != stats_counter (0x%x)\n",
850 le16_to_cpu(counters->tstats_counter), bp->stats_counter);
854 estats->error_bytes_received_hi = 0;
855 estats->error_bytes_received_lo = 0;
857 for_each_eth_queue(bp, i) {
858 struct bnx2x_fastpath *fp = &bp->fp[i];
859 struct tstorm_per_queue_stats *tclient =
860 &bp->fw_stats_data->queue_stats[i].
861 tstorm_queue_statistics;
862 struct tstorm_per_queue_stats *old_tclient = &fp->old_tclient;
863 struct ustorm_per_queue_stats *uclient =
864 &bp->fw_stats_data->queue_stats[i].
865 ustorm_queue_statistics;
866 struct ustorm_per_queue_stats *old_uclient = &fp->old_uclient;
867 struct xstorm_per_queue_stats *xclient =
868 &bp->fw_stats_data->queue_stats[i].
869 xstorm_queue_statistics;
870 struct xstorm_per_queue_stats *old_xclient = &fp->old_xclient;
871 struct bnx2x_eth_q_stats *qstats = &fp->eth_q_stats;
872 struct bnx2x_eth_q_stats_old *qstats_old = &fp->eth_q_stats_old;
876 DP(BNX2X_MSG_STATS, "queue[%d]: ucast_sent 0x%x, bcast_sent 0x%x mcast_sent 0x%x\n",
877 i, xclient->ucast_pkts_sent,
878 xclient->bcast_pkts_sent, xclient->mcast_pkts_sent);
880 DP(BNX2X_MSG_STATS, "---------------\n");
882 UPDATE_QSTAT(tclient->rcv_bcast_bytes,
883 total_broadcast_bytes_received);
884 UPDATE_QSTAT(tclient->rcv_mcast_bytes,
885 total_multicast_bytes_received);
886 UPDATE_QSTAT(tclient->rcv_ucast_bytes,
887 total_unicast_bytes_received);
890 * sum to total_bytes_received all
891 * unicast/multicast/broadcast
893 qstats->total_bytes_received_hi =
894 qstats->total_broadcast_bytes_received_hi;
895 qstats->total_bytes_received_lo =
896 qstats->total_broadcast_bytes_received_lo;
898 ADD_64(qstats->total_bytes_received_hi,
899 qstats->total_multicast_bytes_received_hi,
900 qstats->total_bytes_received_lo,
901 qstats->total_multicast_bytes_received_lo);
903 ADD_64(qstats->total_bytes_received_hi,
904 qstats->total_unicast_bytes_received_hi,
905 qstats->total_bytes_received_lo,
906 qstats->total_unicast_bytes_received_lo);
908 qstats->valid_bytes_received_hi =
909 qstats->total_bytes_received_hi;
910 qstats->valid_bytes_received_lo =
911 qstats->total_bytes_received_lo;
914 UPDATE_EXTEND_TSTAT(rcv_ucast_pkts,
915 total_unicast_packets_received);
916 UPDATE_EXTEND_TSTAT(rcv_mcast_pkts,
917 total_multicast_packets_received);
918 UPDATE_EXTEND_TSTAT(rcv_bcast_pkts,
919 total_broadcast_packets_received);
920 UPDATE_EXTEND_E_TSTAT(pkts_too_big_discard,
921 etherstatsoverrsizepkts);
922 UPDATE_EXTEND_E_TSTAT(no_buff_discard, no_buff_discard);
924 SUB_EXTEND_USTAT(ucast_no_buff_pkts,
925 total_unicast_packets_received);
926 SUB_EXTEND_USTAT(mcast_no_buff_pkts,
927 total_multicast_packets_received);
928 SUB_EXTEND_USTAT(bcast_no_buff_pkts,
929 total_broadcast_packets_received);
930 UPDATE_EXTEND_E_USTAT(ucast_no_buff_pkts, no_buff_discard);
931 UPDATE_EXTEND_E_USTAT(mcast_no_buff_pkts, no_buff_discard);
932 UPDATE_EXTEND_E_USTAT(bcast_no_buff_pkts, no_buff_discard);
934 UPDATE_QSTAT(xclient->bcast_bytes_sent,
935 total_broadcast_bytes_transmitted);
936 UPDATE_QSTAT(xclient->mcast_bytes_sent,
937 total_multicast_bytes_transmitted);
938 UPDATE_QSTAT(xclient->ucast_bytes_sent,
939 total_unicast_bytes_transmitted);
942 * sum to total_bytes_transmitted all
943 * unicast/multicast/broadcast
945 qstats->total_bytes_transmitted_hi =
946 qstats->total_unicast_bytes_transmitted_hi;
947 qstats->total_bytes_transmitted_lo =
948 qstats->total_unicast_bytes_transmitted_lo;
950 ADD_64(qstats->total_bytes_transmitted_hi,
951 qstats->total_broadcast_bytes_transmitted_hi,
952 qstats->total_bytes_transmitted_lo,
953 qstats->total_broadcast_bytes_transmitted_lo);
955 ADD_64(qstats->total_bytes_transmitted_hi,
956 qstats->total_multicast_bytes_transmitted_hi,
957 qstats->total_bytes_transmitted_lo,
958 qstats->total_multicast_bytes_transmitted_lo);
960 UPDATE_EXTEND_XSTAT(ucast_pkts_sent,
961 total_unicast_packets_transmitted);
962 UPDATE_EXTEND_XSTAT(mcast_pkts_sent,
963 total_multicast_packets_transmitted);
964 UPDATE_EXTEND_XSTAT(bcast_pkts_sent,
965 total_broadcast_packets_transmitted);
967 UPDATE_EXTEND_TSTAT(checksum_discard,
968 total_packets_received_checksum_discarded);
969 UPDATE_EXTEND_TSTAT(ttl0_discard,
970 total_packets_received_ttl0_discarded);
972 UPDATE_EXTEND_XSTAT(error_drop_pkts,
973 total_transmitted_dropped_packets_error);
975 /* TPA aggregations completed */
976 UPDATE_EXTEND_E_USTAT(coalesced_events, total_tpa_aggregations);
977 /* Number of network frames aggregated by TPA */
978 UPDATE_EXTEND_E_USTAT(coalesced_pkts,
979 total_tpa_aggregated_frames);
980 /* Total number of bytes in completed TPA aggregations */
981 UPDATE_QSTAT(uclient->coalesced_bytes, total_tpa_bytes);
983 UPDATE_ESTAT_QSTAT_64(total_tpa_bytes);
985 UPDATE_FSTAT_QSTAT(total_bytes_received);
986 UPDATE_FSTAT_QSTAT(total_bytes_transmitted);
987 UPDATE_FSTAT_QSTAT(total_unicast_packets_received);
988 UPDATE_FSTAT_QSTAT(total_multicast_packets_received);
989 UPDATE_FSTAT_QSTAT(total_broadcast_packets_received);
990 UPDATE_FSTAT_QSTAT(total_unicast_packets_transmitted);
991 UPDATE_FSTAT_QSTAT(total_multicast_packets_transmitted);
992 UPDATE_FSTAT_QSTAT(total_broadcast_packets_transmitted);
993 UPDATE_FSTAT_QSTAT(valid_bytes_received);
996 ADD_64(estats->total_bytes_received_hi,
997 estats->rx_stat_ifhcinbadoctets_hi,
998 estats->total_bytes_received_lo,
999 estats->rx_stat_ifhcinbadoctets_lo);
1001 ADD_64(estats->total_bytes_received_hi,
1002 le32_to_cpu(tfunc->rcv_error_bytes.hi),
1003 estats->total_bytes_received_lo,
1004 le32_to_cpu(tfunc->rcv_error_bytes.lo));
1006 ADD_64(estats->error_bytes_received_hi,
1007 le32_to_cpu(tfunc->rcv_error_bytes.hi),
1008 estats->error_bytes_received_lo,
1009 le32_to_cpu(tfunc->rcv_error_bytes.lo));
1011 UPDATE_ESTAT(etherstatsoverrsizepkts, rx_stat_dot3statsframestoolong);
1013 ADD_64(estats->error_bytes_received_hi,
1014 estats->rx_stat_ifhcinbadoctets_hi,
1015 estats->error_bytes_received_lo,
1016 estats->rx_stat_ifhcinbadoctets_lo);
1019 struct bnx2x_fw_port_stats_old *fwstats = &bp->fw_stats_old;
1020 UPDATE_FW_STAT(mac_filter_discard);
1021 UPDATE_FW_STAT(mf_tag_discard);
1022 UPDATE_FW_STAT(brb_truncate_discard);
1023 UPDATE_FW_STAT(mac_discard);
1026 fstats->host_func_stats_start = ++fstats->host_func_stats_end;
1028 bp->stats_pending = 0;
1033 static void bnx2x_net_stats_update(struct bnx2x *bp)
1035 struct bnx2x_eth_stats *estats = &bp->eth_stats;
1036 struct net_device_stats *nstats = &bp->dev->stats;
1040 nstats->rx_packets =
1041 bnx2x_hilo(&estats->total_unicast_packets_received_hi) +
1042 bnx2x_hilo(&estats->total_multicast_packets_received_hi) +
1043 bnx2x_hilo(&estats->total_broadcast_packets_received_hi);
1045 nstats->tx_packets =
1046 bnx2x_hilo(&estats->total_unicast_packets_transmitted_hi) +
1047 bnx2x_hilo(&estats->total_multicast_packets_transmitted_hi) +
1048 bnx2x_hilo(&estats->total_broadcast_packets_transmitted_hi);
1050 nstats->rx_bytes = bnx2x_hilo(&estats->total_bytes_received_hi);
1052 nstats->tx_bytes = bnx2x_hilo(&estats->total_bytes_transmitted_hi);
1054 tmp = estats->mac_discard;
1055 for_each_rx_queue(bp, i)
1056 tmp += le32_to_cpu(bp->fp[i].old_tclient.checksum_discard);
1057 nstats->rx_dropped = tmp + bp->net_stats_old.rx_dropped;
1059 nstats->tx_dropped = 0;
1062 bnx2x_hilo(&estats->total_multicast_packets_received_hi);
1064 nstats->collisions =
1065 bnx2x_hilo(&estats->tx_stat_etherstatscollisions_hi);
1067 nstats->rx_length_errors =
1068 bnx2x_hilo(&estats->rx_stat_etherstatsundersizepkts_hi) +
1069 bnx2x_hilo(&estats->etherstatsoverrsizepkts_hi);
1070 nstats->rx_over_errors = bnx2x_hilo(&estats->brb_drop_hi) +
1071 bnx2x_hilo(&estats->brb_truncate_hi);
1072 nstats->rx_crc_errors =
1073 bnx2x_hilo(&estats->rx_stat_dot3statsfcserrors_hi);
1074 nstats->rx_frame_errors =
1075 bnx2x_hilo(&estats->rx_stat_dot3statsalignmenterrors_hi);
1076 nstats->rx_fifo_errors = bnx2x_hilo(&estats->no_buff_discard_hi);
1077 nstats->rx_missed_errors = 0;
1079 nstats->rx_errors = nstats->rx_length_errors +
1080 nstats->rx_over_errors +
1081 nstats->rx_crc_errors +
1082 nstats->rx_frame_errors +
1083 nstats->rx_fifo_errors +
1084 nstats->rx_missed_errors;
1086 nstats->tx_aborted_errors =
1087 bnx2x_hilo(&estats->tx_stat_dot3statslatecollisions_hi) +
1088 bnx2x_hilo(&estats->tx_stat_dot3statsexcessivecollisions_hi);
1089 nstats->tx_carrier_errors =
1090 bnx2x_hilo(&estats->rx_stat_dot3statscarriersenseerrors_hi);
1091 nstats->tx_fifo_errors = 0;
1092 nstats->tx_heartbeat_errors = 0;
1093 nstats->tx_window_errors = 0;
1095 nstats->tx_errors = nstats->tx_aborted_errors +
1096 nstats->tx_carrier_errors +
1097 bnx2x_hilo(&estats->tx_stat_dot3statsinternalmactransmiterrors_hi);
1100 static void bnx2x_drv_stats_update(struct bnx2x *bp)
1102 struct bnx2x_eth_stats *estats = &bp->eth_stats;
1105 for_each_queue(bp, i) {
1106 struct bnx2x_eth_q_stats *qstats = &bp->fp[i].eth_q_stats;
1107 struct bnx2x_eth_q_stats_old *qstats_old =
1108 &bp->fp[i].eth_q_stats_old;
1110 UPDATE_ESTAT_QSTAT(driver_xoff);
1111 UPDATE_ESTAT_QSTAT(rx_err_discard_pkt);
1112 UPDATE_ESTAT_QSTAT(rx_skb_alloc_failed);
1113 UPDATE_ESTAT_QSTAT(hw_csum_err);
1117 static bool bnx2x_edebug_stats_stopped(struct bnx2x *bp)
1121 if (SHMEM2_HAS(bp, edebug_driver_if[1])) {
1122 val = SHMEM2_RD(bp, edebug_driver_if[1]);
1124 if (val == EDEBUG_DRIVER_IF_OP_CODE_DISABLE_STAT)
1131 static void bnx2x_stats_update(struct bnx2x *bp)
1133 u32 *stats_comp = bnx2x_sp(bp, stats_comp);
1135 if (bnx2x_edebug_stats_stopped(bp))
1138 if (*stats_comp != DMAE_COMP_VAL)
1142 bnx2x_hw_stats_update(bp);
1144 if (bnx2x_storm_stats_update(bp) && (bp->stats_pending++ == 3)) {
1145 BNX2X_ERR("storm stats were not updated for 3 times\n");
1150 bnx2x_net_stats_update(bp);
1151 bnx2x_drv_stats_update(bp);
1153 if (netif_msg_timer(bp)) {
1154 struct bnx2x_eth_stats *estats = &bp->eth_stats;
1156 netdev_dbg(bp->dev, "brb drops %u brb truncate %u\n",
1157 estats->brb_drop_lo, estats->brb_truncate_lo);
1160 bnx2x_hw_stats_post(bp);
1161 bnx2x_storm_stats_post(bp);
1164 static void bnx2x_port_stats_stop(struct bnx2x *bp)
1166 struct dmae_command *dmae;
1168 int loader_idx = PMF_DMAE_C(bp);
1169 u32 *stats_comp = bnx2x_sp(bp, stats_comp);
1171 bp->executer_idx = 0;
1173 opcode = bnx2x_dmae_opcode(bp, DMAE_SRC_PCI, DMAE_DST_GRC, false, 0);
1175 if (bp->port.port_stx) {
1177 dmae = bnx2x_sp(bp, dmae[bp->executer_idx++]);
1179 dmae->opcode = bnx2x_dmae_opcode_add_comp(
1180 opcode, DMAE_COMP_GRC);
1182 dmae->opcode = bnx2x_dmae_opcode_add_comp(
1183 opcode, DMAE_COMP_PCI);
1185 dmae->src_addr_lo = U64_LO(bnx2x_sp_mapping(bp, port_stats));
1186 dmae->src_addr_hi = U64_HI(bnx2x_sp_mapping(bp, port_stats));
1187 dmae->dst_addr_lo = bp->port.port_stx >> 2;
1188 dmae->dst_addr_hi = 0;
1189 dmae->len = bnx2x_get_port_stats_dma_len(bp);
1191 dmae->comp_addr_lo = dmae_reg_go_c[loader_idx] >> 2;
1192 dmae->comp_addr_hi = 0;
1195 dmae->comp_addr_lo =
1196 U64_LO(bnx2x_sp_mapping(bp, stats_comp));
1197 dmae->comp_addr_hi =
1198 U64_HI(bnx2x_sp_mapping(bp, stats_comp));
1199 dmae->comp_val = DMAE_COMP_VAL;
1207 dmae = bnx2x_sp(bp, dmae[bp->executer_idx++]);
1209 bnx2x_dmae_opcode_add_comp(opcode, DMAE_COMP_PCI);
1210 dmae->src_addr_lo = U64_LO(bnx2x_sp_mapping(bp, func_stats));
1211 dmae->src_addr_hi = U64_HI(bnx2x_sp_mapping(bp, func_stats));
1212 dmae->dst_addr_lo = bp->func_stx >> 2;
1213 dmae->dst_addr_hi = 0;
1214 dmae->len = sizeof(struct host_func_stats) >> 2;
1215 dmae->comp_addr_lo = U64_LO(bnx2x_sp_mapping(bp, stats_comp));
1216 dmae->comp_addr_hi = U64_HI(bnx2x_sp_mapping(bp, stats_comp));
1217 dmae->comp_val = DMAE_COMP_VAL;
1223 static void bnx2x_stats_stop(struct bnx2x *bp)
1227 bnx2x_stats_comp(bp);
1230 update = (bnx2x_hw_stats_update(bp) == 0);
1232 update |= (bnx2x_storm_stats_update(bp) == 0);
1235 bnx2x_net_stats_update(bp);
1238 bnx2x_port_stats_stop(bp);
1240 bnx2x_hw_stats_post(bp);
1241 bnx2x_stats_comp(bp);
1245 static void bnx2x_stats_do_nothing(struct bnx2x *bp)
1249 static const struct {
1250 void (*action)(struct bnx2x *bp);
1251 enum bnx2x_stats_state next_state;
1252 } bnx2x_stats_stm[STATS_STATE_MAX][STATS_EVENT_MAX] = {
1255 /* DISABLED PMF */ {bnx2x_stats_pmf_update, STATS_STATE_DISABLED},
1256 /* LINK_UP */ {bnx2x_stats_start, STATS_STATE_ENABLED},
1257 /* UPDATE */ {bnx2x_stats_do_nothing, STATS_STATE_DISABLED},
1258 /* STOP */ {bnx2x_stats_do_nothing, STATS_STATE_DISABLED}
1261 /* ENABLED PMF */ {bnx2x_stats_pmf_start, STATS_STATE_ENABLED},
1262 /* LINK_UP */ {bnx2x_stats_restart, STATS_STATE_ENABLED},
1263 /* UPDATE */ {bnx2x_stats_update, STATS_STATE_ENABLED},
1264 /* STOP */ {bnx2x_stats_stop, STATS_STATE_DISABLED}
1268 void bnx2x_stats_handle(struct bnx2x *bp, enum bnx2x_stats_event event)
1270 enum bnx2x_stats_state state;
1271 if (unlikely(bp->panic))
1274 spin_lock_bh(&bp->stats_lock);
1275 state = bp->stats_state;
1276 bp->stats_state = bnx2x_stats_stm[state][event].next_state;
1277 spin_unlock_bh(&bp->stats_lock);
1279 bnx2x_stats_stm[state][event].action(bp);
1281 if ((event != STATS_EVENT_UPDATE) || netif_msg_timer(bp))
1282 DP(BNX2X_MSG_STATS, "state %d -> event %d -> state %d\n",
1283 state, event, bp->stats_state);
1286 static void bnx2x_port_stats_base_init(struct bnx2x *bp)
1288 struct dmae_command *dmae;
1289 u32 *stats_comp = bnx2x_sp(bp, stats_comp);
1292 if (!bp->port.pmf || !bp->port.port_stx) {
1293 BNX2X_ERR("BUG!\n");
1297 bp->executer_idx = 0;
1299 dmae = bnx2x_sp(bp, dmae[bp->executer_idx++]);
1300 dmae->opcode = bnx2x_dmae_opcode(bp, DMAE_SRC_PCI, DMAE_DST_GRC,
1301 true, DMAE_COMP_PCI);
1302 dmae->src_addr_lo = U64_LO(bnx2x_sp_mapping(bp, port_stats));
1303 dmae->src_addr_hi = U64_HI(bnx2x_sp_mapping(bp, port_stats));
1304 dmae->dst_addr_lo = bp->port.port_stx >> 2;
1305 dmae->dst_addr_hi = 0;
1306 dmae->len = bnx2x_get_port_stats_dma_len(bp);
1307 dmae->comp_addr_lo = U64_LO(bnx2x_sp_mapping(bp, stats_comp));
1308 dmae->comp_addr_hi = U64_HI(bnx2x_sp_mapping(bp, stats_comp));
1309 dmae->comp_val = DMAE_COMP_VAL;
1312 bnx2x_hw_stats_post(bp);
1313 bnx2x_stats_comp(bp);
1317 * This function will prepare the statistics ramrod data the way
1318 * we will only have to increment the statistics counter and
1319 * send the ramrod each time we have to.
1323 static void bnx2x_prep_fw_stats_req(struct bnx2x *bp)
1326 int first_queue_query_index;
1327 struct stats_query_header *stats_hdr = &bp->fw_stats_req->hdr;
1329 dma_addr_t cur_data_offset;
1330 struct stats_query_entry *cur_query_entry;
1332 stats_hdr->cmd_num = bp->fw_stats_num;
1333 stats_hdr->drv_stats_counter = 0;
1335 /* storm_counters struct contains the counters of completed
1336 * statistics requests per storm which are incremented by FW
1337 * each time it completes hadning a statistics ramrod. We will
1338 * check these counters in the timer handler and discard a
1339 * (statistics) ramrod completion.
1341 cur_data_offset = bp->fw_stats_data_mapping +
1342 offsetof(struct bnx2x_fw_stats_data, storm_counters);
1344 stats_hdr->stats_counters_addrs.hi =
1345 cpu_to_le32(U64_HI(cur_data_offset));
1346 stats_hdr->stats_counters_addrs.lo =
1347 cpu_to_le32(U64_LO(cur_data_offset));
1349 /* prepare to the first stats ramrod (will be completed with
1350 * the counters equal to zero) - init counters to somethig different.
1352 memset(&bp->fw_stats_data->storm_counters, 0xff,
1353 sizeof(struct stats_counter));
1355 /**** Port FW statistics data ****/
1356 cur_data_offset = bp->fw_stats_data_mapping +
1357 offsetof(struct bnx2x_fw_stats_data, port);
1359 cur_query_entry = &bp->fw_stats_req->query[BNX2X_PORT_QUERY_IDX];
1361 cur_query_entry->kind = STATS_TYPE_PORT;
1362 /* For port query index is a DONT CARE */
1363 cur_query_entry->index = BP_PORT(bp);
1364 /* For port query funcID is a DONT CARE */
1365 cur_query_entry->funcID = cpu_to_le16(BP_FUNC(bp));
1366 cur_query_entry->address.hi = cpu_to_le32(U64_HI(cur_data_offset));
1367 cur_query_entry->address.lo = cpu_to_le32(U64_LO(cur_data_offset));
1369 /**** PF FW statistics data ****/
1370 cur_data_offset = bp->fw_stats_data_mapping +
1371 offsetof(struct bnx2x_fw_stats_data, pf);
1373 cur_query_entry = &bp->fw_stats_req->query[BNX2X_PF_QUERY_IDX];
1375 cur_query_entry->kind = STATS_TYPE_PF;
1376 /* For PF query index is a DONT CARE */
1377 cur_query_entry->index = BP_PORT(bp);
1378 cur_query_entry->funcID = cpu_to_le16(BP_FUNC(bp));
1379 cur_query_entry->address.hi = cpu_to_le32(U64_HI(cur_data_offset));
1380 cur_query_entry->address.lo = cpu_to_le32(U64_LO(cur_data_offset));
1382 /**** FCoE FW statistics data ****/
1384 cur_data_offset = bp->fw_stats_data_mapping +
1385 offsetof(struct bnx2x_fw_stats_data, fcoe);
1388 &bp->fw_stats_req->query[BNX2X_FCOE_QUERY_IDX];
1390 cur_query_entry->kind = STATS_TYPE_FCOE;
1391 /* For FCoE query index is a DONT CARE */
1392 cur_query_entry->index = BP_PORT(bp);
1393 cur_query_entry->funcID = cpu_to_le16(BP_FUNC(bp));
1394 cur_query_entry->address.hi =
1395 cpu_to_le32(U64_HI(cur_data_offset));
1396 cur_query_entry->address.lo =
1397 cpu_to_le32(U64_LO(cur_data_offset));
1400 /**** Clients' queries ****/
1401 cur_data_offset = bp->fw_stats_data_mapping +
1402 offsetof(struct bnx2x_fw_stats_data, queue_stats);
1404 /* first queue query index depends whether FCoE offloaded request will
1405 * be included in the ramrod
1408 first_queue_query_index = BNX2X_FIRST_QUEUE_QUERY_IDX;
1410 first_queue_query_index = BNX2X_FIRST_QUEUE_QUERY_IDX - 1;
1412 for_each_eth_queue(bp, i) {
1415 query[first_queue_query_index + i];
1417 cur_query_entry->kind = STATS_TYPE_QUEUE;
1418 cur_query_entry->index = bnx2x_stats_id(&bp->fp[i]);
1419 cur_query_entry->funcID = cpu_to_le16(BP_FUNC(bp));
1420 cur_query_entry->address.hi =
1421 cpu_to_le32(U64_HI(cur_data_offset));
1422 cur_query_entry->address.lo =
1423 cpu_to_le32(U64_LO(cur_data_offset));
1425 cur_data_offset += sizeof(struct per_queue_stats);
1428 /* add FCoE queue query if needed */
1432 query[first_queue_query_index + i];
1434 cur_query_entry->kind = STATS_TYPE_QUEUE;
1435 cur_query_entry->index = bnx2x_stats_id(&bp->fp[FCOE_IDX]);
1436 cur_query_entry->funcID = cpu_to_le16(BP_FUNC(bp));
1437 cur_query_entry->address.hi =
1438 cpu_to_le32(U64_HI(cur_data_offset));
1439 cur_query_entry->address.lo =
1440 cpu_to_le32(U64_LO(cur_data_offset));
1444 void bnx2x_stats_init(struct bnx2x *bp)
1446 int /*abs*/port = BP_PORT(bp);
1447 int mb_idx = BP_FW_MB_IDX(bp);
1450 bp->stats_pending = 0;
1451 bp->executer_idx = 0;
1452 bp->stats_counter = 0;
1454 /* port and func stats for management */
1455 if (!BP_NOMCP(bp)) {
1456 bp->port.port_stx = SHMEM_RD(bp, port_mb[port].port_stx);
1457 bp->func_stx = SHMEM_RD(bp, func_mb[mb_idx].fw_mb_param);
1460 bp->port.port_stx = 0;
1463 DP(BNX2X_MSG_STATS, "port_stx 0x%x func_stx 0x%x\n",
1464 bp->port.port_stx, bp->func_stx);
1466 /* pmf should retrieve port statistics from SP on a non-init*/
1467 if (!bp->stats_init && bp->port.pmf && bp->port.port_stx)
1468 bnx2x_stats_handle(bp, STATS_EVENT_PMF);
1472 memset(&(bp->port.old_nig_stats), 0, sizeof(struct nig_stats));
1473 bp->port.old_nig_stats.brb_discard =
1474 REG_RD(bp, NIG_REG_STAT0_BRB_DISCARD + port*0x38);
1475 bp->port.old_nig_stats.brb_truncate =
1476 REG_RD(bp, NIG_REG_STAT0_BRB_TRUNCATE + port*0x38);
1477 if (!CHIP_IS_E3(bp)) {
1478 REG_RD_DMAE(bp, NIG_REG_STAT0_EGRESS_MAC_PKT0 + port*0x50,
1479 &(bp->port.old_nig_stats.egress_mac_pkt0_lo), 2);
1480 REG_RD_DMAE(bp, NIG_REG_STAT0_EGRESS_MAC_PKT1 + port*0x50,
1481 &(bp->port.old_nig_stats.egress_mac_pkt1_lo), 2);
1484 /* function stats */
1485 for_each_queue(bp, i) {
1486 struct bnx2x_fastpath *fp = &bp->fp[i];
1488 memset(&fp->old_tclient, 0, sizeof(fp->old_tclient));
1489 memset(&fp->old_uclient, 0, sizeof(fp->old_uclient));
1490 memset(&fp->old_xclient, 0, sizeof(fp->old_xclient));
1491 if (bp->stats_init) {
1492 memset(&fp->eth_q_stats, 0, sizeof(fp->eth_q_stats));
1493 memset(&fp->eth_q_stats_old, 0,
1494 sizeof(fp->eth_q_stats_old));
1498 /* Prepare statistics ramrod data */
1499 bnx2x_prep_fw_stats_req(bp);
1501 memset(&bp->dev->stats, 0, sizeof(bp->dev->stats));
1502 if (bp->stats_init) {
1503 memset(&bp->net_stats_old, 0, sizeof(bp->net_stats_old));
1504 memset(&bp->fw_stats_old, 0, sizeof(bp->fw_stats_old));
1505 memset(&bp->eth_stats_old, 0, sizeof(bp->eth_stats_old));
1506 memset(&bp->eth_stats, 0, sizeof(bp->eth_stats));
1507 memset(&bp->func_stats, 0, sizeof(bp->func_stats));
1509 /* Clean SP from previous statistics */
1511 memset(bnx2x_sp(bp, func_stats), 0,
1512 sizeof(struct host_func_stats));
1513 bnx2x_func_stats_init(bp);
1514 bnx2x_hw_stats_post(bp);
1515 bnx2x_stats_comp(bp);
1519 bp->stats_state = STATS_STATE_DISABLED;
1521 if (bp->port.pmf && bp->port.port_stx)
1522 bnx2x_port_stats_base_init(bp);
1524 /* mark the end of statistics initializiation */
1525 bp->stats_init = false;
1528 void bnx2x_save_statistics(struct bnx2x *bp)
1531 struct net_device_stats *nstats = &bp->dev->stats;
1533 /* save queue statistics */
1534 for_each_eth_queue(bp, i) {
1535 struct bnx2x_fastpath *fp = &bp->fp[i];
1536 struct bnx2x_eth_q_stats *qstats = &fp->eth_q_stats;
1537 struct bnx2x_eth_q_stats_old *qstats_old = &fp->eth_q_stats_old;
1539 UPDATE_QSTAT_OLD(total_unicast_bytes_received_hi);
1540 UPDATE_QSTAT_OLD(total_unicast_bytes_received_lo);
1541 UPDATE_QSTAT_OLD(total_broadcast_bytes_received_hi);
1542 UPDATE_QSTAT_OLD(total_broadcast_bytes_received_lo);
1543 UPDATE_QSTAT_OLD(total_multicast_bytes_received_hi);
1544 UPDATE_QSTAT_OLD(total_multicast_bytes_received_lo);
1545 UPDATE_QSTAT_OLD(total_unicast_bytes_transmitted_hi);
1546 UPDATE_QSTAT_OLD(total_unicast_bytes_transmitted_lo);
1547 UPDATE_QSTAT_OLD(total_broadcast_bytes_transmitted_hi);
1548 UPDATE_QSTAT_OLD(total_broadcast_bytes_transmitted_lo);
1549 UPDATE_QSTAT_OLD(total_multicast_bytes_transmitted_hi);
1550 UPDATE_QSTAT_OLD(total_multicast_bytes_transmitted_lo);
1551 UPDATE_QSTAT_OLD(total_tpa_bytes_hi);
1552 UPDATE_QSTAT_OLD(total_tpa_bytes_lo);
1555 /* save net_device_stats statistics */
1556 bp->net_stats_old.rx_dropped = nstats->rx_dropped;
1558 /* store port firmware statistics */
1559 if (bp->port.pmf && IS_MF(bp)) {
1560 struct bnx2x_eth_stats *estats = &bp->eth_stats;
1561 struct bnx2x_fw_port_stats_old *fwstats = &bp->fw_stats_old;
1562 UPDATE_FW_STAT_OLD(mac_filter_discard);
1563 UPDATE_FW_STAT_OLD(mf_tag_discard);
1564 UPDATE_FW_STAT_OLD(brb_truncate_discard);
1565 UPDATE_FW_STAT_OLD(mac_discard);
1569 void bnx2x_afex_collect_stats(struct bnx2x *bp, void *void_afex_stats,
1573 struct afex_stats *afex_stats = (struct afex_stats *)void_afex_stats;
1574 struct bnx2x_eth_stats *estats = &bp->eth_stats;
1575 struct per_queue_stats *fcoe_q_stats =
1576 &bp->fw_stats_data->queue_stats[FCOE_IDX];
1578 struct tstorm_per_queue_stats *fcoe_q_tstorm_stats =
1579 &fcoe_q_stats->tstorm_queue_statistics;
1581 struct ustorm_per_queue_stats *fcoe_q_ustorm_stats =
1582 &fcoe_q_stats->ustorm_queue_statistics;
1584 struct xstorm_per_queue_stats *fcoe_q_xstorm_stats =
1585 &fcoe_q_stats->xstorm_queue_statistics;
1587 struct fcoe_statistics_params *fw_fcoe_stat =
1588 &bp->fw_stats_data->fcoe;
1590 memset(afex_stats, 0, sizeof(struct afex_stats));
1592 for_each_eth_queue(bp, i) {
1593 struct bnx2x_fastpath *fp = &bp->fp[i];
1594 struct bnx2x_eth_q_stats *qstats = &fp->eth_q_stats;
1596 ADD_64(afex_stats->rx_unicast_bytes_hi,
1597 qstats->total_unicast_bytes_received_hi,
1598 afex_stats->rx_unicast_bytes_lo,
1599 qstats->total_unicast_bytes_received_lo);
1601 ADD_64(afex_stats->rx_broadcast_bytes_hi,
1602 qstats->total_broadcast_bytes_received_hi,
1603 afex_stats->rx_broadcast_bytes_lo,
1604 qstats->total_broadcast_bytes_received_lo);
1606 ADD_64(afex_stats->rx_multicast_bytes_hi,
1607 qstats->total_multicast_bytes_received_hi,
1608 afex_stats->rx_multicast_bytes_lo,
1609 qstats->total_multicast_bytes_received_lo);
1611 ADD_64(afex_stats->rx_unicast_frames_hi,
1612 qstats->total_unicast_packets_received_hi,
1613 afex_stats->rx_unicast_frames_lo,
1614 qstats->total_unicast_packets_received_lo);
1616 ADD_64(afex_stats->rx_broadcast_frames_hi,
1617 qstats->total_broadcast_packets_received_hi,
1618 afex_stats->rx_broadcast_frames_lo,
1619 qstats->total_broadcast_packets_received_lo);
1621 ADD_64(afex_stats->rx_multicast_frames_hi,
1622 qstats->total_multicast_packets_received_hi,
1623 afex_stats->rx_multicast_frames_lo,
1624 qstats->total_multicast_packets_received_lo);
1626 /* sum to rx_frames_discarded all discraded
1627 * packets due to size, ttl0 and checksum
1629 ADD_64(afex_stats->rx_frames_discarded_hi,
1630 qstats->total_packets_received_checksum_discarded_hi,
1631 afex_stats->rx_frames_discarded_lo,
1632 qstats->total_packets_received_checksum_discarded_lo);
1634 ADD_64(afex_stats->rx_frames_discarded_hi,
1635 qstats->total_packets_received_ttl0_discarded_hi,
1636 afex_stats->rx_frames_discarded_lo,
1637 qstats->total_packets_received_ttl0_discarded_lo);
1639 ADD_64(afex_stats->rx_frames_discarded_hi,
1640 qstats->etherstatsoverrsizepkts_hi,
1641 afex_stats->rx_frames_discarded_lo,
1642 qstats->etherstatsoverrsizepkts_lo);
1644 ADD_64(afex_stats->rx_frames_dropped_hi,
1645 qstats->no_buff_discard_hi,
1646 afex_stats->rx_frames_dropped_lo,
1647 qstats->no_buff_discard_lo);
1649 ADD_64(afex_stats->tx_unicast_bytes_hi,
1650 qstats->total_unicast_bytes_transmitted_hi,
1651 afex_stats->tx_unicast_bytes_lo,
1652 qstats->total_unicast_bytes_transmitted_lo);
1654 ADD_64(afex_stats->tx_broadcast_bytes_hi,
1655 qstats->total_broadcast_bytes_transmitted_hi,
1656 afex_stats->tx_broadcast_bytes_lo,
1657 qstats->total_broadcast_bytes_transmitted_lo);
1659 ADD_64(afex_stats->tx_multicast_bytes_hi,
1660 qstats->total_multicast_bytes_transmitted_hi,
1661 afex_stats->tx_multicast_bytes_lo,
1662 qstats->total_multicast_bytes_transmitted_lo);
1664 ADD_64(afex_stats->tx_unicast_frames_hi,
1665 qstats->total_unicast_packets_transmitted_hi,
1666 afex_stats->tx_unicast_frames_lo,
1667 qstats->total_unicast_packets_transmitted_lo);
1669 ADD_64(afex_stats->tx_broadcast_frames_hi,
1670 qstats->total_broadcast_packets_transmitted_hi,
1671 afex_stats->tx_broadcast_frames_lo,
1672 qstats->total_broadcast_packets_transmitted_lo);
1674 ADD_64(afex_stats->tx_multicast_frames_hi,
1675 qstats->total_multicast_packets_transmitted_hi,
1676 afex_stats->tx_multicast_frames_lo,
1677 qstats->total_multicast_packets_transmitted_lo);
1679 ADD_64(afex_stats->tx_frames_dropped_hi,
1680 qstats->total_transmitted_dropped_packets_error_hi,
1681 afex_stats->tx_frames_dropped_lo,
1682 qstats->total_transmitted_dropped_packets_error_lo);
1685 /* now add FCoE statistics which are collected separately
1686 * (both offloaded and non offloaded)
1689 ADD_64_LE(afex_stats->rx_unicast_bytes_hi,
1691 afex_stats->rx_unicast_bytes_lo,
1692 fw_fcoe_stat->rx_stat0.fcoe_rx_byte_cnt);
1694 ADD_64_LE(afex_stats->rx_unicast_bytes_hi,
1695 fcoe_q_tstorm_stats->rcv_ucast_bytes.hi,
1696 afex_stats->rx_unicast_bytes_lo,
1697 fcoe_q_tstorm_stats->rcv_ucast_bytes.lo);
1699 ADD_64_LE(afex_stats->rx_broadcast_bytes_hi,
1700 fcoe_q_tstorm_stats->rcv_bcast_bytes.hi,
1701 afex_stats->rx_broadcast_bytes_lo,
1702 fcoe_q_tstorm_stats->rcv_bcast_bytes.lo);
1704 ADD_64_LE(afex_stats->rx_multicast_bytes_hi,
1705 fcoe_q_tstorm_stats->rcv_mcast_bytes.hi,
1706 afex_stats->rx_multicast_bytes_lo,
1707 fcoe_q_tstorm_stats->rcv_mcast_bytes.lo);
1709 ADD_64_LE(afex_stats->rx_unicast_frames_hi,
1711 afex_stats->rx_unicast_frames_lo,
1712 fw_fcoe_stat->rx_stat0.fcoe_rx_pkt_cnt);
1714 ADD_64_LE(afex_stats->rx_unicast_frames_hi,
1716 afex_stats->rx_unicast_frames_lo,
1717 fcoe_q_tstorm_stats->rcv_ucast_pkts);
1719 ADD_64_LE(afex_stats->rx_broadcast_frames_hi,
1721 afex_stats->rx_broadcast_frames_lo,
1722 fcoe_q_tstorm_stats->rcv_bcast_pkts);
1724 ADD_64_LE(afex_stats->rx_multicast_frames_hi,
1726 afex_stats->rx_multicast_frames_lo,
1727 fcoe_q_tstorm_stats->rcv_ucast_pkts);
1729 ADD_64_LE(afex_stats->rx_frames_discarded_hi,
1731 afex_stats->rx_frames_discarded_lo,
1732 fcoe_q_tstorm_stats->checksum_discard);
1734 ADD_64_LE(afex_stats->rx_frames_discarded_hi,
1736 afex_stats->rx_frames_discarded_lo,
1737 fcoe_q_tstorm_stats->pkts_too_big_discard);
1739 ADD_64_LE(afex_stats->rx_frames_discarded_hi,
1741 afex_stats->rx_frames_discarded_lo,
1742 fcoe_q_tstorm_stats->ttl0_discard);
1744 ADD_64_LE16(afex_stats->rx_frames_dropped_hi,
1746 afex_stats->rx_frames_dropped_lo,
1747 fcoe_q_tstorm_stats->no_buff_discard);
1749 ADD_64_LE(afex_stats->rx_frames_dropped_hi,
1751 afex_stats->rx_frames_dropped_lo,
1752 fcoe_q_ustorm_stats->ucast_no_buff_pkts);
1754 ADD_64_LE(afex_stats->rx_frames_dropped_hi,
1756 afex_stats->rx_frames_dropped_lo,
1757 fcoe_q_ustorm_stats->mcast_no_buff_pkts);
1759 ADD_64_LE(afex_stats->rx_frames_dropped_hi,
1761 afex_stats->rx_frames_dropped_lo,
1762 fcoe_q_ustorm_stats->bcast_no_buff_pkts);
1764 ADD_64_LE(afex_stats->rx_frames_dropped_hi,
1766 afex_stats->rx_frames_dropped_lo,
1767 fw_fcoe_stat->rx_stat1.fcoe_rx_drop_pkt_cnt);
1769 ADD_64_LE(afex_stats->rx_frames_dropped_hi,
1771 afex_stats->rx_frames_dropped_lo,
1772 fw_fcoe_stat->rx_stat2.fcoe_rx_drop_pkt_cnt);
1774 ADD_64_LE(afex_stats->tx_unicast_bytes_hi,
1776 afex_stats->tx_unicast_bytes_lo,
1777 fw_fcoe_stat->tx_stat.fcoe_tx_byte_cnt);
1779 ADD_64_LE(afex_stats->tx_unicast_bytes_hi,
1780 fcoe_q_xstorm_stats->ucast_bytes_sent.hi,
1781 afex_stats->tx_unicast_bytes_lo,
1782 fcoe_q_xstorm_stats->ucast_bytes_sent.lo);
1784 ADD_64_LE(afex_stats->tx_broadcast_bytes_hi,
1785 fcoe_q_xstorm_stats->bcast_bytes_sent.hi,
1786 afex_stats->tx_broadcast_bytes_lo,
1787 fcoe_q_xstorm_stats->bcast_bytes_sent.lo);
1789 ADD_64_LE(afex_stats->tx_multicast_bytes_hi,
1790 fcoe_q_xstorm_stats->mcast_bytes_sent.hi,
1791 afex_stats->tx_multicast_bytes_lo,
1792 fcoe_q_xstorm_stats->mcast_bytes_sent.lo);
1794 ADD_64_LE(afex_stats->tx_unicast_frames_hi,
1796 afex_stats->tx_unicast_frames_lo,
1797 fw_fcoe_stat->tx_stat.fcoe_tx_pkt_cnt);
1799 ADD_64_LE(afex_stats->tx_unicast_frames_hi,
1801 afex_stats->tx_unicast_frames_lo,
1802 fcoe_q_xstorm_stats->ucast_pkts_sent);
1804 ADD_64_LE(afex_stats->tx_broadcast_frames_hi,
1806 afex_stats->tx_broadcast_frames_lo,
1807 fcoe_q_xstorm_stats->bcast_pkts_sent);
1809 ADD_64_LE(afex_stats->tx_multicast_frames_hi,
1811 afex_stats->tx_multicast_frames_lo,
1812 fcoe_q_xstorm_stats->mcast_pkts_sent);
1814 ADD_64_LE(afex_stats->tx_frames_dropped_hi,
1816 afex_stats->tx_frames_dropped_lo,
1817 fcoe_q_xstorm_stats->error_drop_pkts);
1820 /* if port stats are requested, add them to the PMF
1821 * stats, as anyway they will be accumulated by the
1822 * MCP before sent to the switch
1824 if ((bp->port.pmf) && (stats_type == VICSTATST_UIF_INDEX)) {
1825 ADD_64(afex_stats->rx_frames_dropped_hi,
1827 afex_stats->rx_frames_dropped_lo,
1828 estats->mac_filter_discard);
1829 ADD_64(afex_stats->rx_frames_dropped_hi,
1831 afex_stats->rx_frames_dropped_lo,
1832 estats->brb_truncate_discard);
1833 ADD_64(afex_stats->rx_frames_discarded_hi,
1835 afex_stats->rx_frames_discarded_lo,
1836 estats->mac_discard);