Skip to contentSkip to conversation

dsa: support for Broadcom Starfighter 2

PATCH Superseded Florian Fainelli 5 participants 22 messages Aug 24, 2014 – Aug 26, 2014

Subsystems (6)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

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

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 (12):
net: dsa: rework skb->protocol override helpers
net: phy: add generic UniMAC MDIO bus driver
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                          |  16 +-
 include/net/dsa.h                                  |  30 +-
 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                                    | 140 ++++-
 net/dsa/tag_brcm.c                                 | 173 ++++++
 net/ethernet/eth.c                                 |   7 +-
 21 files changed, 1729 insertions(+), 23 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 v3 1/12 net: dsa: rework skb->protocol override helpers

DSA currently maintains one helper function per tagging protocol that does not insert a real ethertype in the Ethernet frame:
netdev_uses_dsa_tags() and netdev_uses_trailer_tags().

This patch reworks the logic to introduce two helper functions that makes the DSA tagging protocol checking more scalable to the addition of new tagging protocols.

The first helper function returns whether a DSA-enabled device is using a non-ethertype protocol, while the second helper does return the actual protocol value we should override skb->protocol with.

---
New patch in v3

 include/linux/netdevice.h | 16 +++++++---------
 include/net/dsa.h         | 11 ++++++-----
 net/ethernet/eth.c        |  7 ++-----
 3 files changed, 15 insertions(+), 19 deletions(-)
include/linux/netdevice.h +7 -9
index 7e2b0b8b5cd7..c0a033b0037c 100644
@@ -1781,23 +1781,21 @@ 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_tagging(struct net_device *dev)
 {
-#ifdef CONFIG_NET_DSA_TAG_DSA
+#ifdef CONFIG_NET_DSA
 	if (dev->dsa_ptr != NULL)
-		return dsa_uses_dsa_tags(dev->dsa_ptr);
+		return dsa_protocol_is_tagged(dev->dsa_ptr);
 #endif
-
-	return 0;
+	return false;
 }
 
-static inline bool netdev_uses_trailer_tags(struct net_device *dev)
+static inline __be16 netdev_dsa_tag_protocol(struct net_device *dev)
 {
-#ifdef CONFIG_NET_DSA_TAG_TRAILER
+#ifdef CONFIG_NET_DSA
 	if (dev->dsa_ptr != NULL)
-		return dsa_uses_trailer_tags(dev->dsa_ptr);
+		return dsa_tag_protocol(dev->dsa_ptr);
 #endif
-
 	return 0;
 }
 
include/net/dsa.h +6 -5
index 6efce384451e..36a397bfbd2e 100644
@@ -192,15 +192,16 @@ static inline void *ds_to_priv(struct dsa_switch *ds)
  * 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.
+ *
+ * ETH_P_EDSA is the only real ethertype currently supported
  */
-static inline bool dsa_uses_dsa_tags(struct dsa_switch_tree *dst)
+static inline bool dsa_protocol_is_tagged(struct dsa_switch_tree *dst)
 {
-	return !!(dst->tag_protocol == htons(ETH_P_DSA));
+	return dst->tag_protocol != ETH_P_EDSA;
 }
 
-static inline bool dsa_uses_trailer_tags(struct dsa_switch_tree *dst)
+static inline __be16 dsa_tag_protocol(struct dsa_switch_tree *dst)
 {
-	return !!(dst->tag_protocol == htons(ETH_P_TRAILER));
+	return dst->tag_protocol;
 }
-
 #endif
net/ethernet/eth.c +2 -5
index f405e0592407..4ca8e489bc3d 100644
@@ -181,11 +181,8 @@ __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)))
-		return htons(ETH_P_DSA);
-
-	if (unlikely(netdev_uses_trailer_tags(dev)))
-		return htons(ETH_P_TRAILER);
+	if (unlikely(netdev_uses_dsa_tagging(dev)))
+		return netdev_dsa_tag_protocol(dev);
 
 	if (likely(ntohs(eth->h_proto) >= ETH_P_802_3_MIN))
 		return eth->h_proto;
Signature · 1 line
1.9.1
#2 lore raw

PATCH v3 2/12 net: phy: add generic UniMAC MDIO bus driver

In reply to Florian Fainelli

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 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                            |   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
#3 lore raw

PATCH v3 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 36a397bfbd2e..91d5ba435ab6 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
#4 lore raw

PATCH v3 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.

---
 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 91d5ba435ab6..66bb036831fd 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
#5 lore raw

Re: [PATCH net-next v3 04/12] net: dsa: retain a per-port device_node pointer

Quoted 15 lines · Florian Fainelli

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

---
 include/net/dsa.h | 1 +
 net/dsa/dsa.c     | 2 ++
 net/dsa/slave.c   | 1 +
 3 files changed, 4 insertions(+)
include/net/dsa.h +0 -0
index 91d5ba435ab6..66bb036831fd 100644

include/net/dsa.h struct dsa_chip_data { · line 47

Quoted 7 lines
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]

It might make sense to place name and device_node pointers members of a port struct, and move that array of structs to the end of the dsa_chip_data structure.

Thanks,

ALex

#6 lore raw

Re: [PATCH net-next v3 04/12] net: dsa: retain a per-port device_node pointer

Quoted 21 lines · Alexander Duyck
Quoted 20 lines · Florian Fainelli

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

---
  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 91d5ba435ab6..66bb036831fd 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];
 
Quoted 6 lines

include/net/dsa.h struct dsa_chip_data { · line 47

Quoted 2 lines
include/net/dsa.h +0 -0
  	/*
  	 * An array (with nr_chips elements) of which element [a]

It might make sense to place name and device_node pointers members of a port struct, and move that array of structs to the end of the dsa_chip_data structure.

That's a good point, I will fix that.
--
Florian

#7 lore raw

Re: [PATCH net-next v3 04/12] net: dsa: retain a per-port device_node pointer

Quoted 22 lines · Florian Fainelli
Quoted 21 lines · Alexander Duyck
Quoted 20 lines · Florian Fainelli

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

---
  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 91d5ba435ab6..66bb036831fd 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];
 
Quoted 8 lines
Quoted 6 lines

include/net/dsa.h struct dsa_chip_data { · line 47

Quoted 2 lines
include/net/dsa.h +0 -0
      /*
       * An array (with nr_chips elements) of which element [a]

It might make sense to place name and device_node pointers members of a port struct, and move that array of structs to the end of the dsa_chip_data structure.

That's a good point, I will fix that.

I just realized that this structure is also used in arch/arm/* and arch/blackfin/*. While I can compile test this, I am kind of reluctant to make this change just now, maybe a little later in the net-next merge window, if that sounds okay with you?

Thanks
--
Florian

#8 lore raw

PATCH v3 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 66bb036831fd..89b44e8d2dc3 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
#9 lore raw

PATCH v3 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.

dsa_protocol_is_tagged() is updated to check that the switch driver tag_protocol field is not 0 to avoid overriding skb->protocol in the eth_type_trans().

---
Changes in v3:
- update logic with the helpers introduced in the firs patch set
- renamed dummy to notag

 include/net/dsa.h |  2 +-
 net/dsa/slave.c   | 25 ++++++++++++++++++++++++-
 2 files changed, 25 insertions(+), 2 deletions(-)
include/net/dsa.h +1 -1
index 89b44e8d2dc3..6620d4722efa 100644
@@ -206,7 +206,7 @@ static inline void *ds_to_priv(struct dsa_switch *ds)
  */
 static inline bool dsa_protocol_is_tagged(struct dsa_switch_tree *dst)
 {
-	return dst->tag_protocol != ETH_P_EDSA;
+	return (dst->tag_protocol != 0) && (dst->tag_protocol != ETH_P_EDSA);
 }
 
 static inline __be16 dsa_tag_protocol(struct dsa_switch_tree *dst)
net/dsa/slave.c +24 -1
index b4b6d457bfd0..35cd8b7a56b8 100644
@@ -332,6 +332,28 @@ static const struct net_device_ops trailer_netdev_ops = {
 };
 #endif
 
+static netdev_tx_t dsa_slave_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 notag_netdev_ops = {
+	.ndo_init		= dsa_slave_init,
+	.ndo_open		= dsa_slave_open,
+	.ndo_stop		= dsa_slave_close,
+	.ndo_start_xmit		= dsa_slave_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 = &notag_netdev_ops;
+		break;
 	}
 
 	SET_NETDEV_DEV(slave_dev, parent);
Signature · 1 line
1.9.1
#10 lore raw

Re: [PATCH net-next v3 06/12] net: dsa: allow switches to work without tagging

Quoted 65 lines · 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.

dsa_protocol_is_tagged() is updated to check that the switch driver tag_protocol field is not 0 to avoid overriding skb->protocol in the eth_type_trans().

---
Changes in v3:
- update logic with the helpers introduced in the firs patch set
- renamed dummy to notag

 include/net/dsa.h |  2 +-
 net/dsa/slave.c   | 25 ++++++++++++++++++++++++-
 2 files changed, 25 insertions(+), 2 deletions(-)
include/net/dsa.h +1 -1
index 89b44e8d2dc3..6620d4722efa 100644
@@ -206,7 +206,7 @@ static inline void *ds_to_priv(struct dsa_switch *ds)
  */
 static inline bool dsa_protocol_is_tagged(struct dsa_switch_tree *dst)
 {
-	return dst->tag_protocol != ETH_P_EDSA;
+	return (dst->tag_protocol != 0) && (dst->tag_protocol != ETH_P_EDSA);
 }
 
 static inline __be16 dsa_tag_protocol(struct dsa_switch_tree *dst)
net/dsa/slave.c +22 -0
index b4b6d457bfd0..35cd8b7a56b8 100644
@@ -332,6 +332,28 @@ static const struct net_device_ops trailer_netdev_ops = {
 };
 #endif
 
+static netdev_tx_t dsa_slave_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 notag_netdev_ops = {
+	.ndo_init		= dsa_slave_init,
+	.ndo_open		= dsa_slave_open,
+	.ndo_stop		= dsa_slave_close,
+	.ndo_start_xmit		= dsa_slave_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);

net/dsa/slave.c dsa_slave_create(struct dsa_switch *ds, struct device *parent, · line 461

Quoted 9 lines
net/dsa/slave.c +2 -1
@@ -432,7 +454,8 @@ dsa_slave_create(struct dsa_switch *ds, struct device *parent,
 		break;
 #endif
 	default:
-		BUG();
+		slave_dev->netdev_ops = &notag_netdev_ops;
+		break;
 	}
 
 	SET_NETDEV_DEV(slave_dev, parent);

Actually the more I look at this the more I think it might make sense to just have a pair of function pointers, maybe even a header ops structure that is maintained in the dsa_switch_tree for xmit and rcv. Then instead of having to define 4 slaves each with only one function different between them you could have just one function that calls the xmit function pointer contained in the dsa_switch_tree structure.

Thanks,

Alex

#11 lore raw

PATCH v3 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 6620d4722efa..4507c50d29a6 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 35cd8b7a56b8..893afe9e60aa 100644
@@ -357,6 +357,7 @@ static const struct net_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) {
@@ -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 v3 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 4507c50d29a6..9c0fd1b5e530 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 893afe9e60aa..ee019ec29dec 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;
+	unsigned int phy_is_fixed = 0;
 	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 = 1;
 		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
maintainer
#13 lore raw

Re: [PATCH net-next v3 08/12] net: dsa: allow updating fixed PHY link information

From: Florian Fainelli <[email protected]>
Date: Sun, 24 Aug 2014 11:44:25 -0700

net/dsa/slave.c static void dsa_slave_phy_setup(struct dsa_slave_priv *p, · line 404

Quoted 5 lines
net/dsa/slave.c +1 -0
@@ -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;
+	unsigned int phy_is_fixed = 0;

Please make this a bool.

#14 lore raw

Re: [PATCH net-next v3 08/12] net: dsa: allow updating fixed PHY link information

In reply to Florian Fainelli

Hello.

Quoted 4 lines · Florian Fainelli

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

[...]

Quoted 4 lines
net/dsa/slave.c +0 -0
index 893afe9e60aa..ee019ec29dec 100644

[...]

net/dsa/slave.c static void dsa_slave_phy_setup(struct dsa_slave_priv *p, · line 404

Quoted 5 lines
net/dsa/slave.c +1 -0
@@ -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;
+	unsigned int phy_is_fixed = 0;

Why not *bool*?

[...]

WBR, Sergei

#15 lore raw

PATCH v3 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. We use a fake EtherType field for this 4-bytes switch tag: ETH_P_BRCMTAG since we need to use the skb->protocol override in the receive path.

---
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.c                 |   6 ++
 net/dsa/dsa_priv.h            |   4 +
 net/dsa/slave.c               |  17 +++++
 net/dsa/tag_brcm.c            | 173 ++++++++++++++++++++++++++++++++++++++++++
 7 files changed, 205 insertions(+)
 create mode 100644 net/dsa/tag_brcm.c
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/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 ee019ec29dec..279728c53c91 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 = &notag_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
#16 lore raw

Re: [PATCH net-next v3 09/12] net: dsa: add Broadcom tag RX/TX handler

Quoted 11 lines · 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. We use a fake EtherType field for this 4-bytes switch tag: ETH_P_BRCMTAG since we need to use the skb->protocol override in the receive path.

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

I was just wondering. Is there a reason we need to register this as yet another protocol?

It seems like we should be able to just register one DSA tag protocol and then we could push the parsing function out to a function pointer contained in the DSA switch structure. My concern is that as we add each new switch message format we are looking at the potential for yet another Ethertype and they are a limited resource.

So for example in the section below you already have to dig out the dsa_switch structure and tree before you even start processing the headers.

Quoted 7 lines
net/dsa/tag_brcm.c new file +7 -0
+
+static int brcm_tag_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;
+	struct dsa_switch *ds;
+	int source_port;

net/dsa/tag_brcm.c line 120

Quoted 10 lines
net/dsa/tag_brcm.c new file +10 -0
+	u8 *brcm_tag;
+
+	if (unlikely(dst == NULL))
+		goto out_drop;
+
+	ds = dst->ds[0];
+
+	skb = skb_unshare(skb, GFP_ATOMIC);
+	if (skb == NULL)
+		goto out;

At this point here we already have the dsa pointers and could just pull up a function pointer so all of the code below could potentially be moved into a separate function allowing us to drop the need to have multiple Ethertypes and so we could just use ETH_P_DSA for all DSA tagging type. We could then also rewrite the check for if we need to insert a DSA tag to simply check for if this function pointer is set or not.

Quoted 52 lines
net/dsa/tag_brcm.c new file +52 -0
+	if (unlikely(!pskb_may_pull(skb, BRCM_TAG_LEN)))
+		goto out_drop;
+
+	/* skb->data points to the EtherType, the tag is right before it */
+	brcm_tag = skb->data - 2;
+
+	/* The opcode should never be different than 0b000 */
+	if (unlikely((brcm_tag[0] >> BRCM_OPCODE_SHIFT) & BRCM_OPCODE_MASK))
+		goto out_drop;
+
+	/* We should never see a reserved reason code without knowing how to
+	 * handle it
+	 */
+	WARN_ON(brcm_tag[2] & BRCM_EG_RC_RSVD);
+
+	/* Locate which port this is coming from */
+	source_port = brcm_tag[3] & BRCM_EG_PID_MASK;
+
+	/* Validate port against switch setup, either the port is totally */
+	if (source_port >= DSA_MAX_PORTS || ds->ports[source_port] == NULL)
+		goto out_drop;
+
+	/* Remove Broadcom tag and update checksum */
+	skb_pull_rcsum(skb, BRCM_TAG_LEN);
+
+	/* Move the Ethernet DA and SA */
+	memmove(skb->data - ETH_HLEN,
+		skb->data - ETH_HLEN - BRCM_TAG_LEN,
+		2 * ETH_ALEN);
+
+	skb_push(skb, ETH_HLEN);
+	skb->pkt_type = PACKET_HOST;
+	skb->dev = ds->ports[source_port];
+	skb->protocol = eth_type_trans(skb, skb->dev);
+
+	skb->dev->stats.rx_packets++;
+	skb->dev->stats.rx_bytes += skb->len;
+
+	netif_receive_skb(skb);
+
+	return 0;
+
+out_drop:
+	kfree_skb(skb);
+out:
+	return 0;
+}
+
+struct packet_type brcm_tag_packet_type __read_mostly = {
+	.type	= cpu_to_be16(ETH_P_BRCMTAG),
+	.func	= brcm_tag_rcv,
+};
#17 lore raw

Re: [PATCH net-next v3 09/12] net: dsa: add Broadcom tag RX/TX handler

Quoted 7 lines · Alexander Duyck
Quoted 6 lines · 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. We use a fake EtherType field for this 4-bytes switch tag: ETH_P_BRCMTAG since we need to use the skb->protocol override in the receive path.

Quoted 8 lines
Quoted 5 lines

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

I was just wondering. Is there a reason we need to register this as yet another protocol?

For the broadcom tag format, not specifically no, this is mostly so it looks like what has been done so far, but since this is not a real ethertype, there is no need for this.

Quoted 26 lines

It seems like we should be able to just register one DSA tag protocol and then we could push the parsing function out to a function pointer contained in the DSA switch structure. My concern is that as we add each new switch message format we are looking at the potential for yet another Ethertype and they are a limited resource.

So for example in the section below you already have to dig out the dsa_switch structure and tree before you even start processing the headers.

Quoted 15 lines
net/dsa/tag_brcm.c new file +15 -0
+
+static int brcm_tag_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;
+	struct dsa_switch *ds;
+	int source_port;
+	u8 *brcm_tag;
+
+	if (unlikely(dst == NULL))
+		goto out_drop;
+
+	ds = dst->ds[0];
+
+	skb = skb_unshare(skb, GFP_ATOMIC);
Quoted 8 lines

net/dsa/tag_brcm.c line 120

Quoted 2 lines
net/dsa/tag_brcm.c new file +2 -0
+	if (skb == NULL)
+		goto out;

At this point here we already have the dsa pointers and could just pull up a function pointer so all of the code below could potentially be moved into a separate function allowing us to drop the need to have multiple Ethertypes and so we could just use ETH_P_DSA for all DSA tagging type.

I see, or rather maybe just use ETH_P_EDSA which is a real assigned ethertype? --
Florian

#18 lore raw

Re: [PATCH net-next v3 09/12] net: dsa: add Broadcom tag RX/TX handler

Quoted 26 lines · Florian Fainelli
Quoted 16 lines · Alexander Duyck
Quoted 15 lines · Florian Fainelli
net/dsa/tag_brcm.c new file +15 -0
+
+static int brcm_tag_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;
+    struct dsa_switch *ds;
+    int source_port;
+    u8 *brcm_tag;
+
+    if (unlikely(dst == NULL))
+        goto out_drop;
+
+    ds = dst->ds[0];
+
+    skb = skb_unshare(skb, GFP_ATOMIC);
Quoted 8 lines

net/dsa/tag_brcm.c line 120

Quoted 2 lines
net/dsa/tag_brcm.c new file +2 -0
+    if (skb == NULL)
+        goto out;

At this point here we already have the dsa pointers and could just pull up a function pointer so all of the code below could potentially be moved into a separate function allowing us to drop the need to have multiple Ethertypes and so we could just use ETH_P_DSA for all DSA tagging type.

Quoted 4 lines

I see, or rather maybe just use ETH_P_EDSA which is a real assigned ethertype?

Signature · 1 line
Florian

I suppose we could probably do that. Although I would probably say we should just rename it to ETH_P_DSA since we can just go through and drop all of the other defined Ethertypes for DSA. In addition since the EDSA isn't actually a registered type we probably don't need to bother with conserving the name anyway.

Thanks,

Alex

#19 lore raw

PATCH v3 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.

---
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      | 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
#20 lore raw

PATCH v3 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
#21 lore raw

PATCH v3 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