Skip to content

Commit 9428148

Browse files
HoratiuVulturdavem330
authored andcommitted
net: lan966x: Add VCAP debugFS support
Enable debugfs for vcap for lan966x. This will allow to print all the entries in the VCAP and also the port information regarding which keys are configured. Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 64e09d0 commit 9428148

File tree

5 files changed

+136
-16
lines changed

5 files changed

+136
-16
lines changed

drivers/net/ethernet/microchip/lan966x/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,7 @@ lan966x-switch-objs := lan966x_main.o lan966x_phylink.o lan966x_port.o \
1515
lan966x_xdp.o lan966x_vcap_impl.o lan966x_vcap_ag_api.o \
1616
lan966x_tc_flower.o lan966x_goto.o
1717

18+
lan966x-switch-$(CONFIG_DEBUG_FS) += lan966x_vcap_debugfs.o
19+
1820
# Provide include files
1921
ccflags-y += -I$(srctree)/drivers/net/ethernet/microchip/vcap

drivers/net/ethernet/microchip/lan966x/lan966x_main.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,8 @@ static int lan966x_probe(struct platform_device *pdev)
10351035
platform_set_drvdata(pdev, lan966x);
10361036
lan966x->dev = &pdev->dev;
10371037

1038+
lan966x->debugfs_root = debugfs_create_dir("lan966x", NULL);
1039+
10381040
if (!device_get_mac_address(&pdev->dev, mac_addr)) {
10391041
ether_addr_copy(lan966x->base_mac, mac_addr);
10401042
} else {
@@ -1223,6 +1225,8 @@ static int lan966x_remove(struct platform_device *pdev)
12231225
lan966x_fdb_deinit(lan966x);
12241226
lan966x_ptp_deinit(lan966x);
12251227

1228+
debugfs_remove_recursive(lan966x->debugfs_root);
1229+
12261230
return 0;
12271231
}
12281232

drivers/net/ethernet/microchip/lan966x/lan966x_main.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#ifndef __LAN966X_MAIN_H__
44
#define __LAN966X_MAIN_H__
55

6+
#include <linux/debugfs.h>
67
#include <linux/etherdevice.h>
78
#include <linux/if_vlan.h>
89
#include <linux/jiffies.h>
@@ -14,6 +15,9 @@
1415
#include <net/pkt_sched.h>
1516
#include <net/switchdev.h>
1617

18+
#include <vcap_api.h>
19+
#include <vcap_api_client.h>
20+
1721
#include "lan966x_regs.h"
1822
#include "lan966x_ifh.h"
1923

@@ -128,6 +132,13 @@ enum LAN966X_PORT_MASK_MODE {
128132
LAN966X_PMM_REDIRECT,
129133
};
130134

135+
enum vcap_is2_port_sel_ipv6 {
136+
VCAP_IS2_PS_IPV6_TCPUDP_OTHER,
137+
VCAP_IS2_PS_IPV6_STD,
138+
VCAP_IS2_PS_IPV6_IP4_TCPUDP_IP4_OTHER,
139+
VCAP_IS2_PS_IPV6_MAC_ETYPE,
140+
};
141+
131142
struct lan966x_port;
132143

133144
struct lan966x_db {
@@ -315,6 +326,9 @@ struct lan966x {
315326

316327
/* vcap */
317328
struct vcap_control *vcap_ctrl;
329+
330+
/* debugfs */
331+
struct dentry *debugfs_root;
318332
};
319333

320334
struct lan966x_port_config {
@@ -601,6 +615,18 @@ static inline bool lan966x_xdp_port_present(struct lan966x_port *port)
601615

602616
int lan966x_vcap_init(struct lan966x *lan966x);
603617
void lan966x_vcap_deinit(struct lan966x *lan966x);
618+
#if defined(CONFIG_DEBUG_FS)
619+
int lan966x_vcap_port_info(struct net_device *dev,
620+
struct vcap_admin *admin,
621+
struct vcap_output_print *out);
622+
#else
623+
static inline int lan966x_vcap_port_info(struct net_device *dev,
624+
struct vcap_admin *admin,
625+
struct vcap_output_print *out)
626+
{
627+
return 0;
628+
}
629+
#endif
604630

605631
int lan966x_tc_flower(struct lan966x_port *port,
606632
struct flow_cls_offload *f,
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
// SPDX-License-Identifier: GPL-2.0+
2+
3+
#include "lan966x_main.h"
4+
#include "lan966x_vcap_ag_api.h"
5+
#include "vcap_api.h"
6+
#include "vcap_api_client.h"
7+
8+
static void lan966x_vcap_port_keys(struct lan966x_port *port,
9+
struct vcap_admin *admin,
10+
struct vcap_output_print *out)
11+
{
12+
struct lan966x *lan966x = port->lan966x;
13+
u32 val;
14+
15+
out->prf(out->dst, " port[%d] (%s): ", port->chip_port,
16+
netdev_name(port->dev));
17+
18+
val = lan_rd(lan966x, ANA_VCAP_S2_CFG(port->chip_port));
19+
out->prf(out->dst, "\n state: ");
20+
if (ANA_VCAP_S2_CFG_ENA_GET(val))
21+
out->prf(out->dst, "on");
22+
else
23+
out->prf(out->dst, "off");
24+
25+
for (int l = 0; l < admin->lookups; ++l) {
26+
out->prf(out->dst, "\n Lookup %d: ", l);
27+
28+
out->prf(out->dst, "\n snap: ");
29+
if (ANA_VCAP_S2_CFG_SNAP_DIS_GET(val) & (BIT(0) << l))
30+
out->prf(out->dst, "mac_llc");
31+
else
32+
out->prf(out->dst, "mac_snap");
33+
34+
out->prf(out->dst, "\n oam: ");
35+
if (ANA_VCAP_S2_CFG_OAM_DIS_GET(val) & (BIT(0) << l))
36+
out->prf(out->dst, "mac_etype");
37+
else
38+
out->prf(out->dst, "mac_oam");
39+
40+
out->prf(out->dst, "\n arp: ");
41+
if (ANA_VCAP_S2_CFG_ARP_DIS_GET(val) & (BIT(0) << l))
42+
out->prf(out->dst, "mac_etype");
43+
else
44+
out->prf(out->dst, "mac_arp");
45+
46+
out->prf(out->dst, "\n ipv4_other: ");
47+
if (ANA_VCAP_S2_CFG_IP_OTHER_DIS_GET(val) & (BIT(0) << l))
48+
out->prf(out->dst, "mac_etype");
49+
else
50+
out->prf(out->dst, "ip4_other");
51+
52+
out->prf(out->dst, "\n ipv4_tcp_udp: ");
53+
if (ANA_VCAP_S2_CFG_IP_TCPUDP_DIS_GET(val) & (BIT(0) << l))
54+
out->prf(out->dst, "mac_etype");
55+
else
56+
out->prf(out->dst, "ipv4_tcp_udp");
57+
58+
out->prf(out->dst, "\n ipv6: ");
59+
switch (ANA_VCAP_S2_CFG_IP6_CFG_GET(val) & (0x3 << l)) {
60+
case VCAP_IS2_PS_IPV6_TCPUDP_OTHER:
61+
out->prf(out->dst, "ipv6_tcp_udp ipv6_tcp_udp");
62+
break;
63+
case VCAP_IS2_PS_IPV6_STD:
64+
out->prf(out->dst, "ipv6_std");
65+
break;
66+
case VCAP_IS2_PS_IPV6_IP4_TCPUDP_IP4_OTHER:
67+
out->prf(out->dst, "ipv4_tcp_udp ipv4_tcp_udp");
68+
break;
69+
case VCAP_IS2_PS_IPV6_MAC_ETYPE:
70+
out->prf(out->dst, "mac_etype");
71+
break;
72+
}
73+
}
74+
75+
out->prf(out->dst, "\n");
76+
}
77+
78+
int lan966x_vcap_port_info(struct net_device *dev,
79+
struct vcap_admin *admin,
80+
struct vcap_output_print *out)
81+
{
82+
struct lan966x_port *port = netdev_priv(dev);
83+
struct lan966x *lan966x = port->lan966x;
84+
const struct vcap_info *vcap;
85+
struct vcap_control *vctrl;
86+
87+
vctrl = lan966x->vcap_ctrl;
88+
vcap = &vctrl->vcaps[admin->vtype];
89+
90+
out->prf(out->dst, "%s:\n", vcap->name);
91+
lan966x_vcap_port_keys(port, admin, out);
92+
93+
return 0;
94+
}

drivers/net/ethernet/microchip/lan966x/lan966x_vcap_impl.c

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,12 @@
44
#include "lan966x_vcap_ag_api.h"
55
#include "vcap_api.h"
66
#include "vcap_api_client.h"
7+
#include "vcap_api_debugfs.h"
78

89
#define STREAMSIZE (64 * 4)
910

1011
#define LAN966X_IS2_LOOKUPS 2
1112

12-
enum vcap_is2_port_sel_ipv6 {
13-
VCAP_IS2_PS_IPV6_TCPUDP_OTHER,
14-
VCAP_IS2_PS_IPV6_STD,
15-
VCAP_IS2_PS_IPV6_IP4_TCPUDP_IP4_OTHER,
16-
VCAP_IS2_PS_IPV6_MAC_ETYPE,
17-
};
18-
1913
static struct lan966x_vcap_inst {
2014
enum vcap_type vtype; /* type of vcap */
2115
int tgt_inst; /* hardware instance number */
@@ -385,13 +379,6 @@ static void lan966x_vcap_move(struct net_device *dev,
385379
lan966x_vcap_wait_update(lan966x, admin->tgt_inst);
386380
}
387381

388-
static int lan966x_vcap_port_info(struct net_device *dev,
389-
struct vcap_admin *admin,
390-
struct vcap_output_print *out)
391-
{
392-
return 0;
393-
}
394-
395382
static struct vcap_operations lan966x_vcap_ops = {
396383
.validate_keyset = lan966x_vcap_validate_keyset,
397384
.add_default_fields = lan966x_vcap_add_default_fields,
@@ -486,6 +473,7 @@ int lan966x_vcap_init(struct lan966x *lan966x)
486473
struct lan966x_vcap_inst *cfg;
487474
struct vcap_control *ctrl;
488475
struct vcap_admin *admin;
476+
struct dentry *dir;
489477

490478
ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL);
491479
if (!ctrl)
@@ -509,11 +497,17 @@ int lan966x_vcap_init(struct lan966x *lan966x)
509497
list_add_tail(&admin->list, &ctrl->list);
510498
}
511499

512-
for (int p = 0; p < lan966x->num_phys_ports; ++p)
513-
if (lan966x->ports[p])
500+
dir = vcap_debugfs(lan966x->dev, lan966x->debugfs_root, ctrl);
501+
for (int p = 0; p < lan966x->num_phys_ports; ++p) {
502+
if (lan966x->ports[p]) {
503+
vcap_port_debugfs(lan966x->dev, dir, ctrl,
504+
lan966x->ports[p]->dev);
505+
514506
lan_rmw(ANA_VCAP_S2_CFG_ENA_SET(true),
515507
ANA_VCAP_S2_CFG_ENA, lan966x,
516508
ANA_VCAP_S2_CFG(lan966x->ports[p]->chip_port));
509+
}
510+
}
517511

518512
lan966x->vcap_ctrl = ctrl;
519513

0 commit comments

Comments
 (0)