Skip to content

Commit ef82f66

Browse files
Hariprasad Shenaidavem330
authored andcommitted
cxgb4: Add support for mps_tcam debugfs
Debug log to get the MPS TCAM table Signed-off-by: Hariprasad Shenai <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 74b3092 commit ef82f66

File tree

2 files changed

+191
-0
lines changed

2 files changed

+191
-0
lines changed

drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,136 @@ static const struct file_operations devlog_fops = {
433433
.release = seq_release_private
434434
};
435435

436+
static inline void tcamxy2valmask(u64 x, u64 y, u8 *addr, u64 *mask)
437+
{
438+
*mask = x | y;
439+
y = (__force u64)cpu_to_be64(y);
440+
memcpy(addr, (char *)&y + 2, ETH_ALEN);
441+
}
442+
443+
static int mps_tcam_show(struct seq_file *seq, void *v)
444+
{
445+
if (v == SEQ_START_TOKEN)
446+
seq_puts(seq, "Idx Ethernet address Mask Vld Ports PF"
447+
" VF Replication "
448+
"P0 P1 P2 P3 ML\n");
449+
else {
450+
u64 mask;
451+
u8 addr[ETH_ALEN];
452+
struct adapter *adap = seq->private;
453+
unsigned int idx = (uintptr_t)v - 2;
454+
u64 tcamy = t4_read_reg64(adap, MPS_CLS_TCAM_Y_L(idx));
455+
u64 tcamx = t4_read_reg64(adap, MPS_CLS_TCAM_X_L(idx));
456+
u32 cls_lo = t4_read_reg(adap, MPS_CLS_SRAM_L(idx));
457+
u32 cls_hi = t4_read_reg(adap, MPS_CLS_SRAM_H(idx));
458+
u32 rplc[4] = {0, 0, 0, 0};
459+
460+
if (tcamx & tcamy) {
461+
seq_printf(seq, "%3u -\n", idx);
462+
goto out;
463+
}
464+
465+
if (cls_lo & REPLICATE_F) {
466+
struct fw_ldst_cmd ldst_cmd;
467+
int ret;
468+
469+
memset(&ldst_cmd, 0, sizeof(ldst_cmd));
470+
ldst_cmd.op_to_addrspace =
471+
htonl(FW_CMD_OP_V(FW_LDST_CMD) |
472+
FW_CMD_REQUEST_F |
473+
FW_CMD_READ_F |
474+
FW_LDST_CMD_ADDRSPACE_V(
475+
FW_LDST_ADDRSPC_MPS));
476+
ldst_cmd.cycles_to_len16 = htonl(FW_LEN16(ldst_cmd));
477+
ldst_cmd.u.mps.fid_ctl =
478+
htons(FW_LDST_CMD_FID_V(FW_LDST_MPS_RPLC) |
479+
FW_LDST_CMD_CTL_V(idx));
480+
ret = t4_wr_mbox(adap, adap->mbox, &ldst_cmd,
481+
sizeof(ldst_cmd), &ldst_cmd);
482+
if (ret)
483+
dev_warn(adap->pdev_dev, "Can't read MPS "
484+
"replication map for idx %d: %d\n",
485+
idx, -ret);
486+
else {
487+
rplc[0] = ntohl(ldst_cmd.u.mps.rplc31_0);
488+
rplc[1] = ntohl(ldst_cmd.u.mps.rplc63_32);
489+
rplc[2] = ntohl(ldst_cmd.u.mps.rplc95_64);
490+
rplc[3] = ntohl(ldst_cmd.u.mps.rplc127_96);
491+
}
492+
}
493+
494+
tcamxy2valmask(tcamx, tcamy, addr, &mask);
495+
seq_printf(seq, "%3u %02x:%02x:%02x:%02x:%02x:%02x %012llx"
496+
"%3c %#x%4u%4d",
497+
idx, addr[0], addr[1], addr[2], addr[3], addr[4],
498+
addr[5], (unsigned long long)mask,
499+
(cls_lo & SRAM_VLD_F) ? 'Y' : 'N', PORTMAP_G(cls_hi),
500+
PF_G(cls_lo),
501+
(cls_lo & VF_VALID_F) ? VF_G(cls_lo) : -1);
502+
if (cls_lo & REPLICATE_F)
503+
seq_printf(seq, " %08x %08x %08x %08x",
504+
rplc[3], rplc[2], rplc[1], rplc[0]);
505+
else
506+
seq_printf(seq, "%36c", ' ');
507+
seq_printf(seq, "%4u%3u%3u%3u %#x\n",
508+
SRAM_PRIO0_G(cls_lo), SRAM_PRIO1_G(cls_lo),
509+
SRAM_PRIO2_G(cls_lo), SRAM_PRIO3_G(cls_lo),
510+
(cls_lo >> MULTILISTEN0_S) & 0xf);
511+
}
512+
out: return 0;
513+
}
514+
515+
static inline void *mps_tcam_get_idx(struct seq_file *seq, loff_t pos)
516+
{
517+
struct adapter *adap = seq->private;
518+
int max_mac_addr = is_t4(adap->params.chip) ?
519+
NUM_MPS_CLS_SRAM_L_INSTANCES :
520+
NUM_MPS_T5_CLS_SRAM_L_INSTANCES;
521+
return ((pos <= max_mac_addr) ? (void *)(uintptr_t)(pos + 1) : NULL);
522+
}
523+
524+
static void *mps_tcam_start(struct seq_file *seq, loff_t *pos)
525+
{
526+
return *pos ? mps_tcam_get_idx(seq, *pos) : SEQ_START_TOKEN;
527+
}
528+
529+
static void *mps_tcam_next(struct seq_file *seq, void *v, loff_t *pos)
530+
{
531+
++*pos;
532+
return mps_tcam_get_idx(seq, *pos);
533+
}
534+
535+
static void mps_tcam_stop(struct seq_file *seq, void *v)
536+
{
537+
}
538+
539+
static const struct seq_operations mps_tcam_seq_ops = {
540+
.start = mps_tcam_start,
541+
.next = mps_tcam_next,
542+
.stop = mps_tcam_stop,
543+
.show = mps_tcam_show
544+
};
545+
546+
static int mps_tcam_open(struct inode *inode, struct file *file)
547+
{
548+
int res = seq_open(file, &mps_tcam_seq_ops);
549+
550+
if (!res) {
551+
struct seq_file *seq = file->private_data;
552+
553+
seq->private = inode->i_private;
554+
}
555+
return res;
556+
}
557+
558+
static const struct file_operations mps_tcam_debugfs_fops = {
559+
.owner = THIS_MODULE,
560+
.open = mps_tcam_open,
561+
.read = seq_read,
562+
.llseek = seq_lseek,
563+
.release = seq_release,
564+
};
565+
436566
static ssize_t mem_read(struct file *file, char __user *buf, size_t count,
437567
loff_t *ppos)
438568
{
@@ -515,6 +645,7 @@ int t4_setup_debugfs(struct adapter *adap)
515645
{ "cim_qcfg", &cim_qcfg_fops, S_IRUSR, 0 },
516646
{ "devlog", &devlog_fops, S_IRUSR, 0 },
517647
{ "l2t", &t4_l2t_fops, S_IRUSR, 0},
648+
{ "mps_tcam", &mps_tcam_debugfs_fops, S_IRUSR, 0 },
518649
};
519650

520651
add_debugfs_files(adap,

drivers/net/ethernet/chelsio/cxgb4/t4_regs.h

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1708,6 +1708,66 @@
17081708

17091709
#define MPS_RX_PERR_INT_CAUSE_A 0x11074
17101710

1711+
#define MPS_CLS_TCAM_Y_L_A 0xf000
1712+
#define MPS_CLS_TCAM_X_L_A 0xf008
1713+
1714+
#define MPS_CLS_TCAM_Y_L(idx) (MPS_CLS_TCAM_Y_L_A + (idx) * 16)
1715+
#define NUM_MPS_CLS_TCAM_Y_L_INSTANCES 512
1716+
1717+
#define MPS_CLS_TCAM_X_L(idx) (MPS_CLS_TCAM_X_L_A + (idx) * 16)
1718+
#define NUM_MPS_CLS_TCAM_X_L_INSTANCES 512
1719+
1720+
#define MPS_CLS_SRAM_L_A 0xe000
1721+
#define MPS_CLS_SRAM_H_A 0xe004
1722+
1723+
#define MPS_CLS_SRAM_L(idx) (MPS_CLS_SRAM_L_A + (idx) * 8)
1724+
#define NUM_MPS_CLS_SRAM_L_INSTANCES 336
1725+
1726+
#define MPS_CLS_SRAM_H(idx) (MPS_CLS_SRAM_H_A + (idx) * 8)
1727+
#define NUM_MPS_CLS_SRAM_H_INSTANCES 336
1728+
1729+
#define MULTILISTEN0_S 25
1730+
1731+
#define REPLICATE_S 11
1732+
#define REPLICATE_V(x) ((x) << REPLICATE_S)
1733+
#define REPLICATE_F REPLICATE_V(1U)
1734+
1735+
#define PF_S 8
1736+
#define PF_M 0x7U
1737+
#define PF_G(x) (((x) >> PF_S) & PF_M)
1738+
1739+
#define VF_VALID_S 7
1740+
#define VF_VALID_V(x) ((x) << VF_VALID_S)
1741+
#define VF_VALID_F VF_VALID_V(1U)
1742+
1743+
#define VF_S 0
1744+
#define VF_M 0x7fU
1745+
#define VF_G(x) (((x) >> VF_S) & VF_M)
1746+
1747+
#define SRAM_PRIO3_S 22
1748+
#define SRAM_PRIO3_M 0x7U
1749+
#define SRAM_PRIO3_G(x) (((x) >> SRAM_PRIO3_S) & SRAM_PRIO3_M)
1750+
1751+
#define SRAM_PRIO2_S 19
1752+
#define SRAM_PRIO2_M 0x7U
1753+
#define SRAM_PRIO2_G(x) (((x) >> SRAM_PRIO2_S) & SRAM_PRIO2_M)
1754+
1755+
#define SRAM_PRIO1_S 16
1756+
#define SRAM_PRIO1_M 0x7U
1757+
#define SRAM_PRIO1_G(x) (((x) >> SRAM_PRIO1_S) & SRAM_PRIO1_M)
1758+
1759+
#define SRAM_PRIO0_S 13
1760+
#define SRAM_PRIO0_M 0x7U
1761+
#define SRAM_PRIO0_G(x) (((x) >> SRAM_PRIO0_S) & SRAM_PRIO0_M)
1762+
1763+
#define SRAM_VLD_S 12
1764+
#define SRAM_VLD_V(x) ((x) << SRAM_VLD_S)
1765+
#define SRAM_VLD_F SRAM_VLD_V(1U)
1766+
1767+
#define PORTMAP_S 0
1768+
#define PORTMAP_M 0xfU
1769+
#define PORTMAP_G(x) (((x) >> PORTMAP_S) & PORTMAP_M)
1770+
17111771
#define CPL_INTR_CAUSE_A 0x19054
17121772

17131773
#define CIM_OP_MAP_PERR_S 5

0 commit comments

Comments
 (0)