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>
This commit is contained in:
parent
64e09d04b9
commit
9428148401
|
@ -15,5 +15,7 @@ lan966x-switch-objs := lan966x_main.o lan966x_phylink.o lan966x_port.o \
|
|||
lan966x_xdp.o lan966x_vcap_impl.o lan966x_vcap_ag_api.o \
|
||||
lan966x_tc_flower.o lan966x_goto.o
|
||||
|
||||
lan966x-switch-$(CONFIG_DEBUG_FS) += lan966x_vcap_debugfs.o
|
||||
|
||||
# Provide include files
|
||||
ccflags-y += -I$(srctree)/drivers/net/ethernet/microchip/vcap
|
||||
|
|
|
@ -1035,6 +1035,8 @@ static int lan966x_probe(struct platform_device *pdev)
|
|||
platform_set_drvdata(pdev, lan966x);
|
||||
lan966x->dev = &pdev->dev;
|
||||
|
||||
lan966x->debugfs_root = debugfs_create_dir("lan966x", NULL);
|
||||
|
||||
if (!device_get_mac_address(&pdev->dev, mac_addr)) {
|
||||
ether_addr_copy(lan966x->base_mac, mac_addr);
|
||||
} else {
|
||||
|
@ -1223,6 +1225,8 @@ static int lan966x_remove(struct platform_device *pdev)
|
|||
lan966x_fdb_deinit(lan966x);
|
||||
lan966x_ptp_deinit(lan966x);
|
||||
|
||||
debugfs_remove_recursive(lan966x->debugfs_root);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#ifndef __LAN966X_MAIN_H__
|
||||
#define __LAN966X_MAIN_H__
|
||||
|
||||
#include <linux/debugfs.h>
|
||||
#include <linux/etherdevice.h>
|
||||
#include <linux/if_vlan.h>
|
||||
#include <linux/jiffies.h>
|
||||
|
@ -14,6 +15,9 @@
|
|||
#include <net/pkt_sched.h>
|
||||
#include <net/switchdev.h>
|
||||
|
||||
#include <vcap_api.h>
|
||||
#include <vcap_api_client.h>
|
||||
|
||||
#include "lan966x_regs.h"
|
||||
#include "lan966x_ifh.h"
|
||||
|
||||
|
@ -128,6 +132,13 @@ enum LAN966X_PORT_MASK_MODE {
|
|||
LAN966X_PMM_REDIRECT,
|
||||
};
|
||||
|
||||
enum vcap_is2_port_sel_ipv6 {
|
||||
VCAP_IS2_PS_IPV6_TCPUDP_OTHER,
|
||||
VCAP_IS2_PS_IPV6_STD,
|
||||
VCAP_IS2_PS_IPV6_IP4_TCPUDP_IP4_OTHER,
|
||||
VCAP_IS2_PS_IPV6_MAC_ETYPE,
|
||||
};
|
||||
|
||||
struct lan966x_port;
|
||||
|
||||
struct lan966x_db {
|
||||
|
@ -315,6 +326,9 @@ struct lan966x {
|
|||
|
||||
/* vcap */
|
||||
struct vcap_control *vcap_ctrl;
|
||||
|
||||
/* debugfs */
|
||||
struct dentry *debugfs_root;
|
||||
};
|
||||
|
||||
struct lan966x_port_config {
|
||||
|
@ -601,6 +615,18 @@ static inline bool lan966x_xdp_port_present(struct lan966x_port *port)
|
|||
|
||||
int lan966x_vcap_init(struct lan966x *lan966x);
|
||||
void lan966x_vcap_deinit(struct lan966x *lan966x);
|
||||
#if defined(CONFIG_DEBUG_FS)
|
||||
int lan966x_vcap_port_info(struct net_device *dev,
|
||||
struct vcap_admin *admin,
|
||||
struct vcap_output_print *out);
|
||||
#else
|
||||
static inline int lan966x_vcap_port_info(struct net_device *dev,
|
||||
struct vcap_admin *admin,
|
||||
struct vcap_output_print *out)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
int lan966x_tc_flower(struct lan966x_port *port,
|
||||
struct flow_cls_offload *f,
|
||||
|
|
|
@ -0,0 +1,94 @@
|
|||
// SPDX-License-Identifier: GPL-2.0+
|
||||
|
||||
#include "lan966x_main.h"
|
||||
#include "lan966x_vcap_ag_api.h"
|
||||
#include "vcap_api.h"
|
||||
#include "vcap_api_client.h"
|
||||
|
||||
static void lan966x_vcap_port_keys(struct lan966x_port *port,
|
||||
struct vcap_admin *admin,
|
||||
struct vcap_output_print *out)
|
||||
{
|
||||
struct lan966x *lan966x = port->lan966x;
|
||||
u32 val;
|
||||
|
||||
out->prf(out->dst, " port[%d] (%s): ", port->chip_port,
|
||||
netdev_name(port->dev));
|
||||
|
||||
val = lan_rd(lan966x, ANA_VCAP_S2_CFG(port->chip_port));
|
||||
out->prf(out->dst, "\n state: ");
|
||||
if (ANA_VCAP_S2_CFG_ENA_GET(val))
|
||||
out->prf(out->dst, "on");
|
||||
else
|
||||
out->prf(out->dst, "off");
|
||||
|
||||
for (int l = 0; l < admin->lookups; ++l) {
|
||||
out->prf(out->dst, "\n Lookup %d: ", l);
|
||||
|
||||
out->prf(out->dst, "\n snap: ");
|
||||
if (ANA_VCAP_S2_CFG_SNAP_DIS_GET(val) & (BIT(0) << l))
|
||||
out->prf(out->dst, "mac_llc");
|
||||
else
|
||||
out->prf(out->dst, "mac_snap");
|
||||
|
||||
out->prf(out->dst, "\n oam: ");
|
||||
if (ANA_VCAP_S2_CFG_OAM_DIS_GET(val) & (BIT(0) << l))
|
||||
out->prf(out->dst, "mac_etype");
|
||||
else
|
||||
out->prf(out->dst, "mac_oam");
|
||||
|
||||
out->prf(out->dst, "\n arp: ");
|
||||
if (ANA_VCAP_S2_CFG_ARP_DIS_GET(val) & (BIT(0) << l))
|
||||
out->prf(out->dst, "mac_etype");
|
||||
else
|
||||
out->prf(out->dst, "mac_arp");
|
||||
|
||||
out->prf(out->dst, "\n ipv4_other: ");
|
||||
if (ANA_VCAP_S2_CFG_IP_OTHER_DIS_GET(val) & (BIT(0) << l))
|
||||
out->prf(out->dst, "mac_etype");
|
||||
else
|
||||
out->prf(out->dst, "ip4_other");
|
||||
|
||||
out->prf(out->dst, "\n ipv4_tcp_udp: ");
|
||||
if (ANA_VCAP_S2_CFG_IP_TCPUDP_DIS_GET(val) & (BIT(0) << l))
|
||||
out->prf(out->dst, "mac_etype");
|
||||
else
|
||||
out->prf(out->dst, "ipv4_tcp_udp");
|
||||
|
||||
out->prf(out->dst, "\n ipv6: ");
|
||||
switch (ANA_VCAP_S2_CFG_IP6_CFG_GET(val) & (0x3 << l)) {
|
||||
case VCAP_IS2_PS_IPV6_TCPUDP_OTHER:
|
||||
out->prf(out->dst, "ipv6_tcp_udp ipv6_tcp_udp");
|
||||
break;
|
||||
case VCAP_IS2_PS_IPV6_STD:
|
||||
out->prf(out->dst, "ipv6_std");
|
||||
break;
|
||||
case VCAP_IS2_PS_IPV6_IP4_TCPUDP_IP4_OTHER:
|
||||
out->prf(out->dst, "ipv4_tcp_udp ipv4_tcp_udp");
|
||||
break;
|
||||
case VCAP_IS2_PS_IPV6_MAC_ETYPE:
|
||||
out->prf(out->dst, "mac_etype");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
out->prf(out->dst, "\n");
|
||||
}
|
||||
|
||||
int lan966x_vcap_port_info(struct net_device *dev,
|
||||
struct vcap_admin *admin,
|
||||
struct vcap_output_print *out)
|
||||
{
|
||||
struct lan966x_port *port = netdev_priv(dev);
|
||||
struct lan966x *lan966x = port->lan966x;
|
||||
const struct vcap_info *vcap;
|
||||
struct vcap_control *vctrl;
|
||||
|
||||
vctrl = lan966x->vcap_ctrl;
|
||||
vcap = &vctrl->vcaps[admin->vtype];
|
||||
|
||||
out->prf(out->dst, "%s:\n", vcap->name);
|
||||
lan966x_vcap_port_keys(port, admin, out);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -4,18 +4,12 @@
|
|||
#include "lan966x_vcap_ag_api.h"
|
||||
#include "vcap_api.h"
|
||||
#include "vcap_api_client.h"
|
||||
#include "vcap_api_debugfs.h"
|
||||
|
||||
#define STREAMSIZE (64 * 4)
|
||||
|
||||
#define LAN966X_IS2_LOOKUPS 2
|
||||
|
||||
enum vcap_is2_port_sel_ipv6 {
|
||||
VCAP_IS2_PS_IPV6_TCPUDP_OTHER,
|
||||
VCAP_IS2_PS_IPV6_STD,
|
||||
VCAP_IS2_PS_IPV6_IP4_TCPUDP_IP4_OTHER,
|
||||
VCAP_IS2_PS_IPV6_MAC_ETYPE,
|
||||
};
|
||||
|
||||
static struct lan966x_vcap_inst {
|
||||
enum vcap_type vtype; /* type of vcap */
|
||||
int tgt_inst; /* hardware instance number */
|
||||
|
@ -385,13 +379,6 @@ static void lan966x_vcap_move(struct net_device *dev,
|
|||
lan966x_vcap_wait_update(lan966x, admin->tgt_inst);
|
||||
}
|
||||
|
||||
static int lan966x_vcap_port_info(struct net_device *dev,
|
||||
struct vcap_admin *admin,
|
||||
struct vcap_output_print *out)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct vcap_operations lan966x_vcap_ops = {
|
||||
.validate_keyset = lan966x_vcap_validate_keyset,
|
||||
.add_default_fields = lan966x_vcap_add_default_fields,
|
||||
|
@ -486,6 +473,7 @@ int lan966x_vcap_init(struct lan966x *lan966x)
|
|||
struct lan966x_vcap_inst *cfg;
|
||||
struct vcap_control *ctrl;
|
||||
struct vcap_admin *admin;
|
||||
struct dentry *dir;
|
||||
|
||||
ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL);
|
||||
if (!ctrl)
|
||||
|
@ -509,11 +497,17 @@ int lan966x_vcap_init(struct lan966x *lan966x)
|
|||
list_add_tail(&admin->list, &ctrl->list);
|
||||
}
|
||||
|
||||
for (int p = 0; p < lan966x->num_phys_ports; ++p)
|
||||
if (lan966x->ports[p])
|
||||
dir = vcap_debugfs(lan966x->dev, lan966x->debugfs_root, ctrl);
|
||||
for (int p = 0; p < lan966x->num_phys_ports; ++p) {
|
||||
if (lan966x->ports[p]) {
|
||||
vcap_port_debugfs(lan966x->dev, dir, ctrl,
|
||||
lan966x->ports[p]->dev);
|
||||
|
||||
lan_rmw(ANA_VCAP_S2_CFG_ENA_SET(true),
|
||||
ANA_VCAP_S2_CFG_ENA, lan966x,
|
||||
ANA_VCAP_S2_CFG(lan966x->ports[p]->chip_port));
|
||||
}
|
||||
}
|
||||
|
||||
lan966x->vcap_ctrl = ctrl;
|
||||
|
||||
|
|
Loading…
Reference in New Issue