dsa: Broadcom Starfighter 2 switch support
Subsystems (6)
v4 cover dsa: Broadcom Starfighter 2 switch support
Hi all,
This patch series adds support for the Broadcom Starfighter 2 (Roboswitch successor) using the existing DSA infrastructure. This integrated switch is heavily used in Set Top Box, Cable gateways and DSL gateways products from Broadcom, and to a larger extent the new ARM-based Wi-Fi routers although slightly differently.
Changes in v4 are the introducing of an indirection level for DSA switch tag protocols receive and transmit functions.
I intentionnaly did not address one comment from Alexander who suggested to move port_names and port_dn in a separate structure since that involves touching arch/arm/ and arch/blackfin/ code which I am not yet comfortable doing.
Notable changes in v3 is the preliminary patch that reworks the skb->protocol override helpers for non-Ethertype switch tags, based on feedback from Alexander Duyck.
The biggest changes from v1 of this patch series are:
- use the new fixed PHY helpers
- improved the switch driver with more complete features (interrupts, (RG)MII configuration, memory arrays power down/up, port disabling/enable VLAN separation
Future work will focus on bringing the upstream driver in feature parity with the current downstream driver, including:
- adding Wake-on-LAN support to the switch
- adding suspend/resume callbacks for S2/S3 Power Management modes
- extending the switch register interface to cover BCM5310X SoCs
Florian Fainelli (13):
net: dsa: reduce number of protocol hooks
net: phy: add generic UniMAC MDIO bus driver
net: phy: provide stub for fixed_phy_set_link_update
net: dsa: provide a switch device device tree node pointer
net: dsa: retain a per-port device_node pointer
net: dsa: allow for more complex PHY setups
net: dsa: allow switches to work without tagging
net: dsa: allow drivers to do link adjustment
net: dsa: allow updating fixed PHY link information
net: dsa: add Broadcom tag RX/TX handler
net: dsa: add Broadcom SF2 switch driver
Documentation: devicetree: update dsa binding with optional properties
Documentation: devicetree: add Broadcom Starfighter 2 binding
.../bindings/net/broadcom-mdio-unimac.txt | 39 ++ .../devicetree/bindings/net/broadcom-sf2.txt | 78 +++ Documentation/devicetree/bindings/net/dsa/dsa.txt | 17 + drivers/net/dsa/Kconfig | 11 + drivers/net/dsa/Makefile | 1 + drivers/net/dsa/bcm_sf2.c | 626 +++++++++++++++++++++ drivers/net/dsa/bcm_sf2.h | 140 +++++ drivers/net/dsa/bcm_sf2_regs.h | 227 ++++++++ drivers/net/phy/Kconfig | 8 + drivers/net/phy/Makefile | 1 + drivers/net/phy/mdio-bcm-unimac.c | 212 +++++++ include/linux/netdevice.h | 26 +- include/linux/phy_fixed.h | 17 +- include/net/dsa.h | 38 +- include/uapi/linux/if_ether.h | 1 + net/dsa/Kconfig | 3 + net/dsa/Makefile | 1 + net/dsa/dsa.c | 48 +- net/dsa/dsa_priv.h | 16 +- net/dsa/slave.c | 165 ++++-- net/dsa/tag_brcm.c | 173 ++++++ net/dsa/tag_dsa.c | 8 +- net/dsa/tag_edsa.c | 8 +- net/dsa/tag_trailer.c | 8 +- net/ethernet/eth.c | 5 +- 25 files changed, 1766 insertions(+), 111 deletions(-) create mode 100644 Documentation/devicetree/bindings/net/broadcom-mdio-unimac.txt create mode 100644 Documentation/devicetree/bindings/net/broadcom-sf2.txt create mode 100644 drivers/net/dsa/bcm_sf2.c create mode 100644 drivers/net/dsa/bcm_sf2.h create mode 100644 drivers/net/dsa/bcm_sf2_regs.h create mode 100644 drivers/net/phy/mdio-bcm-unimac.c create mode 100644 net/dsa/tag_brcm.c
Signature · 1 line
1.9.1
PATCH v4 1/13 net: dsa: reduce number of protocol hooks
DSA is currently registering one packet_type function per EtherType it needs to intercept in the receive path of a DSA-enabled Ethernet device. Right now we have three of them: trailer, DSA and eDSA, and there might be more in the future, this will not scale to the addition of new protocols.
This patch proceeds with adding a new layer of abstraction and two new functions:
dsa_switch_rcv() which will dispatch into the tag-protocol specific receive function implemented by net/dsa/tag_*.c
dsa_slave_xmit() which will dispatch into the tag-protocol specific transmit function implemented by net/dsa/tag_*.c
When we do create the per-port slave network devices, we iterate over the switch protocol to assign the DSA-specific receive and transmit operations.
This allows us to greatly simplify the check in eth_type_trans() and always override the skb->protocol with ETH_P_DSA for Ethernet switches tagged protocol, while also reducing the number repetitive slave netdevice_ops assignments.
---
Changes in v4:
- introduce a level of indirection and dsa_device_ops to limit the number of packet_type functions to just one and do the dispatching in the core dsa code.
New patch in v3
include/linux/netdevice.h | 28 ++++++++++++---------------- include/net/dsa.h | 20 +++----------------- net/dsa/dsa.c | 39 +++++++++++++++++++++------------------ net/dsa/dsa_priv.h | 9 +++------ net/dsa/slave.c | 45 ++++++++++++++------------------------------- net/dsa/tag_dsa.c | 8 ++++---- net/dsa/tag_edsa.c | 8 ++++---- net/dsa/tag_trailer.c | 8 ++++---- net/ethernet/eth.c | 5 +---- 9 files changed, 66 insertions(+), 104 deletions(-)
include/linux/netdevice.h +12 -16
@@ -1781,24 +1781,13 @@ void dev_net_set(struct net_device *dev, struct net *net)#endif } -static inline bool netdev_uses_dsa_tags (struct net_device *dev) +static inline bool netdev_uses_dsa (struct net_device *dev) { -#ifdef CONFIG_NET_DSA_TAG_DSA -if (dev->dsa_ptr !=NULL ) -return dsa_uses_dsa_tags (dev->dsa_ptr); -#endif - -return 0 ; -} - -static inline bool netdev_uses_trailer_tags (struct net_device *dev) -{ -#ifdef CONFIG_NET_DSA_TAG_TRAILER -if (dev->dsa_ptr !=NULL ) -return dsa_uses_trailer_tags (dev->dsa_ptr); +#ifdef CONFIG_NET_DSA +return dev->dsa_ptr !=NULL ; +#else +return false;#endif - -return 0 ; }/**
@@ -1933,6 +1922,13 @@ struct udp_offload {struct offload_callbacks callbacks; }; +struct dsa_device_ops { +netdev_tx_t (*xmit)(struct sk_buff *skb,struct net_device *dev); +int (*rcv)(struct sk_buff *skb,struct net_device *dev, +struct packet_type *pt,struct net_device *orig_dev); +}; + +/* often modified stats are per cpu, other are shared (netdev->stats) */ struct pcpu_sw_netstats {u64 rx_packets;
include/net/dsa.h +3 -17
@@ -59,6 +59,8 @@ struct dsa_platform_data {struct dsa_chip_data *chip; }; +struct dsa_device_ops ; +struct dsa_switch_tree {/* * Configuration data for the platform device that owns
@@ -71,6 +73,7 @@ struct dsa_switch_tree {* protocol to use. */ struct net_device *master_netdev; +const struct dsa_device_ops *ops;__be16 tag_protocol;/*
@@ -186,21 +189,4 @@ static inline void *ds_to_priv(struct dsa_switch *ds) return (void *)(ds + 1); } -/* -* The original DSA tag format and some other tag formats have no -* ethertype, which means that we need to add a little hack to the -* networking receive path to make sure that received frames get -* the right ->protocol assigned to them when one of those tag -* formats is in use. -*/ -static inline bool dsa_uses_dsa_tags (struct dsa_switch_tree *dst) -{ -return !!(dst->tag_protocol ==htons (ETH_P_DSA )); -} - -static inline bool dsa_uses_trailer_tags (struct dsa_switch_tree *dst) -{ -return !!(dst->tag_protocol ==htons (ETH_P_TRAILER )); -} -#endif
net/dsa/dsa.c +21 -18
@@ -608,6 +608,24 @@ static void dsa_shutdown(struct platform_device *pdev) { } +static int dsa_switch_rcv (struct sk_buff *skb,struct net_device *dev, +struct packet_type *pt,struct net_device *orig_dev) +{ +struct dsa_switch_tree *dst = dev->dsa_ptr; + +if (unlikely (dst ==NULL )) { +kfree_skb (skb); +return 0 ; + } + +return dst->ops->rcv (skb, dev, pt, orig_dev); +} + +struct packet_type dsa_pack_type__read_mostly = { + .type =cpu_to_be16 (ETH_P_DSA ), + .func = dsa_switch_rcv, +}; +static const struct of_device_id dsa_of_match_table[] = { { .compatible ="marvell,dsa" , }, {}
@@ -633,30 +651,15 @@ static int __init dsa_init_module(void)if (rc)return rc; -#ifdef CONFIG_NET_DSA_TAG_DSA -dev_add_pack (&dsa_packet_type); -#endif -#ifdef CONFIG_NET_DSA_TAG_EDSA -dev_add_pack (&edsa_packet_type); -#endif -#ifdef CONFIG_NET_DSA_TAG_TRAILER -dev_add_pack (&trailer_packet_type); -#endif +dev_add_pack (&dsa_pack_type); +return 0 ; }module_init (dsa_init_module); static void __exit dsa_cleanup_module(void) { -#ifdef CONFIG_NET_DSA_TAG_TRAILER -dev_remove_pack (&trailer_packet_type); -#endif -#ifdef CONFIG_NET_DSA_TAG_EDSA -dev_remove_pack (&edsa_packet_type); -#endif -#ifdef CONFIG_NET_DSA_TAG_DSA -dev_remove_pack (&dsa_packet_type); -#endif +dev_remove_pack (&dsa_pack_type);platform_driver_unregister (&dsa_driver); }module_exit (dsa_cleanup_module);
net/dsa/dsa_priv.h +3 -6
@@ -45,16 +45,13 @@ struct net_device *dsa_slave_create(struct dsa_switch *ds, int port, char *name);/* tag_dsa.c */ -netdev_tx_t dsa_xmit (struct sk_buff *skb,struct net_device *dev); -extern struct packet_type dsa_packet_type; +extern const struct dsa_device_ops dsa_netdev_ops;/* tag_edsa.c */ -netdev_tx_t edsa_xmit (struct sk_buff *skb,struct net_device *dev); -extern struct packet_type edsa_packet_type; +extern const struct dsa_device_ops edsa_netdev_ops;/* tag_trailer.c */ -netdev_tx_t trailer_xmit (struct sk_buff *skb,struct net_device *dev); -extern struct packet_type trailer_packet_type; +extern const struct dsa_device_ops trailer_netdev_ops;#endif
net/dsa/slave.c +14 -31
83 lines not on this page · raw message
net/dsa/tag_dsa.c +4 -4
@@ -16,7 +16,7 @@#define DSA_HLEN 4 -netdev_tx_t dsa_xmit (struct sk_buff *skb,struct net_device *dev) +static netdev_tx_t dsa_xmit (struct sk_buff *skb,struct net_device *dev) {struct dsa_slave_priv *p =netdev_priv (dev);u8 *dsa_header;
@@ -186,7 +186,7 @@ out:return 0 ; } -struct packet_type dsa_packet_type__read_mostly = { - .type =cpu_to_be16 (ETH_P_DSA ), - .func = dsa_rcv, +const struct dsa_device_ops dsa_netdev_ops = { + .xmit = dsa_xmit, + .rcv = dsa_rcv, };
net/dsa/tag_edsa.c +4 -4
@@ -17,7 +17,7 @@#define DSA_HLEN 4#define EDSA_HLEN 8 -netdev_tx_t edsa_xmit (struct sk_buff *skb,struct net_device *dev) +static netdev_tx_t edsa_xmit (struct sk_buff *skb,struct net_device *dev) {struct dsa_slave_priv *p =netdev_priv (dev);u8 *edsa_header;
@@ -205,7 +205,7 @@ out:return 0 ; } -struct packet_type edsa_packet_type__read_mostly = { - .type =cpu_to_be16 (ETH_P_EDSA ), - .func = edsa_rcv, +const struct dsa_device_ops edsa_netdev_ops = { + .xmit = edsa_xmit, + .rcv = edsa_rcv, };
net/dsa/tag_trailer.c +4 -4
@@ -14,7 +14,7 @@#include <linux/slab.h> #include "dsa_priv.h" -netdev_tx_t trailer_xmit (struct sk_buff *skb,struct net_device *dev) +static netdev_tx_t trailer_xmit (struct sk_buff *skb,struct net_device *dev) {struct dsa_slave_priv *p =netdev_priv (dev);struct sk_buff *nskb;
@@ -114,7 +114,7 @@ out:return 0 ; } -struct packet_type trailer_packet_type__read_mostly = { - .type =cpu_to_be16 (ETH_P_TRAILER ), - .func = trailer_rcv, +const struct dsa_device_ops trailer_netdev_ops = { + .xmit = trailer_xmit, + .rcv = trailer_rcv, };
net/ethernet/eth.c +1 -4
@@ -181,12 +181,9 @@ __be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev)* variants has been configured on the receiving interface, * and if so, set skb->protocol without looking at the packet. */ -if (unlikely (netdev_uses_dsa_tags (dev))) +if (unlikely (netdev_uses_dsa (dev)))return htons (ETH_P_DSA ); -if (unlikely (netdev_uses_trailer_tags (dev))) -return htons (ETH_P_TRAILER ); -if (likely (ntohs (eth->h_proto) >=ETH_P_802_3_MIN ))return eth->h_proto;
Signature · 1 line
1.9.1
Re: [PATCH net-next v4 01/13] net: dsa: reduce number of protocol hooks
Quoted 24 lines · Florian Fainelli
DSA is currently registering one
packet_typefunction per EtherType it needs to intercept in the receive path of a DSA-enabled Ethernet device. Right now we have three of them: trailer, DSA and eDSA, and there might be more in the future, this will not scale to the addition of new protocols.This patch proceeds with adding a new layer of abstraction and two new functions:
dsa_switch_rcv()which will dispatch into the tag-protocol specific receive function implemented bynet/dsa/tag_*.c
dsa_slave_xmit()which will dispatch into the tag-protocol specific transmit function implemented bynet/dsa/tag_*.cWhen we do create the per-port slave network devices, we iterate over the switch protocol to assign the DSA-specific receive and transmit operations.
This allows us to greatly simplify the check in
eth_type_trans()and always override theskb->protocolwithETH_P_DSAfor Ethernet switches tagged protocol, while also reducing the number repetitive slavenetdevice_opsassignments.
Quoted 9 lines
Signed-off-by Florian Fainelli <[email protected]>---
Changes in v4:
- introduce a level of indirection anddsa_device_opsto limit the number ofpacket_typefunctions to just one and do the dispatching in the core dsa code.New patch in v3
Just a thought, you might want to consider using a protocol value other than ETH_P_DSA. Maybe we should add a new value named ETH_P_XDSA for this approach since what we are doing is a multiplexed DSA protocol now.
This would allow for much easier back-porting of this if needed and also prevents us from possibly triggering any issues if there are any user-space APIs that might be trying to capture packets based on the protocol value.
Thanks,
Alex
David Miller
maintainerRe: [PATCH net-next v4 01/13] net: dsa: reduce number of protocol hooks
From: Alexander Duyck <[email protected]>
Date: Wed, 27 Aug 2014 08:25:45 -0700
Quoted 8 lines
Just a thought, you might want to consider using a protocol value other than
ETH_P_DSA. Maybe we should add a new value namedETH_P_XDSAfor this approach since what we are doing is a multiplexed DSA protocol now.This would allow for much easier back-porting of this if needed and also prevents us from possibly triggering any issues if there are any user-space APIs that might be trying to capture packets based on the protocol value.
Agreed, Florian can you respin this patch set using a newly allocated ETH_P_* value for these new semantics?
Thanks.
Re: [PATCH net-next v4 01/13] net: dsa: reduce number of protocol hooks
Quoted 7 lines · David Miller
From: Alexander Duyck <[email protected]>
Date: Wed, 27 Aug 2014 08:25:45 -0700Quoted 4 lines
Just a thought, you might want to consider using a protocol value other than
ETH_P_DSA. Maybe we should add a new value namedETH_P_XDSAfor this approach since what we are doing is a multiplexed DSA protocol now.
Quoted 7 lines
Quoted 4 lines
This would allow for much easier back-porting of this if needed and also prevents us from possibly triggering any issues if there are any user-space APIs that might be trying to capture packets based on the protocol value.
Agreed, Florian can you respin this patch set using a newly allocated ETH_P_* value for these new semantics?
Absolutely. While at it, I just realized that ETH_P_BRCMTAG should probably remain within include/net/dsa.h. We don't want that to be exported to user-space since it is used for internal DSA de-multiplexing.
Stay tuned!
--
Florian
Re: [PATCH net-next v4 01/13] net: dsa: reduce number of protocol hooks
Quoted 14 lines · Florian Fainelli
Quoted 7 lines · David Miller
From: Alexander Duyck <[email protected]>
Date: Wed, 27 Aug 2014 08:25:45 -0700Quoted 4 lines
Just a thought, you might want to consider using a protocol value other than
ETH_P_DSA. Maybe we should add a new value namedETH_P_XDSAfor this approach since what we are doing is a multiplexed DSA protocol now.Quoted 6 lines
Quoted 4 lines
This would allow for much easier back-porting of this if needed and also prevents us from possibly triggering any issues if there are any user-space APIs that might be trying to capture packets based on the protocol value.
Agreed, Florian can you respin this patch set using a newly allocated ETH_P_* value for these new semantics?
Quoted 8 lines
Absolutely. While at it, I just realized that
ETH_P_BRCMTAGshould probably remain withininclude/net/dsa.h. We don't want that to be exported to user-space since it is used for internal DSA de-multiplexing.Stay tuned!
--
Florian
Actually you could probably simplify this all a bit more by replacing the ETH_P_BRCMTAG and tag_protcol values with a simple enum/u16 instead of having to use be16 values. It would make things a bit more explicit as well since you could specify something like DSA_TAG_NONE = 0.
If you can't get to it I will probably work on submitting a patch for it next week.
Thanks,
Alex
PATCH v4 2/13 net: phy: add generic UniMAC MDIO bus driver
In reply to Florian FainelliAdd a generic UniMAC MDIO bus driver and its Device Tree binding, which can be used by the BCMGENET driver as-is, and the upcoming Starfighter 2 Ethernet switch MDIO bus controller.
---
Changes in v4:
- added a slightly longer paragraph in Kconfig about where this hardware can be found
Changes in v3:
- renamed from mdio-unimac to mdio-bcm-unimac
Changes in v2:
- improved binding documentation with respect to the HW setups available influencing interrupts
.../bindings/net/broadcom-mdio-unimac.txt | 39 ++++ drivers/net/phy/Kconfig | 8 + drivers/net/phy/Makefile | 1 + drivers/net/phy/mdio-bcm-unimac.c | 212 +++++++++++++++++++++ 4 files changed, 260 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/broadcom-mdio-unimac.txt create mode 100644 drivers/net/phy/mdio-bcm-unimac.c
Documentation/devicetree/bindings/net/broadcom-mdio-unimac.txt new file +39 -0
@@ -0,0 +1,39 @@ +* Broadcom UniMAC MDIO bus controller + +Required properties: +- compatible: should one from "brcm,genet-mdio-v1", "brcm,genet-mdio-v2", + "brcm,genet-mdio-v3", "brcm,genet-mdio-v4" or "brcm,unimac-mdio" +- reg: address and length of the regsiter set for the device, first one is the + base register, and the second one is optional and for indirect accesses to + larger than 16-bits MDIO transactions +- reg-names: name(s) of the register must be "mdio" and optional "mdio_indir_rw" +- #size-cells: must be 1 +- #address-cells: must be 0 + +Optional properties: +- interrupts: must be one if the interrupt is shared with the Ethernet MAC or + Ethernet switch this MDIO block is integrated from, or must be two, if there + are two separate interrupts, first one must be "mdio done" and second must be + for "mdio error" +- interrupt-names: must be "mdio_done_error" when there is a share interrupt fed + to this hardware block, or must be "mdio_done" for the first interrupt and + "mdio_error" for the second when there are separate interrupts + +Child nodes of this MDIO bus controller node are standard Ethernet PHY device +nodes as described in Documentation/devicetree/bindings/net/phy.txt + +Example: + +mdio@403c0 { + compatible = "brcm,unimac-mdio"; + reg = <0x403c0 0x8 0x40300 0x18>; + reg-names = "mdio", "mdio_indir_rw"; + #size-cells = <1>; + #address-cells = <0>; + + ... + phy@0 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <0>; + }; +};
drivers/net/phy/Kconfig +8 -0
@@ -205,6 +205,14 @@ config MDIO_BUS_MUX_MMIOREG Currently, only 8-bit registers are supported. +config MDIO_BCM_UNIMAC + tristate "Broadcom UniMAC MDIO bus controller" + help + This module provides a driver for the Broadcom UniMAC MDIO busses. + This hardware can be found in the Broadcom GENET Ethernet MAC + controllers as well as some Broadcom Ethernet switches such as the + Starfighter 2 switches. + endif # PHYLIB config MICREL_KS8995MA
drivers/net/phy/Makefile +1 -0
@@ -34,3 +34,4 @@ obj-$(CONFIG_MDIO_BUS_MUX_MMIOREG) += mdio-mux-mmioreg.o obj-$(CONFIG_MDIO_SUN4I) += mdio-sun4i.o obj-$(CONFIG_MDIO_MOXART) += mdio-moxart.o obj-$(CONFIG_AMD_XGBE_PHY) += amd-xgbe-phy.o +obj-$(CONFIG_MDIO_BCM_UNIMAC) += mdio-bcm-unimac.o
drivers/net/phy/mdio-bcm-unimac.c new file +212 -0
212 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v4 3/13 net: phy: provide stub for fixed_phy_set_link_update
In reply to Florian FainelliIn preparation for updating the DSA code and avoid using ifdefs there, provide an empty stub for fixed_phy_set_link_update when CONFIG_FIXED_PHY is not selected.
---
New patch in v4 that resulted in more build testing
include/linux/phy_fixed.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
include/linux/phy_fixed.h +9 -8
@@ -18,6 +18,9 @@ extern int fixed_phy_register(unsigned int irq,struct fixed_phy_status *status, struct device_node *np);extern void fixed_phy_del (int phy_addr); +extern int fixed_phy_set_link_update (struct phy_device *phydev, +int (*link_update)(struct net_device *, +struct fixed_phy_status *));#else static inline int fixed_phy_add (unsigned int irq,int phy_id,struct fixed_phy_status *status)
@@ -34,14 +37,12 @@ static inline int fixed_phy_del(int phy_addr) {return -ENODEV ; } -#endif /* CONFIG_FIXED_PHY */ - -/* -* This function issued only by fixed_phy-aware drivers, no need -* protect it with #ifdef -*/ -extern int fixed_phy_set_link_update (struct phy_device *phydev, +static inline int fixed_phy_set_link_update (struct phy_device *phydev,int (*link_update)(struct net_device *, -struct fixed_phy_status *)); +struct fixed_phy_status *)) +{ +return -ENODEV ; +} +#endif /* CONFIG_FIXED_PHY */ #endif /* __PHY_FIXED_H */
Signature · 1 line
1.9.1
PATCH v4 4/13 net: dsa: provide a switch device device tree node pointer
In reply to Florian FainelliWe might need to fetch additional resources from the device tree node pointer, such as register ranges or other properties. Keep a device_node pointer around for this.
--- include/net/dsa.h | 7 +++++++ net/dsa/dsa.c | 1 + 2 files changed, 8 insertions(+)
include/net/dsa.h +7 -0
@@ -15,6 +15,7 @@#include <linux/list.h> #include <linux/timer.h> #include <linux/workqueue.h> +#include <linux/of.h> #define DSA_MAX_SWITCHES 4#define DSA_MAX_PORTS 12
@@ -26,6 +27,12 @@ struct dsa_chip_data {struct device *mii_bus;int sw_addr; +/* Device tree node pointer for this specific switch chip +* used during switch setup in case additional properties +* and resources needs to be used +*/ +struct device_node *of_node; +/* * The names of the switch's ports. Use "cpu" to * designate the switch port that the cpu is connected to,
net/dsa/dsa.c +1 -0
@@ -410,6 +410,7 @@ static int dsa_of_probe(struct platform_device *pdev) chip_index++; cd = &pd->chip[chip_index]; + cd->of_node = child; cd->mii_bus = &mdio_bus->dev; sw_addr =of_get_property (child,"reg" ,NULL );
Signature · 1 line
1.9.1
PATCH v4 5/13 net: dsa: retain a per-port device_node pointer
In reply to Florian FainelliWe will later use the per-port device_node pointer to fetch a bunch of port-specific properties.
---
Changes in v2, v3, v4:
- respin
include/net/dsa.h | 1 + net/dsa/dsa.c | 2 ++ net/dsa/slave.c | 1 + 3 files changed, 4 insertions(+)
include/net/dsa.h +1 -0
@@ -41,6 +41,7 @@ struct dsa_chip_data {* or any other string to indicate this is a physical port. */ char *port_names[DSA_MAX_PORTS ]; +struct device_node *port_dn[DSA_MAX_PORTS ];/* * An array (with nr_chips elements) of which element [a]
net/dsa/dsa.c +2 -0
@@ -432,6 +432,8 @@ static int dsa_of_probe(struct platform_device *pdev)if (!port_name)continue ; + cd->port_dn[port_index] = port; + cd->port_names[port_index] =kstrdup (port_name,GFP_KERNEL );if (!cd->port_names[port_index]) {
net/dsa/slave.c +1 -0
@@ -354,6 +354,7 @@ dsa_slave_create(struct dsa_switch *ds, struct device *parent, }SET_NETDEV_DEV (slave_dev, parent); + slave_dev->dev.of_node = ds->pd->port_dn[port]; slave_dev->vlan_features = master->vlan_features; p =netdev_priv (slave_dev);
Signature · 1 line
1.9.1
PATCH v4 6/13 net: dsa: allow for more complex PHY setups
In reply to Florian FainelliModify the DSA slave interface to be bound to an arbitray PHY, not just the ones that are available as child PHY devices of the switch MDIO bus.
This allows us for instance to have external PHYs connected to a separate MDIO bus, but yet also connected to a given switch port.
Under certain configurations, the physical port mask might not be a 1:1 mapping to the MII PHYs mask. This is the case, if e.g: Port 1 of the switch is used and connects to a PHY at a MDIO address different than 1.
Introduce a phys_mii_mask variable which allows driver to implement and divert their own MDIO read/writes operations for a subset of the MDIO PHY addresses.
---
Changes in v4:
- make more build testing
- changed phy_is_fixed from 'unsigned int' to 'bool' type
Changes in v2:
- introduce phys_mii_mask to allow switch drivers to divert MDIO operations for some PHY addresses
- use the latest fixed PHY API
- iron out non-OF setups
include/net/dsa.h | 1 + net/dsa/dsa.c | 5 ++++ net/dsa/dsa_priv.h | 4 +++ net/dsa/slave.c | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 4 files changed, 83 insertions(+), 3 deletions(-)
include/net/dsa.h +1 -0
@@ -130,6 +130,7 @@ struct dsa_switch {*/ u32 dsa_port_mask;u32 phys_port_mask; +u32 phys_mii_mask;struct mii_bus *slave_mii_bus;struct net_device *ports[DSA_MAX_PORTS ]; };
net/dsa/dsa.c +5 -0
@@ -144,6 +144,11 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index, goto out; } +/* Make the built-in MII bus mask match the number of ports, +* switch drivers can override this later +*/ + ds->phys_mii_mask = ds->phys_port_mask; +/* * If the CPU connects to this switch, set the switch tree * tagging protocol to the preferred tagging format of this
net/dsa/dsa_priv.h +4 -0
@@ -33,6 +33,10 @@ struct dsa_slave_priv {* to this port. */ struct phy_device *phy; +phy_interface_t phy_interface; +int old_link; +int old_pause; +int old_duplex; };/* dsa.c */
net/dsa/slave.c +73 -3
107 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v4 7/13 net: dsa: allow switches to work without tagging
In reply to Florian FainelliIn case switch port tagging is disabled (voluntarily, or the switch just does not support it), allow us to continue using the defined set of dsa_device_ops in net/dsa/slave.c.
We introduce dsa_protocol_is_tagged() to check whether we need to override skb->protocol and go through the DSA-specifif packet_type function, or if we just go on and receive the SKB through the normal path.
---
Changes in v4:
- reworked logic to use dsa_device_ops introduced in patch 1
- added a helper to check for the switch protocol tag
Changes in v3:
- update logic with the helpers introduced in the firs patch set
- renamed dummy to notag
include/linux/netdevice.h | 6 +++--- include/net/dsa.h | 5 +++++ net/dsa/slave.c | 19 ++++++++++++++++++- 3 files changed, 26 insertions(+), 4 deletions(-)
include/linux/netdevice.h +3 -3
@@ -1784,10 +1784,10 @@ void dev_net_set(struct net_device *dev, struct net *net)static inline bool netdev_uses_dsa (struct net_device *dev) {#ifdef CONFIG_NET_DSA -return dev->dsa_ptr !=NULL ; -#else -return false; +if (dev->dsa_ptr !=NULL ) +return dsa_uses_tagged_protocol (dev->dsa_ptr);#endif +return false; }/**
include/net/dsa.h +5 -0
@@ -198,4 +198,9 @@ static inline void *ds_to_priv(struct dsa_switch *ds) return (void *)(ds + 1); } +static inline bool dsa_uses_tagged_protocol (struct dsa_switch_tree *dst) +{ +return dst->tag_protocol !=0 ; +} +#endif
net/dsa/slave.c +18 -1
@@ -181,6 +181,17 @@ static netdev_tx_t dsa_slave_xmit(struct sk_buff *skb, struct net_device *dev)return dst->ops->xmit (skb, dev); } +static netdev_tx_t dsa_slave_notag_xmit (struct sk_buff *skb, +struct net_device *dev) +{ +struct dsa_slave_priv *p =netdev_priv (dev); + + skb->dev = p->parent->dst->master_netdev; +dev_queue_xmit (skb); + +return NETDEV_TX_OK ; +} +/* ethtool operations *******************************************************/ static int
@@ -314,6 +325,11 @@ static const struct net_device_ops dsa_slave_netdev_ops = { .ndo_do_ioctl = dsa_slave_ioctl, }; +static const struct dsa_device_ops notag_netdev_ops = { + .xmit = dsa_slave_notag_xmit, + .rcv =NULL , +}; +static void dsa_slave_adjust_link (struct net_device *dev) {struct dsa_slave_priv *p =netdev_priv (dev);
@@ -415,7 +431,8 @@ dsa_slave_create(struct dsa_switch *ds, struct device *parent,break ;#endif default : -BUG (); + ds->dst->ops = ¬ag_netdev_ops; +break ; }SET_NETDEV_DEV (slave_dev, parent);
Signature · 1 line
1.9.1
PATCH v4 8/13 net: dsa: allow drivers to do link adjustment
In reply to Florian FainelliWhenever libphy determines that the link status of a given PHY/port has changed, allow to call into the switch driver link adjustment callback so proper actions can be taken care of by the switch driver upon link notification.
--- include/net/dsa.h | 7 +++++++ net/dsa/slave.c | 4 ++++ 2 files changed, 11 insertions(+)
include/net/dsa.h +7 -0
@@ -16,6 +16,7 @@#include <linux/timer.h> #include <linux/workqueue.h> #include <linux/of.h> +#include <linux/phy.h> #define DSA_MAX_SWITCHES 4#define DSA_MAX_PORTS 12
@@ -182,6 +183,12 @@ struct dsa_switch_driver {void (*poll_link)(struct dsa_switch *ds);/* +* Link state adjustment (called from libphy) +*/ +void (*adjust_link)(struct dsa_switch *ds,int port, +struct phy_device *phydev); + +/* * ethtool hardware statistics. */ void (*get_strings)(struct dsa_switch *ds,int port,uint8_t *data);
net/dsa/slave.c +4 -0
@@ -333,6 +333,7 @@ static const struct dsa_device_ops notag_netdev_ops = {static void dsa_slave_adjust_link (struct net_device *dev) {struct dsa_slave_priv *p =netdev_priv (dev); +struct dsa_switch *ds = p->parent;unsigned int status_changed =0 ;if (p->old_link != p->phy->link) {
@@ -350,6 +351,9 @@ static void dsa_slave_adjust_link(struct net_device *dev) p->old_pause = p->phy->pause; } +if (ds->drv->adjust_link && status_changed) + ds->drv->adjust_link (ds, p->port, p->phy); +if (status_changed)phy_print_status (p->phy); }
Signature · 1 line
1.9.1
PATCH v4 9/13 net: dsa: allow updating fixed PHY link information
In reply to Florian FainelliAllow switch drivers to hook a PHY link update callback to perform port-specific link work.
---
Changes in v4:
- changed phy_is_fixed from 'unsigned int' to 'bool'
include/net/dsa.h | 3 +++ net/dsa/slave.c | 17 +++++++++++++++++ 2 files changed, 20 insertions(+)
include/net/dsa.h +3 -0
@@ -17,6 +17,7 @@#include <linux/workqueue.h> #include <linux/of.h> #include <linux/phy.h> +#include <linux/phy_fixed.h> #define DSA_MAX_SWITCHES 4#define DSA_MAX_PORTS 12
@@ -187,6 +188,8 @@ struct dsa_switch_driver {*/ void (*adjust_link)(struct dsa_switch *ds,int port,struct phy_device *phydev); +void (*fixed_link_update)(struct dsa_switch *ds,int port, +struct fixed_phy_status *st);/* * ethtool hardware statistics.
net/dsa/slave.c +17 -0
@@ -358,6 +358,18 @@ static void dsa_slave_adjust_link(struct net_device *dev)phy_print_status (p->phy); } +static int dsa_slave_fixed_link_update (struct net_device *dev, +struct fixed_phy_status *status) +{ +struct dsa_slave_priv *p =netdev_priv (dev); +struct dsa_switch *ds = p->parent; + +if (ds->drv->fixed_link_update) + ds->drv->fixed_link_update (ds, p->port, status); + +return 0 ; +} +/* slave device setup *******************************************************/ static void dsa_slave_phy_setup (struct dsa_slave_priv *p,struct net_device *slave_dev)
@@ -365,6 +377,7 @@ static void dsa_slave_phy_setup(struct dsa_slave_priv *p,struct dsa_switch *ds = p->parent;struct dsa_chip_data *cd = ds->pd;struct device_node *phy_dn, *port_dn; +bool phy_is_fixed = false;int ret; port_dn = cd->port_dn[p->port];
@@ -380,6 +393,7 @@ static void dsa_slave_phy_setup(struct dsa_slave_priv *p,pr_err ("failed to register fixed PHY\n" );return ; } + phy_is_fixed = true; phy_dn = port_dn; }
@@ -388,6 +402,9 @@ static void dsa_slave_phy_setup(struct dsa_slave_priv *p, dsa_slave_adjust_link,0 , p->phy_interface); +if (p->phy && phy_is_fixed) +fixed_phy_set_link_update (p->phy, dsa_slave_fixed_link_update); +/* We could not connect to a designated PHY, so use the switch internal * MDIO bus instead */
Signature · 1 line
1.9.1
PATCH v4 10/13 net: dsa: add Broadcom tag RX/TX handler
In reply to Florian FainelliAdd support for the 4-bytes Broadcom tag that built-in switches such as the Starfighter 2 might insert when receiving packets, or that we need to insert while targetting specific switch ports. We use a fake EtherType field for this 4-bytes switch tag: ETH_P_BRCMTAG to make sure we can assign DSA-specific network operations.
---
Changes in v4:
- reworked changes to match the new dsa_device_ops introduced in patch 1
Changes in v3:
- add ETH_P_BRCMTAG as part of this changeset and not in a previous patch
- fixed an early de-reference in the receive hook
include/uapi/linux/if_ether.h | 1 + net/dsa/Kconfig | 3 + net/dsa/Makefile | 1 + net/dsa/dsa_priv.h | 3 + net/dsa/slave.c | 5 ++ net/dsa/tag_brcm.c | 173 ++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 186 insertions(+) create mode 100644 net/dsa/tag_brcm.c
include/uapi/linux/if_ether.h +1 -0
@@ -128,6 +128,7 @@#define ETH_P_PHONET 0x00F5/* Nokia Phonet frames */ #define ETH_P_IEEE802154 0x00F6/* IEEE802.15.4 frame */ #define ETH_P_CAIF 0x00F7/* ST-Ericsson CAIF protocol */ +#define ETH_P_BRCMTAG 0x00F8/* Broadcom tag (4 bytes *) */ /* * This is an Ethernet frame header.
net/dsa/Kconfig +3 -0
@@ -12,6 +12,9 @@ config NET_DSA if NET_DSA # tagging formats +config NET_DSA_TAG_BRCM + bool + config NET_DSA_TAG_DSA bool
net/dsa/Makefile +1 -0
@@ -3,6 +3,7 @@ obj-$(CONFIG_NET_DSA) += dsa_core.o dsa_core-y += dsa.o slave.o # tagging formats +dsa_core-$(CONFIG_NET_DSA_TAG_BRCM) += tag_brcm.o dsa_core-$(CONFIG_NET_DSA_TAG_DSA) += tag_dsa.o dsa_core-$(CONFIG_NET_DSA_TAG_EDSA) += tag_edsa.o dsa_core-$(CONFIG_NET_DSA_TAG_TRAILER) += tag_trailer.o
net/dsa/dsa_priv.h +3 -0
@@ -57,5 +57,8 @@ extern const struct dsa_device_ops edsa_netdev_ops;/* tag_trailer.c */ extern const struct dsa_device_ops trailer_netdev_ops; +/* tag_brcm.c */ +extern const struct dsa_device_ops brcm_netdev_ops; +#endif
net/dsa/slave.c +5 -0
@@ -451,6 +451,11 @@ dsa_slave_create(struct dsa_switch *ds, struct device *parent, ds->dst->ops = &trailer_netdev_ops;break ;#endif +#ifdef CONFIG_NET_DSA_TAG_BRCM +case htons (ETH_P_BRCMTAG ): + ds->dst->ops = &brcm_netdev_ops; +break ; +#endif default : ds->dst->ops = ¬ag_netdev_ops;break ;
net/dsa/tag_brcm.c new file +173 -0
173 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v4 11/13 net: dsa: add Broadcom SF2 switch driver
In reply to Florian FainelliAdd support for the Broadcom Starfigther 2 switch chip using a DSA driver. This switch driver supports the following features:
- configuration of the external switch port interface: MII, RevMII, RGMII and RGMII_NO_ID are supported
- support for the per-port MIB counters
- support for link interrupts for special ports (e.g: MoCA)
- powering up/down of switch memories to conserve power when ports are unused
Finally, update the compatible property for the DSA core code to match our switch top-level compatible node.
---
Changes in v4:
- fixed typo on the word Starfighter
- fixed a few checkpatch.pl warnings
No changes in v3
Changes in v2:
- add support for reading to special MDIO phys (0 and 30)
- added more power down optimization
- added VLAN separation
drivers/net/dsa/Kconfig | 11 + drivers/net/dsa/Makefile | 1 + drivers/net/dsa/bcm_sf2.c | 626 +++++++++++++++++++++++++++++++++++++++++ drivers/net/dsa/bcm_sf2.h | 140 +++++++++ drivers/net/dsa/bcm_sf2_regs.h | 227 +++++++++++++++ net/dsa/dsa.c | 1 + 6 files changed, 1006 insertions(+) create mode 100644 drivers/net/dsa/bcm_sf2.c create mode 100644 drivers/net/dsa/bcm_sf2.h create mode 100644 drivers/net/dsa/bcm_sf2_regs.h
drivers/net/dsa/Kconfig +11 -0
@@ -36,4 +36,15 @@ config NET_DSA_MV88E6123_61_65 This enables support for the Marvell 88E6123/6161/6165 ethernet switch chips. +config NET_DSA_BCM_SF2 + tristate "Broadcom Starfighter 2 Ethernet switch support" + select NET_DSA + select NET_DSA_TAG_BRCM + select FIXED_PHY if NET_DSA_BCM_SF2=y + select BCM7XXX_PHY + select MDIO_BCM_UNIMAC + ---help--- + This enables support for the Broadcom Starfighter 2 Ethernet + switch chips. + endmenu
drivers/net/dsa/Makefile +1 -0
@@ -7,3 +7,4 @@ endif ifdef CONFIG_NET_DSA_MV88E6131 mv88e6xxx_drv-y += mv88e6131.o endif +obj-$(CONFIG_NET_DSA_BCM_SF2) += bcm_sf2.o
drivers/net/dsa/bcm_sf2.c new file +626 -0
626 lines not on this page · raw message
drivers/net/dsa/bcm_sf2.h new file +140 -0
140 lines not on this page · raw message
drivers/net/dsa/bcm_sf2_regs.h new file +227 -0
227 lines not on this page · raw message
net/dsa/dsa.c +1 -0
@@ -635,6 +635,7 @@ struct packet_type dsa_pack_type __read_mostly = { };static const struct of_device_id dsa_of_match_table[] = { + { .compatible ="brcm,bcm7445-switch-v4.0" }, { .compatible ="marvell,dsa" , }, {} };
Signature · 1 line
1.9.1
PATCH v4 12/13 Documentation: devicetree: update dsa binding with optional properties
In reply to Florian FainelliAdd documentation for a bunch of new optional properties described in ethernet.txt and fixed-link.txt, this includes: 'phy-handle', 'phy-mode' and the 'fixed-link' subnode.
--- Documentation/devicetree/bindings/net/dsa/dsa.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
Documentation/devicetree/bindings/net/dsa/dsa.txt +17 -0
@@ -39,6 +39,22 @@ Optionnal property: This property is only used when switches are being chained/cascaded together. +- 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 designeted + PHY node specified by the 'phy-handle' property. See + Documentation/devicetree/bindings/net/ethernet.txt + for details. + +Optionnal 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 {
@@ -58,6 +74,7 @@ Example: port@0 { reg = <0>; label = "lan1"; + phy-handle = <&phy0>; }; port@1 {
Signature · 1 line
1.9.1
Re: [PATCH net-next v4 12/13] Documentation: devicetree: update dsa binding with optional properties
Hello.
Quoted 14 lines · Florian Fainelli
Add documentation for a bunch of new optional properties described in ethernet.txt and fixed-link.txt, this includes: 'phy-handle', 'phy-mode' and the 'fixed-link' subnode.
Signed-off-by Florian Fainelli <[email protected]>--- Documentation/devicetree/bindings/net/dsa/dsa.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)Documentation/devicetree/bindings/net/dsa/dsa.txt +0
-0
Documentation/devicetree/bindings/net/dsa/dsa.txt Optionnal property: · line 47
Quoted 9 lines
Documentation/devicetree/bindings/net/dsa/dsa.txt +6
-0@@ -39,6 +39,22 @@ Optionnal property: This property is only used when switches are being chained/cascaded together. +- 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 designeted
Designated?
Documentation/devicetree/bindings/net/dsa/dsa.txt Optionnal property: · line 52
Quoted 5 lines
Documentation/devicetree/bindings/net/dsa/dsa.txt +5
-0+ PHY node specified by the 'phy-handle' property. See + Documentation/devicetree/bindings/net/ethernet.txt + for details. + +Optionnal subnodes:
One 'n' is enough (although DaveM may disagree ;-).
WBR, Sergei
PATCH v4 13/13 Documentation: devicetree: add Broadcom Starfighter 2 binding
In reply to Florian FainelliAdd the binding documentation for the Broadcom Starfighter 2 integrated switch hardware.
--- .../devicetree/bindings/net/broadcom-sf2.txt | 78 ++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/broadcom-sf2.txt
Documentation/devicetree/bindings/net/broadcom-sf2.txt new file +78 -0
@@ -0,0 +1,78 @@ +* Broadcom Starfighter 2 integrated swich + +Required properties: + +- compatible: should be "brcm,bcm7445-switch-v4.0" +- reg: addresses and length of the register sets for the device, must be 6 + pairs of register addresses and lengths +- interrupts: interrupts for the devices, must be two interrupts +- dsa,mii-bus: phandle to the MDIO bus controller, see dsa/dsa.txt +- dsa,ethernet: phandle to the CPU network interface controller, see dsa/dsa.txt +- #size-cells: must be 0 +- #address-cells: must be 2, see dsa/dsa.txt + +Subnodes: + +The integrated switch subnode should be specified according to the binding +described in dsa/dsa.txt. + +Optional properties: + +- reg-names: litteral names for the device base register addresses, when present + must be: "core", "reg", "intrl2_0", "intrl2_1", "fcb", "acb" + +- interrupt-names: litternal names for the device interrupt lines, when present + must be: "switch_0" and "switch_1" + +- brcm,num-gphy: specify the maximum number of integrated gigabit PHYs in the + switch + +- brcm,num-rgmii-ports: specify the maximum number of RGMII interfaces supported + by the switch + +- brcm,fcb-pause-override: boolean property, if present indicates that the switch + supports Failover Control Block pause override capability + +- brcm,acb-packets-inflight: boolean property, if present indicates that the switch + Admission Control Block supports reporting the number of packets in-flight in a + switch queue + +Example: + +switch_top@f0b00000 { + compatible = "simple-bus"; + #size-cells = <1>; + #address-cells = <1>; + ranges = <0 0xf0b00000 0x40804>; + + ethernet_switch@0 { + compatible = "brcm,bcm7445-switch-v4.0"; + #size-cells = <0>; + #address-cells = <2>; + reg = <0x0 0x40000 + 0x40000 0x110 + 0x40340 0x30 + 0x40380 0x30 + 0x40400 0x34 + 0x40600 0x208>; + interrupts = <0 0x18 0 + 0 0x19 0>; + brcm,num-gphy = <1>; + brcm,num-rgmii-ports = <2>; + brcm,fcb-pause-override; + brcm,acb-packets-inflight; + + ... + switch@0 { + reg = <0 0>; + #size-cells = <0>; + #address-cells <1>; + + port@0 { + label = "gphy"; + reg = <0>; + }; + ... + }; + }; +};
Signature · 1 line
1.9.1