Skip to contentSkip to conversation

New DSA driver for VSC9953 Seville switch

PATCH Superseded Vladimir Oltean 5 participants 31 messages May 27, 2020 – May 29, 2020

Subsystems (5)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Vladimir Oltean

author maintainer
#0 lore raw

cover New DSA driver for VSC9953 Seville switch

Looking at the Felix and Ocelot drivers, Maxim asked if it would be possible to use them as a base for a new driver for the switch inside NXP T1040. Turns out, it is! The result is a driver eerily similar to Felix.

The biggest challenge seems to be getting register read/write API generic enough to cover such wild bitfield variations between hardware generations. There is a patch on the regmap core which I would like to get in through the networking subsystem, if possible (and if Mark is ok), since it's a trivial addition.

Maxim Kochetkov (4):
soc/mscc: ocelot: add MII registers description
net: mscc: ocelot: convert SYS_PAUSE_CFG register access to regfield
net: mscc: ocelot: extend watermark encoding function
net: dsa: ocelot: introduce driver for Seville VSC9953 switch

Vladimir Oltean (7):
regmap: add helper for per-port regfield initialization
net: mscc: ocelot: unexport ocelot_probe_port
net: mscc: ocelot: convert port registers to regmap
net: mscc: ocelot: convert QSYS_SWITCH_PORT_MODE and SYS_PORT_MODE to
regfields
net: dsa: ocelot: create a template for the DSA tags on xmit
net: mscc: ocelot: split writes to pause frame enable bit and to
thresholds
net: mscc: ocelot: disable flow control on NPI interface

 drivers/net/dsa/ocelot/Kconfig           |   12 +
 drivers/net/dsa/ocelot/Makefile          |    6 +
 drivers/net/dsa/ocelot/felix.c           |   49 +-
 drivers/net/dsa/ocelot/felix_vsc9959.c   |   72 +-
 drivers/net/dsa/ocelot/seville.c         |  742 +++++++++++++++
 drivers/net/dsa/ocelot/seville.h         |   50 +
 drivers/net/dsa/ocelot/seville_vsc9953.c | 1064 ++++++++++++++++++++++
 drivers/net/ethernet/mscc/ocelot.c       |   87 +-
 drivers/net/ethernet/mscc/ocelot.h       |    9 +-
 drivers/net/ethernet/mscc/ocelot_board.c |   21 +-
 drivers/net/ethernet/mscc/ocelot_io.c    |   18 +-
 drivers/net/ethernet/mscc/ocelot_regs.c  |   57 ++
 include/linux/regmap.h                   |    8 +
 include/soc/mscc/ocelot.h                |   68 +-
 include/soc/mscc/ocelot_dev.h            |   78 --
 include/soc/mscc/ocelot_qsys.h           |   13 -
 include/soc/mscc/ocelot_sys.h            |   23 -
 net/dsa/tag_ocelot.c                     |   21 +-
 18 files changed, 2196 insertions(+), 202 deletions(-)
 create mode 100644 drivers/net/dsa/ocelot/seville.c
 create mode 100644 drivers/net/dsa/ocelot/seville.h
 create mode 100644 drivers/net/dsa/ocelot/seville_vsc9953.c
Signature · 1 line
2.25.1
author maintainer
#1 lore raw

PATCH 1/11 regmap: add helper for per-port regfield initialization

From: Vladimir Oltean <[email protected]>

Similar to the standalone regfields, add an initializer for the users who need to set .id_size and .id_offset in order to use the regmap_fields_update_bits_base API.

---
 include/linux/regmap.h | 8 ++++++++
 1 file changed, 8 insertions(+)
include/linux/regmap.h +8 -0
index 40b07168fd8e..87703d105191 100644
@@ -1134,6 +1134,14 @@ struct reg_field {
 				.msb = _msb,	\
 				}
 
+#define REG_FIELD_ID(_reg, _lsb, _msb, _size, _offset) {	\
+				.reg = _reg,			\
+				.lsb = _lsb,			\
+				.msb = _msb,			\
+				.id_size = _size,		\
+				.id_offset = _offset,		\
+				}
+
 struct regmap_field *regmap_field_alloc(struct regmap *regmap,
 		struct reg_field reg_field);
 void regmap_field_free(struct regmap_field *field);
Signature · 1 line
2.25.1
author maintainer
#2 lore raw

Re: [PATCH net-next 01/11] regmap: add helper for per-port regfield initialization

Quoted 9 lines · Vladimir Oltean

From: Vladimir Oltean <[email protected]>

Similar to the standalone regfields, add an initializer for the users who need to set .id_size and .id_offset in order to use the regmap_fields_update_bits_base API.

---

Oops, looks like I forgot to copy Mark on this patch, sorry... Since you don't have this series in your inbox, here's the patchwork link to it:
https://patchwork.ozlabs.org/project/netdev/cover/[email protected]/

Quoted 23 lines
 include/linux/regmap.h | 8 ++++++++
 1 file changed, 8 insertions(+)
include/linux/regmap.h +8 -1
index 40b07168fd8e..87703d105191 100644
@@ -1134,6 +1134,14 @@ struct reg_field {
                                .msb = _msb,    \
                                }
 
+#define REG_FIELD_ID(_reg, _lsb, _msb, _size, _offset) {       \
+                               .reg = _reg,                    \
+                               .lsb = _lsb,                    \
+                               .msb = _msb,                    \
+                               .id_size = _size,               \
+                               .id_offset = _offset,           \
+                               }
+
 struct regmap_field *regmap_field_alloc(struct regmap *regmap,
                struct reg_field reg_field);
 void regmap_field_free(struct regmap_field *field);
--
Quoted 2 lines

2.25.1

Regards,
-Vladimir

author maintainer
#3 lore raw

PATCH 2/11 net: mscc: ocelot: unexport ocelot_probe_port

In reply to Vladimir Oltean

From: Vladimir Oltean <[email protected]>

This is not being used by any other module except ocelot (i.e. felix does not use it). So remove the EXPORT_SYMBOL.

---
 drivers/net/ethernet/mscc/ocelot.c | 1 -
 1 file changed, 1 deletion(-)
drivers/net/ethernet/mscc/ocelot.c +0 -1
index e621c4c3ee86..ff875c2f1d46 100644
@@ -2152,7 +2152,6 @@ int ocelot_probe_port(struct ocelot *ocelot, u8 port,
 
 	return err;
 }
-EXPORT_SYMBOL(ocelot_probe_port);
 
 /* Configure and enable the CPU port module, which is a set of queues.
  * If @npi contains a valid port index, the CPU port module is connected
Signature · 1 line
2.25.1
maintainer
#4 lore raw

Re: [PATCH net-next 02/11] net: mscc: ocelot: unexport ocelot_probe_port

Quoted 15 lines · On Thu, 28 May 2020 02:41:04 +0300 Vladimir Oltean wrote:

From: Vladimir Oltean <[email protected]>

This is not being used by any other module except ocelot (i.e. felix does not use it). So remove the EXPORT_SYMBOL.

---
 drivers/net/ethernet/mscc/ocelot.c | 1 -
 1 file changed, 1 deletion(-)
drivers/net/ethernet/mscc/ocelot.c +0 -0
index e621c4c3ee86..ff875c2f1d46 100644

drivers/net/ethernet/mscc/ocelot.c int ocelot_probe_port(struct ocelot *ocelot, u8 port, · line 2157

Quoted 7 lines
drivers/net/ethernet/mscc/ocelot.c +0 -1
@@ -2152,7 +2152,6 @@ int ocelot_probe_port(struct ocelot *ocelot, u8 port,
 
 	return err;
 }
-EXPORT_SYMBOL(ocelot_probe_port);
 
 /* Configure and enable the CPU port module, which is a set of queues.
  * If @npi contains a valid port index, the CPU port module is connected

Strangely I get an error after this patch:

ERROR: modpost: "ocelot_probe_port" [drivers/net/ethernet/mscc/ocelot_board.ko] undefined! make[2]: *** [__modpost] Error 1 make[1]: *** [modules] Error 2
make: *** [sub-make] Error 2

Maybe a build system error, could you double check?

author maintainer
#5 lore raw

Re: [PATCH net-next 02/11] net: mscc: ocelot: unexport ocelot_probe_port

Quoted 27 lines · Jakub Kicinski
Quoted 15 lines · On Thu, 28 May 2020 02:41:04 +0300 Vladimir Oltean wrote:

From: Vladimir Oltean <[email protected]>

This is not being used by any other module except ocelot (i.e. felix does not use it). So remove the EXPORT_SYMBOL.

---
 drivers/net/ethernet/mscc/ocelot.c | 1 -
 1 file changed, 1 deletion(-)
drivers/net/ethernet/mscc/ocelot.c +0 -0
index e621c4c3ee86..ff875c2f1d46 100644

drivers/net/ethernet/mscc/ocelot.c int ocelot_probe_port(struct ocelot *ocelot, u8 port, · line 2157

Quoted 7 lines
drivers/net/ethernet/mscc/ocelot.c +0 -1
@@ -2152,7 +2152,6 @@ int ocelot_probe_port(struct ocelot *ocelot, u8 port,
 
      return err;
 }
-EXPORT_SYMBOL(ocelot_probe_port);
 
 /* Configure and enable the CPU port module, which is a set of queues.
  * If @npi contains a valid port index, the CPU port module is connected

Strangely I get an error after this patch:

Quoted 6 lines

ERROR: modpost: "ocelot_probe_port" [drivers/net/ethernet/mscc/ocelot_board.ko] undefined! make[2]: *** [__modpost] Error 1 make[1]: *** [modules] Error 2
make: *** [sub-make] Error 2

Maybe a build system error, could you double check?

Oh, I keep forgetting that CONFIG_MSCC_OCELOT_SWITCH and CONFIG_MSCC_OCELOT_SWITCH_OCELOT are different modules.... Ok, so moving ocelot_probe_port to ocelot_board.c needs a bit more work, I guess I'll just skip this patch for now.

author maintainer
#6 lore raw

PATCH 3/11 net: mscc: ocelot: convert port registers to regmap

In reply to Vladimir Oltean

From: Vladimir Oltean <[email protected]>

At the moment, there are some minimal register differences between VSC7514 Ocelot and VSC9959 Felix. To be precise, the PCS1G registers are missing from Felix because it was integrated with an NXP PCS.

But with VSC9953 Seville (not yet introduced), the register differences are more pronounced. The MAC registers are located at different offsets within the DEV_GMII target. So we need to refactor the driver to keep a regmap even for per-port registers. The callers of the ocelot_port_readl and ocelot_port_writel were kept unchanged, only the implementation is now more generic.

---
 drivers/net/dsa/ocelot/felix.c           | 13 ++--
 drivers/net/dsa/ocelot/felix_vsc9959.c   | 45 +++++++++++++-
 drivers/net/ethernet/mscc/ocelot.c       |  5 +-
 drivers/net/ethernet/mscc/ocelot.h       |  3 +-
 drivers/net/ethernet/mscc/ocelot_board.c |  8 +--
 drivers/net/ethernet/mscc/ocelot_io.c    | 16 ++++-
 drivers/net/ethernet/mscc/ocelot_regs.c  | 43 +++++++++++++
 include/soc/mscc/ocelot.h                | 42 ++++++++++++-
 include/soc/mscc/ocelot_dev.h            | 78 ------------------------
 9 files changed, 156 insertions(+), 97 deletions(-)
drivers/net/dsa/ocelot/felix.c +7 -6
index a6e272d2110d..13722cde503e 100644
@@ -478,7 +478,7 @@ static int felix_init_structs(struct felix *felix, int num_phys_ports)
 
 	for (port = 0; port < num_phys_ports; port++) {
 		struct ocelot_port *ocelot_port;
-		void __iomem *port_regs;
+		struct regmap *target;
 
 		ocelot_port = devm_kzalloc(ocelot->dev,
 					   sizeof(struct ocelot_port),
@@ -495,17 +495,18 @@ static int felix_init_structs(struct felix *felix, int num_phys_ports)
 		res.start += switch_base;
 		res.end += switch_base;
 
-		port_regs = devm_ioremap_resource(ocelot->dev, &res);
-		if (IS_ERR(port_regs)) {
+		target = ocelot_regmap_init(ocelot, &res);
+		if (IS_ERR(target)) {
 			dev_err(ocelot->dev,
-				"failed to map registers for port %d\n", port);
+				"Failed to map memory space for port %d\n",
+				port);
 			kfree(port_phy_modes);
-			return PTR_ERR(port_regs);
+			return PTR_ERR(target);
 		}
 
 		ocelot_port->phy_mode = port_phy_modes[port];
 		ocelot_port->ocelot = ocelot;
-		ocelot_port->regs = port_regs;
+		ocelot_port->target = target;
 		ocelot->ports[port] = ocelot_port;
 	}
 
drivers/net/dsa/ocelot/felix_vsc9959.c +44 -1

60 lines not on this page · raw message

drivers/net/ethernet/mscc/ocelot.c +2 -3
index ff875c2f1d46..d5bfa6d3e73c 100644
@@ -2108,8 +2108,7 @@ void ocelot_init_port(struct ocelot *ocelot, int port)
 }
 EXPORT_SYMBOL(ocelot_init_port);
 
-int ocelot_probe_port(struct ocelot *ocelot, u8 port,
-		      void __iomem *regs,
+int ocelot_probe_port(struct ocelot *ocelot, int port, struct regmap *target,
 		      struct phy_device *phy)
 {
 	struct ocelot_port_private *priv;
@@ -2127,7 +2126,7 @@ int ocelot_probe_port(struct ocelot *ocelot, u8 port,
 	priv->chip_port = port;
 	ocelot_port = &priv->port;
 	ocelot_port->ocelot = ocelot;
-	ocelot_port->regs = regs;
+	ocelot_port->target = target;
 	ocelot->ports[port] = ocelot_port;
 
 	dev->netdev_ops = &ocelot_port_netdev_ops;
drivers/net/ethernet/mscc/ocelot.h +1 -2
index f0a15aa187f2..b22997dd098e 100644
@@ -67,8 +67,7 @@ void ocelot_port_writel(struct ocelot_port *port, u32 val, u32 reg);
 #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,
+int ocelot_probe_port(struct ocelot *ocelot, int port, struct regmap *target,
 		      struct phy_device *phy);
 
 void ocelot_set_cpu_port(struct ocelot *ocelot, int cpu,
drivers/net/ethernet/mscc/ocelot_board.c +4 -4
index 67a8d61c926a..b6ea9694c3ae 100644
@@ -505,9 +505,9 @@ static int mscc_ocelot_probe(struct platform_device *pdev)
 		struct device_node *phy_node;
 		phy_interface_t phy_mode;
 		struct phy_device *phy;
+		struct regmap *target;
 		struct resource *res;
 		struct phy *serdes;
-		void __iomem *regs;
 		char res_name[8];
 		u32 port;
 
@@ -518,8 +518,8 @@ static int mscc_ocelot_probe(struct platform_device *pdev)
 
 		res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
 						   res_name);
-		regs = devm_ioremap_resource(&pdev->dev, res);
-		if (IS_ERR(regs))
+		target = ocelot_regmap_init(ocelot, res);
+		if (IS_ERR(target))
 			continue;
 
 		phy_node = of_parse_phandle(portnp, "phy-handle", 0);
@@ -531,7 +531,7 @@ static int mscc_ocelot_probe(struct platform_device *pdev)
 		if (!phy)
 			continue;
 
-		err = ocelot_probe_port(ocelot, port, regs, phy);
+		err = ocelot_probe_port(ocelot, port, target, phy);
 		if (err) {
 			of_node_put(portnp);
 			goto out_put_ports;
drivers/net/ethernet/mscc/ocelot_io.c +14 -2
index b229b1cb68ef..741f653bc85b 100644
@@ -49,13 +49,25 @@ EXPORT_SYMBOL(__ocelot_rmw_ix);
 
 u32 ocelot_port_readl(struct ocelot_port *port, u32 reg)
 {
-	return readl(port->regs + reg);
+	struct ocelot *ocelot = port->ocelot;
+	u16 target = reg >> TARGET_OFFSET;
+	u32 val;
+
+	WARN_ON(!target);
+
+	regmap_read(port->target, ocelot->map[target][reg & REG_MASK], &val);
+	return val;
 }
 EXPORT_SYMBOL(ocelot_port_readl);
 
 void ocelot_port_writel(struct ocelot_port *port, u32 val, u32 reg)
 {
-	writel(val, port->regs + reg);
+	struct ocelot *ocelot = port->ocelot;
+	u16 target = reg >> TARGET_OFFSET;
+
+	WARN_ON(!target);
+
+	regmap_write(port->target, ocelot->map[target][reg & REG_MASK], val);
 }
 EXPORT_SYMBOL(ocelot_port_writel);
 
drivers/net/ethernet/mscc/ocelot_regs.c +43 -0

55 lines not on this page · raw message

include/soc/mscc/ocelot.h +41 -1

60 lines not on this page · raw message

include/soc/mscc/ocelot_dev.h +0 -78

213 lines not on this page · raw message

Signature · 1 line
2.25.1
author maintainer
#7 lore raw

PATCH 4/11 soc/mscc: ocelot: add MII registers description

In reply to Vladimir Oltean

From: Maxim Kochetkov <[email protected]>

Add the register definitions for the MSCC MIIM MDIO controller in preparation for seville_vsc9959.c to create its accessors for the internal MDIO bus.

---
 include/soc/mscc/ocelot.h | 5 +++++
 1 file changed, 5 insertions(+)
include/soc/mscc/ocelot.h +5 -0
index 79c77aab87e5..85b16f099c8f 100644
@@ -394,6 +394,9 @@ enum ocelot_reg {
 	PTP_CLK_CFG_ADJ_CFG,
 	PTP_CLK_CFG_ADJ_FREQ,
 	GCB_SOFT_RST = GCB << TARGET_OFFSET,
+	GCB_MIIM_MII_STATUS,
+	GCB_MIIM_MII_CMD,
+	GCB_MIIM_MII_DATA,
 	DEV_CLOCK_CFG = DEV_GMII << TARGET_OFFSET,
 	DEV_PORT_MISC,
 	DEV_EVENTS,
@@ -481,6 +484,8 @@ enum ocelot_regfield {
 	SYS_RESET_CFG_MEM_ENA,
 	SYS_RESET_CFG_MEM_INIT,
 	GCB_SOFT_RST_SWC_RST,
+	GCB_MIIM_MII_STATUS_PENDING,
+	GCB_MIIM_MII_STATUS_BUSY,
 	REGFIELD_MAX
 };
 
Signature · 1 line
2.25.1
author maintainer
#8 lore raw

PATCH 5/11 net: mscc: ocelot: convert QSYS_SWITCH_PORT_MODE and SYS_PORT_MODE to regfields

In reply to Vladimir Oltean

From: Vladimir Oltean <[email protected]>

Currently Felix and Ocelot share the same bit layout in these per-port registers, but Seville does not. So we need reg_fields for that.

Actually since these are per-port registers, we need to also specify the number of ports, and register size per port, and use the regmap API for multiple ports.

---
 drivers/net/dsa/ocelot/felix.c          | 13 ++++----
 drivers/net/dsa/ocelot/felix_vsc9959.c  | 11 +++++++
 drivers/net/ethernet/mscc/ocelot.c      | 44 ++++++++++++-------------
 drivers/net/ethernet/mscc/ocelot.h      |  6 ----
 drivers/net/ethernet/mscc/ocelot_io.c   |  2 ++
 drivers/net/ethernet/mscc/ocelot_regs.c | 11 +++++++
 include/soc/mscc/ocelot.h               | 15 +++++++++
 include/soc/mscc/ocelot_qsys.h          | 13 --------
 include/soc/mscc/ocelot_sys.h           | 13 --------
 9 files changed, 68 insertions(+), 60 deletions(-)
drivers/net/dsa/ocelot/felix.c +7 -6
index 13722cde503e..8b15cbcb597c 100644
@@ -260,8 +260,7 @@ static void felix_phylink_mac_link_down(struct dsa_switch *ds, int port,
 	struct ocelot_port *ocelot_port = ocelot->ports[port];
 
 	ocelot_port_writel(ocelot_port, 0, DEV_MAC_ENA_CFG);
-	ocelot_rmw_rix(ocelot, 0, QSYS_SWITCH_PORT_MODE_PORT_ENA,
-		       QSYS_SWITCH_PORT_MODE, port);
+	ocelot_fields_write(ocelot, port, QSYS_SWITCH_PORT_MODE_PORT_ENA, 0);
 }
 
 static void felix_phylink_mac_link_up(struct dsa_switch *ds, int port,
@@ -287,10 +286,12 @@ static void felix_phylink_mac_link_up(struct dsa_switch *ds, int port,
 			 ANA_PORT_PORT_CFG, port);
 
 	/* Core: Enable port for frame transfer */
-	ocelot_write_rix(ocelot, QSYS_SWITCH_PORT_MODE_INGRESS_DROP_MODE |
-			 QSYS_SWITCH_PORT_MODE_SCH_NEXT_CFG(1) |
-			 QSYS_SWITCH_PORT_MODE_PORT_ENA,
-			 QSYS_SWITCH_PORT_MODE, port);
+	ocelot_fields_write(ocelot, port,
+			    QSYS_SWITCH_PORT_MODE_INGRESS_DROP_MODE, 1);
+	ocelot_fields_write(ocelot, port,
+			    QSYS_SWITCH_PORT_MODE_SCH_NEXT_CFG, 1);
+	ocelot_fields_write(ocelot, port,
+			    QSYS_SWITCH_PORT_MODE_PORT_ENA, 1);
 }
 
 static void felix_port_qos_map_init(struct ocelot *ocelot, int port)
drivers/net/dsa/ocelot/felix_vsc9959.c +11 -0
index dda7a3a7aa6f..dc9480e82d70 100644
@@ -503,6 +503,17 @@ static const struct reg_field vsc9959_regfields[] = {
 	[ANA_TABLES_MACTINDX_M_INDEX] = REG_FIELD(ANA_TABLES_MACTINDX, 0, 10),
 	[SYS_RESET_CFG_CORE_ENA] = REG_FIELD(SYS_RESET_CFG, 0, 0),
 	[GCB_SOFT_RST_SWC_RST] = REG_FIELD(GCB_SOFT_RST, 0, 0),
+	/* Replicated per number of ports (7), register size 4 per port */
+	[QSYS_SWITCH_PORT_MODE_PORT_ENA] = REG_FIELD_ID(QSYS_SWITCH_PORT_MODE, 14, 14, 7, 4),
+	[QSYS_SWITCH_PORT_MODE_SCH_NEXT_CFG] = REG_FIELD_ID(QSYS_SWITCH_PORT_MODE, 11, 13, 7, 4),
+	[QSYS_SWITCH_PORT_MODE_YEL_RSRVD] = REG_FIELD_ID(QSYS_SWITCH_PORT_MODE, 10, 10, 7, 4),
+	[QSYS_SWITCH_PORT_MODE_INGRESS_DROP_MODE] = REG_FIELD_ID(QSYS_SWITCH_PORT_MODE, 9, 9, 7, 4),
+	[QSYS_SWITCH_PORT_MODE_TX_PFC_ENA] = REG_FIELD_ID(QSYS_SWITCH_PORT_MODE, 1, 8, 7, 4),
+	[QSYS_SWITCH_PORT_MODE_TX_PFC_MODE] = REG_FIELD_ID(QSYS_SWITCH_PORT_MODE, 0, 0, 7, 4),
+	[SYS_PORT_MODE_DATA_WO_TS] = REG_FIELD_ID(SYS_PORT_MODE, 5, 6, 7, 4),
+	[SYS_PORT_MODE_INCL_INJ_HDR] = REG_FIELD_ID(SYS_PORT_MODE, 3, 4, 7, 4),
+	[SYS_PORT_MODE_INCL_XTR_HDR] = REG_FIELD_ID(SYS_PORT_MODE, 1, 2, 7, 4),
+	[SYS_PORT_MODE_INCL_HDR_ERR] = REG_FIELD_ID(SYS_PORT_MODE, 0, 0, 7, 4),
 };
 
 static const struct ocelot_stat_layout vsc9959_stats_layout[] = {
drivers/net/ethernet/mscc/ocelot.c +22 -22

67 lines not on this page · raw message

drivers/net/ethernet/mscc/ocelot.h +0 -6
index b22997dd098e..d6a3cb5a4b36 100644
@@ -63,9 +63,6 @@ struct ocelot_port_private {
 u32 ocelot_port_readl(struct ocelot_port *port, u32 reg);
 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, int port, struct regmap *target,
 		      struct phy_device *phy);
@@ -78,7 +75,4 @@ extern struct notifier_block ocelot_netdevice_nb;
 extern struct notifier_block ocelot_switchdev_nb;
 extern struct notifier_block ocelot_switchdev_blocking_nb;
 
-#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))
-
 #endif
drivers/net/ethernet/mscc/ocelot_io.c +2 -0
index 741f653bc85b..d22711282183 100644
@@ -89,6 +89,8 @@ int ocelot_regfields_init(struct ocelot *ocelot,
 		regfield.reg = ocelot->map[target][reg & REG_MASK];
 		regfield.lsb = regfields[i].lsb;
 		regfield.msb = regfields[i].msb;
+		regfield.id_size = regfields[i].id_size;
+		regfield.id_offset = regfields[i].id_offset;
 
 		ocelot->regfields[i] =
 		devm_regmap_field_alloc(ocelot->dev,
drivers/net/ethernet/mscc/ocelot_regs.c +11 -0
index 18d73b4e5cb5..56bdb1bb2f36 100644
@@ -341,6 +341,17 @@ static const struct reg_field ocelot_regfields[] = {
 	[SYS_RESET_CFG_CORE_ENA] = REG_FIELD(SYS_RESET_CFG, 2, 2),
 	[SYS_RESET_CFG_MEM_ENA] = REG_FIELD(SYS_RESET_CFG, 1, 1),
 	[SYS_RESET_CFG_MEM_INIT] = REG_FIELD(SYS_RESET_CFG, 0, 0),
+	/* Replicated per number of ports (11), register size 4 per port */
+	[QSYS_SWITCH_PORT_MODE_PORT_ENA] = REG_FIELD_ID(QSYS_SWITCH_PORT_MODE, 14, 14, 11, 4),
+	[QSYS_SWITCH_PORT_MODE_SCH_NEXT_CFG] = REG_FIELD_ID(QSYS_SWITCH_PORT_MODE, 11, 13, 11, 4),
+	[QSYS_SWITCH_PORT_MODE_YEL_RSRVD] = REG_FIELD_ID(QSYS_SWITCH_PORT_MODE, 10, 10, 11, 4),
+	[QSYS_SWITCH_PORT_MODE_INGRESS_DROP_MODE] = REG_FIELD_ID(QSYS_SWITCH_PORT_MODE, 9, 9, 11, 4),
+	[QSYS_SWITCH_PORT_MODE_TX_PFC_ENA] = REG_FIELD_ID(QSYS_SWITCH_PORT_MODE, 1, 8, 11, 4),
+	[QSYS_SWITCH_PORT_MODE_TX_PFC_MODE] = REG_FIELD_ID(QSYS_SWITCH_PORT_MODE, 0, 0, 11, 4),
+	[SYS_PORT_MODE_DATA_WO_TS] = REG_FIELD_ID(SYS_PORT_MODE, 5, 6, 11, 4),
+	[SYS_PORT_MODE_INCL_INJ_HDR] = REG_FIELD_ID(SYS_PORT_MODE, 3, 4, 11, 4),
+	[SYS_PORT_MODE_INCL_XTR_HDR] = REG_FIELD_ID(SYS_PORT_MODE, 1, 2, 11, 4),
+	[SYS_PORT_MODE_INCL_HDR_ERR] = REG_FIELD_ID(SYS_PORT_MODE, 0, 0, 11, 4),
 };
 
 static const struct ocelot_stat_layout ocelot_stats_layout[] = {
include/soc/mscc/ocelot.h +15 -0
index 85b16f099c8f..8e6c13d99ced 100644
@@ -475,11 +475,21 @@ enum ocelot_regfield {
 	ANA_TABLES_MACACCESS_B_DOM,
 	ANA_TABLES_MACTINDX_BUCKET,
 	ANA_TABLES_MACTINDX_M_INDEX,
+	QSYS_SWITCH_PORT_MODE_PORT_ENA,
+	QSYS_SWITCH_PORT_MODE_SCH_NEXT_CFG,
+	QSYS_SWITCH_PORT_MODE_YEL_RSRVD,
+	QSYS_SWITCH_PORT_MODE_INGRESS_DROP_MODE,
+	QSYS_SWITCH_PORT_MODE_TX_PFC_ENA,
+	QSYS_SWITCH_PORT_MODE_TX_PFC_MODE,
 	QSYS_TIMED_FRAME_ENTRY_TFRM_VLD,
 	QSYS_TIMED_FRAME_ENTRY_TFRM_FP,
 	QSYS_TIMED_FRAME_ENTRY_TFRM_PORTNO,
 	QSYS_TIMED_FRAME_ENTRY_TFRM_TM_SEL,
 	QSYS_TIMED_FRAME_ENTRY_TFRM_TM_T,
+	SYS_PORT_MODE_DATA_WO_TS,
+	SYS_PORT_MODE_INCL_INJ_HDR,
+	SYS_PORT_MODE_INCL_XTR_HDR,
+	SYS_PORT_MODE_INCL_HDR_ERR,
 	SYS_RESET_CFG_CORE_ENA,
 	SYS_RESET_CFG_MEM_ENA,
 	SYS_RESET_CFG_MEM_INIT,
@@ -623,6 +633,11 @@ struct ocelot_policer {
 #define ocelot_rmw_rix(ocelot, val, m, reg, ri) __ocelot_rmw_ix(ocelot, val, m, reg, reg##_RSZ * (ri))
 #define ocelot_rmw(ocelot, val, m, reg) __ocelot_rmw_ix(ocelot, val, m, reg, 0)
 
+#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))
+#define ocelot_fields_write(ocelot, id, reg, val) regmap_fields_write((ocelot)->regfields[(reg)], (id), (val))
+#define ocelot_fields_read(ocelot, id, reg, val) regmap_fields_read((ocelot)->regfields[(reg)], (id), (val))
+
 /* I/O */
 u32 ocelot_port_readl(struct ocelot_port *port, u32 reg);
 void ocelot_port_writel(struct ocelot_port *port, u32 val, u32 reg);
include/soc/mscc/ocelot_qsys.h +0 -13
index d8c63aa761be..a814bc2017d8 100644
@@ -13,19 +13,6 @@
 #define QSYS_PORT_MODE_DEQUEUE_DIS                        BIT(1)
 #define QSYS_PORT_MODE_DEQUEUE_LATE                       BIT(0)
 
-#define QSYS_SWITCH_PORT_MODE_RSZ                         0x4
-
-#define QSYS_SWITCH_PORT_MODE_PORT_ENA                    BIT(14)
-#define QSYS_SWITCH_PORT_MODE_SCH_NEXT_CFG(x)             (((x) << 11) & GENMASK(13, 11))
-#define QSYS_SWITCH_PORT_MODE_SCH_NEXT_CFG_M              GENMASK(13, 11)
-#define QSYS_SWITCH_PORT_MODE_SCH_NEXT_CFG_X(x)           (((x) & GENMASK(13, 11)) >> 11)
-#define QSYS_SWITCH_PORT_MODE_YEL_RSRVD                   BIT(10)
-#define QSYS_SWITCH_PORT_MODE_INGRESS_DROP_MODE           BIT(9)
-#define QSYS_SWITCH_PORT_MODE_TX_PFC_ENA(x)               (((x) << 1) & GENMASK(8, 1))
-#define QSYS_SWITCH_PORT_MODE_TX_PFC_ENA_M                GENMASK(8, 1)
-#define QSYS_SWITCH_PORT_MODE_TX_PFC_ENA_X(x)             (((x) & GENMASK(8, 1)) >> 1)
-#define QSYS_SWITCH_PORT_MODE_TX_PFC_MODE                 BIT(0)
-
 #define QSYS_STAT_CNT_CFG_TX_GREEN_CNT_MODE               BIT(5)
 #define QSYS_STAT_CNT_CFG_TX_YELLOW_CNT_MODE              BIT(4)
 #define QSYS_STAT_CNT_CFG_DROP_GREEN_CNT_MODE             BIT(3)
include/soc/mscc/ocelot_sys.h +0 -13
index 16f91e172bcb..8a95fc93fde5 100644
@@ -12,19 +12,6 @@
 
 #define SYS_COUNT_TX_OCTETS_RSZ                           0x4
 
-#define SYS_PORT_MODE_RSZ                                 0x4
-
-#define SYS_PORT_MODE_DATA_WO_TS(x)                       (((x) << 5) & GENMASK(6, 5))
-#define SYS_PORT_MODE_DATA_WO_TS_M                        GENMASK(6, 5)
-#define SYS_PORT_MODE_DATA_WO_TS_X(x)                     (((x) & GENMASK(6, 5)) >> 5)
-#define SYS_PORT_MODE_INCL_INJ_HDR(x)                     (((x) << 3) & GENMASK(4, 3))
-#define SYS_PORT_MODE_INCL_INJ_HDR_M                      GENMASK(4, 3)
-#define SYS_PORT_MODE_INCL_INJ_HDR_X(x)                   (((x) & GENMASK(4, 3)) >> 3)
-#define SYS_PORT_MODE_INCL_XTR_HDR(x)                     (((x) << 1) & GENMASK(2, 1))
-#define SYS_PORT_MODE_INCL_XTR_HDR_M                      GENMASK(2, 1)
-#define SYS_PORT_MODE_INCL_XTR_HDR_X(x)                   (((x) & GENMASK(2, 1)) >> 1)
-#define SYS_PORT_MODE_INJ_HDR_ERR                         BIT(0)
-
 #define SYS_FRONT_PORT_MODE_RSZ                           0x4
 
 #define SYS_FRONT_PORT_MODE_HDX_MODE                      BIT(0)
Signature · 1 line
2.25.1
author maintainer
#9 lore raw

PATCH 6/11 net: dsa: ocelot: create a template for the DSA tags on xmit

In reply to Vladimir Oltean

From: Vladimir Oltean <[email protected]>

With this patch we try to kill 2 birds with 1 stone.

First of all, some switches that use tag_ocelot.c don't have the exact same bitfield layout for the DSA tags. The destination ports field is different for Seville VSC9953 for example. So the choices are to either duplicate tag_ocelot.c into a new tag_seville.c (sub-optimal) or somehow take into account a supposed ocelot->dest_ports_offset when packing this field into the DSA injection header (again not ideal).

Secondly, tag_ocelot.c already needs to memset a 128-bit area to zero and call some packing() functions of dubious performance in the fastpath. And most of the values it needs to pack are pretty much constant (BYPASS=1, SRC_PORT=CPU, DEST=port index). So it would be good if we could improve that.

The proposed solution is to allocate a memory area per port at probe time, initialize that with the statically defined bits as per chip hardware revision, and just perform a simpler memcpy in the fastpath.

---
 drivers/net/dsa/ocelot/felix.c | 23 +++++++++++++++++++++++
 include/soc/mscc/ocelot.h      |  2 ++
 net/dsa/tag_ocelot.c           | 21 ++++++++-------------
 3 files changed, 33 insertions(+), 13 deletions(-)
drivers/net/dsa/ocelot/felix.c +23 -0
index 8b15cbcb597c..0a392e0f4fbb 100644
@@ -480,6 +480,8 @@ static int felix_init_structs(struct felix *felix, int num_phys_ports)
 	for (port = 0; port < num_phys_ports; port++) {
 		struct ocelot_port *ocelot_port;
 		struct regmap *target;
+		u64 bypass, dest, src;
+		u8 *template;
 
 		ocelot_port = devm_kzalloc(ocelot->dev,
 					   sizeof(struct ocelot_port),
@@ -505,9 +507,30 @@ static int felix_init_structs(struct felix *felix, int num_phys_ports)
 			return PTR_ERR(target);
 		}
 
+		template = devm_kzalloc(ocelot->dev, OCELOT_TAG_LEN,
+					GFP_KERNEL);
+		if (!template) {
+			dev_err(ocelot->dev,
+				"Failed to allocate memory for DSA tag\n");
+			kfree(port_phy_modes);
+			return -ENOMEM;
+		}
+
+		/* Set the source port as the CPU port module and not the
+		 * NPI port
+		 */
+		src = ocelot->num_phys_ports;
+		dest = BIT(port);
+		bypass = true;
+
+		packing(template, &bypass, 127, 127, OCELOT_TAG_LEN, PACK, 0);
+		packing(template, &dest,    68,  56, OCELOT_TAG_LEN, PACK, 0);
+		packing(template, &src,     46,  43, OCELOT_TAG_LEN, PACK, 0);
+
 		ocelot_port->phy_mode = port_phy_modes[port];
 		ocelot_port->ocelot = ocelot;
 		ocelot_port->target = target;
+		ocelot_port->xmit_template = template;
 		ocelot->ports[port] = ocelot_port;
 	}
 
include/soc/mscc/ocelot.h +2 -0
index 8e6c13d99ced..1a87a3a32616 100644
@@ -549,6 +549,8 @@ struct ocelot_port {
 	u8				ts_id;
 
 	phy_interface_t			phy_mode;
+
+	u8				*xmit_template;
 };
 
 struct ocelot {
net/dsa/tag_ocelot.c +8 -13
index b0c98ee4e13b..42f327c06dca 100644
@@ -137,11 +137,10 @@ static struct sk_buff *ocelot_xmit(struct sk_buff *skb,
 				   struct net_device *netdev)
 {
 	struct dsa_port *dp = dsa_slave_to_port(netdev);
-	u64 bypass, dest, src, qos_class, rew_op;
 	struct dsa_switch *ds = dp->ds;
-	int port = dp->index;
 	struct ocelot *ocelot = ds->priv;
-	struct ocelot_port *ocelot_port = ocelot->ports[port];
+	struct ocelot_port *ocelot_port;
+	u64 qos_class, rew_op;
 	u8 *injection;
 
 	if (unlikely(skb_cow_head(skb, OCELOT_TAG_LEN) < 0)) {
@@ -149,19 +148,15 @@ static struct sk_buff *ocelot_xmit(struct sk_buff *skb,
 		return NULL;
 	}
 
-	injection = skb_push(skb, OCELOT_TAG_LEN);
+	ocelot_port = ocelot->ports[dp->index];
 
-	memset(injection, 0, OCELOT_TAG_LEN);
+	injection = skb_push(skb, OCELOT_TAG_LEN);
 
-	/* Set the source port as the CPU port module and not the NPI port */
-	src = ocelot->num_phys_ports;
-	dest = BIT(port);
-	bypass = true;
+	memcpy(injection, ocelot_port->xmit_template, OCELOT_TAG_LEN);
+	/* Fix up the fields which are not statically determined
+	 * in the template
+	 */
 	qos_class = skb->priority;
-
-	packing(injection, &bypass,   127, 127, OCELOT_TAG_LEN, PACK, 0);
-	packing(injection, &dest,      68,  56, OCELOT_TAG_LEN, PACK, 0);
-	packing(injection, &src,       46,  43, OCELOT_TAG_LEN, PACK, 0);
 	packing(injection, &qos_class, 19,  17, OCELOT_TAG_LEN, PACK, 0);
 
 	if (ocelot->ptp && (skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)) {
Signature · 1 line
2.25.1
maintainer
#10 lore raw

Re: [PATCH net-next 06/11] net: dsa: ocelot: create a template for the DSA tags on xmit

Quoted 17 lines · Vladimir Oltean

From: Vladimir Oltean <[email protected]>

With this patch we try to kill 2 birds with 1 stone.

First of all, some switches that use tag_ocelot.c don't have the exact same bitfield layout for the DSA tags. The destination ports field is different for Seville VSC9953 for example. So the choices are to either duplicate tag_ocelot.c into a new tag_seville.c (sub-optimal) or somehow take into account a supposed ocelot->dest_ports_offset when packing this field into the DSA injection header (again not ideal).

Secondly, tag_ocelot.c already needs to memset a 128-bit area to zero and call some packing() functions of dubious performance in the fastpath. And most of the values it needs to pack are pretty much constant (BYPASS=1, SRC_PORT=CPU, DEST=port index). So it would be good if we could improve that.

Quoted 3 lines

The proposed solution is to allocate a memory area per port at probe time, initialize that with the statically defined bits as per chip hardware revision, and just perform a simpler memcpy in the fastpath.

Hi Vladimir

We try to keep the taggers independent of the DSA drivers. I think tag_ocelot.c is the only one that breaks this.

tag drivers are kernel modules. They have all the options of a kernel module, such as init and exit functions. You could create these templates in the module init function, and clean them up in the exit function. You can also register multiple taggers in one driver. tag_brcm.c does this as an example. So you can have a Seville tagger which uses different templates to ocelot.

Andrew

author maintainer
#11 lore raw

Re: [PATCH net-next 06/11] net: dsa: ocelot: create a template for the DSA tags on xmit

Hi Andrew,

Quoted 28 lines · Andrew Lunn
Quoted 17 lines · Vladimir Oltean

From: Vladimir Oltean <[email protected]>

With this patch we try to kill 2 birds with 1 stone.

First of all, some switches that use tag_ocelot.c don't have the exact same bitfield layout for the DSA tags. The destination ports field is different for Seville VSC9953 for example. So the choices are to either duplicate tag_ocelot.c into a new tag_seville.c (sub-optimal) or somehow take into account a supposed ocelot->dest_ports_offset when packing this field into the DSA injection header (again not ideal).

Secondly, tag_ocelot.c already needs to memset a 128-bit area to zero and call some packing() functions of dubious performance in the fastpath. And most of the values it needs to pack are pretty much constant (BYPASS=1, SRC_PORT=CPU, DEST=port index). So it would be good if we could improve that.

Quoted 3 lines

The proposed solution is to allocate a memory area per port at probe time, initialize that with the statically defined bits as per chip hardware revision, and just perform a simpler memcpy in the fastpath.

Hi Vladimir

We try to keep the taggers independent of the DSA drivers. I think tag_ocelot.c is the only one that breaks this.

Quoted 8 lines

tag drivers are kernel modules. They have all the options of a kernel module, such as init and exit functions. You could create these templates in the module init function, and clean them up in the exit function. You can also register multiple taggers in one driver. tag_brcm.c does this as an example. So you can have a Seville tagger which uses different templates to ocelot.

Andrew

I don't particularly like that tag_brcm.c is riddled with #if / #endif, they make it difficult to follow.

And if I allocate/free the xmit template in the dsa_tag_driver_module_init / dsa_tag_driver_module_exit, how can I reach the pointer to the correct per-switch-per-port template in the ocelot_xmit function?

Please note that ocelot_xmit is already stateful, and it _needs_ to be
stateful: for 1588, it saves and increments the TX timestamp ID which will be matched to the data that is received in felix_irq_handler.

And sja1105 also breaks the tagger/driver separation, and in even "worse" ways - see sja1105_xmit_tpid which transmits a different frame depending on which state the driver is in; also sja1105_decode_subvlan which on RX looks up a table populated by the driver.

Generally speaking, I don't see any good reason why keeping the tagger and the driver separated should be a design goal, especially when the hotpath depends on stateful information (and the tagging driver can't do anything at all without a backing switch driver anyway). Separation could be done only in the simplest of cases, but as more advanced features are necessary (not arguing that the template I'm adding here is "advanced" stuff), this becomes practically impossible. Please also see this tag_ocelot.c patch which needs to take the classified VLAN from the DSA tag, or not, depending on the VLAN awareness state of the port:
https://patchwork.ozlabs.org/project/netdev/patch/[email protected]/

Thanks,
-Vladimir

author maintainer
#12 lore raw

PATCH 7/11 net: mscc: ocelot: split writes to pause frame enable bit and to thresholds

In reply to Vladimir Oltean

From: Vladimir Oltean <[email protected]>

We don't want ocelot_port_set_maxlen to enable pause frame TX, just to adjust the pause thresholds.

Move the unconditional enabling of pause TX to ocelot_init_port. There is no good place to put such setting because it shouldn't be unconditional. But at the moment it is, we're not changing that.

---
 drivers/net/ethernet/mscc/ocelot.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)
drivers/net/ethernet/mscc/ocelot.c +12 -7
index 0f016f497972..6fc5b72c9260 100644
@@ -2012,6 +2012,7 @@ void ocelot_port_set_maxlen(struct ocelot *ocelot, int port, size_t sdu)
 {
 	struct ocelot_port *ocelot_port = ocelot->ports[port];
 	int maxlen = sdu + ETH_HLEN + ETH_FCS_LEN;
+	int pause_start, pause_stop;
 	int atop_wm;
 
 	if (port == ocelot->npi) {
@@ -2025,13 +2026,13 @@ void ocelot_port_set_maxlen(struct ocelot *ocelot, int port, size_t sdu)
 
 	ocelot_port_writel(ocelot_port, maxlen, DEV_MAC_MAXLEN_CFG);
 
-	/* Set Pause WM hysteresis
-	 * 152 = 6 * maxlen / OCELOT_BUFFER_CELL_SZ
-	 * 101 = 4 * maxlen / OCELOT_BUFFER_CELL_SZ
-	 */
-	ocelot_write_rix(ocelot, SYS_PAUSE_CFG_PAUSE_ENA |
-			 SYS_PAUSE_CFG_PAUSE_STOP(101) |
-			 SYS_PAUSE_CFG_PAUSE_START(152), SYS_PAUSE_CFG, port);
+	/* Set Pause watermark hysteresis */
+	pause_start = 6 * maxlen / OCELOT_BUFFER_CELL_SZ;
+	pause_stop = 4 * maxlen / OCELOT_BUFFER_CELL_SZ;
+	ocelot_rmw_rix(ocelot, SYS_PAUSE_CFG_PAUSE_START(pause_start),
+		       SYS_PAUSE_CFG_PAUSE_START_M, SYS_PAUSE_CFG, port);
+	ocelot_rmw_rix(ocelot, SYS_PAUSE_CFG_PAUSE_STOP(pause_stop),
+		       SYS_PAUSE_CFG_PAUSE_STOP_M, SYS_PAUSE_CFG, port);
 
 	/* Tail dropping watermark */
 	atop_wm = (ocelot->shared_queue_sz - 9 * maxlen) /
@@ -2094,6 +2095,10 @@ void ocelot_init_port(struct ocelot *ocelot, int port)
 	ocelot_port_writel(ocelot_port, 0, DEV_MAC_FC_MAC_HIGH_CFG);
 	ocelot_port_writel(ocelot_port, 0, DEV_MAC_FC_MAC_LOW_CFG);
 
+	/* Enable transmission of pause frames */
+	ocelot_rmw_rix(ocelot, SYS_PAUSE_CFG_PAUSE_ENA, SYS_PAUSE_CFG_PAUSE_ENA,
+		       SYS_PAUSE_CFG, port);
+
 	/* Drop frames with multicast source address */
 	ocelot_rmw_gix(ocelot, ANA_PORT_DROP_CFG_DROP_MC_SMAC_ENA,
 		       ANA_PORT_DROP_CFG_DROP_MC_SMAC_ENA,
Signature · 1 line
2.25.1
author maintainer
#13 lore raw

PATCH 8/11 net: mscc: ocelot: disable flow control on NPI interface

In reply to Vladimir Oltean

From: Vladimir Oltean <[email protected]>

The Ocelot switches do not support flow control on Ethernet interfaces where a DSA tag must be added. If pause frames are enabled, they will be encapsulated in the DSA tag just like regular frames, and the DSA master will not recognize them.

---
 drivers/net/ethernet/mscc/ocelot.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/net/ethernet/mscc/ocelot.c +4 -0
index 6fc5b72c9260..41d1026ec5b3 100644
@@ -2200,6 +2200,10 @@ void ocelot_configure_cpu(struct ocelot *ocelot, int npi,
 				    extraction);
 		ocelot_fields_write(ocelot, npi, SYS_PORT_MODE_INCL_INJ_HDR,
 				    injection);
+
+		/* Disable transmission of pause frames */
+		ocelot_rmw_rix(ocelot, 0, SYS_PAUSE_CFG_PAUSE_ENA,
+			       SYS_PAUSE_CFG, npi);
 	}
 
 	/* Enable CPU port module */
Signature · 1 line
2.25.1
author maintainer
#14 lore raw

PATCH 9/11 net: mscc: ocelot: convert SYS_PAUSE_CFG register access to regfield

In reply to Vladimir Oltean

From: Maxim Kochetkov <[email protected]>

Seville has a different bitwise layout than Ocelot and Felix.

---
 drivers/net/dsa/ocelot/felix_vsc9959.c  |  3 +++
 drivers/net/ethernet/mscc/ocelot.c      | 14 ++++++--------
 drivers/net/ethernet/mscc/ocelot_regs.c |  3 +++
 include/soc/mscc/ocelot.h               |  3 +++
 include/soc/mscc/ocelot_sys.h           | 10 ----------
 5 files changed, 15 insertions(+), 18 deletions(-)
drivers/net/dsa/ocelot/felix_vsc9959.c +3 -0
index dc9480e82d70..bd0bb720558c 100644
@@ -514,6 +514,9 @@ static const struct reg_field vsc9959_regfields[] = {
 	[SYS_PORT_MODE_INCL_INJ_HDR] = REG_FIELD_ID(SYS_PORT_MODE, 3, 4, 7, 4),
 	[SYS_PORT_MODE_INCL_XTR_HDR] = REG_FIELD_ID(SYS_PORT_MODE, 1, 2, 7, 4),
 	[SYS_PORT_MODE_INCL_HDR_ERR] = REG_FIELD_ID(SYS_PORT_MODE, 0, 0, 7, 4),
+	[SYS_PAUSE_CFG_PAUSE_START] = REG_FIELD_ID(SYS_PAUSE_CFG, 10, 18, 7, 4),
+	[SYS_PAUSE_CFG_PAUSE_STOP] = REG_FIELD_ID(SYS_PAUSE_CFG, 1, 9, 7, 4),
+	[SYS_PAUSE_CFG_PAUSE_ENA] = REG_FIELD_ID(SYS_PAUSE_CFG, 0, 1, 7, 4),
 };
 
 static const struct ocelot_stat_layout vsc9959_stats_layout[] = {
drivers/net/ethernet/mscc/ocelot.c +6 -8
index 41d1026ec5b3..b66589a5300c 100644
@@ -2029,10 +2029,10 @@ void ocelot_port_set_maxlen(struct ocelot *ocelot, int port, size_t sdu)
 	/* Set Pause watermark hysteresis */
 	pause_start = 6 * maxlen / OCELOT_BUFFER_CELL_SZ;
 	pause_stop = 4 * maxlen / OCELOT_BUFFER_CELL_SZ;
-	ocelot_rmw_rix(ocelot, SYS_PAUSE_CFG_PAUSE_START(pause_start),
-		       SYS_PAUSE_CFG_PAUSE_START_M, SYS_PAUSE_CFG, port);
-	ocelot_rmw_rix(ocelot, SYS_PAUSE_CFG_PAUSE_STOP(pause_stop),
-		       SYS_PAUSE_CFG_PAUSE_STOP_M, SYS_PAUSE_CFG, port);
+	ocelot_fields_write(ocelot, port, SYS_PAUSE_CFG_PAUSE_START,
+			    pause_start);
+	ocelot_fields_write(ocelot, port, SYS_PAUSE_CFG_PAUSE_STOP,
+			    pause_stop);
 
 	/* Tail dropping watermark */
 	atop_wm = (ocelot->shared_queue_sz - 9 * maxlen) /
@@ -2096,8 +2096,7 @@ void ocelot_init_port(struct ocelot *ocelot, int port)
 	ocelot_port_writel(ocelot_port, 0, DEV_MAC_FC_MAC_LOW_CFG);
 
 	/* Enable transmission of pause frames */
-	ocelot_rmw_rix(ocelot, SYS_PAUSE_CFG_PAUSE_ENA, SYS_PAUSE_CFG_PAUSE_ENA,
-		       SYS_PAUSE_CFG, port);
+	ocelot_fields_write(ocelot, port, SYS_PAUSE_CFG_PAUSE_ENA, 1);
 
 	/* Drop frames with multicast source address */
 	ocelot_rmw_gix(ocelot, ANA_PORT_DROP_CFG_DROP_MC_SMAC_ENA,
@@ -2202,8 +2201,7 @@ void ocelot_configure_cpu(struct ocelot *ocelot, int npi,
 				    injection);
 
 		/* Disable transmission of pause frames */
-		ocelot_rmw_rix(ocelot, 0, SYS_PAUSE_CFG_PAUSE_ENA,
-			       SYS_PAUSE_CFG, npi);
+		ocelot_fields_write(ocelot, npi, SYS_PAUSE_CFG_PAUSE_ENA, 0);
 	}
 
 	/* Enable CPU port module */
drivers/net/ethernet/mscc/ocelot_regs.c +3 -0
index 56bdb1bb2f36..eeb4771a9a2a 100644
@@ -352,6 +352,9 @@ static const struct reg_field ocelot_regfields[] = {
 	[SYS_PORT_MODE_INCL_INJ_HDR] = REG_FIELD_ID(SYS_PORT_MODE, 3, 4, 11, 4),
 	[SYS_PORT_MODE_INCL_XTR_HDR] = REG_FIELD_ID(SYS_PORT_MODE, 1, 2, 11, 4),
 	[SYS_PORT_MODE_INCL_HDR_ERR] = REG_FIELD_ID(SYS_PORT_MODE, 0, 0, 11, 4),
+	[SYS_PAUSE_CFG_PAUSE_START] = REG_FIELD_ID(SYS_PAUSE_CFG, 10, 18, 11, 4),
+	[SYS_PAUSE_CFG_PAUSE_STOP] = REG_FIELD_ID(SYS_PAUSE_CFG, 1, 9, 11, 4),
+	[SYS_PAUSE_CFG_PAUSE_ENA] = REG_FIELD_ID(SYS_PAUSE_CFG, 0, 1, 11, 4),
 };
 
 static const struct ocelot_stat_layout ocelot_stats_layout[] = {
include/soc/mscc/ocelot.h +3 -0
index 1a87a3a32616..a97cc1796b5e 100644
@@ -496,6 +496,9 @@ enum ocelot_regfield {
 	GCB_SOFT_RST_SWC_RST,
 	GCB_MIIM_MII_STATUS_PENDING,
 	GCB_MIIM_MII_STATUS_BUSY,
+	SYS_PAUSE_CFG_PAUSE_START,
+	SYS_PAUSE_CFG_PAUSE_STOP,
+	SYS_PAUSE_CFG_PAUSE_ENA,
 	REGFIELD_MAX
 };
 
include/soc/mscc/ocelot_sys.h +0 -10
index 8a95fc93fde5..79cf40ccdbe6 100644
@@ -43,16 +43,6 @@
 #define SYS_TIMESTAMP_OFFSET_TIMESTAMP_OFFSET(x)          ((x) & GENMASK(5, 0))
 #define SYS_TIMESTAMP_OFFSET_TIMESTAMP_OFFSET_M           GENMASK(5, 0)
 
-#define SYS_PAUSE_CFG_RSZ                                 0x4
-
-#define SYS_PAUSE_CFG_PAUSE_START(x)                      (((x) << 10) & GENMASK(18, 10))
-#define SYS_PAUSE_CFG_PAUSE_START_M                       GENMASK(18, 10)
-#define SYS_PAUSE_CFG_PAUSE_START_X(x)                    (((x) & GENMASK(18, 10)) >> 10)
-#define SYS_PAUSE_CFG_PAUSE_STOP(x)                       (((x) << 1) & GENMASK(9, 1))
-#define SYS_PAUSE_CFG_PAUSE_STOP_M                        GENMASK(9, 1)
-#define SYS_PAUSE_CFG_PAUSE_STOP_X(x)                     (((x) & GENMASK(9, 1)) >> 1)
-#define SYS_PAUSE_CFG_PAUSE_ENA                           BIT(0)
-
 #define SYS_PAUSE_TOT_CFG_PAUSE_TOT_START(x)              (((x) << 9) & GENMASK(17, 9))
 #define SYS_PAUSE_TOT_CFG_PAUSE_TOT_START_M               GENMASK(17, 9)
 #define SYS_PAUSE_TOT_CFG_PAUSE_TOT_START_X(x)            (((x) & GENMASK(17, 9)) >> 9)
Signature · 1 line
2.25.1
author maintainer
#15 lore raw

PATCH 10/11 net: mscc: ocelot: extend watermark encoding function

In reply to Vladimir Oltean

From: Maxim Kochetkov <[email protected]>

The ocelot_wm_encode function deals with setting thresholds for pause frame start and stop. In Ocelot and Felix the register layout is the same, but for Seville, it isn't. The easiest way to accommodate Seville hardware configuration is to introduce a function pointer for setting this up.

---
 drivers/net/dsa/ocelot/felix_vsc9959.c   | 13 +++++++++++++
 drivers/net/ethernet/mscc/ocelot.c       | 16 ++--------------
 drivers/net/ethernet/mscc/ocelot_board.c | 13 +++++++++++++
 include/soc/mscc/ocelot.h                |  1 +
 4 files changed, 29 insertions(+), 14 deletions(-)
drivers/net/dsa/ocelot/felix_vsc9959.c +13 -0
index bd0bb720558c..8efcc2bda2b0 100644
@@ -1162,8 +1162,21 @@ static int vsc9959_prevalidate_phy_mode(struct ocelot *ocelot, int port,
 	}
 }
 
+/* Watermark encode
+ * Bit 8:   Unit; 0:1, 1:16
+ * Bit 7-0: Value to be multiplied with unit
+ */
+static u16 vsc9959_wm_enc(u16 value)
+{
+	if (value >= BIT(8))
+		return BIT(8) | (value / 16);
+
+	return value;
+}
+
 static const struct ocelot_ops vsc9959_ops = {
 	.reset			= vsc9959_reset,
+	.wm_enc			= vsc9959_wm_enc,
 };
 
 static int vsc9959_mdio_bus_alloc(struct ocelot *ocelot)
drivers/net/ethernet/mscc/ocelot.c +2 -14
index b66589a5300c..583f62c52131 100644
@@ -396,18 +396,6 @@ static void ocelot_vlan_init(struct ocelot *ocelot)
 	}
 }
 
-/* Watermark encode
- * Bit 8:   Unit; 0:1, 1:16
- * Bit 7-0: Value to be multiplied with unit
- */
-static u16 ocelot_wm_enc(u16 value)
-{
-	if (value >= BIT(8))
-		return BIT(8) | (value / 16);
-
-	return value;
-}
-
 void ocelot_adjust_link(struct ocelot *ocelot, int port,
 			struct phy_device *phydev)
 {
@@ -2037,9 +2025,9 @@ void ocelot_port_set_maxlen(struct ocelot *ocelot, int port, size_t sdu)
 	/* Tail dropping watermark */
 	atop_wm = (ocelot->shared_queue_sz - 9 * maxlen) /
 		   OCELOT_BUFFER_CELL_SZ;
-	ocelot_write_rix(ocelot, ocelot_wm_enc(9 * maxlen),
+	ocelot_write_rix(ocelot, ocelot->ops->wm_enc(9 * maxlen),
 			 SYS_ATOP, port);
-	ocelot_write(ocelot, ocelot_wm_enc(atop_wm), SYS_ATOP_TOT_CFG);
+	ocelot_write(ocelot, ocelot->ops->wm_enc(atop_wm), SYS_ATOP_TOT_CFG);
 }
 EXPORT_SYMBOL(ocelot_port_set_maxlen);
 
drivers/net/ethernet/mscc/ocelot_board.c +13 -0
index b6ea9694c3ae..4a807a9027f5 100644
@@ -239,8 +239,21 @@ static int ocelot_reset(struct ocelot *ocelot)
 	return 0;
 }
 
+/* Watermark encode
+ * Bit 8:   Unit; 0:1, 1:16
+ * Bit 7-0: Value to be multiplied with unit
+ */
+static u16 ocelot_wm_enc(u16 value)
+{
+	if (value >= BIT(8))
+		return BIT(8) | (value / 16);
+
+	return value;
+}
+
 static const struct ocelot_ops ocelot_ops = {
 	.reset			= ocelot_reset,
+	.wm_enc			= ocelot_wm_enc,
 };
 
 static const struct vcap_field vsc7514_vcap_is2_keys[] = {
include/soc/mscc/ocelot.h +1 -0
index a97cc1796b5e..8a2cb5ea17e7 100644
@@ -526,6 +526,7 @@ struct ocelot;
 
 struct ocelot_ops {
 	int (*reset)(struct ocelot *ocelot);
+	u16 (*wm_enc)(u16 value);
 };
 
 struct ocelot_acl_block {
Signature · 1 line
2.25.1
author maintainer
#16 lore raw

PATCH 11/11 net: dsa: ocelot: introduce driver for Seville VSC9953 switch

In reply to Vladimir Oltean

From: Maxim Kochetkov <[email protected]>

This is a 10-port (8 external, 2 internal) switch from Vitesse/Microsemi/Microchip that is integrated into the Freescale/NXP T1040 PowerPC SoC. The situation is very similar to Felix from NXP LS1028A, except that this is a platform device and Felix is a PCI device.

Extending the Felix driver to probe a PCI as well as a platform device would have introduced unnecessary complexity. The 'meat' of both drivers is in drivers/net/ethernet/mscc/ocelot*.c anyway, so let's just duplicate the Felix driver, s/Felix/Seville/, and define the low-level bits in seville_vsc9953.c.

Like Felix, this driver configures its own PCS on the internal MDIO bus using a phy_device abstraction for it (yes, it will be refactored to use a raw mdio_device, like other phylink drivers do, but let's keep it like that for now). But unlike Felix, the MDIO bus and the PCS are not from the same vendor. The PCS is the same QorIQ/Layerscape PCS as found in Felix/ENETC/DPAA*, but the internal MDIO bus that is used to access it is actually an instantiation of drivers/net/phy/mdio-mscc-miim.c. But it would be difficult to reuse that driver (it doesn't even use regmap, and it's less than 200 lines of code), so we hand-roll here some internal MDIO bus accessors within seville_vsc9953.c, which serves the purpose of driving the PCS absolutely fine.

Also, same as Felix, the PCS doesn't support dynamic reconfiguration of SerDes protocol, so we need to do pre-validation of PHY mode from device tree and not let phylink change it.

---
 drivers/net/dsa/ocelot/Kconfig           |   12 +
 drivers/net/dsa/ocelot/Makefile          |    6 +
 drivers/net/dsa/ocelot/seville.c         |  742 +++++++++++++++
 drivers/net/dsa/ocelot/seville.h         |   50 +
 drivers/net/dsa/ocelot/seville_vsc9953.c | 1064 ++++++++++++++++++++++
 5 files changed, 1874 insertions(+)
 create mode 100644 drivers/net/dsa/ocelot/seville.c
 create mode 100644 drivers/net/dsa/ocelot/seville.h
 create mode 100644 drivers/net/dsa/ocelot/seville_vsc9953.c
drivers/net/dsa/ocelot/Kconfig +12 -0
index a5b7cca03d09..38763b829b17 100644
@@ -12,3 +12,15 @@ config NET_DSA_MSCC_FELIX
 	  the Vitesse / Microsemi / Microchip Ocelot family of switching cores.
 	  It is embedded as a PCIe function of the NXP LS1028A ENETC integrated
 	  endpoint.
+
+config NET_DSA_MSCC_SEVILLE
+	tristate "Ocelot / Seville Ethernet switch support"
+	depends on NET_DSA
+	depends on NET_VENDOR_MICROSEMI
+	depends on NET_VENDOR_FREESCALE
+	select MSCC_OCELOT_SWITCH
+	select NET_DSA_TAG_OCELOT
+	help
+	  This driver supports the VSC9953 network switch, which is a member of
+	  the Vitesse / Microsemi / Microchip Ocelot family of switching cores.
+	  It is embedded inside the NXP T1040 SoC.
drivers/net/dsa/ocelot/Makefile +6 -0
index 37ad403e0b2a..17b1ccdcbf17 100644
@@ -4,3 +4,9 @@ obj-$(CONFIG_NET_DSA_MSCC_FELIX) += mscc_felix.o
 mscc_felix-objs := \
 	felix.o \
 	felix_vsc9959.o
+
+obj-$(CONFIG_NET_DSA_MSCC_SEVILLE) += mscc_seville.o
+
+mscc_seville-objs := \
+	seville.o \
+	seville_vsc9953.o
drivers/net/dsa/ocelot/seville.c new file +742 -0

742 lines not on this page · raw message

drivers/net/dsa/ocelot/seville.h new file +50 -0

50 lines not on this page · raw message

drivers/net/dsa/ocelot/seville_vsc9953.c new file +1064 -0

1,064 lines not on this page · raw message

Signature · 1 line
2.25.1
maintainer
#17 lore raw

Re: [PATCH net-next 11/11] net: dsa: ocelot: introduce driver for Seville VSC9953 switch

Quoted 26 lines · On Thu, 28 May 2020 02:41:13 +0300 Vladimir Oltean wrote:

From: Maxim Kochetkov <[email protected]>

This is a 10-port (8 external, 2 internal) switch from Vitesse/Microsemi/Microchip that is integrated into the Freescale/NXP T1040 PowerPC SoC. The situation is very similar to Felix from NXP LS1028A, except that this is a platform device and Felix is a PCI device.

Extending the Felix driver to probe a PCI as well as a platform device would have introduced unnecessary complexity. The 'meat' of both drivers is in drivers/net/ethernet/mscc/ocelot*.c anyway, so let's just duplicate the Felix driver, s/Felix/Seville/, and define the low-level bits in seville_vsc9953.c.

Like Felix, this driver configures its own PCS on the internal MDIO bus using a phy_device abstraction for it (yes, it will be refactored to use a raw mdio_device, like other phylink drivers do, but let's keep it like that for now). But unlike Felix, the MDIO bus and the PCS are not from the same vendor. The PCS is the same QorIQ/Layerscape PCS as found in Felix/ENETC/DPAA*, but the internal MDIO bus that is used to access it is actually an instantiation of drivers/net/phy/mdio-mscc-miim.c. But it would be difficult to reuse that driver (it doesn't even use regmap, and it's less than 200 lines of code), so we hand-roll here some internal MDIO bus accessors within seville_vsc9953.c, which serves the purpose of driving the PCS absolutely fine.

Quoted 6 lines

Also, same as Felix, the PCS doesn't support dynamic reconfiguration of SerDes protocol, so we need to do pre-validation of PHY mode from device tree and not let phylink change it.

drivers/net/dsa/ocelot/seville_vsc9953.c:636:19: warning: symbol 'vsc9953_vcap_is2_keys' was not declared. Should it be static? drivers/net/dsa/ocelot/seville_vsc9953.c:706:19: warning: symbol 'vsc9953_vcap_is2_actions' was not declared. Should it be static?

author maintainer
#18 lore raw

Re: [PATCH net-next 11/11] net: dsa: ocelot: introduce driver for Seville VSC9953 switch

Quoted 32 lines · Jakub Kicinski
Quoted 30 lines · On Thu, 28 May 2020 02:41:13 +0300 Vladimir Oltean wrote:

From: Maxim Kochetkov <[email protected]>

This is a 10-port (8 external, 2 internal) switch from Vitesse/Microsemi/Microchip that is integrated into the Freescale/NXP T1040 PowerPC SoC. The situation is very similar to Felix from NXP LS1028A, except that this is a platform device and Felix is a PCI device.

Extending the Felix driver to probe a PCI as well as a platform device would have introduced unnecessary complexity. The 'meat' of both drivers is in drivers/net/ethernet/mscc/ocelot*.c anyway, so let's just duplicate the Felix driver, s/Felix/Seville/, and define the low-level bits in seville_vsc9953.c.

Like Felix, this driver configures its own PCS on the internal MDIO bus using a phy_device abstraction for it (yes, it will be refactored to use a raw mdio_device, like other phylink drivers do, but let's keep it like that for now). But unlike Felix, the MDIO bus and the PCS are not from the same vendor. The PCS is the same QorIQ/Layerscape PCS as found in Felix/ENETC/DPAA*, but the internal MDIO bus that is used to access it is actually an instantiation of drivers/net/phy/mdio-mscc-miim.c. But it would be difficult to reuse that driver (it doesn't even use regmap, and it's less than 200 lines of code), so we hand-roll here some internal MDIO bus accessors within seville_vsc9953.c, which serves the purpose of driving the PCS absolutely fine.

Also, same as Felix, the PCS doesn't support dynamic reconfiguration of SerDes protocol, so we need to do pre-validation of PHY mode from device tree and not let phylink change it.

Quoted 5 lines
Quoted 2 lines

drivers/net/dsa/ocelot/seville_vsc9953.c:636:19: warning: symbol 'vsc9953_vcap_is2_keys' was not declared. Should it be static? drivers/net/dsa/ocelot/seville_vsc9953.c:706:19: warning: symbol 'vsc9953_vcap_is2_actions' was not declared. Should it be static?

Rhetorical question...

maintainer
#19 lore raw

Re: [PATCH net-next 11/11] net: dsa: ocelot: introduce driver for Seville VSC9953 switch

In reply to Vladimir Oltean
Quoted 5 lines

Extending the Felix driver to probe a PCI as well as a platform device would have introduced unnecessary complexity. The 'meat' of both drivers is in drivers/net/ethernet/mscc/ocelot*.c anyway, so let's just duplicate the Felix driver, s/Felix/Seville/, and define the low-level bits in seville_vsc9953.c.

Hi Vladimir

That has resulted in a lot of duplicated code.

Is there an overall family name for these switch?

Could you add foo_set_ageing_time() with both felix and saville share?

Andrew

author maintainer
#20 lore raw

Re: [PATCH net-next 11/11] net: dsa: ocelot: introduce driver for Seville VSC9953 switch

Quoted 9 lines · Andrew Lunn
Quoted 6 lines

Extending the Felix driver to probe a PCI as well as a platform device would have introduced unnecessary complexity. The 'meat' of both drivers is in drivers/net/ethernet/mscc/ocelot*.c anyway, so let's just duplicate the Felix driver, s/Felix/Seville/, and define the low-level bits in seville_vsc9953.c.

Hi Vladimir

Quoted 7 lines

That has resulted in a lot of duplicated code.

Is there an overall family name for these switch?

Could you add foo_set_ageing_time() with both felix and saville share?

Andrew

Yes, it looks like I can. I can move Felix PCI probing to felix_vsc9959.c, Seville platform device probing to seville_vsc9953.c, and remove seville.c.
I would not be in a position to know whether there's any larger family name which should be used here. According to
https://media.digikey.com/pdf/Data%20Sheets/Microsemi%20PDFs/Ocelot_Family_of_Ethernet_Switches_Dec2016.pdf,
"Ocelot is a low port count, small form factor Ethernet switch family for the Industrial IoT market". Seville would not qualify as part of the Ocelot family (high port count, no 1588) but that doesn't mean it can't use the Ocelot driver. As confusing as it might be for the people at Microchip, I would tend to call anything that probes as pure switchdev "ocelot" and anything that probes as DSA "felix", since these were the first 2 drivers that entered mainline. Under this working model, Seville would reuse the struct dsa_switch_ops felix_switch_ops, while having its own low-level seville_vsc9953.c that deals with platform integration specific stuff (probing, internal MDIO, register map, etc), and the felix_switch_ops would call into ocelot for the common functionalities.
What do you think?

-Vladimir

#21 lore raw

Re: [PATCH net-next 11/11] net: dsa: ocelot: introduce driver for Seville VSC9953 switch

Quoted 18 lines · Vladimir Oltean
Quoted 9 lines · Andrew Lunn
Quoted 6 lines

Extending the Felix driver to probe a PCI as well as a platform device would have introduced unnecessary complexity. The 'meat' of both drivers is in drivers/net/ethernet/mscc/ocelot*.c anyway, so let's just duplicate the Felix driver, s/Felix/Seville/, and define the low-level bits in seville_vsc9953.c.

Hi Vladimir

Quoted 7 lines

That has resulted in a lot of duplicated code.

Is there an overall family name for these switch?

Could you add foo_set_ageing_time() with both felix and saville share?

Andrew

Quoted 12 lines

Yes, it looks like I can. I can move Felix PCI probing to felix_vsc9959.c, Seville platform device probing to seville_vsc9953.c, and remove seville.c.
I would not be in a position to know whether there's any larger family name which should be used here. According to
https://media.digikey.com/pdf/Data%20Sheets/Microsemi%20PDFs/Ocelot_Family_of_Ethernet_Switches_Dec2016.pdf,
"Ocelot is a low port count, small form factor Ethernet switch family for the Industrial IoT market". Seville would not qualify as part of the Ocelot family (high port count, no 1588) but that doesn't mean it can't use the Ocelot driver. As confusing as it might be for the people at Microchip, I would tend to call anything that probes as pure switchdev "ocelot" and anything that probes as DSA "felix", since

As ocelot can be used in a DSA configuration (even if it is not implemented yet), I don't think this would be correct. From my point of view, felix and seville are part of the ocelot family.

Quoted 9 lines

these were the first 2 drivers that entered mainline. Under this working model, Seville would reuse the struct dsa_switch_ops felix_switch_ops, while having its own low-level seville_vsc9953.c that deals with platform integration specific stuff (probing, internal MDIO, register map, etc), and the felix_switch_ops would call into ocelot for the common functionalities.
What do you think?

-Vladimir

Signature · 3 lines
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
author maintainer
#22 lore raw

Re: [PATCH net-next 11/11] net: dsa: ocelot: introduce driver for Seville VSC9953 switch

Hi Alexandre,

Quoted 33 lines · Alexandre Belloni
Quoted 18 lines · Vladimir Oltean
Quoted 9 lines · Andrew Lunn
Quoted 6 lines

Extending the Felix driver to probe a PCI as well as a platform device would have introduced unnecessary complexity. The 'meat' of both drivers is in drivers/net/ethernet/mscc/ocelot*.c anyway, so let's just duplicate the Felix driver, s/Felix/Seville/, and define the low-level bits in seville_vsc9953.c.

Hi Vladimir

Quoted 7 lines

That has resulted in a lot of duplicated code.

Is there an overall family name for these switch?

Could you add foo_set_ageing_time() with both felix and saville share?

Andrew

Quoted 12 lines

Yes, it looks like I can. I can move Felix PCI probing to felix_vsc9959.c, Seville platform device probing to seville_vsc9953.c, and remove seville.c.
I would not be in a position to know whether there's any larger family name which should be used here. According to
https://media.digikey.com/pdf/Data%20Sheets/Microsemi%20PDFs/Ocelot_Family_of_Ethernet_Switches_Dec2016.pdf,
"Ocelot is a low port count, small form factor Ethernet switch family for the Industrial IoT market". Seville would not qualify as part of the Ocelot family (high port count, no 1588) but that doesn't mean it can't use the Ocelot driver. As confusing as it might be for the people at Microchip, I would tend to call anything that probes as pure switchdev "ocelot" and anything that probes as DSA "felix", since

Quoted 4 lines

As ocelot can be used in a DSA configuration (even if it is not implemented yet), I don't think this would be correct. From my point of view, felix and seville are part of the ocelot family.

In this case, there would be a third driver in drivers/net/dsa/ocelot/ocelot_vsc7511.c which uses the intermediate felix_switch_ops from felix.c to access the ocelot core implementation. Unless you have better naming suggestions?

Quoted 8 lines
Quoted 8 lines

these were the first 2 drivers that entered mainline. Under this working model, Seville would reuse the struct dsa_switch_ops felix_switch_ops, while having its own low-level seville_vsc9953.c that deals with platform integration specific stuff (probing, internal MDIO, register map, etc), and the felix_switch_ops would call into ocelot for the common functionalities.
What do you think?

Quoted 6 lines
Quoted 1 line

-Vladimir

--
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

Thanks,
-Vladimir

#23 lore raw

Re: [PATCH net-next 11/11] net: dsa: ocelot: introduce driver for Seville VSC9953 switch

Quoted 10 lines · Vladimir Oltean
Quoted 4 lines

As ocelot can be used in a DSA configuration (even if it is not implemented yet), I don't think this would be correct. From my point of view, felix and seville are part of the ocelot family.

In this case, there would be a third driver in drivers/net/dsa/ocelot/ocelot_vsc7511.c which uses the intermediate felix_switch_ops from felix.c to access the ocelot core implementation. Unless you have better naming suggestions?

I don't. Maybe felix.c should have been ocelot.c from the beginning but honestly, it doesn't matter that much.

BTW, maybe we should merge the VITESSE FELIX ETHERNET SWITCH DRIVER and MICROSEMI ETHERNET SWITCH DRIVER entries in MAINTAINERS. You do much more work in drivers/net/ethernet/mscc/ than I currently do.

Signature · 3 lines
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
author maintainer
#24 lore raw

Re: [PATCH net-next 11/11] net: dsa: ocelot: introduce driver for Seville VSC9953 switch

Quoted 7 lines · Alexandre Belloni
Quoted 5 lines · Vladimir Oltean
Quoted 4 lines

As ocelot can be used in a DSA configuration (even if it is not implemented yet), I don't think this would be correct. From my point of view, felix and seville are part of the ocelot family.

Quoted 9 lines
Quoted 5 lines

In this case, there would be a third driver in drivers/net/dsa/ocelot/ocelot_vsc7511.c which uses the intermediate felix_switch_ops from felix.c to access the ocelot core implementation. Unless you have better naming suggestions?

I don't. Maybe felix.c should have been ocelot.c from the beginning but honestly, it doesn't matter that much.

Technically Seville is not part of the Ocelot family but part of Serval, but then again, it's just a marketing name, so it doesn't really mean anything..
I am a bit reluctant to rename the DSA driver ops to "ocelot", since it would be even more confusing for everyone to have a function ocelot_dsa_set_ageing_time that calls ocelot_set_ageing_time. At least this way, there's going to be some learning curve figuring out that felix is an umbrella term for DSA ops, but there will be more naming predictability. (at least that's how I see it)

Quoted 4 lines

BTW, maybe we should merge the VITESSE FELIX ETHERNET SWITCH DRIVER and MICROSEMI ETHERNET SWITCH DRIVER entries in MAINTAINERS. You do much more work in drivers/net/ethernet/mscc/ than I currently do.

How would you see the merged MAINTAINERS entry? Something like this?

MICROSEMI ETHERNET SWITCH DRIVER

M:    Alexandre Belloni <[email protected]>
M:    Microchip Linux Driver Support <[email protected]>
M:    Vladimir Oltean <[email protected]>
M:    Claudiu Manoil <[email protected]>
L:    [email protected]
S:    Maintained
F:    include/soc/mscc/ocelot*
F:    drivers/net/ethernet/mscc/
F:    drivers/net/dsa/ocelot/*
F:    net/dsa/tag_ocelot.c

Any takers from Microchip, or is the internal mailing list enough?

Quoted 4 lines

--
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

#25 lore raw

Re: [PATCH net-next 11/11] net: dsa: ocelot: introduce driver for Seville VSC9953 switch

Quoted 15 lines · Vladimir Oltean
Quoted 13 lines · Alexandre Belloni
Quoted 10 lines · Vladimir Oltean
Quoted 4 lines

As ocelot can be used in a DSA configuration (even if it is not implemented yet), I don't think this would be correct. From my point of view, felix and seville are part of the ocelot family.

In this case, there would be a third driver in drivers/net/dsa/ocelot/ocelot_vsc7511.c which uses the intermediate felix_switch_ops from felix.c to access the ocelot core implementation. Unless you have better naming suggestions?

Quoted 7 lines
Quoted 3 lines

I don't. Maybe felix.c should have been ocelot.c from the beginning but honestly, it doesn't matter that much.

Technically Seville is not part of the Ocelot family but part of Serval, but then again, it's just a marketing name, so it doesn't really mean anything..

When I submitted ocelot, I was thinking we would have different drivers for jaguar, luton, ocelot, serval and serval-t. IIRC, ocelot is a subset of serval or at least, it is similar enough to share the same driver.

Quoted 7 lines

I am a bit reluctant to rename the DSA driver ops to "ocelot", since it would be even more confusing for everyone to have a function ocelot_dsa_set_ageing_time that calls ocelot_set_ageing_time. At least this way, there's going to be some learning curve figuring out that felix is an umbrella term for DSA ops, but there will be more naming predictability. (at least that's how I see it)

I'm fine with the current naming, I was certainly not suggesting to change it.

Quoted 11 lines
Quoted 4 lines

BTW, maybe we should merge the VITESSE FELIX ETHERNET SWITCH DRIVER and MICROSEMI ETHERNET SWITCH DRIVER entries in MAINTAINERS. You do much more work in drivers/net/ethernet/mscc/ than I currently do.

How would you see the merged MAINTAINERS entry? Something like this?

MICROSEMI ETHERNET SWITCH DRIVER

M:    Alexandre Belloni <[email protected]>
M:    Microchip Linux Driver Support <[email protected]>
M:    Vladimir Oltean <[email protected]>

You should probably be in the top position.

Quoted 3 lines
M:    Claudiu Manoil <[email protected]>
L:    [email protected]
S:    Maintained

I guess this could stay Supported unless you are not paid to work on that.

Quoted 6 lines
F:    include/soc/mscc/ocelot*
F:    drivers/net/ethernet/mscc/
F:    drivers/net/dsa/ocelot/*
F:    net/dsa/tag_ocelot.c

Any takers from Microchip, or is the internal mailing list enough?

It seems ok for now, we can always add/replace people later on.

Signature · 3 lines
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
maintainer
#26 lore raw
In reply to Vladimir Oltean
Quoted 5 lines · Vladimir Oltean

Looking at the Felix and Ocelot drivers, Maxim asked if it would be possible to use them as a base for a new driver for the switch inside NXP T1040. Turns out, it is! The result is a driver eerily similar to Felix.

Quoted 7 lines

The biggest challenge seems to be getting register read/write API generic enough to cover such wild bitfield variations between hardware generations. There is a patch on the regmap core which I would like to get in through the networking subsystem, if possible (and if Mark is ok), since it's a trivial addition.

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git for-next

Thanks!

[1/1] regmap: add helper for per-port regfield initialization

      commit: 8baebfc2aca26e3fa67ab28343671b82be42b22c

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

maintainer
#27 lore raw
Quoted 2 lines · Mark Brown

[1/1] regmap: add helper for per-port regfield initialization

      commit: 8baebfc2aca26e3fa67ab28343671b82be42b22c

Let me know if you need a pull request for this, I figured it was too late to deal with the cross tree issues for the merge window.

author maintainer
#28 lore raw

Hi Mark,

Quoted 8 lines · Mark Brown
Quoted 2 lines · Mark Brown

[1/1] regmap: add helper for per-port regfield initialization

      commit: 8baebfc2aca26e3fa67ab28343671b82be42b22c

Let me know if you need a pull request for this, I figured it was too late to deal with the cross tree issues for the merge window.

Thanks a lot for merging this. I plan to resend this series again (on the last mile!) during the weekend, with the feedback collected so far, so I'm not sure what is the best path to make sure Dave also has this patch in his tree so I don't break net-next.

-Vladimir

maintainer
#29 lore raw
Quoted 4 lines · Vladimir Oltean

Thanks a lot for merging this. I plan to resend this series again (on the last mile!) during the weekend, with the feedback collected so far, so I'm not sure what is the best path to make sure Dave also has this patch in his tree so I don't break net-next.

That was what the pull request would be for, though if you need to resend the chances are it'll be after the merge window before it gets applied in which case he'll get the patch through Linus' tree which makes things easier (that was part of the reason I just went ahead and applied).

author maintainer
#30 lore raw
Quoted 8 lines · Mark Brown
Quoted 4 lines · Vladimir Oltean

Thanks a lot for merging this. I plan to resend this series again (on the last mile!) during the weekend, with the feedback collected so far, so I'm not sure what is the best path to make sure Dave also has this patch in his tree so I don't break net-next.

Quoted 5 lines

That was what the pull request would be for, though if you need to resend the chances are it'll be after the merge window before it gets applied in which case he'll get the patch through Linus' tree which makes things easier (that was part of the reason I just went ahead and applied).

Yeah, well, I was hoping I could get this in for 5.8, since the changes requested so far aren't radical (and neither are the patches themselves). If it's too much of a hassle I can wait for the merge window to close, sure.

Thanks,
-Vladimir