aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVasundhara Volam <vasundhara-v.volam@broadcom.com>2018-03-31 13:54:12 -0400
committerDavid S. Miller <davem@davemloft.net>2018-03-31 23:24:19 -0400
commit00db3cba35211cd7d458d378a5931fadfa86a17c (patch)
tree6fb292cca023801c987d31ce7afa913d4d8f7e75
parent699efed00df0631e39a639b49e3b8e27e62e6c89 (diff)
bnxt_en: Add extended port statistics support
Gather periodic extended port statistics, if the device is PF and link is up. Signed-off-by: Vasundhara Volam <vasundhara-v.volam@broadcom.com> Signed-off-by: Michael Chan <michael.chan@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/broadcom/bnxt/bnxt.c45
-rw-r--r--drivers/net/ethernet/broadcom/bnxt/bnxt.h6
-rw-r--r--drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c32
3 files changed, 81 insertions, 2 deletions
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 527ef269fed0..2251327f8cdf 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -3059,12 +3059,21 @@ static void bnxt_free_stats(struct bnxt *bp)
3059 u32 size, i; 3059 u32 size, i;
3060 struct pci_dev *pdev = bp->pdev; 3060 struct pci_dev *pdev = bp->pdev;
3061 3061
3062 bp->flags &= ~BNXT_FLAG_PORT_STATS;
3063 bp->flags &= ~BNXT_FLAG_PORT_STATS_EXT;
3064
3062 if (bp->hw_rx_port_stats) { 3065 if (bp->hw_rx_port_stats) {
3063 dma_free_coherent(&pdev->dev, bp->hw_port_stats_size, 3066 dma_free_coherent(&pdev->dev, bp->hw_port_stats_size,
3064 bp->hw_rx_port_stats, 3067 bp->hw_rx_port_stats,
3065 bp->hw_rx_port_stats_map); 3068 bp->hw_rx_port_stats_map);
3066 bp->hw_rx_port_stats = NULL; 3069 bp->hw_rx_port_stats = NULL;
3067 bp->flags &= ~BNXT_FLAG_PORT_STATS; 3070 }
3071
3072 if (bp->hw_rx_port_stats_ext) {
3073 dma_free_coherent(&pdev->dev, sizeof(struct rx_port_stats_ext),
3074 bp->hw_rx_port_stats_ext,
3075 bp->hw_rx_port_stats_ext_map);
3076 bp->hw_rx_port_stats_ext = NULL;
3068 } 3077 }
3069 3078
3070 if (!bp->bnapi) 3079 if (!bp->bnapi)
@@ -3120,6 +3129,21 @@ static int bnxt_alloc_stats(struct bnxt *bp)
3120 bp->hw_tx_port_stats_map = bp->hw_rx_port_stats_map + 3129 bp->hw_tx_port_stats_map = bp->hw_rx_port_stats_map +
3121 sizeof(struct rx_port_stats) + 512; 3130 sizeof(struct rx_port_stats) + 512;
3122 bp->flags |= BNXT_FLAG_PORT_STATS; 3131 bp->flags |= BNXT_FLAG_PORT_STATS;
3132
3133 /* Display extended statistics only if FW supports it */
3134 if (bp->hwrm_spec_code < 0x10804 ||
3135 bp->hwrm_spec_code == 0x10900)
3136 return 0;
3137
3138 bp->hw_rx_port_stats_ext =
3139 dma_zalloc_coherent(&pdev->dev,
3140 sizeof(struct rx_port_stats_ext),
3141 &bp->hw_rx_port_stats_ext_map,
3142 GFP_KERNEL);
3143 if (!bp->hw_rx_port_stats_ext)
3144 return 0;
3145
3146 bp->flags |= BNXT_FLAG_PORT_STATS_EXT;
3123 } 3147 }
3124 return 0; 3148 return 0;
3125} 3149}
@@ -5340,6 +5364,21 @@ static int bnxt_hwrm_port_qstats(struct bnxt *bp)
5340 return rc; 5364 return rc;
5341} 5365}
5342 5366
5367static int bnxt_hwrm_port_qstats_ext(struct bnxt *bp)
5368{
5369 struct hwrm_port_qstats_ext_input req = {0};
5370 struct bnxt_pf_info *pf = &bp->pf;
5371
5372 if (!(bp->flags & BNXT_FLAG_PORT_STATS_EXT))
5373 return 0;
5374
5375 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_PORT_QSTATS_EXT, -1, -1);
5376 req.port_id = cpu_to_le16(pf->port_id);
5377 req.rx_stat_size = cpu_to_le16(sizeof(struct rx_port_stats_ext));
5378 req.rx_stat_host_addr = cpu_to_le64(bp->hw_rx_port_stats_ext_map);
5379 return hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
5380}
5381
5343static void bnxt_hwrm_free_tunnel_ports(struct bnxt *bp) 5382static void bnxt_hwrm_free_tunnel_ports(struct bnxt *bp)
5344{ 5383{
5345 if (bp->vxlan_port_cnt) { 5384 if (bp->vxlan_port_cnt) {
@@ -7491,8 +7530,10 @@ static void bnxt_sp_task(struct work_struct *work)
7491 bnxt_hwrm_tunnel_dst_port_free( 7530 bnxt_hwrm_tunnel_dst_port_free(
7492 bp, TUNNEL_DST_PORT_FREE_REQ_TUNNEL_TYPE_GENEVE); 7531 bp, TUNNEL_DST_PORT_FREE_REQ_TUNNEL_TYPE_GENEVE);
7493 } 7532 }
7494 if (test_and_clear_bit(BNXT_PERIODIC_STATS_SP_EVENT, &bp->sp_event)) 7533 if (test_and_clear_bit(BNXT_PERIODIC_STATS_SP_EVENT, &bp->sp_event)) {
7495 bnxt_hwrm_port_qstats(bp); 7534 bnxt_hwrm_port_qstats(bp);
7535 bnxt_hwrm_port_qstats_ext(bp);
7536 }
7496 7537
7497 if (test_and_clear_bit(BNXT_LINK_CHNG_SP_EVENT, &bp->sp_event)) { 7538 if (test_and_clear_bit(BNXT_LINK_CHNG_SP_EVENT, &bp->sp_event)) {
7498 int rc; 7539 int rc;
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
index ae7c69b44472..78034b504baa 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
@@ -1154,6 +1154,7 @@ struct bnxt {
1154 #define BNXT_FLAG_DIM 0x2000000 1154 #define BNXT_FLAG_DIM 0x2000000
1155 #define BNXT_FLAG_ROCE_MIRROR_CAP 0x4000000 1155 #define BNXT_FLAG_ROCE_MIRROR_CAP 0x4000000
1156 #define BNXT_FLAG_NEW_RM 0x8000000 1156 #define BNXT_FLAG_NEW_RM 0x8000000
1157 #define BNXT_FLAG_PORT_STATS_EXT 0x10000000
1157 1158
1158 #define BNXT_FLAG_ALL_CONFIG_FEATS (BNXT_FLAG_TPA | \ 1159 #define BNXT_FLAG_ALL_CONFIG_FEATS (BNXT_FLAG_TPA | \
1159 BNXT_FLAG_RFS | \ 1160 BNXT_FLAG_RFS | \
@@ -1273,8 +1274,10 @@ struct bnxt {
1273 1274
1274 struct rx_port_stats *hw_rx_port_stats; 1275 struct rx_port_stats *hw_rx_port_stats;
1275 struct tx_port_stats *hw_tx_port_stats; 1276 struct tx_port_stats *hw_tx_port_stats;
1277 struct rx_port_stats_ext *hw_rx_port_stats_ext;
1276 dma_addr_t hw_rx_port_stats_map; 1278 dma_addr_t hw_rx_port_stats_map;
1277 dma_addr_t hw_tx_port_stats_map; 1279 dma_addr_t hw_tx_port_stats_map;
1280 dma_addr_t hw_rx_port_stats_ext_map;
1278 int hw_port_stats_size; 1281 int hw_port_stats_size;
1279 1282
1280 u16 hwrm_max_req_len; 1283 u16 hwrm_max_req_len;
@@ -1385,6 +1388,9 @@ struct bnxt {
1385 ((offsetof(struct tx_port_stats, counter) + \ 1388 ((offsetof(struct tx_port_stats, counter) + \
1386 sizeof(struct rx_port_stats) + 512) / 8) 1389 sizeof(struct rx_port_stats) + 512) / 8)
1387 1390
1391#define BNXT_RX_STATS_EXT_OFFSET(counter) \
1392 (offsetof(struct rx_port_stats_ext, counter) / 8)
1393
1388#define I2C_DEV_ADDR_A0 0xa0 1394#define I2C_DEV_ADDR_A0 0xa0
1389#define I2C_DEV_ADDR_A2 0xa2 1395#define I2C_DEV_ADDR_A2 0xa2
1390#define SFP_EEPROM_SFF_8472_COMP_ADDR 0x5e 1396#define SFP_EEPROM_SFF_8472_COMP_ADDR 0x5e
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
index 859d4c0b5b31..e184e4bbe544 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
@@ -137,6 +137,9 @@ reset_coalesce:
137#define BNXT_TX_STATS_ENTRY(counter) \ 137#define BNXT_TX_STATS_ENTRY(counter) \
138 { BNXT_TX_STATS_OFFSET(counter), __stringify(counter) } 138 { BNXT_TX_STATS_OFFSET(counter), __stringify(counter) }
139 139
140#define BNXT_RX_STATS_EXT_ENTRY(counter) \
141 { BNXT_RX_STATS_EXT_OFFSET(counter), __stringify(counter) }
142
140static const struct { 143static const struct {
141 long offset; 144 long offset;
142 char string[ETH_GSTRING_LEN]; 145 char string[ETH_GSTRING_LEN];
@@ -223,7 +226,19 @@ static const struct {
223 BNXT_TX_STATS_ENTRY(tx_stat_error), 226 BNXT_TX_STATS_ENTRY(tx_stat_error),
224}; 227};
225 228
229static const struct {
230 long offset;
231 char string[ETH_GSTRING_LEN];
232} bnxt_port_stats_ext_arr[] = {
233 BNXT_RX_STATS_EXT_ENTRY(link_down_events),
234 BNXT_RX_STATS_EXT_ENTRY(continuous_pause_events),
235 BNXT_RX_STATS_EXT_ENTRY(resume_pause_events),
236 BNXT_RX_STATS_EXT_ENTRY(continuous_roce_pause_events),
237 BNXT_RX_STATS_EXT_ENTRY(resume_roce_pause_events),
238};
239
226#define BNXT_NUM_PORT_STATS ARRAY_SIZE(bnxt_port_stats_arr) 240#define BNXT_NUM_PORT_STATS ARRAY_SIZE(bnxt_port_stats_arr)
241#define BNXT_NUM_PORT_STATS_EXT ARRAY_SIZE(bnxt_port_stats_ext_arr)
227 242
228static int bnxt_get_num_stats(struct bnxt *bp) 243static int bnxt_get_num_stats(struct bnxt *bp)
229{ 244{
@@ -232,6 +247,9 @@ static int bnxt_get_num_stats(struct bnxt *bp)
232 if (bp->flags & BNXT_FLAG_PORT_STATS) 247 if (bp->flags & BNXT_FLAG_PORT_STATS)
233 num_stats += BNXT_NUM_PORT_STATS; 248 num_stats += BNXT_NUM_PORT_STATS;
234 249
250 if (bp->flags & BNXT_FLAG_PORT_STATS_EXT)
251 num_stats += BNXT_NUM_PORT_STATS_EXT;
252
235 return num_stats; 253 return num_stats;
236} 254}
237 255
@@ -279,6 +297,14 @@ static void bnxt_get_ethtool_stats(struct net_device *dev,
279 bnxt_port_stats_arr[i].offset)); 297 bnxt_port_stats_arr[i].offset));
280 } 298 }
281 } 299 }
300 if (bp->flags & BNXT_FLAG_PORT_STATS_EXT) {
301 __le64 *port_stats_ext = (__le64 *)bp->hw_rx_port_stats_ext;
302
303 for (i = 0; i < BNXT_NUM_PORT_STATS_EXT; i++, j++) {
304 buf[j] = le64_to_cpu(*(port_stats_ext +
305 bnxt_port_stats_ext_arr[i].offset));
306 }
307 }
282} 308}
283 309
284static void bnxt_get_strings(struct net_device *dev, u32 stringset, u8 *buf) 310static void bnxt_get_strings(struct net_device *dev, u32 stringset, u8 *buf)
@@ -339,6 +365,12 @@ static void bnxt_get_strings(struct net_device *dev, u32 stringset, u8 *buf)
339 buf += ETH_GSTRING_LEN; 365 buf += ETH_GSTRING_LEN;
340 } 366 }
341 } 367 }
368 if (bp->flags & BNXT_FLAG_PORT_STATS_EXT) {
369 for (i = 0; i < BNXT_NUM_PORT_STATS_EXT; i++) {
370 strcpy(buf, bnxt_port_stats_ext_arr[i].string);
371 buf += ETH_GSTRING_LEN;
372 }
373 }
342 break; 374 break;
343 case ETH_SS_TEST: 375 case ETH_SS_TEST:
344 if (bp->num_tests) 376 if (bp->num_tests)