Skip to contentSkip to conversation

dsa: support for Broadcom Starfighter 2

PATCH Superseded Florian Fainelli 4 participants 18 messages Aug 5, 2014 – Aug 6, 2014

Subsystems (6)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v2 cover dsa: support for Broadcom Starfighter 2

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 extend the new ARM-based Wi-Fi routers although slightly differently.

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

Thanks!

Florian Fainelli (12):
net: phy: add generic UniMAC MDIO bus driver
net: dsa: add Broadcom tag hook
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                          | 139 +++++
 drivers/net/dsa/bcm_sf2_regs.h                     | 228 ++++++++
 drivers/net/phy/Kconfig                            |   6 +
 drivers/net/phy/Makefile                           |   1 +
 drivers/net/phy/mdio-bcm-unimac.c                  | 212 +++++++
 include/linux/netdevice.h                          |  10 +
 include/net/dsa.h                                  |  24 +
 include/uapi/linux/if_ether.h                      |   1 +
 net/dsa/Kconfig                                    |   3 +
 net/dsa/Makefile                                   |   1 +
 net/dsa/dsa.c                                      |  15 +
 net/dsa/dsa_priv.h                                 |   8 +
 net/dsa/slave.c                                    | 153 ++++-
 net/dsa/tag_brcm.c                                 | 170 ++++++
 net/ethernet/eth.c                                 |   2 +
 21 files changed, 1738 insertions(+), 7 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
#1 lore raw

PATCH v2 1/12 net: phy: add generic UniMAC MDIO bus driver

Add 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 v2:

- improved binding documentation with respect to the HW setups available influencing interrupts

 .../bindings/net/broadcom-mdio-unimac.txt          |  39 ++++
 drivers/net/phy/Kconfig                            |   6 +
 drivers/net/phy/Makefile                           |   1 +
 drivers/net/phy/mdio-bcm-unimac.c                  | 212 +++++++++++++++++++++
 4 files changed, 258 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
new file mode 100644
index 000000000000..ab0bb4247d14
@@ -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 +6 -0
index 65de0cab8d07..3e00f3adc91c 100644
@@ -205,6 +205,12 @@ 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.
+	  It is required by the Broadcom GENET Ethernet device drivers.
+
 endif # PHYLIB
 
 config MICREL_KS8995MA
drivers/net/phy/Makefile +1 -0
index 7dc3d5b304cf..eb3b18b5978b 100644
@@ -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
#2 lore raw

PATCH v2 2/12 net: dsa: add Broadcom tag hook

In reply to Florian Fainelli

Register a fake Ethertype for the Broadcom tag to allow us to hook into a given Ethernet device receive path and parse this Broadcom tag.

---
 include/linux/netdevice.h     | 10 ++++++++++
 include/net/dsa.h             |  5 +++++
 include/uapi/linux/if_ether.h |  1 +
 net/ethernet/eth.c            |  2 ++
 4 files changed, 18 insertions(+)
include/linux/netdevice.h +10 -0
index 38377392d082..290b44ceefec 100644
@@ -1801,6 +1801,16 @@ static inline bool netdev_uses_trailer_tags(struct net_device *dev)
 	return 0;
 }
 
+static inline bool netdev_uses_brcm_tags(struct net_device *dev)
+{
+#ifdef CONFIG_NET_DSA_TAG_BRCM
+	if (dev->dsa_ptr != NULL)
+		return dsa_uses_brcm_tags(dev->dsa_ptr);
+#endif
+
+	return 0;
+}
+
 /**
  *	netdev_priv - access network device private data
  *	@dev: network device
include/net/dsa.h +5 -0
index 6efce384451e..0ada9c814ff9 100644
@@ -203,4 +203,9 @@ static inline bool dsa_uses_trailer_tags(struct dsa_switch_tree *dst)
 	return !!(dst->tag_protocol == htons(ETH_P_TRAILER));
 }
 
+static inline bool dsa_uses_brcm_tags(struct dsa_switch_tree *dst)
+{
+	return !!(dst->tag_protocol == htons(ETH_P_BRCMTAG));
+}
+
 #endif
include/uapi/linux/if_ether.h +1 -0
index 0f8210b8e0bc..2e9f13768abd 100644
@@ -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/ethernet/eth.c +2 -0
index f405e0592407..6b67653d5283 100644
@@ -186,6 +186,8 @@ __be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev)
 
 	if (unlikely(netdev_uses_trailer_tags(dev)))
 		return htons(ETH_P_TRAILER);
+	if (netdev_uses_brcm_tags(dev))
+		return htons(ETH_P_BRCMTAG);
 
 	if (likely(ntohs(eth->h_proto) >= ETH_P_802_3_MIN))
 		return eth->h_proto;
Signature · 1 line
1.9.1
#3 lore raw

Re: [PATCH net-next v2 02/12] net: dsa: add Broadcom tag hook

Hello.

Quoted 4 lines · Florian Fainelli

Register a fake Ethertype for the Broadcom tag to allow us to hook into a given Ethernet device receive path and parse this Broadcom tag.

[...]

include/net/dsa.h static inline bool dsa_uses_trailer_tags(struct dsa_switch_tree *dst) · line 208

Quoted 11 lines
include/net/dsa.h +3 -0
index 6efce384451e..0ada9c814ff9 100644
@@ -203,4 +203,9 @@ static inline bool dsa_uses_trailer_tags(struct dsa_switch_tree *dst)
  	return !!(dst->tag_protocol == htons(ETH_P_TRAILER));
  }
 
+static inline bool dsa_uses_brcm_tags(struct dsa_switch_tree *dst)
+{
+	return !!(dst->tag_protocol == htons(ETH_P_BRCMTAG));

Er, !! doesn't seem needed here.

include/net/dsa.h static inline bool dsa_uses_trailer_tags(struct dsa_switch_tree *dst) · line 211

Quoted 3 lines
include/net/dsa.h +2 -0
+}
+
  #endif

WBR, Sergei

#4 lore raw

Re: [PATCH net-next v2 02/12] net: dsa: add Broadcom tag hook

In reply to Florian Fainelli
Quoted 64 lines · Florian Fainelli

Register a fake Ethertype for the Broadcom tag to allow us to hook into a given Ethernet device receive path and parse this Broadcom tag.

---
 include/linux/netdevice.h     | 10 ++++++++++
 include/net/dsa.h             |  5 +++++
 include/uapi/linux/if_ether.h |  1 +
 net/ethernet/eth.c            |  2 ++
 4 files changed, 18 insertions(+)
include/linux/netdevice.h +10 -0
index 38377392d082..290b44ceefec 100644
@@ -1801,6 +1801,16 @@ static inline bool netdev_uses_trailer_tags(struct net_device *dev)
 	return 0;
 }
 
+static inline bool netdev_uses_brcm_tags(struct net_device *dev)
+{
+#ifdef CONFIG_NET_DSA_TAG_BRCM
+	if (dev->dsa_ptr != NULL)
+		return dsa_uses_brcm_tags(dev->dsa_ptr);
+#endif
+
+	return 0;
+}
+
 /**
  *	netdev_priv - access network device private data
  *	@dev: network device
include/net/dsa.h +5 -0
index 6efce384451e..0ada9c814ff9 100644
@@ -203,4 +203,9 @@ static inline bool dsa_uses_trailer_tags(struct dsa_switch_tree *dst)
 	return !!(dst->tag_protocol == htons(ETH_P_TRAILER));
 }
 
+static inline bool dsa_uses_brcm_tags(struct dsa_switch_tree *dst)
+{
+	return !!(dst->tag_protocol == htons(ETH_P_BRCMTAG));
+}
+
 #endif
include/uapi/linux/if_ether.h +1 -0
index 0f8210b8e0bc..2e9f13768abd 100644
@@ -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/ethernet/eth.c +0 -0
index f405e0592407..6b67653d5283 100644

net/ethernet/eth.c __be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev) · line 193

Quoted 8 lines
net/ethernet/eth.c +2 -0
@@ -186,6 +186,8 @@ __be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev)
 
 	if (unlikely(netdev_uses_trailer_tags(dev)))
 		return htons(ETH_P_TRAILER);
+	if (netdev_uses_brcm_tags(dev))
+		return htons(ETH_P_BRCMTAG);
 
 	if (likely(ntohs(eth->h_proto) >= ETH_P_802_3_MIN))
 		return eth->h_proto;

Maybe we should consider some change to this logic. Maybe a bit flag in the dsa_switch_tree structure that indicates if eth_type_trans should override the protocol or not. Otherwise this is going to start becoming a rather large conditional statement if we have to add a new if every time a new switch is added.

Thanks,

Alex

#5 lore raw

Re: [PATCH net-next v2 02/12] net: dsa: add Broadcom tag hook

Quoted 5 lines · Alexander Duyck
Quoted 4 lines · Florian Fainelli

Register a fake Ethertype for the Broadcom tag to allow us to hook into a given Ethernet device receive path and parse this Broadcom tag.

[snip]

Quoted 11 lines
Quoted 11 lines
net/ethernet/eth.c +2 -0
index f405e0592407..6b67653d5283 100644
@@ -186,6 +186,8 @@ __be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev)
 
 	if (unlikely(netdev_uses_trailer_tags(dev)))
 		return htons(ETH_P_TRAILER);
+	if (netdev_uses_brcm_tags(dev))
+		return htons(ETH_P_BRCMTAG);
 
Quoted 7 lines

net/ethernet/eth.c __be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev) · line 193

Quoted 3 lines
net/ethernet/eth.c +0 -0
 	if (likely(ntohs(eth->h_proto) >= ETH_P_802_3_MIN))
 		return eth->h_proto;

Maybe we should consider some change to this logic. Maybe a bit flag in the dsa_switch_tree structure that indicates if eth_type_trans should override the protocol or not.

I just tested something like this, which becomes protocol agnostic:

if (unlikely(netdev_uses_dsa(dev)))

	return dsa_tag_protocol(dev);

include/linux/netdevice.h:
static inline bool netdev_uses_dsa(struct net_device *dev) {

#ifdef CONFIG_NET_DSA
	return dev->dsa_ptr != NULL;
#else
	return false;

#endif
}

include/net/dsa.h:
static __be16 netdev_dsa_protocol(struct net_device *dev) {

#ifdef CONFIG_NET_DSA
	struct dsa_switch_tree *dst = dev->dsa_ptr;
	return dst->tag_protocol;

#endif
}

Quoted 3 lines

Otherwise this is going to start becoming
a rather large conditional statement if we have to add a new if every time a new switch is added.

Agreed.

Quoted 5 lines

Thanks,

Alex

#6 lore raw

Re: [PATCH net-next v2 02/12] net: dsa: add Broadcom tag hook

Quoted 49 lines · Florian Fainelli
Quoted 5 lines · Alexander Duyck
Quoted 4 lines · Florian Fainelli

Register a fake Ethertype for the Broadcom tag to allow us to hook into a given Ethernet device receive path and parse this Broadcom tag.

[snip]

Quoted 11 lines
Quoted 11 lines
net/ethernet/eth.c +2 -0
index f405e0592407..6b67653d5283 100644
@@ -186,6 +186,8 @@ __be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev)
 
 	if (unlikely(netdev_uses_trailer_tags(dev)))
 		return htons(ETH_P_TRAILER);
+	if (netdev_uses_brcm_tags(dev))
+		return htons(ETH_P_BRCMTAG);
 
Quoted 7 lines

net/ethernet/eth.c __be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev) · line 193

Quoted 3 lines
net/ethernet/eth.c +0 -0
 	if (likely(ntohs(eth->h_proto) >= ETH_P_802_3_MIN))
 		return eth->h_proto;

Maybe we should consider some change to this logic. Maybe a bit flag in the dsa_switch_tree structure that indicates if eth_type_trans should override the protocol or not.

I just tested something like this, which becomes protocol agnostic:

if (unlikely(netdev_uses_dsa(dev)))

	return dsa_tag_protocol(dev);

include/linux/netdevice.h:
static inline bool netdev_uses_dsa(struct net_device *dev) {

#ifdef CONFIG_NET_DSA
	return dev->dsa_ptr != NULL;
#else
	return false;

#endif
}

include/net/dsa.h:
static __be16 netdev_dsa_protocol(struct net_device *dev) {

#ifdef CONFIG_NET_DSA
	struct dsa_switch_tree *dst = dev->dsa_ptr;
	return dst->tag_protocol;
Quoted 9 lines

#endif
}

Quoted 3 lines

Otherwise this is going to start becoming
a rather large conditional statement if we have to add a new if every time a new switch is added.

Agreed.

I think EDSA does not have same logic for inserting the tags. You may want to look into that to determine if this is acceptable for that case or not.

Thanks,

Alex

#7 lore raw

PATCH v2 3/12 net: dsa: provide a switch device device tree node pointer

In reply to Florian Fainelli

We 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
index 0ada9c814ff9..9a16c5290738 100644
@@ -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
index 0a49632fac47..069586547cf5 100644
@@ -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
#8 lore raw

PATCH v2 4/12 net: dsa: retain a per-port device_node pointer

In reply to Florian Fainelli

We will later use the per-port device_node pointer to fetch a bunch of port-specific properties.

---
Changes in v2:
- assign slave_dev->dev.of_node for various OF routines to work correctly

 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
index 9a16c5290738..c435eaa772d5 100644
@@ -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
index 069586547cf5..788b2b2f39f2 100644
@@ -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
index 45a1e34c89e0..9e4d3816c54e 100644
@@ -371,6 +371,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
#9 lore raw

PATCH v2 5/12 net: dsa: allow for more complex PHY setups

In reply to Florian Fainelli

Modify 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 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
index c435eaa772d5..35141155f368 100644
@@ -127,6 +127,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
index 788b2b2f39f2..62f2f4e67d7d 100644
@@ -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
index d4cf5cc747e3..a7f6f0c5fa31 100644
@@ -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
#10 lore raw

PATCH v2 6/12 net: dsa: allow switches to work without tagging

In reply to Florian Fainelli

In case switch port tagging is disabled (voluntarily, or the switch just does not support it), allow us to continue using the master net_device operations instead of the tag-specific ones.

---
 net/dsa/slave.c | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)
net/dsa/slave.c +24 -1
index b4b6d457bfd0..d1dfa3d8552f 100644
@@ -332,6 +332,28 @@ static const struct net_device_ops trailer_netdev_ops = {
 };
 #endif
 
+static netdev_tx_t dsa_slave_dummy_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;
+}
+
+static const struct net_device_ops dummy_netdev_ops = {
+	.ndo_init		= dsa_slave_init,
+	.ndo_open		= dsa_slave_open,
+	.ndo_stop		= dsa_slave_close,
+	.ndo_start_xmit		= dsa_slave_dummy_xmit,
+	.ndo_change_rx_flags	= dsa_slave_change_rx_flags,
+	.ndo_set_rx_mode	= dsa_slave_set_rx_mode,
+	.ndo_set_mac_address	= dsa_slave_set_mac_address,
+	.ndo_do_ioctl		= dsa_slave_ioctl,
+};
+
 static void dsa_slave_adjust_link(struct net_device *dev)
 {
 	struct dsa_slave_priv *p = netdev_priv(dev);
@@ -432,7 +454,8 @@ dsa_slave_create(struct dsa_switch *ds, struct device *parent,
 		break;
 #endif
 	default:
-		BUG();
+		slave_dev->netdev_ops = &dummy_netdev_ops;
+		break;
 	}
 
 	SET_NETDEV_DEV(slave_dev, parent);
Signature · 1 line
1.9.1
#11 lore raw

PATCH v2 7/12 net: dsa: allow drivers to do link adjustment

In reply to Florian Fainelli

Whenever 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
index 35141155f368..e024511dbcdb 100644
@@ -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
@@ -179,6 +180,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
index d1dfa3d8552f..08a92db7f109 100644
@@ -357,6 +357,7 @@ static const struct net_device_ops dummy_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) {
@@ -374,6 +375,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
#12 lore raw

PATCH v2 8/12 net: dsa: allow updating fixed PHY link information

In reply to Florian Fainelli

Allow switch drivers to hook a PHY link update callback to perform port-specific link work.

---
 include/net/dsa.h |  3 +++
 net/dsa/slave.c   | 17 +++++++++++++++++
 2 files changed, 20 insertions(+)
include/net/dsa.h +3 -0
index e024511dbcdb..983c8400fd09 100644
@@ -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
@@ -184,6 +185,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
index 08a92db7f109..129eadf3a657 100644
@@ -382,6 +382,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)
@@ -389,6 +401,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];
@@ -404,6 +417,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;
 	}
 
@@ -412,6 +426,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
#13 lore raw

PATCH v2 9/12 net: dsa: add Broadcom tag RX/TX handler

In reply to Florian Fainelli

Add 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.

---
 net/dsa/Kconfig    |   3 +
 net/dsa/Makefile   |   1 +
 net/dsa/dsa.c      |   6 ++
 net/dsa/dsa_priv.h |   4 ++
 net/dsa/slave.c    |  17 ++++++
 net/dsa/tag_brcm.c | 171 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 202 insertions(+)
 create mode 100644 net/dsa/tag_brcm.c
net/dsa/Kconfig +3 -0
index f5eede1d6cb8..a585fd6352eb 100644
@@ -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
index 7b9fcbbeda5d..da06ed1df620 100644
@@ -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.c +6 -0
index 62f2f4e67d7d..cd33ddf6ff4f 100644
@@ -650,6 +650,9 @@ static int __init dsa_init_module(void)
 #ifdef CONFIG_NET_DSA_TAG_TRAILER
 	dev_add_pack(&trailer_packet_type);
 #endif
+#ifdef CONFIG_NET_DSA_TAG_BRCM
+	dev_add_pack(&brcm_tag_packet_type);
+#endif
 	return 0;
 }
 module_init(dsa_init_module);
@@ -665,6 +668,9 @@ static void __exit dsa_cleanup_module(void)
 #ifdef CONFIG_NET_DSA_TAG_DSA
 	dev_remove_pack(&dsa_packet_type);
 #endif
+#ifdef CONFIG_NET_DSA_TAG_BRCM
+	dev_remove_pack(&brcm_tag_packet_type);
+#endif
 	platform_driver_unregister(&dsa_driver);
 }
 module_exit(dsa_cleanup_module);
net/dsa/dsa_priv.h +4 -0
index a7f6f0c5fa31..8fb71da70dd6 100644
@@ -60,5 +60,9 @@ extern struct packet_type edsa_packet_type;
 netdev_tx_t trailer_xmit(struct sk_buff *skb, struct net_device *dev);
 extern struct packet_type trailer_packet_type;
 
+/* tag_brcm.c */
+netdev_tx_t brcm_tag_xmit(struct sk_buff *skb, struct net_device *dev);
+extern struct packet_type brcm_tag_packet_type;
+
 
 #endif
net/dsa/slave.c +17 -0
index 129eadf3a657..d86309271446 100644
@@ -295,6 +295,18 @@ static const struct ethtool_ops dsa_slave_ethtool_ops = {
 	.get_sset_count		= dsa_slave_get_sset_count,
 };
 
+#ifdef CONFIG_NET_DSA_TAG_BRCM
+static const struct net_device_ops brcm_netdev_ops = {
+	.ndo_init		= dsa_slave_init,
+	.ndo_open		= dsa_slave_open,
+	.ndo_stop		= dsa_slave_close,
+	.ndo_start_xmit		= brcm_tag_xmit,
+	.ndo_change_rx_flags	= dsa_slave_change_rx_flags,
+	.ndo_set_rx_mode	= dsa_slave_set_rx_mode,
+	.ndo_set_mac_address	= dsa_slave_set_mac_address,
+	.ndo_do_ioctl		= dsa_slave_ioctl,
+};
+#endif
 #ifdef CONFIG_NET_DSA_TAG_DSA
 static const struct net_device_ops dsa_netdev_ops = {
 	.ndo_init		= dsa_slave_init,
@@ -474,6 +486,11 @@ dsa_slave_create(struct dsa_switch *ds, struct device *parent,
 		slave_dev->netdev_ops = &trailer_netdev_ops;
 		break;
 #endif
+#ifdef CONFIG_NET_DSA_TAG_BRCM
+	case htons(ETH_P_BRCMTAG):
+		slave_dev->netdev_ops = &brcm_netdev_ops;
+		break;
+#endif
 	default:
 		slave_dev->netdev_ops = &dummy_netdev_ops;
 		break;
net/dsa/tag_brcm.c new file +171 -0

171 lines not on this page · raw message

Signature · 1 line
1.9.1
#14 lore raw

PATCH v2 10/12 net: dsa: add Broadcom SF2 switch driver

In reply to Florian Fainelli

Add 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 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      | 139 +++++++++
 drivers/net/dsa/bcm_sf2_regs.h | 228 +++++++++++++++
 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
index b8fe808b7957..3472af31821f 100644
@@ -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
+	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
index f3bda05536cc..dd3cd3b8157f 100644
@@ -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 +139 -0

139 lines not on this page · raw message

drivers/net/dsa/bcm_sf2_regs.h new file +228 -0

228 lines not on this page · raw message

net/dsa/dsa.c +1 -0
index cd33ddf6ff4f..65c6068a9435 100644
@@ -617,6 +617,7 @@ static void dsa_shutdown(struct platform_device *pdev)
 }
 
 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
#15 lore raw

PATCH v2 11/12 Documentation: devicetree: update dsa binding with optional properties

In reply to 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.

---
 Documentation/devicetree/bindings/net/dsa/dsa.txt | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
Documentation/devicetree/bindings/net/dsa/dsa.txt +17 -0
index 49f4f7ae3f51..6192f9a7aa89 100644
@@ -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
#16 lore raw

PATCH v2 12/12 Documentation: devicetree: add Broadcom Starfighter 2 binding

In reply to Florian Fainelli

Add 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
new file mode 100644
index 000000000000..30d487597ecb
@@ -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
maintainer
#17 lore raw
In reply to Florian Fainelli

From: Florian Fainelli <[email protected]>
Date: Tue, 5 Aug 2014 15:31:34 -0700

Quoted 15 lines

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 extend the new ARM-based Wi-Fi routers although slightly differently.

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

Quoted 6 lines

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

Sorry Florian, the merge window just openned up so I have to stop accepting new features.

Please repost this after I open the net-next tree up again, thanks a lot.