netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* vlan 00/07: VLAN update part 1
@ 2008-07-07 12:35 Patrick McHardy
  2008-07-07 12:35 ` vlan 01/07: fix network_header/mac_header adjustments Patrick McHardy
                   ` (7 more replies)
  0 siblings, 8 replies; 15+ messages in thread
From: Patrick McHardy @ 2008-07-07 12:35 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy

Hi Dave,

following is a first VLAN update for net-next-2.6, containing a fix for the
skb->network_header issue pointed out by Lennert, VLAN ethtool support for
querying offload settings, uninlining of __vlan_hwaccel_rx and some assorted
cleanups.

A second update in my queue on top of this one will attack the packet socket
inconsistencies with VLAN acceleration, but I've split the set for easier
review of the more interesting changes.

Please apply, thanks.


 drivers/net/cxgb3/l2t.c         |    2 +-
 drivers/s390/net/qeth_l3_main.c |    4 +-
 include/linux/if_vlan.h         |  204 +++++++++++++--------------------------
 net/8021q/Makefile              |    9 +-
 net/8021q/vlan.c                |   41 ++++-----
 net/8021q/vlan.h                |   67 ++++++++++++-
 net/8021q/vlan_core.c           |   60 ++++++++++++
 net/8021q/vlan_dev.c            |   73 ++++++++------
 net/8021q/vlan_gvrp.c           |    8 +-
 net/8021q/vlanproc.c            |    2 +-
 net/Makefile                    |    4 +-
 11 files changed, 265 insertions(+), 209 deletions(-)
 create mode 100644 net/8021q/vlan_core.c

Joonwoo Park (1):
      vlan: Use is_vlan_dev()

Patrick McHardy (6):
      vlan: fix network_header/mac_header adjustments
      vlan: Add ethtool support
      vlan: uninline __vlan_hwaccel_rx
      vlan: move struct vlan_dev_info to private header
      vlan: remove useless struct hlist_node declaration from if_vlan.h
      vlan: TCI related type and naming cleanups

^ permalink raw reply	[flat|nested] 15+ messages in thread

* vlan 01/07: fix network_header/mac_header adjustments
  2008-07-07 12:35 vlan 00/07: VLAN update part 1 Patrick McHardy
@ 2008-07-07 12:35 ` Patrick McHardy
  2008-07-07 12:36 ` vlan 02/07: Use is_vlan_dev() Patrick McHardy
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 15+ messages in thread
From: Patrick McHardy @ 2008-07-07 12:35 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy

vlan: fix network_header/mac_header adjustments

Lennert Buytenhek points out that the VLAN code incorrectly adjusts
skb->network_header to point in the middle of the VLAN header and
additionally tries to adjust skb->mac_header without checking for
validity.

The network_header should not be touched at all since we're only
adding headers in front of it, mac_header adjustments are not
necessary at all.

Based on patch by Lennert Buytenhek <buytenh@wantstofly.org>.

Signed-off-by: Patrick McHardy <kaber@trash.net>

---
commit 12680f9e7c4d8c1d4dd89569e63f4f74d57243b0
tree 1ea90c61f99c3fba4ca3cac1729dd550ee98274a
parent 768cea593522d816b374149f3bf35e7c246fc8d0
author Patrick McHardy <kaber@trash.net> Mon, 07 Jul 2008 14:26:42 +0200
committer Patrick McHardy <kaber@trash.net> Mon, 07 Jul 2008 14:26:42 +0200

 include/linux/if_vlan.h |    2 --
 net/8021q/vlan_dev.c    |    1 -
 2 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index 5190452..8f5bf9b 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -279,8 +279,6 @@ static inline struct sk_buff *__vlan_put_tag(struct sk_buff *skb, unsigned short
 	veth->h_vlan_TCI = htons(tag);
 
 	skb->protocol = htons(ETH_P_8021Q);
-	skb->mac_header -= VLAN_HLEN;
-	skb->network_header -= VLAN_HLEN;
 
 	return skb;
 }
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index a0617bf..4a85259 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -308,7 +308,6 @@ static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
 			vhdr->h_vlan_encapsulated_proto = htons(len);
 
 		skb->protocol = htons(ETH_P_8021Q);
-		skb_reset_network_header(skb);
 	}
 
 	/* Before delegating work to the lower layer, enter our MAC-address */

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* vlan 02/07: Use is_vlan_dev()
  2008-07-07 12:35 vlan 00/07: VLAN update part 1 Patrick McHardy
  2008-07-07 12:35 ` vlan 01/07: fix network_header/mac_header adjustments Patrick McHardy
@ 2008-07-07 12:36 ` Patrick McHardy
  2008-07-07 12:36 ` vlan 03/07: Add ethtool support Patrick McHardy
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 15+ messages in thread
From: Patrick McHardy @ 2008-07-07 12:36 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy

vlan: Use is_vlan_dev()

Use simplified is_vlan_dev function.

Signed-off-by: Joonwoo Park <joonwpark81@gmail.com>
Signed-off-by: Patrick McHardy <kaber@trash.net>

---
commit 5d835c9df8f14434867d206073316f771cfaac48
tree e30923fbd12ea4dbe12fb7a4b82d9e5261df935a
parent 12680f9e7c4d8c1d4dd89569e63f4f74d57243b0
author Joonwoo Park <joonwpark81@gmail.com> Mon, 07 Jul 2008 14:26:43 +0200
committer Patrick McHardy <kaber@trash.net> Mon, 07 Jul 2008 14:26:43 +0200

 net/8021q/vlan.c     |    3 +--
 net/8021q/vlan_dev.c |    2 +-
 net/8021q/vlanproc.c |    2 +-
 3 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index b529110..8141e2d 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -570,8 +570,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
 			goto out;
 
 		err = -EINVAL;
-		if (args.cmd != ADD_VLAN_CMD &&
-		    !(dev->priv_flags & IFF_802_1Q_VLAN))
+		if (args.cmd != ADD_VLAN_CMD && !is_vlan_dev(dev))
 			goto out;
 	}
 
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index 4a85259..88f318a 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -694,7 +694,7 @@ static int vlan_dev_init(struct net_device *dev)
 		dev->hard_start_xmit = vlan_dev_hard_start_xmit;
 	}
 
-	if (real_dev->priv_flags & IFF_802_1Q_VLAN)
+	if (is_vlan_dev(real_dev))
 		subclass = 1;
 
 	lockdep_set_class_and_subclass(&dev->_xmit_lock,
diff --git a/net/8021q/vlanproc.c b/net/8021q/vlanproc.c
index 08b54b5..6073a88 100644
--- a/net/8021q/vlanproc.c
+++ b/net/8021q/vlanproc.c
@@ -290,7 +290,7 @@ static int vlandev_seq_show(struct seq_file *seq, void *offset)
 	static const char fmt[] = "%30s %12lu\n";
 	int i;
 
-	if (!(vlandev->priv_flags & IFF_802_1Q_VLAN))
+	if (!is_vlan_dev(vlandev))
 		return 0;
 
 	seq_printf(seq,

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* vlan 03/07: Add ethtool support
  2008-07-07 12:35 vlan 00/07: VLAN update part 1 Patrick McHardy
  2008-07-07 12:35 ` vlan 01/07: fix network_header/mac_header adjustments Patrick McHardy
  2008-07-07 12:36 ` vlan 02/07: Use is_vlan_dev() Patrick McHardy
@ 2008-07-07 12:36 ` Patrick McHardy
  2008-07-07 16:52   ` Ben Hutchings
  2008-07-07 12:36 ` vlan 04/07: uninline __vlan_hwaccel_rx Patrick McHardy
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 15+ messages in thread
From: Patrick McHardy @ 2008-07-07 12:36 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy

vlan: Add ethtool support

Add ethtool support for querying the device for offload settings.

Signed-off-by: Patrick McHardy <kaber@trash.net>

---
commit 0dba2d1f208d01290f0ea2d19a201f06da80dded
tree 568a86a3ccd0e587675607caa2f5d66fd526eaa3
parent 5d835c9df8f14434867d206073316f771cfaac48
author Patrick McHardy <kaber@trash.net> Mon, 07 Jul 2008 14:26:43 +0200
committer Patrick McHardy <kaber@trash.net> Mon, 07 Jul 2008 14:26:43 +0200

 net/8021q/vlan_dev.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index 88f318a..722697d 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -28,6 +28,7 @@
 #include <linux/skbuff.h>
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
+#include <linux/ethtool.h>
 #include <net/datalink.h>
 #include <net/p8022.h>
 #include <net/arp.h>
@@ -716,6 +717,22 @@ static void vlan_dev_uninit(struct net_device *dev)
 	}
 }
 
+static u32 vlan_ethtool_get_rx_csum(struct net_device *dev)
+{
+	const struct vlan_dev_info *vlan = vlan_dev_info(dev);
+	struct net_device *real_dev = vlan->real_dev;
+
+	if (real_dev->ethtool_ops == NULL ||
+	    real_dev->ethtool_ops->get_rx_csum == NULL)
+		return 0;
+	return real_dev->ethtool_ops->get_rx_csum(real_dev);
+}
+
+static const struct ethtool_ops vlan_ethtool_ops = {
+	.get_link		= ethtool_op_get_link,
+	.get_rx_csum		= vlan_ethtool_get_rx_csum,
+};
+
 void vlan_setup(struct net_device *dev)
 {
 	ether_setup(dev);
@@ -734,6 +751,7 @@ void vlan_setup(struct net_device *dev)
 	dev->change_rx_flags	= vlan_dev_change_rx_flags;
 	dev->do_ioctl		= vlan_dev_ioctl;
 	dev->destructor		= free_netdev;
+	dev->ethtool_ops	= &vlan_ethtool_ops;
 
 	memset(dev->broadcast, 0, ETH_ALEN);
 }

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* vlan 04/07: uninline __vlan_hwaccel_rx
  2008-07-07 12:35 vlan 00/07: VLAN update part 1 Patrick McHardy
                   ` (2 preceding siblings ...)
  2008-07-07 12:36 ` vlan 03/07: Add ethtool support Patrick McHardy
@ 2008-07-07 12:36 ` Patrick McHardy
  2008-07-07 12:36 ` vlan 05/07: move struct vlan_dev_info to private header Patrick McHardy
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 15+ messages in thread
From: Patrick McHardy @ 2008-07-07 12:36 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy

vlan: uninline __vlan_hwaccel_rx

The function is huge and included at least once in every VLAN acceleration
capable driver. Uninline it; to avoid having drivers depend on the VLAN
module, the function is always built in statically when VLAN is enabled.

With all VLAN acceleration capable drivers that build on x86_64 enabled,
this results in:

   text    data     bss     dec     hex filename
6515227  854044  343968 7713239  75b1d7 vmlinux.inlined
6505637  854044  343968 7703649  758c61 vmlinux.uninlined
----------------------------------------------------------
  -9590

Signed-off-by: Patrick McHardy <kaber@trash.net>

---
commit f8a70bfd12e6421b2c98e19a475633fddb5d5a2a
tree 0fdcf8c5470ec7cc9743f6850e38a99999dc8431
parent 0dba2d1f208d01290f0ea2d19a201f06da80dded
author Patrick McHardy <kaber@trash.net> Mon, 07 Jul 2008 14:26:44 +0200
committer Patrick McHardy <kaber@trash.net> Mon, 07 Jul 2008 14:26:44 +0200

 include/linux/if_vlan.h |   64 ++++++-----------------------------------------
 net/8021q/Makefile      |    9 ++++---
 net/8021q/vlan.h        |    8 ++++++
 net/8021q/vlan_core.c   |   48 +++++++++++++++++++++++++++++++++++
 net/Makefile            |    4 ++-
 5 files changed, 72 insertions(+), 61 deletions(-)

diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index 8f5bf9b..594cd35 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -150,15 +150,6 @@ static inline struct vlan_dev_info *vlan_dev_info(const struct net_device *dev)
 	return netdev_priv(dev);
 }
 
-/* inline functions */
-static inline __u32 vlan_get_ingress_priority(struct net_device *dev,
-					      unsigned short vlan_tag)
-{
-	struct vlan_dev_info *vip = vlan_dev_info(dev);
-
-	return vip->ingress_priority_map[(vlan_tag >> 13) & 0x7];
-}
-
 /* VLAN tx hw acceleration helpers. */
 struct vlan_skb_tx_cookie {
 	u32	magic;
@@ -171,56 +162,17 @@ struct vlan_skb_tx_cookie {
 	(VLAN_TX_SKB_CB(__skb)->magic == VLAN_TX_COOKIE_MAGIC)
 #define vlan_tx_tag_get(__skb)	(VLAN_TX_SKB_CB(__skb)->vlan_tag)
 
-/* VLAN rx hw acceleration helper.  This acts like netif_{rx,receive_skb}(). */
-static inline int __vlan_hwaccel_rx(struct sk_buff *skb,
-				    struct vlan_group *grp,
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
+extern int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp,
+			     unsigned short vlan_tag, int polling);
+#else
+static inline int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp,
 				    unsigned short vlan_tag, int polling)
 {
-	struct net_device_stats *stats;
-
-	if (skb_bond_should_drop(skb)) {
-		dev_kfree_skb_any(skb);
-		return NET_RX_DROP;
-	}
-
-	skb->dev = vlan_group_get_device(grp, vlan_tag & VLAN_VID_MASK);
-	if (skb->dev == NULL) {
-		dev_kfree_skb_any(skb);
-
-		/* Not NET_RX_DROP, this is not being dropped
-		 * due to congestion.
-		 */
-		return 0;
-	}
-
-	skb->dev->last_rx = jiffies;
-
-	stats = &skb->dev->stats;
-	stats->rx_packets++;
-	stats->rx_bytes += skb->len;
-
-	skb->priority = vlan_get_ingress_priority(skb->dev, vlan_tag);
-	switch (skb->pkt_type) {
-	case PACKET_BROADCAST:
-		break;
-
-	case PACKET_MULTICAST:
-		stats->multicast++;
-		break;
-
-	case PACKET_OTHERHOST:
-		/* Our lower layer thinks this is not local, let's make sure.
-		 * This allows the VLAN to have a different MAC than the underlying
-		 * device, and still route correctly.
-		 */
-		if (!compare_ether_addr(eth_hdr(skb)->h_dest,
-				       	skb->dev->dev_addr))
-			skb->pkt_type = PACKET_HOST;
-		break;
-	};
-
-	return (polling ? netif_receive_skb(skb) : netif_rx(skb));
+	BUG();
+	return NET_XMIT_SUCCESS;
 }
+#endif
 
 static inline int vlan_hwaccel_rx(struct sk_buff *skb,
 				  struct vlan_group *grp,
diff --git a/net/8021q/Makefile b/net/8021q/Makefile
index 3006e9e..9f4f174 100644
--- a/net/8021q/Makefile
+++ b/net/8021q/Makefile
@@ -1,9 +1,10 @@
 #
 # Makefile for the Linux VLAN layer.
 #
+obj-$(subst m,y,$(CONFIG_VLAN_8021Q))	+= vlan_core.o
+obj-$(CONFIG_VLAN_8021Q)		+= 8021q.o
 
-obj-$(CONFIG_VLAN_8021Q) += 8021q.o
+8021q-y					:= vlan.o vlan_dev.o vlan_netlink.o
+8021q-$(CONFIG_VLAN_8021Q_GVRP)		+= vlan_gvrp.o
+8021q-$(CONFIG_PROC_FS)			+= vlanproc.o
 
-8021q-y				:= vlan.o vlan_dev.o vlan_netlink.o
-8021q-$(CONFIG_VLAN_8021Q_GVRP)	+= vlan_gvrp.o
-8021q-$(CONFIG_PROC_FS)		+= vlanproc.o
diff --git a/net/8021q/vlan.h b/net/8021q/vlan.h
index 097b2e0..7cc1a97 100644
--- a/net/8021q/vlan.h
+++ b/net/8021q/vlan.h
@@ -37,6 +37,14 @@ void vlan_setup(struct net_device *dev);
 int register_vlan_dev(struct net_device *dev);
 void unregister_vlan_dev(struct net_device *dev);
 
+static inline u32 vlan_get_ingress_priority(struct net_device *dev,
+					    unsigned short vlan_tag)
+{
+	struct vlan_dev_info *vip = vlan_dev_info(dev);
+
+	return vip->ingress_priority_map[(vlan_tag >> 13) & 0x7];
+}
+
 #ifdef CONFIG_VLAN_8021Q_GVRP
 extern int vlan_gvrp_request_join(const struct net_device *dev);
 extern void vlan_gvrp_request_leave(const struct net_device *dev);
diff --git a/net/8021q/vlan_core.c b/net/8021q/vlan_core.c
new file mode 100644
index 0000000..a6c249c
--- /dev/null
+++ b/net/8021q/vlan_core.c
@@ -0,0 +1,48 @@
+#include <linux/skbuff.h>
+#include <linux/netdevice.h>
+#include <linux/if_vlan.h>
+#include "vlan.h"
+
+/* VLAN rx hw acceleration helper.  This acts like netif_{rx,receive_skb}(). */
+int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp,
+		      unsigned short vlan_tag, int polling)
+{
+	struct net_device_stats *stats;
+
+	if (skb_bond_should_drop(skb)) {
+		dev_kfree_skb_any(skb);
+		return NET_RX_DROP;
+	}
+
+	skb->dev = vlan_group_get_device(grp, vlan_tag & VLAN_VID_MASK);
+	if (skb->dev == NULL) {
+		dev_kfree_skb_any(skb);
+		/* Not NET_RX_DROP, this is not being dropped
+		 * due to congestion. */
+		return NET_RX_SUCCESS;
+	}
+	skb->dev->last_rx = jiffies;
+
+	stats = &skb->dev->stats;
+	stats->rx_packets++;
+	stats->rx_bytes += skb->len;
+
+	skb->priority = vlan_get_ingress_priority(skb->dev, vlan_tag);
+	switch (skb->pkt_type) {
+	case PACKET_BROADCAST:
+		break;
+	case PACKET_MULTICAST:
+		stats->multicast++;
+		break;
+	case PACKET_OTHERHOST:
+		/* Our lower layer thinks this is not local, let's make sure.
+		 * This allows the VLAN to have a different MAC than the
+		 * underlying device, and still route correctly. */
+		if (!compare_ether_addr(eth_hdr(skb)->h_dest,
+				       	skb->dev->dev_addr))
+			skb->pkt_type = PACKET_HOST;
+		break;
+	};
+	return (polling ? netif_receive_skb(skb) : netif_rx(skb));
+}
+EXPORT_SYMBOL(__vlan_hwaccel_rx);
diff --git a/net/Makefile b/net/Makefile
index b7a1364..4f43e7f 100644
--- a/net/Makefile
+++ b/net/Makefile
@@ -42,7 +42,9 @@ obj-$(CONFIG_AF_RXRPC)		+= rxrpc/
 obj-$(CONFIG_ATM)		+= atm/
 obj-$(CONFIG_DECNET)		+= decnet/
 obj-$(CONFIG_ECONET)		+= econet/
-obj-$(CONFIG_VLAN_8021Q)	+= 8021q/
+ifneq ($(CONFIG_VLAN_8021Q),)
+obj-y				+= 8021q/
+endif
 obj-$(CONFIG_IP_DCCP)		+= dccp/
 obj-$(CONFIG_IP_SCTP)		+= sctp/
 obj-y				+= wireless/

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* vlan 05/07: move struct vlan_dev_info to private header
  2008-07-07 12:35 vlan 00/07: VLAN update part 1 Patrick McHardy
                   ` (3 preceding siblings ...)
  2008-07-07 12:36 ` vlan 04/07: uninline __vlan_hwaccel_rx Patrick McHardy
@ 2008-07-07 12:36 ` Patrick McHardy
  2008-07-07 12:36 ` vlan 06/07: remove useless struct hlist_node declaration from if_vlan.h Patrick McHardy
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 15+ messages in thread
From: Patrick McHardy @ 2008-07-07 12:36 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy

vlan: move struct vlan_dev_info to private header

Hide struct vlan_dev_info from drivers to prevent them from growing
more creative ways to use it. Provide accessors for the two drivers
that currently use it.

Signed-off-by: Patrick McHardy <kaber@trash.net>

---
commit b060b0baf74457b1a9e05e7b264be91a753477ee
tree dd424a8b7481db49bb1160ea8b28c4115d2ad330
parent f8a70bfd12e6421b2c98e19a475633fddb5d5a2a
author Patrick McHardy <kaber@trash.net> Mon, 07 Jul 2008 14:26:44 +0200
committer Patrick McHardy <kaber@trash.net> Mon, 07 Jul 2008 14:26:44 +0200

 drivers/net/cxgb3/l2t.c         |    2 +
 drivers/s390/net/qeth_l3_main.c |    4 +--
 include/linux/if_vlan.h         |   56 ++++++++++-----------------------------
 net/8021q/vlan.c                |    4 +--
 net/8021q/vlan.h                |   50 ++++++++++++++++++++++++++++++++++-
 net/8021q/vlan_core.c           |   12 ++++++++
 net/8021q/vlan_dev.c            |    5 ---
 7 files changed, 80 insertions(+), 53 deletions(-)

diff --git a/drivers/net/cxgb3/l2t.c b/drivers/net/cxgb3/l2t.c
index f510140..825e510 100644
--- a/drivers/net/cxgb3/l2t.c
+++ b/drivers/net/cxgb3/l2t.c
@@ -337,7 +337,7 @@ struct l2t_entry *t3_l2t_get(struct t3cdev *cdev, struct neighbour *neigh,
 		atomic_set(&e->refcnt, 1);
 		neigh_replace(e, neigh);
 		if (neigh->dev->priv_flags & IFF_802_1Q_VLAN)
-			e->vlan = vlan_dev_info(neigh->dev)->vlan_id;
+			e->vlan = vlan_dev_vlan_id(neigh->dev);
 		else
 			e->vlan = VLAN_NONE;
 		spin_unlock(&e->lock);
diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c
index 999552c..85be40a 100644
--- a/drivers/s390/net/qeth_l3_main.c
+++ b/drivers/s390/net/qeth_l3_main.c
@@ -2020,7 +2020,7 @@ static int qeth_l3_verify_vlan_dev(struct net_device *dev,
 		}
 	}
 
-	if (rc && !(netdev_priv(vlan_dev_info(dev)->real_dev) == (void *)card))
+	if (rc && !(netdev_priv(vlan_dev_real_dev(dev)) == (void *)card))
 		return 0;
 
 	return rc;
@@ -2056,7 +2056,7 @@ static struct qeth_card *qeth_l3_get_card_from_dev(struct net_device *dev)
 	if (rc == QETH_REAL_CARD)
 		card = netdev_priv(dev);
 	else if (rc == QETH_VLAN_CARD)
-		card = netdev_priv(vlan_dev_info(dev)->real_dev);
+		card = netdev_priv(vlan_dev_real_dev(dev));
 	if (card && card->options.layer2)
 		card = NULL;
 	QETH_DBF_TEXT_(TRACE, 4, "%d", rc);
diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index 594cd35..cb2e6b4 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -109,47 +109,6 @@ static inline void vlan_group_set_device(struct vlan_group *vg,
 	array[vlan_id % VLAN_GROUP_ARRAY_PART_LEN] = dev;
 }
 
-struct vlan_priority_tci_mapping {
-	u32 priority;
-	unsigned short vlan_qos; /* This should be shifted when first set, so we only do it
-				  * at provisioning time.
-				  * ((skb->priority << 13) & 0xE000)
-				  */
-	struct vlan_priority_tci_mapping *next;
-};
-
-/* Holds information that makes sense if this device is a VLAN device. */
-struct vlan_dev_info {
-	/** This will be the mapping that correlates skb->priority to
-	 * 3 bits of VLAN QOS tags...
-	 */
-	unsigned int nr_ingress_mappings;
-	u32 ingress_priority_map[8];
-
-	unsigned int nr_egress_mappings;
-	struct vlan_priority_tci_mapping *egress_priority_map[16]; /* hash table */
-
-	unsigned short vlan_id;        /*  The VLAN Identifier for this interface. */
-	unsigned short flags;          /* (1 << 0) re_order_header   This option will cause the
-                                        *   VLAN code to move around the ethernet header on
-                                        *   ingress to make the skb look **exactly** like it
-                                        *   came in from an ethernet port.  This destroys some of
-                                        *   the VLAN information in the skb, but it fixes programs
-                                        *   like DHCP that use packet-filtering and don't understand
-                                        *   802.1Q
-                                        */
-	struct net_device *real_dev;    /* the underlying device/interface */
-	unsigned char real_dev_addr[ETH_ALEN];
-	struct proc_dir_entry *dent;    /* Holds the proc data */
-	unsigned long cnt_inc_headroom_on_tx; /* How many times did we have to grow the skb on TX. */
-	unsigned long cnt_encap_on_xmit;      /* How many times did we have to encapsulate the skb on TX. */
-};
-
-static inline struct vlan_dev_info *vlan_dev_info(const struct net_device *dev)
-{
-	return netdev_priv(dev);
-}
-
 /* VLAN tx hw acceleration helpers. */
 struct vlan_skb_tx_cookie {
 	u32	magic;
@@ -163,9 +122,24 @@ struct vlan_skb_tx_cookie {
 #define vlan_tx_tag_get(__skb)	(VLAN_TX_SKB_CB(__skb)->vlan_tag)
 
 #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
+extern struct net_device *vlan_dev_real_dev(const struct net_device *dev);
+extern u16 vlan_dev_vlan_id(const struct net_device *dev);
+
 extern int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp,
 			     unsigned short vlan_tag, int polling);
 #else
+static inline struct net_device *vlan_dev_real_dev(const struct net_device *dev)
+{
+	BUG();
+	return NULL;
+}
+
+static inline u16 vlan_dev_vlan_id(const struct net_device *dev)
+{
+	BUG();
+	return 0;
+}
+
 static inline int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp,
 				    unsigned short vlan_tag, int polling)
 {
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index 8141e2d..7a2625d 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -543,7 +543,6 @@ static struct notifier_block vlan_notifier_block __read_mostly = {
 static int vlan_ioctl_handler(struct net *net, void __user *arg)
 {
 	int err;
-	unsigned short vid = 0;
 	struct vlan_ioctl_args args;
 	struct net_device *dev = NULL;
 
@@ -644,8 +643,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
 
 	case GET_VLAN_VID_CMD:
 		err = 0;
-		vlan_dev_get_vid(dev, &vid);
-		args.u.VID = vid;
+		args.u.VID = vlan_dev_vlan_id(dev);
 		if (copy_to_user(arg, &args,
 				 sizeof(struct vlan_ioctl_args)))
 		      err = -EFAULT;
diff --git a/net/8021q/vlan.h b/net/8021q/vlan.h
index 7cc1a97..14c421e 100644
--- a/net/8021q/vlan.h
+++ b/net/8021q/vlan.h
@@ -3,6 +3,55 @@
 
 #include <linux/if_vlan.h>
 
+
+/**
+ *	struct vlan_priority_tci_mapping - vlan egress priority mappings
+ *	@priority: skb priority
+ *	@vlan_qos: vlan priority: (skb->priority << 13) & 0xE000
+ *	@next: pointer to next struct
+ */
+struct vlan_priority_tci_mapping {
+	u32					priority;
+	unsigned short				vlan_qos;
+	struct vlan_priority_tci_mapping	*next;
+};
+
+/**
+ *	struct vlan_dev_info - VLAN private device data
+ *	@nr_ingress_mappings: number of ingress priority mappings
+ *	@ingress_priority_map: ingress priority mappings
+ *	@nr_egress_mappings: number of egress priority mappings
+ *	@egress_priority_map: hash of egress priority mappings
+ *	@vlan_id: VLAN identifier
+ *	@flags: device flags
+ *	@real_dev: underlying netdevice
+ *	@real_dev_addr: address of underlying netdevice
+ *	@dent: proc dir entry
+ *	@cnt_inc_headroom_on_tx: statistic - number of skb expansions on TX
+ *	@cnt_encap_on_xmit: statistic - number of skb encapsulations on TX
+ */
+struct vlan_dev_info {
+	unsigned int				nr_ingress_mappings;
+	u32					ingress_priority_map[8];
+	unsigned int				nr_egress_mappings;
+	struct vlan_priority_tci_mapping	*egress_priority_map[16];
+
+	unsigned short				vlan_id;
+	unsigned short				flags;
+
+	struct net_device			*real_dev;
+	unsigned char				real_dev_addr[ETH_ALEN];
+
+	struct proc_dir_entry			*dent;
+	unsigned long				cnt_inc_headroom_on_tx;
+	unsigned long				cnt_encap_on_xmit;
+};
+
+static inline struct vlan_dev_info *vlan_dev_info(const struct net_device *dev)
+{
+	return netdev_priv(dev);
+}
+
 #define VLAN_GRP_HASH_SHIFT	5
 #define VLAN_GRP_HASH_SIZE	(1 << VLAN_GRP_HASH_SHIFT)
 #define VLAN_GRP_HASH_MASK	(VLAN_GRP_HASH_SIZE - 1)
@@ -30,7 +79,6 @@ int vlan_dev_set_egress_priority(const struct net_device *dev,
 				 u32 skb_prio, short vlan_prio);
 int vlan_dev_change_flags(const struct net_device *dev, u32 flag, u32 mask);
 void vlan_dev_get_realdev_name(const struct net_device *dev, char *result);
-void vlan_dev_get_vid(const struct net_device *dev, unsigned short *result);
 
 int vlan_check_real_dev(struct net_device *real_dev, unsigned short vlan_id);
 void vlan_setup(struct net_device *dev);
diff --git a/net/8021q/vlan_core.c b/net/8021q/vlan_core.c
index a6c249c..4daabc2 100644
--- a/net/8021q/vlan_core.c
+++ b/net/8021q/vlan_core.c
@@ -46,3 +46,15 @@ int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp,
 	return (polling ? netif_receive_skb(skb) : netif_rx(skb));
 }
 EXPORT_SYMBOL(__vlan_hwaccel_rx);
+
+struct net_device *vlan_dev_real_dev(const struct net_device *dev)
+{
+	return vlan_dev_info(dev)->real_dev;
+}
+EXPORT_SYMBOL_GPL(vlan_dev_real_dev);
+
+u16 vlan_dev_vlan_id(const struct net_device *dev)
+{
+	return vlan_dev_info(dev)->vlan_id;
+}
+EXPORT_SYMBOL_GPL(vlan_dev_vlan_id);
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index 722697d..2aab294 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -531,11 +531,6 @@ void vlan_dev_get_realdev_name(const struct net_device *dev, char *result)
 	strncpy(result, vlan_dev_info(dev)->real_dev->name, 23);
 }
 
-void vlan_dev_get_vid(const struct net_device *dev, unsigned short *result)
-{
-	*result = vlan_dev_info(dev)->vlan_id;
-}
-
 static int vlan_dev_open(struct net_device *dev)
 {
 	struct vlan_dev_info *vlan = vlan_dev_info(dev);

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* vlan 06/07: remove useless struct hlist_node declaration from if_vlan.h
  2008-07-07 12:35 vlan 00/07: VLAN update part 1 Patrick McHardy
                   ` (4 preceding siblings ...)
  2008-07-07 12:36 ` vlan 05/07: move struct vlan_dev_info to private header Patrick McHardy
@ 2008-07-07 12:36 ` Patrick McHardy
  2008-07-07 12:36 ` vlan 07/07: TCI related type and naming cleanups Patrick McHardy
  2008-07-08 10:44 ` vlan 00/07: VLAN update part 1 David Miller
  7 siblings, 0 replies; 15+ messages in thread
From: Patrick McHardy @ 2008-07-07 12:36 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy

vlan: remove useless struct hlist_node declaration from if_vlan.h

Signed-off-by: Patrick McHardy <kaber@trash.net>

---
commit daeb32dc9028e7929568becc899169cd8ff3e6ad
tree b5fccfbfefbc2c0b5221e2774fa7ea8f84579b8f
parent b060b0baf74457b1a9e05e7b264be91a753477ee
author Patrick McHardy <kaber@trash.net> Mon, 07 Jul 2008 14:26:45 +0200
committer Patrick McHardy <kaber@trash.net> Mon, 07 Jul 2008 14:26:45 +0200

 include/linux/if_vlan.h |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)

diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index cb2e6b4..8e68b05 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -14,10 +14,6 @@
 #define _LINUX_IF_VLAN_H_
 
 #ifdef __KERNEL__
-
-/* externally defined structs */
-struct hlist_node;
-
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* vlan 07/07: TCI related type and naming cleanups
  2008-07-07 12:35 vlan 00/07: VLAN update part 1 Patrick McHardy
                   ` (5 preceding siblings ...)
  2008-07-07 12:36 ` vlan 06/07: remove useless struct hlist_node declaration from if_vlan.h Patrick McHardy
@ 2008-07-07 12:36 ` Patrick McHardy
  2008-07-08 10:44 ` vlan 00/07: VLAN update part 1 David Miller
  7 siblings, 0 replies; 15+ messages in thread
From: Patrick McHardy @ 2008-07-07 12:36 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy

vlan: TCI related type and naming cleanups

The VLAN code contains multiple spots that use tag, id and tci as
identifiers for arguments and variables incorrectly and they actually
contain or are expected to contain something different. Additionally
types are used inconsistently (unsigned short vs u16) and identifiers
are sometimes capitalized.

- consistently use u16 for storing TCI, ID or QoS values
- consistently use vlan_id and vlan_tci for storing the respective values
- remove capitalization
- add kdoc comment to netif_hwaccel_{rx,receive_skb}

Signed-off-by: Patrick McHardy <kaber@trash.net>

---
commit 030f4ae9fb86661142f2dc12079077ae79ffc98e
tree 59dcb702888222d4ccea79e241ed168976cd7335
parent daeb32dc9028e7929568becc899169cd8ff3e6ad
author Patrick McHardy <kaber@trash.net> Mon, 07 Jul 2008 14:26:45 +0200
committer Patrick McHardy <kaber@trash.net> Mon, 07 Jul 2008 14:26:45 +0200

 include/linux/if_vlan.h |   84 +++++++++++++++++++++++++++--------------------
 net/8021q/vlan.c        |   34 +++++++++----------
 net/8021q/vlan.h        |   19 +++++------
 net/8021q/vlan_core.c   |    6 ++-
 net/8021q/vlan_dev.c    |   47 +++++++++++++-------------
 net/8021q/vlan_gvrp.c   |    8 ++--
 6 files changed, 103 insertions(+), 95 deletions(-)

diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index 8e68b05..d36515d 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -87,7 +87,7 @@ struct vlan_group {
 };
 
 static inline struct net_device *vlan_group_get_device(struct vlan_group *vg,
-						       unsigned int vlan_id)
+						       u16 vlan_id)
 {
 	struct net_device **array;
 	array = vg->vlan_devices_arrays[vlan_id / VLAN_GROUP_ARRAY_PART_LEN];
@@ -95,7 +95,7 @@ static inline struct net_device *vlan_group_get_device(struct vlan_group *vg,
 }
 
 static inline void vlan_group_set_device(struct vlan_group *vg,
-					 unsigned int vlan_id,
+					 u16 vlan_id,
 					 struct net_device *dev)
 {
 	struct net_device **array;
@@ -122,7 +122,7 @@ extern struct net_device *vlan_dev_real_dev(const struct net_device *dev);
 extern u16 vlan_dev_vlan_id(const struct net_device *dev);
 
 extern int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp,
-			     unsigned short vlan_tag, int polling);
+			     u16 vlan_tci, int polling);
 #else
 static inline struct net_device *vlan_dev_real_dev(const struct net_device *dev)
 {
@@ -137,39 +137,51 @@ static inline u16 vlan_dev_vlan_id(const struct net_device *dev)
 }
 
 static inline int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp,
-				    unsigned short vlan_tag, int polling)
+				    u16 vlan_tci, int polling)
 {
 	BUG();
 	return NET_XMIT_SUCCESS;
 }
 #endif
 
+/**
+ * vlan_hwaccel_rx - netif_rx wrapper for VLAN RX acceleration
+ * @skb: buffer
+ * @grp: vlan group
+ * @vlan_tci: VLAN TCI as received from the card
+ */
 static inline int vlan_hwaccel_rx(struct sk_buff *skb,
 				  struct vlan_group *grp,
-				  unsigned short vlan_tag)
+				  u16 vlan_tci)
 {
-	return __vlan_hwaccel_rx(skb, grp, vlan_tag, 0);
+	return __vlan_hwaccel_rx(skb, grp, vlan_tci, 0);
 }
 
+/**
+ * vlan_hwaccel_receive_skb - netif_receive_skb wrapper for VLAN RX acceleration
+ * @skb: buffer
+ * @grp: vlan group
+ * @vlan_tci: VLAN TCI as received from the card
+ */
 static inline int vlan_hwaccel_receive_skb(struct sk_buff *skb,
 					   struct vlan_group *grp,
-					   unsigned short vlan_tag)
+					   u16 vlan_tci)
 {
-	return __vlan_hwaccel_rx(skb, grp, vlan_tag, 1);
+	return __vlan_hwaccel_rx(skb, grp, vlan_tci, 1);
 }
 
 /**
  * __vlan_put_tag - regular VLAN tag inserting
  * @skb: skbuff to tag
- * @tag: VLAN tag to insert
+ * @vlan_tci: VLAN TCI to insert
  *
  * Inserts the VLAN tag into @skb as part of the payload
  * Returns a VLAN tagged skb. If a new skb is created, @skb is freed.
- * 
+ *
  * Following the skb_unshare() example, in case of error, the calling function
  * doesn't have to worry about freeing the original skb.
  */
-static inline struct sk_buff *__vlan_put_tag(struct sk_buff *skb, unsigned short tag)
+static inline struct sk_buff *__vlan_put_tag(struct sk_buff *skb, u16 vlan_tci)
 {
 	struct vlan_ethhdr *veth;
 
@@ -197,8 +209,8 @@ static inline struct sk_buff *__vlan_put_tag(struct sk_buff *skb, unsigned short
 	/* first, the ethernet type */
 	veth->h_vlan_proto = htons(ETH_P_8021Q);
 
-	/* now, the tag */
-	veth->h_vlan_TCI = htons(tag);
+	/* now, the TCI */
+	veth->h_vlan_TCI = htons(vlan_tci);
 
 	skb->protocol = htons(ETH_P_8021Q);
 
@@ -208,17 +220,18 @@ static inline struct sk_buff *__vlan_put_tag(struct sk_buff *skb, unsigned short
 /**
  * __vlan_hwaccel_put_tag - hardware accelerated VLAN inserting
  * @skb: skbuff to tag
- * @tag: VLAN tag to insert
+ * @vlan_tci: VLAN TCI to insert
  *
- * Puts the VLAN tag in @skb->cb[] and lets the device do the rest
+ * Puts the VLAN TCI in @skb->cb[] and lets the device do the rest
  */
-static inline struct sk_buff *__vlan_hwaccel_put_tag(struct sk_buff *skb, unsigned short tag)
+static inline struct sk_buff *__vlan_hwaccel_put_tag(struct sk_buff *skb,
+						     u16 vlan_tci)
 {
 	struct vlan_skb_tx_cookie *cookie;
 
 	cookie = VLAN_TX_SKB_CB(skb);
 	cookie->magic = VLAN_TX_COOKIE_MAGIC;
-	cookie->vlan_tag = tag;
+	cookie->vlan_tag = vlan_tci;
 
 	return skb;
 }
@@ -228,28 +241,28 @@ static inline struct sk_buff *__vlan_hwaccel_put_tag(struct sk_buff *skb, unsign
 /**
  * vlan_put_tag - inserts VLAN tag according to device features
  * @skb: skbuff to tag
- * @tag: VLAN tag to insert
+ * @vlan_tci: VLAN TCI to insert
  *
  * Assumes skb->dev is the target that will xmit this frame.
  * Returns a VLAN tagged skb.
  */
-static inline struct sk_buff *vlan_put_tag(struct sk_buff *skb, unsigned short tag)
+static inline struct sk_buff *vlan_put_tag(struct sk_buff *skb, u16 vlan_tci)
 {
 	if (skb->dev->features & NETIF_F_HW_VLAN_TX) {
-		return __vlan_hwaccel_put_tag(skb, tag);
+		return __vlan_hwaccel_put_tag(skb, vlan_tci);
 	} else {
-		return __vlan_put_tag(skb, tag);
+		return __vlan_put_tag(skb, vlan_tci);
 	}
 }
 
 /**
  * __vlan_get_tag - get the VLAN ID that is part of the payload
  * @skb: skbuff to query
- * @tag: buffer to store vlaue
- * 
+ * @vlan_tci: buffer to store vlaue
+ *
  * Returns error if the skb is not of VLAN type
  */
-static inline int __vlan_get_tag(const struct sk_buff *skb, unsigned short *tag)
+static inline int __vlan_get_tag(const struct sk_buff *skb, u16 *vlan_tci)
 {
 	struct vlan_ethhdr *veth = (struct vlan_ethhdr *)skb->data;
 
@@ -257,29 +270,28 @@ static inline int __vlan_get_tag(const struct sk_buff *skb, unsigned short *tag)
 		return -EINVAL;
 	}
 
-	*tag = ntohs(veth->h_vlan_TCI);
-
+	*vlan_tci = ntohs(veth->h_vlan_TCI);
 	return 0;
 }
 
 /**
  * __vlan_hwaccel_get_tag - get the VLAN ID that is in @skb->cb[]
  * @skb: skbuff to query
- * @tag: buffer to store vlaue
- * 
+ * @vlan_tci: buffer to store vlaue
+ *
  * Returns error if @skb->cb[] is not set correctly
  */
 static inline int __vlan_hwaccel_get_tag(const struct sk_buff *skb,
-					 unsigned short *tag)
+					 u16 *vlan_tci)
 {
 	struct vlan_skb_tx_cookie *cookie;
 
 	cookie = VLAN_TX_SKB_CB(skb);
 	if (cookie->magic == VLAN_TX_COOKIE_MAGIC) {
-		*tag = cookie->vlan_tag;
+		*vlan_tci = cookie->vlan_tag;
 		return 0;
 	} else {
-		*tag = 0;
+		*vlan_tci = 0;
 		return -EINVAL;
 	}
 }
@@ -289,16 +301,16 @@ static inline int __vlan_hwaccel_get_tag(const struct sk_buff *skb,
 /**
  * vlan_get_tag - get the VLAN ID from the skb
  * @skb: skbuff to query
- * @tag: buffer to store vlaue
- * 
+ * @vlan_tci: buffer to store vlaue
+ *
  * Returns error if the skb is not VLAN tagged
  */
-static inline int vlan_get_tag(const struct sk_buff *skb, unsigned short *tag)
+static inline int vlan_get_tag(const struct sk_buff *skb, u16 *vlan_tci)
 {
 	if (skb->dev->features & NETIF_F_HW_VLAN_TX) {
-		return __vlan_hwaccel_get_tag(skb, tag);
+		return __vlan_hwaccel_get_tag(skb, vlan_tci);
 	} else {
-		return __vlan_get_tag(skb, tag);
+		return __vlan_get_tag(skb, vlan_tci);
 	}
 }
 
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index 7a2625d..68bdcf4 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -83,13 +83,12 @@ static struct vlan_group *__vlan_find_group(struct net_device *real_dev)
  *
  * Must be invoked with RCU read lock (no preempt)
  */
-struct net_device *__find_vlan_dev(struct net_device *real_dev,
-				   unsigned short VID)
+struct net_device *__find_vlan_dev(struct net_device *real_dev, u16 vlan_id)
 {
 	struct vlan_group *grp = __vlan_find_group(real_dev);
 
 	if (grp)
-		return vlan_group_get_device(grp, VID);
+		return vlan_group_get_device(grp, vlan_id);
 
 	return NULL;
 }
@@ -117,14 +116,14 @@ static struct vlan_group *vlan_group_alloc(struct net_device *real_dev)
 	return grp;
 }
 
-static int vlan_group_prealloc_vid(struct vlan_group *vg, int vid)
+static int vlan_group_prealloc_vid(struct vlan_group *vg, u16 vlan_id)
 {
 	struct net_device **array;
 	unsigned int size;
 
 	ASSERT_RTNL();
 
-	array = vg->vlan_devices_arrays[vid / VLAN_GROUP_ARRAY_PART_LEN];
+	array = vg->vlan_devices_arrays[vlan_id / VLAN_GROUP_ARRAY_PART_LEN];
 	if (array != NULL)
 		return 0;
 
@@ -133,7 +132,7 @@ static int vlan_group_prealloc_vid(struct vlan_group *vg, int vid)
 	if (array == NULL)
 		return -ENOBUFS;
 
-	vg->vlan_devices_arrays[vid / VLAN_GROUP_ARRAY_PART_LEN] = array;
+	vg->vlan_devices_arrays[vlan_id / VLAN_GROUP_ARRAY_PART_LEN] = array;
 	return 0;
 }
 
@@ -147,7 +146,7 @@ void unregister_vlan_dev(struct net_device *dev)
 	struct vlan_dev_info *vlan = vlan_dev_info(dev);
 	struct net_device *real_dev = vlan->real_dev;
 	struct vlan_group *grp;
-	unsigned short vlan_id = vlan->vlan_id;
+	u16 vlan_id = vlan->vlan_id;
 
 	ASSERT_RTNL();
 
@@ -205,7 +204,7 @@ static void vlan_transfer_operstate(const struct net_device *dev,
 	}
 }
 
-int vlan_check_real_dev(struct net_device *real_dev, unsigned short vlan_id)
+int vlan_check_real_dev(struct net_device *real_dev, u16 vlan_id)
 {
 	char *name = real_dev->name;
 
@@ -242,7 +241,7 @@ int register_vlan_dev(struct net_device *dev)
 {
 	struct vlan_dev_info *vlan = vlan_dev_info(dev);
 	struct net_device *real_dev = vlan->real_dev;
-	unsigned short vlan_id = vlan->vlan_id;
+	u16 vlan_id = vlan->vlan_id;
 	struct vlan_group *grp, *ngrp = NULL;
 	int err;
 
@@ -295,8 +294,7 @@ out_free_group:
 /*  Attach a VLAN device to a mac address (ie Ethernet Card).
  *  Returns 0 if the device was created or a negative error code otherwise.
  */
-static int register_vlan_device(struct net_device *real_dev,
-				unsigned short VLAN_ID)
+static int register_vlan_device(struct net_device *real_dev, u16 vlan_id)
 {
 	struct net_device *new_dev;
 	struct net *net = dev_net(real_dev);
@@ -304,10 +302,10 @@ static int register_vlan_device(struct net_device *real_dev,
 	char name[IFNAMSIZ];
 	int err;
 
-	if (VLAN_ID >= VLAN_VID_MASK)
+	if (vlan_id >= VLAN_VID_MASK)
 		return -ERANGE;
 
-	err = vlan_check_real_dev(real_dev, VLAN_ID);
+	err = vlan_check_real_dev(real_dev, vlan_id);
 	if (err < 0)
 		return err;
 
@@ -315,26 +313,26 @@ static int register_vlan_device(struct net_device *real_dev,
 	switch (vn->name_type) {
 	case VLAN_NAME_TYPE_RAW_PLUS_VID:
 		/* name will look like:	 eth1.0005 */
-		snprintf(name, IFNAMSIZ, "%s.%.4i", real_dev->name, VLAN_ID);
+		snprintf(name, IFNAMSIZ, "%s.%.4i", real_dev->name, vlan_id);
 		break;
 	case VLAN_NAME_TYPE_PLUS_VID_NO_PAD:
 		/* Put our vlan.VID in the name.
 		 * Name will look like:	 vlan5
 		 */
-		snprintf(name, IFNAMSIZ, "vlan%i", VLAN_ID);
+		snprintf(name, IFNAMSIZ, "vlan%i", vlan_id);
 		break;
 	case VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD:
 		/* Put our vlan.VID in the name.
 		 * Name will look like:	 eth0.5
 		 */
-		snprintf(name, IFNAMSIZ, "%s.%i", real_dev->name, VLAN_ID);
+		snprintf(name, IFNAMSIZ, "%s.%i", real_dev->name, vlan_id);
 		break;
 	case VLAN_NAME_TYPE_PLUS_VID:
 		/* Put our vlan.VID in the name.
 		 * Name will look like:	 vlan0005
 		 */
 	default:
-		snprintf(name, IFNAMSIZ, "vlan%.4i", VLAN_ID);
+		snprintf(name, IFNAMSIZ, "vlan%.4i", vlan_id);
 	}
 
 	new_dev = alloc_netdev(sizeof(struct vlan_dev_info), name,
@@ -349,7 +347,7 @@ static int register_vlan_device(struct net_device *real_dev,
 	 */
 	new_dev->mtu = real_dev->mtu;
 
-	vlan_dev_info(new_dev)->vlan_id = VLAN_ID; /* 1 through VLAN_VID_MASK */
+	vlan_dev_info(new_dev)->vlan_id = vlan_id;
 	vlan_dev_info(new_dev)->real_dev = real_dev;
 	vlan_dev_info(new_dev)->dent = NULL;
 	vlan_dev_info(new_dev)->flags = VLAN_FLAG_REORDER_HDR;
diff --git a/net/8021q/vlan.h b/net/8021q/vlan.h
index 14c421e..a6603a4 100644
--- a/net/8021q/vlan.h
+++ b/net/8021q/vlan.h
@@ -12,7 +12,7 @@
  */
 struct vlan_priority_tci_mapping {
 	u32					priority;
-	unsigned short				vlan_qos;
+	u16					vlan_qos;
 	struct vlan_priority_tci_mapping	*next;
 };
 
@@ -36,8 +36,8 @@ struct vlan_dev_info {
 	unsigned int				nr_egress_mappings;
 	struct vlan_priority_tci_mapping	*egress_priority_map[16];
 
-	unsigned short				vlan_id;
-	unsigned short				flags;
+	u16					vlan_id;
+	u16					flags;
 
 	struct net_device			*real_dev;
 	unsigned char				real_dev_addr[ETH_ALEN];
@@ -67,30 +67,29 @@ static inline struct vlan_dev_info *vlan_dev_info(const struct net_device *dev)
  *  Must be invoked with rcu_read_lock (ie preempt disabled)
  *  or with RTNL.
  */
-struct net_device *__find_vlan_dev(struct net_device *real_dev,
-				   unsigned short VID); /* vlan.c */
+struct net_device *__find_vlan_dev(struct net_device *real_dev, u16 vlan_id);
 
 /* found in vlan_dev.c */
 int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
 		  struct packet_type *ptype, struct net_device *orig_dev);
 void vlan_dev_set_ingress_priority(const struct net_device *dev,
-				   u32 skb_prio, short vlan_prio);
+				   u32 skb_prio, u16 vlan_prio);
 int vlan_dev_set_egress_priority(const struct net_device *dev,
-				 u32 skb_prio, short vlan_prio);
+				 u32 skb_prio, u16 vlan_prio);
 int vlan_dev_change_flags(const struct net_device *dev, u32 flag, u32 mask);
 void vlan_dev_get_realdev_name(const struct net_device *dev, char *result);
 
-int vlan_check_real_dev(struct net_device *real_dev, unsigned short vlan_id);
+int vlan_check_real_dev(struct net_device *real_dev, u16 vlan_id);
 void vlan_setup(struct net_device *dev);
 int register_vlan_dev(struct net_device *dev);
 void unregister_vlan_dev(struct net_device *dev);
 
 static inline u32 vlan_get_ingress_priority(struct net_device *dev,
-					    unsigned short vlan_tag)
+					    u16 vlan_tci)
 {
 	struct vlan_dev_info *vip = vlan_dev_info(dev);
 
-	return vip->ingress_priority_map[(vlan_tag >> 13) & 0x7];
+	return vip->ingress_priority_map[(vlan_tci >> 13) & 0x7];
 }
 
 #ifdef CONFIG_VLAN_8021Q_GVRP
diff --git a/net/8021q/vlan_core.c b/net/8021q/vlan_core.c
index 4daabc2..2bec74c 100644
--- a/net/8021q/vlan_core.c
+++ b/net/8021q/vlan_core.c
@@ -5,7 +5,7 @@
 
 /* VLAN rx hw acceleration helper.  This acts like netif_{rx,receive_skb}(). */
 int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp,
-		      unsigned short vlan_tag, int polling)
+		      u16 vlan_tci, int polling)
 {
 	struct net_device_stats *stats;
 
@@ -14,7 +14,7 @@ int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp,
 		return NET_RX_DROP;
 	}
 
-	skb->dev = vlan_group_get_device(grp, vlan_tag & VLAN_VID_MASK);
+	skb->dev = vlan_group_get_device(grp, vlan_tci & VLAN_VID_MASK);
 	if (skb->dev == NULL) {
 		dev_kfree_skb_any(skb);
 		/* Not NET_RX_DROP, this is not being dropped
@@ -27,7 +27,7 @@ int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp,
 	stats->rx_packets++;
 	stats->rx_bytes += skb->len;
 
-	skb->priority = vlan_get_ingress_priority(skb->dev, vlan_tag);
+	skb->priority = vlan_get_ingress_priority(skb->dev, vlan_tci);
 	switch (skb->pkt_type) {
 	case PACKET_BROADCAST:
 		break;
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index 2aab294..2ccac6b 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -150,9 +150,9 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
 		  struct packet_type *ptype, struct net_device *orig_dev)
 {
 	struct vlan_hdr *vhdr;
-	unsigned short vid;
 	struct net_device_stats *stats;
-	unsigned short vlan_TCI;
+	u16 vlan_id;
+	u16 vlan_tci;
 
 	skb = skb_share_check(skb, GFP_ATOMIC);
 	if (skb == NULL)
@@ -162,14 +162,14 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
 		goto err_free;
 
 	vhdr = (struct vlan_hdr *)skb->data;
-	vlan_TCI = ntohs(vhdr->h_vlan_TCI);
-	vid = (vlan_TCI & VLAN_VID_MASK);
+	vlan_tci = ntohs(vhdr->h_vlan_TCI);
+	vlan_id = vlan_tci & VLAN_VID_MASK;
 
 	rcu_read_lock();
-	skb->dev = __find_vlan_dev(dev, vid);
+	skb->dev = __find_vlan_dev(dev, vlan_id);
 	if (!skb->dev) {
 		pr_debug("%s: ERROR: No net_device for VID: %u on dev: %s\n",
-			 __func__, (unsigned int)vid, dev->name);
+			 __func__, vlan_id, dev->name);
 		goto err_unlock;
 	}
 
@@ -181,11 +181,10 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
 
 	skb_pull_rcsum(skb, VLAN_HLEN);
 
-	skb->priority = vlan_get_ingress_priority(skb->dev,
-						  ntohs(vhdr->h_vlan_TCI));
+	skb->priority = vlan_get_ingress_priority(skb->dev, vlan_tci);
 
 	pr_debug("%s: priority: %u for TCI: %hu\n",
-		 __func__, skb->priority, ntohs(vhdr->h_vlan_TCI));
+		 __func__, skb->priority, vlan_tci);
 
 	switch (skb->pkt_type) {
 	case PACKET_BROADCAST: /* Yeah, stats collect these together.. */
@@ -228,7 +227,7 @@ err_free:
 	return NET_RX_DROP;
 }
 
-static inline unsigned short
+static inline u16
 vlan_dev_get_egress_qos_mask(struct net_device *dev, struct sk_buff *skb)
 {
 	struct vlan_priority_tci_mapping *mp;
@@ -260,7 +259,7 @@ static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
 				unsigned int len)
 {
 	struct vlan_hdr *vhdr;
-	unsigned short veth_TCI = 0;
+	u16 vlan_tci = 0;
 	int rc = 0;
 	int build_vlan_header = 0;
 	struct net_device *vdev = dev;
@@ -292,10 +291,10 @@ static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
 		 * VLAN ID	 12 bits (low bits)
 		 *
 		 */
-		veth_TCI = vlan_dev_info(dev)->vlan_id;
-		veth_TCI |= vlan_dev_get_egress_qos_mask(dev, skb);
+		vlan_tci = vlan_dev_info(dev)->vlan_id;
+		vlan_tci |= vlan_dev_get_egress_qos_mask(dev, skb);
 
-		vhdr->h_vlan_TCI = htons(veth_TCI);
+		vhdr->h_vlan_TCI = htons(vlan_tci);
 
 		/*
 		 *  Set the protocol type. For a packet of type ETH_P_802_3 we
@@ -373,7 +372,7 @@ static int vlan_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
 	if (veth->h_vlan_proto != htons(ETH_P_8021Q) ||
 		vlan_dev_info(dev)->flags & VLAN_FLAG_REORDER_HDR) {
 		int orig_headroom = skb_headroom(skb);
-		unsigned short veth_TCI;
+		u16 vlan_tci;
 
 		/* This is not a VLAN frame...but we can fix that! */
 		vlan_dev_info(dev)->cnt_encap_on_xmit++;
@@ -386,10 +385,10 @@ static int vlan_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
 		 * CFI		 1 bit
 		 * VLAN ID	 12 bits (low bits)
 		 */
-		veth_TCI = vlan_dev_info(dev)->vlan_id;
-		veth_TCI |= vlan_dev_get_egress_qos_mask(dev, skb);
+		vlan_tci = vlan_dev_info(dev)->vlan_id;
+		vlan_tci |= vlan_dev_get_egress_qos_mask(dev, skb);
 
-		skb = __vlan_put_tag(skb, veth_TCI);
+		skb = __vlan_put_tag(skb, vlan_tci);
 		if (!skb) {
 			stats->tx_dropped++;
 			return 0;
@@ -422,7 +421,7 @@ static int vlan_dev_hwaccel_hard_start_xmit(struct sk_buff *skb,
 					    struct net_device *dev)
 {
 	struct net_device_stats *stats = &dev->stats;
-	unsigned short veth_TCI;
+	u16 vlan_tci;
 
 	/* Construct the second two bytes. This field looks something
 	 * like:
@@ -430,9 +429,9 @@ static int vlan_dev_hwaccel_hard_start_xmit(struct sk_buff *skb,
 	 * CFI		 1 bit
 	 * VLAN ID	 12 bits (low bits)
 	 */
-	veth_TCI = vlan_dev_info(dev)->vlan_id;
-	veth_TCI |= vlan_dev_get_egress_qos_mask(dev, skb);
-	skb = __vlan_hwaccel_put_tag(skb, veth_TCI);
+	vlan_tci = vlan_dev_info(dev)->vlan_id;
+	vlan_tci |= vlan_dev_get_egress_qos_mask(dev, skb);
+	skb = __vlan_hwaccel_put_tag(skb, vlan_tci);
 
 	stats->tx_packets++;
 	stats->tx_bytes += skb->len;
@@ -457,7 +456,7 @@ static int vlan_dev_change_mtu(struct net_device *dev, int new_mtu)
 }
 
 void vlan_dev_set_ingress_priority(const struct net_device *dev,
-				   u32 skb_prio, short vlan_prio)
+				   u32 skb_prio, u16 vlan_prio)
 {
 	struct vlan_dev_info *vlan = vlan_dev_info(dev);
 
@@ -470,7 +469,7 @@ void vlan_dev_set_ingress_priority(const struct net_device *dev,
 }
 
 int vlan_dev_set_egress_priority(const struct net_device *dev,
-				 u32 skb_prio, short vlan_prio)
+				 u32 skb_prio, u16 vlan_prio)
 {
 	struct vlan_dev_info *vlan = vlan_dev_info(dev);
 	struct vlan_priority_tci_mapping *mp = NULL;
diff --git a/net/8021q/vlan_gvrp.c b/net/8021q/vlan_gvrp.c
index db97816..061cece 100644
--- a/net/8021q/vlan_gvrp.c
+++ b/net/8021q/vlan_gvrp.c
@@ -30,19 +30,19 @@ static struct garp_application vlan_gvrp_app __read_mostly = {
 int vlan_gvrp_request_join(const struct net_device *dev)
 {
 	const struct vlan_dev_info *vlan = vlan_dev_info(dev);
-	__be16 vid = htons(vlan->vlan_id);
+	__be16 vlan_id = htons(vlan->vlan_id);
 
 	return garp_request_join(vlan->real_dev, &vlan_gvrp_app,
-				 &vid, sizeof(vid), GVRP_ATTR_VID);
+				 &vlan_id, sizeof(vlan_id), GVRP_ATTR_VID);
 }
 
 void vlan_gvrp_request_leave(const struct net_device *dev)
 {
 	const struct vlan_dev_info *vlan = vlan_dev_info(dev);
-	__be16 vid = htons(vlan->vlan_id);
+	__be16 vlan_id = htons(vlan->vlan_id);
 
 	garp_request_leave(vlan->real_dev, &vlan_gvrp_app,
-			   &vid, sizeof(vid), GVRP_ATTR_VID);
+			   &vlan_id, sizeof(vlan_id), GVRP_ATTR_VID);
 }
 
 int vlan_gvrp_init_applicant(struct net_device *dev)

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: vlan 03/07: Add ethtool support
  2008-07-07 12:36 ` vlan 03/07: Add ethtool support Patrick McHardy
@ 2008-07-07 16:52   ` Ben Hutchings
  2008-07-07 16:59     ` Patrick McHardy
  0 siblings, 1 reply; 15+ messages in thread
From: Ben Hutchings @ 2008-07-07 16:52 UTC (permalink / raw)
  To: Patrick McHardy; +Cc: davem, netdev

Patrick McHardy wrote:
> vlan: Add ethtool support
> 
> Add ethtool support for querying the device for offload settings.
> 
> Signed-off-by: Patrick McHardy <kaber@trash.net>
[...]
> +static u32 vlan_ethtool_get_rx_csum(struct net_device *dev)
> +{
> +	const struct vlan_dev_info *vlan = vlan_dev_info(dev);
> +	struct net_device *real_dev = vlan->real_dev;
> +
> +	if (real_dev->ethtool_ops == NULL ||
> +	    real_dev->ethtool_ops->get_rx_csum == NULL)
> +		return 0;
> +	return real_dev->ethtool_ops->get_rx_csum(real_dev);

But we don't know whether RX checksum offload applies to VLAN-tagged
packets (or, admittedly, any specific protocol).  It would be nice if there
was a feature flag for this so it could be advertised in vlan_features.

> +}
> +
> +static const struct ethtool_ops vlan_ethtool_ops = {
> +	.get_link		= ethtool_op_get_link,
> +	.get_rx_csum		= vlan_ethtool_get_rx_csum,

Can't we also add:

	.get_tx_csum		= ethtool_op_get_tx_csum,
	.get_sg			= ethtool_op_get_sg,
	.get_tso		= ethtool_op_get_tso,
	.get_flags		= ethtool_op_get_flags,

?

Ben.

-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: vlan 03/07: Add ethtool support
  2008-07-07 16:52   ` Ben Hutchings
@ 2008-07-07 16:59     ` Patrick McHardy
  2008-07-07 17:21       ` Ben Hutchings
  0 siblings, 1 reply; 15+ messages in thread
From: Patrick McHardy @ 2008-07-07 16:59 UTC (permalink / raw)
  To: Ben Hutchings; +Cc: davem, netdev

Ben Hutchings wrote:
> Patrick McHardy wrote:
>> vlan: Add ethtool support
>>
>> Add ethtool support for querying the device for offload settings.
>>
>> Signed-off-by: Patrick McHardy <kaber@trash.net>
> [...]
>> +static u32 vlan_ethtool_get_rx_csum(struct net_device *dev)
>> +{
>> +	const struct vlan_dev_info *vlan = vlan_dev_info(dev);
>> +	struct net_device *real_dev = vlan->real_dev;
>> +
>> +	if (real_dev->ethtool_ops == NULL ||
>> +	    real_dev->ethtool_ops->get_rx_csum == NULL)
>> +		return 0;
>> +	return real_dev->ethtool_ops->get_rx_csum(real_dev);
> 
> But we don't know whether RX checksum offload applies to VLAN-tagged
> packets (or, admittedly, any specific protocol).  It would be nice if there
> was a feature flag for this so it could be advertised in vlan_features.

True, for now the assumption is that it works for VLANs.
I don't think that assumption is unreasonable, but I can
look into a separate flag for this.

> 
>> +}
>> +
>> +static const struct ethtool_ops vlan_ethtool_ops = {
>> +	.get_link		= ethtool_op_get_link,
>> +	.get_rx_csum		= vlan_ethtool_get_rx_csum,
> 
> Can't we also add:
> 
> 	.get_tx_csum		= ethtool_op_get_tx_csum,
> 	.get_sg			= ethtool_op_get_sg,
> 	.get_tso		= ethtool_op_get_tso,
> 	.get_flags		= ethtool_op_get_flags,

Besides get_flags all of these are handled by default handlers.
What is get_flags used for?

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: vlan 03/07: Add ethtool support
  2008-07-07 16:59     ` Patrick McHardy
@ 2008-07-07 17:21       ` Ben Hutchings
  2008-07-07 17:47         ` Patrick McHardy
  0 siblings, 1 reply; 15+ messages in thread
From: Ben Hutchings @ 2008-07-07 17:21 UTC (permalink / raw)
  To: Patrick McHardy; +Cc: davem, netdev

Patrick McHardy wrote:
> Ben Hutchings wrote:
> >Patrick McHardy wrote:
> >>vlan: Add ethtool support
> >>
> >>Add ethtool support for querying the device for offload settings.
> >>
> >>Signed-off-by: Patrick McHardy <kaber@trash.net>
> >[...]
> >>+static u32 vlan_ethtool_get_rx_csum(struct net_device *dev)
> >>+{
> >>+	const struct vlan_dev_info *vlan = vlan_dev_info(dev);
> >>+	struct net_device *real_dev = vlan->real_dev;
> >>+
> >>+	if (real_dev->ethtool_ops == NULL ||
> >>+	    real_dev->ethtool_ops->get_rx_csum == NULL)
> >>+		return 0;
> >>+	return real_dev->ethtool_ops->get_rx_csum(real_dev);
> >
> >But we don't know whether RX checksum offload applies to VLAN-tagged
> >packets (or, admittedly, any specific protocol).  It would be nice if there
> >was a feature flag for this so it could be advertised in vlan_features.
> 
> True, for now the assumption is that it works for VLANs.
> I don't think that assumption is unreasonable, but I can
> look into a separate flag for this.

I would be surprised if there aren't some NICs that only check frames with
protocol/length set to ETH_P_IP.

> >>+}
> >>+
> >>+static const struct ethtool_ops vlan_ethtool_ops = {
> >>+	.get_link		= ethtool_op_get_link,
> >>+	.get_rx_csum		= vlan_ethtool_get_rx_csum,
> >
> >Can't we also add:
> >
> >	.get_tx_csum		= ethtool_op_get_tx_csum,
> >	.get_sg			= ethtool_op_get_sg,
> >	.get_tso		= ethtool_op_get_tso,
> >	.get_flags		= ethtool_op_get_flags,
> 
> Besides get_flags all of these are handled by default handlers.

So they are.

> What is get_flags used for?

Currently only LRO, but potentially other offload features.

Ben.

-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: vlan 03/07: Add ethtool support
  2008-07-07 17:21       ` Ben Hutchings
@ 2008-07-07 17:47         ` Patrick McHardy
  2008-07-08 13:54           ` Ben Hutchings
  0 siblings, 1 reply; 15+ messages in thread
From: Patrick McHardy @ 2008-07-07 17:47 UTC (permalink / raw)
  To: Ben Hutchings; +Cc: davem, netdev

Ben Hutchings wrote:
> Patrick McHardy wrote:
>> Ben Hutchings wrote:
>>> Patrick McHardy wrote:
>>>> vlan: Add ethtool support
>>>>
>>>> Add ethtool support for querying the device for offload settings.
>>>>
>>>> Signed-off-by: Patrick McHardy <kaber@trash.net>
>>> [...]
>>>> +static u32 vlan_ethtool_get_rx_csum(struct net_device *dev)
>>>> +{
>>>> +	const struct vlan_dev_info *vlan = vlan_dev_info(dev);
>>>> +	struct net_device *real_dev = vlan->real_dev;
>>>> +
>>>> +	if (real_dev->ethtool_ops == NULL ||
>>>> +	    real_dev->ethtool_ops->get_rx_csum == NULL)
>>>> +		return 0;
>>>> +	return real_dev->ethtool_ops->get_rx_csum(real_dev);
>>> But we don't know whether RX checksum offload applies to VLAN-tagged
>>> packets (or, admittedly, any specific protocol).  It would be nice if there
>>> was a feature flag for this so it could be advertised in vlan_features.
>> True, for now the assumption is that it works for VLANs.
>> I don't think that assumption is unreasonable, but I can
>> look into a separate flag for this.
> 
> I would be surprised if there aren't some NICs that only check frames with
> protocol/length set to ETH_P_IP.

Yes, probably. But this is only informational and it won't be
any wronger than on the device itself. So no big deal I'd say,
but if you prefer I can also remove the TX csum support.

>>> Can't we also add:
>>>
>>> 	.get_tx_csum		= ethtool_op_get_tx_csum,
>>> 	.get_sg			= ethtool_op_get_sg,
>>> 	.get_tso		= ethtool_op_get_tso,
>>> 	.get_flags		= ethtool_op_get_flags,
>> Besides get_flags all of these are handled by default handlers.
> 
> So they are.
> 
>> What is get_flags used for?
> 
> Currently only LRO, but potentially other offload features.

LRO is currently not supported by the VLAN code, at least
not directly (drivers supporting VLAN accel can do VLAN
LRO though). So for now it seems useless to add it.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: vlan 00/07: VLAN update part 1
  2008-07-07 12:35 vlan 00/07: VLAN update part 1 Patrick McHardy
                   ` (6 preceding siblings ...)
  2008-07-07 12:36 ` vlan 07/07: TCI related type and naming cleanups Patrick McHardy
@ 2008-07-08 10:44 ` David Miller
  7 siblings, 0 replies; 15+ messages in thread
From: David Miller @ 2008-07-08 10:44 UTC (permalink / raw)
  To: kaber; +Cc: netdev

From: Patrick McHardy <kaber@trash.net>
Date: Mon,  7 Jul 2008 14:35:58 +0200 (MEST)

> following is a first VLAN update for net-next-2.6, containing a fix for the
> skb->network_header issue pointed out by Lennert, VLAN ethtool support for
> querying offload settings, uninlining of __vlan_hwaccel_rx and some assorted
> cleanups.
> 
> A second update in my queue on top of this one will attack the packet socket
> inconsistencies with VLAN acceleration, but I've split the set for easier
> review of the more interesting changes.
> 
> Please apply, thanks.

Looks good.  Applied and pushed out to net-next-2.6

Thanks!

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: vlan 03/07: Add ethtool support
  2008-07-07 17:47         ` Patrick McHardy
@ 2008-07-08 13:54           ` Ben Hutchings
  2008-07-08 14:01             ` Patrick McHardy
  0 siblings, 1 reply; 15+ messages in thread
From: Ben Hutchings @ 2008-07-08 13:54 UTC (permalink / raw)
  To: Patrick McHardy; +Cc: davem, netdev

Patrick McHardy wrote:
> Ben Hutchings wrote:
> >Patrick McHardy wrote:
> >>Ben Hutchings wrote:
> >>>Patrick McHardy wrote:
> >>>>vlan: Add ethtool support
> >>>>
> >>>>Add ethtool support for querying the device for offload settings.
> >>>>
> >>>>Signed-off-by: Patrick McHardy <kaber@trash.net>
> >>>[...]
> >>>>+static u32 vlan_ethtool_get_rx_csum(struct net_device *dev)
> >>>>+{
> >>>>+	const struct vlan_dev_info *vlan = vlan_dev_info(dev);
> >>>>+	struct net_device *real_dev = vlan->real_dev;
> >>>>+
> >>>>+	if (real_dev->ethtool_ops == NULL ||
> >>>>+	    real_dev->ethtool_ops->get_rx_csum == NULL)
> >>>>+		return 0;
> >>>>+	return real_dev->ethtool_ops->get_rx_csum(real_dev);
> >>>But we don't know whether RX checksum offload applies to VLAN-tagged
> >>>packets (or, admittedly, any specific protocol).  It would be nice if 
> >>>there
> >>>was a feature flag for this so it could be advertised in vlan_features.
> >>True, for now the assumption is that it works for VLANs.
> >>I don't think that assumption is unreasonable, but I can
> >>look into a separate flag for this.
> >
> >I would be surprised if there aren't some NICs that only check frames with
> >protocol/length set to ETH_P_IP.
> 
> Yes, probably. But this is only informational and it won't be
> any wronger than on the device itself. So no big deal I'd say,
> but if you prefer I can also remove the TX csum support.

As I said there's no way to see which protocols RX csum offload works for
anyway, so just showing whether it's enabled on the physical device is no
worse than the current behaviour for physical devices.

> >>>Can't we also add:
> >>>
> >>>	.get_tx_csum		= ethtool_op_get_tx_csum,
> >>>	.get_sg			= ethtool_op_get_sg,
> >>>	.get_tso		= ethtool_op_get_tso,
> >>>	.get_flags		= ethtool_op_get_flags,
> >>Besides get_flags all of these are handled by default handlers.
> >
> >So they are.
> >
> >>What is get_flags used for?
> >
> >Currently only LRO, but potentially other offload features.
> 
> LRO is currently not supported by the VLAN code, at least
> not directly (drivers supporting VLAN accel can do VLAN
> LRO though). So for now it seems useless to add it.

If the physical device driver is doing VLAN LRO then doesn't it make sense
to expose this in the VLAN device?

Ben.

-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: vlan 03/07: Add ethtool support
  2008-07-08 13:54           ` Ben Hutchings
@ 2008-07-08 14:01             ` Patrick McHardy
  0 siblings, 0 replies; 15+ messages in thread
From: Patrick McHardy @ 2008-07-08 14:01 UTC (permalink / raw)
  To: Ben Hutchings; +Cc: davem, netdev

Ben Hutchings wrote:
> Patrick McHardy wrote:
>   
>> Ben Hutchings wrote:
>>     
>>> I would be surprised if there aren't some NICs that only check frames with
>>> protocol/length set to ETH_P_IP.
>>>       
>> Yes, probably. But this is only informational and it won't be
>> any wronger than on the device itself. So no big deal I'd say,
>> but if you prefer I can also remove the TX csum support.
>>     
>
> As I said there's no way to see which protocols RX csum offload works for
> anyway, so just showing whether it's enabled on the physical device is no
> worse than the current behaviour for physical devices.

I must have misunderstood you then. Thats the way I see
it as well.

>> LRO is currently not supported by the VLAN code, at least
>> not directly (drivers supporting VLAN accel can do VLAN
>> LRO though). So for now it seems useless to add it.
>>     
>
> If the physical device driver is doing VLAN LRO then doesn't it make sense
> to expose this in the VLAN device?
>   

You're right, that makes sense. I'll add a patch to my next update to do
this.

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2008-07-08 14:12 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-07 12:35 vlan 00/07: VLAN update part 1 Patrick McHardy
2008-07-07 12:35 ` vlan 01/07: fix network_header/mac_header adjustments Patrick McHardy
2008-07-07 12:36 ` vlan 02/07: Use is_vlan_dev() Patrick McHardy
2008-07-07 12:36 ` vlan 03/07: Add ethtool support Patrick McHardy
2008-07-07 16:52   ` Ben Hutchings
2008-07-07 16:59     ` Patrick McHardy
2008-07-07 17:21       ` Ben Hutchings
2008-07-07 17:47         ` Patrick McHardy
2008-07-08 13:54           ` Ben Hutchings
2008-07-08 14:01             ` Patrick McHardy
2008-07-07 12:36 ` vlan 04/07: uninline __vlan_hwaccel_rx Patrick McHardy
2008-07-07 12:36 ` vlan 05/07: move struct vlan_dev_info to private header Patrick McHardy
2008-07-07 12:36 ` vlan 06/07: remove useless struct hlist_node declaration from if_vlan.h Patrick McHardy
2008-07-07 12:36 ` vlan 07/07: TCI related type and naming cleanups Patrick McHardy
2008-07-08 10:44 ` vlan 00/07: VLAN update part 1 David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).