net: phy: Add Broadcom BCM53xx switch driver
Subsystems (2)
cover net: phy: Add Broadcom BCM53xx switch driver
(this time after subscribing to the list)
Hi all,
This patch series adds support for the Broadcom BCM53xx switches, in particular BCM53125 which is found no the Lamobo R1 board.
The driver is largely based on the DSA/b53 driver Linux driver and only incorporates what is necessary to succesfully bring-up all ports (including the management port) for boot over the network:
=> dhcpdw_adjust_link: Speed: 1000, full duplex
BOOTP broadcast 1
DHCP client bound to address 192.168.0.11 (3 ms)
Using ethernet at 01c50000 device
TFTP from server 192.168.0.1; our IP address is 192.168.0.11 Filename 'sun7i-a20-lamobo-r1-kernel.bin'.
Load address: 0x42000000
Loading: #################################################################
#################################################################
################################
11.6 MiB/sdone
Bytes transferred = 2371552 (242fe0 hex)
=>
Florian Fainelli (4):
net: phy: Add Broadcom BCM53xx switch driver
net: designware: Pad small packets
net: phy: b53: Add b53_reg read/write commands
configs: Update Lamobo_R1 with B53 switch options
configs/Lamobo_R1_defconfig | 3 + drivers/net/designware.c | 4 + drivers/net/phy/Kconfig | 14 + drivers/net/phy/Makefile | 1 + drivers/net/phy/b53.c | 767 ++++++++++++++++++++++++++++++++++++++++++++ drivers/net/phy/phy.c | 3 + include/phy.h | 1 + 7 files changed, 793 insertions(+) create mode 100644 drivers/net/phy/b53.c
Signature · 1 line
2.11.0
PATCH 1/4 net: phy: Add Broadcom BCM53xx switch driver
Add a minimalistic Broadcom BCM53xx (roboswitch) switch driver similar to the Marvell MV88E617x. This takes care of configuring the minimum amount out of the switch hardware such that each user visible port (configurable) and the CPU port can forward packets between each other while preserving isolation with other ports.
This is useful for e.g: the Lamobo R1 board featuring a Broadcom BCM53125 switch.
--- drivers/net/phy/Kconfig | 14 ++ drivers/net/phy/Makefile | 1 + drivers/net/phy/b53.c | 629 +++++++++++++++++++++++++++++++++++++++++++++++ drivers/net/phy/phy.c | 3 + include/phy.h | 1 + 5 files changed, 648 insertions(+) create mode 100644 drivers/net/phy/b53.c
drivers/net/phy/Kconfig +14 -0
@@ -12,6 +12,20 @@ menuconfig PHYLIB if PHYLIB +config B53_SWITCH + bool "Broadcom BCM53xx (roboswitch) Ethernet switch PHY support." + +if B53_SWITCH + +config B53_CPU_PORT + int "CPU port" + default 8 + +config B53_PHY_PORTS + hex "Bitmask of PHY ports" + +endif # B53_SWITCH + config MV88E61XX_SWITCH bool "Marvel MV88E61xx Ethernet switch PHY support."
drivers/net/phy/Makefile +1 -0
@@ -6,6 +6,7 @@ # obj-$(CONFIG_BITBANGMII) += miiphybb.o +obj-$(CONFIG_B53_SWITCH) += b53.o obj-$(CONFIG_MV88E61XX_SWITCH) += mv88e61xx.o obj-$(CONFIG_MV88E6352_SWITCH) += mv88e6352.o
drivers/net/phy/b53.c new file +629 -0
629 lines not on this page · raw message
drivers/net/phy/phy.c +3 -0
@@ -461,6 +461,9 @@ static LIST_HEAD(phy_drivers);int phy_init (void ) { +#ifdef CONFIG_B53_SWITCH +phy_b53_init (); +#endif #ifdef CONFIG_MV88E61XX_SWITCH phy_mv88e61xx_init ();#endif
include/phy.h +1 -0
@@ -257,6 +257,7 @@ int gen10g_startup(struct phy_device *phydev);int gen10g_shutdown (struct phy_device *phydev);int gen10g_discover_mmds (struct phy_device *phydev); +int phy_b53_init (void );int phy_mv88e61xx_init (void );int phy_aquantia_init (void );int phy_atheros_init (void );
Signature · 1 line
2.11.0
PATCH 1/4 net: phy: Add Broadcom BCM53xx switch driver
Quoted 10 lines · Florian Fainelli
Add a minimalistic Broadcom BCM53xx (roboswitch) switch driver similar to the Marvell MV88E617x. This takes care of configuring the minimum amount out of the switch hardware such that each user visible port (configurable) and the CPU port can forward packets between each other while preserving isolation with other ports.
This is useful for e.g: the Lamobo R1 board featuring a Broadcom BCM53125 switch.
Signed-off-by Florian Fainelli <[email protected]>
Thanks,
Stefan
PATCH 2/4 net: designware: Pad small packets
In reply to Florian FainelliMake sure that we pad small packets to a minimum length of 60 bytes (without FCS). This is necessary to interface with Ethernet switches that will reject RUNT frames unless padded correctly.
--- drivers/net/designware.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/designware.c +4 -0
@@ -343,6 +343,8 @@ int designware_eth_enable(struct dw_eth_dev *priv)return 0 ; } +#define ETH_ZLEN 60 +static int _dw_eth_send (struct dw_eth_dev *priv,void *packet,int length) {struct eth_dma_regs *dma_p = priv->dma_regs_p;
@@ -369,6 +371,8 @@ static int _dw_eth_send(struct dw_eth_dev *priv, void *packet, int length)return -EPERM ; } + length = (length <ETH_ZLEN ) ?ETH_ZLEN : length; +memcpy ((void *)data_start, packet, length);/* Flush data to be sent */
Signature · 1 line
2.11.0
PATCH 2/4 net: designware: Pad small packets
Quoted 5 lines · Florian Fainelli
Make sure that we pad small packets to a minimum length of 60 bytes (without FCS). This is necessary to interface with Ethernet switches that will reject RUNT frames unless padded correctly.
Signed-off-by Florian Fainelli <[email protected]>
Thanks,
Stefan
PATCH 2/4 net: designware: Pad small packets
In reply to Florian FainelliQuoted 23 lines · Florian Fainelli
Make sure that we pad small packets to a minimum length of 60 bytes (without FCS). This is necessary to interface with Ethernet switches that will reject RUNT frames unless padded correctly.
Signed-off-by Florian Fainelli <[email protected]>--- drivers/net/designware.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/net/designware.c +2
-0@@ -343,6 +343,8 @@ int designware_eth_enable(struct dw_eth_dev *priv)return 0 ; } +#define ETH_ZLEN 60 +static int _dw_eth_send (struct dw_eth_dev *priv,void *packet,int length) {struct eth_dma_regs *dma_p = priv->dma_regs_p;
drivers/net/designware.c static int _dw_eth_send(struct dw_eth_dev *priv, void *packet, int length) · line 374
Quoted 4 lines
drivers/net/designware.c +1
-0@@ -369,6 +371,8 @@ static int _dw_eth_send(struct dw_eth_dev *priv, void *packet, int length)return -EPERM ; } + length = (length <ETH_ZLEN ) ?ETH_ZLEN : length;
Why not use max() from include/linux/kernel.h here?
Quoted 6 lines
drivers/net/designware.c +1
-1+memcpy ((void *)data_start, packet, length);/* Flush data to be sent */ --2.11.0
PATCH 3/4 net: phy: b53: Add b53_reg read/write commands
In reply to Florian FainelliAdd a b53_reg read/write command which allows inspecting the switch registers. Because the Broadcom BCM53xx registers have different sizes, we need to split the accesses in 8, 16, 32, 48 or 64 bits to obtain expected results.
--- drivers/net/phy/b53.c | 138 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+)
drivers/net/phy/b53.c +138 -0
@@ -627,3 +627,141 @@ int phy_b53_init(void)return 0 ; } + +int do_b53_reg_read (const char *name,int argc,char *const argv[]) +{ +u8 page, offset, width; +struct mii_dev *bus; +int ret = -EINVAL ; +u64 value64 =0 ; +u32 value32 =0 ; +u16 value16 =0 ; +u8 value8 =0 ; + + bus =miiphy_get_dev_by_name (name); +if (!bus) { +printf ("unable to find MDIO bus: %s\n" , name); +return ret; + } + + page =simple_strtoul (argv[1 ],NULL ,16 ); + offset =simple_strtoul (argv[2 ],NULL ,16 ); + width =simple_strtoul (argv[3 ],NULL ,10 ); + +switch (width) { +case 8 : + ret =b53_mdio_read8 (bus, page, offset, &value8); +printf ("page=0x%02x, offset=0x%02x, value=0x%02x\n" , + page, offset, value8); +break ; +case 16 : + ret =b53_mdio_read16 (bus, page, offset, &value16); +printf ("page=0x%02x, offset=0x%02x, value=0x%04x\n" , + page, offset, value16); +break ; +case 32 : + ret =b53_mdio_read32 (bus, page, offset, &value32); +printf ("page=0x%02x, offset=0x%02x, value=0x%08x\n" , + page, offset, value32); +break ; +case 48 : + ret =b53_mdio_read48 (bus, page, offset, &value64); +printf ("page=0x%02x, offset=0x%02x, value=0x%012llx\n" , + page, offset, value64); +break ; +case 64 : + ret =b53_mdio_read48 (bus, page, offset, &value64); +printf ("page=0x%02x, offset=0x%02x, value=0x%016llx\n" , + page, offset, value64); +break ; +default : +printf ("Unsupported width: %d\n" , width); +break ; + } + +return ret; +} + +int do_b53_reg_write (const char *name,int argc,char *const argv[]) +{ +u8 page, offset, width; +struct mii_dev *bus; +int ret = -EINVAL ; +u64 value64 =0 ; +u32 value =0 ; + + bus =miiphy_get_dev_by_name (name); +if (!bus) { +printf ("unable to find MDIO bus: %s\n" , name); +return ret; + } + + page =simple_strtoul (argv[1 ],NULL ,16 ); + offset =simple_strtoul (argv[2 ],NULL ,16 ); + width =simple_strtoul (argv[3 ],NULL ,10 ); +if (width ==48 || width ==64 ) + value64 =simple_strtoull (argv[4 ],NULL ,16 ); +else + value =simple_strtoul (argv[4 ],NULL ,16 ); + +switch (width) { +case 8 : + ret =b53_mdio_write8 (bus, page, offset, value &0xff ); +break ; +case 16 : + ret =b53_mdio_write16 (bus, page, offset, value); +break ; +case 32 : + ret =b53_mdio_write32 (bus, page, offset, value); +break ; +case 48 : + ret =b53_mdio_write48 (bus, page, offset, value64); +break ; +case 64 : + ret =b53_mdio_write64 (bus, page, offset, value64); +break ; +default : +printf ("Unsupported width: %d\n" , width); +break ; + } + +return ret; +} + +int do_b53_reg (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) +{ +const char *cmd, *mdioname; +int ret =0 ; + +if (argc <2 ) +return cmd_usage (cmdtp); + + cmd = argv[1 ]; + --argc; + ++argv; + +if (!strcmp (cmd,"write" )) { +if (argc <4 ) +return cmd_usage (cmdtp); + mdioname = argv[1 ]; + --argc; + ++argv; + ret =do_b53_reg_write (mdioname, argc, argv); + }else if (!strcmp (cmd,"read" )) { +if (argc <5 ) +return cmd_usage (cmdtp); + mdioname = argv[1 ]; + --argc; + ++argv; + ret =do_b53_reg_read (mdioname, argc, argv); + }else +return cmd_usage (cmdtp); + +return ret; +} + +U_BOOT_CMD (b53_reg,7 ,1 , do_b53_reg, +"Broadcom B53 switch register access" , +"write mdioname page (hex) offset (hex) width (dec) value (hex)\n" +"read mdioname page (hex) offset (hex) width (dec)\n" + );
Signature · 1 line
2.11.0
PATCH 3/4 net: phy: b53: Add b53_reg read/write commands
Quoted 6 lines · Florian Fainelli
Add a
b53_regread/write command which allows inspecting the switch registers. Because the Broadcom BCM53xx registers have different sizes, we need to split the accesses in 8, 16, 32, 48 or 64 bits to obtain expected results.Signed-off-by Florian Fainelli <[email protected]>
Thanks,
Stefan
PATCH 3/4 net: phy: b53: Add b53_reg read/write commands
In reply to Florian FainelliQuoted 6 lines · Florian Fainelli
Add a
b53_regread/write command which allows inspecting the switch registers. Because the Broadcom BCM53xx registers have different sizes, we need to split the accesses in 8, 16, 32, 48 or 64 bits to obtain expected results.Signed-off-by Florian Fainelli <[email protected]>
PATCH 4/4 configs: Update Lamobo_R1 with B53 switch options
In reply to Florian FainelliEnable CONFIG_B53_SWITCH, define the CPU/management port number (8) and enable all 5 ports of the switch to be usable.
--- configs/Lamobo_R1_defconfig | 3 +++ 1 file changed, 3 insertions(+)
configs/Lamobo_R1_defconfig +3 -0
@@ -22,3 +22,6 @@ CONFIG_SUN7I_GMAC=y CONFIG_SCSI=y CONFIG_USB_EHCI_HCD=y CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y +CONFIG_B53_SWITCH=y +CONFIG_B53_CPU_PORT=8 +CONFIG_B53_PHY_PORTS=0x1f
Signature · 1 line
2.11.0
PATCH 4/4 configs: Update Lamobo_R1 with B53 switch options
Quoted 4 lines · Florian Fainelli
Enable
CONFIG_B53_SWITCH, define the CPU/management port number (8) and enable all 5 ports of the switch to be usable.Signed-off-by Florian Fainelli <[email protected]>
Thanks,
Stefan
PATCH 4/4 configs: Update Lamobo_R1 with B53 switch options
In reply to Florian FainelliQuoted 4 lines · Florian Fainelli
Enable
CONFIG_B53_SWITCH, define the CPU/management port number (8) and enable all 5 ports of the switch to be usable.Signed-off-by Florian Fainelli <[email protected]>
cover net: phy: Add Broadcom BCM53xx switch driver
In reply to Florian FainelliQuoted 6 lines · Florian Fainelli
(this time after subscribing to the list)
Hi all,
This patch series adds support for the Broadcom BCM53xx switches, in particular BCM53125 which is found no the Lamobo R1 board.
Thanks Stefan for the review. I suppose Joe should now queue those up, provided that he is happy with the patches and then submit a pull request?
Quoted 38 lines
The driver is largely based on the DSA/b53 driver Linux driver and only incorporates what is necessary to succesfully bring-up all ports (including the management port) for boot over the network:
=> dhcp
dw_adjust_link: Speed: 1000, full duplex
BOOTP broadcast 1
DHCP client bound to address 192.168.0.11 (3 ms)
Using ethernet at01c50000device
TFTP from server 192.168.0.1; our IP address is 192.168.0.11 Filename 'sun7i-a20-lamobo-r1-kernel.bin'.
Load address:0x42000000
Loading: ################################################################################################################################## ################################ 11.6 MiB/sdone
Bytes transferred = 2371552 (242fe0 hex)
=>Florian Fainelli (4):
net: phy: Add Broadcom BCM53xx switch driver
net: designware: Pad small packets
net: phy: b53: Addb53_regread/write commands
configs: UpdateLamobo_R1with B53 switch optionsconfigs/Lamobo_R1_defconfig | 3 + drivers/net/designware.c | 4 + drivers/net/phy/Kconfig | 14 + drivers/net/phy/Makefile | 1 + drivers/net/phy/b53.c | 767 ++++++++++++++++++++++++++++++++++++++++++++ drivers/net/phy/phy.c | 3 + include/phy.h | 1 + 7 files changed, 793 insertions(+) create mode 100644 drivers/net/phy/b53.c
Signature · 1 line
Florian
cover net: phy: Add Broadcom BCM53xx switch driver
Quoted 10 lines · Florian Fainelli
Quoted 6 lines · Florian Fainelli
(this time after subscribing to the list)
Hi all,
This patch series adds support for the Broadcom BCM53xx switches, in particular BCM53125 which is found no the Lamobo R1 board.
Thanks Stefan for the review. I suppose Joe should now queue those up, provided that he is happy with the patches and then submit a pull request?
Yes, this is how it usually works.
Thanks,
Stefan
cover net: phy: Add Broadcom BCM53xx switch driver
Le 10/19/17 à 21:45, Stefan Roese a écrit :
Quoted 10 lines · Florian Fainelli
Quoted 9 lines · Florian Fainelli
Quoted 7 lines
(this time after subscribing to the list)
Hi all,
This patch series adds support for the Broadcom BCM53xx switches, in particular
BCM53125 which is found no the Lamobo R1 board.
Quoted 5 lines
Quoted 3 lines
Thanks Stefan for the review. I suppose Joe should now queue those up, provided that he is happy with the patches and then submit a pull request?
Yes, this is how it usually works.
Joe, should I do anything, are you happy with how the patches look like?
Signature · 1 line
Florian
cover net: phy: Add Broadcom BCM53xx switch driver
Quoted 11 lines · Florian Fainelli
Le 10/19/17 à 21:45, Stefan Roese a écrit :
Quoted 10 lines · Florian Fainelli
Quoted 9 lines · Florian Fainelli
Quoted 7 lines
(this time after subscribing to the list)
Hi all,
This patch series adds support for the Broadcom BCM53xx switches, in particular
BCM53125 which is found no the Lamobo R1 board.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Thanks Stefan for the review. I suppose Joe should now queue those up, provided that he is happy with the patches and then submit a pull request?
Yes, this is how it usually works.
Joe, should I do anything, are you happy with how the patches look like?
Ping? How do we get these moving?
Signature · 1 line
Florian