hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/drivers/net/ethernet/intel/i40e/i40e_debugfs.c
....@@ -10,6 +10,12 @@
1010
1111 static struct dentry *i40e_dbg_root;
1212
13
+enum ring_type {
14
+ RING_TYPE_RX,
15
+ RING_TYPE_TX,
16
+ RING_TYPE_XDP
17
+};
18
+
1319 /**
1420 * i40e_dbg_find_vsi - searches for the vsi with the given seid
1521 * @pf: the PF structure to search for the vsi
....@@ -132,8 +138,6 @@
132138 dev_info(&pf->pdev->dev, " vlan_features = 0x%08lx\n",
133139 (unsigned long int)nd->vlan_features);
134140 }
135
- dev_info(&pf->pdev->dev, " active_vlans is %s\n",
136
- vsi->active_vlans ? "<valid>" : "<null>");
137141 dev_info(&pf->pdev->dev,
138142 " flags = 0x%08lx, netdev_registered = %i, current_netdev_flags = 0x%04x\n",
139143 vsi->flags, vsi->netdev_registered, vsi->current_netdev_flags);
....@@ -321,6 +325,47 @@
321325 i, tx_ring->itr_setting,
322326 ITR_IS_DYNAMIC(tx_ring->itr_setting) ? "dynamic" : "fixed");
323327 }
328
+ if (i40e_enabled_xdp_vsi(vsi)) {
329
+ for (i = 0; i < vsi->num_queue_pairs; i++) {
330
+ struct i40e_ring *xdp_ring = READ_ONCE(vsi->xdp_rings[i]);
331
+
332
+ if (!xdp_ring)
333
+ continue;
334
+
335
+ dev_info(&pf->pdev->dev,
336
+ " xdp_rings[%i]: state = %lu, queue_index = %d, reg_idx = %d\n",
337
+ i, *xdp_ring->state,
338
+ xdp_ring->queue_index,
339
+ xdp_ring->reg_idx);
340
+ dev_info(&pf->pdev->dev,
341
+ " xdp_rings[%i]: next_to_use = %d, next_to_clean = %d, ring_active = %i\n",
342
+ i,
343
+ xdp_ring->next_to_use,
344
+ xdp_ring->next_to_clean,
345
+ xdp_ring->ring_active);
346
+ dev_info(&pf->pdev->dev,
347
+ " xdp_rings[%i]: tx_stats: packets = %lld, bytes = %lld, restart_queue = %lld\n",
348
+ i, xdp_ring->stats.packets,
349
+ xdp_ring->stats.bytes,
350
+ xdp_ring->tx_stats.restart_queue);
351
+ dev_info(&pf->pdev->dev,
352
+ " xdp_rings[%i]: tx_stats: tx_busy = %lld, tx_done_old = %lld\n",
353
+ i,
354
+ xdp_ring->tx_stats.tx_busy,
355
+ xdp_ring->tx_stats.tx_done_old);
356
+ dev_info(&pf->pdev->dev,
357
+ " xdp_rings[%i]: size = %i\n",
358
+ i, xdp_ring->size);
359
+ dev_info(&pf->pdev->dev,
360
+ " xdp_rings[%i]: DCB tc = %d\n",
361
+ i, xdp_ring->dcb_tc);
362
+ dev_info(&pf->pdev->dev,
363
+ " xdp_rings[%i]: itr_setting = %d (%s)\n",
364
+ i, xdp_ring->itr_setting,
365
+ ITR_IS_DYNAMIC(xdp_ring->itr_setting) ?
366
+ "dynamic" : "fixed");
367
+ }
368
+ }
324369 rcu_read_unlock();
325370 dev_info(&pf->pdev->dev,
326371 " work_limit = %d\n",
....@@ -335,8 +380,9 @@
335380 " seid = %d, id = %d, uplink_seid = %d\n",
336381 vsi->seid, vsi->id, vsi->uplink_seid);
337382 dev_info(&pf->pdev->dev,
338
- " base_queue = %d, num_queue_pairs = %d, num_desc = %d\n",
339
- vsi->base_queue, vsi->num_queue_pairs, vsi->num_desc);
383
+ " base_queue = %d, num_queue_pairs = %d, num_tx_desc = %d, num_rx_desc = %d\n",
384
+ vsi->base_queue, vsi->num_queue_pairs, vsi->num_tx_desc,
385
+ vsi->num_rx_desc);
340386 dev_info(&pf->pdev->dev, " type = %i\n", vsi->type);
341387 if (vsi->type == I40E_VSI_SRIOV)
342388 dev_info(&pf->pdev->dev, " VF ID = %i\n", vsi->vf_id);
....@@ -490,11 +536,12 @@
490536 * @ring_id: ring id entered by user
491537 * @desc_n: descriptor number entered by user
492538 * @pf: the i40e_pf created in command write
493
- * @is_rx_ring: true if rx, false if tx
539
+ * @type: enum describing whether ring is RX, TX or XDP
494540 **/
495541 static void i40e_dbg_dump_desc(int cnt, int vsi_seid, int ring_id, int desc_n,
496
- struct i40e_pf *pf, bool is_rx_ring)
542
+ struct i40e_pf *pf, enum ring_type type)
497543 {
544
+ bool is_rx_ring = type == RING_TYPE_RX;
498545 struct i40e_tx_desc *txd;
499546 union i40e_rx_desc *rxd;
500547 struct i40e_ring *ring;
....@@ -504,6 +551,18 @@
504551 vsi = i40e_dbg_find_vsi(pf, vsi_seid);
505552 if (!vsi) {
506553 dev_info(&pf->pdev->dev, "vsi %d not found\n", vsi_seid);
554
+ return;
555
+ }
556
+ if (vsi->type != I40E_VSI_MAIN &&
557
+ vsi->type != I40E_VSI_FDIR &&
558
+ vsi->type != I40E_VSI_VMDQ2) {
559
+ dev_info(&pf->pdev->dev,
560
+ "vsi %d type %d descriptor rings not available\n",
561
+ vsi_seid, vsi->type);
562
+ return;
563
+ }
564
+ if (type == RING_TYPE_XDP && !i40e_enabled_xdp_vsi(vsi)) {
565
+ dev_info(&pf->pdev->dev, "XDP not enabled on VSI %d\n", vsi_seid);
507566 return;
508567 }
509568 if (ring_id >= vsi->num_queue_pairs || ring_id < 0) {
....@@ -517,15 +576,35 @@
517576 return;
518577 }
519578
520
- ring = kmemdup(is_rx_ring
521
- ? vsi->rx_rings[ring_id] : vsi->tx_rings[ring_id],
522
- sizeof(*ring), GFP_KERNEL);
579
+ switch (type) {
580
+ case RING_TYPE_RX:
581
+ ring = kmemdup(vsi->rx_rings[ring_id], sizeof(*ring), GFP_KERNEL);
582
+ break;
583
+ case RING_TYPE_TX:
584
+ ring = kmemdup(vsi->tx_rings[ring_id], sizeof(*ring), GFP_KERNEL);
585
+ break;
586
+ case RING_TYPE_XDP:
587
+ ring = kmemdup(vsi->xdp_rings[ring_id], sizeof(*ring), GFP_KERNEL);
588
+ break;
589
+ default:
590
+ ring = NULL;
591
+ break;
592
+ }
523593 if (!ring)
524594 return;
525595
526596 if (cnt == 2) {
527
- dev_info(&pf->pdev->dev, "vsi = %02i %s ring = %02i\n",
528
- vsi_seid, is_rx_ring ? "rx" : "tx", ring_id);
597
+ switch (type) {
598
+ case RING_TYPE_RX:
599
+ dev_info(&pf->pdev->dev, "VSI = %02i Rx ring = %02i\n", vsi_seid, ring_id);
600
+ break;
601
+ case RING_TYPE_TX:
602
+ dev_info(&pf->pdev->dev, "VSI = %02i Tx ring = %02i\n", vsi_seid, ring_id);
603
+ break;
604
+ case RING_TYPE_XDP:
605
+ dev_info(&pf->pdev->dev, "VSI = %02i XDP ring = %02i\n", vsi_seid, ring_id);
606
+ break;
607
+ }
529608 for (i = 0; i < ring->count; i++) {
530609 if (!is_rx_ring) {
531610 txd = I40E_TX_DESC(ring, i);
....@@ -536,10 +615,9 @@
536615 } else {
537616 rxd = I40E_RX_DESC(ring, i);
538617 dev_info(&pf->pdev->dev,
539
- " d[%03x] = 0x%016llx 0x%016llx 0x%016llx 0x%016llx\n",
618
+ " d[%03x] = 0x%016llx 0x%016llx\n",
540619 i, rxd->read.pkt_addr,
541
- rxd->read.hdr_addr,
542
- rxd->read.rsvd1, rxd->read.rsvd2);
620
+ rxd->read.hdr_addr);
543621 }
544622 }
545623 } else if (cnt == 3) {
....@@ -557,13 +635,12 @@
557635 } else {
558636 rxd = I40E_RX_DESC(ring, desc_n);
559637 dev_info(&pf->pdev->dev,
560
- "vsi = %02i rx ring = %02i d[%03x] = 0x%016llx 0x%016llx 0x%016llx 0x%016llx\n",
638
+ "vsi = %02i rx ring = %02i d[%03x] = 0x%016llx 0x%016llx\n",
561639 vsi_seid, ring_id, desc_n,
562
- rxd->read.pkt_addr, rxd->read.hdr_addr,
563
- rxd->read.rsvd1, rxd->read.rsvd2);
640
+ rxd->read.pkt_addr, rxd->read.hdr_addr);
564641 }
565642 } else {
566
- dev_info(&pf->pdev->dev, "dump desc rx/tx <vsi_seid> <ring_id> [<desc_n>]\n");
643
+ dev_info(&pf->pdev->dev, "dump desc rx/tx/xdp <vsi_seid> <ring_id> [<desc_n>]\n");
567644 }
568645
569646 out:
....@@ -665,10 +742,8 @@
665742 vsi = pf->vsi[vf->lan_vsi_idx];
666743 dev_info(&pf->pdev->dev, "vf %2d: VSI id=%d, seid=%d, qps=%d\n",
667744 vf_id, vf->lan_vsi_id, vsi->seid, vf->num_queue_pairs);
668
- dev_info(&pf->pdev->dev, " num MDD=%lld, invalid msg=%lld, valid msg=%lld\n",
669
- vf->num_mdd_events,
670
- vf->num_invalid_msgs,
671
- vf->num_valid_msgs);
745
+ dev_info(&pf->pdev->dev, " num MDD=%lld\n",
746
+ vf->num_mdd_events);
672747 } else {
673748 dev_info(&pf->pdev->dev, "invalid VF id %d\n", vf_id);
674749 }
....@@ -689,7 +764,6 @@
689764 i40e_dbg_dump_vf(pf, i);
690765 }
691766
692
-#define I40E_MAX_DEBUG_OUT_BUFFER (4096*4)
693767 /**
694768 * i40e_dbg_command_write - write into command datum
695769 * @filp: the opened file
....@@ -921,13 +995,19 @@
921995 cnt = sscanf(&cmd_buf[12], "%i %i %i",
922996 &vsi_seid, &ring_id, &desc_n);
923997 i40e_dbg_dump_desc(cnt, vsi_seid, ring_id,
924
- desc_n, pf, true);
998
+ desc_n, pf, RING_TYPE_RX);
925999 } else if (strncmp(&cmd_buf[10], "tx", 2)
9261000 == 0) {
9271001 cnt = sscanf(&cmd_buf[12], "%i %i %i",
9281002 &vsi_seid, &ring_id, &desc_n);
9291003 i40e_dbg_dump_desc(cnt, vsi_seid, ring_id,
930
- desc_n, pf, false);
1004
+ desc_n, pf, RING_TYPE_TX);
1005
+ } else if (strncmp(&cmd_buf[10], "xdp", 3)
1006
+ == 0) {
1007
+ cnt = sscanf(&cmd_buf[13], "%i %i %i",
1008
+ &vsi_seid, &ring_id, &desc_n);
1009
+ i40e_dbg_dump_desc(cnt, vsi_seid, ring_id,
1010
+ desc_n, pf, RING_TYPE_XDP);
9311011 } else if (strncmp(&cmd_buf[10], "aq", 2) == 0) {
9321012 i40e_dbg_dump_aq_desc(pf);
9331013 } else {
....@@ -935,6 +1015,8 @@
9351015 "dump desc tx <vsi_seid> <ring_id> [<desc_n>]\n");
9361016 dev_info(&pf->pdev->dev,
9371017 "dump desc rx <vsi_seid> <ring_id> [<desc_n>]\n");
1018
+ dev_info(&pf->pdev->dev,
1019
+ "dump desc xdp <vsi_seid> <ring_id> [<desc_n>]\n");
9381020 dev_info(&pf->pdev->dev, "dump desc aq\n");
9391021 }
9401022 } else if (strncmp(&cmd_buf[5], "reset stats", 11) == 0) {
....@@ -1105,7 +1187,7 @@
11051187 buff = NULL;
11061188 } else {
11071189 dev_info(&pf->pdev->dev,
1108
- "dump desc tx <vsi_seid> <ring_id> [<desc_n>], dump desc rx <vsi_seid> <ring_id> [<desc_n>],\n");
1190
+ "dump desc tx <vsi_seid> <ring_id> [<desc_n>], dump desc rx <vsi_seid> <ring_id> [<desc_n>], dump desc xdp <vsi_seid> <ring_id> [<desc_n>],\n");
11091191 dev_info(&pf->pdev->dev, "dump switch\n");
11101192 dev_info(&pf->pdev->dev, "dump vsi [seid]\n");
11111193 dev_info(&pf->pdev->dev, "dump reset stats\n");
....@@ -1125,10 +1207,6 @@
11251207 } else if (strncmp(cmd_buf, "globr", 5) == 0) {
11261208 dev_info(&pf->pdev->dev, "debugfs: forcing GlobR\n");
11271209 i40e_do_reset_safe(pf, BIT(__I40E_GLOBAL_RESET_REQUESTED));
1128
-
1129
- } else if (strncmp(cmd_buf, "empr", 4) == 0) {
1130
- dev_info(&pf->pdev->dev, "debugfs: forcing EMPR\n");
1131
- i40e_do_reset_safe(pf, BIT(__I40E_EMP_RESET_REQUESTED));
11321210
11331211 } else if (strncmp(cmd_buf, "read", 4) == 0) {
11341212 u32 address;
....@@ -1323,7 +1401,7 @@
13231401 if (strncmp(&cmd_buf[5], "stop", 4) == 0) {
13241402 int ret;
13251403
1326
- ret = i40e_aq_stop_lldp(&pf->hw, false, NULL);
1404
+ ret = i40e_aq_stop_lldp(&pf->hw, false, false, NULL);
13271405 if (ret) {
13281406 dev_info(&pf->pdev->dev,
13291407 "Stop LLDP AQ command failed =0x%x\n",
....@@ -1332,7 +1410,7 @@
13321410 }
13331411 ret = i40e_aq_add_rem_control_packet_filter(&pf->hw,
13341412 pf->hw.mac.addr,
1335
- I40E_ETH_P_LLDP, 0,
1413
+ ETH_P_LLDP, 0,
13361414 pf->vsi[pf->lan_vsi]->seid,
13371415 0, true, NULL, NULL);
13381416 if (ret) {
....@@ -1350,7 +1428,7 @@
13501428
13511429 ret = i40e_aq_add_rem_control_packet_filter(&pf->hw,
13521430 pf->hw.mac.addr,
1353
- I40E_ETH_P_LLDP, 0,
1431
+ ETH_P_LLDP, 0,
13541432 pf->vsi[pf->lan_vsi]->seid,
13551433 0, false, NULL, NULL);
13561434 if (ret) {
....@@ -1360,7 +1438,7 @@
13601438 /* Continue and start FW LLDP anyways */
13611439 }
13621440
1363
- ret = i40e_aq_start_lldp(&pf->hw, NULL);
1441
+ ret = i40e_aq_start_lldp(&pf->hw, false, NULL);
13641442 if (ret) {
13651443 dev_info(&pf->pdev->dev,
13661444 "Start LLDP AQ command failed =0x%x\n",
....@@ -1525,6 +1603,7 @@
15251603 dev_info(&pf->pdev->dev, " dump vsi [seid]\n");
15261604 dev_info(&pf->pdev->dev, " dump desc tx <vsi_seid> <ring_id> [<desc_n>]\n");
15271605 dev_info(&pf->pdev->dev, " dump desc rx <vsi_seid> <ring_id> [<desc_n>]\n");
1606
+ dev_info(&pf->pdev->dev, " dump desc xdp <vsi_seid> <ring_id> [<desc_n>]\n");
15281607 dev_info(&pf->pdev->dev, " dump desc aq\n");
15291608 dev_info(&pf->pdev->dev, " dump reset stats\n");
15301609 dev_info(&pf->pdev->dev, " dump debug fwdata <cluster_id> <table_id> <index>\n");
....@@ -1644,30 +1723,7 @@
16441723 count = buf_tmp - i40e_dbg_netdev_ops_buf + 1;
16451724 }
16461725
1647
- if (strncmp(i40e_dbg_netdev_ops_buf, "tx_timeout", 10) == 0) {
1648
- cnt = sscanf(&i40e_dbg_netdev_ops_buf[11], "%i", &vsi_seid);
1649
- if (cnt != 1) {
1650
- dev_info(&pf->pdev->dev, "tx_timeout <vsi_seid>\n");
1651
- goto netdev_ops_write_done;
1652
- }
1653
- vsi = i40e_dbg_find_vsi(pf, vsi_seid);
1654
- if (!vsi) {
1655
- dev_info(&pf->pdev->dev,
1656
- "tx_timeout: VSI %d not found\n", vsi_seid);
1657
- } else if (!vsi->netdev) {
1658
- dev_info(&pf->pdev->dev, "tx_timeout: no netdev for VSI %d\n",
1659
- vsi_seid);
1660
- } else if (test_bit(__I40E_VSI_DOWN, vsi->state)) {
1661
- dev_info(&pf->pdev->dev, "tx_timeout: VSI %d not UP\n",
1662
- vsi_seid);
1663
- } else if (rtnl_trylock()) {
1664
- vsi->netdev->netdev_ops->ndo_tx_timeout(vsi->netdev);
1665
- rtnl_unlock();
1666
- dev_info(&pf->pdev->dev, "tx_timeout called\n");
1667
- } else {
1668
- dev_info(&pf->pdev->dev, "Could not acquire RTNL - please try again\n");
1669
- }
1670
- } else if (strncmp(i40e_dbg_netdev_ops_buf, "change_mtu", 10) == 0) {
1726
+ if (strncmp(i40e_dbg_netdev_ops_buf, "change_mtu", 10) == 0) {
16711727 int mtu;
16721728
16731729 cnt = sscanf(&i40e_dbg_netdev_ops_buf[11], "%i %i",
....@@ -1735,7 +1791,6 @@
17351791 dev_info(&pf->pdev->dev, "unknown command '%s'\n",
17361792 i40e_dbg_netdev_ops_buf);
17371793 dev_info(&pf->pdev->dev, "available commands\n");
1738
- dev_info(&pf->pdev->dev, " tx_timeout <vsi_seid>\n");
17391794 dev_info(&pf->pdev->dev, " change_mtu <vsi_seid> <mtu>\n");
17401795 dev_info(&pf->pdev->dev, " set_rx_mode <vsi_seid>\n");
17411796 dev_info(&pf->pdev->dev, " napi <vsi_seid>\n");
....@@ -1757,29 +1812,15 @@
17571812 **/
17581813 void i40e_dbg_pf_init(struct i40e_pf *pf)
17591814 {
1760
- struct dentry *pfile;
17611815 const char *name = pci_name(pf->pdev);
1762
- const struct device *dev = &pf->pdev->dev;
17631816
17641817 pf->i40e_dbg_pf = debugfs_create_dir(name, i40e_dbg_root);
1765
- if (!pf->i40e_dbg_pf)
1766
- return;
17671818
1768
- pfile = debugfs_create_file("command", 0600, pf->i40e_dbg_pf, pf,
1769
- &i40e_dbg_command_fops);
1770
- if (!pfile)
1771
- goto create_failed;
1819
+ debugfs_create_file("command", 0600, pf->i40e_dbg_pf, pf,
1820
+ &i40e_dbg_command_fops);
17721821
1773
- pfile = debugfs_create_file("netdev_ops", 0600, pf->i40e_dbg_pf, pf,
1774
- &i40e_dbg_netdev_ops_fops);
1775
- if (!pfile)
1776
- goto create_failed;
1777
-
1778
- return;
1779
-
1780
-create_failed:
1781
- dev_info(dev, "debugfs dir/file for %s failed\n", name);
1782
- debugfs_remove_recursive(pf->i40e_dbg_pf);
1822
+ debugfs_create_file("netdev_ops", 0600, pf->i40e_dbg_pf, pf,
1823
+ &i40e_dbg_netdev_ops_fops);
17831824 }
17841825
17851826 /**