Skip to content

Commit 0c2a01d

Browse files
committed
Merge branch 'Offload-tc-flower-to-mscc_ocelot-switch-using-VCAP-chains'
Vladimir Oltean says: ==================== Offload tc-flower to mscc_ocelot switch using VCAP chains The purpose of this patch is to add more comprehensive support for flow offloading in the mscc_ocelot library and switch drivers. The design (with chains) is the result of this discussion: https://lkml.org/lkml/2020/6/2/203 I have tested it on Seville VSC9953 and Felix VSC9959, but it should also work on Ocelot-1 VSC7514. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 26d0a8e + 8cd6b02 commit 0c2a01d

File tree

15 files changed

+1261
-106
lines changed

15 files changed

+1261
-106
lines changed

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12542,6 +12542,7 @@ F: drivers/net/dsa/ocelot/*
1254212542
F: drivers/net/ethernet/mscc/
1254312543
F: include/soc/mscc/ocelot*
1254412544
F: net/dsa/tag_ocelot.c
12545+
F: tools/testing/selftests/drivers/net/ocelot/*
1254512546

1254612547
OCXL (Open Coherent Accelerator Processor Interface OpenCAPI) DRIVER
1254712548
M: Frederic Barrat <[email protected]>

drivers/net/dsa/ocelot/felix.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -810,3 +810,25 @@ const struct dsa_switch_ops felix_switch_ops = {
810810
.cls_flower_stats = felix_cls_flower_stats,
811811
.port_setup_tc = felix_port_setup_tc,
812812
};
813+
814+
struct net_device *felix_port_to_netdev(struct ocelot *ocelot, int port)
815+
{
816+
struct felix *felix = ocelot_to_felix(ocelot);
817+
struct dsa_switch *ds = felix->ds;
818+
819+
if (!dsa_is_user_port(ds, port))
820+
return NULL;
821+
822+
return dsa_to_port(ds, port)->slave;
823+
}
824+
825+
int felix_netdev_to_port(struct net_device *dev)
826+
{
827+
struct dsa_port *dp;
828+
829+
dp = dsa_port_from_netdev(dev);
830+
if (IS_ERR(dp))
831+
return -EINVAL;
832+
833+
return dp->index;
834+
}

drivers/net/dsa/ocelot/felix.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,7 @@ struct felix {
5252
resource_size_t imdio_base;
5353
};
5454

55+
struct net_device *felix_port_to_netdev(struct ocelot *ocelot, int port);
56+
int felix_netdev_to_port(struct net_device *dev);
57+
5558
#endif

drivers/net/dsa/ocelot/felix_vsc9959.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,7 @@ static const struct vcap_field vsc9959_vcap_is1_actions[] = {
711711
[VCAP_IS1_ACT_PAG_OVERRIDE_MASK] = { 13, 8},
712712
[VCAP_IS1_ACT_PAG_VAL] = { 21, 8},
713713
[VCAP_IS1_ACT_RSV] = { 29, 9},
714+
/* The fields below are incorrectly shifted by 2 in the manual */
714715
[VCAP_IS1_ACT_VID_REPLACE_ENA] = { 38, 1},
715716
[VCAP_IS1_ACT_VID_ADD_VAL] = { 39, 12},
716717
[VCAP_IS1_ACT_FID_SEL] = { 51, 2},
@@ -1006,6 +1007,8 @@ static u16 vsc9959_wm_enc(u16 value)
10061007
static const struct ocelot_ops vsc9959_ops = {
10071008
.reset = vsc9959_reset,
10081009
.wm_enc = vsc9959_wm_enc,
1010+
.port_to_netdev = felix_port_to_netdev,
1011+
.netdev_to_port = felix_netdev_to_port,
10091012
};
10101013

10111014
static int vsc9959_mdio_bus_alloc(struct ocelot *ocelot)

drivers/net/dsa/ocelot/seville_vsc9953.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,6 +1058,8 @@ static u16 vsc9953_wm_enc(u16 value)
10581058
static const struct ocelot_ops vsc9953_ops = {
10591059
.reset = vsc9953_reset,
10601060
.wm_enc = vsc9953_wm_enc,
1061+
.port_to_netdev = felix_port_to_netdev,
1062+
.netdev_to_port = felix_netdev_to_port,
10611063
};
10621064

10631065
static int vsc9953_mdio_bus_alloc(struct ocelot *ocelot)

drivers/net/ethernet/mscc/ocelot.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,13 @@ static void ocelot_vcap_enable(struct ocelot *ocelot, int port)
108108
ocelot_write_gix(ocelot, ANA_PORT_VCAP_S2_CFG_S2_ENA |
109109
ANA_PORT_VCAP_S2_CFG_S2_IP6_CFG(0xa),
110110
ANA_PORT_VCAP_S2_CFG, port);
111+
112+
ocelot_write_gix(ocelot, ANA_PORT_VCAP_CFG_S1_ENA,
113+
ANA_PORT_VCAP_CFG, port);
114+
115+
ocelot_rmw_gix(ocelot, REW_PORT_CFG_ES0_EN,
116+
REW_PORT_CFG_ES0_EN,
117+
REW_PORT_CFG, port);
111118
}
112119

113120
static inline u32 ocelot_vlant_read_vlanaccess(struct ocelot *ocelot)

drivers/net/ethernet/mscc/ocelot.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ int ocelot_port_lag_join(struct ocelot *ocelot, int port,
9898
struct net_device *bond);
9999
void ocelot_port_lag_leave(struct ocelot *ocelot, int port,
100100
struct net_device *bond);
101+
struct net_device *ocelot_port_to_netdev(struct ocelot *ocelot, int port);
102+
int ocelot_netdev_to_port(struct net_device *dev);
101103

102104
u32 ocelot_port_readl(struct ocelot_port *port, u32 reg);
103105
void ocelot_port_writel(struct ocelot_port *port, u32 val, u32 reg);

0 commit comments

Comments
 (0)