Ocelot/Felix driver cleanup
Subsystems (4)
Vladimir Oltean
maintainercover Ocelot/Felix driver cleanup
From: Vladimir Oltean <[email protected]>
Some of the code in the mscc felix and ocelot drivers was added while in a bit of a hurry. Let's take a moment and put things in relative order.
First 3 patches are sparse warning fixes.
Patches 4-9 perform some further splitting between mscc_felix, mscc_ocelot, and the common hardware library they share. Meaning that some code is being moved from the library into just the mscc_ocelot module.
Patches 10-12 refactor the naming conventions in the existing VCAP code (for tc-flower offload), since we're going to be adding some more code for VCAP IS1 (previous tentatives already submitted here:
https://patchwork.ozlabs.org/project/netdev/cover/[email protected]/),
and that code would be confusing to read and maintain using current naming conventions.
No functional modification is intended. I checked that the VCAP IS2 code still works by applying a tc ingress filter with an EtherType key and 'drop' action.
Vladimir Oltean (12):
net: dsa: felix: make vcap is2 keys and actions static
net: mscc: ocelot: use plain int when interacting with TCAM tables
net: mscc: ocelot: access EtherType using __be16
net: mscc: ocelot: rename ocelot_board.c to ocelot_vsc7514.c
net: mscc: ocelot: rename module to mscc_ocelot
net: mscc: ocelot: convert MSCC_OCELOT_SWITCH into a library
net: mscc: ocelot: rename MSCC_OCELOT_SWITCH_OCELOT to
MSCC_OCELOT_SWITCH
net: mscc: ocelot: move ocelot_regs.c into ocelot_vsc7514.c
net: mscc: ocelot: move net_device related functions to ocelot_net.c
net: mscc: ocelot: rename ocelot_ace.{c,h} to ocelot_vcap.{c,h}
net: mscc: ocelot: generalize the "ACE/ACL" names
net: mscc: ocelot: unexpose ocelot_vcap_policer_{add,del}
drivers/net/dsa/ocelot/Kconfig | 4 +-
drivers/net/dsa/ocelot/felix_vsc9959.c | 4 +-
drivers/net/ethernet/mscc/Kconfig | 22 +-
drivers/net/ethernet/mscc/Makefile | 16 +-
drivers/net/ethernet/mscc/ocelot.c | 913 +-------------
drivers/net/ethernet/mscc/ocelot.h | 46 +-
drivers/net/ethernet/mscc/ocelot_board.c | 626 ----------
drivers/net/ethernet/mscc/ocelot_flower.c | 146 +--
drivers/net/ethernet/mscc/ocelot_net.c | 1031 ++++++++++++++++
drivers/net/ethernet/mscc/ocelot_police.c | 49 +-
drivers/net/ethernet/mscc/ocelot_police.h | 25 +-
drivers/net/ethernet/mscc/ocelot_regs.c | 450 -------
drivers/net/ethernet/mscc/ocelot_tc.c | 179 ---
drivers/net/ethernet/mscc/ocelot_tc.h | 22 -
.../mscc/{ocelot_ace.c => ocelot_vcap.c} | 336 +++---
.../mscc/{ocelot_ace.h => ocelot_vcap.h} | 88 +-
drivers/net/ethernet/mscc/ocelot_vsc7514.c | 1068 +++++++++++++++++
include/soc/mscc/ocelot.h | 4 +-
18 files changed, 2510 insertions(+), 2519 deletions(-)
delete mode 100644 drivers/net/ethernet/mscc/ocelot_board.c
create mode 100644 drivers/net/ethernet/mscc/ocelot_net.c
delete mode 100644 drivers/net/ethernet/mscc/ocelot_regs.c
delete mode 100644 drivers/net/ethernet/mscc/ocelot_tc.c
delete mode 100644 drivers/net/ethernet/mscc/ocelot_tc.h
rename drivers/net/ethernet/mscc/{ocelot_ace.c => ocelot_vcap.c} (77%)
rename drivers/net/ethernet/mscc/{ocelot_ace.h => ocelot_vcap.h} (75%)
create mode 100644 drivers/net/ethernet/mscc/ocelot_vsc7514.cSignature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH 1/12 net: dsa: felix: make vcap is2 keys and actions static
From: Vladimir Oltean <[email protected]>
Get rid of some sparse warnings.
--- drivers/net/dsa/ocelot/felix_vsc9959.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/dsa/ocelot/felix_vsc9959.c +2 -2
@@ -557,7 +557,7 @@ static const struct ocelot_stat_layout vsc9959_stats_layout[] = { { .offset = 0x111, .name = "drop_green_prio_7", }, }; -struct vcap_field vsc9959_vcap_is2_keys[] = { +static struct vcap_field vsc9959_vcap_is2_keys[] = {/* Common: 41 bits */ [VCAP_IS2_TYPE ] = {0 ,4 }, [VCAP_IS2_HK_FIRST ] = {4 ,1 },
@@ -637,7 +637,7 @@ struct vcap_field vsc9959_vcap_is2_keys[] = { [VCAP_IS2_HK_OAM_IS_Y1731] = {182, 1}, }; -struct vcap_field vsc9959_vcap_is2_actions[] = { +static struct vcap_field vsc9959_vcap_is2_actions[] = { [VCAP_IS2_ACT_HIT_ME_ONCE ] = {0 ,1 }, [VCAP_IS2_ACT_CPU_COPY_ENA ] = {1 ,1 }, [VCAP_IS2_ACT_CPU_QU_NUM ] = {2 ,3 },
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH 2/12 net: mscc: ocelot: use plain int when interacting with TCAM tables
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
sparse is rightfully complaining about the fact that:
warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
26 | __builtin_constant_p((l) > (h)), (l) > (h), 0)))
| ^
note: in expansion of macro ‘GENMASK_INPUT_CHECK’
39 | (GENMASK_INPUT_CHECK(h, l) + __GENMASK(h, l))
| ^~~~~~~~~~~~~~~~~~~
note: in expansion of macro ‘GENMASK’
127 | mask = GENMASK(width, 0);
| ^~~~~~~So replace the variables that go into GENMASK with plain, signed integer types.
--- drivers/net/ethernet/mscc/ocelot_ace.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/net/ethernet/mscc/ocelot_ace.c +6 -4
@@ -119,7 +119,8 @@ static void vcap_cache2entry(struct ocelot *ocelot, struct vcap_data *data)static void vcap_action2cache (struct ocelot *ocelot,struct vcap_data *data) {const struct vcap_props *vcap_is2 = &ocelot->vcap[VCAP_IS2 ]; -u32 action_words, i, width, mask; +u32 action_words, mask; +int i, width;/* Encode action type */ width = vcap_is2->action_type_width;
@@ -141,7 +142,8 @@ static void vcap_action2cache(struct ocelot *ocelot, struct vcap_data *data)static void vcap_cache2action (struct ocelot *ocelot,struct vcap_data *data) {const struct vcap_props *vcap_is2 = &ocelot->vcap[VCAP_IS2 ]; -u32 action_words, i, width; +u32 action_words; +int i, width; action_words =DIV_ROUND_UP (vcap_is2->action_width,ENTRY_WIDTH );
@@ -161,8 +163,8 @@ static void vcap_cache2action(struct ocelot *ocelot, struct vcap_data *data)static void is2_data_get (struct ocelot *ocelot,struct vcap_data *data,int ix) {const struct vcap_props *vcap_is2 = &ocelot->vcap[VCAP_IS2 ]; -u32 i, col, offset, count, cnt, base; -u32 width = vcap_is2->tg_width; +int i, col, offset, count, cnt, base; +int width = vcap_is2->tg_width; count = (data->tg_sw ==VCAP_TG_HALF ?2 :4 ); col = (ix %2 );
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH 3/12 net: mscc: ocelot: access EtherType using __be16
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
Get rid of sparse "cast to restricted __be16" warnings.
--- drivers/net/ethernet/mscc/ocelot_ace.c | 4 ++-- drivers/net/ethernet/mscc/ocelot_flower.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/mscc/ocelot_ace.c +2 -2
@@ -746,8 +746,8 @@ static bool ocelot_ace_is_problematic_mac_etype(struct ocelot_ace_rule *ace)if (ace->type !=OCELOT_ACE_TYPE_ETYPE )return false; - proto =ntohs (*(u16 *)ace->frame.etype.etype.value); - mask =ntohs (*(u16 *)ace->frame.etype.etype.mask); + proto =ntohs (*(__be16 *)ace->frame.etype.etype.value); + mask =ntohs (*(__be16 *)ace->frame.etype.etype.mask);/* ETH_P_ALL match, so all protocols below are included */ if (mask ==0 )
drivers/net/ethernet/mscc/ocelot_flower.c +2 -2
@@ -176,8 +176,8 @@ static int ocelot_flower_parse(struct flow_cls_offload *f,if (proto <ETH_P_802_3_MIN )return -EOPNOTSUPP ; ace->type =OCELOT_ACE_TYPE_ETYPE ; - *(u16 *)ace->frame.etype.etype.value =htons (proto); - *(u16 *)ace->frame.etype.etype.mask =0xffff ; + *(__be16 *)ace->frame.etype.etype.value =htons (proto); + *(__be16 *)ace->frame.etype.etype.mask =htons (0xffff ); }/* else, a rule of type OCELOT_ACE_TYPE_ANY is implicitly added */
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH 4/12 net: mscc: ocelot: rename ocelot_board.c to ocelot_vsc7514.c
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
To follow the model of felix and seville where we have one platform-specific file, rename this file to the actual SoC it serves.
---
drivers/net/ethernet/mscc/Makefile | 2 +-
drivers/net/ethernet/mscc/{ocelot_board.c => ocelot_vsc7514.c} | 0
2 files changed, 1 insertion(+), 1 deletion(-)
rename drivers/net/ethernet/mscc/{ocelot_board.c => ocelot_vsc7514.c} (100%)drivers/net/ethernet/mscc/Makefile +1 -1
@@ -2,4 +2,4 @@ obj-$(CONFIG_MSCC_OCELOT_SWITCH) += mscc_ocelot_common.o mscc_ocelot_common-y := ocelot.o ocelot_io.o mscc_ocelot_common-y += ocelot_regs.o ocelot_tc.o ocelot_police.o ocelot_ace.o ocelot_flower.o ocelot_ptp.o -obj-$(CONFIG_MSCC_OCELOT_SWITCH_OCELOT) += ocelot_board.o +obj-$(CONFIG_MSCC_OCELOT_SWITCH_OCELOT) += ocelot_vsc7514.o
drivers/net/ethernet/mscc/ocelot_vsc7514.c renamed from drivers/net/ethernet/mscc/ocelot_board.c +0 -0
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH 5/12 net: mscc: ocelot: rename module to mscc_ocelot
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
mscc_ocelot is a slightly better name for a module than ocelot_board or ocelot_vsc7514 is, so let's use that.
--- drivers/net/ethernet/mscc/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/mscc/Makefile +2 -1
@@ -2,4 +2,5 @@ obj-$(CONFIG_MSCC_OCELOT_SWITCH) += mscc_ocelot_common.o mscc_ocelot_common-y := ocelot.o ocelot_io.o mscc_ocelot_common-y += ocelot_regs.o ocelot_tc.o ocelot_police.o ocelot_ace.o ocelot_flower.o ocelot_ptp.o -obj-$(CONFIG_MSCC_OCELOT_SWITCH_OCELOT) += ocelot_vsc7514.o +obj-$(CONFIG_MSCC_OCELOT_SWITCH_OCELOT) += mscc_ocelot.o +mscc_ocelot-y := ocelot_vsc7514.o
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH 6/12 net: mscc: ocelot: convert MSCC_OCELOT_SWITCH into a library
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
Hide the CONFIG_MSCC_OCELOT_SWITCH option from users. It is meant to be only a hardware library which is selected by the drivers that use it (ocelot, felix).
Since it is "selected" from Kconfig, all its dependencies are manually transferred to the driver that selects it. This is because "select" in Kconfig language is a bit of a mess, and doesn't handle dependencies of selected options quite right.
--- drivers/net/dsa/ocelot/Kconfig | 4 +++- drivers/net/ethernet/mscc/Kconfig | 18 ++++++++++-------- drivers/net/ethernet/mscc/Makefile | 13 ++++++++++--- 3 files changed, 23 insertions(+), 12 deletions(-)
drivers/net/dsa/ocelot/Kconfig +3 -1
@@ -4,7 +4,9 @@ config NET_DSA_MSCC_FELIX depends on NET_DSA && PCI depends on NET_VENDOR_MICROSEMI depends on NET_VENDOR_FREESCALE - select MSCC_OCELOT_SWITCH + depends on HAS_IOMEM + depends on REGMAP_MMIO + select MSCC_OCELOT_SWITCH_LIB select NET_DSA_TAG_OCELOT select FSL_ENETC_MDIO help
drivers/net/ethernet/mscc/Kconfig +10 -8
@@ -11,20 +11,22 @@ config NET_VENDOR_MICROSEMI if NET_VENDOR_MICROSEMI -config MSCC_OCELOT_SWITCH - tristate "Ocelot switch driver" - depends on NET_SWITCHDEV - depends on HAS_IOMEM - select PHYLIB - select REGMAP_MMIO +# Users should depend on NET_SWITCHDEV, HAS_IOMEM, PHYLIB and REGMAP_MMIO +config MSCC_OCELOT_SWITCH_LIB + tristate help - This driver supports the Ocelot network switch device. + This is a hardware support library for Ocelot network switches. It is + used by switchdev as well as by DSA drivers. config MSCC_OCELOT_SWITCH_OCELOT tristate "Ocelot switch driver on Ocelot" - depends on MSCC_OCELOT_SWITCH + depends on NET_SWITCHDEV depends on GENERIC_PHY + depends on REGMAP_MMIO + depends on HAS_IOMEM + depends on PHYLIB depends on OF_NET + select MSCC_OCELOT_SWITCH_LIB help This driver supports the Ocelot network switch device as present on the Ocelot SoCs.
drivers/net/ethernet/mscc/Makefile +10 -3
@@ -1,6 +1,13 @@ # SPDX-License-Identifier: (GPL-2.0 OR MIT) -obj-$(CONFIG_MSCC_OCELOT_SWITCH) += mscc_ocelot_common.o -mscc_ocelot_common-y := ocelot.o ocelot_io.o -mscc_ocelot_common-y += ocelot_regs.o ocelot_tc.o ocelot_police.o ocelot_ace.o ocelot_flower.o ocelot_ptp.o +obj-$(CONFIG_MSCC_OCELOT_SWITCH_LIB) += mscc_ocelot_switch_lib.o +mscc_ocelot_switch_lib-y := \ + ocelot.o \ + ocelot_io.o \ + ocelot_regs.o \ + ocelot_tc.o \ + ocelot_police.o \ + ocelot_ace.o \ + ocelot_flower.o \ + ocelot_ptp.o obj-$(CONFIG_MSCC_OCELOT_SWITCH_OCELOT) += mscc_ocelot.o mscc_ocelot-y := ocelot_vsc7514.o
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH 7/12 net: mscc: ocelot: rename MSCC_OCELOT_SWITCH_OCELOT to MSCC_OCELOT_SWITCH
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
Putting 'ocelot' in the config's name twice just to say that 'it's the ocelot driver running on the ocelot SoC' is a bit confusing. Instead, it's just the ocelot driver. Now that we've renamed the previous symbol that was holding the MSCC_OCELOT_SWITCH_OCELOT into *_LIB (because that's what it is), we're free to use this name for the driver.
--- drivers/net/ethernet/mscc/Kconfig | 6 +++--- drivers/net/ethernet/mscc/Makefile | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/mscc/Kconfig +3 -3
@@ -18,8 +18,8 @@ config MSCC_OCELOT_SWITCH_LIB This is a hardware support library for Ocelot network switches. It is used by switchdev as well as by DSA drivers. -config MSCC_OCELOT_SWITCH_OCELOT - tristate "Ocelot switch driver on Ocelot" +config MSCC_OCELOT_SWITCH + tristate "Ocelot switch driver" depends on NET_SWITCHDEV depends on GENERIC_PHY depends on REGMAP_MMIO
@@ -29,6 +29,6 @@ config MSCC_OCELOT_SWITCH_OCELOT select MSCC_OCELOT_SWITCH_LIB help This driver supports the Ocelot network switch device as present on - the Ocelot SoCs. + the Ocelot SoCs (VSC7514). endif # NET_VENDOR_MICROSEMI
drivers/net/ethernet/mscc/Makefile +1 -1
@@ -9,5 +9,5 @@ mscc_ocelot_switch_lib-y := \ ocelot_ace.o \ ocelot_flower.o \ ocelot_ptp.o -obj-$(CONFIG_MSCC_OCELOT_SWITCH_OCELOT) += mscc_ocelot.o +obj-$(CONFIG_MSCC_OCELOT_SWITCH) += mscc_ocelot.o mscc_ocelot-y := ocelot_vsc7514.o
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH 8/12 net: mscc: ocelot: move ocelot_regs.c into ocelot_vsc7514.c
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
ocelot_regs.c actually shouldn't be part of the common library. It describes the register map of the VSC7514 switch. The way ocelot switches work, they'll have highly optimized register maps, so another SoC will likely have the same registers but laid out completely different in memory (so there's little room for reusing this structure). So move it to ocelot_vsc7514.c instead.
--- drivers/net/ethernet/mscc/Makefile | 1 - drivers/net/ethernet/mscc/ocelot.h | 1 - drivers/net/ethernet/mscc/ocelot_regs.c | 450 --------------------- drivers/net/ethernet/mscc/ocelot_vsc7514.c | 442 ++++++++++++++++++++ 4 files changed, 442 insertions(+), 452 deletions(-) delete mode 100644 drivers/net/ethernet/mscc/ocelot_regs.c
drivers/net/ethernet/mscc/Makefile +0 -1
@@ -3,7 +3,6 @@ obj-$(CONFIG_MSCC_OCELOT_SWITCH_LIB) += mscc_ocelot_switch_lib.o mscc_ocelot_switch_lib-y := \ ocelot.o \ ocelot_io.o \ - ocelot_regs.o \ ocelot_tc.o \ ocelot_police.o \ ocelot_ace.o \
drivers/net/ethernet/mscc/ocelot.h +0 -1
@@ -66,7 +66,6 @@ void ocelot_port_writel(struct ocelot_port *port, u32 val, u32 reg);#define ocelot_field_write (ocelot, reg, val) regmap_field_write((ocelot)->regfields[(reg)], (val))#define ocelot_field_read (ocelot, reg, val) regmap_field_read((ocelot)->regfields[(reg)], (val)) -int ocelot_chip_init (struct ocelot *ocelot,const struct ocelot_ops *ops);int ocelot_probe_port (struct ocelot *ocelot,u8 port,void __iomem *regs,struct phy_device *phy);
drivers/net/ethernet/mscc/ocelot_regs.c deleted +0 -450
450 lines not on this page · raw message
drivers/net/ethernet/mscc/ocelot_vsc7514.c +442 -0
454 lines not on this page · raw message
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH 9/12 net: mscc: ocelot: move net_device related functions to ocelot_net.c
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
The ocelot hardware library shouldn't contain too much net_device specific code, since it is shared with DSA which abstracts that structure away. So much as much of this code as possible into the mscc_ocelot driver and outside of the common library.
We're making an exception for MDB and LAG code. That is not yet exported to DSA, but when it will, most of the code that's already in ocelot.c will remain there. So, there's no point in moving code to ocelot_net.c just to move it back later.
We could have moved all net_device code to ocelot_vsc7514.c directly, but let's operate under the assumption that if a new switchdev ocelot driver gets added, it'll define its SoC-specific stuff in a new ocelot_vsc*.c file and it'll reuse the rest of the code.
--- drivers/net/ethernet/mscc/Makefile | 5 +- drivers/net/ethernet/mscc/ocelot.c | 909 +----------------- drivers/net/ethernet/mscc/ocelot.h | 45 +- drivers/net/ethernet/mscc/ocelot_ace.c | 24 + drivers/net/ethernet/mscc/ocelot_flower.c | 22 - drivers/net/ethernet/mscc/ocelot_net.c | 1031 +++++++++++++++++++++ drivers/net/ethernet/mscc/ocelot_police.c | 49 +- drivers/net/ethernet/mscc/ocelot_police.h | 24 + drivers/net/ethernet/mscc/ocelot_tc.c | 179 ---- drivers/net/ethernet/mscc/ocelot_tc.h | 22 - 10 files changed, 1151 insertions(+), 1159 deletions(-) create mode 100644 drivers/net/ethernet/mscc/ocelot_net.c delete mode 100644 drivers/net/ethernet/mscc/ocelot_tc.c delete mode 100644 drivers/net/ethernet/mscc/ocelot_tc.h
drivers/net/ethernet/mscc/Makefile +3 -2
@@ -3,10 +3,11 @@ obj-$(CONFIG_MSCC_OCELOT_SWITCH_LIB) += mscc_ocelot_switch_lib.o mscc_ocelot_switch_lib-y := \ ocelot.o \ ocelot_io.o \ - ocelot_tc.o \ ocelot_police.o \ ocelot_ace.o \ ocelot_flower.o \ ocelot_ptp.o obj-$(CONFIG_MSCC_OCELOT_SWITCH) += mscc_ocelot.o -mscc_ocelot-y := ocelot_vsc7514.o +mscc_ocelot-y := \ + ocelot_vsc7514.o \ + ocelot_net.o
drivers/net/ethernet/mscc/ocelot.c +23 -886
1,099 lines not on this page · raw message
drivers/net/ethernet/mscc/ocelot.h +44 -1
63 lines not on this page · raw message
drivers/net/ethernet/mscc/ocelot_ace.c +24 -0
@@ -843,6 +843,30 @@ int ocelot_ace_rule_offload_add(struct ocelot *ocelot,return 0 ; } +int ocelot_ace_policer_add (struct ocelot *ocelot,u32 pol_ix, +struct ocelot_policer *pol) +{ +struct qos_policer_conf pp = {0 }; + +if (!pol) +return -EINVAL ; + + pp.mode =MSCC_QOS_RATE_MODE_DATA ; + pp.pir = pol->rate; + pp.pbs = pol->burst; + +return qos_policer_conf_set (ocelot,0 , pol_ix, &pp); +} + +int ocelot_ace_policer_del (struct ocelot *ocelot,u32 pol_ix) +{ +struct qos_policer_conf pp = {0 }; + + pp.mode =MSCC_QOS_RATE_MODE_DISABLED ; + +return qos_policer_conf_set (ocelot,0 , pol_ix, &pp); +} +static void ocelot_ace_police_del (struct ocelot *ocelot,struct ocelot_acl_block *block,u32 ix)
drivers/net/ethernet/mscc/ocelot_flower.c +0 -22
@@ -249,25 +249,3 @@ int ocelot_cls_flower_stats(struct ocelot *ocelot, int port,return 0 ; }EXPORT_SYMBOL_GPL (ocelot_cls_flower_stats); - -int ocelot_setup_tc_cls_flower (struct ocelot_port_private *priv, -struct flow_cls_offload *f, -bool ingress) -{ -struct ocelot *ocelot = priv->port.ocelot; -int port = priv->chip_port; - -if (!ingress) -return -EOPNOTSUPP ; - -switch (f->command) { -case FLOW_CLS_REPLACE : -return ocelot_cls_flower_replace (ocelot, port, f, ingress); -case FLOW_CLS_DESTROY : -return ocelot_cls_flower_destroy (ocelot, port, f, ingress); -case FLOW_CLS_STATS : -return ocelot_cls_flower_stats (ocelot, port, f, ingress); -default : -return -EOPNOTSUPP ; - } -}
drivers/net/ethernet/mscc/ocelot_net.c new file +1031 -0
1,031 lines not on this page · raw message
drivers/net/ethernet/mscc/ocelot_police.c +2 -47
64 lines not on this page · raw message
drivers/net/ethernet/mscc/ocelot_police.h +24 -0
@@ -9,6 +9,30 @@#include "ocelot.h" +enum mscc_qos_rate_mode { +MSCC_QOS_RATE_MODE_DISABLED ,/* Policer/shaper disabled */ +MSCC_QOS_RATE_MODE_LINE ,/* Measure line rate in kbps incl. IPG */ +MSCC_QOS_RATE_MODE_DATA ,/* Measures data rate in kbps excl. IPG */ +MSCC_QOS_RATE_MODE_FRAME ,/* Measures frame rate in fps */ + __MSCC_QOS_RATE_MODE_END, +NUM_MSCC_QOS_RATE_MODE = __MSCC_QOS_RATE_MODE_END, +MSCC_QOS_RATE_MODE_MAX = __MSCC_QOS_RATE_MODE_END -1 , +}; + +struct qos_policer_conf { +enum mscc_qos_rate_mode mode; +bool dlb;/* Enable DLB (dual leaky bucket mode */ +bool cf;/* Coupling flag (ignored in SLB mode) */ +u32 cir;/* CIR in kbps/fps (ignored in SLB mode) */ +u32 cbs;/* CBS in bytes/frames (ignored in SLB mode) */ +u32 pir;/* PIR in kbps/fps */ +u32 pbs;/* PBS in bytes/frames */ +u8 ipg;/* Size of IPG when MSCC_QOS_RATE_MODE_LINE is chosen */ +}; + +int qos_policer_conf_set (struct ocelot *ocelot,int port,u32 pol_ix, +struct qos_policer_conf *conf); +int ocelot_ace_policer_add (struct ocelot *ocelot,u32 pol_ix,struct ocelot_policer *pol);
drivers/net/ethernet/mscc/ocelot_tc.c deleted +0 -179
179 lines not on this page · raw message
drivers/net/ethernet/mscc/ocelot_tc.h deleted +0 -22
@@ -1,22 +0,0 @@ -/* SPDX-License-Identifier: (GPL-2.0 OR MIT) */ -/* Microsemi Ocelot Switch driver -* -* Copyright (c) 2019 Microsemi Corporation -*/ - -#ifndef _MSCC_OCELOT_TC_H_ -#define _MSCC_OCELOT_TC_H_ - -#include <linux/netdevice.h> - -struct ocelot_port_tc { -bool block_shared; -unsigned long offload_cnt; - -unsigned long police_id; -}; - -int ocelot_setup_tc (struct net_device *dev,enum tc_setup_type type, -void *type_data); - -#endif /* _MSCC_OCELOT_TC_H_ */
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH 10/12 net: mscc: ocelot: rename ocelot_ace.{c,h} to ocelot_vcap.{c,h}
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
Access Control Lists (and their respective Access Control Entries) are specifically entries in the VCAP IS2, the security enforcement block, according to the documentation.
Let's rename the files that deal with generic operations on the VCAP TCAM, so that VCAP IS1 and ES0 can reuse the same code without confusion.
---
drivers/net/ethernet/mscc/Makefile | 2 +-
drivers/net/ethernet/mscc/ocelot.c | 2 +-
drivers/net/ethernet/mscc/ocelot_flower.c | 2 +-
drivers/net/ethernet/mscc/ocelot_net.c | 2 +-
drivers/net/ethernet/mscc/{ocelot_ace.c => ocelot_vcap.c} | 2 +-
drivers/net/ethernet/mscc/{ocelot_ace.h => ocelot_vcap.h} | 0
6 files changed, 5 insertions(+), 5 deletions(-)
rename drivers/net/ethernet/mscc/{ocelot_ace.c => ocelot_vcap.c} (99%)
rename drivers/net/ethernet/mscc/{ocelot_ace.h => ocelot_vcap.h} (100%)drivers/net/ethernet/mscc/Makefile +1 -1
@@ -4,7 +4,7 @@ mscc_ocelot_switch_lib-y := \ ocelot.o \ ocelot_io.o \ ocelot_police.o \ - ocelot_ace.o \ + ocelot_vcap.o \ ocelot_flower.o \ ocelot_ptp.o obj-$(CONFIG_MSCC_OCELOT_SWITCH) += mscc_ocelot.o
drivers/net/ethernet/mscc/ocelot.c +1 -1
@@ -6,7 +6,7 @@*/ #include <linux/if_bridge.h> #include "ocelot.h" -#include "ocelot_ace.h" +#include "ocelot_vcap.h" #define TABLE_UPDATE_SLEEP_US 10#define TABLE_UPDATE_TIMEOUT_US 100000
drivers/net/ethernet/mscc/ocelot_flower.c +1 -1
@@ -6,7 +6,7 @@#include <net/pkt_cls.h> #include <net/tc_act/tc_gact.h> -#include "ocelot_ace.h" +#include "ocelot_vcap.h" static int ocelot_flower_parse_action (struct flow_cls_offload *f,struct ocelot_ace_rule *ace)
drivers/net/ethernet/mscc/ocelot_net.c +1 -1
@@ -6,7 +6,7 @@#include <linux/if_bridge.h> #include "ocelot.h" -#include "ocelot_ace.h" +#include "ocelot_vcap.h" int ocelot_setup_tc_cls_flower(struct ocelot_port_private *priv, struct flow_cls_offload *f,
drivers/net/ethernet/mscc/ocelot_vcap.c renamed from drivers/net/ethernet/mscc/ocelot_ace.c +1 -1
@@ -8,7 +8,7 @@#include <soc/mscc/ocelot_vcap.h> #include "ocelot_police.h" -#include "ocelot_ace.h" +#include "ocelot_vcap.h" #include "ocelot_s2.h" #define OCELOT_POLICER_DISCARD 0x17f
drivers/net/ethernet/mscc/ocelot_vcap.h renamed from drivers/net/ethernet/mscc/ocelot_ace.h +0 -0
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH 11/12 net: mscc: ocelot: generalize the "ACE/ACL" names
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
Access Control Lists (and their respective Access Control Entries) are specifically entries in the VCAP IS2, the security enforcement block, according to the documentation.
Let's rename the structures and functions to something more generic, so that VCAP IS1 structures (which would otherwise have to be called Ingress Classification Entries) can reuse the same code without confusion.
Some renaming that was done:
struct ocelot_ace_rule -> struct ocelot_vcap_filter struct ocelot_acl_block -> struct ocelot_vcap_block enum ocelot_ace_type -> enum ocelot_vcap_key_type struct ocelot_ace_vlan -> struct ocelot_vcap_key_vlan enum ocelot_ace_action -> enum ocelot_vcap_action struct ocelot_ace_stats -> struct ocelot_vcap_stats enum ocelot_ace_type -> enum ocelot_vcap_key_type struct ocelot_ace_frame_* -> struct ocelot_vcap_key_*
No functional change is intended.
--- drivers/net/ethernet/mscc/ocelot.c | 2 +- drivers/net/ethernet/mscc/ocelot_flower.c | 122 ++++----- drivers/net/ethernet/mscc/ocelot_police.h | 6 +- drivers/net/ethernet/mscc/ocelot_vcap.c | 286 +++++++++++----------- drivers/net/ethernet/mscc/ocelot_vcap.h | 88 +++---- include/soc/mscc/ocelot.h | 4 +- 6 files changed, 257 insertions(+), 251 deletions(-)
drivers/net/ethernet/mscc/ocelot.c +1 -1
@@ -1392,7 +1392,7 @@ int ocelot_init(struct ocelot *ocelot)INIT_LIST_HEAD (&ocelot->multicast);ocelot_mact_init (ocelot);ocelot_vlan_init (ocelot); -ocelot_ace_init (ocelot); +ocelot_vcap_init (ocelot);for (port =0 ; port < ocelot->num_phys_ports; port++) {/* Clear all counters (5 groups) */
drivers/net/ethernet/mscc/ocelot_flower.c +61 -61
237 lines not on this page · raw message
drivers/net/ethernet/mscc/ocelot_police.h +3 -3
@@ -33,9 +33,9 @@ struct qos_policer_conf {int qos_policer_conf_set (struct ocelot *ocelot,int port,u32 pol_ix,struct qos_policer_conf *conf); -int ocelot_ace_policer_add (struct ocelot *ocelot,u32 pol_ix, -struct ocelot_policer *pol); +int ocelot_vcap_policer_add (struct ocelot *ocelot,u32 pol_ix, +struct ocelot_policer *pol); -int ocelot_ace_policer_del (struct ocelot *ocelot,u32 pol_ix); +int ocelot_vcap_policer_del (struct ocelot *ocelot,u32 pol_ix);#endif /* _MSCC_OCELOT_POLICE_H_ */
drivers/net/ethernet/mscc/ocelot_vcap.c +146 -140
564 lines not on this page · raw message
drivers/net/ethernet/mscc/ocelot_vcap.h +44 -44
169 lines not on this page · raw message
include/soc/mscc/ocelot.h +2 -2
@@ -470,7 +470,7 @@ struct ocelot_ops {int (*reset)(struct ocelot *ocelot); }; -struct ocelot_acl_block { +struct ocelot_vcap_block {struct list_head rules;int count;int pol_lpr;
@@ -535,7 +535,7 @@ struct ocelot {struct list_head multicast; -struct ocelot_acl_block acl_block; +struct ocelot_vcap_block block;const struct vcap_field *vcap_is2_keys;const struct vcap_field *vcap_is2_actions;
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH 12/12 net: mscc: ocelot: unexpose ocelot_vcap_policer_{add,del}
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
Remove the function prototypes from ocelot_police.h and make these functions static. We need to move them above their callers. Note that moving the implementations to ocelot_police.c is not trivially possible due to dependency on is2_entry_set() which is static to ocelot_vcap.c.
--- drivers/net/ethernet/mscc/ocelot_police.h | 5 -- drivers/net/ethernet/mscc/ocelot_vcap.c | 96 +++++++++++------------ 2 files changed, 45 insertions(+), 56 deletions(-)
drivers/net/ethernet/mscc/ocelot_police.h +0 -5
@@ -33,9 +33,4 @@ struct qos_policer_conf {int qos_policer_conf_set (struct ocelot *ocelot,int port,u32 pol_ix,struct qos_policer_conf *conf); -int ocelot_vcap_policer_add (struct ocelot *ocelot,u32 pol_ix, -struct ocelot_policer *pol); - -int ocelot_vcap_policer_del (struct ocelot *ocelot,u32 pol_ix); -#endif /* _MSCC_OCELOT_POLICE_H_ */
drivers/net/ethernet/mscc/ocelot_vcap.c +45 -51
114 lines not on this page · raw message
Signature · 1 line
2.25.1
David Miller
maintainerFrom: Vladimir Oltean <[email protected]>
Date: Sat, 20 Jun 2020 18:43:35 +0300
Quoted 19 lines
From: Vladimir Oltean <[email protected]>
Some of the code in the mscc felix and ocelot drivers was added while in a bit of a hurry. Let's take a moment and put things in relative order.
First 3 patches are sparse warning fixes.
Patches 4-9 perform some further splitting between
mscc_felix,mscc_ocelot, and the common hardware library they share. Meaning that some code is being moved from the library into just themscc_ocelotmodule.Patches 10-12 refactor the naming conventions in the existing VCAP code (for tc-flower offload), since we're going to be adding some more code for VCAP IS1 (previous tentatives already submitted here:
https://patchwork.ozlabs.org/project/netdev/cover/[email protected]/),
and that code would be confusing to read and maintain using current naming conventions.
Quoted 3 lines
No functional modification is intended. I checked that the VCAP IS2 code still works by applying a tc ingress filter with an EtherType key and 'drop' action.
This looks good, series applied, thanks.