aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorYitchak Gertner <gertner@broadcom.com>2008-08-13 18:49:05 -0400
committerDavid S. Miller <davem@davemloft.net>2008-08-13 19:01:31 -0400
commit66e855f3f5197fec1162c5235fdb5f92b956d618 (patch)
tree2f19f96c48f50cd703b66d35e19312b208acd3bd /drivers/net
parent1adcd8bee37f494e22aee856467e994ae086ae45 (diff)
bnx2x: Statistics
Statistics - Making sure that each drop is accounted for in the driver statistics - Clearing the FW statistics when driver is loaded to prevent inconsistency with HW statistics - Once error is detected (bnx2x_panic_dump), stop the statistics before other actions (currently it is stopped last and can corrupt the data) - Adding HW checksum error counter to the statistics - Removing unused variable stats_ticks - Using macros instead of magic numbers to indicate which statistics are shared per port and which are per function Signed-off-by: Yitchak Gertner <gertner@broadcom.com> Signed-off-by: Eilon Greenstein <eilong@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/bnx2x.h11
-rw-r--r--drivers/net/bnx2x_fw_defs.h6
-rw-r--r--drivers/net/bnx2x_main.c228
-rw-r--r--drivers/net/bnx2x_reg.h3
4 files changed, 154 insertions, 94 deletions
diff --git a/drivers/net/bnx2x.h b/drivers/net/bnx2x.h
index dc54602494fb..9cbf0e82ef38 100644
--- a/drivers/net/bnx2x.h
+++ b/drivers/net/bnx2x.h
@@ -258,8 +258,7 @@ struct bnx2x_fastpath {
258 258
259 unsigned long tx_pkt, 259 unsigned long tx_pkt,
260 rx_pkt, 260 rx_pkt,
261 rx_calls, 261 rx_calls;
262 rx_alloc_failed;
263 /* TPA related */ 262 /* TPA related */
264 struct sw_rx_bd tpa_pool[ETH_MAX_AGGREGATION_QUEUES_E1H]; 263 struct sw_rx_bd tpa_pool[ETH_MAX_AGGREGATION_QUEUES_E1H];
265 u8 tpa_state[ETH_MAX_AGGREGATION_QUEUES_E1H]; 264 u8 tpa_state[ETH_MAX_AGGREGATION_QUEUES_E1H];
@@ -655,6 +654,8 @@ struct bnx2x_eth_stats {
655 654
656 u32 brb_drop_hi; 655 u32 brb_drop_hi;
657 u32 brb_drop_lo; 656 u32 brb_drop_lo;
657 u32 brb_truncate_hi;
658 u32 brb_truncate_lo;
658 659
659 u32 jabber_packets_received; 660 u32 jabber_packets_received;
660 661
@@ -671,6 +672,9 @@ struct bnx2x_eth_stats {
671 u32 mac_discard; 672 u32 mac_discard;
672 673
673 u32 driver_xoff; 674 u32 driver_xoff;
675 u32 rx_err_discard_pkt;
676 u32 rx_skb_alloc_failed;
677 u32 hw_csum_err;
674}; 678};
675 679
676#define STATS_OFFSET32(stat_name) \ 680#define STATS_OFFSET32(stat_name) \
@@ -844,7 +848,6 @@ struct bnx2x {
844 u16 rx_ticks_int; 848 u16 rx_ticks_int;
845 u16 rx_ticks; 849 u16 rx_ticks;
846 850
847 u32 stats_ticks;
848 u32 lin_cnt; 851 u32 lin_cnt;
849 852
850 int state; 853 int state;
@@ -984,7 +987,7 @@ static inline u32 reg_poll(struct bnx2x *bp, u32 reg, u32 expected, int ms,
984#define PCICFG_LINK_SPEED_SHIFT 16 987#define PCICFG_LINK_SPEED_SHIFT 16
985 988
986 989
987#define BNX2X_NUM_STATS 39 990#define BNX2X_NUM_STATS 42
988#define BNX2X_NUM_TESTS 8 991#define BNX2X_NUM_TESTS 8
989 992
990#define BNX2X_MAC_LOOPBACK 0 993#define BNX2X_MAC_LOOPBACK 0
diff --git a/drivers/net/bnx2x_fw_defs.h b/drivers/net/bnx2x_fw_defs.h
index e3da7f69d27b..6e35761fc7dc 100644
--- a/drivers/net/bnx2x_fw_defs.h
+++ b/drivers/net/bnx2x_fw_defs.h
@@ -79,6 +79,9 @@
79#define TSTORM_MAC_FILTER_CONFIG_OFFSET(function) \ 79#define TSTORM_MAC_FILTER_CONFIG_OFFSET(function) \
80 (IS_E1H_OFFSET? (0x3008 + (function * 0x38)) : (0x1508 + \ 80 (IS_E1H_OFFSET? (0x3008 + (function * 0x38)) : (0x1508 + \
81 (function * 0x38))) 81 (function * 0x38)))
82#define TSTORM_PER_COUNTER_ID_STATS_OFFSET(port, stats_counter_id) \
83 (IS_E1H_OFFSET ? (0x2010 + (port * 0x5b0) + (stats_counter_id * \
84 0x50)) : (0x4000 + (port * 0x3f0) + (stats_counter_id * 0x38)))
82#define TSTORM_RX_PRODS_OFFSET(port, client_id) \ 85#define TSTORM_RX_PRODS_OFFSET(port, client_id) \
83 (IS_E1H_OFFSET? (0x3350 + (port * 0x3e8) + (client_id * 0x28)) : \ 86 (IS_E1H_OFFSET? (0x3350 + (port * 0x3e8) + (client_id * 0x28)) : \
84 (0x9c0 + (port * 0x2f8) + (client_id * 0x28))) 87 (0x9c0 + (port * 0x2f8) + (client_id * 0x28)))
@@ -157,6 +160,9 @@
157 (IS_E1H_OFFSET? 0x2ac8 : 0xffffffff) 160 (IS_E1H_OFFSET? 0x2ac8 : 0xffffffff)
158#define XSTORM_HC_BTR_OFFSET(port) \ 161#define XSTORM_HC_BTR_OFFSET(port) \
159 (IS_E1H_OFFSET? (0xa144 + (port * 0x30)) : (0x1454 + (port * 0x18))) 162 (IS_E1H_OFFSET? (0xa144 + (port * 0x30)) : (0x1454 + (port * 0x18)))
163#define XSTORM_PER_COUNTER_ID_STATS_OFFSET(port, stats_counter_id) \
164 (IS_E1H_OFFSET ? (0xc000 + (port * 0x3f0) + (stats_counter_id * \
165 0x38)) : (0x3378 + (port * 0x3f0) + (stats_counter_id * 0x38)))
160#define XSTORM_RATE_SHAPING_PER_VN_VARS_OFFSET(function) \ 166#define XSTORM_RATE_SHAPING_PER_VN_VARS_OFFSET(function) \
161 (IS_E1H_OFFSET? (0x2528 + (function * 0x70)) : (0x3c20 + \ 167 (IS_E1H_OFFSET? (0x2528 + (function * 0x70)) : (0x3c20 + \
162 (function * 0x70))) 168 (function * 0x70)))
diff --git a/drivers/net/bnx2x_main.c b/drivers/net/bnx2x_main.c
index b9d376d972ca..ac46228cc9d0 100644
--- a/drivers/net/bnx2x_main.c
+++ b/drivers/net/bnx2x_main.c
@@ -501,6 +501,9 @@ static void bnx2x_panic_dump(struct bnx2x *bp)
501 int i; 501 int i;
502 u16 j, start, end; 502 u16 j, start, end;
503 503
504 bp->stats_state = STATS_STATE_DISABLED;
505 DP(BNX2X_MSG_STATS, "stats_state - DISABLED\n");
506
504 BNX2X_ERR("begin crash dump -----------------\n"); 507 BNX2X_ERR("begin crash dump -----------------\n");
505 508
506 for_each_queue(bp, i) { 509 for_each_queue(bp, i) {
@@ -511,17 +514,20 @@ static void bnx2x_panic_dump(struct bnx2x *bp)
511 " tx_bd_prod(%x) tx_bd_cons(%x) *tx_cons_sb(%x)\n", 514 " tx_bd_prod(%x) tx_bd_cons(%x) *tx_cons_sb(%x)\n",
512 i, fp->tx_pkt_prod, fp->tx_pkt_cons, fp->tx_bd_prod, 515 i, fp->tx_pkt_prod, fp->tx_pkt_cons, fp->tx_bd_prod,
513 fp->tx_bd_cons, le16_to_cpu(*fp->tx_cons_sb)); 516 fp->tx_bd_cons, le16_to_cpu(*fp->tx_cons_sb));
514 BNX2X_ERR(" rx_comp_prod(%x) rx_comp_cons(%x)" 517 BNX2X_ERR(" rx_bd_prod(%x) rx_bd_cons(%x)"
515 " *rx_cons_sb(%x) *rx_bd_cons_sb(%x)" 518 " *rx_bd_cons_sb(%x) rx_comp_prod(%x)"
516 " rx_sge_prod(%x) last_max_sge(%x)\n", 519 " rx_comp_cons(%x) *rx_cons_sb(%x)\n",
517 fp->rx_comp_prod, fp->rx_comp_cons, 520 fp->rx_bd_prod, fp->rx_bd_cons,
518 le16_to_cpu(*fp->rx_cons_sb), 521 le16_to_cpu(*fp->rx_bd_cons_sb), fp->rx_comp_prod,
519 le16_to_cpu(*fp->rx_bd_cons_sb), 522 fp->rx_comp_cons, le16_to_cpu(*fp->rx_cons_sb));
520 fp->rx_sge_prod, fp->last_max_sge); 523 BNX2X_ERR(" rx_sge_prod(%x) last_max_sge(%x)"
521 BNX2X_ERR(" fp_c_idx(%x) fp_u_idx(%x)" 524 " fp_c_idx(%x) *sb_c_idx(%x) fp_u_idx(%x)"
522 " bd data(%x,%x) rx_alloc_failed(%lx)\n", 525 " *sb_u_idx(%x) bd data(%x,%x)\n",
523 fp->fp_c_idx, fp->fp_u_idx, hw_prods->packets_prod, 526 fp->rx_sge_prod, fp->last_max_sge, fp->fp_c_idx,
524 hw_prods->bds_prod, fp->rx_alloc_failed); 527 fp->status_blk->c_status_block.status_block_index,
528 fp->fp_u_idx,
529 fp->status_blk->u_status_block.status_block_index,
530 hw_prods->packets_prod, hw_prods->bds_prod);
525 531
526 start = TX_BD(le16_to_cpu(*fp->tx_cons_sb) - 10); 532 start = TX_BD(le16_to_cpu(*fp->tx_cons_sb) - 10);
527 end = TX_BD(le16_to_cpu(*fp->tx_cons_sb) + 245); 533 end = TX_BD(le16_to_cpu(*fp->tx_cons_sb) + 245);
@@ -580,9 +586,6 @@ static void bnx2x_panic_dump(struct bnx2x *bp)
580 bnx2x_fw_dump(bp); 586 bnx2x_fw_dump(bp);
581 bnx2x_mc_assert(bp); 587 bnx2x_mc_assert(bp);
582 BNX2X_ERR("end crash dump -----------------\n"); 588 BNX2X_ERR("end crash dump -----------------\n");
583
584 bp->stats_state = STATS_STATE_DISABLED;
585 DP(BNX2X_MSG_STATS, "stats_state - DISABLED\n");
586} 589}
587 590
588static void bnx2x_int_enable(struct bnx2x *bp) 591static void bnx2x_int_enable(struct bnx2x *bp)
@@ -1259,7 +1262,7 @@ static int bnx2x_fill_frag_skb(struct bnx2x *bp, struct bnx2x_fastpath *fp,
1259 where we are and drop the whole packet */ 1262 where we are and drop the whole packet */
1260 err = bnx2x_alloc_rx_sge(bp, fp, sge_idx); 1263 err = bnx2x_alloc_rx_sge(bp, fp, sge_idx);
1261 if (unlikely(err)) { 1264 if (unlikely(err)) {
1262 fp->rx_alloc_failed++; 1265 bp->eth_stats.rx_skb_alloc_failed++;
1263 return err; 1266 return err;
1264 } 1267 }
1265 1268
@@ -1295,14 +1298,13 @@ static void bnx2x_tpa_stop(struct bnx2x *bp, struct bnx2x_fastpath *fp,
1295 pci_unmap_single(bp->pdev, pci_unmap_addr(rx_buf, mapping), 1298 pci_unmap_single(bp->pdev, pci_unmap_addr(rx_buf, mapping),
1296 bp->rx_buf_use_size, PCI_DMA_FROMDEVICE); 1299 bp->rx_buf_use_size, PCI_DMA_FROMDEVICE);
1297 1300
1298 /* if alloc failed drop the packet and keep the buffer in the bin */
1299 if (likely(new_skb)) { 1301 if (likely(new_skb)) {
1302 /* fix ip xsum and give it to the stack */
1303 /* (no need to map the new skb) */
1300 1304
1301 prefetch(skb); 1305 prefetch(skb);
1302 prefetch(((char *)(skb)) + 128); 1306 prefetch(((char *)(skb)) + 128);
1303 1307
1304 /* else fix ip xsum and give it to the stack */
1305 /* (no need to map the new skb) */
1306#ifdef BNX2X_STOP_ON_ERROR 1308#ifdef BNX2X_STOP_ON_ERROR
1307 if (pad + len > bp->rx_buf_size) { 1309 if (pad + len > bp->rx_buf_size) {
1308 BNX2X_ERR("skb_put is about to fail... " 1310 BNX2X_ERR("skb_put is about to fail... "
@@ -1351,9 +1353,10 @@ static void bnx2x_tpa_stop(struct bnx2x *bp, struct bnx2x_fastpath *fp,
1351 fp->tpa_pool[queue].skb = new_skb; 1353 fp->tpa_pool[queue].skb = new_skb;
1352 1354
1353 } else { 1355 } else {
1356 /* else drop the packet and keep the buffer in the bin */
1354 DP(NETIF_MSG_RX_STATUS, 1357 DP(NETIF_MSG_RX_STATUS,
1355 "Failed to allocate new skb - dropping packet!\n"); 1358 "Failed to allocate new skb - dropping packet!\n");
1356 fp->rx_alloc_failed++; 1359 bp->eth_stats.rx_skb_alloc_failed++;
1357 } 1360 }
1358 1361
1359 fp->tpa_state[queue] = BNX2X_TPA_STOP; 1362 fp->tpa_state[queue] = BNX2X_TPA_STOP;
@@ -1504,7 +1507,7 @@ static int bnx2x_rx_int(struct bnx2x_fastpath *fp, int budget)
1504 DP(NETIF_MSG_RX_ERR, 1507 DP(NETIF_MSG_RX_ERR,
1505 "ERROR flags %x rx packet %u\n", 1508 "ERROR flags %x rx packet %u\n",
1506 cqe_fp_flags, sw_comp_cons); 1509 cqe_fp_flags, sw_comp_cons);
1507 /* TBD make sure MC counts this as a drop */ 1510 bp->eth_stats.rx_err_discard_pkt++;
1508 goto reuse_rx; 1511 goto reuse_rx;
1509 } 1512 }
1510 1513
@@ -1521,7 +1524,7 @@ static int bnx2x_rx_int(struct bnx2x_fastpath *fp, int budget)
1521 DP(NETIF_MSG_RX_ERR, 1524 DP(NETIF_MSG_RX_ERR,
1522 "ERROR packet dropped " 1525 "ERROR packet dropped "
1523 "because of alloc failure\n"); 1526 "because of alloc failure\n");
1524 fp->rx_alloc_failed++; 1527 bp->eth_stats.rx_skb_alloc_failed++;
1525 goto reuse_rx; 1528 goto reuse_rx;
1526 } 1529 }
1527 1530
@@ -1547,7 +1550,7 @@ static int bnx2x_rx_int(struct bnx2x_fastpath *fp, int budget)
1547 DP(NETIF_MSG_RX_ERR, 1550 DP(NETIF_MSG_RX_ERR,
1548 "ERROR packet dropped because " 1551 "ERROR packet dropped because "
1549 "of alloc failure\n"); 1552 "of alloc failure\n");
1550 fp->rx_alloc_failed++; 1553 bp->eth_stats.rx_skb_alloc_failed++;
1551reuse_rx: 1554reuse_rx:
1552 bnx2x_reuse_rx_skb(fp, skb, bd_cons, bd_prod); 1555 bnx2x_reuse_rx_skb(fp, skb, bd_cons, bd_prod);
1553 goto next_rx; 1556 goto next_rx;
@@ -1556,10 +1559,12 @@ reuse_rx:
1556 skb->protocol = eth_type_trans(skb, bp->dev); 1559 skb->protocol = eth_type_trans(skb, bp->dev);
1557 1560
1558 skb->ip_summed = CHECKSUM_NONE; 1561 skb->ip_summed = CHECKSUM_NONE;
1559 if (bp->rx_csum) 1562 if (bp->rx_csum) {
1560 if (likely(BNX2X_RX_CSUM_OK(cqe))) 1563 if (likely(BNX2X_RX_CSUM_OK(cqe)))
1561 skb->ip_summed = CHECKSUM_UNNECESSARY; 1564 skb->ip_summed = CHECKSUM_UNNECESSARY;
1562 1565 else
1566 bp->eth_stats.hw_csum_err++;
1567 }
1563 } 1568 }
1564 1569
1565#ifdef BCM_VLAN 1570#ifdef BCM_VLAN
@@ -3039,6 +3044,8 @@ static void bnx2x_stats_init(struct bnx2x *bp)
3039 memset(&(bp->port.old_nig_stats), 0, sizeof(struct nig_stats)); 3044 memset(&(bp->port.old_nig_stats), 0, sizeof(struct nig_stats));
3040 bp->port.old_nig_stats.brb_discard = 3045 bp->port.old_nig_stats.brb_discard =
3041 REG_RD(bp, NIG_REG_STAT0_BRB_DISCARD + port*0x38); 3046 REG_RD(bp, NIG_REG_STAT0_BRB_DISCARD + port*0x38);
3047 bp->port.old_nig_stats.brb_truncate =
3048 REG_RD(bp, NIG_REG_STAT0_BRB_TRUNCATE + port*0x38);
3042 REG_RD_DMAE(bp, NIG_REG_STAT0_EGRESS_MAC_PKT0 + port*0x50, 3049 REG_RD_DMAE(bp, NIG_REG_STAT0_EGRESS_MAC_PKT0 + port*0x50,
3043 &(bp->port.old_nig_stats.egress_mac_pkt0_lo), 2); 3050 &(bp->port.old_nig_stats.egress_mac_pkt0_lo), 2);
3044 REG_RD_DMAE(bp, NIG_REG_STAT0_EGRESS_MAC_PKT1 + port*0x50, 3051 REG_RD_DMAE(bp, NIG_REG_STAT0_EGRESS_MAC_PKT1 + port*0x50,
@@ -3458,8 +3465,7 @@ static void bnx2x_bmac_stats_update(struct bnx2x *bp)
3458 UPDATE_STAT64(rx_stat_grovr, rx_stat_dot3statsframestoolong); 3465 UPDATE_STAT64(rx_stat_grovr, rx_stat_dot3statsframestoolong);
3459 UPDATE_STAT64(rx_stat_grfrg, rx_stat_etherstatsfragments); 3466 UPDATE_STAT64(rx_stat_grfrg, rx_stat_etherstatsfragments);
3460 UPDATE_STAT64(rx_stat_grjbr, rx_stat_etherstatsjabbers); 3467 UPDATE_STAT64(rx_stat_grjbr, rx_stat_etherstatsjabbers);
3461 UPDATE_STAT64(rx_stat_grxpf, rx_stat_bmac_xpf); 3468 UPDATE_STAT64(rx_stat_grxcf, rx_stat_maccontrolframesreceived);
3462 UPDATE_STAT64(rx_stat_grxcf, rx_stat_bmac_xcf);
3463 UPDATE_STAT64(rx_stat_grxpf, rx_stat_xoffstateentered); 3469 UPDATE_STAT64(rx_stat_grxpf, rx_stat_xoffstateentered);
3464 UPDATE_STAT64(rx_stat_grxpf, rx_stat_xoffpauseframesreceived); 3470 UPDATE_STAT64(rx_stat_grxpf, rx_stat_xoffpauseframesreceived);
3465 UPDATE_STAT64(tx_stat_gtxpf, tx_stat_outxoffsent); 3471 UPDATE_STAT64(tx_stat_gtxpf, tx_stat_outxoffsent);
@@ -3543,6 +3549,8 @@ static int bnx2x_hw_stats_update(struct bnx2x *bp)
3543 3549
3544 ADD_EXTEND_64(pstats->brb_drop_hi, pstats->brb_drop_lo, 3550 ADD_EXTEND_64(pstats->brb_drop_hi, pstats->brb_drop_lo,
3545 new->brb_discard - old->brb_discard); 3551 new->brb_discard - old->brb_discard);
3552 ADD_EXTEND_64(estats->brb_truncate_hi, estats->brb_truncate_lo,
3553 new->brb_truncate - old->brb_truncate);
3546 3554
3547 UPDATE_STAT64_NIG(egress_mac_pkt0, 3555 UPDATE_STAT64_NIG(egress_mac_pkt0,
3548 etherstatspkts1024octetsto1522octets); 3556 etherstatspkts1024octetsto1522octets);
@@ -3720,8 +3728,7 @@ static void bnx2x_net_stats_update(struct bnx2x *bp)
3720 nstats->rx_length_errors = 3728 nstats->rx_length_errors =
3721 estats->rx_stat_etherstatsundersizepkts_lo + 3729 estats->rx_stat_etherstatsundersizepkts_lo +
3722 estats->jabber_packets_received; 3730 estats->jabber_packets_received;
3723 nstats->rx_over_errors = estats->brb_drop_lo + 3731 nstats->rx_over_errors = estats->brb_drop_lo + estats->brb_truncate_lo;
3724 estats->brb_truncate_discard;
3725 nstats->rx_crc_errors = estats->rx_stat_dot3statsfcserrors_lo; 3732 nstats->rx_crc_errors = estats->rx_stat_dot3statsfcserrors_lo;
3726 nstats->rx_frame_errors = estats->rx_stat_dot3statsalignmenterrors_lo; 3733 nstats->rx_frame_errors = estats->rx_stat_dot3statsalignmenterrors_lo;
3727 nstats->rx_fifo_errors = old_tclient->no_buff_discard; 3734 nstats->rx_fifo_errors = old_tclient->no_buff_discard;
@@ -4201,6 +4208,7 @@ static void bnx2x_init_def_sb(struct bnx2x *bp,
4201 XSTORM_DEF_SB_HC_DISABLE_OFFSET(func, index), 1); 4208 XSTORM_DEF_SB_HC_DISABLE_OFFSET(func, index), 1);
4202 4209
4203 bp->stats_pending = 0; 4210 bp->stats_pending = 0;
4211 bp->set_mac_pending = 0;
4204 4212
4205 bnx2x_ack_sb(bp, sb_id, CSTORM_ID, 0, IGU_INT_ENABLE, 0); 4213 bnx2x_ack_sb(bp, sb_id, CSTORM_ID, 0, IGU_INT_ENABLE, 0);
4206} 4214}
@@ -4370,13 +4378,13 @@ static void bnx2x_init_rx_rings(struct bnx2x *bp)
4370 fp->rx_sge_prod = ring_prod; 4378 fp->rx_sge_prod = ring_prod;
4371 4379
4372 /* Allocate BDs and initialize BD ring */ 4380 /* Allocate BDs and initialize BD ring */
4373 fp->rx_comp_cons = fp->rx_alloc_failed = 0; 4381 fp->rx_comp_cons = 0;
4374 cqe_ring_prod = ring_prod = 0; 4382 cqe_ring_prod = ring_prod = 0;
4375 for (i = 0; i < bp->rx_ring_size; i++) { 4383 for (i = 0; i < bp->rx_ring_size; i++) {
4376 if (bnx2x_alloc_rx_skb(bp, fp, ring_prod) < 0) { 4384 if (bnx2x_alloc_rx_skb(bp, fp, ring_prod) < 0) {
4377 BNX2X_ERR("was only able to allocate " 4385 BNX2X_ERR("was only able to allocate "
4378 "%d rx skbs\n", i); 4386 "%d rx skbs\n", i);
4379 fp->rx_alloc_failed++; 4387 bp->eth_stats.rx_skb_alloc_failed++;
4380 break; 4388 break;
4381 } 4389 }
4382 ring_prod = NEXT_RX_IDX(ring_prod); 4390 ring_prod = NEXT_RX_IDX(ring_prod);
@@ -4542,7 +4550,7 @@ static void bnx2x_set_client_config(struct bnx2x *bp)
4542 int i; 4550 int i;
4543 4551
4544 tstorm_client.mtu = bp->dev->mtu + ETH_OVREHEAD; 4552 tstorm_client.mtu = bp->dev->mtu + ETH_OVREHEAD;
4545 tstorm_client.statistics_counter_id = 0; 4553 tstorm_client.statistics_counter_id = BP_CL_ID(bp);
4546 tstorm_client.config_flags = 4554 tstorm_client.config_flags =
4547 TSTORM_ETH_CLIENT_CONFIG_STATSITICS_ENABLE; 4555 TSTORM_ETH_CLIENT_CONFIG_STATSITICS_ENABLE;
4548#ifdef BCM_VLAN 4556#ifdef BCM_VLAN
@@ -4649,25 +4657,50 @@ static void bnx2x_init_internal(struct bnx2x *bp)
4649 bp->rx_mode = BNX2X_RX_MODE_NONE; /* no rx until link is up */ 4657 bp->rx_mode = BNX2X_RX_MODE_NONE; /* no rx until link is up */
4650 bnx2x_set_storm_rx_mode(bp); 4658 bnx2x_set_storm_rx_mode(bp);
4651 4659
4660 /* reset xstorm per client statistics */
4661 for (i = 0; i < sizeof(struct xstorm_per_client_stats) / 4; i++) {
4662 REG_WR(bp, BAR_XSTRORM_INTMEM +
4663 XSTORM_PER_COUNTER_ID_STATS_OFFSET(port, BP_CL_ID(bp)) +
4664 i*4, 0);
4665 }
4666 /* reset tstorm per client statistics */
4667 for (i = 0; i < sizeof(struct tstorm_per_client_stats) / 4; i++) {
4668 REG_WR(bp, BAR_TSTRORM_INTMEM +
4669 TSTORM_PER_COUNTER_ID_STATS_OFFSET(port, BP_CL_ID(bp)) +
4670 i*4, 0);
4671 }
4672
4673 /* Init statistics related context */
4652 stats_flags.collect_eth = 1; 4674 stats_flags.collect_eth = 1;
4653 4675
4654 REG_WR(bp, BAR_XSTRORM_INTMEM + XSTORM_STATS_FLAGS_OFFSET(port), 4676 REG_WR(bp, BAR_XSTRORM_INTMEM + XSTORM_STATS_FLAGS_OFFSET(func),
4655 ((u32 *)&stats_flags)[0]); 4677 ((u32 *)&stats_flags)[0]);
4656 REG_WR(bp, BAR_XSTRORM_INTMEM + XSTORM_STATS_FLAGS_OFFSET(port) + 4, 4678 REG_WR(bp, BAR_XSTRORM_INTMEM + XSTORM_STATS_FLAGS_OFFSET(func) + 4,
4657 ((u32 *)&stats_flags)[1]); 4679 ((u32 *)&stats_flags)[1]);
4658 4680
4659 REG_WR(bp, BAR_TSTRORM_INTMEM + TSTORM_STATS_FLAGS_OFFSET(port), 4681 REG_WR(bp, BAR_TSTRORM_INTMEM + TSTORM_STATS_FLAGS_OFFSET(func),
4660 ((u32 *)&stats_flags)[0]); 4682 ((u32 *)&stats_flags)[0]);
4661 REG_WR(bp, BAR_TSTRORM_INTMEM + TSTORM_STATS_FLAGS_OFFSET(port) + 4, 4683 REG_WR(bp, BAR_TSTRORM_INTMEM + TSTORM_STATS_FLAGS_OFFSET(func) + 4,
4662 ((u32 *)&stats_flags)[1]); 4684 ((u32 *)&stats_flags)[1]);
4663 4685
4664 REG_WR(bp, BAR_CSTRORM_INTMEM + CSTORM_STATS_FLAGS_OFFSET(port), 4686 REG_WR(bp, BAR_CSTRORM_INTMEM + CSTORM_STATS_FLAGS_OFFSET(func),
4665 ((u32 *)&stats_flags)[0]); 4687 ((u32 *)&stats_flags)[0]);
4666 REG_WR(bp, BAR_CSTRORM_INTMEM + CSTORM_STATS_FLAGS_OFFSET(port) + 4, 4688 REG_WR(bp, BAR_CSTRORM_INTMEM + CSTORM_STATS_FLAGS_OFFSET(func) + 4,
4667 ((u32 *)&stats_flags)[1]); 4689 ((u32 *)&stats_flags)[1]);
4668 4690
4669/* DP(NETIF_MSG_IFUP, "stats_flags: 0x%08x 0x%08x\n", 4691 REG_WR(bp, BAR_XSTRORM_INTMEM +
4670 ((u32 *)&stats_flags)[0], ((u32 *)&stats_flags)[1]); */ 4692 XSTORM_ETH_STATS_QUERY_ADDR_OFFSET(func),
4693 U64_LO(bnx2x_sp_mapping(bp, fw_stats)));
4694 REG_WR(bp, BAR_XSTRORM_INTMEM +
4695 XSTORM_ETH_STATS_QUERY_ADDR_OFFSET(func) + 4,
4696 U64_HI(bnx2x_sp_mapping(bp, fw_stats)));
4697
4698 REG_WR(bp, BAR_TSTRORM_INTMEM +
4699 TSTORM_ETH_STATS_QUERY_ADDR_OFFSET(func),
4700 U64_LO(bnx2x_sp_mapping(bp, fw_stats)));
4701 REG_WR(bp, BAR_TSTRORM_INTMEM +
4702 TSTORM_ETH_STATS_QUERY_ADDR_OFFSET(func) + 4,
4703 U64_HI(bnx2x_sp_mapping(bp, fw_stats)));
4671 4704
4672 if (CHIP_IS_E1H(bp)) { 4705 if (CHIP_IS_E1H(bp)) {
4673 REG_WR8(bp, BAR_XSTRORM_INTMEM + XSTORM_FUNCTION_MODE_OFFSET, 4706 REG_WR8(bp, BAR_XSTRORM_INTMEM + XSTORM_FUNCTION_MODE_OFFSET,
@@ -7386,8 +7419,6 @@ static int __devinit bnx2x_init_bp(struct bnx2x *bp)
7386 bp->tx_ticks = 50; 7419 bp->tx_ticks = 50;
7387 bp->rx_ticks = 25; 7420 bp->rx_ticks = 25;
7388 7421
7389 bp->stats_ticks = 1000000 & 0xffff00;
7390
7391 bp->timer_interval = (CHIP_REV_IS_SLOW(bp) ? 5*HZ : HZ); 7422 bp->timer_interval = (CHIP_REV_IS_SLOW(bp) ? 5*HZ : HZ);
7392 bp->current_interval = (poll ? poll : bp->timer_interval); 7423 bp->current_interval = (poll ? poll : bp->timer_interval);
7393 7424
@@ -8137,7 +8168,6 @@ static int bnx2x_get_coalesce(struct net_device *dev,
8137 8168
8138 coal->rx_coalesce_usecs = bp->rx_ticks; 8169 coal->rx_coalesce_usecs = bp->rx_ticks;
8139 coal->tx_coalesce_usecs = bp->tx_ticks; 8170 coal->tx_coalesce_usecs = bp->tx_ticks;
8140 coal->stats_block_coalesce_usecs = bp->stats_ticks;
8141 8171
8142 return 0; 8172 return 0;
8143} 8173}
@@ -8155,11 +8185,6 @@ static int bnx2x_set_coalesce(struct net_device *dev,
8155 if (bp->tx_ticks > 0x3000) 8185 if (bp->tx_ticks > 0x3000)
8156 bp->tx_ticks = 0x3000; 8186 bp->tx_ticks = 0x3000;
8157 8187
8158 bp->stats_ticks = coal->stats_block_coalesce_usecs;
8159 if (bp->stats_ticks > 0xffff00)
8160 bp->stats_ticks = 0xffff00;
8161 bp->stats_ticks &= 0xffff00;
8162
8163 if (netif_running(dev)) 8188 if (netif_running(dev))
8164 bnx2x_update_coalesce(bp); 8189 bnx2x_update_coalesce(bp);
8165 8190
@@ -8836,76 +8861,99 @@ static const struct {
8836 long offset; 8861 long offset;
8837 int size; 8862 int size;
8838 u32 flags; 8863 u32 flags;
8839 char string[ETH_GSTRING_LEN]; 8864#define STATS_FLAGS_PORT 1
8865#define STATS_FLAGS_FUNC 2
8866 u8 string[ETH_GSTRING_LEN];
8840} bnx2x_stats_arr[BNX2X_NUM_STATS] = { 8867} bnx2x_stats_arr[BNX2X_NUM_STATS] = {
8841/* 1 */ { STATS_OFFSET32(valid_bytes_received_hi), 8, 1, "rx_bytes" }, 8868/* 1 */ { STATS_OFFSET32(valid_bytes_received_hi),
8842 { STATS_OFFSET32(error_bytes_received_hi), 8, 1, "rx_error_bytes" }, 8869 8, STATS_FLAGS_FUNC, "rx_bytes" },
8843 { STATS_OFFSET32(total_bytes_transmitted_hi), 8, 1, "tx_bytes" }, 8870 { STATS_OFFSET32(error_bytes_received_hi),
8844 { STATS_OFFSET32(tx_stat_ifhcoutbadoctets_hi), 8, 0, "tx_error_bytes" }, 8871 8, STATS_FLAGS_FUNC, "rx_error_bytes" },
8872 { STATS_OFFSET32(total_bytes_transmitted_hi),
8873 8, STATS_FLAGS_FUNC, "tx_bytes" },
8874 { STATS_OFFSET32(tx_stat_ifhcoutbadoctets_hi),
8875 8, STATS_FLAGS_PORT, "tx_error_bytes" },
8845 { STATS_OFFSET32(total_unicast_packets_received_hi), 8876 { STATS_OFFSET32(total_unicast_packets_received_hi),
8846 8, 1, "rx_ucast_packets" }, 8877 8, STATS_FLAGS_FUNC, "rx_ucast_packets" },
8847 { STATS_OFFSET32(total_multicast_packets_received_hi), 8878 { STATS_OFFSET32(total_multicast_packets_received_hi),
8848 8, 1, "rx_mcast_packets" }, 8879 8, STATS_FLAGS_FUNC, "rx_mcast_packets" },
8849 { STATS_OFFSET32(total_broadcast_packets_received_hi), 8880 { STATS_OFFSET32(total_broadcast_packets_received_hi),
8850 8, 1, "rx_bcast_packets" }, 8881 8, STATS_FLAGS_FUNC, "rx_bcast_packets" },
8851 { STATS_OFFSET32(total_unicast_packets_transmitted_hi), 8882 { STATS_OFFSET32(total_unicast_packets_transmitted_hi),
8852 8, 1, "tx_packets" }, 8883 8, STATS_FLAGS_FUNC, "tx_packets" },
8853 { STATS_OFFSET32(tx_stat_dot3statsinternalmactransmiterrors_hi), 8884 { STATS_OFFSET32(tx_stat_dot3statsinternalmactransmiterrors_hi),
8854 8, 0, "tx_mac_errors" }, 8885 8, STATS_FLAGS_PORT, "tx_mac_errors" },
8855/* 10 */{ STATS_OFFSET32(rx_stat_dot3statscarriersenseerrors_hi), 8886/* 10 */{ STATS_OFFSET32(rx_stat_dot3statscarriersenseerrors_hi),
8856 8, 0, "tx_carrier_errors" }, 8887 8, STATS_FLAGS_PORT, "tx_carrier_errors" },
8857 { STATS_OFFSET32(rx_stat_dot3statsfcserrors_hi), 8888 { STATS_OFFSET32(rx_stat_dot3statsfcserrors_hi),
8858 8, 0, "rx_crc_errors" }, 8889 8, STATS_FLAGS_PORT, "rx_crc_errors" },
8859 { STATS_OFFSET32(rx_stat_dot3statsalignmenterrors_hi), 8890 { STATS_OFFSET32(rx_stat_dot3statsalignmenterrors_hi),
8860 8, 0, "rx_align_errors" }, 8891 8, STATS_FLAGS_PORT, "rx_align_errors" },
8861 { STATS_OFFSET32(tx_stat_dot3statssinglecollisionframes_hi), 8892 { STATS_OFFSET32(tx_stat_dot3statssinglecollisionframes_hi),
8862 8, 0, "tx_single_collisions" }, 8893 8, STATS_FLAGS_PORT, "tx_single_collisions" },
8863 { STATS_OFFSET32(tx_stat_dot3statsmultiplecollisionframes_hi), 8894 { STATS_OFFSET32(tx_stat_dot3statsmultiplecollisionframes_hi),
8864 8, 0, "tx_multi_collisions" }, 8895 8, STATS_FLAGS_PORT, "tx_multi_collisions" },
8865 { STATS_OFFSET32(tx_stat_dot3statsdeferredtransmissions_hi), 8896 { STATS_OFFSET32(tx_stat_dot3statsdeferredtransmissions_hi),
8866 8, 0, "tx_deferred" }, 8897 8, STATS_FLAGS_PORT, "tx_deferred" },
8867 { STATS_OFFSET32(tx_stat_dot3statsexcessivecollisions_hi), 8898 { STATS_OFFSET32(tx_stat_dot3statsexcessivecollisions_hi),
8868 8, 0, "tx_excess_collisions" }, 8899 8, STATS_FLAGS_PORT, "tx_excess_collisions" },
8869 { STATS_OFFSET32(tx_stat_dot3statslatecollisions_hi), 8900 { STATS_OFFSET32(tx_stat_dot3statslatecollisions_hi),
8870 8, 0, "tx_late_collisions" }, 8901 8, STATS_FLAGS_PORT, "tx_late_collisions" },
8871 { STATS_OFFSET32(tx_stat_etherstatscollisions_hi), 8902 { STATS_OFFSET32(tx_stat_etherstatscollisions_hi),
8872 8, 0, "tx_total_collisions" }, 8903 8, STATS_FLAGS_PORT, "tx_total_collisions" },
8873 { STATS_OFFSET32(rx_stat_etherstatsfragments_hi), 8904 { STATS_OFFSET32(rx_stat_etherstatsfragments_hi),
8874 8, 0, "rx_fragments" }, 8905 8, STATS_FLAGS_PORT, "rx_fragments" },
8875/* 20 */{ STATS_OFFSET32(rx_stat_etherstatsjabbers_hi), 8, 0, "rx_jabbers" }, 8906/* 20 */{ STATS_OFFSET32(rx_stat_etherstatsjabbers_hi),
8907 8, STATS_FLAGS_PORT, "rx_jabbers" },
8876 { STATS_OFFSET32(rx_stat_etherstatsundersizepkts_hi), 8908 { STATS_OFFSET32(rx_stat_etherstatsundersizepkts_hi),
8877 8, 0, "rx_undersize_packets" }, 8909 8, STATS_FLAGS_PORT, "rx_undersize_packets" },
8878 { STATS_OFFSET32(jabber_packets_received), 8910 { STATS_OFFSET32(jabber_packets_received),
8879 4, 1, "rx_oversize_packets" }, 8911 4, STATS_FLAGS_FUNC, "rx_oversize_packets" },
8880 { STATS_OFFSET32(tx_stat_etherstatspkts64octets_hi), 8912 { STATS_OFFSET32(tx_stat_etherstatspkts64octets_hi),
8881 8, 0, "tx_64_byte_packets" }, 8913 8, STATS_FLAGS_PORT, "tx_64_byte_packets" },
8882 { STATS_OFFSET32(tx_stat_etherstatspkts65octetsto127octets_hi), 8914 { STATS_OFFSET32(tx_stat_etherstatspkts65octetsto127octets_hi),
8883 8, 0, "tx_65_to_127_byte_packets" }, 8915 8, STATS_FLAGS_PORT, "tx_65_to_127_byte_packets" },
8884 { STATS_OFFSET32(tx_stat_etherstatspkts128octetsto255octets_hi), 8916 { STATS_OFFSET32(tx_stat_etherstatspkts128octetsto255octets_hi),
8885 8, 0, "tx_128_to_255_byte_packets" }, 8917 8, STATS_FLAGS_PORT, "tx_128_to_255_byte_packets" },
8886 { STATS_OFFSET32(tx_stat_etherstatspkts256octetsto511octets_hi), 8918 { STATS_OFFSET32(tx_stat_etherstatspkts256octetsto511octets_hi),
8887 8, 0, "tx_256_to_511_byte_packets" }, 8919 8, STATS_FLAGS_PORT, "tx_256_to_511_byte_packets" },
8888 { STATS_OFFSET32(tx_stat_etherstatspkts512octetsto1023octets_hi), 8920 { STATS_OFFSET32(tx_stat_etherstatspkts512octetsto1023octets_hi),
8889 8, 0, "tx_512_to_1023_byte_packets" }, 8921 8, STATS_FLAGS_PORT, "tx_512_to_1023_byte_packets" },
8890 { STATS_OFFSET32(etherstatspkts1024octetsto1522octets_hi), 8922 { STATS_OFFSET32(etherstatspkts1024octetsto1522octets_hi),
8891 8, 0, "tx_1024_to_1522_byte_packets" }, 8923 8, STATS_FLAGS_PORT, "tx_1024_to_1522_byte_packets" },
8892 { STATS_OFFSET32(etherstatspktsover1522octets_hi), 8924 { STATS_OFFSET32(etherstatspktsover1522octets_hi),
8893 8, 0, "tx_1523_to_9022_byte_packets" }, 8925 8, STATS_FLAGS_PORT, "tx_1523_to_9022_byte_packets" },
8894/* 30 */{ STATS_OFFSET32(rx_stat_xonpauseframesreceived_hi), 8926/* 30 */{ STATS_OFFSET32(rx_stat_xonpauseframesreceived_hi),
8895 8, 0, "rx_xon_frames" }, 8927 8, STATS_FLAGS_PORT, "rx_xon_frames" },
8896 { STATS_OFFSET32(rx_stat_xoffpauseframesreceived_hi), 8928 { STATS_OFFSET32(rx_stat_xoffpauseframesreceived_hi),
8897 8, 0, "rx_xoff_frames" }, 8929 8, STATS_FLAGS_PORT, "rx_xoff_frames" },
8898 { STATS_OFFSET32(tx_stat_outxonsent_hi), 8, 0, "tx_xon_frames" }, 8930 { STATS_OFFSET32(tx_stat_outxonsent_hi),
8899 { STATS_OFFSET32(tx_stat_outxoffsent_hi), 8, 0, "tx_xoff_frames" }, 8931 8, STATS_FLAGS_PORT, "tx_xon_frames" },
8932 { STATS_OFFSET32(tx_stat_outxoffsent_hi),
8933 8, STATS_FLAGS_PORT, "tx_xoff_frames" },
8900 { STATS_OFFSET32(rx_stat_maccontrolframesreceived_hi), 8934 { STATS_OFFSET32(rx_stat_maccontrolframesreceived_hi),
8901 8, 0, "rx_mac_ctrl_frames" }, 8935 8, STATS_FLAGS_PORT, "rx_mac_ctrl_frames" },
8902 { STATS_OFFSET32(mac_filter_discard), 4, 1, "rx_filtered_packets" }, 8936 { STATS_OFFSET32(mac_filter_discard),
8903 { STATS_OFFSET32(no_buff_discard), 4, 1, "rx_discards" }, 8937 4, STATS_FLAGS_PORT, "rx_filtered_packets" },
8904 { STATS_OFFSET32(xxoverflow_discard), 4, 1, "rx_fw_discards" }, 8938 { STATS_OFFSET32(no_buff_discard),
8905 { STATS_OFFSET32(brb_drop_hi), 8, 1, "brb_discard" }, 8939 4, STATS_FLAGS_FUNC, "rx_discards" },
8906/* 39 */{ STATS_OFFSET32(brb_truncate_discard), 8, 1, "brb_truncate" } 8940 { STATS_OFFSET32(xxoverflow_discard),
8941 4, STATS_FLAGS_PORT, "rx_fw_discards" },
8942 { STATS_OFFSET32(brb_drop_hi),
8943 8, STATS_FLAGS_PORT, "brb_discard" },
8944 { STATS_OFFSET32(brb_truncate_hi),
8945 8, STATS_FLAGS_PORT, "brb_truncate" },
8946/* 40 */{ STATS_OFFSET32(rx_err_discard_pkt),
8947 4, STATS_FLAGS_FUNC, "rx_phy_ip_err_discards"},
8948 { STATS_OFFSET32(rx_skb_alloc_failed),
8949 4, STATS_FLAGS_FUNC, "rx_skb_alloc_discard" },
8950/* 42 */{ STATS_OFFSET32(hw_csum_err),
8951 4, STATS_FLAGS_FUNC, "rx_csum_offload_errors" }
8907}; 8952};
8908 8953
8954#define IS_NOT_E1HMF_STAT(bp, i) \
8955 (IS_E1HMF(bp) && (bnx2x_stats_arr[i].flags & STATS_FLAGS_PORT))
8956
8909static void bnx2x_get_strings(struct net_device *dev, u32 stringset, u8 *buf) 8957static void bnx2x_get_strings(struct net_device *dev, u32 stringset, u8 *buf)
8910{ 8958{
8911 struct bnx2x *bp = netdev_priv(dev); 8959 struct bnx2x *bp = netdev_priv(dev);
@@ -8914,7 +8962,7 @@ static void bnx2x_get_strings(struct net_device *dev, u32 stringset, u8 *buf)
8914 switch (stringset) { 8962 switch (stringset) {
8915 case ETH_SS_STATS: 8963 case ETH_SS_STATS:
8916 for (i = 0, j = 0; i < BNX2X_NUM_STATS; i++) { 8964 for (i = 0, j = 0; i < BNX2X_NUM_STATS; i++) {
8917 if (IS_E1HMF(bp) && (!bnx2x_stats_arr[i].flags)) 8965 if (IS_NOT_E1HMF_STAT(bp, i))
8918 continue; 8966 continue;
8919 strcpy(buf + j*ETH_GSTRING_LEN, 8967 strcpy(buf + j*ETH_GSTRING_LEN,
8920 bnx2x_stats_arr[i].string); 8968 bnx2x_stats_arr[i].string);
@@ -8934,7 +8982,7 @@ static int bnx2x_get_stats_count(struct net_device *dev)
8934 int i, num_stats = 0; 8982 int i, num_stats = 0;
8935 8983
8936 for (i = 0; i < BNX2X_NUM_STATS; i++) { 8984 for (i = 0; i < BNX2X_NUM_STATS; i++) {
8937 if (IS_E1HMF(bp) && (!bnx2x_stats_arr[i].flags)) 8985 if (IS_NOT_E1HMF_STAT(bp, i))
8938 continue; 8986 continue;
8939 num_stats++; 8987 num_stats++;
8940 } 8988 }
@@ -8949,7 +8997,7 @@ static void bnx2x_get_ethtool_stats(struct net_device *dev,
8949 int i, j; 8997 int i, j;
8950 8998
8951 for (i = 0, j = 0; i < BNX2X_NUM_STATS; i++) { 8999 for (i = 0, j = 0; i < BNX2X_NUM_STATS; i++) {
8952 if (IS_E1HMF(bp) && (!bnx2x_stats_arr[i].flags)) 9000 if (IS_NOT_E1HMF_STAT(bp, i))
8953 continue; 9001 continue;
8954 9002
8955 if (bnx2x_stats_arr[i].size == 0) { 9003 if (bnx2x_stats_arr[i].size == 0) {
diff --git a/drivers/net/bnx2x_reg.h b/drivers/net/bnx2x_reg.h
index 15c9a9946724..40c3a7735d25 100644
--- a/drivers/net/bnx2x_reg.h
+++ b/drivers/net/bnx2x_reg.h
@@ -1727,6 +1727,9 @@
1727/* [R 32] Rx statistics : In user packets discarded due to BRB backpressure 1727/* [R 32] Rx statistics : In user packets discarded due to BRB backpressure
1728 for port0 */ 1728 for port0 */
1729#define NIG_REG_STAT0_BRB_DISCARD 0x105f0 1729#define NIG_REG_STAT0_BRB_DISCARD 0x105f0
1730/* [R 32] Rx statistics : In user packets truncated due to BRB backpressure
1731 for port0 */
1732#define NIG_REG_STAT0_BRB_TRUNCATE 0x105f8
1730/* [WB_R 36] Tx statistics : Number of packets from emac0 or bmac0 that 1733/* [WB_R 36] Tx statistics : Number of packets from emac0 or bmac0 that
1731 between 1024 and 1522 bytes for port0 */ 1734 between 1024 and 1522 bytes for port0 */
1732#define NIG_REG_STAT0_EGRESS_MAC_PKT0 0x10750 1735#define NIG_REG_STAT0_EGRESS_MAC_PKT0 0x10750