net: dsa: add tagging driver for MaxLinear GSW1xx switch family
Subsystems (4)
RFC PATCH 21/23 net: dsa: add tagging driver for MaxLinear GSW1xx switch family
Add support for a new DSA tagging protocol driver for the MaxLinear GSW1xx switch family. The GSW1xx switches use a proprietary 8-byte special tag inserted between the source MAC address and the EtherType field to indicate the source and destination ports for frames traversing the CPU port.
Implement the tag handling logic to insert the special tag on transmit and parse it on receive.
--- include/net/dsa.h | 2 + net/dsa/Kconfig | 8 +++ net/dsa/Makefile | 1 + net/dsa/tag_mxl-gsw1xx.c | 141 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 152 insertions(+) create mode 100644 net/dsa/tag_mxl-gsw1xx.c
include/net/dsa.h +2 -0
@@ -55,6 +55,7 @@ struct tc_action;#define DSA_TAG_PROTO_LAN937X_VALUE 27#define DSA_TAG_PROTO_VSC73XX_8021Q_VALUE 28#define DSA_TAG_PROTO_BRCM_LEGACY_FCS_VALUE 29 +#define DSA_TAG_PROTO_MXL_GSW1XX_VALUE 30enum dsa_tag_protocol {DSA_TAG_PROTO_NONE =DSA_TAG_PROTO_NONE_VALUE ,
@@ -87,6 +88,7 @@ enum dsa_tag_protocol {DSA_TAG_PROTO_RZN1_A5PSW =DSA_TAG_PROTO_RZN1_A5PSW_VALUE ,DSA_TAG_PROTO_LAN937X =DSA_TAG_PROTO_LAN937X_VALUE ,DSA_TAG_PROTO_VSC73XX_8021Q =DSA_TAG_PROTO_VSC73XX_8021Q_VALUE , + DSA_TAG_PROTO_MXL_GSW1XX = DSA_TAG_PROTO_MXL_GSW1XX_VALUE, };struct dsa_switch ;
net/dsa/Kconfig +8 -0
@@ -98,6 +98,14 @@ config NET_DSA_TAG_EDSA Say Y or M if you want to enable support for tagging frames for the Marvell switches which use EtherType DSA headers. +config NET_DSA_TAG_MXL_GSW1XX + tristate "Tag driver for MaxLinear GSW1xx switches" + help + The GSW1xx family of switches supports an 8-byte special tag which + can be used on the CPU port of the switch. + Say Y or M if you want to enable support for tagging frames for + MaxLinear GSW1xx switches. + config NET_DSA_TAG_MTK tristate "Tag driver for Mediatek switches" help
net/dsa/Makefile +1 -0
@@ -27,6 +27,7 @@ obj-$(CONFIG_NET_DSA_TAG_GSWIP) += tag_gswip.o obj-$(CONFIG_NET_DSA_TAG_HELLCREEK) += tag_hellcreek.o obj-$(CONFIG_NET_DSA_TAG_KSZ) += tag_ksz.o obj-$(CONFIG_NET_DSA_TAG_LAN9303) += tag_lan9303.o +obj-$(CONFIG_NET_DSA_TAG_MXL_GSW1XX) += tag_mxl-gsw1xx.o obj-$(CONFIG_NET_DSA_TAG_MTK) += tag_mtk.o obj-$(CONFIG_NET_DSA_TAG_NONE) += tag_none.o obj-$(CONFIG_NET_DSA_TAG_OCELOT) += tag_ocelot.o
net/dsa/tag_mxl-gsw1xx.c new file +141 -0
141 lines not on this page · raw message
Signature · 1 line
2.50.1
Andrew Lunn
maintainernet/dsa/Makefile obj-$(CONFIG_NET_DSA_TAG_GSWIP) += tag_gswip.o · line 33
Quoted 8 lines
net/dsa/Makefile +1
-0@@ -27,6 +27,7 @@ obj-$(CONFIG_NET_DSA_TAG_GSWIP) += tag_gswip.o obj-$(CONFIG_NET_DSA_TAG_HELLCREEK) += tag_hellcreek.o obj-$(CONFIG_NET_DSA_TAG_KSZ) += tag_ksz.o obj-$(CONFIG_NET_DSA_TAG_LAN9303) += tag_lan9303.o +obj-$(CONFIG_NET_DSA_TAG_MXL_GSW1XX) += tag_mxl-gsw1xx.o obj-$(CONFIG_NET_DSA_TAG_MTK) += tag_mtk.o obj-$(CONFIG_NET_DSA_TAG_NONE) += tag_none.o obj-$(CONFIG_NET_DSA_TAG_OCELOT) += tag_ocelot.o
DSA is not particularly good at sorting, many lists are not. But this list is sorted, and MX > MT.
net/dsa/tag_mxl-gsw1xx.c line 66
Quoted 8 lines
net/dsa/tag_mxl-gsw1xx.c new file +8
-0+static struct sk_buff *gsw1xx_tag_xmit (struct sk_buff *skb, +struct net_device *dev) +{ +struct dsa_port *dp =dsa_user_to_port (dev); +u8 *gsw1xx_tag; + +if (!skb) +return skb;
Can that happen?
net/dsa/tag_mxl-gsw1xx.c line 72
Quoted 5 lines
net/dsa/tag_mxl-gsw1xx.c new file +5
-0+/* provide additional space 'GSW1XX_TX_HEADER_LEN' bytes */ +skb_push (skb,GSW1XX_TX_HEADER_LEN ); + +/* add space between MAC address and Ethertype */ +memmove (skb->data, skb->data +GSW1XX_TX_HEADER_LEN ,2 *ETH_ALEN );
dsa_alloc_etype_header() seems appropriate here.
net/dsa/tag_mxl-gsw1xx.c line 75
Quoted 3 lines
net/dsa/tag_mxl-gsw1xx.c new file +3
-0+ +/* special tag ingress */ + gsw1xx_tag = skb->data +2 *ETH_ALEN ;
and dsa_etype_header_pos_tx().
Quoted 14 lines
net/dsa/tag_mxl-gsw1xx.c new file +14
-0+ gsw1xx_tag[0 ] =0x88 ; + gsw1xx_tag[1 ] =0xc3 ; + gsw1xx_tag[2 ] =GSW1XX_TX_PORT_MAP_EN |GSW1XX_TX_LRN_DIS ; + gsw1xx_tag[3 ] =BIT (dp->index +GSW1XX_TX_PORT_MAP_LOW_SHIFT ) &GSW1XX_TX_PORT_MAP_LOW_MASK ; + gsw1xx_tag[4 ] =0 ; + gsw1xx_tag[5 ] =0 ; + gsw1xx_tag[6 ] =0 ; + gsw1xx_tag[7 ] =0 ; + +return skb; +} + +static struct sk_buff *gsw1xx_tag_rcv (struct sk_buff *skb, +struct net_device *dev)
net/dsa/tag_mxl-gsw1xx.c line 99
Quoted 10 lines
net/dsa/tag_mxl-gsw1xx.c new file +10
-0+{ +int port; +u8 *gsw1xx_tag; + +if (unlikely (!pskb_may_pull (skb,GSW1XX_RX_HEADER_LEN ))) { +dev_warn_ratelimited (&dev->dev,"Dropping packet, cannot pull SKB\n" ); +return NULL ; + } + + gsw1xx_tag = skb->data -2 ;
dsa_etype_header_pos_rx()
Quoted 14 lines
net/dsa/tag_mxl-gsw1xx.c new file +14
-0+if (gsw1xx_tag[0 ] !=0x88 && gsw1xx_tag[1 ] !=0xc3 ) { +dev_warn_ratelimited (&dev->dev,"Dropping packet due to invalid special tag\n" ); +dev_warn_ratelimited (&dev->dev, +"Tag: 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n" , + gsw1xx_tag[0 ], gsw1xx_tag[1 ], gsw1xx_tag[2 ], gsw1xx_tag[3 ], + gsw1xx_tag[4 ], gsw1xx_tag[5 ], gsw1xx_tag[6 ], gsw1xx_tag[7 ]); +return NULL ; + } + +/* Get source port information */ + port = (gsw1xx_tag[2 ] &GSW1XX_RX_PORT_MAP_LOW_MASK ) >>GSW1XX_RX_PORT_MAP_LOW_SHIFT ; + skb->dev =dsa_conduit_find_user (dev,0 , port); +if (!skb->dev) { +dev_warn_ratelimited (&dev->dev,"Dropping packet due to invalid source port\n" );
net/dsa/tag_mxl-gsw1xx.c line 124
Quoted 10 lines
net/dsa/tag_mxl-gsw1xx.c new file +10
-0+dev_warn_ratelimited (&dev->dev, +"Tag: 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n" , + gsw1xx_tag[0 ], gsw1xx_tag[1 ], gsw1xx_tag[2 ], gsw1xx_tag[3 ], + gsw1xx_tag[4 ], gsw1xx_tag[5 ], gsw1xx_tag[6 ], gsw1xx_tag[7 ]); +return NULL ; + } + +/* remove the GSW1xx special tag between MAC addresses and the current ethertype field. */ +skb_pull_rcsum (skb,GSW1XX_RX_HEADER_LEN ); +memmove (skb->data -ETH_HLEN , skb->data - (ETH_HLEN +GSW1XX_RX_HEADER_LEN ),2 *ETH_ALEN );
dsa_strip_etype_header() might also be useful here.
Andrew
---
pw-bot: cr