net: dsa: bcm_sf2: Allow non-IMP ports to have Broadcom tags enabled
authorFlorian Fainelli <f.fainelli@gmail.com>
Fri, 20 Jan 2017 20:36:32 +0000 (12:36 -0800)
committerDavid S. Miller <davem@davemloft.net>
Sun, 22 Jan 2017 21:58:31 +0000 (16:58 -0500)
Parse the "brcm,use-bcm-hdr" boolean property during ports
identification to fill a bitmask of ports that should have Broadcom tags
enabled. This is needed in some configurations where per-packet metadata
can be exchanged using Broadcom tags between the switch and an on-chip
acceleration device.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Documentation/devicetree/bindings/net/brcm,bcm7445-switch-v4.0.txt
drivers/net/dsa/bcm_sf2.c
drivers/net/dsa/bcm_sf2.h

index e1b2c3e32859b298807157fa0fe42b7734901019..9a734d808aa7eb2919c87d4bc9dd7440bdd7d2c3 100644 (file)
@@ -41,6 +41,13 @@ Optional properties:
   Admission Control Block supports reporting the number of packets in-flight in a
   switch queue
 
+Port subnodes:
+
+Optional properties:
+
+- brcm,use-bcm-hdr: boolean property, if present, indicates that the switch
+  port has Broadcom tags enabled (per-packet metadata)
+
 Example:
 
 switch_top@f0b00000 {
@@ -114,6 +121,7 @@ switch_top@f0b00000 {
                        port@0 {
                                label = "gphy";
                                reg = <0>;
+                               brcm,use-bcm-hdr;
                        };
                        ...
                };
index 571e112c8e343839a197f3610f1906f83aa4efeb..8eecfd227e068b0b14aa7329189dd381aff756a2 100644 (file)
@@ -236,6 +236,10 @@ static int bcm_sf2_port_setup(struct dsa_switch *ds, int port,
        reg &= ~P_TXQ_PSM_VDD(port);
        core_writel(priv, reg, CORE_MEM_PSM_VDD_CTRL);
 
+       /* Enable Broadcom tags for that port if requested */
+       if (priv->brcm_tag_mask & BIT(port))
+               bcm_sf2_brcm_hdr_setup(priv, port);
+
        /* Clear the Rx and Tx disable bits and set to no spanning tree */
        core_writel(priv, 0, CORE_G_PCTL_PORT(port));
 
@@ -515,6 +519,9 @@ static void bcm_sf2_identify_ports(struct bcm_sf2_priv *priv,
 
                if (mode == PHY_INTERFACE_MODE_MOCA)
                        priv->moca_port = port_num;
+
+               if (of_property_read_bool(port, "brcm,use-bcm-hdr"))
+                       priv->brcm_tag_mask |= 1 << port_num;
        }
 }
 
index a1430866bd7953a0898dc2a3783d2fe866ba88f9..6e1f74e4d471daf982f10517bde7191a13530114 100644 (file)
@@ -100,6 +100,9 @@ struct bcm_sf2_priv {
        struct device_node              *master_mii_dn;
        struct mii_bus                  *slave_mii_bus;
        struct mii_bus                  *master_mii_bus;
+
+       /* Bitmask of ports needing BRCM tags */
+       unsigned int                    brcm_tag_mask;
 };
 
 static inline struct bcm_sf2_priv *bcm_sf2_to_priv(struct dsa_switch *ds)