Skip to contentSkip to conversation

dsa: add support for Trailer tagging format

PATCH In review Lennert Buytenhek 1 participant 1 message Oct 7, 2008

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

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.

---
 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
index 32b9dcd..a0099e9 100644
@@ -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
index 97f0c64..d3ea3de 100644
@@ -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
index 72e509b..52e97bf 100644
@@ -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
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 f8c5492..33e9946 100644
@@ -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
index 148ade8..5f6af7d 100644
@@ -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
index 8f8868d..3761688 100644
@@ -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
index dae47e7..b9d85af 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