From 8eac86e535ca270c196b4fcf1c63570fb94aca15 Mon Sep 17 00:00:00 2001
From: Gabor Juhos <juhosg@openwrt.org>
Date: Mon, 8 Mar 2010 14:38:43 +0000
Subject: [PATCH] ar71xx: enable AR7240 DSA driver on 2.6.33 as well

SVN-Revision: 20059
---
 target/linux/ar71xx/config-2.6.33             |  2 +
 .../122-dsa-add-qinq-tagging-format.patch     | 79 +++++++++++++++++++
 ...a-add-ar7240-built-in-switch-support.patch | 28 +++++++
 3 files changed, 109 insertions(+)
 create mode 100644 target/linux/ar71xx/patches-2.6.33/122-dsa-add-qinq-tagging-format.patch
 create mode 100644 target/linux/ar71xx/patches-2.6.33/123-dsa-add-ar7240-built-in-switch-support.patch

diff --git a/target/linux/ar71xx/config-2.6.33 b/target/linux/ar71xx/config-2.6.33
index 14e57685915..1a8eaadba09 100644
--- a/target/linux/ar71xx/config-2.6.33
+++ b/target/linux/ar71xx/config-2.6.33
@@ -212,6 +212,7 @@ CONFIG_MTD_WRT160NL_PARTS=y
 # CONFIG_MUTEX_SPIN_ON_OWNER is not set
 CONFIG_MYLOADER=y
 CONFIG_NET_DSA=y
+CONFIG_NET_DSA_AR7240=y
 CONFIG_NET_DSA_MV88E6060=y
 CONFIG_NET_DSA_MV88E6063=y
 # CONFIG_NET_DSA_MV88E6123_61_65 is not set
@@ -220,6 +221,7 @@ CONFIG_NET_DSA_MV88E6063=y
 # CONFIG_NET_DSA_MV88E6XXX_NEED_PPU is not set
 # CONFIG_NET_DSA_TAG_DSA is not set
 # CONFIG_NET_DSA_TAG_EDSA is not set
+CONFIG_NET_DSA_TAG_QINQ=y
 CONFIG_NET_DSA_TAG_TRAILER=y
 # CONFIG_NO_IOPORT is not set
 # CONFIG_NXP_STB220 is not set
diff --git a/target/linux/ar71xx/patches-2.6.33/122-dsa-add-qinq-tagging-format.patch b/target/linux/ar71xx/patches-2.6.33/122-dsa-add-qinq-tagging-format.patch
new file mode 100644
index 00000000000..dc03fd6eb49
--- /dev/null
+++ b/target/linux/ar71xx/patches-2.6.33/122-dsa-add-qinq-tagging-format.patch
@@ -0,0 +1,79 @@
+--- a/include/linux/if_ether.h
++++ b/include/linux/if_ether.h
+@@ -81,6 +81,7 @@
+ #define ETH_P_1588	0x88F7		/* IEEE 1588 Timesync */
+ #define ETH_P_FCOE	0x8906		/* Fibre Channel over Ethernet  */
+ #define ETH_P_FIP	0x8914		/* FCoE Initialization Protocol */
++#define ETH_P_QINQ	0x9100		/* QinQ VLAN Stacking Protocol */
+ #define ETH_P_EDSA	0xDADA		/* Ethertype DSA [ NOT AN OFFICIALLY REGISTERED ID ] */
+ 
+ /*
+--- a/net/dsa/dsa_priv.h
++++ b/net/dsa/dsa_priv.h
+@@ -174,6 +174,9 @@ netdev_tx_t dsa_xmit(struct sk_buff *skb
+ /* tag_edsa.c */
+ netdev_tx_t edsa_xmit(struct sk_buff *skb, struct net_device *dev);
+ 
++/* tag_qinq.c */
++netdev_tx_t qinq_xmit(struct sk_buff *skb, struct net_device *dev);
++
+ /* tag_trailer.c */
+ netdev_tx_t trailer_xmit(struct sk_buff *skb, struct net_device *dev);
+ 
+--- a/net/dsa/Kconfig
++++ b/net/dsa/Kconfig
+@@ -23,6 +23,10 @@ config NET_DSA_TAG_TRAILER
+ 	bool
+ 	default n
+ 
++config NET_DSA_TAG_QINQ
++	bool
++	default y
++
+ 
+ # switch drivers
+ config NET_DSA_MV88E6XXX
+--- a/net/dsa/Makefile
++++ b/net/dsa/Makefile
+@@ -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_QINQ) += tag_qinq.o
+ obj-$(CONFIG_NET_DSA_TAG_TRAILER) += tag_trailer.o
+ 
+ # switch drivers
+--- a/net/dsa/slave.c
++++ b/net/dsa/slave.c
+@@ -321,6 +321,19 @@ static const struct net_device_ops edsa_
+ 	.ndo_do_ioctl		= dsa_slave_ioctl,
+ };
+ #endif
++#ifdef CONFIG_NET_DSA_TAG_QINQ
++static const struct net_device_ops qinq_netdev_ops = {
++	.ndo_init		= dsa_slave_init,
++	.ndo_open	 	= dsa_slave_open,
++	.ndo_stop		= dsa_slave_close,
++	.ndo_start_xmit		= qinq_xmit,
++	.ndo_change_rx_flags	= dsa_slave_change_rx_flags,
++	.ndo_set_rx_mode	= dsa_slave_set_rx_mode,
++	.ndo_set_multicast_list = dsa_slave_set_rx_mode,
++	.ndo_set_mac_address	= dsa_slave_set_mac_address,
++	.ndo_do_ioctl		= dsa_slave_ioctl,
++};
++#endif
+ #ifdef CONFIG_NET_DSA_TAG_TRAILER
+ static const struct net_device_ops trailer_netdev_ops = {
+ 	.ndo_init		= dsa_slave_init,
+@@ -366,6 +379,11 @@ dsa_slave_create(struct dsa_switch *ds, 
+ 		slave_dev->netdev_ops = &edsa_netdev_ops;
+ 		break;
+ #endif
++#ifdef CONFIG_NET_DSA_TAG_QINQ
++	case htons(ETH_P_QINQ):
++		slave_dev->netdev_ops = &qinq_netdev_ops;
++		break;
++#endif
+ #ifdef CONFIG_NET_DSA_TAG_TRAILER
+ 	case htons(ETH_P_TRAILER):
+ 		slave_dev->netdev_ops = &trailer_netdev_ops;
diff --git a/target/linux/ar71xx/patches-2.6.33/123-dsa-add-ar7240-built-in-switch-support.patch b/target/linux/ar71xx/patches-2.6.33/123-dsa-add-ar7240-built-in-switch-support.patch
new file mode 100644
index 00000000000..50e6e5de278
--- /dev/null
+++ b/target/linux/ar71xx/patches-2.6.33/123-dsa-add-ar7240-built-in-switch-support.patch
@@ -0,0 +1,28 @@
+--- a/net/dsa/Kconfig
++++ b/net/dsa/Kconfig
+@@ -29,6 +29,15 @@ config NET_DSA_TAG_QINQ
+ 
+ 
+ # switch drivers
++config NET_DSA_AR7240
++	bool "Atheros AR7240 built-in ethernet switch support"
++	depends on ATHEROS_AR71XX
++	default n
++	select NET_DSA_TAG_QINQ
++	---help---
++	  This enables support for the built-in ethernet switch of the
++	  Atheros AR7240 SoC.
++
+ config NET_DSA_MV88E6XXX
+ 	bool
+ 	default n
+--- a/net/dsa/Makefile
++++ b/net/dsa/Makefile
+@@ -5,6 +5,7 @@ obj-$(CONFIG_NET_DSA_TAG_QINQ) += tag_qi
+ obj-$(CONFIG_NET_DSA_TAG_TRAILER) += tag_trailer.o
+ 
+ # switch drivers
++obj-$(CONFIG_NET_DSA_AR7240) += ar7240.o
+ obj-$(CONFIG_NET_DSA_MV88E6XXX) += mv88e6xxx.o
+ obj-$(CONFIG_NET_DSA_MV88E6060) += mv88e6060.o
+ obj-$(CONFIG_NET_DSA_MV88E6063) += mv88e6063.o