Modernize mv88e6060 and remove legacy probe
Subsystems (5)
Andrew Lunn
maintainercover Modernize mv88e6060 and remove legacy probe
The mv88e6060 is the last device using the legacy method of probing an DSA Ethernet switch. This patchset applies some cleanups to the driver, and then adds support for probing the device as an MDIO bus device. The legacy probe is then removed from the driver, and then from DSA as a whole.
This is compile tested only. Comment and testing welcome.
It should not be merged yet, and one of the patches should go via arm-soc.
Andrew Lunn (10):
net: dsa: mv88e6xxx: Remove legacy probe support
net: dsa: mv88e6060: Replace ds with priv
net: dsa: mv88e6060: Replace REG_WRITE macro
net: dsa: mv88e6060: Replace REG_READ macro
net: dsa: mv88e6060: Support probing as an mdio device
net: dsa: mv88e6060: Remove support for legacy probing
net: dsa: mv88e6060: Add SPDX header
net: dsa: Remove legacy probing support
arch: arm: dts: Remove disabled marvell,dsa properties
bt-bindings: net: DSA: Remove legacy binding
.../devicetree/bindings/net/dsa/dsa.txt | 155 ---- arch/arm/boot/dts/armada-370-rd.dts | 42 - arch/arm/boot/dts/armada-388-clearfog.dts | 58 -- arch/arm/boot/dts/armada-xp-linksys-mamba.dts | 47 -- arch/arm/boot/dts/kirkwood-dir665.dts | 47 -- arch/arm/boot/dts/kirkwood-linksys-viper.dts | 47 -- .../arm/boot/dts/kirkwood-mv88f6281gtw-ge.dts | 47 -- arch/arm/boot/dts/kirkwood-rd88f6281.dtsi | 41 - drivers/net/dsa/Kconfig | 2 +- drivers/net/dsa/mv88e6060.c | 217 ++--- drivers/net/dsa/mv88e6060.h | 1 + drivers/net/dsa/mv88e6xxx/chip.c | 71 +- include/net/dsa.h | 23 - net/dsa/Kconfig | 9 - net/dsa/Makefile | 1 - net/dsa/dsa.c | 5 - net/dsa/dsa_priv.h | 12 - net/dsa/legacy.c | 745 ------------------ 18 files changed, 121 insertions(+), 1449 deletions(-)
Signature · 1 line
2.20.1
Andrew Lunn
maintainerRFC PATCH 1/10 net: dsa: mv88e6xxx: Remove legacy probe support
Remove the legacy method of probing the mv88e6xxx driver, now that all the mainline boards have been converted to use mdio based probing for a number of cycles.
--- drivers/net/dsa/mv88e6xxx/chip.c | 71 +------------------------------- 1 file changed, 1 insertion(+), 70 deletions(-)
drivers/net/dsa/mv88e6xxx/chip.c +1 -70
@@ -4587,56 +4587,6 @@ static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,return chip->info->tag_protocol; } -#if IS_ENABLED (CONFIG_NET_DSA_LEGACY ) -static const char *mv88e6xxx_drv_probe (struct device *dsa_dev, -struct device *host_dev,int sw_addr, -void **priv) -{ -struct mv88e6xxx_chip *chip; -struct mii_bus *bus; -int err; - - bus =dsa_host_dev_to_mii_bus (host_dev); -if (!bus) -return NULL ; - - chip =mv88e6xxx_alloc_chip (dsa_dev); -if (!chip) -return NULL ; - -/* Legacy SMI probing will only support chips similar to 88E6085 */ - chip->info = &mv88e6xxx_table[MV88E6085 ]; - - err =mv88e6xxx_smi_init (chip, bus, sw_addr); -if (err) - goto free; - - err =mv88e6xxx_detect (chip); -if (err) - goto free; - -mutex_lock (&chip->reg_lock); - err =mv88e6xxx_switch_reset (chip); -mutex_unlock (&chip->reg_lock); -if (err) - goto free; - -mv88e6xxx_phy_init (chip); - - err =mv88e6xxx_mdios_register (chip,NULL ); -if (err) - goto free; - - *priv = chip; - -return chip->info->name; -free: -devm_kfree (dsa_dev, chip); - -return NULL ; -} -#endif -static int mv88e6xxx_port_mdb_prepare (struct dsa_switch *ds,int port,const struct switchdev_obj_port_mdb *mdb) {
@@ -4675,9 +4625,6 @@ static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port, }static const struct dsa_switch_ops mv88e6xxx_switch_ops = { -#if IS_ENABLED(CONFIG_NET_DSA_LEGACY) - .probe = mv88e6xxx_drv_probe, -#endif .get_tag_protocol = mv88e6xxx_get_tag_protocol, .setup = mv88e6xxx_setup, .adjust_link = mv88e6xxx_adjust_link,
@@ -4722,10 +4669,6 @@ static const struct dsa_switch_ops mv88e6xxx_switch_ops = { .get_ts_info = mv88e6xxx_get_ts_info, }; -static struct dsa_switch_driver mv88e6xxx_switch_drv = { - .ops = &mv88e6xxx_switch_ops, -}; -static int mv88e6xxx_register_switch (struct mv88e6xxx_chip *chip) {struct device *dev = chip->dev;
@@ -4951,19 +4894,7 @@ static struct mdio_driver mv88e6xxx_driver = { }, }; -static int __init mv88e6xxx_init (void ) -{ -register_switch_driver (&mv88e6xxx_switch_drv); -return mdio_driver_register (&mv88e6xxx_driver); -} -module_init (mv88e6xxx_init); - -static void __exit mv88e6xxx_cleanup(void) -{ -mdio_driver_unregister (&mv88e6xxx_driver); -unregister_switch_driver (&mv88e6xxx_switch_drv); -} -module_exit (mv88e6xxx_cleanup); +mdio_module_driver (mv88e6xxx_driver);MODULE_AUTHOR ("Lennert Buytenhek <[email protected]>" );MODULE_DESCRIPTION ("Driver for Marvell 88E6XXX ethernet switch chips" );
Signature · 1 line
2.20.1
Andrew Lunn
maintainerRFC PATCH 2/10 net: dsa: mv88e6060: Replace ds with priv
In reply to Andrew LunnPass around priv, not ds. This will help with changing to an mdio driver, and makes this driver more like mv88e6xxx.
--- drivers/net/dsa/mv88e6060.c | 43 +++++++++++++++++++------------------ drivers/net/dsa/mv88e6060.h | 1 + 2 files changed, 23 insertions(+), 21 deletions(-)
drivers/net/dsa/mv88e6060.c +22 -21
@@ -18,10 +18,8 @@#include <net/dsa.h> #include "mv88e6060.h" -static int reg_read (struct dsa_switch *ds,int addr,int reg) +static int reg_read (struct mv88e6060_priv *priv,int addr,int reg) { -struct mv88e6060_priv *priv = ds->priv; -return mdiobus_read_nested (priv->bus, priv->sw_addr + addr, reg); }
@@ -29,17 +27,15 @@ static int reg_read(struct dsa_switch *ds, int addr, int reg) ({ \int __ret; \ \ - __ret =reg_read (ds, addr, reg); \ + __ret =reg_read (priv, addr, reg); \if (__ret <0 ) \return __ret; \ __ret; \ }) -static int reg_write (struct dsa_switch *ds,int addr,int reg,u16 val) +static int reg_write (struct mv88e6060_priv *priv,int addr,int reg,u16 val) { -struct mv88e6060_priv *priv = ds->priv; -return mdiobus_write_nested (priv->bus, priv->sw_addr + addr, reg, val); }
@@ -47,7 +43,7 @@ static int reg_write(struct dsa_switch *ds, int addr, int reg, u16 val) ({ \int __ret; \ \ - __ret =reg_write (ds, addr, reg, val); \ + __ret =reg_write (priv, addr, reg, val); \if (__ret <0 ) \return __ret; \ })
@@ -97,7 +93,7 @@ static const char *mv88e6060_drv_probe(struct device *dsa_dev,return name; } -static int mv88e6060_switch_reset (struct dsa_switch *ds) +static int mv88e6060_switch_reset (struct mv88e6060_priv *priv) {int i;int ret;
@@ -133,7 +129,7 @@ static int mv88e6060_switch_reset(struct dsa_switch *ds)return 0 ; } -static int mv88e6060_setup_global (struct dsa_switch *ds) +static int mv88e6060_setup_global (struct mv88e6060_priv *priv) {/* Disable discarding of frames with excessive collisions, * set the maximum frame size to 1536 bytes, and mask all
@@ -149,7 +145,7 @@ static int mv88e6060_setup_global(struct dsa_switch *ds)return 0 ; } -static int mv88e6060_setup_port (struct dsa_switch *ds,int p) +static int mv88e6060_setup_port (struct mv88e6060_priv *priv,int p) {int addr =REG_PORT (p);
@@ -159,7 +155,7 @@ static int mv88e6060_setup_port(struct dsa_switch *ds, int p)* port, enable Ingress and Egress Trailer tagging mode. */ REG_WRITE(addr, PORT_CONTROL, - dsa_is_cpu_port(ds, p) ? + dsa_is_cpu_port(priv->ds, p) ? PORT_CONTROL_TRAILER | PORT_CONTROL_INGRESS_MODE | PORT_CONTROL_STATE_FORWARDING :
@@ -172,8 +168,8 @@ static int mv88e6060_setup_port(struct dsa_switch *ds, int p)*/ REG_WRITE (addr,PORT_VLAN_MAP , ((p &0xf ) <<PORT_VLAN_MAP_DBNUM_SHIFT ) | - (dsa_is_cpu_port (ds, p) ?dsa_user_ports (ds) : -BIT (dsa_to_port (ds, p)->cpu_dp->index))); + (dsa_is_cpu_port (priv->ds, p) ?dsa_user_ports (priv->ds) : +BIT (dsa_to_port (priv->ds, p)->cpu_dp->index)));/* Port Association Vector: when learning source addresses * of packets, add the address to the address database using
@@ -185,7 +181,7 @@ static int mv88e6060_setup_port(struct dsa_switch *ds, int p)return 0 ; } -static int mv88e6060_setup_addr (struct dsa_switch *ds) +static int mv88e6060_setup_addr (struct mv88e6060_priv *priv) {u8 addr[ETH_ALEN ];u16 val;
@@ -208,25 +204,28 @@ static int mv88e6060_setup_addr(struct dsa_switch *ds)static int mv88e6060_setup (struct dsa_switch *ds) { +struct mv88e6060_priv *priv = ds->priv;int ret;int i; - ret =mv88e6060_switch_reset (ds); + priv->ds = ds; + + ret =mv88e6060_switch_reset (priv);if (ret <0 )return ret;/* @@@ initialise atu */ - ret =mv88e6060_setup_global (ds); + ret =mv88e6060_setup_global (priv);if (ret <0 )return ret; - ret =mv88e6060_setup_addr (ds); + ret =mv88e6060_setup_addr (priv);if (ret <0 )return ret;for (i =0 ; i <MV88E6060_PORTS ; i++) { - ret =mv88e6060_setup_port (ds, i); + ret =mv88e6060_setup_port (priv, i);if (ret <0 )return ret; }
@@ -243,25 +242,27 @@ static int mv88e6060_port_to_phy_addr(int port)static int mv88e6060_phy_read (struct dsa_switch *ds,int port,int regnum) { +struct mv88e6060_priv *priv = ds->priv;int addr; addr =mv88e6060_port_to_phy_addr (port);if (addr ==-1 )return 0xffff ; -return reg_read (ds, addr, regnum); +return reg_read (priv, addr, regnum); }static int mv88e6060_phy_write (struct dsa_switch *ds,int port,int regnum,u16 val) { +struct mv88e6060_priv *priv = ds->priv;int addr; addr =mv88e6060_port_to_phy_addr (port);if (addr ==-1 )return 0xffff ; -return reg_write (ds, addr, regnum, val); +return reg_write (priv, addr, regnum, val); }static const struct dsa_switch_ops mv88e6060_switch_ops = {
drivers/net/dsa/mv88e6060.h +1 -0
@@ -117,6 +117,7 @@ struct mv88e6060_priv {*/ struct mii_bus *bus;int sw_addr; + struct dsa_switch *ds; };#endif
Signature · 1 line
2.20.1
Andrew Lunn
maintainerRFC PATCH 3/10 net: dsa: mv88e6060: Replace REG_WRITE macro
In reply to Andrew LunnThe REG_WRITE macro contains a return statement, making it not very safe. Remove it by inlining the code.
--- drivers/net/dsa/mv88e6060.c | 73 +++++++++++++++++++++---------------- 1 file changed, 41 insertions(+), 32 deletions(-)
drivers/net/dsa/mv88e6060.c +41 -32
@@ -39,15 +39,6 @@ static int reg_write(struct mv88e6060_priv *priv, int addr, int reg, u16 val)return mdiobus_write_nested (priv->bus, priv->sw_addr + addr, reg, val); } -#define REG_WRITE (addr, reg, val) \ - ({ \ - int __ret; \ - \ - __ret = reg_write(priv, addr, reg, val); \ - if (__ret < 0) \ - return __ret; \ - }) -static const char *mv88e6060_get_name (struct mii_bus *bus,int sw_addr) {int ret;
@@ -102,17 +93,21 @@ static int mv88e6060_switch_reset(struct mv88e6060_priv *priv)/* Set all ports to the disabled state. */ for (i =0 ; i <MV88E6060_PORTS ; i++) { ret =REG_READ (REG_PORT (i),PORT_CONTROL ); -REG_WRITE (REG_PORT (i),PORT_CONTROL , - ret & ~PORT_CONTROL_STATE_MASK ); + ret =reg_write (priv,REG_PORT (i),PORT_CONTROL , + ret & ~PORT_CONTROL_STATE_MASK ); +if (ret) +return ret; }/* Wait for transmit queues to drain. */ usleep_range (2000 ,4000 );/* Reset the switch. */ -REG_WRITE (REG_GLOBAL ,GLOBAL_ATU_CONTROL , -GLOBAL_ATU_CONTROL_SWRESET | -GLOBAL_ATU_CONTROL_LEARNDIS ); + ret =reg_write (priv,REG_GLOBAL ,GLOBAL_ATU_CONTROL , +GLOBAL_ATU_CONTROL_SWRESET | +GLOBAL_ATU_CONTROL_LEARNDIS ); +if (ret) +return ret;/* Wait up to one second for reset to complete. */ timeout = jiffies +1 *HZ ;
@@ -131,59 +126,67 @@ static int mv88e6060_switch_reset(struct mv88e6060_priv *priv)static int mv88e6060_setup_global (struct mv88e6060_priv *priv) { +int ret; +/* Disable discarding of frames with excessive collisions, * set the maximum frame size to 1536 bytes, and mask all * interrupt sources. */ -REG_WRITE (REG_GLOBAL ,GLOBAL_CONTROL ,GLOBAL_CONTROL_MAX_FRAME_1536 ); + ret =reg_write (priv,REG_GLOBAL ,GLOBAL_CONTROL , +GLOBAL_CONTROL_MAX_FRAME_1536 ); +if (ret) +return ret;/* Disable automatic address learning. */ -REG_WRITE (REG_GLOBAL ,GLOBAL_ATU_CONTROL , -GLOBAL_ATU_CONTROL_LEARNDIS ); - -return 0 ; +return reg_write (priv,REG_GLOBAL ,GLOBAL_ATU_CONTROL , +GLOBAL_ATU_CONTROL_LEARNDIS ); }static int mv88e6060_setup_port (struct mv88e6060_priv *priv,int p) {int addr =REG_PORT (p); +int ret;/* Do not force flow control, disable Ingress and Egress * Header tagging, disable VLAN tunneling, and set the port * state to Forwarding. Additionally, if this is the CPU * port, enable Ingress and Egress Trailer tagging mode. */ -REG_WRITE (addr,PORT_CONTROL , -dsa_is_cpu_port (priv->ds, p) ? + ret =reg_write (priv, addr,PORT_CONTROL , +dsa_is_cpu_port (priv->ds, p) ?PORT_CONTROL_TRAILER |PORT_CONTROL_INGRESS_MODE |PORT_CONTROL_STATE_FORWARDING :PORT_CONTROL_STATE_FORWARDING ); +if (ret) +return ret;/* Port based VLAN map: give each port its own address * database, allow the CPU port to talk to each of the 'real' * ports, and allow each of the 'real' ports to only talk to * the CPU port. */ -REG_WRITE (addr,PORT_VLAN_MAP , - ((p &0xf ) <<PORT_VLAN_MAP_DBNUM_SHIFT ) | - (dsa_is_cpu_port (priv->ds, p) ?dsa_user_ports (priv->ds) : -BIT (dsa_to_port (priv->ds, p)->cpu_dp->index))); + ret =reg_write (priv, addr,PORT_VLAN_MAP , + ((p &0xf ) <<PORT_VLAN_MAP_DBNUM_SHIFT ) | + (dsa_is_cpu_port (priv->ds, p) ? +dsa_user_ports (priv->ds) : +BIT (dsa_to_port (priv->ds, p)->cpu_dp->index))); +if (ret) +return ret;/* Port Association Vector: when learning source addresses * of packets, add the address to the address database using * a port bitmap that has only the bit for this port set and * the other bits clear. */ -REG_WRITE (addr,PORT_ASSOC_VECTOR ,BIT (p)); - -return 0 ; +return reg_write (priv, addr,PORT_ASSOC_VECTOR ,BIT (p)); }static int mv88e6060_setup_addr (struct mv88e6060_priv *priv) {u8 addr[ETH_ALEN ]; +int ret;u16 val;eth_random_addr (addr);
@@ -195,11 +198,17 @@ static int mv88e6060_setup_addr(struct mv88e6060_priv *priv)*/ val &=0xfeff ; -REG_WRITE (REG_GLOBAL ,GLOBAL_MAC_01 , val); -REG_WRITE (REG_GLOBAL ,GLOBAL_MAC_23 , (addr[2 ] <<8 ) | addr[3 ]); -REG_WRITE (REG_GLOBAL ,GLOBAL_MAC_45 , (addr[4 ] <<8 ) | addr[5 ]); + ret =reg_write (priv,REG_GLOBAL ,GLOBAL_MAC_01 , val); +if (ret) +return ret; + + ret =reg_write (priv,REG_GLOBAL ,GLOBAL_MAC_23 , + (addr[2 ] <<8 ) | addr[3 ]); +if (ret) +return ret; -return 0 ; +return reg_write (priv,REG_GLOBAL ,GLOBAL_MAC_45 , + (addr[4 ] <<8 ) | addr[5 ]); }static int mv88e6060_setup (struct dsa_switch *ds)
Signature · 1 line
2.20.1
Re: [PATCH RFC RFT net-next 03/10] net: dsa: mv88e6060: Replace REG_WRITE macro
Quoted 2 lines · Andrew Lunn
The
REG_WRITEmacro contains a return statement, making it not very safe. Remove it by inlining the code.
Not bad, but maybe there should be dev_err() or something in case of reg_write() returns an error?
Because no errors are expected in this case... AFAICT.
Pavel
Quoted 156 lines
Signed-off-by Andrew Lunn <[email protected]>--- drivers/net/dsa/mv88e6060.c | 73 +++++++++++++++++++++---------------- 1 file changed, 41 insertions(+), 32 deletions(-)drivers/net/dsa/mv88e6060.c +41
-32@@ -39,15 +39,6 @@ static int reg_write(struct mv88e6060_priv *priv, int addr, int reg, u16 val)return mdiobus_write_nested (priv->bus, priv->sw_addr + addr, reg, val); } -#define REG_WRITE (addr, reg, val) \ - ({ \ - int __ret; \ - \ - __ret = reg_write(priv, addr, reg, val); \ - if (__ret < 0) \ - return __ret; \ - }) -static const char *mv88e6060_get_name (struct mii_bus *bus,int sw_addr) {int ret;@@ -102,17 +93,21 @@ static int mv88e6060_switch_reset(struct mv88e6060_priv *priv)/* Set all ports to the disabled state. */ for (i =0 ; i <MV88E6060_PORTS ; i++) { ret =REG_READ (REG_PORT (i),PORT_CONTROL ); -REG_WRITE (REG_PORT (i),PORT_CONTROL , - ret & ~PORT_CONTROL_STATE_MASK ); + ret =reg_write (priv,REG_PORT (i),PORT_CONTROL , + ret & ~PORT_CONTROL_STATE_MASK ); +if (ret) +return ret; }/* Wait for transmit queues to drain. */ usleep_range (2000 ,4000 );/* Reset the switch. */ -REG_WRITE (REG_GLOBAL ,GLOBAL_ATU_CONTROL , -GLOBAL_ATU_CONTROL_SWRESET | -GLOBAL_ATU_CONTROL_LEARNDIS ); + ret =reg_write (priv,REG_GLOBAL ,GLOBAL_ATU_CONTROL , +GLOBAL_ATU_CONTROL_SWRESET | +GLOBAL_ATU_CONTROL_LEARNDIS ); +if (ret) +return ret;/* Wait up to one second for reset to complete. */ timeout = jiffies +1 *HZ ;@@ -131,59 +126,67 @@ static int mv88e6060_switch_reset(struct mv88e6060_priv *priv)static int mv88e6060_setup_global (struct mv88e6060_priv *priv) { +int ret; +/* Disable discarding of frames with excessive collisions, * set the maximum frame size to 1536 bytes, and mask all * interrupt sources. */ -REG_WRITE (REG_GLOBAL ,GLOBAL_CONTROL ,GLOBAL_CONTROL_MAX_FRAME_1536 ); + ret =reg_write (priv,REG_GLOBAL ,GLOBAL_CONTROL , +GLOBAL_CONTROL_MAX_FRAME_1536 ); +if (ret) +return ret;/* Disable automatic address learning. */ -REG_WRITE (REG_GLOBAL ,GLOBAL_ATU_CONTROL , -GLOBAL_ATU_CONTROL_LEARNDIS ); - -return 0 ; +return reg_write (priv,REG_GLOBAL ,GLOBAL_ATU_CONTROL , +GLOBAL_ATU_CONTROL_LEARNDIS ); }static int mv88e6060_setup_port (struct mv88e6060_priv *priv,int p) {int addr =REG_PORT (p); +int ret;/* Do not force flow control, disable Ingress and Egress * Header tagging, disable VLAN tunneling, and set the port * state to Forwarding. Additionally, if this is the CPU * port, enable Ingress and Egress Trailer tagging mode. */ -REG_WRITE (addr,PORT_CONTROL , -dsa_is_cpu_port (priv->ds, p) ? + ret =reg_write (priv, addr,PORT_CONTROL , +dsa_is_cpu_port (priv->ds, p) ?PORT_CONTROL_TRAILER |PORT_CONTROL_INGRESS_MODE |PORT_CONTROL_STATE_FORWARDING :PORT_CONTROL_STATE_FORWARDING ); +if (ret) +return ret;/* Port based VLAN map: give each port its own address * database, allow the CPU port to talk to each of the 'real' * ports, and allow each of the 'real' ports to only talk to * the CPU port. */ -REG_WRITE (addr,PORT_VLAN_MAP , - ((p &0xf ) <<PORT_VLAN_MAP_DBNUM_SHIFT ) | - (dsa_is_cpu_port (priv->ds, p) ?dsa_user_ports (priv->ds) : -BIT (dsa_to_port (priv->ds, p)->cpu_dp->index))); + ret =reg_write (priv, addr,PORT_VLAN_MAP , + ((p &0xf ) <<PORT_VLAN_MAP_DBNUM_SHIFT ) | + (dsa_is_cpu_port (priv->ds, p) ? +dsa_user_ports (priv->ds) : +BIT (dsa_to_port (priv->ds, p)->cpu_dp->index))); +if (ret) +return ret;/* Port Association Vector: when learning source addresses * of packets, add the address to the address database using * a port bitmap that has only the bit for this port set and * the other bits clear. */ -REG_WRITE (addr,PORT_ASSOC_VECTOR ,BIT (p)); - -return 0 ; +return reg_write (priv, addr,PORT_ASSOC_VECTOR ,BIT (p)); }static int mv88e6060_setup_addr (struct mv88e6060_priv *priv) {u8 addr[ETH_ALEN ]; +int ret;u16 val;eth_random_addr (addr);@@ -195,11 +198,17 @@ static int mv88e6060_setup_addr(struct mv88e6060_priv *priv)*/ val &=0xfeff ; -REG_WRITE (REG_GLOBAL ,GLOBAL_MAC_01 , val); -REG_WRITE (REG_GLOBAL ,GLOBAL_MAC_23 , (addr[2 ] <<8 ) | addr[3 ]); -REG_WRITE (REG_GLOBAL ,GLOBAL_MAC_45 , (addr[4 ] <<8 ) | addr[5 ]); + ret =reg_write (priv,REG_GLOBAL ,GLOBAL_MAC_01 , val); +if (ret) +return ret; + + ret =reg_write (priv,REG_GLOBAL ,GLOBAL_MAC_23 , + (addr[2 ] <<8 ) | addr[3 ]); +if (ret) +return ret; -return 0 ; +return reg_write (priv,REG_GLOBAL ,GLOBAL_MAC_45 , + (addr[4 ] <<8 ) | addr[5 ]); }static int mv88e6060_setup (struct dsa_switch *ds)
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Andrew Lunn
maintainerRe: [PATCH RFC RFT net-next 03/10] net: dsa: mv88e6060: Replace REG_WRITE macro
Quoted 6 lines · Pavel Machek
Quoted 2 lines · Andrew Lunn
The
REG_WRITEmacro contains a return statement, making it not very safe. Remove it by inlining the code.Not bad, but maybe there should be
dev_err()or something in case ofreg_write()returns an error?
Hi Pavel
An error is always returned to the caller. It should be the caller who handles error recovery, and if need be prints an error message. The only time we would print an error message is in a void function, when we cannot return an error code.
I've also followed what we do in mv88e6xxx. It works fine there, so i don't see the need to do anything different here.
Andrew
Andrew Lunn
maintainerRFC PATCH 4/10 net: dsa: mv88e6060: Replace REG_READ macro
In reply to Andrew LunnThe REG_READ macro contains a return statement, making it not very safe. Remove it by inlining the code.
--- drivers/net/dsa/mv88e6060.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-)
drivers/net/dsa/mv88e6060.c +7 -13
@@ -23,17 +23,6 @@ static int reg_read(struct mv88e6060_priv *priv, int addr, int reg)return mdiobus_read_nested (priv->bus, priv->sw_addr + addr, reg); } -#define REG_READ (addr, reg) \ - ({ \ - int __ret; \ - \ - __ret = reg_read(priv, addr, reg); \ - if (__ret < 0) \ - return __ret; \ - __ret; \ - }) - -static int reg_write (struct mv88e6060_priv *priv,int addr,int reg,u16 val) {return mdiobus_write_nested (priv->bus, priv->sw_addr + addr, reg, val);
@@ -92,7 +81,9 @@ static int mv88e6060_switch_reset(struct mv88e6060_priv *priv)/* Set all ports to the disabled state. */ for (i =0 ; i <MV88E6060_PORTS ; i++) { - ret =REG_READ (REG_PORT (i),PORT_CONTROL ); + ret =reg_read (priv,REG_PORT (i),PORT_CONTROL ); +if (ret <0 ) +return ret; ret =reg_write (priv,REG_PORT (i),PORT_CONTROL , ret & ~PORT_CONTROL_STATE_MASK );if (ret)
@@ -112,7 +103,10 @@ static int mv88e6060_switch_reset(struct mv88e6060_priv *priv)/* Wait up to one second for reset to complete. */ timeout = jiffies +1 *HZ ;while (time_before (jiffies, timeout)) { - ret =REG_READ (REG_GLOBAL ,GLOBAL_STATUS ); + ret =reg_read (priv,REG_GLOBAL ,GLOBAL_STATUS ); +if (ret <0 ) +return ret; +if (ret &GLOBAL_STATUS_INIT_READY )break ;
Signature · 1 line
2.20.1
Andrew Lunn
maintainerRFC PATCH 5/10 net: dsa: mv88e6060: Support probing as an mdio device
In reply to Andrew LunnProbing DSA devices as platform devices has been superseded by using normal bus drivers. Add support for probing the mv88e6060 device as an mdio device.
--- drivers/net/dsa/mv88e6060.c | 61 ++++++++++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-)
drivers/net/dsa/mv88e6060.c +60 -1
@@ -280,19 +280,78 @@ static struct dsa_switch_driver mv88e6060_switch_drv = { .ops = &mv88e6060_switch_ops, }; +static int mv88e6060_probe (struct mdio_device *mdiodev) +{ +struct device *dev = &mdiodev->dev; +struct mv88e6060_priv *priv; +struct dsa_switch *ds; +const char *name; + + priv =devm_kzalloc (dev,sizeof (*priv),GFP_KERNEL ); +if (!priv) +return -ENOMEM ; + + priv->bus = mdiodev->bus; + priv->sw_addr = mdiodev->addr; + + name =mv88e6060_get_name (priv->bus, priv->sw_addr); +if (!name) +return -ENODEV ; + +dev_info (dev,"switch %s detected\n" , name); + + ds =dsa_switch_alloc (dev,MV88E6060_PORTS ); +if (!ds) +return -ENOMEM ; + + ds->priv = priv; + ds->dev = dev; + ds->ops = &mv88e6060_switch_ops; + +dev_set_drvdata (dev, ds); + +return dsa_register_switch (ds); +} + +static void mv88e6060_remove (struct mdio_device *mdiodev) +{ +struct dsa_switch *ds =dev_get_drvdata (&mdiodev->dev); + +dsa_unregister_switch (ds); +} + +static const struct of_device_id mv88e6060_of_match[] = { + { + .compatible ="marvell,mv88e6060" , + }, + {/* sentinel */ }, +}; + +static struct mdio_driver mv88e6060_driver = { + .probe = mv88e6060_probe, + .remove = mv88e6060_remove, + .mdiodrv.driver = { + .name ="mv88e6060" , + .of_match_table = mv88e6060_of_match, + }, +}; +static int __init mv88e6060_init (void ) {register_switch_driver (&mv88e6060_switch_drv); -return 0 ; +return mdio_driver_register (&mv88e6060_driver); }module_init (mv88e6060_init); static void __exit mv88e6060_cleanup(void) { +mdio_driver_unregister (&mv88e6060_driver);unregister_switch_driver (&mv88e6060_switch_drv); }module_exit (mv88e6060_cleanup); + +MODULE_AUTHOR ("Lennert Buytenhek <[email protected]>" );MODULE_DESCRIPTION ("Driver for Marvell 88E6060 ethernet switch chip" );MODULE_LICENSE ("GPL" );
Signature · 1 line
2.20.1
Andrew Lunn
maintainerRFC PATCH 6/10 net: dsa: mv88e6060: Remove support for legacy probing
In reply to Andrew LunnNow that the driver can be probed as an mdio device, remove the legacy DSA platform device probing.
--- drivers/net/dsa/Kconfig | 2 +- drivers/net/dsa/mv88e6060.c | 42 +------------------------------------ 2 files changed, 2 insertions(+), 42 deletions(-)
drivers/net/dsa/Kconfig +1 -1
@@ -41,7 +41,7 @@ config NET_DSA_MT7530 config NET_DSA_MV88E6060 tristate "Marvell 88E6060 ethernet switch chip support" - depends on NET_DSA && NET_DSA_LEGACY + depends on NET_DSA select NET_DSA_TAG_TRAILER ---help--- This enables support for the Marvell 88E6060 ethernet switch
drivers/net/dsa/mv88e6060.c +1 -41
65 lines not on this page · raw message
Signature · 1 line
2.20.1
Andrew Lunn
maintainerRFC PATCH 7/10 net: dsa: mv88e6060: Add SPDX header
In reply to Andrew LunnAdd an SPDX header, and remove the license text.
--- drivers/net/dsa/mv88e6060.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/net/dsa/mv88e6060.c +1 -5
@@ -1,11 +1,7 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * net/dsa/mv88e6060.c - Driver for Marvell 88e6060 switch chips * Copyright (c) 2008-2009 Marvell Semiconductor -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. */ #include <linux/delay.h>
Signature · 1 line
2.20.1
Andrew Lunn
maintainerRFC PATCH 8/10 net: dsa: Remove legacy probing support
In reply to Andrew LunnNow that all drivers can be probed using more traditional methods, remove the legacy probe code.
--- include/net/dsa.h | 23 -- net/dsa/Kconfig | 9 - net/dsa/Makefile | 1 - net/dsa/dsa.c | 5 - net/dsa/dsa_priv.h | 12 - net/dsa/legacy.c | 745 --------------------------------------------- 6 files changed, 795 deletions(-)
include/net/dsa.h +0 -23
@@ -277,15 +277,6 @@ static inline unsigned int dsa_upstream_port(struct dsa_switch *ds, int port)typedef int dsa_fdb_dump_cb_t (const unsigned char *addr,u16 vid,bool is_static,void *data);struct dsa_switch_ops { -#if IS_ENABLED (CONFIG_NET_DSA_LEGACY ) -/* -* Legacy probing. -*/ -const char *(*probe)(struct device *dsa_dev, -struct device *host_dev,int sw_addr, -void **priv); -#endif -enum dsa_tag_protocol (*get_tag_protocol)(struct dsa_switch *ds,int port);
@@ -474,20 +465,6 @@ struct dsa_switch_driver {const struct dsa_switch_ops *ops; }; -#if IS_ENABLED (CONFIG_NET_DSA_LEGACY ) -/* Legacy driver registration */ -void register_switch_driver (struct dsa_switch_driver *type); -void unregister_switch_driver (struct dsa_switch_driver *type); -struct mii_bus *dsa_host_dev_to_mii_bus (struct device *dev); - -#else -static inline void register_switch_driver (struct dsa_switch_driver *type) { } -static inline void unregister_switch_driver (struct dsa_switch_driver *type) { } -static inline struct mii_bus *dsa_host_dev_to_mii_bus (struct device *dev) -{ -return NULL ; -} -#endif struct net_device *dsa_dev_to_net_device (struct device *dev);/* Keep inline for faster access in hot path */
net/dsa/Kconfig +0 -9
@@ -16,15 +16,6 @@ config NET_DSA if NET_DSA -config NET_DSA_LEGACY - bool "Support for older platform device and Device Tree registration" - default y - ---help--- - Say Y if you want to enable support for the older platform device and - deprecated Device Tree binding registration. - - This feature is scheduled for removal in 4.17. - # tagging formats config NET_DSA_TAG_BRCM bool
net/dsa/Makefile +0 -1
@@ -2,7 +2,6 @@ # the core obj-$(CONFIG_NET_DSA) += dsa_core.o dsa_core-y += dsa.o dsa2.o master.o port.o slave.o switch.o -dsa_core-$(CONFIG_NET_DSA_LEGACY) += legacy.o # tagging formats dsa_core-$(CONFIG_NET_DSA_TAG_BRCM) += tag_brcm.o
net/dsa/dsa.c +0 -5
@@ -344,10 +344,6 @@ static int __init dsa_init_module(void)if (rc)return rc; - rc =dsa_legacy_register (); -if (rc) -return rc; -dev_add_pack (&dsa_pack_type);return 0 ;
@@ -358,7 +354,6 @@ static void __exit dsa_cleanup_module(void) {dsa_slave_unregister_notifier ();dev_remove_pack (&dsa_pack_type); -dsa_legacy_unregister ();destroy_workqueue (dsa_owq); }module_exit (dsa_cleanup_module);
net/dsa/dsa_priv.h +0 -12
@@ -88,18 +88,6 @@ const struct dsa_device_ops *dsa_resolve_tag_protocol(int tag_protocol);bool dsa_schedule_work (struct work_struct *work);const char *dsa_tag_protocol_to_str (const struct dsa_device_ops *ops); -/* legacy.c */ -#if IS_ENABLED (CONFIG_NET_DSA_LEGACY ) -int dsa_legacy_register (void ); -void dsa_legacy_unregister (void ); -#else -static inline int dsa_legacy_register (void ) -{ -return 0 ; -} - -static inline void dsa_legacy_unregister (void ) { } -#endif int dsa_legacy_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], struct net_device *dev, const unsigned char *addr, u16 vid,
net/dsa/legacy.c +0 -745
745 lines not on this page · raw message
Signature · 1 line
2.20.1
Andrew Lunn
maintainerRFC PATCH 9/10 arch: arm: dts: Remove disabled marvell,dsa properties
In reply to Andrew LunnThese have been disable since the change to probe Marvell Ethernet switches as MDIO devices. Remove the properties now that the code to suppport them has also been removed.
--- arch/arm/boot/dts/armada-370-rd.dts | 42 -------------- arch/arm/boot/dts/armada-388-clearfog.dts | 58 ------------------- arch/arm/boot/dts/armada-xp-linksys-mamba.dts | 47 --------------- arch/arm/boot/dts/kirkwood-dir665.dts | 47 --------------- arch/arm/boot/dts/kirkwood-linksys-viper.dts | 47 --------------- .../arm/boot/dts/kirkwood-mv88f6281gtw-ge.dts | 47 --------------- arch/arm/boot/dts/kirkwood-rd88f6281.dtsi | 41 ------------- 7 files changed, 329 deletions(-)
arch/arm/boot/dts/armada-370-rd.dts +0 -42
@@ -114,48 +114,6 @@ }; }; }; - - dsa { - status = "disabled"; - - compatible = "marvell,dsa"; - #address-cells = <2>; - #size-cells = <0>; - - dsa,ethernet = <ð1>; - dsa,mii-bus = <&mdio>; - - switch@0 { - #address-cells = <1>; - #size-cells = <0>; - reg = <0x10 0>; /* MDIO address 16, switch 0 in tree */ - - port@0 { - reg = <0>; - label = "lan0"; - }; - - port@1 { - reg = <1>; - label = "lan1"; - }; - - port@2 { - reg = <2>; - label = "lan2"; - }; - - port@3 { - reg = <3>; - label = "lan3"; - }; - - port@5 { - reg = <5>; - label = "cpu"; - }; - }; - }; }; &pciec {
arch/arm/boot/dts/armada-388-clearfog.dts +0 -58
64 lines not on this page · raw message
arch/arm/boot/dts/armada-xp-linksys-mamba.dts +0 -47
53 lines not on this page · raw message
arch/arm/boot/dts/kirkwood-dir665.dts +0 -47
53 lines not on this page · raw message
arch/arm/boot/dts/kirkwood-linksys-viper.dts +0 -47
53 lines not on this page · raw message
arch/arm/boot/dts/kirkwood-mv88f6281gtw-ge.dts +0 -47
53 lines not on this page · raw message
arch/arm/boot/dts/kirkwood-rd88f6281.dtsi +0 -41
47 lines not on this page · raw message
Signature · 1 line
2.20.1
Andrew Lunn
maintainerRFC PATCH 10/10 bt-bindings: net: DSA: Remove legacy binding
In reply to Andrew LunnNow that the code to support the legacy binding has been removed, remove the documentation for it.
--- .../devicetree/bindings/net/dsa/dsa.txt | 155 ------------------ 1 file changed, 155 deletions(-)
Documentation/devicetree/bindings/net/dsa/dsa.txt +0 -155
@@ -1,12 +1,6 @@ Distributed Switch Architecture Device Tree Bindings ---------------------------------------------------- -Two bindings exist, one of which has been deprecated due to -limitations. - -Current Binding ---------------- - Switches are true Linux devices and can be probed by any means. Once probed, they register to the DSA framework, passing a node pointer. This node is expected to fulfil the following binding, and
@@ -257,152 +251,3 @@ linked into one DSA cluster. }; }; }; - -Deprecated Binding ------------------- - -The deprecated binding makes use of a platform device to represent the -switches. The switches themselves are not Linux devices, and make use -of an MDIO bus for management. - -Required properties: -- compatible : Should be "marvell,dsa" -- #address-cells : Must be 2, first cell is the address on the MDIO bus - and second cell is the address in the switch tree. - Second cell is used only when cascading/chaining. -- #size-cells : Must be 0 -- dsa,ethernet : Should be a phandle to a valid Ethernet device node -- dsa,mii-bus : Should be a phandle to a valid MDIO bus device node - -Optional properties: -- interrupts : property with a value describing the switch - interrupt number (not supported by the driver) - -A DSA node can contain multiple switch chips which are therefore child nodes of -the parent DSA node. The maximum number of allowed child nodes is 4 -(DSA_MAX_SWITCHES). -Each of these switch child nodes should have the following required properties: - -- reg : Contains two fields. The first one describes the - address on the MII bus. The second is the switch - number that must be unique in cascaded configurations -- #address-cells : Must be 1 -- #size-cells : Must be 0 - -A switch child node has the following optional property: - -- eeprom-length : Set to the length of an EEPROM connected to the - switch. Must be set if the switch can not detect - the presence and/or size of a connected EEPROM, - otherwise optional. - -A switch may have multiple "port" children nodes - -Each port children node must have the following mandatory properties: -- reg : Describes the port address in the switch -- label : Describes the label associated with this port, special - labels are "cpu" to indicate a CPU port and "dsa" to - indicate an uplink/downlink port. - -Note that a port labelled "dsa" will imply checking for the uplink phandle -described below. - -Optional property: -- link : Should be a list of phandles to another switch's DSA port. - This property is only used when switches are being - chained/cascaded together. This port is used as outgoing port - towards the phandle port, which can be more than one hop away. - -- phy-handle : Phandle to a PHY on an external MDIO bus, not the - switch internal one. See - Documentation/devicetree/bindings/net/ethernet.txt - for details. - -- phy-mode : String representing the connection to the designated - PHY node specified by the 'phy-handle' property. See - Documentation/devicetree/bindings/net/ethernet.txt - for details. - -- mii-bus : Should be a phandle to a valid MDIO bus device node. - This mii-bus will be used in preference to the - global dsa,mii-bus defined above, for this switch. - -Optional subnodes: -- fixed-link : Fixed-link subnode describing a link to a non-MDIO - managed entity. See - Documentation/devicetree/bindings/net/fixed-link.txt - for details. - -Example: - - dsa@0 { - compatible = "marvell,dsa"; - #address-cells = <2>; - #size-cells = <0>; - - interrupts = <10>; - dsa,ethernet = <ðernet0>; - dsa,mii-bus = <&mii_bus0>; - - switch@0 { - #address-cells = <1>; - #size-cells = <0>; - reg = <16 0>; /* MDIO address 16, switch 0 in tree */ - - port@0 { - reg = <0>; - label = "lan1"; - phy-handle = <&phy0>; - }; - - port@1 { - reg = <1>; - label = "lan2"; - }; - - port@5 { - reg = <5>; - label = "cpu"; - }; - - switch0port6: port@6 { - reg = <6>; - label = "dsa"; - link = <&switch1port0 - &switch2port0>; - }; - }; - - switch@1 { - #address-cells = <1>; - #size-cells = <0>; - reg = <17 1>; /* MDIO address 17, switch 1 in tree */ - mii-bus = <&mii_bus1>; - reset-gpios = <&gpio5 1 GPIO_ACTIVE_LOW>; - - switch1port0: port@0 { - reg = <0>; - label = "dsa"; - link = <&switch0port6>; - }; - switch1port1: port@1 { - reg = <1>; - label = "dsa"; - link = <&switch2port1>; - }; - }; - - switch@2 { - #address-cells = <1>; - #size-cells = <0>; - reg = <18 2>; /* MDIO address 18, switch 2 in tree */ - mii-bus = <&mii_bus1>; - - switch2port0: port@0 { - reg = <0>; - label = "dsa"; - link = <&switch1port1 - &switch0port6>; - }; - }; - };
Signature · 1 line
2.20.1
Quoted 7 lines · Andrew Lunn
The mv88e6060 is the last device using the legacy method of probing an DSA Ethernet switch. This patchset applies some cleanups to the driver, and then adds support for probing the device as an MDIO bus device. The legacy probe is then removed from the driver, and then from DSA as a whole.
This is compile tested only. Comment and testing welcome.
Series looks good to me. But I have out of tree board 6065, not 6060, so testing is not too easy.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Hi Andrew,
Quoted 11 lines · Andrew Lunn
The mv88e6060 is the last device using the legacy method of probing an DSA Ethernet switch. This patchset applies some cleanups to the driver, and then adds support for probing the device as an MDIO bus device. The legacy probe is then removed from the driver, and then from DSA as a whole.
This is compile tested only. Comment and testing welcome.
It should not be merged yet, and one of the patches should go via arm-soc.
Quoted 11 lines
Andrew Lunn (10):
net: dsa: mv88e6xxx: Remove legacy probe support
net: dsa: mv88e6060: Replace ds with priv
net: dsa: mv88e6060: ReplaceREG_WRITEmacro
net: dsa: mv88e6060: ReplaceREG_READmacro
net: dsa: mv88e6060: Support probing as an mdio device
net: dsa: mv88e6060: Remove support for legacy probing
net: dsa: mv88e6060: Add SPDX header
net: dsa: Remove legacy probing support
arch: arm: dts: Remove disabled marvell,dsa properties
bt-bindings: net: DSA: Remove legacy binding
I saw there was some test already done on this series, but unless I am wrong it was not applied yet.
Do you plan to send a new iteration soon?
I am asking because this week the dt part can be applied to be merged in v5.1, whereas next week, it will be doable but as rc6 will be released there will be less chance to be accepted.
Thanks,
Gregory
Quoted 24 lines
.../devicetree/bindings/net/dsa/dsa.txt | 155 ---- arch/arm/boot/dts/armada-370-rd.dts | 42 - arch/arm/boot/dts/armada-388-clearfog.dts | 58 -- arch/arm/boot/dts/armada-xp-linksys-mamba.dts | 47 -- arch/arm/boot/dts/kirkwood-dir665.dts | 47 -- arch/arm/boot/dts/kirkwood-linksys-viper.dts | 47 -- .../arm/boot/dts/kirkwood-mv88f6281gtw-ge.dts | 47 -- arch/arm/boot/dts/kirkwood-rd88f6281.dtsi | 41 - drivers/net/dsa/Kconfig | 2 +- drivers/net/dsa/mv88e6060.c | 217 ++--- drivers/net/dsa/mv88e6060.h | 1 + drivers/net/dsa/mv88e6xxx/chip.c | 71 +- include/net/dsa.h | 23 - net/dsa/Kconfig | 9 - net/dsa/Makefile | 1 - net/dsa/dsa.c | 5 - net/dsa/dsa_priv.h | 12 - net/dsa/legacy.c | 745 ------------------ 18 files changed, 121 insertions(+), 1449 deletions(-)Signature · 1 line
2.20.1
Signature · 3 lines
Gregory Clement, Bootlin Embedded Linux and Kernel engineering http://bootlin.com
Andrew Lunn
maintainerQuoted 3 lines
I am asking because this week the dt part can be applied to be merged in v5.1, whereas next week, it will be doable but as rc6 will be released there will be less chance to be accepted.
Hi Gregory
The DT changes can be applied anyway. They just remove disabled nodes. I will repost that patch today, without the RFC.
Andrew