Skip to content

Commit dbc52de

Browse files
Hariprasad Kelamdavem330
authored andcommitted
octeontx2-af: Debugfs support for DMAC filters
Add debugfs support to display CGX/RPM DMAC filter table associated with pf. cat /sys/kernel/debug/octeontx2/cgx/cgx0/lmac0/mac_filter PCI dev RVUPF BROADCAST MULTICAST FILTER-MODE 0002:02:00.0 PF2 ACCEPT ACCEPT UNICAST DMAC-INDEX ADDRESS 0 00:0f:b7:06:17:06 1 1a:1b:1c:1d:1e:01 2 1a:1b:1c:1d:1e:02 Signed-off-by: Hariprasad Kelam <[email protected]> Signed-off-by: Sunil Kovvuri Goutham <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 6f14078 commit dbc52de

File tree

5 files changed

+113
-9
lines changed

5 files changed

+113
-9
lines changed

drivers/net/ethernet/marvell/octeontx2/af/cgx.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,34 @@ int cgx_lmac_addr_set(u8 cgx_id, u8 lmac_id, u8 *mac_addr)
266266
return 0;
267267
}
268268

269+
u64 cgx_read_dmac_ctrl(void *cgxd, int lmac_id)
270+
{
271+
struct mac_ops *mac_ops;
272+
struct cgx *cgx = cgxd;
273+
274+
if (!cgxd || !is_lmac_valid(cgxd, lmac_id))
275+
return 0;
276+
277+
cgx = cgxd;
278+
/* Get mac_ops to know csr offset */
279+
mac_ops = cgx->mac_ops;
280+
281+
return cgx_read(cgxd, lmac_id, CGXX_CMRX_RX_DMAC_CTL0);
282+
}
283+
284+
u64 cgx_read_dmac_entry(void *cgxd, int index)
285+
{
286+
struct mac_ops *mac_ops;
287+
struct cgx *cgx;
288+
289+
if (!cgxd)
290+
return 0;
291+
292+
cgx = cgxd;
293+
mac_ops = cgx->mac_ops;
294+
return cgx_read(cgx, 0, (CGXX_CMRX_RX_DMAC_CAM0 + (index * 8)));
295+
}
296+
269297
int cgx_lmac_addr_add(u8 cgx_id, u8 lmac_id, u8 *mac_addr)
270298
{
271299
struct cgx *cgx_dev = cgx_get_pdata(cgx_id);

drivers/net/ethernet/marvell/octeontx2/af/cgx.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
#define CGX_DMAC_BCAST_MODE BIT_ULL(0)
5353
#define CGXX_CMRX_RX_DMAC_CAM0 (0x200 + mac_ops->csr_offset)
5454
#define CGX_DMAC_CAM_ADDR_ENABLE BIT_ULL(48)
55+
#define CGX_DMAC_CAM_ENTRY_LMACID GENMASK_ULL(50, 49)
5556
#define CGXX_CMRX_RX_DMAC_CAM1 0x400
5657
#define CGX_RX_DMAC_ADR_MASK GENMASK_ULL(47, 0)
5758
#define CGXX_CMRX_TX_STAT0 0x700
@@ -172,4 +173,6 @@ unsigned long cgx_get_lmac_bmap(void *cgxd);
172173
void cgx_lmac_write(int cgx_id, int lmac_id, u64 offset, u64 val);
173174
u64 cgx_lmac_read(int cgx_id, int lmac_id, u64 offset);
174175
int cgx_lmac_addr_update(u8 cgx_id, u8 lmac_id, u8 *mac_addr, u8 index);
176+
u64 cgx_read_dmac_ctrl(void *cgxd, int lmac_id);
177+
u64 cgx_read_dmac_entry(void *cgxd, int index);
175178
#endif /* CGX_H */

drivers/net/ethernet/marvell/octeontx2/af/rvu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,7 @@ void npc_read_mcam_entry(struct rvu *rvu, struct npc_mcam *mcam,
744744
bool is_mac_feature_supported(struct rvu *rvu, int pf, int feature);
745745
u32 rvu_cgx_get_fifolen(struct rvu *rvu);
746746
void *rvu_first_cgx_pdata(struct rvu *rvu);
747+
int cgxlmac_to_pf(struct rvu *rvu, int cgx_id, int lmac_id);
747748

748749
int npc_get_nixlf_mcam_index(struct npc_mcam *mcam, u16 pcifunc, int nixlf,
749750
int type);

drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ static u16 cgxlmac_to_pfmap(struct rvu *rvu, u8 cgx_id, u8 lmac_id)
6363
return rvu->cgxlmac2pf_map[CGX_OFFSET(cgx_id) + lmac_id];
6464
}
6565

66-
static int cgxlmac_to_pf(struct rvu *rvu, int cgx_id, int lmac_id)
66+
int cgxlmac_to_pf(struct rvu *rvu, int cgx_id, int lmac_id)
6767
{
6868
unsigned long pfmap;
6969

drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c

Lines changed: 80 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1971,28 +1971,97 @@ static int cgx_print_stats(struct seq_file *s, int lmac_id)
19711971
return err;
19721972
}
19731973

1974-
static int rvu_dbg_cgx_stat_display(struct seq_file *filp, void *unused)
1974+
static int rvu_dbg_derive_lmacid(struct seq_file *filp, int *lmac_id)
19751975
{
19761976
struct dentry *current_dir;
1977-
int err, lmac_id;
19781977
char *buf;
19791978

19801979
current_dir = filp->file->f_path.dentry->d_parent;
19811980
buf = strrchr(current_dir->d_name.name, 'c');
19821981
if (!buf)
19831982
return -EINVAL;
19841983

1985-
err = kstrtoint(buf + 1, 10, &lmac_id);
1986-
if (!err) {
1987-
err = cgx_print_stats(filp, lmac_id);
1988-
if (err)
1989-
return err;
1990-
}
1984+
return kstrtoint(buf + 1, 10, lmac_id);
1985+
}
1986+
1987+
static int rvu_dbg_cgx_stat_display(struct seq_file *filp, void *unused)
1988+
{
1989+
int lmac_id, err;
1990+
1991+
err = rvu_dbg_derive_lmacid(filp, &lmac_id);
1992+
if (!err)
1993+
return cgx_print_stats(filp, lmac_id);
1994+
19911995
return err;
19921996
}
19931997

19941998
RVU_DEBUG_SEQ_FOPS(cgx_stat, cgx_stat_display, NULL);
19951999

2000+
static int cgx_print_dmac_flt(struct seq_file *s, int lmac_id)
2001+
{
2002+
struct pci_dev *pdev = NULL;
2003+
void *cgxd = s->private;
2004+
char *bcast, *mcast;
2005+
u16 index, domain;
2006+
u8 dmac[ETH_ALEN];
2007+
struct rvu *rvu;
2008+
u64 cfg, mac;
2009+
int pf;
2010+
2011+
rvu = pci_get_drvdata(pci_get_device(PCI_VENDOR_ID_CAVIUM,
2012+
PCI_DEVID_OCTEONTX2_RVU_AF, NULL));
2013+
if (!rvu)
2014+
return -ENODEV;
2015+
2016+
pf = cgxlmac_to_pf(rvu, cgx_get_cgxid(cgxd), lmac_id);
2017+
domain = 2;
2018+
2019+
pdev = pci_get_domain_bus_and_slot(domain, pf + 1, 0);
2020+
if (!pdev)
2021+
return 0;
2022+
2023+
cfg = cgx_read_dmac_ctrl(cgxd, lmac_id);
2024+
bcast = cfg & CGX_DMAC_BCAST_MODE ? "ACCEPT" : "REJECT";
2025+
mcast = cfg & CGX_DMAC_MCAST_MODE ? "ACCEPT" : "REJECT";
2026+
2027+
seq_puts(s,
2028+
"PCI dev RVUPF BROADCAST MULTICAST FILTER-MODE\n");
2029+
seq_printf(s, "%s PF%d %9s %9s",
2030+
dev_name(&pdev->dev), pf, bcast, mcast);
2031+
if (cfg & CGX_DMAC_CAM_ACCEPT)
2032+
seq_printf(s, "%12s\n\n", "UNICAST");
2033+
else
2034+
seq_printf(s, "%16s\n\n", "PROMISCUOUS");
2035+
2036+
seq_puts(s, "\nDMAC-INDEX ADDRESS\n");
2037+
2038+
for (index = 0 ; index < 32 ; index++) {
2039+
cfg = cgx_read_dmac_entry(cgxd, index);
2040+
/* Display enabled dmac entries associated with current lmac */
2041+
if (lmac_id == FIELD_GET(CGX_DMAC_CAM_ENTRY_LMACID, cfg) &&
2042+
FIELD_GET(CGX_DMAC_CAM_ADDR_ENABLE, cfg)) {
2043+
mac = FIELD_GET(CGX_RX_DMAC_ADR_MASK, cfg);
2044+
u64_to_ether_addr(mac, dmac);
2045+
seq_printf(s, "%7d %pM\n", index, dmac);
2046+
}
2047+
}
2048+
2049+
return 0;
2050+
}
2051+
2052+
static int rvu_dbg_cgx_dmac_flt_display(struct seq_file *filp, void *unused)
2053+
{
2054+
int err, lmac_id;
2055+
2056+
err = rvu_dbg_derive_lmacid(filp, &lmac_id);
2057+
if (!err)
2058+
return cgx_print_dmac_flt(filp, lmac_id);
2059+
2060+
return err;
2061+
}
2062+
2063+
RVU_DEBUG_SEQ_FOPS(cgx_dmac_flt, cgx_dmac_flt_display, NULL);
2064+
19962065
static void rvu_dbg_cgx_init(struct rvu *rvu)
19972066
{
19982067
struct mac_ops *mac_ops;
@@ -2029,6 +2098,9 @@ static void rvu_dbg_cgx_init(struct rvu *rvu)
20292098

20302099
debugfs_create_file("stats", 0600, rvu->rvu_dbg.lmac,
20312100
cgx, &rvu_dbg_cgx_stat_fops);
2101+
debugfs_create_file("mac_filter", 0600,
2102+
rvu->rvu_dbg.lmac, cgx,
2103+
&rvu_dbg_cgx_dmac_flt_fops);
20322104
}
20332105
}
20342106
}

0 commit comments

Comments
 (0)