net: dsa: Support prepended Broadcom tag
authorFlorian Fainelli <f.fainelli@gmail.com>
Fri, 10 Nov 2017 23:22:54 +0000 (15:22 -0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 13 Nov 2017 01:34:54 +0000 (10:34 +0900)
Add a new type: DSA_TAG_PROTO_PREPEND which allows us to support for the
4-bytes Broadcom tag that we already support, but in a format where it
is pre-pended to the packet instead of located between the MAC SA and
the Ethertyper (DSA_TAG_PROTO_BRCM).

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/dsa.h
net/dsa/Kconfig
net/dsa/Makefile
net/dsa/dsa.c
net/dsa/dsa_priv.h
net/dsa/tag_brcm.c

index 68e232fd4b0f0476e3cd4f658e05bdaf94932454..2a05738570d83c4976b764c86ecb1b12aa697896 100644 (file)
@@ -29,6 +29,7 @@ struct fixed_phy_status;
 enum dsa_tag_protocol {
        DSA_TAG_PROTO_NONE = 0,
        DSA_TAG_PROTO_BRCM,
+       DSA_TAG_PROTO_BRCM_PREPEND,
        DSA_TAG_PROTO_DSA,
        DSA_TAG_PROTO_EDSA,
        DSA_TAG_PROTO_KSZ,
index cc5f8f971689b9fd9947adbdaaf9a92b7b3f3944..2fed892094bcc61df3d47e742ad04555b39991c1 100644 (file)
@@ -19,6 +19,9 @@ if NET_DSA
 config NET_DSA_TAG_BRCM
        bool
 
+config NET_DSA_TAG_BRCM_PREPEND
+       bool
+
 config NET_DSA_TAG_DSA
        bool
 
index e9a4a0f33e86c5f962be141981013c27ef5ca0a0..0e13c1f95d13b8f5a70d5f1303afaad100d29cf5 100644 (file)
@@ -5,6 +5,7 @@ dsa_core-y += dsa.o dsa2.o legacy.o master.o port.o slave.o switch.o
 
 # tagging formats
 dsa_core-$(CONFIG_NET_DSA_TAG_BRCM) += tag_brcm.o
+dsa_core-$(CONFIG_NET_DSA_TAG_BRCM_PREPEND) += 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_KSZ) += tag_ksz.o
index b8f2d9f7c3edffbd77c136b576e81abf96806850..6a9d0f50fbeea1ed5394564f2223aec0547b2348 100644 (file)
@@ -44,6 +44,9 @@ const struct dsa_device_ops *dsa_device_ops[DSA_TAG_LAST] = {
 #ifdef CONFIG_NET_DSA_TAG_BRCM
        [DSA_TAG_PROTO_BRCM] = &brcm_netdev_ops,
 #endif
+#ifdef CONFIG_NET_DSA_TAG_BRCM_PREPEND
+       [DSA_TAG_PROTO_BRCM_PREPEND] = &brcm_prepend_netdev_ops,
+#endif
 #ifdef CONFIG_NET_DSA_TAG_DSA
        [DSA_TAG_PROTO_DSA] = &dsa_netdev_ops,
 #endif
index 507e1ce4d4d2d168c79bc3566db2559b63f759e8..7d036696e8c47bde0c6a8e5827a451acb376ccb9 100644 (file)
@@ -191,6 +191,7 @@ void dsa_switch_unregister_notifier(struct dsa_switch *ds);
 
 /* tag_brcm.c */
 extern const struct dsa_device_ops brcm_netdev_ops;
+extern const struct dsa_device_ops brcm_prepend_netdev_ops;
 
 /* tag_dsa.c */
 extern const struct dsa_device_ops dsa_netdev_ops;
index 771409a1e65c042694b8d143b6e731b3273ad560..e6e0b7b6025c1c43ac94b5da8e7b4be4b2c1c184 100644 (file)
@@ -96,13 +96,6 @@ static struct sk_buff *brcm_tag_xmit_ll(struct sk_buff *skb,
        return skb;
 }
 
-static struct sk_buff *brcm_tag_xmit(struct sk_buff *skb,
-                                    struct net_device *dev)
-{
-       /* Build the tag after the MAC Source Address */
-       return brcm_tag_xmit_ll(skb, dev, 2 * ETH_ALEN);
-}
-
 static struct sk_buff *brcm_tag_rcv_ll(struct sk_buff *skb,
                                       struct net_device *dev,
                                       struct packet_type *pt,
@@ -139,6 +132,15 @@ static struct sk_buff *brcm_tag_rcv_ll(struct sk_buff *skb,
        return skb;
 }
 
+#ifdef CONFIG_NET_DSA_TAG_BRCM
+static struct sk_buff *brcm_tag_xmit(struct sk_buff *skb,
+                                    struct net_device *dev)
+{
+       /* Build the tag after the MAC Source Address */
+       return brcm_tag_xmit_ll(skb, dev, 2 * ETH_ALEN);
+}
+
+
 static struct sk_buff *brcm_tag_rcv(struct sk_buff *skb, struct net_device *dev,
                                    struct packet_type *pt)
 {
@@ -161,3 +163,26 @@ const struct dsa_device_ops brcm_netdev_ops = {
        .xmit   = brcm_tag_xmit,
        .rcv    = brcm_tag_rcv,
 };
+#endif
+
+#ifdef CONFIG_NET_DSA_TAG_BRCM_PREPEND
+static struct sk_buff *brcm_tag_xmit_prepend(struct sk_buff *skb,
+                                            struct net_device *dev)
+{
+       /* tag is prepended to the packet */
+       return brcm_tag_xmit_ll(skb, dev, 0);
+}
+
+static struct sk_buff *brcm_tag_rcv_prepend(struct sk_buff *skb,
+                                           struct net_device *dev,
+                                           struct packet_type *pt)
+{
+       /* tag is prepended to the packet */
+       return brcm_tag_rcv_ll(skb, dev, pt, ETH_HLEN);
+}
+
+const struct dsa_device_ops brcm_prepend_netdev_ops = {
+       .xmit   = brcm_tag_xmit_prepend,
+       .rcv    = brcm_tag_rcv_prepend,
+};
+#endif