Skip to content

Commit 5797d3c

Browse files
ahduyckkuba-moo
authored andcommitted
eth: fbnic: support listing tcam content via debugfs
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 <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent d2348b4 commit 5797d3c

File tree

1 file changed

+138
-0
lines changed

1 file changed

+138
-0
lines changed

drivers/net/ethernet/meta/fbnic/fbnic_debugfs.c

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,132 @@ static int fbnic_dbg_mac_addr_show(struct seq_file *s, void *v)
4444
}
4545
DEFINE_SHOW_ATTRIBUTE(fbnic_dbg_mac_addr);
4646

47+
static int fbnic_dbg_tce_tcam_show(struct seq_file *s, void *v)
48+
{
49+
struct fbnic_dev *fbd = s->private;
50+
int i, tcam_idx = 0;
51+
char hdr[80];
52+
53+
/* Generate Header */
54+
snprintf(hdr, sizeof(hdr), "%3s %s %-17s %s\n",
55+
"Idx", "S", "TCAM Bitmap", "Addr/Mask");
56+
seq_puts(s, hdr);
57+
fbnic_dbg_desc_break(s, strnlen(hdr, sizeof(hdr)));
58+
59+
for (i = 0; i < ARRAY_SIZE(fbd->mac_addr); i++) {
60+
struct fbnic_mac_addr *mac_addr = &fbd->mac_addr[i];
61+
62+
/* Verify BMC bit is set */
63+
if (!test_bit(FBNIC_MAC_ADDR_T_BMC, mac_addr->act_tcam))
64+
continue;
65+
66+
if (tcam_idx == FBNIC_TCE_TCAM_NUM_ENTRIES)
67+
break;
68+
69+
seq_printf(s, "%02d %d %64pb %pm\n",
70+
tcam_idx, mac_addr->state, mac_addr->act_tcam,
71+
mac_addr->value.addr8);
72+
seq_printf(s, " %pm\n",
73+
mac_addr->mask.addr8);
74+
tcam_idx++;
75+
}
76+
77+
return 0;
78+
}
79+
DEFINE_SHOW_ATTRIBUTE(fbnic_dbg_tce_tcam);
80+
81+
static int fbnic_dbg_act_tcam_show(struct seq_file *s, void *v)
82+
{
83+
struct fbnic_dev *fbd = s->private;
84+
char hdr[80];
85+
int i;
86+
87+
/* Generate Header */
88+
snprintf(hdr, sizeof(hdr), "%3s %s %-55s %-4s %s\n",
89+
"Idx", "S", "Value/Mask", "RSS", "Dest");
90+
seq_puts(s, hdr);
91+
fbnic_dbg_desc_break(s, strnlen(hdr, sizeof(hdr)));
92+
93+
for (i = 0; i < FBNIC_RPC_TCAM_ACT_NUM_ENTRIES; i++) {
94+
struct fbnic_act_tcam *act_tcam = &fbd->act_tcam[i];
95+
96+
seq_printf(s, "%02d %d %04x %04x %04x %04x %04x %04x %04x %04x %04x %04x %04x %04x %08x\n",
97+
i, act_tcam->state,
98+
act_tcam->value.tcam[10], act_tcam->value.tcam[9],
99+
act_tcam->value.tcam[8], act_tcam->value.tcam[7],
100+
act_tcam->value.tcam[6], act_tcam->value.tcam[5],
101+
act_tcam->value.tcam[4], act_tcam->value.tcam[3],
102+
act_tcam->value.tcam[2], act_tcam->value.tcam[1],
103+
act_tcam->value.tcam[0], act_tcam->rss_en_mask,
104+
act_tcam->dest);
105+
seq_printf(s, " %04x %04x %04x %04x %04x %04x %04x %04x %04x %04x %04x\n",
106+
act_tcam->mask.tcam[10], act_tcam->mask.tcam[9],
107+
act_tcam->mask.tcam[8], act_tcam->mask.tcam[7],
108+
act_tcam->mask.tcam[6], act_tcam->mask.tcam[5],
109+
act_tcam->mask.tcam[4], act_tcam->mask.tcam[3],
110+
act_tcam->mask.tcam[2], act_tcam->mask.tcam[1],
111+
act_tcam->mask.tcam[0]);
112+
}
113+
114+
return 0;
115+
}
116+
DEFINE_SHOW_ATTRIBUTE(fbnic_dbg_act_tcam);
117+
118+
static int fbnic_dbg_ip_addr_show(struct seq_file *s,
119+
struct fbnic_ip_addr *ip_addr)
120+
{
121+
char hdr[80];
122+
int i;
123+
124+
/* Generate Header */
125+
snprintf(hdr, sizeof(hdr), "%3s %s %-17s %s %s\n",
126+
"Idx", "S", "TCAM Bitmap", "V", "Addr/Mask");
127+
seq_puts(s, hdr);
128+
fbnic_dbg_desc_break(s, strnlen(hdr, sizeof(hdr)));
129+
130+
for (i = 0; i < FBNIC_RPC_TCAM_IP_ADDR_NUM_ENTRIES; i++, ip_addr++) {
131+
seq_printf(s, "%02d %d %64pb %d %pi6\n",
132+
i, ip_addr->state, ip_addr->act_tcam,
133+
ip_addr->version, &ip_addr->value);
134+
seq_printf(s, " %pi6\n",
135+
&ip_addr->mask);
136+
}
137+
138+
return 0;
139+
}
140+
141+
static int fbnic_dbg_ip_src_show(struct seq_file *s, void *v)
142+
{
143+
struct fbnic_dev *fbd = s->private;
144+
145+
return fbnic_dbg_ip_addr_show(s, fbd->ip_src);
146+
}
147+
DEFINE_SHOW_ATTRIBUTE(fbnic_dbg_ip_src);
148+
149+
static int fbnic_dbg_ip_dst_show(struct seq_file *s, void *v)
150+
{
151+
struct fbnic_dev *fbd = s->private;
152+
153+
return fbnic_dbg_ip_addr_show(s, fbd->ip_dst);
154+
}
155+
DEFINE_SHOW_ATTRIBUTE(fbnic_dbg_ip_dst);
156+
157+
static int fbnic_dbg_ipo_src_show(struct seq_file *s, void *v)
158+
{
159+
struct fbnic_dev *fbd = s->private;
160+
161+
return fbnic_dbg_ip_addr_show(s, fbd->ipo_src);
162+
}
163+
DEFINE_SHOW_ATTRIBUTE(fbnic_dbg_ipo_src);
164+
165+
static int fbnic_dbg_ipo_dst_show(struct seq_file *s, void *v)
166+
{
167+
struct fbnic_dev *fbd = s->private;
168+
169+
return fbnic_dbg_ip_addr_show(s, fbd->ipo_dst);
170+
}
171+
DEFINE_SHOW_ATTRIBUTE(fbnic_dbg_ipo_dst);
172+
47173
static int fbnic_dbg_pcie_stats_show(struct seq_file *s, void *v)
48174
{
49175
struct fbnic_dev *fbd = s->private;
@@ -84,6 +210,18 @@ void fbnic_dbg_fbd_init(struct fbnic_dev *fbd)
84210
&fbnic_dbg_pcie_stats_fops);
85211
debugfs_create_file("mac_addr", 0400, fbd->dbg_fbd, fbd,
86212
&fbnic_dbg_mac_addr_fops);
213+
debugfs_create_file("tce_tcam", 0400, fbd->dbg_fbd, fbd,
214+
&fbnic_dbg_tce_tcam_fops);
215+
debugfs_create_file("act_tcam", 0400, fbd->dbg_fbd, fbd,
216+
&fbnic_dbg_act_tcam_fops);
217+
debugfs_create_file("ip_src", 0400, fbd->dbg_fbd, fbd,
218+
&fbnic_dbg_ip_src_fops);
219+
debugfs_create_file("ip_dst", 0400, fbd->dbg_fbd, fbd,
220+
&fbnic_dbg_ip_dst_fops);
221+
debugfs_create_file("ipo_src", 0400, fbd->dbg_fbd, fbd,
222+
&fbnic_dbg_ipo_src_fops);
223+
debugfs_create_file("ipo_dst", 0400, fbd->dbg_fbd, fbd,
224+
&fbnic_dbg_ipo_dst_fops);
87225
}
88226

89227
void fbnic_dbg_fbd_exit(struct fbnic_dev *fbd)

0 commit comments

Comments
 (0)