aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGanesh Goudar <ganeshgr@chelsio.com>2018-08-10 05:17:01 -0400
committerDavid S. Miller <davem@davemloft.net>2018-08-10 13:26:28 -0400
commitebddd97afb89cb1e88cc037aef2913ad4723a59f (patch)
tree0ec6be0ef98d1cc6bfa1d0955a6e687be422f706
parente4ed2b9eff1dcc4ed7a85fa1e63f86b471215416 (diff)
cxgb4: add support to display DCB info
display Data Center bridging information in debug fs. Signed-off-by: Casey Leedom <leedom@chelsio.com> Signed-off-by: Ganesh Goudar <ganeshgr@chelsio.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/cxgb4.h1
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c2
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c193
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c3
4 files changed, 197 insertions, 2 deletions
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index 3da9299cd786..76d16747f513 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -1853,4 +1853,5 @@ void cxgb4_write_sgl(const struct sk_buff *skb, struct sge_txq *q,
1853void cxgb4_ring_tx_db(struct adapter *adap, struct sge_txq *q, int n); 1853void cxgb4_ring_tx_db(struct adapter *adap, struct sge_txq *q, int n);
1854int t4_set_vlan_acl(struct adapter *adap, unsigned int mbox, unsigned int vf, 1854int t4_set_vlan_acl(struct adapter *adap, unsigned int mbox, unsigned int vf,
1855 u16 vlan); 1855 u16 vlan);
1856int cxgb4_dcb_enabled(const struct net_device *dev);
1856#endif /* __CXGB4_H__ */ 1857#endif /* __CXGB4_H__ */
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c
index 4e7f72b17e82..b34f0f077a31 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c
@@ -22,7 +22,7 @@
22 22
23/* DCBx version control 23/* DCBx version control
24 */ 24 */
25static const char * const dcb_ver_array[] = { 25const char * const dcb_ver_array[] = {
26 "Unknown", 26 "Unknown",
27 "DCBx-CIN", 27 "DCBx-CIN",
28 "DCBx-CEE 1.01", 28 "DCBx-CEE 1.01",
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
index 6f312e03432f..0f72f9c4ec74 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
@@ -2414,6 +2414,196 @@ static const struct file_operations rss_vf_config_debugfs_fops = {
2414 .release = seq_release_private 2414 .release = seq_release_private
2415}; 2415};
2416 2416
2417#ifdef CONFIG_CHELSIO_T4_DCB
2418extern char *dcb_ver_array[];
2419
2420/* Data Center Briging information for each port.
2421 */
2422static int dcb_info_show(struct seq_file *seq, void *v)
2423{
2424 struct adapter *adap = seq->private;
2425
2426 if (v == SEQ_START_TOKEN) {
2427 seq_puts(seq, "Data Center Bridging Information\n");
2428 } else {
2429 int port = (uintptr_t)v - 2;
2430 struct net_device *dev = adap->port[port];
2431 struct port_info *pi = netdev2pinfo(dev);
2432 struct port_dcb_info *dcb = &pi->dcb;
2433
2434 seq_puts(seq, "\n");
2435 seq_printf(seq, "Port: %d (DCB negotiated: %s)\n",
2436 port,
2437 cxgb4_dcb_enabled(dev) ? "yes" : "no");
2438
2439 if (cxgb4_dcb_enabled(dev))
2440 seq_printf(seq, "[ DCBx Version %s ]\n",
2441 dcb_ver_array[dcb->dcb_version]);
2442
2443 if (dcb->msgs) {
2444 int i;
2445
2446 seq_puts(seq, "\n Index\t\t\t :\t");
2447 for (i = 0; i < 8; i++)
2448 seq_printf(seq, " %3d", i);
2449 seq_puts(seq, "\n\n");
2450 }
2451
2452 if (dcb->msgs & CXGB4_DCB_FW_PGID) {
2453 int prio, pgid;
2454
2455 seq_puts(seq, " Priority Group IDs\t :\t");
2456 for (prio = 0; prio < 8; prio++) {
2457 pgid = (dcb->pgid >> 4 * (7 - prio)) & 0xf;
2458 seq_printf(seq, " %3d", pgid);
2459 }
2460 seq_puts(seq, "\n");
2461 }
2462
2463 if (dcb->msgs & CXGB4_DCB_FW_PGRATE) {
2464 int pg;
2465
2466 seq_puts(seq, " Priority Group BW(%)\t :\t");
2467 for (pg = 0; pg < 8; pg++)
2468 seq_printf(seq, " %3d", dcb->pgrate[pg]);
2469 seq_puts(seq, "\n");
2470
2471 if (dcb->dcb_version == FW_PORT_DCB_VER_IEEE) {
2472 seq_puts(seq, " TSA Algorithm\t\t :\t");
2473 for (pg = 0; pg < 8; pg++)
2474 seq_printf(seq, " %3d", dcb->tsa[pg]);
2475 seq_puts(seq, "\n");
2476 }
2477
2478 seq_printf(seq, " Max PG Traffic Classes [%3d ]\n",
2479 dcb->pg_num_tcs_supported);
2480
2481 seq_puts(seq, "\n");
2482 }
2483
2484 if (dcb->msgs & CXGB4_DCB_FW_PRIORATE) {
2485 int prio;
2486
2487 seq_puts(seq, " Priority Rate\t:\t");
2488 for (prio = 0; prio < 8; prio++)
2489 seq_printf(seq, " %3d", dcb->priorate[prio]);
2490 seq_puts(seq, "\n");
2491 }
2492
2493 if (dcb->msgs & CXGB4_DCB_FW_PFC) {
2494 int prio;
2495
2496 seq_puts(seq, " Priority Flow Control :\t");
2497 for (prio = 0; prio < 8; prio++) {
2498 int pfcen = (dcb->pfcen >> 1 * (7 - prio))
2499 & 0x1;
2500 seq_printf(seq, " %3d", pfcen);
2501 }
2502 seq_puts(seq, "\n");
2503
2504 seq_printf(seq, " Max PFC Traffic Classes [%3d ]\n",
2505 dcb->pfc_num_tcs_supported);
2506
2507 seq_puts(seq, "\n");
2508 }
2509
2510 if (dcb->msgs & CXGB4_DCB_FW_APP_ID) {
2511 int app, napps;
2512
2513 seq_puts(seq, " Application Information:\n");
2514 seq_puts(seq, " App Priority Selection Protocol\n");
2515 seq_puts(seq, " Index Map Field ID\n");
2516 for (app = 0, napps = 0;
2517 app < CXGB4_MAX_DCBX_APP_SUPPORTED; app++) {
2518 struct app_priority *ap;
2519 static const char * const sel_names[] = {
2520 "Ethertype",
2521 "Socket TCP",
2522 "Socket UDP",
2523 "Socket All",
2524 };
2525 const char *sel_name;
2526
2527 ap = &dcb->app_priority[app];
2528 /* skip empty slots */
2529 if (ap->protocolid == 0)
2530 continue;
2531 napps++;
2532
2533 if (ap->sel_field < ARRAY_SIZE(sel_names))
2534 sel_name = sel_names[ap->sel_field];
2535 else
2536 sel_name = "UNKNOWN";
2537
2538 seq_printf(seq, " %3d %#04x %-10s (%d) %#06x (%d)\n",
2539 app,
2540 ap->user_prio_map,
2541 sel_name, ap->sel_field,
2542 ap->protocolid, ap->protocolid);
2543 }
2544 if (napps == 0)
2545 seq_puts(seq, " --- None ---\n");
2546 }
2547 }
2548 return 0;
2549}
2550
2551static inline void *dcb_info_get_idx(struct adapter *adap, loff_t pos)
2552{
2553 return (pos <= adap->params.nports
2554 ? (void *)((uintptr_t)pos + 1)
2555 : NULL);
2556}
2557
2558static void *dcb_info_start(struct seq_file *seq, loff_t *pos)
2559{
2560 struct adapter *adap = seq->private;
2561
2562 return (*pos
2563 ? dcb_info_get_idx(adap, *pos)
2564 : SEQ_START_TOKEN);
2565}
2566
2567static void dcb_info_stop(struct seq_file *seq, void *v)
2568{
2569}
2570
2571static void *dcb_info_next(struct seq_file *seq, void *v, loff_t *pos)
2572{
2573 struct adapter *adap = seq->private;
2574
2575 (*pos)++;
2576 return dcb_info_get_idx(adap, *pos);
2577}
2578
2579static const struct seq_operations dcb_info_seq_ops = {
2580 .start = dcb_info_start,
2581 .next = dcb_info_next,
2582 .stop = dcb_info_stop,
2583 .show = dcb_info_show
2584};
2585
2586static int dcb_info_open(struct inode *inode, struct file *file)
2587{
2588 int res = seq_open(file, &dcb_info_seq_ops);
2589
2590 if (!res) {
2591 struct seq_file *seq = file->private_data;
2592
2593 seq->private = inode->i_private;
2594 }
2595 return res;
2596}
2597
2598static const struct file_operations dcb_info_debugfs_fops = {
2599 .owner = THIS_MODULE,
2600 .open = dcb_info_open,
2601 .read = seq_read,
2602 .llseek = seq_lseek,
2603 .release = seq_release,
2604};
2605#endif /* CONFIG_CHELSIO_T4_DCB */
2606
2417static int resources_show(struct seq_file *seq, void *v) 2607static int resources_show(struct seq_file *seq, void *v)
2418{ 2608{
2419 struct adapter *adapter = seq->private; 2609 struct adapter *adapter = seq->private;
@@ -3435,6 +3625,9 @@ int t4_setup_debugfs(struct adapter *adap)
3435 { "rss_pf_config", &rss_pf_config_debugfs_fops, 0400, 0 }, 3625 { "rss_pf_config", &rss_pf_config_debugfs_fops, 0400, 0 },
3436 { "rss_vf_config", &rss_vf_config_debugfs_fops, 0400, 0 }, 3626 { "rss_vf_config", &rss_vf_config_debugfs_fops, 0400, 0 },
3437 { "resources", &resources_debugfs_fops, 0400, 0 }, 3627 { "resources", &resources_debugfs_fops, 0400, 0 },
3628#ifdef CONFIG_CHELSIO_T4_DCB
3629 { "dcb_info", &dcb_info_debugfs_fops, 0400, 0 },
3630#endif
3438 { "sge_qinfo", &sge_qinfo_debugfs_fops, 0400, 0 }, 3631 { "sge_qinfo", &sge_qinfo_debugfs_fops, 0400, 0 },
3439 { "ibq_tp0", &cim_ibq_fops, 0400, 0 }, 3632 { "ibq_tp0", &cim_ibq_fops, 0400, 0 },
3440 { "ibq_tp1", &cim_ibq_fops, 0400, 1 }, 3633 { "ibq_tp1", &cim_ibq_fops, 0400, 1 },
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 0f7ce71205e6..69590cff2a2d 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -267,7 +267,7 @@ static void dcb_tx_queue_prio_enable(struct net_device *dev, int enable)
267 } 267 }
268} 268}
269 269
270static int cxgb4_dcb_enabled(const struct net_device *dev) 270int cxgb4_dcb_enabled(const struct net_device *dev)
271{ 271{
272 struct port_info *pi = netdev_priv(dev); 272 struct port_info *pi = netdev_priv(dev);
273 273
@@ -5658,6 +5658,7 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
5658#ifdef CONFIG_CHELSIO_T4_DCB 5658#ifdef CONFIG_CHELSIO_T4_DCB
5659 netdev->dcbnl_ops = &cxgb4_dcb_ops; 5659 netdev->dcbnl_ops = &cxgb4_dcb_ops;
5660 cxgb4_dcb_state_init(netdev); 5660 cxgb4_dcb_state_init(netdev);
5661 cxgb4_dcb_version_init(netdev);
5661#endif 5662#endif
5662 cxgb4_set_ethtool_ops(netdev); 5663 cxgb4_set_ethtool_ops(netdev);
5663 } 5664 }