Re: [PATCH net-next 7/7] eth: fbnic: support listing tcam content via debugfs

From
Kalesh Anakkur Purayil <kalesh-anakkur.purayil@broadcom.com>
Date
2025-02-07 02:46:32
Reply to
Jakub Kicinski, 2025-02-06
Hi Jakub,

One minor nit in line. Looks good otherwise.

On Fri, Feb 7, 2025 at 5:25 AM Jakub Kicinski [off-list ref] wrote:
quoted hunk ↗ jump to hunk
From: Alexander Duyck <redacted>

The device has a handful of relatively small TCAM tables,
support dumping the driver state via debugfs.

  # ethtool -N eth0 flow-type tcp6 \
      dst-ip 1111::2222 dst-port $((0x1122)) \
      src-ip 3333::4444 src-port $((0x3344)) \
      action 2
  Added rule with ID 47

  # cd $dbgfs
  # cat ip_src
  Idx S TCAM Bitmap       V Addr/Mask
  ------------------------------------
  00  1 00020000,00000000 6 33330000000000000000000000004444
                            00000000000000000000000000000000
  ...
  # cat ip_dst
  Idx S TCAM Bitmap       V Addr/Mask
  ------------------------------------
  00  1 00020000,00000000 6 11110000000000000000000000002222
                            00000000000000000000000000000000
  ...

  # cat act_tcam
  Idx S Value/Mask                                              RSS  Dest
  ------------------------------------------------------------------------
  ...
  49  1 0000 0000 0000 0000 0000 0000 1122 3344 0000 9c00 0088  000f 00000212
        ffff ffff ffff ffff ffff ffff 0000 0000 ffff 23ff ff00
  ...

The ipo_* tables are for outer IP addresses.
The tce_* table is for directing/stealing traffic to NC-SI.

Signed-off-by: Alexander Duyck <redacted>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 .../net/ethernet/meta/fbnic/fbnic_debugfs.c   | 138 ++++++++++++++++++
 1 file changed, 138 insertions(+)
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_debugfs.c b/drivers/net/ethernet/meta/fbnic/fbnic_debugfs.c
index ac80981f67c0..e8f2d7f2d962 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_debugfs.c
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_debugfs.c
@@ -44,6 +44,132 @@ static int fbnic_dbg_mac_addr_show(struct seq_file *s, void *v)
 }
 DEFINE_SHOW_ATTRIBUTE(fbnic_dbg_mac_addr);

+static int fbnic_dbg_tce_tcam_show(struct seq_file *s, void *v)
+{
+       struct fbnic_dev *fbd = s->private;
+       int i, tcam_idx = 0;
+       char hdr[80];
This magic number, 80 is used at multiple places. Can you have a macro for this?
quoted hunk ↗ jump to hunk
+
+       /* Generate Header */
+       snprintf(hdr, sizeof(hdr), "%3s %s %-17s %s\n",
+                "Idx", "S", "TCAM Bitmap", "Addr/Mask");
+       seq_puts(s, hdr);
+       fbnic_dbg_desc_break(s, strnlen(hdr, sizeof(hdr)));
+
+       for (i = 0; i < ARRAY_SIZE(fbd->mac_addr); i++) {
+               struct fbnic_mac_addr *mac_addr = &fbd->mac_addr[i];
+
+               /* Verify BMC bit is set */
+               if (!test_bit(FBNIC_MAC_ADDR_T_BMC, mac_addr->act_tcam))
+                       continue;
+
+               if (tcam_idx == FBNIC_TCE_TCAM_NUM_ENTRIES)
+                       break;
+
+               seq_printf(s, "%02d  %d %64pb %pm\n",
+                          tcam_idx, mac_addr->state, mac_addr->act_tcam,
+                          mac_addr->value.addr8);
+               seq_printf(s, "                        %pm\n",
+                          mac_addr->mask.addr8);
+               tcam_idx++;
+       }
+
+       return 0;
+}
+DEFINE_SHOW_ATTRIBUTE(fbnic_dbg_tce_tcam);
+
+static int fbnic_dbg_act_tcam_show(struct seq_file *s, void *v)
+{
+       struct fbnic_dev *fbd = s->private;
+       char hdr[80];
+       int i;
+
+       /* Generate Header */
+       snprintf(hdr, sizeof(hdr), "%3s %s %-55s %-4s %s\n",
+                "Idx", "S", "Value/Mask", "RSS", "Dest");
+       seq_puts(s, hdr);
+       fbnic_dbg_desc_break(s, strnlen(hdr, sizeof(hdr)));
+
+       for (i = 0; i < FBNIC_RPC_TCAM_ACT_NUM_ENTRIES; i++) {
+               struct fbnic_act_tcam *act_tcam = &fbd->act_tcam[i];
+
+               seq_printf(s, "%02d  %d %04x %04x %04x %04x %04x %04x %04x %04x %04x %04x %04x  %04x %08x\n",
+                          i, act_tcam->state,
+                          act_tcam->value.tcam[10], act_tcam->value.tcam[9],
+                          act_tcam->value.tcam[8], act_tcam->value.tcam[7],
+                          act_tcam->value.tcam[6], act_tcam->value.tcam[5],
+                          act_tcam->value.tcam[4], act_tcam->value.tcam[3],
+                          act_tcam->value.tcam[2], act_tcam->value.tcam[1],
+                          act_tcam->value.tcam[0], act_tcam->rss_en_mask,
+                          act_tcam->dest);
+               seq_printf(s, "      %04x %04x %04x %04x %04x %04x %04x %04x %04x %04x %04x\n",
+                          act_tcam->mask.tcam[10], act_tcam->mask.tcam[9],
+                          act_tcam->mask.tcam[8], act_tcam->mask.tcam[7],
+                          act_tcam->mask.tcam[6], act_tcam->mask.tcam[5],
+                          act_tcam->mask.tcam[4], act_tcam->mask.tcam[3],
+                          act_tcam->mask.tcam[2], act_tcam->mask.tcam[1],
+                          act_tcam->mask.tcam[0]);
+       }
+
+       return 0;
+}
+DEFINE_SHOW_ATTRIBUTE(fbnic_dbg_act_tcam);
+
+static int fbnic_dbg_ip_addr_show(struct seq_file *s,
+                                 struct fbnic_ip_addr *ip_addr)
+{
+       char hdr[80];
+       int i;
+
+       /* Generate Header */
+       snprintf(hdr, sizeof(hdr), "%3s %s %-17s %s %s\n",
+                "Idx", "S", "TCAM Bitmap", "V", "Addr/Mask");
+       seq_puts(s, hdr);
+       fbnic_dbg_desc_break(s, strnlen(hdr, sizeof(hdr)));
+
+       for (i = 0; i < FBNIC_RPC_TCAM_IP_ADDR_NUM_ENTRIES; i++, ip_addr++) {
+               seq_printf(s, "%02d  %d %64pb %d %pi6\n",
+                          i, ip_addr->state, ip_addr->act_tcam,
+                          ip_addr->version, &ip_addr->value);
+               seq_printf(s, "                          %pi6\n",
+                          &ip_addr->mask);
+       }
+
+       return 0;
+}
+
+static int fbnic_dbg_ip_src_show(struct seq_file *s, void *v)
+{
+       struct fbnic_dev *fbd = s->private;
+
+       return fbnic_dbg_ip_addr_show(s, fbd->ip_src);
+}
+DEFINE_SHOW_ATTRIBUTE(fbnic_dbg_ip_src);
+
+static int fbnic_dbg_ip_dst_show(struct seq_file *s, void *v)
+{
+       struct fbnic_dev *fbd = s->private;
+
+       return fbnic_dbg_ip_addr_show(s, fbd->ip_dst);
+}
+DEFINE_SHOW_ATTRIBUTE(fbnic_dbg_ip_dst);
+
+static int fbnic_dbg_ipo_src_show(struct seq_file *s, void *v)
+{
+       struct fbnic_dev *fbd = s->private;
+
+       return fbnic_dbg_ip_addr_show(s, fbd->ipo_src);
+}
+DEFINE_SHOW_ATTRIBUTE(fbnic_dbg_ipo_src);
+
+static int fbnic_dbg_ipo_dst_show(struct seq_file *s, void *v)
+{
+       struct fbnic_dev *fbd = s->private;
+
+       return fbnic_dbg_ip_addr_show(s, fbd->ipo_dst);
+}
+DEFINE_SHOW_ATTRIBUTE(fbnic_dbg_ipo_dst);
+
 static int fbnic_dbg_pcie_stats_show(struct seq_file *s, void *v)
 {
        struct fbnic_dev *fbd = s->private;
@@ -84,6 +210,18 @@ void fbnic_dbg_fbd_init(struct fbnic_dev *fbd)
                            &fbnic_dbg_pcie_stats_fops);
        debugfs_create_file("mac_addr", 0400, fbd->dbg_fbd, fbd,
                            &fbnic_dbg_mac_addr_fops);
+       debugfs_create_file("tce_tcam", 0400, fbd->dbg_fbd, fbd,
+                           &fbnic_dbg_tce_tcam_fops);
+       debugfs_create_file("act_tcam", 0400, fbd->dbg_fbd, fbd,
+                           &fbnic_dbg_act_tcam_fops);
+       debugfs_create_file("ip_src", 0400, fbd->dbg_fbd, fbd,
+                           &fbnic_dbg_ip_src_fops);
+       debugfs_create_file("ip_dst", 0400, fbd->dbg_fbd, fbd,
+                           &fbnic_dbg_ip_dst_fops);
+       debugfs_create_file("ipo_src", 0400, fbd->dbg_fbd, fbd,
+                           &fbnic_dbg_ipo_src_fops);
+       debugfs_create_file("ipo_dst", 0400, fbd->dbg_fbd, fbd,
+                           &fbnic_dbg_ipo_dst_fops);
 }

 void fbnic_dbg_fbd_exit(struct fbnic_dev *fbd)
--
2.48.1

-- 
Regards,
Kalesh AP

Attachments

Thread (19 messages) 19 messages, 6 authors, last reply 2025-02-12
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help