DSA driver for Vitesse Felix switch
Subsystems (4)
Vladimir Oltean
maintainerv2 cover DSA driver for Vitesse Felix switch
This series builds upon the previous "Accomodate DSA front-end into Ocelot" topic and does the following:
- Reworks the Ocelot (VSC7514) driver to support one more switching core (VSC9959), used in NPI mode. Some code which was thought to be SoC-specific (ocelot_board.c) wasn't, and vice versa, so it is being accordingly moved.
- Exports ocelot driver structures and functions to include/soc/mscc.
- Adds a DSA ocelot front-end for VSC9959, which is a PCI device and uses the exported ocelot functionality for hardware configuration.
- Adds a tagger driver for the Vitesse injection/extraction DSA headers. This is known to be compatible with at least Ocelot and Felix.
Claudiu Manoil (2):
net: mscc: ocelot: move resource ioremap and regmap init to common
code
net: mscc: ocelot: filter out ocelot SoC specific PCS config from
common path
Vladimir Oltean (9):
net: mscc: ocelot: move invariant configs out of adjust_link
net: mscc: ocelot: create a helper for changing the port MTU
net: mscc: ocelot: export a constant for the tag length in bytes
net: mscc: ocelot: adjust MTU on the CPU port in NPI mode
net: mscc: ocelot: separate the implementation of switch reset
net: mscc: ocelot: publish structure definitions to
include/soc/mscc/ocelot.h
net: mscc: ocelot: publish ocelot_sys.h to include/soc/mscc
net: dsa: ocelot: add tagger for Ocelot/Felix switches
net: dsa: ocelot: add driver for Felix switch family
MAINTAINERS | 9 +
drivers/net/dsa/Kconfig | 2 +
drivers/net/dsa/Makefile | 1 +
drivers/net/dsa/ocelot/Kconfig | 11 +
drivers/net/dsa/ocelot/Makefile | 6 +
drivers/net/dsa/ocelot/felix.c | 441 ++++++++++++++
drivers/net/dsa/ocelot/felix.h | 37 ++
drivers/net/dsa/ocelot/felix_vsc9959.c | 567 ++++++++++++++++++
drivers/net/ethernet/mscc/ocelot.c | 209 ++++---
drivers/net/ethernet/mscc/ocelot.h | 479 +--------------
drivers/net/ethernet/mscc/ocelot_board.c | 85 ++-
drivers/net/ethernet/mscc/ocelot_io.c | 14 +-
drivers/net/ethernet/mscc/ocelot_regs.c | 3 +-
include/net/dsa.h | 2 +
include/soc/mscc/ocelot.h | 539 +++++++++++++++++
.../soc}/mscc/ocelot_sys.h | 0
net/dsa/Kconfig | 7 +
net/dsa/Makefile | 1 +
net/dsa/tag_ocelot.c | 229 +++++++
19 files changed, 2043 insertions(+), 599 deletions(-)
create mode 100644 drivers/net/dsa/ocelot/Kconfig
create mode 100644 drivers/net/dsa/ocelot/Makefile
create mode 100644 drivers/net/dsa/ocelot/felix.c
create mode 100644 drivers/net/dsa/ocelot/felix.h
create mode 100644 drivers/net/dsa/ocelot/felix_vsc9959.c
create mode 100644 include/soc/mscc/ocelot.h
rename {drivers/net/ethernet => include/soc}/mscc/ocelot_sys.h (100%)
create mode 100644 net/dsa/tag_ocelot.cSignature · 1 line
2.17.1
Vladimir Oltean
maintainerPATCH v2 1/11 net: mscc: ocelot: move resource ioremap and regmap init to common code
From: Claudiu Manoil <[email protected]>
Let's make this ioremap and regmap init code common. It should not be platform dependent as it should be usable by PCI devices too. Use better names where necessary to avoid clashes.
---
Changes in v2:
None.
drivers/net/ethernet/mscc/ocelot.h | 4 +--- drivers/net/ethernet/mscc/ocelot_board.c | 17 ++++++++++------- drivers/net/ethernet/mscc/ocelot_io.c | 14 +++++--------- 3 files changed, 16 insertions(+), 19 deletions(-)
drivers/net/ethernet/mscc/ocelot.h +1 -3
@@ -546,9 +546,7 @@ void ocelot_port_writel(struct ocelot_port *port, u32 val, u32 reg);int ocelot_regfields_init (struct ocelot *ocelot,const struct reg_field *const regfields); -struct regmap *ocelot_io_platform_init (struct ocelot *ocelot, -struct platform_device *pdev, -const char *name); +struct regmap *ocelot_regmap_init (struct ocelot *ocelot,struct resource *res);#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))
drivers/net/ethernet/mscc/ocelot_board.c +10 -7
@@ -268,7 +268,7 @@ static int mscc_ocelot_probe(struct platform_device *pdev)enum ocelot_target id;char *name; u8 optional:1; - } res[] = { + } io_target[] = { { SYS, "sys" }, { REW, "rew" }, { QSYS, "qsys" },
@@ -288,20 +288,23 @@ static int mscc_ocelot_probe(struct platform_device *pdev)platform_set_drvdata (pdev, ocelot); ocelot->dev = &pdev->dev; -for (i =0 ; i <ARRAY_SIZE (res); i++) { +for (i =0 ; i <ARRAY_SIZE (io_target); i++) {struct regmap *target; +struct resource *res; + + res =platform_get_resource_byname (pdev,IORESOURCE_MEM , + io_target[i].name); - target =ocelot_io_platform_init (ocelot, pdev, res[i].name); + target =ocelot_regmap_init (ocelot, res);if (IS_ERR (target)) { -if (res[i].optional) { - ocelot->targets[res[i].id] =NULL ; +if (io_target[i].optional) { + ocelot->targets[io_target[i].id] =NULL ;continue ; } -return PTR_ERR (target); } - ocelot->targets[res[i].id] = target; + ocelot->targets[io_target[i].id] = target; } hsio =syscon_regmap_lookup_by_compatible ("mscc,ocelot-hsio" );
drivers/net/ethernet/mscc/ocelot_io.c +5 -9
@@ -97,20 +97,16 @@ static struct regmap_config ocelot_regmap_config = { .reg_stride = 4, }; -struct regmap *ocelot_io_platform_init (struct ocelot *ocelot, -struct platform_device *pdev, -const char *name) +struct regmap *ocelot_regmap_init (struct ocelot *ocelot,struct resource *res) { -struct resource *res;void __iomem *regs; - res =platform_get_resource_byname (pdev,IORESOURCE_MEM , name); regs =devm_ioremap_resource (ocelot->dev, res);if (IS_ERR (regs))return ERR_CAST (regs); - ocelot_regmap_config.name = name; -return devm_regmap_init_mmio (ocelot->dev, regs, - &ocelot_regmap_config); + ocelot_regmap_config.name = res->name; + +return devm_regmap_init_mmio (ocelot->dev, regs, &ocelot_regmap_config); } -EXPORT_SYMBOL (ocelot_io_platform_init); +EXPORT_SYMBOL (ocelot_regmap_init);
Signature · 1 line
2.17.1
Vladimir Oltean
maintainerPATCH v2 2/11 net: mscc: ocelot: filter out ocelot SoC specific PCS config from common path
In reply to Vladimir OlteanFrom: Claudiu Manoil <[email protected]>
The adjust_link routine should be generic enough to be (re)used by any SoC that integrates a switch core compatible with the Ocelot core switch driver. Currently all configurations are generic except for the PCS settings that are SoC specific. Move these out to the Ocelot SoC/board instance.
---
Changes in v2:
Fixed an overzealous removal of EXPORT_SYMBOL(ocelot_chip_init) that caused a build error.
drivers/net/ethernet/mscc/ocelot.c | 19 ++-------------- drivers/net/ethernet/mscc/ocelot.h | 8 ++++++- drivers/net/ethernet/mscc/ocelot_board.c | 29 +++++++++++++++++++++++- drivers/net/ethernet/mscc/ocelot_regs.c | 3 ++- 4 files changed, 39 insertions(+), 20 deletions(-)
drivers/net/ethernet/mscc/ocelot.c +2 -17
@@ -455,23 +455,8 @@ static void ocelot_adjust_link(struct ocelot *ocelot, int port,ocelot_port_writel (ocelot_port,DEV_MAC_HDX_CFG_LATE_COL_POS (67 ),DEV_MAC_HDX_CFG ); -/* Disable HDX fast control */ -ocelot_port_writel (ocelot_port,DEV_PORT_MISC_HDX_FAST_DIS , -DEV_PORT_MISC ); - -/* SGMII only for now */ -ocelot_port_writel (ocelot_port,PCS1G_MODE_CFG_SGMII_MODE_ENA , -PCS1G_MODE_CFG ); -ocelot_port_writel (ocelot_port,PCS1G_SD_CFG_SD_SEL ,PCS1G_SD_CFG ); - -/* Enable PCS */ -ocelot_port_writel (ocelot_port,PCS1G_CFG_PCS_ENA ,PCS1G_CFG ); - -/* No aneg on SGMII */ -ocelot_port_writel (ocelot_port,0 ,PCS1G_ANEG_CFG ); - -/* No loopback */ -ocelot_port_writel (ocelot_port,0 ,PCS1G_LB_CFG ); +if (ocelot->ops->pcs_init) + ocelot->ops->pcs_init (ocelot, port);/* Set Max Length and maximum tags allowed */ ocelot_port_writel(ocelot_port, VLAN_ETH_FRAME_LEN,
drivers/net/ethernet/mscc/ocelot.h +7 -1
@@ -435,13 +435,19 @@ enum ocelot_tag_prefix { };struct ocelot_port ; +struct ocelot ;struct ocelot_stat_layout {u32 offset;char name[ETH_GSTRING_LEN ]; }; +struct ocelot_ops { +void (*pcs_init)(struct ocelot *ocelot,int port); +}; +struct ocelot { +const struct ocelot_ops *ops;struct device *dev;struct regmap *targets[TARGET_MAX ];
@@ -553,7 +559,7 @@ struct regmap *ocelot_regmap_init(struct ocelot *ocelot, struct resource *res);int ocelot_init (struct ocelot *ocelot);void ocelot_deinit (struct ocelot *ocelot); -int ocelot_chip_init (struct ocelot *ocelot); +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_board.c +28 -1
@@ -254,6 +254,33 @@ static const struct of_device_id mscc_ocelot_match[] = { };MODULE_DEVICE_TABLE (of, mscc_ocelot_match); +static void ocelot_port_pcs_init (struct ocelot *ocelot,int port) +{ +struct ocelot_port *ocelot_port = ocelot->ports[port]; + +/* Disable HDX fast control */ +ocelot_port_writel (ocelot_port,DEV_PORT_MISC_HDX_FAST_DIS , +DEV_PORT_MISC ); + +/* SGMII only for now */ +ocelot_port_writel (ocelot_port,PCS1G_MODE_CFG_SGMII_MODE_ENA , +PCS1G_MODE_CFG ); +ocelot_port_writel (ocelot_port,PCS1G_SD_CFG_SD_SEL ,PCS1G_SD_CFG ); + +/* Enable PCS */ +ocelot_port_writel (ocelot_port,PCS1G_CFG_PCS_ENA ,PCS1G_CFG ); + +/* No aneg on SGMII */ +ocelot_port_writel (ocelot_port,0 ,PCS1G_ANEG_CFG ); + +/* No loopback */ +ocelot_port_writel (ocelot_port,0 ,PCS1G_LB_CFG ); +} + +static const struct ocelot_ops ocelot_ops = { + .pcs_init = ocelot_port_pcs_init, +}; +static int mscc_ocelot_probe (struct platform_device *pdev) {struct device_node *np = pdev->dev.of_node;
@@ -315,7 +342,7 @@ static int mscc_ocelot_probe(struct platform_device *pdev) ocelot->targets[HSIO ] = hsio; - err =ocelot_chip_init (ocelot); + err =ocelot_chip_init (ocelot, &ocelot_ops);if (err)return err;
drivers/net/ethernet/mscc/ocelot_regs.c +2 -1
@@ -423,7 +423,7 @@ static void ocelot_pll5_init(struct ocelot *ocelot) HSIO_PLL5G_CFG2_AMPC_SEL(0x10)); } -int ocelot_chip_init (struct ocelot *ocelot) +int ocelot_chip_init (struct ocelot *ocelot,const struct ocelot_ops *ops) {int ret;
@@ -431,6 +431,7 @@ int ocelot_chip_init(struct ocelot *ocelot) ocelot->stats_layout = ocelot_stats_layout; ocelot->num_stats =ARRAY_SIZE (ocelot_stats_layout); ocelot->shared_queue_sz =224 *1024 ; + ocelot->ops = ops; ret =ocelot_regfields_init (ocelot, ocelot_regfields);if (ret)
Signature · 1 line
2.17.1
Vladimir Oltean
maintainerPATCH v2 4/11 net: mscc: ocelot: create a helper for changing the port MTU
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
Since in an NPI/DSA setup, not all ports will have the same MTU, we need to make sure the watermarks for pause frames and/or tail dropping logic that existed in the driver is still coherent for the new MTU values.
We need to do this because the NPI (aka external CPU) port needs an increased MTU for the DSA tag. This will be done in a future patch.
---
Changes in v2:
Added the "why" in the commit message.
drivers/net/ethernet/mscc/ocelot.c | 40 +++++++++++++++++------------- 1 file changed, 23 insertions(+), 17 deletions(-)
drivers/net/ethernet/mscc/ocelot.c +23 -17
@@ -2097,11 +2097,32 @@ static int ocelot_init_timestamp(struct ocelot *ocelot)return 0 ; } -static void ocelot_init_port (struct ocelot *ocelot,int port) +static void ocelot_port_set_mtu (struct ocelot *ocelot,int port,size_t mtu) {struct ocelot_port *ocelot_port = ocelot->ports[port];int atop_wm; +ocelot_port_writel (ocelot_port, mtu,DEV_MAC_MAXLEN_CFG ); + +/* Set Pause WM hysteresis +* 152 = 6 * mtu / OCELOT_BUFFER_CELL_SZ +* 101 = 4 * mtu / 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); + +/* Tail dropping watermark */ + atop_wm = (ocelot->shared_queue_sz -9 * mtu) /OCELOT_BUFFER_CELL_SZ ; +ocelot_write_rix (ocelot,ocelot_wm_enc (9 * mtu), +SYS_ATOP , port); +ocelot_write (ocelot,ocelot_wm_enc (atop_wm),SYS_ATOP_TOT_CFG ); +} + +static void ocelot_init_port (struct ocelot *ocelot,int port) +{ +struct ocelot_port *ocelot_port = ocelot->ports[port]; +INIT_LIST_HEAD (&ocelot_port->skbs);/* Basic L2 initialization */
@@ -2122,8 +2143,7 @@ static void ocelot_init_port(struct ocelot *ocelot, int port) DEV_MAC_HDX_CFG);/* Set Max Length and maximum tags allowed */ -ocelot_port_writel (ocelot_port,VLAN_ETH_FRAME_LEN , -DEV_MAC_MAXLEN_CFG ); +ocelot_port_set_mtu (ocelot, port,VLAN_ETH_FRAME_LEN ); ocelot_port_writel(ocelot_port, DEV_MAC_TAGS_CFG_TAG_ID(ETH_P_8021AD) | DEV_MAC_TAGS_CFG_VLAN_AWR_ENA | DEV_MAC_TAGS_CFG_VLAN_LEN_AWR_ENA,
@@ -2133,20 +2153,6 @@ static 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 ); -/* Set Pause WM hysteresis -* 152 = 6 * VLAN_ETH_FRAME_LEN / OCELOT_BUFFER_CELL_SZ -* 101 = 4 * VLAN_ETH_FRAME_LEN / 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); - -/* Tail dropping watermark */ - atop_wm = (ocelot->shared_queue_sz -9 *VLAN_ETH_FRAME_LEN ) /OCELOT_BUFFER_CELL_SZ ; -ocelot_write_rix (ocelot,ocelot_wm_enc (9 *VLAN_ETH_FRAME_LEN ), -SYS_ATOP , port); -ocelot_write (ocelot,ocelot_wm_enc (atop_wm),SYS_ATOP_TOT_CFG ); -/* 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.17.1
Vladimir Oltean
maintainerPATCH v2 3/11 net: mscc: ocelot: move invariant configs out of adjust_link
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
It doesn't make sense to rewrite all these registers every time the PHY library notifies us about a link state change.
In a future patch we will customize the MTU for the CPU port, and since the MTU was previously configured from adjust_link, if we don't make this change, its value would have got overridden.
---
Changes in v2:
None.
drivers/net/ethernet/mscc/ocelot.c | 85 +++++++++++++++--------------- 1 file changed, 43 insertions(+), 42 deletions(-)
drivers/net/ethernet/mscc/ocelot.c +43 -42
@@ -408,7 +408,7 @@ static void ocelot_adjust_link(struct ocelot *ocelot, int port, struct phy_device *phydev) {struct ocelot_port *ocelot_port = ocelot->ports[port]; -int speed, atop_wm, mode =0 ; +int speed, mode =0 ;switch (phydev->speed) {case SPEED_10 :
@@ -440,32 +440,9 @@ static void ocelot_adjust_link(struct ocelot *ocelot, int port,ocelot_port_writel (ocelot_port,DEV_MAC_MODE_CFG_FDX_ENA | mode,DEV_MAC_MODE_CFG ); -/* Set MAC IFG Gaps -* FDX: TX_IFG = 5, RX_IFG1 = RX_IFG2 = 0 -* !FDX: TX_IFG = 5, RX_IFG1 = RX_IFG2 = 5 -*/ -ocelot_port_writel (ocelot_port,DEV_MAC_IFG_CFG_TX_IFG (5 ), -DEV_MAC_IFG_CFG ); - -/* Load seed (0) and set MAC HDX late collision */ -ocelot_port_writel (ocelot_port,DEV_MAC_HDX_CFG_LATE_COL_POS (67 ) | -DEV_MAC_HDX_CFG_SEED_LOAD , -DEV_MAC_HDX_CFG ); -mdelay (1 ); -ocelot_port_writel (ocelot_port,DEV_MAC_HDX_CFG_LATE_COL_POS (67 ), -DEV_MAC_HDX_CFG ); -if (ocelot->ops->pcs_init) ocelot->ops->pcs_init (ocelot, port); -/* Set Max Length and maximum tags allowed */ -ocelot_port_writel (ocelot_port,VLAN_ETH_FRAME_LEN , -DEV_MAC_MAXLEN_CFG ); -ocelot_port_writel (ocelot_port,DEV_MAC_TAGS_CFG_TAG_ID (ETH_P_8021AD ) | -DEV_MAC_TAGS_CFG_VLAN_AWR_ENA | -DEV_MAC_TAGS_CFG_VLAN_LEN_AWR_ENA , -DEV_MAC_TAGS_CFG ); -/* Enable MAC module */ ocelot_port_writel (ocelot_port,DEV_MAC_ENA_CFG_RX_ENA |DEV_MAC_ENA_CFG_TX_ENA ,DEV_MAC_ENA_CFG );
@@ -475,22 +452,10 @@ static void ocelot_adjust_link(struct ocelot *ocelot, int port,ocelot_port_writel (ocelot_port,DEV_CLOCK_CFG_LINK_SPEED (speed),DEV_CLOCK_CFG ); -/* Set SMAC of Pause frame (00:00:00:00:00:00) */ -ocelot_port_writel (ocelot_port,0 ,DEV_MAC_FC_MAC_HIGH_CFG ); -ocelot_port_writel (ocelot_port,0 ,DEV_MAC_FC_MAC_LOW_CFG ); -/* No PFC */ ocelot_write_gix (ocelot,ANA_PFC_PFC_CFG_FC_LINK_SPEED (speed),ANA_PFC_PFC_CFG , port); -/* Set Pause WM hysteresis -* 152 = 6 * VLAN_ETH_FRAME_LEN / OCELOT_BUFFER_CELL_SZ -* 101 = 4 * VLAN_ETH_FRAME_LEN / 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); -/* 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) |
@@ -505,12 +470,6 @@ static void ocelot_adjust_link(struct ocelot *ocelot, int port,SYS_MAC_FC_CFG_FC_LINK_SPEED (speed), SYS_MAC_FC_CFG, port);ocelot_write_rix (ocelot,0 ,ANA_POL_FLOWC , port); - -/* Tail dropping watermark */ - atop_wm = (ocelot->shared_queue_sz -9 *VLAN_ETH_FRAME_LEN ) /OCELOT_BUFFER_CELL_SZ ; -ocelot_write_rix (ocelot,ocelot_wm_enc (9 *VLAN_ETH_FRAME_LEN ), -SYS_ATOP , port); -ocelot_write (ocelot,ocelot_wm_enc (atop_wm),SYS_ATOP_TOT_CFG ); }static void ocelot_port_adjust_link (struct net_device *dev)
@@ -2141,11 +2100,53 @@ static int ocelot_init_timestamp(struct ocelot *ocelot)static void ocelot_init_port (struct ocelot *ocelot,int port) {struct ocelot_port *ocelot_port = ocelot->ports[port]; +int atop_wm;INIT_LIST_HEAD (&ocelot_port->skbs);/* Basic L2 initialization */ +/* Set MAC IFG Gaps +* FDX: TX_IFG = 5, RX_IFG1 = RX_IFG2 = 0 +* !FDX: TX_IFG = 5, RX_IFG1 = RX_IFG2 = 5 +*/ +ocelot_port_writel (ocelot_port,DEV_MAC_IFG_CFG_TX_IFG (5 ), +DEV_MAC_IFG_CFG ); + +/* Load seed (0) and set MAC HDX late collision */ +ocelot_port_writel (ocelot_port,DEV_MAC_HDX_CFG_LATE_COL_POS (67 ) | +DEV_MAC_HDX_CFG_SEED_LOAD , +DEV_MAC_HDX_CFG ); +mdelay (1 ); +ocelot_port_writel (ocelot_port,DEV_MAC_HDX_CFG_LATE_COL_POS (67 ), +DEV_MAC_HDX_CFG ); + +/* Set Max Length and maximum tags allowed */ +ocelot_port_writel (ocelot_port,VLAN_ETH_FRAME_LEN , +DEV_MAC_MAXLEN_CFG ); +ocelot_port_writel (ocelot_port,DEV_MAC_TAGS_CFG_TAG_ID (ETH_P_8021AD ) | +DEV_MAC_TAGS_CFG_VLAN_AWR_ENA | +DEV_MAC_TAGS_CFG_VLAN_LEN_AWR_ENA , +DEV_MAC_TAGS_CFG ); + +/* Set SMAC of Pause frame (00:00:00:00:00:00) */ +ocelot_port_writel (ocelot_port,0 ,DEV_MAC_FC_MAC_HIGH_CFG ); +ocelot_port_writel (ocelot_port,0 ,DEV_MAC_FC_MAC_LOW_CFG ); + +/* Set Pause WM hysteresis +* 152 = 6 * VLAN_ETH_FRAME_LEN / OCELOT_BUFFER_CELL_SZ +* 101 = 4 * VLAN_ETH_FRAME_LEN / 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); + +/* Tail dropping watermark */ + atop_wm = (ocelot->shared_queue_sz -9 *VLAN_ETH_FRAME_LEN ) /OCELOT_BUFFER_CELL_SZ ; +ocelot_write_rix (ocelot,ocelot_wm_enc (9 *VLAN_ETH_FRAME_LEN ), +SYS_ATOP , port); +ocelot_write (ocelot,ocelot_wm_enc (atop_wm),SYS_ATOP_TOT_CFG ); +/* 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.17.1
Vladimir Oltean
maintainerPATCH v2 5/11 net: mscc: ocelot: export a constant for the tag length in bytes
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
This constant will be used in a future patch to increase the MTU on NPI ports, and will also be used in the tagger driver for Felix.
---
Changes in v2:
None.
drivers/net/ethernet/mscc/ocelot.c | 4 ++-- drivers/net/ethernet/mscc/ocelot.h | 4 ++-- drivers/net/ethernet/mscc/ocelot_board.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-)
drivers/net/ethernet/mscc/ocelot.c +2 -2
@@ -576,11 +576,11 @@ static int ocelot_port_xmit(struct sk_buff *skb, struct net_device *dev)struct skb_shared_info *shinfo =skb_shinfo (skb);struct ocelot_port *ocelot_port = &priv->port;struct ocelot *ocelot = ocelot_port->ocelot; +u32 val, ifh[OCELOT_TAG_LEN /4 ];struct frame_info info = {};u8 grp =0 ;/* Send everything on CPU group 0 */ unsigned int i, count, last;int port = priv->chip_port; -u32 val, ifh[IFH_LEN ]; val =ocelot_read (ocelot,QS_INJ_STATUS ); if (!(val & QS_INJ_STATUS_FIFO_RDY(BIT(grp))) ||
@@ -603,7 +603,7 @@ static int ocelot_port_xmit(struct sk_buff *skb, struct net_device *dev)ocelot_gen_ifh (ifh, &info); -for (i =0 ; i <IFH_LEN ; i++) +for (i =0 ; i <OCELOT_TAG_LEN /4 ; i++)ocelot_write_rix (ocelot, (__force u32 )cpu_to_be32 (ifh[i]),QS_INJ_WR , grp);
drivers/net/ethernet/mscc/ocelot.h +2 -2
@@ -43,8 +43,6 @@#define OCELOT_PTP_QUEUE_SZ 128 -#define IFH_LEN 4 -struct frame_info {u32 len;u16 port;
@@ -66,6 +64,8 @@ struct frame_info {#define IFH_REW_OP_TWO_STEP_PTP 0x3#define IFH_REW_OP_ORIGIN_PTP 0x5 +#define OCELOT_TAG_LEN 16 +#define OCELOT_SPEED_2500 0#define OCELOT_SPEED_1000 1#define OCELOT_SPEED_100 2
drivers/net/ethernet/mscc/ocelot_board.c +1 -1
@@ -105,7 +105,7 @@ static irqreturn_t ocelot_xtr_irq_handler(int irq, void *arg)int sz, len, buf_len;struct sk_buff *skb; -for (i =0 ; i <IFH_LEN ; i++) { +for (i =0 ; i <OCELOT_TAG_LEN /4 ; i++) { err =ocelot_rx_frame_word (ocelot, grp, true, &ifh[i]);if (err !=4 )break ;
Signature · 1 line
2.17.1
Vladimir Oltean
maintainerPATCH v2 7/11 net: mscc: ocelot: separate the implementation of switch reset
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
The Felix switch has a different reset procedure, so a function pointer needs to be created and added to the ocelot_ops structure.
The reset procedure has been moved into ocelot_init.
---
Changes in v2:
- Added error checking for ocelot->ops->reset(ocelot).
- Moved the call at the beginning of ocelot_init, to not overwrite the action of calls to ocelot_mact_init, ocelot_vlan_init and ocelot_ace_init.
drivers/net/ethernet/mscc/ocelot.c | 8 +++++ drivers/net/ethernet/mscc/ocelot.h | 1 + drivers/net/ethernet/mscc/ocelot_board.c | 37 +++++++++++++++--------- 3 files changed, 33 insertions(+), 13 deletions(-)
drivers/net/ethernet/mscc/ocelot.c +8 -0
@@ -2269,6 +2269,14 @@ int ocelot_init(struct ocelot *ocelot)int i, ret;u32 port; +if (ocelot->ops->reset) { + ret = ocelot->ops->reset (ocelot); +if (ret) { +dev_err (ocelot->dev,"Switch reset failed\n" ); +return ret; + } + } + ocelot->lags =devm_kcalloc (ocelot->dev, ocelot->num_phys_ports,sizeof (u32),GFP_KERNEL );if (!ocelot->lags)
drivers/net/ethernet/mscc/ocelot.h +1 -0
@@ -446,6 +446,7 @@ struct ocelot_stat_layout {struct ocelot_ops {void (*pcs_init)(struct ocelot *ocelot,int port); +int (*reset)(struct ocelot *ocelot); };struct ocelot {
drivers/net/ethernet/mscc/ocelot_board.c +24 -13
@@ -277,8 +277,32 @@ static void ocelot_port_pcs_init(struct ocelot *ocelot, int port)ocelot_port_writel (ocelot_port,0 ,PCS1G_LB_CFG ); } +static int ocelot_reset (struct ocelot *ocelot) +{ +int retries =100 ; +u32 val; + +regmap_field_write (ocelot->regfields[SYS_RESET_CFG_MEM_INIT ],1 ); +regmap_field_write (ocelot->regfields[SYS_RESET_CFG_MEM_ENA ],1 ); + +do { +msleep (1 ); +regmap_field_read (ocelot->regfields[SYS_RESET_CFG_MEM_INIT ], + &val); + }while (val && --retries); + +if (!retries) +return -ETIMEDOUT ; + +regmap_field_write (ocelot->regfields[SYS_RESET_CFG_MEM_ENA ],1 ); +regmap_field_write (ocelot->regfields[SYS_RESET_CFG_CORE_ENA ],1 ); + +return 0 ; +} +static const struct ocelot_ops ocelot_ops = { .pcs_init = ocelot_port_pcs_init, + .reset = ocelot_reset, };static int mscc_ocelot_probe (struct platform_device *pdev)
@@ -289,7 +313,6 @@ static int mscc_ocelot_probe(struct platform_device *pdev)struct ocelot *ocelot;struct regmap *hsio;unsigned int i; -u32 val;struct {enum ocelot_target id;
@@ -369,18 +392,6 @@ static int mscc_ocelot_probe(struct platform_device *pdev) ocelot->ptp =1 ; } -regmap_field_write (ocelot->regfields[SYS_RESET_CFG_MEM_INIT ],1 ); -regmap_field_write (ocelot->regfields[SYS_RESET_CFG_MEM_ENA ],1 ); - -do { -msleep (1 ); -regmap_field_read (ocelot->regfields[SYS_RESET_CFG_MEM_INIT ], - &val); - }while (val); - -regmap_field_write (ocelot->regfields[SYS_RESET_CFG_MEM_ENA ],1 ); -regmap_field_write (ocelot->regfields[SYS_RESET_CFG_CORE_ENA ],1 ); - ocelot->num_cpu_ports =1 ;/* 1 port on the switch, two groups */ ports =of_get_child_by_name (np,"ethernet-ports" );
Signature · 1 line
2.17.1
Vladimir Oltean
maintainerPATCH v2 9/11 net: mscc: ocelot: publish ocelot_sys.h to include/soc/mscc
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
The Felix DSA driver needs to write to SYS_RAM_INIT_RAM_INIT for its own chip initialization process.
Also update the MAINTAINERS file such that the headers exported by the ocelot driver are under the same maintainers' umbrella as the driver itself.
---
Changes in v2:
Updated the MAINTAINERS file, and noted this fact in the commit message.
MAINTAINERS | 1 +
drivers/net/ethernet/mscc/ocelot.h | 2 +-
{drivers/net/ethernet => include/soc}/mscc/ocelot_sys.h | 0
3 files changed, 2 insertions(+), 1 deletion(-)
rename {drivers/net/ethernet => include/soc}/mscc/ocelot_sys.h (100%)MAINTAINERS +1 -0
@@ -10834,6 +10834,7 @@ M: Microchip Linux Driver Support <[email protected]> L: [email protected] S: Supported F: drivers/net/ethernet/mscc/ +F: include/soc/mscc/ocelot* MICROSOFT SURFACE PRO 3 BUTTON DRIVER M: Chen Yu <[email protected]>
drivers/net/ethernet/mscc/ocelot.h +1 -1
@@ -18,12 +18,12 @@#include <linux/ptp_clock_kernel.h> #include <linux/regmap.h> +#include <soc/mscc/ocelot_sys.h> #include <soc/mscc/ocelot.h> #include "ocelot_ana.h" #include "ocelot_dev.h" #include "ocelot_qsys.h" #include "ocelot_rew.h" -#include "ocelot_sys.h" #include "ocelot_qs.h" #include "ocelot_tc.h" #include "ocelot_ptp.h"
include/soc/mscc/ocelot_sys.h renamed from drivers/net/ethernet/mscc/ocelot_sys.h +0 -0
Signature · 1 line
2.17.1
Vladimir Oltean
maintainerPATCH v2 8/11 net: mscc: ocelot: publish structure definitions to include/soc/mscc/ocelot.h
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
We will be registering another switch driver based on ocelot, which lives under drivers/net/dsa.
Make sure the Felix DSA front-end has the necessary abstractions to implement a new Ocelot driver instantiation. This includes the function prototypes for implementing DSA callbacks.
---
Changes in v2:
- Fixed an overzealous removal of EXPORT_SYMBOL(ocelot_probe_port) which was causing a build failure.
- Removed stubs for the case where MSCC_OCELOT_SWITCH is not enabled.
drivers/net/ethernet/mscc/ocelot.c | 78 +++-- drivers/net/ethernet/mscc/ocelot.h | 482 +------------------------- include/soc/mscc/ocelot.h | 539 +++++++++++++++++++++++++++++ 3 files changed, 588 insertions(+), 511 deletions(-) create mode 100644 include/soc/mscc/ocelot.h
drivers/net/ethernet/mscc/ocelot.c +46 -32
@@ -21,7 +21,6 @@#include <net/netevent.h> #include <net/rtnetlink.h> #include <net/switchdev.h> -#include <net/dsa.h> #include "ocelot.h" #include "ocelot_ace.h"
@@ -184,8 +183,8 @@ static void ocelot_vlan_mode(struct ocelot *ocelot, int port,ocelot_write (ocelot, val,ANA_VLANMASK ); } -static void ocelot_port_vlan_filtering (struct ocelot *ocelot,int port, -bool vlan_aware) +void ocelot_port_vlan_filtering (struct ocelot *ocelot,int port, +bool vlan_aware) {struct ocelot_port *ocelot_port = ocelot->ports[port];u32 val;
@@ -230,6 +229,7 @@ static void ocelot_port_vlan_filtering(struct ocelot *ocelot, int port,REW_TAG_CFG_TAG_CFG_M , REW_TAG_CFG, port); } +EXPORT_SYMBOL (ocelot_port_vlan_filtering);static int ocelot_port_set_native_vlan (struct ocelot *ocelot,int port,u16 vid)
@@ -267,8 +267,8 @@ static void ocelot_port_set_pvid(struct ocelot *ocelot, int port, u16 pvid) ocelot_port->pvid = pvid; } -static int ocelot_vlan_add (struct ocelot *ocelot,int port,u16 vid,bool pvid, -bool untagged) +int ocelot_vlan_add (struct ocelot *ocelot,int port,u16 vid,bool pvid, +bool untagged) {int ret;
@@ -291,6 +291,7 @@ static int ocelot_vlan_add(struct ocelot *ocelot, int port, u16 vid, bool pvid,return 0 ; } +EXPORT_SYMBOL (ocelot_vlan_add);static int ocelot_vlan_vid_add (struct net_device *dev,u16 vid,bool pvid,bool untagged)
@@ -312,7 +313,7 @@ static int ocelot_vlan_vid_add(struct net_device *dev, u16 vid, bool pvid,return 0 ; } -static int ocelot_vlan_del (struct ocelot *ocelot,int port,u16 vid) +int ocelot_vlan_del (struct ocelot *ocelot,int port,u16 vid) {struct ocelot_port *ocelot_port = ocelot->ports[port];int ret;
@@ -333,6 +334,7 @@ static int ocelot_vlan_del(struct ocelot *ocelot, int port, u16 vid)return 0 ; } +EXPORT_SYMBOL (ocelot_vlan_del);static int ocelot_vlan_vid_del (struct net_device *dev,u16 vid) {
@@ -404,8 +406,8 @@ static u16 ocelot_wm_enc(u16 value)return value; } -static void ocelot_adjust_link (struct ocelot *ocelot,int port, -struct phy_device *phydev) +void ocelot_adjust_link (struct ocelot *ocelot,int port, +struct phy_device *phydev) {struct ocelot_port *ocelot_port = ocelot->ports[port];int speed, mode =0 ;
@@ -471,6 +473,7 @@ static void ocelot_adjust_link(struct ocelot *ocelot, int port, SYS_MAC_FC_CFG, port);ocelot_write_rix (ocelot,0 ,ANA_POL_FLOWC , port); } +EXPORT_SYMBOL (ocelot_adjust_link);static void ocelot_port_adjust_link (struct net_device *dev) {
@@ -481,8 +484,8 @@ static void ocelot_port_adjust_link(struct net_device *dev)ocelot_adjust_link (ocelot, port, dev->phydev); } -static void ocelot_port_enable (struct ocelot *ocelot,int port, -struct phy_device *phy) +void ocelot_port_enable (struct ocelot *ocelot,int port, +struct phy_device *phy) {/* Enable receiving frames on the port, and activate auto-learning of * MAC addresses.
@@ -492,6 +495,7 @@ static void ocelot_port_enable(struct ocelot *ocelot, int port,ANA_PORT_PORT_CFG_PORTID_VAL (port), ANA_PORT_PORT_CFG, port); } +EXPORT_SYMBOL (ocelot_port_enable);static int ocelot_port_open (struct net_device *dev) {
@@ -526,7 +530,7 @@ static int ocelot_port_open(struct net_device *dev)return 0 ; } -static void ocelot_port_disable (struct ocelot *ocelot,int port) +void ocelot_port_disable (struct ocelot *ocelot,int port) {struct ocelot_port *ocelot_port = ocelot->ports[port];
@@ -534,6 +538,7 @@ static void ocelot_port_disable(struct ocelot *ocelot, int port)ocelot_rmw_rix (ocelot,0 ,QSYS_SWITCH_PORT_MODE_PORT_ENA ,QSYS_SWITCH_PORT_MODE , port); } +EXPORT_SYMBOL (ocelot_port_disable);static int ocelot_port_stop (struct net_device *dev) {
@@ -790,9 +795,8 @@ static void ocelot_get_stats64(struct net_device *dev, stats->collisions =ocelot_read (ocelot,SYS_COUNT_TX_COLLISION ); } -static int ocelot_fdb_add (struct ocelot *ocelot,int port, -const unsigned char *addr,u16 vid, -bool vlan_aware) +int ocelot_fdb_add (struct ocelot *ocelot,int port, +const unsigned char *addr,u16 vid,bool vlan_aware) {struct ocelot_port *ocelot_port = ocelot->ports[port];
@@ -812,6 +816,7 @@ static int ocelot_fdb_add(struct ocelot *ocelot, int port,return ocelot_mact_learn (ocelot, port, addr, vid,ENTRYTYPE_LOCKED ); } +EXPORT_SYMBOL (ocelot_fdb_add); static int ocelot_port_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], struct net_device *dev,
@@ -826,11 +831,12 @@ static int ocelot_port_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],return ocelot_fdb_add (ocelot, port, addr, vid, priv->vlan_aware); } -static int ocelot_fdb_del (struct ocelot *ocelot,int port, -const unsigned char *addr,u16 vid) +int ocelot_fdb_del (struct ocelot *ocelot,int port, +const unsigned char *addr,u16 vid) {return ocelot_mact_forget (ocelot, addr, vid); } +EXPORT_SYMBOL (ocelot_fdb_del); static int ocelot_port_fdb_del(struct ndmsg *ndm, struct nlattr *tb[], struct net_device *dev,
@@ -940,8 +946,8 @@ static int ocelot_mact_read(struct ocelot *ocelot, int port, int row, int col,return 0 ; } -static int ocelot_fdb_dump (struct ocelot *ocelot,int port, -dsa_fdb_dump_cb_t *cb,void *data) +int ocelot_fdb_dump (struct ocelot *ocelot,int port, +dsa_fdb_dump_cb_t *cb,void *data) {int i, j;
@@ -973,6 +979,7 @@ static int ocelot_fdb_dump(struct ocelot *ocelot, int port,return 0 ; } +EXPORT_SYMBOL (ocelot_fdb_dump); static int ocelot_port_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb,
@@ -1153,8 +1160,7 @@ static const struct net_device_ops ocelot_port_netdev_ops = { .ndo_do_ioctl = ocelot_ioctl, }; -static void ocelot_get_strings (struct ocelot *ocelot,int port,u32 sset, -u8 *data) +void ocelot_get_strings (struct ocelot *ocelot,int port,u32 sset,u8 *data) {int i;
@@ -1165,6 +1171,7 @@ static void ocelot_get_strings(struct ocelot *ocelot, int port, u32 sset,memcpy (data + i *ETH_GSTRING_LEN , ocelot->stats_layout[i].name,ETH_GSTRING_LEN ); } +EXPORT_SYMBOL (ocelot_get_strings);static void ocelot_port_get_strings (struct net_device *netdev,u32 sset,u8 *data)
@@ -1216,7 +1223,7 @@ static void ocelot_check_stats_work(struct work_struct *work) OCELOT_STATS_CHECK_DELAY); } -static void ocelot_get_ethtool_stats (struct ocelot *ocelot,int port,u64 *data) +void ocelot_get_ethtool_stats (struct ocelot *ocelot,int port,u64 *data) {int i;
@@ -1227,6 +1234,7 @@ static void ocelot_get_ethtool_stats(struct ocelot *ocelot, int port, u64 *data)for (i =0 ; i < ocelot->num_stats; i++) *data++ = ocelot->stats[port * ocelot->num_stats + i]; } +EXPORT_SYMBOL (ocelot_get_ethtool_stats); static void ocelot_port_get_ethtool_stats(struct net_device *dev, struct ethtool_stats *stats,
@@ -1239,13 +1247,14 @@ static void ocelot_port_get_ethtool_stats(struct net_device *dev,ocelot_get_ethtool_stats (ocelot, port, data); } -static int ocelot_get_sset_count (struct ocelot *ocelot,int port,int sset) +int ocelot_get_sset_count (struct ocelot *ocelot,int port,int sset) {if (sset !=ETH_SS_STATS )return -EOPNOTSUPP ;return ocelot->num_stats; } +EXPORT_SYMBOL (ocelot_get_sset_count);static int ocelot_port_get_sset_count (struct net_device *dev,int sset) {
@@ -1256,8 +1265,8 @@ static int ocelot_port_get_sset_count(struct net_device *dev, int sset)return ocelot_get_sset_count (ocelot, port, sset); } -static int ocelot_get_ts_info (struct ocelot *ocelot,int port, -struct ethtool_ts_info *info) +int ocelot_get_ts_info (struct ocelot *ocelot,int port, +struct ethtool_ts_info *info) { info->phc_index = ocelot->ptp_clock ?ptp_clock_index (ocelot->ptp_clock) :-1 ;
@@ -1273,6 +1282,7 @@ static int ocelot_get_ts_info(struct ocelot *ocelot, int port,return 0 ; } +EXPORT_SYMBOL (ocelot_get_ts_info);static int ocelot_port_get_ts_info (struct net_device *dev,struct ethtool_ts_info *info)
@@ -1296,8 +1306,7 @@ static const struct ethtool_ops ocelot_ethtool_ops = { .get_ts_info = ocelot_port_get_ts_info, }; -static void ocelot_bridge_stp_state_set (struct ocelot *ocelot,int port, -u8 state) +void ocelot_bridge_stp_state_set (struct ocelot *ocelot,int port,u8 state) {u32 port_cfg;int p, i;
@@ -1358,6 +1367,7 @@ static void ocelot_bridge_stp_state_set(struct ocelot *ocelot, int port, } } } +EXPORT_SYMBOL (ocelot_bridge_stp_state_set); static void ocelot_port_attr_stp_state_set(struct ocelot *ocelot, int port, struct switchdev_trans *trans,
@@ -1369,11 +1379,12 @@ static void ocelot_port_attr_stp_state_set(struct ocelot *ocelot, int port,ocelot_bridge_stp_state_set (ocelot, port, state); } -static void ocelot_set_ageing_time (struct ocelot *ocelot,unsigned int msecs) +void ocelot_set_ageing_time (struct ocelot *ocelot,unsigned int msecs) {ocelot_write (ocelot,ANA_AUTOAGE_AGE_PERIOD (msecs /2 ),ANA_AUTOAGE ); } +EXPORT_SYMBOL (ocelot_set_ageing_time);static void ocelot_port_attr_ageing_set (struct ocelot *ocelot,int port,unsigned long ageing_clock_t)
@@ -1604,8 +1615,8 @@ static int ocelot_port_obj_del(struct net_device *dev,return ret; } -static int ocelot_port_bridge_join (struct ocelot *ocelot,int port, -struct net_device *bridge) +int ocelot_port_bridge_join (struct ocelot *ocelot,int port, +struct net_device *bridge) {if (!ocelot->bridge_mask) { ocelot->hw_bridge_dev = bridge;
@@ -1620,9 +1631,10 @@ static int ocelot_port_bridge_join(struct ocelot *ocelot, int port,return 0 ; } +EXPORT_SYMBOL (ocelot_port_bridge_join); -static int ocelot_port_bridge_leave (struct ocelot *ocelot,int port, -struct net_device *bridge) +int ocelot_port_bridge_leave (struct ocelot *ocelot,int port, +struct net_device *bridge) { ocelot->bridge_mask &= ~BIT (port);
@@ -1633,6 +1645,7 @@ static int ocelot_port_bridge_leave(struct ocelot *ocelot, int port,ocelot_port_set_pvid (ocelot, port,0 );return ocelot_port_set_native_vlan (ocelot, port,0 ); } +EXPORT_SYMBOL (ocelot_port_bridge_leave);static void ocelot_set_aggr_pgids (struct ocelot *ocelot) {
@@ -2119,7 +2132,7 @@ static void ocelot_port_set_mtu(struct ocelot *ocelot, int port, size_t mtu)ocelot_write (ocelot,ocelot_wm_enc (atop_wm),SYS_ATOP_TOT_CFG ); } -static void ocelot_init_port (struct ocelot *ocelot,int port) +void ocelot_init_port (struct ocelot *ocelot,int port) {struct ocelot_port *ocelot_port = ocelot->ports[port];
@@ -2166,6 +2179,7 @@ static void ocelot_init_port(struct ocelot *ocelot, int port)/* Enable vcap lookups */ ocelot_vcap_enable (ocelot, port); } +EXPORT_SYMBOL (ocelot_init_port); int ocelot_probe_port(struct ocelot *ocelot, u8 port, void __iomem *regs,
drivers/net/ethernet/mscc/ocelot.h +3 -479
517 lines not on this page · raw message
include/soc/mscc/ocelot.h new file +539 -0
539 lines not on this page · raw message
Signature · 1 line
2.17.1
Vladimir Oltean
maintainerPATCH v2 10/11 net: dsa: ocelot: add tagger for Ocelot/Felix switches
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
While it is entirely possible that this tagger format is in fact more generic than just these 2 switch families, I don't have that knowledge. The Seville switch in NXP T1040 has a similar frame format, but there are enough differences (e.g. DEST field starts at bit 57 instead of 56) that calling this file tag_vitesse.c is a bit of a stretch at the moment. The frame format has been listed in a comment so that people who add support for further Vitesse switches can rework this tagger while keeping compatibility with Felix.
The "ocelot" name was chosen instead of "felix" because even the Ocelot switch can act as a DSA device when it is used in NPI mode, and the Felix tagger format is almost identical. Currently it is only used for the Felix switch embedded in the NXP LS1028A chip.
The ABI for this tagger should be considered "not stable" at the moment. The DSA tag is always placed before the Ethernet header and therefore, we are using the long prefix for RX tags to avoid putting the DSA master port in promiscuous mode. Once there will be an API in DSA for drivers to request DSA masters to be in promiscuous mode unconditionally, we will switch to the "no prefix" extraction frame header, which will save 16 padding bytes for each RX frame.
---
Changes in v2:
Reordered this patch so it predates the introduction of the Felix driver which uses it.
MAINTAINERS | 7 ++ include/net/dsa.h | 2 + net/dsa/Kconfig | 7 ++ net/dsa/Makefile | 1 + net/dsa/tag_ocelot.c | 229 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 246 insertions(+) create mode 100644 net/dsa/tag_ocelot.c
MAINTAINERS +7 -0
@@ -17360,6 +17360,13 @@ S: Maintained F: drivers/input/serio/userio.c F: include/uapi/linux/userio.h +VITESSE FELIX ETHERNET SWITCH DRIVER +M: Vladimir Oltean <[email protected]> +M: Claudiu Manoil <[email protected]> +L: [email protected] +S: Maintained +F: net/dsa/tag_ocelot.c + VIVID VIRTUAL VIDEO DRIVER M: Hans Verkuil <[email protected]> L: [email protected]
include/net/dsa.h +2 -0
@@ -42,6 +42,7 @@ struct phylink_link_state;#define DSA_TAG_PROTO_8021Q_VALUE 12#define DSA_TAG_PROTO_SJA1105_VALUE 13#define DSA_TAG_PROTO_KSZ8795_VALUE 14 +#define DSA_TAG_PROTO_OCELOT_VALUE 15enum dsa_tag_protocol {DSA_TAG_PROTO_NONE =DSA_TAG_PROTO_NONE_VALUE ,
@@ -59,6 +60,7 @@ enum dsa_tag_protocol {DSA_TAG_PROTO_8021Q =DSA_TAG_PROTO_8021Q_VALUE ,DSA_TAG_PROTO_SJA1105 =DSA_TAG_PROTO_SJA1105_VALUE ,DSA_TAG_PROTO_KSZ8795 =DSA_TAG_PROTO_KSZ8795_VALUE , + DSA_TAG_PROTO_OCELOT = DSA_TAG_PROTO_OCELOT_VALUE, };struct packet_type ;
net/dsa/Kconfig +7 -0
@@ -79,6 +79,13 @@ config NET_DSA_TAG_KSZ Say Y if you want to enable support for tagging frames for the Microchip 8795/9477/9893 families of switches. +config NET_DSA_TAG_OCELOT + tristate "Tag driver for Ocelot family of switches" + select PACKING + help + Say Y or M if you want to enable support for tagging frames for the + Ocelot switches (VSC7511, VSC7512, VSC7513, VSC7514, VSC9959). + config NET_DSA_TAG_QCA tristate "Tag driver for Qualcomm Atheros QCA8K switches" help
net/dsa/Makefile +1 -0
@@ -12,6 +12,7 @@ obj-$(CONFIG_NET_DSA_TAG_GSWIP) += tag_gswip.o obj-$(CONFIG_NET_DSA_TAG_KSZ) += tag_ksz.o obj-$(CONFIG_NET_DSA_TAG_LAN9303) += tag_lan9303.o obj-$(CONFIG_NET_DSA_TAG_MTK) += tag_mtk.o +obj-$(CONFIG_NET_DSA_TAG_OCELOT) += tag_ocelot.o obj-$(CONFIG_NET_DSA_TAG_QCA) += tag_qca.o obj-$(CONFIG_NET_DSA_TAG_SJA1105) += tag_sja1105.o obj-$(CONFIG_NET_DSA_TAG_TRAILER) += tag_trailer.o
net/dsa/tag_ocelot.c new file +229 -0
229 lines not on this page · raw message
Signature · 1 line
2.17.1
Vladimir Oltean
maintainerPATCH v2 6/11 net: mscc: ocelot: adjust MTU on the CPU port in NPI mode
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
When using the NPI port, the DSA tag is passed through Ethernet, so the switch's MAC needs to accept it as it comes from the DSA master. Increase the MTU on the external CPU port to account for the length of the injection header.
Without this patch, MTU-sized frames are dropped by the switch's CPU port on xmit, which is especially obvious in TCP sessions.
---
Changes in v2:
None.
drivers/net/ethernet/mscc/ocelot.c | 9 +++++++++ drivers/net/ethernet/mscc/ocelot.h | 2 ++ 2 files changed, 11 insertions(+)
drivers/net/ethernet/mscc/ocelot.c +9 -0
@@ -2230,9 +2230,18 @@ void ocelot_set_cpu_port(struct ocelot *ocelot, int cpu,* Only one port can be an NPI at the same time. */ if (cpu < ocelot->num_phys_ports) { +int mtu =VLAN_ETH_FRAME_LEN +OCELOT_TAG_LEN ; +ocelot_write (ocelot,QSYS_EXT_CPU_CFG_EXT_CPUQ_MSK_M |QSYS_EXT_CPU_CFG_EXT_CPU_PORT (cpu),QSYS_EXT_CPU_CFG ); + +if (injection ==OCELOT_TAG_PREFIX_SHORT ) + mtu +=OCELOT_SHORT_PREFIX_LEN ; +else if (injection ==OCELOT_TAG_PREFIX_LONG ) + mtu +=OCELOT_LONG_PREFIX_LEN ; + +ocelot_port_set_mtu (ocelot, cpu, mtu); }/* CPU port Injection/Extraction configuration */
drivers/net/ethernet/mscc/ocelot.h +2 -0
@@ -65,6 +65,8 @@ struct frame_info {#define IFH_REW_OP_ORIGIN_PTP 0x5#define OCELOT_TAG_LEN 16 +#define OCELOT_SHORT_PREFIX_LEN 4 +#define OCELOT_LONG_PREFIX_LEN 16#define OCELOT_SPEED_2500 0#define OCELOT_SPEED_1000 1
Signature · 1 line
2.17.1
Vladimir Oltean
maintainerPATCH v2 11/11 net: dsa: ocelot: add driver for Felix switch family
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
This supports an Ethernet switching core from Vitesse / Microsemi / Microchip (VSC9959) which is part of the Ocelot family (a brand name), and whose code name is Felix. The switch can be (and is) integrated on different SoCs as a PCIe endpoint device.
The functionality is provided by the core of the Ocelot switch driver (drivers/net/ethernet/mscc). In this regard, the current driver is an instance of Microsemi's Ocelot core driver, with a DSA front-end. It inherits its name from VSC9959's code name, to distinguish itself from the switchdev ocelot driver.
The patch adds the logic for probing a PCI device and defines the register map for the VSC9959 switch core, since it has some differences in register addresses and bitfield mappings compared to the other Ocelot switches (VSC7511, VSC7512, VSC7513, VSC7514).
The Felix driver declares the register map as part of the "instance table". Currently the VSC9959 inside NXP LS1028A is the only instance, but presumably it can support other switches in the Ocelot family, when used in DSA mode (Linux running on the external CPU, and not on the embedded MIPS).
In a few cases, some h/w operations have to be done differently on VSC9959 due to missing bitfields. This is the case for the switch core reset and init. Because for this operation Ocelot uses some bits that are not present on Felix, the latter has to use a register from the global registers block (GCB) instead.
Although it is a PCI driver, it relies on DT bindings for compatibility with DSA (CPU port link, PHY library). It does not have any custom device tree bindings, since we would like to minimize its dependency on device tree though.
---
Changes in v2:
- Dropped the "vitesse" folder (and the movement of the vsc73xx driver) due to popular demand
- Put the driver in an "ocelot" folder, to appease further people who may want to add a driver for VSC7511. There is enough flexibility that such driver might be added either in felix, or in parallel to it, without moving too many things around.
- Reordered/renamed the Kconfig options to appear as alphabetically sorted in menuconfig.
- Replaced the "felix_ls1028a" string with "vsc9959".
- Added "regfields" element to struct felix_info.
- Renamed felix-regs.c to felix_vsc9959.c
- Moved felix_init_structs from felix_vsc9959.c to felix.c
- Reworded commit message
MAINTAINERS | 1 + drivers/net/dsa/Kconfig | 2 + drivers/net/dsa/Makefile | 1 + drivers/net/dsa/ocelot/Kconfig | 11 + drivers/net/dsa/ocelot/Makefile | 6 + drivers/net/dsa/ocelot/felix.c | 441 +++++++++++++++++++ drivers/net/dsa/ocelot/felix.h | 37 ++ drivers/net/dsa/ocelot/felix_vsc9959.c | 567 +++++++++++++++++++++++++ 8 files changed, 1066 insertions(+) create mode 100644 drivers/net/dsa/ocelot/Kconfig create mode 100644 drivers/net/dsa/ocelot/Makefile create mode 100644 drivers/net/dsa/ocelot/felix.c create mode 100644 drivers/net/dsa/ocelot/felix.h create mode 100644 drivers/net/dsa/ocelot/felix_vsc9959.c
MAINTAINERS +1 -0
@@ -17365,6 +17365,7 @@ M: Vladimir Oltean <[email protected]> M: Claudiu Manoil <[email protected]> L: [email protected] S: Maintained +F: drivers/net/dsa/ocelot/* F: net/dsa/tag_ocelot.c VIVID VIRTUAL VIDEO DRIVER
drivers/net/dsa/Kconfig +2 -0
@@ -52,6 +52,8 @@ source "drivers/net/dsa/microchip/Kconfig" source "drivers/net/dsa/mv88e6xxx/Kconfig" +source "drivers/net/dsa/ocelot/Kconfig" + source "drivers/net/dsa/sja1105/Kconfig" config NET_DSA_QCA8K
drivers/net/dsa/Makefile +1 -0
@@ -20,4 +20,5 @@ obj-$(CONFIG_NET_DSA_VITESSE_VSC73XX_SPI) += vitesse-vsc73xx-spi.o obj-y += b53/ obj-y += microchip/ obj-y += mv88e6xxx/ +obj-y += ocelot/ obj-y += sja1105/
drivers/net/dsa/ocelot/Kconfig new file +11 -0
@@ -0,0 +1,11 @@ +# SPDX-License-Identifier: GPL-2.0-only +config NET_DSA_MSCC_FELIX + tristate "Ocelot / Felix Ethernet switch support" + depends on NET_DSA && PCI + select MSCC_OCELOT_SWITCH + select NET_DSA_TAG_OCELOT + help + This driver supports the VSC9959 network switch, which is a member of + the Vitesse / Microsemi / Microchip Ocelot family of switching cores. + It is embedded as a PCIe function of the NXP LS1028A ENETC integrated + endpoint.
drivers/net/dsa/ocelot/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0-only +obj-$(CONFIG_NET_DSA_MSCC_FELIX) += mscc_felix.o + +mscc_felix-objs := \ + felix.o \ + felix_vsc9959.o
drivers/net/dsa/ocelot/felix.c new file +441 -0
441 lines not on this page · raw message
drivers/net/dsa/ocelot/felix.h new file +37 -0
@@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright 2019 NXP Semiconductors +*/ +#ifndef _MSCC_FELIX_H +#define _MSCC_FELIX_H + +#define ocelot_to_felix (o) container_of((o), struct felix, ocelot) + +/* Platform-specific information */ +struct felix_info { +struct resource *target_io_res; +struct resource *port_io_res; +const struct reg_field *regfields; +const u32 *const *map; +const struct ocelot_ops *ops; +int shared_queue_sz; +const struct ocelot_stat_layout *stats_layout; +unsigned int num_stats; +int num_ports; +int pci_bar; +}; + +extern struct felix_info felix_info_vsc9959; + +enum felix_instance { +FELIX_INSTANCE_VSC9959 =0 , +}; + +/* DSA glue / front-end for struct ocelot */ +struct felix { +struct dsa_switch *ds; +struct pci_dev *pdev; +struct felix_info *info; +struct ocelot ocelot; +}; + +#endif
drivers/net/dsa/ocelot/felix_vsc9959.c new file +567 -0
567 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [PATCH v2 net-next 09/11] net: mscc: ocelot: publish ocelot_sys.h to include/soc/mscc
In reply to Vladimir OlteanQuoted 10 lines · Vladimir Oltean
From: Vladimir Oltean <[email protected]>
The Felix DSA driver needs to write to
SYS_RAM_INIT_RAM_INITfor its own chip initialization process.Also update the
MAINTAINERSfile such that the headers exported by the ocelot driver are under the same maintainers' umbrella as the driver itself.Signed-off-by Vladimir Oltean <[email protected]>
Signature · 1 line
Florian
David Miller
maintainerFrom: Vladimir Oltean <[email protected]>
Date: Thu, 14 Nov 2019 17:03:19 +0200
Quoted 12 lines
This series builds upon the previous "Accomodate DSA front-end into Ocelot" topic and does the following:
- Reworks the Ocelot (VSC7514) driver to support one more switching core (VSC9959), used in NPI mode. Some code which was thought to be SoC-specific (
ocelot_board.c) wasn't, and vice versa, so it is being accordingly moved.
- Exports ocelot driver structures and functions toinclude/soc/mscc.
- Adds a DSA ocelot front-end for VSC9959, which is a PCI device and uses the exported ocelot functionality for hardware configuration.
- Adds a tagger driver for the Vitesse injection/extraction DSA headers. This is known to be compatible with at least Ocelot and Felix.
Series applied, thank you.
Vladimir Oltean
maintainerQuoted 17 lines · David Miller
From: Vladimir Oltean <[email protected]>
Date: Thu, 14 Nov 2019 17:03:19 +0200Quoted 12 lines
This series builds upon the previous "Accomodate DSA front-end into Ocelot" topic and does the following:
- Reworks the Ocelot (VSC7514) driver to support one more switching core (VSC9959), used in NPI mode. Some code which was thought to be SoC-specific (
ocelot_board.c) wasn't, and vice versa, so it is being accordingly moved.
- Exports ocelot driver structures and functions toinclude/soc/mscc.
- Adds a DSA ocelot front-end for VSC9959, which is a PCI device and uses the exported ocelot functionality for hardware configuration.
- Adds a tagger driver for the Vitesse injection/extraction DSA headers. This is known to be compatible with at least Ocelot and Felix.
Quoted 1 line
Series applied, thank you.
Thank you!
-Vladimir