dsa: add support for Trailer tagging format
Subsystems (3)
PATCH v3 4/5 dsa: add support for Trailer tagging format
This adds support for the Trailer switch tagging format. This is another tagging that doesn't explicitly mark tagged packets with a distinct ethertype, so that we need to add a similar hack in the receive path as for the Original DSA tagging format.
Signed-off-by Lennert Buytenhek <[email protected]>
Tested-by Byron Bradley <[email protected]>
Tested-by Tim Ellis <[email protected]>
--- include/linux/if_ether.h | 1 + include/linux/netdevice.h | 10 ++++ include/net/dsa.h | 1 + net/dsa/Kconfig | 4 ++ net/dsa/Makefile | 1 + net/dsa/dsa.c | 7 +++ net/dsa/dsa_priv.h | 3 + net/dsa/slave.c | 5 ++ net/dsa/tag_trailer.c | 130 +++++++++++++++++++++++++++++++++++++++++++++ net/ethernet/eth.c | 2 + 10 files changed, 164 insertions(+), 0 deletions(-) create mode 100644 net/dsa/tag_trailer.c
include/linux/if_ether.h +1 -0
@@ -102,6 +102,7 @@#define ETH_P_HDLC 0x0019/* HDLC frames */ #define ETH_P_ARCNET 0x001A/* 1A for ArcNet :-) */ #define ETH_P_DSA 0x001B/* Distributed Switch Arch. */ +#define ETH_P_TRAILER 0x001C/* Trailer switch tagging */ #define ETH_P_PHONET 0x00F5/* Nokia Phonet frames */ /*
include/linux/netdevice.h +10 -0
@@ -812,6 +812,16 @@ static inline bool netdev_uses_dsa_tags(struct net_device *dev)return 0 ; } +static inline bool netdev_uses_trailer_tags (struct net_device *dev) +{ +#ifdef CONFIG_NET_DSA_TAG_TRAILER +if (dev->dsa_ptr !=NULL ) +return dsa_uses_trailer_tags (dev->dsa_ptr); +#endif + +return 0 ; +} +/** * netdev_priv - access network device private data * @dev: network device
include/net/dsa.h +1 -0
@@ -31,6 +31,7 @@ struct dsa_platform_data { };extern bool dsa_uses_dsa_tags (void *dsa_ptr); +extern bool dsa_uses_trailer_tags (void *dsa_ptr);#endif
net/dsa/Kconfig +4 -0
@@ -18,6 +18,10 @@ config NET_DSA_TAG_EDSA bool default n +config NET_DSA_TAG_TRAILER + bool + default n + # switch drivers config NET_DSA_MV88E6XXX
net/dsa/Makefile +1 -0
@@ -1,6 +1,7 @@ # tagging formats obj-$(CONFIG_NET_DSA_TAG_DSA) += tag_dsa.o obj-$(CONFIG_NET_DSA_TAG_EDSA) += tag_edsa.o +obj-$(CONFIG_NET_DSA_TAG_TRAILER) += tag_trailer.o # switch drivers obj-$(CONFIG_NET_DSA_MV88E6XXX) += mv88e6xxx.o
net/dsa/dsa.c +7 -0
@@ -217,6 +217,13 @@ bool dsa_uses_dsa_tags(void *dsa_ptr)return !!(ds->tag_protocol ==htons (ETH_P_DSA )); } +bool dsa_uses_trailer_tags (void *dsa_ptr) +{ +struct dsa_switch *ds = dsa_ptr; + +return !!(ds->tag_protocol ==htons (ETH_P_TRAILER )); +} +/* link polling *************************************************************/ static void dsa_link_poll_work (struct work_struct *ugly)
net/dsa/dsa_priv.h +3 -0
@@ -108,5 +108,8 @@ int dsa_xmit(struct sk_buff *skb, struct net_device *dev);/* tag_edsa.c */ int edsa_xmit (struct sk_buff *skb,struct net_device *dev); +/* tag_trailer.c */ +int trailer_xmit (struct sk_buff *skb,struct net_device *dev); +#endif
net/dsa/slave.c +5 -0
@@ -249,6 +249,11 @@ dsa_slave_create(struct dsa_switch *ds, struct device *parent, slave_dev->hard_start_xmit = edsa_xmit;break ;#endif +#ifdef CONFIG_NET_DSA_TAG_TRAILER +case htons (ETH_P_TRAILER ): + slave_dev->hard_start_xmit = trailer_xmit; +break ; +#endif default :BUG (); }
net/dsa/tag_trailer.c new file +130 -0
130 lines not on this page · raw message
net/ethernet/eth.c +2 -0
@@ -193,6 +193,8 @@ __be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev)*/ if (netdev_uses_dsa_tags (dev))return htons (ETH_P_DSA ); +if (netdev_uses_trailer_tags (dev)) +return htons (ETH_P_TRAILER );if (ntohs (eth->h_proto) >=1536 )return eth->h_proto;
Signature · 1 line
1.5.6.4