diff mbox series

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

Message ID 20250206235334.1425329-8-kuba@kernel.org (mailing list archive)
State Accepted
Commit 5797d3c62db81fd03ba7aeb36a83b44fb0ac2ecc
Delegated to: Netdev Maintainers
Headers show
Series eth: fbnic: support RSS contexts and ntuple filters | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next, async
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 2 maintainers not CCed: kernel-team@meta.com alexanderduyck@fb.com
netdev/build_clang success Errors and warnings before: 2 this patch: 2
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 150 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2025-02-07--21-00 (tests: 890)

Commit Message

Jakub Kicinski Feb. 6, 2025, 11:53 p.m. UTC
From: Alexander Duyck <alexanderduyck@meta.com>

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 <alexanderduyck@meta.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 .../net/ethernet/meta/fbnic/fbnic_debugfs.c   | 138 ++++++++++++++++++
 1 file changed, 138 insertions(+)

Comments

Kalesh Anakkur Purayil Feb. 7, 2025, 2:46 a.m. UTC | #1
Hi Jakub,

One minor nit in line. Looks good otherwise.

On Fri, Feb 7, 2025 at 5:25 AM Jakub Kicinski <kuba@kernel.org> wrote:
>
> From: Alexander Duyck <alexanderduyck@meta.com>
>
> 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 <alexanderduyck@meta.com>
> 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?
> +
> +       /* 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
>
>
Jakub Kicinski Feb. 7, 2025, 3:15 a.m. UTC | #2
On Fri, 7 Feb 2025 08:16:18 +0530 Kalesh Anakkur Purayil wrote:
> > +       char hdr[80];  
> This magic number, 80 is used at multiple places. Can you have a macro for this?

Can do, tho, it doesn't have any particular meaning.
It's just the default terminal width.
diff mbox series

Patch

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];
+
+	/* 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)