Skip to contentSkip to conversation

dsa: add support for Trailer tagging format

PATCH In review Lennert Buytenhek 1 participant 1 message Sep 29, 2008

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 5/6 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.

---
 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        |    4 ++
 net/dsa/slave.c           |    5 ++
 net/dsa/tag_trailer.c     |  129 +++++++++++++++++++++++++++++++++++++++++++++
 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
index 864982b..23707d4 100644
@@ -101,6 +101,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	*/
 
 /*
  *	This is an Ethernet frame header.
include/linux/netdevice.h +10 -0
index 5226308..169ce79 100644
@@ -812,6 +812,16 @@ static inline int netdev_uses_dsa_tags(struct net_device *dev)
 	return 0;
 }
 
+static inline int 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
index a331f64..d78b95a 100644
@@ -21,6 +21,7 @@ struct dsa_platform_data {
 };
 
 int dsa_uses_dsa_tags(void *dsa_ptr);
+int dsa_uses_trailer_tags(void *dsa_ptr);
 
 
 #endif
net/dsa/Kconfig +4 -0
index 79bcd76..505aa14 100644
@@ -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
index 7fb6f85..63d3c44 100644
@@ -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
index d16a66e..abf69cf 100644
@@ -218,6 +218,13 @@ int dsa_uses_dsa_tags(void *dsa_ptr)
 	return !!(ds->tag_type == TAG_TYPE_DSA);
 }
 
+int dsa_uses_trailer_tags(void *dsa_ptr)
+{
+	struct dsa_switch *ds = dsa_ptr;
+
+	return !!(ds->tag_type == TAG_TYPE_TRAILER);
+}
+
 
 /* link polling *************************************************************/
 static void dsa_link_poll_work(struct work_struct *ugly)
net/dsa/dsa_priv.h +4 -0
index 385a380..17897fe 100644
@@ -20,6 +20,7 @@
 enum dsa_tag_type {
 	TAG_TYPE_DSA,
 	TAG_TYPE_EDSA,
+	TAG_TYPE_TRAILER,
 };
 
 struct dsa_switch {
@@ -108,5 +109,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
index ac8ed09..db3185a 100644
@@ -248,6 +248,11 @@ struct net_device *dsa_slave_create(struct dsa_switch *ds, int port)
 		slave_dev->hard_start_xmit = edsa_xmit;
 		break;
 #endif
+#ifdef CONFIG_NET_DSA_TAG_TRAILER
+	case TAG_TYPE_TRAILER:
+		slave_dev->hard_start_xmit = trailer_xmit;
+		break;
+#endif
 	default:
 		BUG();
 	}
net/dsa/tag_trailer.c new file +129 -0

129 lines not on this page · raw message

net/ethernet/eth.c +2 -0
index e0aca95..9a9dd28 100644
@@ -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