All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 0/7] Move vlan acceleration into networking core.
@ 2010-10-13 20:02 Jesse Gross
  2010-10-13 20:02 ` [RFC PATCH 1/7] ebtables: Allow filtering of hardware accelerated vlan frames Jesse Gross
                   ` (7 more replies)
  0 siblings, 8 replies; 15+ messages in thread
From: Jesse Gross @ 2010-10-13 20:02 UTC (permalink / raw)
  To: davem; +Cc: netdev

Hardware vlan acceleration behaves fairly differently from other types of
offloading, which limits its usefulness.  This patch series aims to bring
it more in line with other common forms of acceleration, such as checksum
offloading and TSO.  In doing this it eliminates common driver bugs, increases
flexibility, and improves performance, while reducing the number of lines of
code.

The first four patches can be applied immediately, while the last three need
to wait until all drivers that support vlan acceleration are updated.  If
people agree that this patch set makes sense I will go ahead and switch over
the dozen or so drivers that would need to change.

Jesse Gross (7):
  ebtables: Allow filtering of hardware accelerated vlan frames.
  vlan: Centralize handling of hardware acceleration.
  bnx2: Update bnx2 to use new vlan accleration.
  ixgbe: Update ixgbe to use new vlan accleration.
  lro: Remove explicit vlan support.
  bonding: Update bonding for new vlan model.
  vlan: Remove accleration legacy functions.

 drivers/net/bnx2.c              |   75 ++--------------------
 drivers/net/bnx2.h              |    4 -
 drivers/net/bonding/bond_alb.c  |    8 +--
 drivers/net/bonding/bond_ipv6.c |    5 +-
 drivers/net/bonding/bond_main.c |  134 ++++++++-------------------------------
 drivers/net/bonding/bonding.h   |    1 -
 drivers/net/ixgbe/ixgbe.h       |    4 +-
 drivers/net/ixgbe/ixgbe_main.c  |   60 +++++-------------
 include/linux/if_vlan.h         |   87 ++++++++------------------
 include/linux/inet_lro.h        |   20 ------
 include/linux/netdevice.h       |   20 +++---
 net/8021q/vlan.c                |  100 +++++++-----------------------
 net/8021q/vlan.h                |   17 -----
 net/8021q/vlan_core.c           |  132 ++++++--------------------------------
 net/8021q/vlan_dev.c            |    2 +-
 net/bridge/br_netfilter.c       |   16 +++--
 net/bridge/netfilter/ebt_vlan.c |   42 +++++++-----
 net/bridge/netfilter/ebtables.c |   15 +++-
 net/core/dev.c                  |   42 +++++++++++--
 net/ipv4/inet_lro.c             |   74 +++------------------
 20 files changed, 225 insertions(+), 633 deletions(-)


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

* [RFC PATCH 1/7] ebtables: Allow filtering of hardware accelerated vlan frames.
  2010-10-13 20:02 [RFC PATCH 0/7] Move vlan acceleration into networking core Jesse Gross
@ 2010-10-13 20:02 ` Jesse Gross
  2010-10-18 19:58   ` Ben Hutchings
  2010-10-13 20:02 ` [RFC PATCH 2/7] vlan: Centralize handling of hardware acceleration Jesse Gross
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 15+ messages in thread
From: Jesse Gross @ 2010-10-13 20:02 UTC (permalink / raw)
  To: davem; +Cc: netdev

An upcoming commit will allow packets with hardware vlan acceleration
information to be passed though more parts of the network stack, including
packets trunked through the bridge.  This adds support for matching and
filtering those packets through ebtables.

Signed-off-by: Jesse Gross <jesse@nicira.com>
---
 net/bridge/br_netfilter.c       |   16 +++++++++-------
 net/bridge/netfilter/ebt_vlan.c |   38 +++++++++++++++++++++++---------------
 net/bridge/netfilter/ebtables.c |   15 +++++++++++----
 3 files changed, 43 insertions(+), 26 deletions(-)

diff --git a/net/bridge/br_netfilter.c b/net/bridge/br_netfilter.c
index 7f9ce96..d6a4fec 100644
--- a/net/bridge/br_netfilter.c
+++ b/net/bridge/br_netfilter.c
@@ -64,22 +64,24 @@ static int brnf_filter_pppoe_tagged __read_mostly = 0;
 
 static inline __be16 vlan_proto(const struct sk_buff *skb)
 {
-	return vlan_eth_hdr(skb)->h_vlan_encapsulated_proto;
+	if (skb->protocol == htons(ETH_P_8021Q))
+		return vlan_eth_hdr(skb)->h_vlan_encapsulated_proto;
+	else if (vlan_tx_tag_present(skb))
+		return skb->protocol;
+	else
+		return 0;
 }
 
 #define IS_VLAN_IP(skb) \
-	(skb->protocol == htons(ETH_P_8021Q) && \
-	 vlan_proto(skb) == htons(ETH_P_IP) && 	\
+	(vlan_proto(skb) == htons(ETH_P_IP) && 	\
 	 brnf_filter_vlan_tagged)
 
 #define IS_VLAN_IPV6(skb) \
-	(skb->protocol == htons(ETH_P_8021Q) && \
-	 vlan_proto(skb) == htons(ETH_P_IPV6) &&\
+	(vlan_proto(skb) == htons(ETH_P_IPV6) &&\
 	 brnf_filter_vlan_tagged)
 
 #define IS_VLAN_ARP(skb) \
-	(skb->protocol == htons(ETH_P_8021Q) &&	\
-	 vlan_proto(skb) == htons(ETH_P_ARP) &&	\
+	(vlan_proto(skb) == htons(ETH_P_ARP) &&	\
 	 brnf_filter_vlan_tagged)
 
 static inline __be16 pppoe_proto(const struct sk_buff *skb)
diff --git a/net/bridge/netfilter/ebt_vlan.c b/net/bridge/netfilter/ebt_vlan.c
index 87b53b3..a39d92d 100644
--- a/net/bridge/netfilter/ebt_vlan.c
+++ b/net/bridge/netfilter/ebt_vlan.c
@@ -39,8 +39,6 @@ static bool
 ebt_vlan_mt(const struct sk_buff *skb, struct xt_action_param *par)
 {
 	const struct ebt_vlan_info *info = par->matchinfo;
-	const struct vlan_hdr *fp;
-	struct vlan_hdr _frame;
 
 	unsigned short TCI;	/* Whole TCI, given from parsed frame */
 	unsigned short id;	/* VLAN ID, given from frame TCI */
@@ -48,21 +46,31 @@ ebt_vlan_mt(const struct sk_buff *skb, struct xt_action_param *par)
 	/* VLAN encapsulated Type/Length field, given from orig frame */
 	__be16 encap;
 
-	fp = skb_header_pointer(skb, 0, sizeof(_frame), &_frame);
-	if (fp == NULL)
-		return false;
-
-	/* Tag Control Information (TCI) consists of the following elements:
-	 * - User_priority. The user_priority field is three bits in length,
-	 * interpreted as a binary number.
-	 * - Canonical Format Indicator (CFI). The Canonical Format Indicator
-	 * (CFI) is a single bit flag value. Currently ignored.
-	 * - VLAN Identifier (VID). The VID is encoded as
-	 * an unsigned binary number. */
-	TCI = ntohs(fp->h_vlan_TCI);
+	if (skb->protocol == htons(ETH_P_8021Q)) {
+		const struct vlan_hdr *fp;
+		struct vlan_hdr _frame;
+
+		fp = skb_header_pointer(skb, 0, sizeof(_frame), &_frame);
+		if (fp == NULL)
+			return false;
+
+		/* Tag Control Information (TCI) consists of the following elements:
+		 * - User_priority. The user_priority field is three bits in length,
+		 * interpreted as a binary number.
+		 * - Canonical Format Indicator (CFI). The Canonical Format Indicator
+		 * (CFI) is a single bit flag value. Currently ignored.
+		 * - VLAN Identifier (VID). The VID is encoded as
+		 * an unsigned binary number. */
+		TCI = ntohs(fp->h_vlan_TCI);
+
+		encap = fp->h_vlan_encapsulated_proto;
+	} else {
+		TCI = vlan_tx_tag_get(skb);
+		encap = skb->protocol;
+	}
+
 	id = TCI & VLAN_VID_MASK;
 	prio = (TCI >> 13) & 0x7;
-	encap = fp->h_vlan_encapsulated_proto;
 
 	/* Checking VLAN Identifier (VID) */
 	if (GET_BITMASK(EBT_VLAN_ID))
diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
index bcc102e..a1dcf83 100644
--- a/net/bridge/netfilter/ebtables.c
+++ b/net/bridge/netfilter/ebtables.c
@@ -124,16 +124,23 @@ ebt_dev_check(const char *entry, const struct net_device *device)
 #define FWINV2(bool,invflg) ((bool) ^ !!(e->invflags & invflg))
 /* process standard matches */
 static inline int
-ebt_basic_match(const struct ebt_entry *e, const struct ethhdr *h,
+ebt_basic_match(const struct ebt_entry *e, const struct sk_buff *skb,
                 const struct net_device *in, const struct net_device *out)
 {
+	const struct ethhdr *h = eth_hdr(skb);
+	__be16 ethproto;
 	int verdict, i;
 
+	if (vlan_tx_tag_present(skb))
+		ethproto = htons(ETH_P_8021Q);
+	else
+		ethproto = h->h_proto;
+
 	if (e->bitmask & EBT_802_3) {
-		if (FWINV2(ntohs(h->h_proto) >= 1536, EBT_IPROTO))
+		if (FWINV2(ntohs(ethproto) >= 1536, EBT_IPROTO))
 			return 1;
 	} else if (!(e->bitmask & EBT_NOPROTO) &&
-	   FWINV2(e->ethproto != h->h_proto, EBT_IPROTO))
+	   FWINV2(e->ethproto != ethproto, EBT_IPROTO))
 		return 1;
 
 	if (FWINV2(ebt_dev_check(e->in, in), EBT_IIN))
@@ -213,7 +220,7 @@ unsigned int ebt_do_table (unsigned int hook, struct sk_buff *skb,
 	base = private->entries;
 	i = 0;
 	while (i < nentries) {
-		if (ebt_basic_match(point, eth_hdr(skb), in, out))
+		if (ebt_basic_match(point, skb, in, out))
 			goto letscontinue;
 
 		if (EBT_MATCH_ITERATE(point, ebt_do_match, skb, &acpar) != 0)
-- 
1.7.0.4


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

* [RFC PATCH 2/7] vlan: Centralize handling of hardware acceleration.
  2010-10-13 20:02 [RFC PATCH 0/7] Move vlan acceleration into networking core Jesse Gross
  2010-10-13 20:02 ` [RFC PATCH 1/7] ebtables: Allow filtering of hardware accelerated vlan frames Jesse Gross
@ 2010-10-13 20:02 ` Jesse Gross
  2010-10-13 21:12   ` Eric Dumazet
  2010-10-13 20:02 ` [RFC PATCH 3/7] bnx2: Update bnx2 to use new vlan accleration Jesse Gross
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 15+ messages in thread
From: Jesse Gross @ 2010-10-13 20:02 UTC (permalink / raw)
  To: davem; +Cc: netdev

Currently each driver that is capable of vlan hardware acceleration
must be aware of the vlan groups that are configured and then pass
the stripped tag to a specialized receive function.  This is
different from other types of hardware offload in that it places a
significant amount of knowledge in the driver itself rather keeping
it in the networking core.

This makes vlan offloading function more similarly to other forms
of offloading (such as checksum offloading or TSO) by doing the
following:
* On receive, stripped vlans are passed directly to the network
core, without attempting to check for vlan groups or reconstructing
the header if no group
* vlans are made less special by folding the logic into the main
receive routines
* On transmit, the device layer will add the vlan header in software
if the hardware doesn't support it, instead of spreading that logic
out in upper layers, such as bonding.

There are a number of advantages to this:
* Fixes all bugs with drivers incorrectly dropping vlan headers at once.
* Avoids having to disable VLAN acceleration when in promiscuous mode
(good for bridging since it always puts devices in promiscuous mode).
* Keeps VLAN tag separate until given to ultimate consumer, which
avoids needing to do header reconstruction as in tg3 unless absolutely
necessary.
* Consolidates common code in core networking.

Signed-off-by: Jesse Gross <jesse@nicira.com>
---
 include/linux/if_vlan.h         |   27 ++++++++-
 include/linux/netdevice.h       |   12 +++-
 net/8021q/vlan.c                |  102 ++++++++-----------------------
 net/8021q/vlan.h                |   17 -----
 net/8021q/vlan_core.c           |  125 +++++++++------------------------------
 net/8021q/vlan_dev.c            |    2 +-
 net/bridge/netfilter/ebt_vlan.c |    4 +-
 net/core/dev.c                  |   42 ++++++++++++--
 8 files changed, 129 insertions(+), 202 deletions(-)

diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index a523207..e21028b 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -68,6 +68,7 @@ static inline struct vlan_ethhdr *vlan_eth_hdr(const struct sk_buff *skb)
 #define VLAN_CFI_MASK		0x1000 /* Canonical Format Indicator */
 #define VLAN_TAG_PRESENT	VLAN_CFI_MASK
 #define VLAN_VID_MASK		0x0fff /* VLAN Identifier */
+#define VLAN_N_VID		4096
 
 /* found in socket.c */
 extern void vlan_ioctl_set(int (*hook)(struct net *, void __user *));
@@ -76,7 +77,7 @@ extern void vlan_ioctl_set(int (*hook)(struct net *, void __user *));
  * depends on completely exhausting the VLAN identifier space.  Thus
  * it gives constant time look-up, but in many cases it wastes memory.
  */
-#define VLAN_GROUP_ARRAY_LEN          4096
+#define VLAN_GROUP_ARRAY_LEN          VLAN_N_VID
 #define VLAN_GROUP_ARRAY_SPLIT_PARTS  8
 #define VLAN_GROUP_ARRAY_PART_LEN     (VLAN_GROUP_ARRAY_LEN/VLAN_GROUP_ARRAY_SPLIT_PARTS)
 
@@ -114,12 +115,24 @@ static inline void vlan_group_set_device(struct vlan_group *vg,
 #define vlan_tx_tag_get(__skb)		((__skb)->vlan_tci & ~VLAN_TAG_PRESENT)
 
 #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
+/* Must be invoked with rcu_read_lock or with RTNL. */
+static inline struct net_device *vlan_find_dev(struct net_device *real_dev,
+					       u16 vlan_id)
+{
+	struct vlan_group *grp = rcu_dereference(real_dev->vlgrp);
+
+	if (grp)
+		return vlan_group_get_device(grp, vlan_id);
+
+	return NULL;
+}
+
 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,
 			     u16 vlan_tci, int polling);
-extern void vlan_hwaccel_do_receive(struct sk_buff *skb);
+extern int vlan_hwaccel_do_receive(struct sk_buff *skb);
 extern gro_result_t
 vlan_gro_receive(struct napi_struct *napi, struct vlan_group *grp,
 		 unsigned int vlan_tci, struct sk_buff *skb);
@@ -128,6 +141,12 @@ vlan_gro_frags(struct napi_struct *napi, struct vlan_group *grp,
 	       unsigned int vlan_tci);
 
 #else
+static inline struct net_device *vlan_find_dev(struct net_device *real_dev,
+					       u16 vlan_id)
+{
+	return NULL;
+}
+
 static inline struct net_device *vlan_dev_real_dev(const struct net_device *dev)
 {
 	BUG();
@@ -147,8 +166,10 @@ static inline int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp,
 	return NET_XMIT_SUCCESS;
 }
 
-static inline void vlan_hwaccel_do_receive(struct sk_buff *skb)
+static inline int vlan_hwaccel_do_receive(struct sk_buff *skb)
 {
+	BUG();
+	return 0;
 }
 
 static inline gro_result_t
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 14fbb04..ef4bbcb 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -942,7 +942,10 @@ struct net_device {
 
 
 	/* Protocol specific pointers */
-	
+
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
+	struct vlan_group	*vlgrp;		/* VLAN group */
+#endif
 #ifdef CONFIG_NET_DSA
 	void			*dsa_ptr;	/* dsa specific data */
 #endif
@@ -2248,8 +2251,13 @@ static inline int skb_gso_ok(struct sk_buff *skb, int features)
 
 static inline int netif_needs_gso(struct net_device *dev, struct sk_buff *skb)
 {
+	int features = dev->features;
+
+	if (skb->protocol == htons(ETH_P_8021Q) || skb->vlan_tci)
+		features &= dev->vlan_features;
+
 	return skb_is_gso(skb) &&
-	       (!skb_gso_ok(skb, dev->features) ||
+	       (!skb_gso_ok(skb, features) ||
 		unlikely(skb->ip_summed != CHECKSUM_PARTIAL));
 }
 
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index 25c2133..77634b9 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -44,9 +44,6 @@
 
 int vlan_net_id __read_mostly;
 
-/* Our listing of VLAN group(s) */
-static struct hlist_head vlan_group_hash[VLAN_GRP_HASH_SIZE];
-
 const char vlan_fullname[] = "802.1Q VLAN Support";
 const char vlan_version[] = DRV_VERSION;
 static const char vlan_copyright[] = "Ben Greear <greearb@candelatech.com>";
@@ -59,40 +56,6 @@ static struct packet_type vlan_packet_type __read_mostly = {
 
 /* End of global variables definitions. */
 
-static inline unsigned int vlan_grp_hashfn(unsigned int idx)
-{
-	return ((idx >> VLAN_GRP_HASH_SHIFT) ^ idx) & VLAN_GRP_HASH_MASK;
-}
-
-/* Must be invoked with RCU read lock (no preempt) */
-static struct vlan_group *__vlan_find_group(struct net_device *real_dev)
-{
-	struct vlan_group *grp;
-	struct hlist_node *n;
-	int hash = vlan_grp_hashfn(real_dev->ifindex);
-
-	hlist_for_each_entry_rcu(grp, n, &vlan_group_hash[hash], hlist) {
-		if (grp->real_dev == real_dev)
-			return grp;
-	}
-
-	return NULL;
-}
-
-/*  Find the protocol handler.  Assumes VID < VLAN_VID_MASK.
- *
- * Must be invoked with RCU read lock (no preempt)
- */
-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, vlan_id);
-
-	return NULL;
-}
-
 static void vlan_group_free(struct vlan_group *grp)
 {
 	int i;
@@ -111,8 +74,6 @@ static struct vlan_group *vlan_group_alloc(struct net_device *real_dev)
 		return NULL;
 
 	grp->real_dev = real_dev;
-	hlist_add_head_rcu(&grp->hlist,
-			&vlan_group_hash[vlan_grp_hashfn(real_dev->ifindex)]);
 	return grp;
 }
 
@@ -146,13 +107,10 @@ void unregister_vlan_dev(struct net_device *dev, struct list_head *head)
 	struct vlan_dev_info *vlan = vlan_dev_info(dev);
 	struct net_device *real_dev = vlan->real_dev;
 	const struct net_device_ops *ops = real_dev->netdev_ops;
-	struct vlan_group *grp;
 	u16 vlan_id = vlan->vlan_id;
 
 	ASSERT_RTNL();
-
-	grp = __vlan_find_group(real_dev);
-	BUG_ON(!grp);
+	BUG_ON(!real_dev->vlgrp);
 
 	/* Take it out of our own structures, but be sure to interlock with
 	 * HW accelerating devices or SW vlan input packet processing if
@@ -161,25 +119,26 @@ void unregister_vlan_dev(struct net_device *dev, struct list_head *head)
 	if (vlan_id && (real_dev->features & NETIF_F_HW_VLAN_FILTER))
 		ops->ndo_vlan_rx_kill_vid(real_dev, vlan_id);
 
-	grp->nr_vlans--;
+	real_dev->vlgrp->nr_vlans--;
 
-	vlan_group_set_device(grp, vlan_id, NULL);
-	if (!grp->killall)
+	vlan_group_set_device(real_dev->vlgrp, vlan_id, NULL);
+	if (!real_dev->vlgrp->killall)
 		synchronize_net();
 
 	unregister_netdevice_queue(dev, head);
 
 	/* If the group is now empty, kill off the group. */
-	if (grp->nr_vlans == 0) {
-		vlan_gvrp_uninit_applicant(real_dev);
+	if (real_dev->vlgrp->nr_vlans == 0) {
+		struct vlan_group *vlgrp = real_dev->vlgrp;
 
-		if (real_dev->features & NETIF_F_HW_VLAN_RX)
+		rcu_assign_pointer(real_dev->vlgrp, NULL);
+		if (ops->ndo_vlan_rx_register)
 			ops->ndo_vlan_rx_register(real_dev, NULL);
 
-		hlist_del_rcu(&grp->hlist);
+		vlan_gvrp_uninit_applicant(real_dev);
 
 		/* Free the group, after all cpu's are done. */
-		call_rcu(&grp->rcu, vlan_rcu_free);
+		call_rcu(&vlgrp->rcu, vlan_rcu_free);
 	}
 
 	/* Get rid of the vlan's reference to real_dev */
@@ -196,18 +155,13 @@ int vlan_check_real_dev(struct net_device *real_dev, u16 vlan_id)
 		return -EOPNOTSUPP;
 	}
 
-	if ((real_dev->features & NETIF_F_HW_VLAN_RX) && !ops->ndo_vlan_rx_register) {
-		pr_info("8021q: device %s has buggy VLAN hw accel\n", name);
-		return -EOPNOTSUPP;
-	}
-
 	if ((real_dev->features & NETIF_F_HW_VLAN_FILTER) &&
 	    (!ops->ndo_vlan_rx_add_vid || !ops->ndo_vlan_rx_kill_vid)) {
 		pr_info("8021q: Device %s has buggy VLAN hw accel\n", name);
 		return -EOPNOTSUPP;
 	}
 
-	if (__find_vlan_dev(real_dev, vlan_id) != NULL)
+	if (vlan_find_dev(real_dev, vlan_id) != NULL)
 		return -EEXIST;
 
 	return 0;
@@ -222,7 +176,7 @@ int register_vlan_dev(struct net_device *dev)
 	struct vlan_group *grp, *ngrp = NULL;
 	int err;
 
-	grp = __vlan_find_group(real_dev);
+	grp = real_dev->vlgrp;
 	if (!grp) {
 		ngrp = grp = vlan_group_alloc(real_dev);
 		if (!grp)
@@ -252,8 +206,11 @@ int register_vlan_dev(struct net_device *dev)
 	vlan_group_set_device(grp, vlan_id, dev);
 	grp->nr_vlans++;
 
-	if (ngrp && real_dev->features & NETIF_F_HW_VLAN_RX)
-		ops->ndo_vlan_rx_register(real_dev, ngrp);
+	if (ngrp) {
+		if (ops->ndo_vlan_rx_register)
+			ops->ndo_vlan_rx_register(real_dev, ngrp);
+		rcu_assign_pointer(real_dev->vlgrp, ngrp);
+	}
 	if (real_dev->features & NETIF_F_HW_VLAN_FILTER)
 		ops->ndo_vlan_rx_add_vid(real_dev, vlan_id);
 
@@ -264,7 +221,6 @@ out_uninit_applicant:
 		vlan_gvrp_uninit_applicant(real_dev);
 out_free_group:
 	if (ngrp) {
-		hlist_del_rcu(&ngrp->hlist);
 		/* Free the group, after all cpu's are done. */
 		call_rcu(&ngrp->rcu, vlan_rcu_free);
 	}
@@ -428,7 +384,7 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
 		dev->netdev_ops->ndo_vlan_rx_add_vid(dev, 0);
 	}
 
-	grp = __vlan_find_group(dev);
+	grp = dev->vlgrp;
 	if (!grp)
 		goto out;
 
@@ -439,7 +395,7 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
 	switch (event) {
 	case NETDEV_CHANGE:
 		/* Propagate real device state to vlan devices */
-		for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) {
+		for (i = 0; i < VLAN_N_VID; i++) {
 			vlandev = vlan_group_get_device(grp, i);
 			if (!vlandev)
 				continue;
@@ -450,7 +406,7 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
 
 	case NETDEV_CHANGEADDR:
 		/* Adjust unicast filters on underlying device */
-		for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) {
+		for (i = 0; i < VLAN_N_VID; i++) {
 			vlandev = vlan_group_get_device(grp, i);
 			if (!vlandev)
 				continue;
@@ -464,7 +420,7 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
 		break;
 
 	case NETDEV_CHANGEMTU:
-		for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) {
+		for (i = 0; i < VLAN_N_VID; i++) {
 			vlandev = vlan_group_get_device(grp, i);
 			if (!vlandev)
 				continue;
@@ -478,7 +434,7 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
 
 	case NETDEV_FEAT_CHANGE:
 		/* Propagate device features to underlying device */
-		for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) {
+		for (i = 0; i < VLAN_N_VID; i++) {
 			vlandev = vlan_group_get_device(grp, i);
 			if (!vlandev)
 				continue;
@@ -490,7 +446,7 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
 
 	case NETDEV_DOWN:
 		/* Put all VLANs for this dev in the down state too.  */
-		for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) {
+		for (i = 0; i < VLAN_N_VID; i++) {
 			vlandev = vlan_group_get_device(grp, i);
 			if (!vlandev)
 				continue;
@@ -508,7 +464,7 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
 
 	case NETDEV_UP:
 		/* Put all VLANs for this dev in the up state too.  */
-		for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) {
+		for (i = 0; i < VLAN_N_VID; i++) {
 			vlandev = vlan_group_get_device(grp, i);
 			if (!vlandev)
 				continue;
@@ -532,7 +488,7 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
 		/* Delete all VLANs for this dev. */
 		grp->killall = 1;
 
-		for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) {
+		for (i = 0; i < VLAN_N_VID; i++) {
 			vlandev = vlan_group_get_device(grp, i);
 			if (!vlandev)
 				continue;
@@ -540,7 +496,7 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
 			/* unregistration of last vlan destroys group, abort
 			 * afterwards */
 			if (grp->nr_vlans == 1)
-				i = VLAN_GROUP_ARRAY_LEN;
+				i = VLAN_N_VID;
 
 			unregister_vlan_dev(vlandev, &list);
 		}
@@ -746,8 +702,6 @@ err0:
 
 static void __exit vlan_cleanup_module(void)
 {
-	unsigned int i;
-
 	vlan_ioctl_set(NULL);
 	vlan_netlink_fini();
 
@@ -755,10 +709,6 @@ static void __exit vlan_cleanup_module(void)
 
 	dev_remove_pack(&vlan_packet_type);
 
-	/* This table must be empty if there are no module references left. */
-	for (i = 0; i < VLAN_GRP_HASH_SIZE; i++)
-		BUG_ON(!hlist_empty(&vlan_group_hash[i]));
-
 	unregister_pernet_subsys(&vlan_net_ops);
 	rcu_barrier(); /* Wait for completion of call_rcu()'s */
 
diff --git a/net/8021q/vlan.h b/net/8021q/vlan.h
index 8d9503a..db01b31 100644
--- a/net/8021q/vlan.h
+++ b/net/8021q/vlan.h
@@ -72,23 +72,6 @@ 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)
-
-/*  Find a VLAN device by the MAC address of its Ethernet device, and
- *  it's VLAN ID.  The default configuration is to have VLAN's scope
- *  to be box-wide, so the MAC will be ignored.  The mac will only be
- *  looked at if we are configured to have a separate set of VLANs per
- *  each MAC addressable interface.  Note that this latter option does
- *  NOT follow the spec for VLANs, but may be useful for doing very
- *  large quantities of VLAN MUX/DEMUX onto FrameRelay or ATM PVCs.
- *
- *  Must be invoked with rcu_read_lock (ie preempt disabled)
- *  or with RTNL.
- */
-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);
diff --git a/net/8021q/vlan_core.c b/net/8021q/vlan_core.c
index dee727c..df90412 100644
--- a/net/8021q/vlan_core.c
+++ b/net/8021q/vlan_core.c
@@ -4,54 +4,33 @@
 #include <linux/netpoll.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,
-		      u16 vlan_tci, int polling)
+int vlan_hwaccel_do_receive(struct sk_buff *skb)
 {
+	u16 vlan_id = skb->vlan_tci & VLAN_VID_MASK;
 	struct net_device *vlan_dev;
-	u16 vlan_id;
-
-	if (netpoll_rx(skb))
-		return NET_RX_DROP;
-
-	if (skb_bond_should_drop(skb, ACCESS_ONCE(skb->dev->master)))
-		skb->deliver_no_wcard = 1;
-
-	skb->skb_iif = skb->dev->ifindex;
-	__vlan_hwaccel_put_tag(skb, vlan_tci);
-	vlan_id = vlan_tci & VLAN_VID_MASK;
-	vlan_dev = vlan_group_get_device(grp, vlan_id);
+	struct vlan_rx_stats *rx_stats;
 
-	if (vlan_dev)
-		skb->dev = vlan_dev;
-	else if (vlan_id) {
-		if (!(skb->dev->flags & IFF_PROMISC))
-			goto drop;
-		skb->pkt_type = PACKET_OTHERHOST;
+	vlan_dev = vlan_find_dev(skb->dev, vlan_id);
+	if (!vlan_dev) {
+		if (vlan_id)
+			skb->pkt_type = PACKET_OTHERHOST;
+		return NET_RX_SUCCESS;
 	}
 
-	return polling ? netif_receive_skb(skb) : netif_rx(skb);
-
-drop:
-	atomic_long_inc(&skb->dev->rx_dropped);
-	dev_kfree_skb_any(skb);
-	return NET_RX_DROP;
-}
-EXPORT_SYMBOL(__vlan_hwaccel_rx);
-
-void vlan_hwaccel_do_receive(struct sk_buff *skb)
-{
-	struct net_device *dev = skb->dev;
-	struct vlan_rx_stats     *rx_stats;
+	if (netpoll_receive_skb(skb))
+		return NET_RX_DROP;
 
-	skb->dev = vlan_dev_real_dev(dev);
 	netif_nit_deliver(skb);
 
-	skb->dev = dev;
-	skb->priority = vlan_get_ingress_priority(dev, skb->vlan_tci);
+	skb->skb_iif = skb->dev->ifindex;
+	if (skb_bond_should_drop(skb, ACCESS_ONCE(skb->dev->master)))
+		skb->deliver_no_wcard = 1;
+
+	skb->dev = vlan_dev;
+	skb->priority = vlan_get_ingress_priority(skb->dev, skb->vlan_tci);
 	skb->vlan_tci = 0;
 
-	rx_stats = this_cpu_ptr(vlan_dev_info(dev)->vlan_rx_stats);
+	rx_stats = this_cpu_ptr(vlan_dev_info(skb->dev)->vlan_rx_stats);
 
 	u64_stats_update_begin(&rx_stats->syncp);
 	rx_stats->rx_packets++;
@@ -68,11 +47,13 @@ void vlan_hwaccel_do_receive(struct sk_buff *skb)
 		 * 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,
-					dev->dev_addr))
+					skb->dev->dev_addr))
 			skb->pkt_type = PACKET_HOST;
 		break;
 	}
 	u64_stats_update_end(&rx_stats->syncp);
+
+	return NET_RX_SUCCESS;
 }
 
 struct net_device *vlan_dev_real_dev(const struct net_device *dev)
@@ -87,75 +68,27 @@ u16 vlan_dev_vlan_id(const struct net_device *dev)
 }
 EXPORT_SYMBOL(vlan_dev_vlan_id);
 
-static gro_result_t
-vlan_gro_common(struct napi_struct *napi, struct vlan_group *grp,
-		unsigned int vlan_tci, struct sk_buff *skb)
+/* VLAN rx hw acceleration helper.  This acts like netif_{rx,receive_skb}(). */
+int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp,
+		      u16 vlan_tci, int polling)
 {
-	struct sk_buff *p;
-	struct net_device *vlan_dev;
-	u16 vlan_id;
-
-	if (skb_bond_should_drop(skb, ACCESS_ONCE(skb->dev->master)))
-		skb->deliver_no_wcard = 1;
-
-	skb->skb_iif = skb->dev->ifindex;
 	__vlan_hwaccel_put_tag(skb, vlan_tci);
-	vlan_id = vlan_tci & VLAN_VID_MASK;
-	vlan_dev = vlan_group_get_device(grp, vlan_id);
-
-	if (vlan_dev)
-		skb->dev = vlan_dev;
-	else if (vlan_id) {
-		if (!(skb->dev->flags & IFF_PROMISC))
-			goto drop;
-		skb->pkt_type = PACKET_OTHERHOST;
-	}
-
-	for (p = napi->gro_list; p; p = p->next) {
-		unsigned long diffs;
-
-		diffs = (unsigned long)p->dev ^ (unsigned long)skb->dev;
-		diffs |= compare_ether_header(skb_mac_header(p),
-					      skb_gro_mac_header(skb));
-		NAPI_GRO_CB(p)->same_flow = !diffs;
-		NAPI_GRO_CB(p)->flush = 0;
-	}
-
-	return dev_gro_receive(napi, skb);
-
-drop:
-	atomic_long_inc(&skb->dev->rx_dropped);
-	return GRO_DROP;
+	return polling ? netif_receive_skb(skb) : netif_rx(skb);
 }
+EXPORT_SYMBOL(__vlan_hwaccel_rx);
 
 gro_result_t vlan_gro_receive(struct napi_struct *napi, struct vlan_group *grp,
 			      unsigned int vlan_tci, struct sk_buff *skb)
 {
-	if (netpoll_rx_on(skb))
-		return vlan_hwaccel_receive_skb(skb, grp, vlan_tci)
-			? GRO_DROP : GRO_NORMAL;
-
-	skb_gro_reset_offset(skb);
-
-	return napi_skb_finish(vlan_gro_common(napi, grp, vlan_tci, skb), skb);
+	__vlan_hwaccel_put_tag(skb, vlan_tci);
+	return napi_gro_receive(napi, skb);
 }
 EXPORT_SYMBOL(vlan_gro_receive);
 
 gro_result_t vlan_gro_frags(struct napi_struct *napi, struct vlan_group *grp,
 			    unsigned int vlan_tci)
 {
-	struct sk_buff *skb = napi_frags_skb(napi);
-
-	if (!skb)
-		return GRO_DROP;
-
-	if (netpoll_rx_on(skb)) {
-		skb->protocol = eth_type_trans(skb, skb->dev);
-		return vlan_hwaccel_receive_skb(skb, grp, vlan_tci)
-			? GRO_DROP : GRO_NORMAL;
-	}
-
-	return napi_frags_finish(napi, skb,
-				 vlan_gro_common(napi, grp, vlan_tci, skb));
+	__vlan_hwaccel_put_tag(napi->skb, vlan_tci);
+	return napi_gro_frags(napi);
 }
 EXPORT_SYMBOL(vlan_gro_frags);
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index f54251e..14e3d1f 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -158,7 +158,7 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
 	vlan_id = vlan_tci & VLAN_VID_MASK;
 
 	rcu_read_lock();
-	vlan_dev = __find_vlan_dev(dev, vlan_id);
+	vlan_dev = vlan_find_dev(dev, vlan_id);
 
 	/* If the VLAN device is defined, we use it.
 	 * If not, and the VID is 0, it is a 802.1p packet (not
diff --git a/net/bridge/netfilter/ebt_vlan.c b/net/bridge/netfilter/ebt_vlan.c
index a39d92d..e724720 100644
--- a/net/bridge/netfilter/ebt_vlan.c
+++ b/net/bridge/netfilter/ebt_vlan.c
@@ -119,10 +119,10 @@ static int ebt_vlan_mt_check(const struct xt_mtchk_param *par)
 	 * 0 - The null VLAN ID.
 	 * 1 - The default Port VID (PVID)
 	 * 0x0FFF - Reserved for implementation use.
-	 * if_vlan.h: VLAN_GROUP_ARRAY_LEN 4096. */
+	 * if_vlan.h: VLAN_N_VID 4096. */
 	if (GET_BITMASK(EBT_VLAN_ID)) {
 		if (!!info->id) { /* if id!=0 => check vid range */
-			if (info->id > VLAN_GROUP_ARRAY_LEN) {
+			if (info->id > VLAN_N_VID) {
 				pr_debug("id %d is out of range (1-4096)\n",
 					 info->id);
 				return -EINVAL;
diff --git a/net/core/dev.c b/net/core/dev.c
index 04972a4..9586aff 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1692,7 +1692,12 @@ static bool can_checksum_protocol(unsigned long features, __be16 protocol)
 
 static bool dev_can_checksum(struct net_device *dev, struct sk_buff *skb)
 {
-	if (can_checksum_protocol(dev->features, skb->protocol))
+	int features = dev->features;
+
+	if (vlan_tx_tag_present(skb))
+		features &= dev->vlan_features;
+
+	if (can_checksum_protocol(features, skb->protocol))
 		return true;
 
 	if (skb->protocol == htons(ETH_P_8021Q)) {
@@ -1791,6 +1796,16 @@ struct sk_buff *skb_gso_segment(struct sk_buff *skb, int features)
 	__be16 type = skb->protocol;
 	int err;
 
+	if (type == htons(ETH_P_8021Q)) {
+		struct vlan_ethhdr *veh;
+
+		if (unlikely(!pskb_may_pull(skb, VLAN_ETH_HLEN)))
+			return ERR_PTR(-EINVAL);
+
+		veh = (struct vlan_ethhdr *)skb->data;
+		type = veh->h_vlan_encapsulated_proto;
+	}
+
 	skb_reset_mac_header(skb);
 	skb->mac_len = skb->network_header - skb->mac_header;
 	__skb_pull(skb, skb->mac_len);
@@ -1962,9 +1977,14 @@ static inline void skb_orphan_try(struct sk_buff *skb)
 static inline int skb_needs_linearize(struct sk_buff *skb,
 				      struct net_device *dev)
 {
+	int features = dev->features;
+
+	if (skb->protocol == htons(ETH_P_8021Q) || vlan_tx_tag_present(skb))
+		features &= dev->vlan_features;
+
 	return skb_is_nonlinear(skb) &&
-	       ((skb_has_frag_list(skb) && !(dev->features & NETIF_F_FRAGLIST)) ||
-	        (skb_shinfo(skb)->nr_frags && (!(dev->features & NETIF_F_SG) ||
+	       ((skb_has_frag_list(skb) && !(features & NETIF_F_FRAGLIST)) ||
+	        (skb_shinfo(skb)->nr_frags && (!(features & NETIF_F_SG) ||
 					      illegal_highdma(dev, skb))));
 }
 
@@ -1987,6 +2007,15 @@ int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev,
 
 		skb_orphan_try(skb);
 
+		if (vlan_tx_tag_present(skb) &&
+		    !(dev->features & NETIF_F_HW_VLAN_TX)) {
+			skb = __vlan_put_tag(skb, vlan_tx_tag_get(skb));
+			if (unlikely(!skb))
+				goto out;
+
+			skb->vlan_tci = 0;
+		}
+
 		if (netif_needs_gso(dev, skb)) {
 			if (unlikely(dev_gso_segment(skb)))
 				goto out_kfree_skb;
@@ -2048,6 +2077,7 @@ out_kfree_gso_skb:
 		skb->destructor = DEV_GSO_CB(skb)->destructor;
 out_kfree_skb:
 	kfree_skb(skb);
+out:
 	return rc;
 }
 
@@ -2893,8 +2923,8 @@ static int __netif_receive_skb(struct sk_buff *skb)
 	if (!netdev_tstamp_prequeue)
 		net_timestamp_check(skb);
 
-	if (vlan_tx_tag_present(skb))
-		vlan_hwaccel_do_receive(skb);
+	if (vlan_tx_tag_present(skb) && vlan_hwaccel_do_receive(skb))
+		return NET_RX_DROP;
 
 	/* if we've gotten here through NAPI, check netpoll */
 	if (netpoll_receive_skb(skb))
@@ -3232,6 +3262,7 @@ __napi_gro_receive(struct napi_struct *napi, struct sk_buff *skb)
 		unsigned long diffs;
 
 		diffs = (unsigned long)p->dev ^ (unsigned long)skb->dev;
+		diffs |= p->vlan_tci ^ skb->vlan_tci;
 		diffs |= compare_ether_header(skb_mac_header(p),
 					      skb_gro_mac_header(skb));
 		NAPI_GRO_CB(p)->same_flow = !diffs;
@@ -3291,6 +3322,7 @@ void napi_reuse_skb(struct napi_struct *napi, struct sk_buff *skb)
 {
 	__skb_pull(skb, skb_headlen(skb));
 	skb_reserve(skb, NET_IP_ALIGN - skb_headroom(skb));
+	skb->vlan_tci = 0;
 
 	napi->skb = skb;
 }
-- 
1.7.0.4


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

* [RFC PATCH 3/7] bnx2: Update bnx2 to use new vlan accleration.
  2010-10-13 20:02 [RFC PATCH 0/7] Move vlan acceleration into networking core Jesse Gross
  2010-10-13 20:02 ` [RFC PATCH 1/7] ebtables: Allow filtering of hardware accelerated vlan frames Jesse Gross
  2010-10-13 20:02 ` [RFC PATCH 2/7] vlan: Centralize handling of hardware acceleration Jesse Gross
@ 2010-10-13 20:02 ` Jesse Gross
  2010-10-14 22:56   ` Michael Chan
  2010-10-13 20:02 ` [RFC PATCH 4/7] ixgbe: Update ixgbe " Jesse Gross
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 15+ messages in thread
From: Jesse Gross @ 2010-10-13 20:02 UTC (permalink / raw)
  To: davem; +Cc: netdev, Michael Chan

Make the bnx2 driver use the new vlan accleration model.

Signed-off-by: Jesse Gross <jesse@nicira.com>
CC: Michael Chan <mchan@broadcom.com>
---
 drivers/net/bnx2.c |   75 +++------------------------------------------------
 drivers/net/bnx2.h |    4 ---
 2 files changed, 5 insertions(+), 74 deletions(-)

diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index ae894bc..2d306f4 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -37,9 +37,6 @@
 #include <linux/ethtool.h>
 #include <linux/mii.h>
 #include <linux/if_vlan.h>
-#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
-#define BCM_VLAN 1
-#endif
 #include <net/ip.h>
 #include <net/tcp.h>
 #include <net/checksum.h>
@@ -3087,8 +3084,6 @@ bnx2_rx_int(struct bnx2 *bp, struct bnx2_napi *bnapi, int budget)
 		struct sw_bd *rx_buf, *next_rx_buf;
 		struct sk_buff *skb;
 		dma_addr_t dma_addr;
-		u16 vtag = 0;
-		int hw_vlan __maybe_unused = 0;
 
 		sw_ring_cons = RX_RING_IDX(sw_cons);
 		sw_ring_prod = RX_RING_IDX(sw_prod);
@@ -3168,23 +3163,8 @@ bnx2_rx_int(struct bnx2 *bp, struct bnx2_napi *bnapi, int budget)
 			goto next_rx;
 
 		if ((status & L2_FHDR_STATUS_L2_VLAN_TAG) &&
-		    !(bp->rx_mode & BNX2_EMAC_RX_MODE_KEEP_VLAN_TAG)) {
-			vtag = rx_hdr->l2_fhdr_vlan_tag;
-#ifdef BCM_VLAN
-			if (bp->vlgrp)
-				hw_vlan = 1;
-			else
-#endif
-			{
-				struct vlan_ethhdr *ve = (struct vlan_ethhdr *)
-					__skb_push(skb, 4);
-
-				memmove(ve, skb->data + 4, ETH_ALEN * 2);
-				ve->h_vlan_proto = htons(ETH_P_8021Q);
-				ve->h_vlan_TCI = htons(vtag);
-				len += 4;
-			}
-		}
+		    !(bp->rx_mode & BNX2_EMAC_RX_MODE_KEEP_VLAN_TAG))
+			__vlan_hwaccel_put_tag(skb, rx_hdr->l2_fhdr_vlan_tag);
 
 		skb->protocol = eth_type_trans(skb, bp->dev);
 
@@ -3211,14 +3191,7 @@ bnx2_rx_int(struct bnx2 *bp, struct bnx2_napi *bnapi, int budget)
 			skb->rxhash = rx_hdr->l2_fhdr_hash;
 
 		skb_record_rx_queue(skb, bnapi - &bp->bnx2_napi[0]);
-
-#ifdef BCM_VLAN
-		if (hw_vlan)
-			vlan_gro_receive(&bnapi->napi, bp->vlgrp, vtag, skb);
-		else
-#endif
-			napi_gro_receive(&bnapi->napi, skb);
-
+		napi_gro_receive(&bnapi->napi, skb);
 		rx_pkt++;
 
 next_rx:
@@ -3533,13 +3506,6 @@ bnx2_set_rx_mode(struct net_device *dev)
 	rx_mode = bp->rx_mode & ~(BNX2_EMAC_RX_MODE_PROMISCUOUS |
 				  BNX2_EMAC_RX_MODE_KEEP_VLAN_TAG);
 	sort_mode = 1 | BNX2_RPM_SORT_USER0_BC_EN;
-#ifdef BCM_VLAN
-	if (!bp->vlgrp && (bp->flags & BNX2_FLAG_CAN_KEEP_VLAN))
-		rx_mode |= BNX2_EMAC_RX_MODE_KEEP_VLAN_TAG;
-#else
-	if (bp->flags & BNX2_FLAG_CAN_KEEP_VLAN)
-		rx_mode |= BNX2_EMAC_RX_MODE_KEEP_VLAN_TAG;
-#endif
 	if (dev->flags & IFF_PROMISC) {
 		/* Promiscuous mode. */
 		rx_mode |= BNX2_EMAC_RX_MODE_PROMISCUOUS;
@@ -6365,29 +6331,6 @@ bnx2_tx_timeout(struct net_device *dev)
 	schedule_work(&bp->reset_task);
 }
 
-#ifdef BCM_VLAN
-/* Called with rtnl_lock */
-static void
-bnx2_vlan_rx_register(struct net_device *dev, struct vlan_group *vlgrp)
-{
-	struct bnx2 *bp = netdev_priv(dev);
-
-	if (netif_running(dev))
-		bnx2_netif_stop(bp, false);
-
-	bp->vlgrp = vlgrp;
-
-	if (!netif_running(dev))
-		return;
-
-	bnx2_set_rx_mode(dev);
-	if (bp->flags & BNX2_FLAG_CAN_KEEP_VLAN)
-		bnx2_fw_sync(bp, BNX2_DRV_MSG_CODE_KEEP_VLAN_UPDATE, 0, 1);
-
-	bnx2_netif_start(bp, false);
-}
-#endif
-
 /* Called with netif_tx_lock.
  * bnx2_tx_int() runs without netif_tx_lock unless it needs to call
  * netif_wake_queue().
@@ -6428,12 +6371,11 @@ bnx2_start_xmit(struct sk_buff *skb, struct net_device *dev)
 		vlan_tag_flags |= TX_BD_FLAGS_TCP_UDP_CKSUM;
 	}
 
-#ifdef BCM_VLAN
-	if (bp->vlgrp && vlan_tx_tag_present(skb)) {
+	if (vlan_tx_tag_present(skb)) {
 		vlan_tag_flags |=
 			(TX_BD_FLAGS_VLAN_TAG | (vlan_tx_tag_get(skb) << 16));
 	}
-#endif
+
 	if ((mss = skb_shinfo(skb)->gso_size)) {
 		u32 tcp_opt_len;
 		struct iphdr *iph;
@@ -8318,9 +8260,6 @@ static const struct net_device_ops bnx2_netdev_ops = {
 	.ndo_set_mac_address	= bnx2_change_mac_addr,
 	.ndo_change_mtu		= bnx2_change_mtu,
 	.ndo_tx_timeout		= bnx2_tx_timeout,
-#ifdef BCM_VLAN
-	.ndo_vlan_rx_register	= bnx2_vlan_rx_register,
-#endif
 #ifdef CONFIG_NET_POLL_CONTROLLER
 	.ndo_poll_controller	= poll_bnx2,
 #endif
@@ -8328,9 +8267,7 @@ static const struct net_device_ops bnx2_netdev_ops = {
 
 static void inline vlan_features_add(struct net_device *dev, unsigned long flags)
 {
-#ifdef BCM_VLAN
 	dev->vlan_features |= flags;
-#endif
 }
 
 static int __devinit
@@ -8379,9 +8316,7 @@ bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 		dev->features |= NETIF_F_IPV6_CSUM;
 		vlan_features_add(dev, NETIF_F_IPV6_CSUM);
 	}
-#ifdef BCM_VLAN
 	dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
-#endif
 	dev->features |= NETIF_F_TSO | NETIF_F_TSO_ECN;
 	vlan_features_add(dev, NETIF_F_TSO | NETIF_F_TSO_ECN);
 	if (CHIP_NUM(bp) == CHIP_NUM_5709) {
diff --git a/drivers/net/bnx2.h b/drivers/net/bnx2.h
index efdfbc2..4f44db6 100644
--- a/drivers/net/bnx2.h
+++ b/drivers/net/bnx2.h
@@ -6742,10 +6742,6 @@ struct bnx2 {
 
 	struct bnx2_napi	bnx2_napi[BNX2_MAX_MSIX_VEC];
 
-#ifdef BCM_VLAN
-	struct			vlan_group *vlgrp;
-#endif
-
 	u32			rx_buf_use_size;	/* useable size */
 	u32			rx_buf_size;		/* with alignment */
 	u32			rx_copy_thresh;
-- 
1.7.0.4


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

* [RFC PATCH 4/7] ixgbe: Update ixgbe to use new vlan accleration.
  2010-10-13 20:02 [RFC PATCH 0/7] Move vlan acceleration into networking core Jesse Gross
                   ` (2 preceding siblings ...)
  2010-10-13 20:02 ` [RFC PATCH 3/7] bnx2: Update bnx2 to use new vlan accleration Jesse Gross
@ 2010-10-13 20:02 ` Jesse Gross
  2010-10-13 20:02 ` [RFC PATCH 5/7] lro: Remove explicit vlan support Jesse Gross
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 15+ messages in thread
From: Jesse Gross @ 2010-10-13 20:02 UTC (permalink / raw)
  To: davem; +Cc: netdev, Peter Waskiewicz, Emil Tantilov, Jeff Kirsher

Make the ixgbe driver use the new vlan accleration model.

Signed-off-by: Jesse Gross <jesse@nicira.com>
CC: Peter Waskiewicz <peter.p.waskiewicz.jr@intel.com>
CC: Emil Tantilov <emil.s.tantilov@intel.com>
CC: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ixgbe/ixgbe.h      |    4 ++-
 drivers/net/ixgbe/ixgbe_main.c |   60 ++++++++++------------------------------
 2 files changed, 18 insertions(+), 46 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe.h b/drivers/net/ixgbe/ixgbe.h
index a8c47b0..5e38de7 100644
--- a/drivers/net/ixgbe/ixgbe.h
+++ b/drivers/net/ixgbe/ixgbe.h
@@ -28,11 +28,13 @@
 #ifndef _IXGBE_H_
 #define _IXGBE_H_
 
+#include <linux/bitops.h>
 #include <linux/types.h>
 #include <linux/pci.h>
 #include <linux/netdevice.h>
 #include <linux/cpumask.h>
 #include <linux/aer.h>
+#include <linux/if_vlan.h>
 
 #include "ixgbe_type.h"
 #include "ixgbe_common.h"
@@ -287,7 +289,7 @@ struct ixgbe_q_vector {
 /* board specific private data structure */
 struct ixgbe_adapter {
 	struct timer_list watchdog_timer;
-	struct vlan_group *vlgrp;
+	unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
 	u16 bd_number;
 	struct work_struct reset_task;
 	struct ixgbe_q_vector *q_vector[MAX_MSIX_Q_VECTORS];
diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c
index 95dbf60..58b3363 100644
--- a/drivers/net/ixgbe/ixgbe_main.c
+++ b/drivers/net/ixgbe/ixgbe_main.c
@@ -954,17 +954,13 @@ static void ixgbe_receive_skb(struct ixgbe_q_vector *q_vector,
 	bool is_vlan = (status & IXGBE_RXD_STAT_VP);
 	u16 tag = le16_to_cpu(rx_desc->wb.upper.vlan);
 
-	if (!(adapter->flags & IXGBE_FLAG_IN_NETPOLL)) {
-		if (adapter->vlgrp && is_vlan && (tag & VLAN_VID_MASK))
-			vlan_gro_receive(napi, adapter->vlgrp, tag, skb);
-		else
-			napi_gro_receive(napi, skb);
-	} else {
-		if (adapter->vlgrp && is_vlan && (tag & VLAN_VID_MASK))
-			vlan_hwaccel_rx(skb, adapter->vlgrp, tag);
-		else
-			netif_rx(skb);
-	}
+	if (is_vlan && (tag & VLAN_VID_MASK))
+		__vlan_hwaccel_put_tag(skb, tag);
+
+	if (!(adapter->flags & IXGBE_FLAG_IN_NETPOLL))
+		napi_gro_receive(napi, skb);
+	else
+		netif_rx(skb);
 }
 
 /**
@@ -3065,6 +3061,7 @@ static void ixgbe_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
 
 	/* add VID to filter table */
 	hw->mac.ops.set_vfta(&adapter->hw, vid, pool_ndx, true);
+	set_bit(vid, adapter->active_vlans);
 }
 
 static void ixgbe_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
@@ -3073,16 +3070,9 @@ static void ixgbe_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
 	struct ixgbe_hw *hw = &adapter->hw;
 	int pool_ndx = adapter->num_vfs;
 
-	if (!test_bit(__IXGBE_DOWN, &adapter->state))
-		ixgbe_irq_disable(adapter);
-
-	vlan_group_set_device(adapter->vlgrp, vid, NULL);
-
-	if (!test_bit(__IXGBE_DOWN, &adapter->state))
-		ixgbe_irq_enable(adapter, true, true);
-
 	/* remove VID from filter table */
 	hw->mac.ops.set_vfta(&adapter->hw, vid, pool_ndx, false);
+	clear_bit(vid, adapter->active_vlans);
 }
 
 /**
@@ -3157,14 +3147,9 @@ static void ixgbe_vlan_filter_enable(struct ixgbe_adapter *adapter)
 	}
 }
 
-static void ixgbe_vlan_rx_register(struct net_device *netdev,
-				   struct vlan_group *grp)
+static void ixgbe_restore_vlan(struct ixgbe_adapter *adapter)
 {
-	struct ixgbe_adapter *adapter = netdev_priv(netdev);
-
-	if (!test_bit(__IXGBE_DOWN, &adapter->state))
-		ixgbe_irq_disable(adapter);
-	adapter->vlgrp = grp;
+	u16 vid;
 
 	/*
 	 * For a DCB driver, always enable VLAN tag stripping so we can
@@ -3173,24 +3158,10 @@ static void ixgbe_vlan_rx_register(struct net_device *netdev,
 	 */
 	ixgbe_vlan_filter_enable(adapter);
 
-	ixgbe_vlan_rx_add_vid(netdev, 0);
-
-	if (!test_bit(__IXGBE_DOWN, &adapter->state))
-		ixgbe_irq_enable(adapter, true, true);
-}
+	ixgbe_vlan_rx_add_vid(adapter->netdev, 0);
 
-static void ixgbe_restore_vlan(struct ixgbe_adapter *adapter)
-{
-	ixgbe_vlan_rx_register(adapter->netdev, adapter->vlgrp);
-
-	if (adapter->vlgrp) {
-		u16 vid;
-		for (vid = 0; vid < VLAN_GROUP_ARRAY_LEN; vid++) {
-			if (!vlan_group_get_device(adapter->vlgrp, vid))
-				continue;
-			ixgbe_vlan_rx_add_vid(adapter->netdev, vid);
-		}
-	}
+	for_each_set_bit(vid, adapter->active_vlans, VLAN_N_VID)
+		ixgbe_vlan_rx_add_vid(adapter->netdev, vid);
 }
 
 /**
@@ -6312,7 +6283,7 @@ netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb, struct net_device *netdev
 	int count = 0;
 	unsigned int f;
 
-	if (adapter->vlgrp && vlan_tx_tag_present(skb)) {
+	if (vlan_tx_tag_present(skb)) {
 		tx_flags |= vlan_tx_tag_get(skb);
 		if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) {
 			tx_flags &= ~IXGBE_TX_FLAGS_VLAN_PRIO_MASK;
@@ -6570,7 +6541,6 @@ static const struct net_device_ops ixgbe_netdev_ops = {
 	.ndo_set_mac_address	= ixgbe_set_mac,
 	.ndo_change_mtu		= ixgbe_change_mtu,
 	.ndo_tx_timeout		= ixgbe_tx_timeout,
-	.ndo_vlan_rx_register	= ixgbe_vlan_rx_register,
 	.ndo_vlan_rx_add_vid	= ixgbe_vlan_rx_add_vid,
 	.ndo_vlan_rx_kill_vid	= ixgbe_vlan_rx_kill_vid,
 	.ndo_do_ioctl		= ixgbe_ioctl,
-- 
1.7.0.4


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

* [RFC PATCH 5/7] lro: Remove explicit vlan support.
  2010-10-13 20:02 [RFC PATCH 0/7] Move vlan acceleration into networking core Jesse Gross
                   ` (3 preceding siblings ...)
  2010-10-13 20:02 ` [RFC PATCH 4/7] ixgbe: Update ixgbe " Jesse Gross
@ 2010-10-13 20:02 ` Jesse Gross
  2010-10-13 20:02 ` [RFC PATCH 6/7] bonding: Update bonding for new vlan model Jesse Gross
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 15+ messages in thread
From: Jesse Gross @ 2010-10-13 20:02 UTC (permalink / raw)
  To: davem; +Cc: netdev

Using the new vlan accleration model, LRO no longer needs to be
explicitly passed the vlan information because it is contained in
the skb.  Since all LRO did was pass the vlan through, this removes
that knowledge.

Signed-off-by: Jesse Gross <jesse@nicira.com>
--
This patch can only be applied once all drivers that use LRO and vlan acceleration
have been converted over to the new model.
---
 include/linux/inet_lro.h |   20 ------------
 net/ipv4/inet_lro.c      |   74 +++++++---------------------------------------
 2 files changed, 11 insertions(+), 83 deletions(-)

diff --git a/include/linux/inet_lro.h b/include/linux/inet_lro.h
index c4335fa..667281a 100644
--- a/include/linux/inet_lro.h
+++ b/include/linux/inet_lro.h
@@ -50,7 +50,6 @@ struct net_lro_desc {
 	struct skb_frag_struct *next_frag;
 	struct iphdr *iph;
 	struct tcphdr *tcph;
-	struct vlan_group *vgrp;
 	__wsum  data_csum;
 	__be32 tcp_rcv_tsecr;
 	__be32 tcp_rcv_tsval;
@@ -60,9 +59,7 @@ struct net_lro_desc {
 	u16 ip_tot_len;
 	u16 tcp_saw_tstamp; 		/* timestamps enabled */
 	__be16 tcp_window;
-	u16 vlan_tag;
 	int pkt_aggr_cnt;		/* counts aggregated packets */
-	int vlan_packet;
 	int mss;
 	int active;
 };
@@ -137,16 +134,6 @@ void lro_receive_skb(struct net_lro_mgr *lro_mgr,
 		     void *priv);
 
 /*
- * Processes a SKB with VLAN HW acceleration support
- */
-
-void lro_vlan_hwaccel_receive_skb(struct net_lro_mgr *lro_mgr,
-				  struct sk_buff *skb,
-				  struct vlan_group *vgrp,
-				  u16 vlan_tag,
-				  void *priv);
-
-/*
  * Processes a fragment list
  *
  * This functions aggregate fragments and generate SKBs do pass
@@ -165,13 +152,6 @@ void lro_receive_frags(struct net_lro_mgr *lro_mgr,
 		       struct skb_frag_struct *frags,
 		       int len, int true_size, void *priv, __wsum sum);
 
-void lro_vlan_hwaccel_receive_frags(struct net_lro_mgr *lro_mgr,
-				    struct skb_frag_struct *frags,
-				    int len, int true_size,
-				    struct vlan_group *vgrp,
-				    u16 vlan_tag,
-				    void *priv, __wsum sum);
-
 /*
  * Forward all aggregated SKBs held by lro_mgr to network stack
  */
diff --git a/net/ipv4/inet_lro.c b/net/ipv4/inet_lro.c
index 47038cb..8945a1d 100644
--- a/net/ipv4/inet_lro.c
+++ b/net/ipv4/inet_lro.c
@@ -146,8 +146,7 @@ static __wsum lro_tcp_data_csum(struct iphdr *iph, struct tcphdr *tcph, int len)
 }
 
 static void lro_init_desc(struct net_lro_desc *lro_desc, struct sk_buff *skb,
-			  struct iphdr *iph, struct tcphdr *tcph,
-			  u16 vlan_tag, struct vlan_group *vgrp)
+			  struct iphdr *iph, struct tcphdr *tcph)
 {
 	int nr_frags;
 	__be32 *ptr;
@@ -173,8 +172,6 @@ static void lro_init_desc(struct net_lro_desc *lro_desc, struct sk_buff *skb,
 	}
 
 	lro_desc->mss = tcp_data_len;
-	lro_desc->vgrp = vgrp;
-	lro_desc->vlan_tag = vlan_tag;
 	lro_desc->active = 1;
 
 	lro_desc->data_csum = lro_tcp_data_csum(iph, tcph,
@@ -309,29 +306,17 @@ static void lro_flush(struct net_lro_mgr *lro_mgr,
 
 	skb_shinfo(lro_desc->parent)->gso_size = lro_desc->mss;
 
-	if (lro_desc->vgrp) {
-		if (lro_mgr->features & LRO_F_NAPI)
-			vlan_hwaccel_receive_skb(lro_desc->parent,
-						 lro_desc->vgrp,
-						 lro_desc->vlan_tag);
-		else
-			vlan_hwaccel_rx(lro_desc->parent,
-					lro_desc->vgrp,
-					lro_desc->vlan_tag);
-
-	} else {
-		if (lro_mgr->features & LRO_F_NAPI)
-			netif_receive_skb(lro_desc->parent);
-		else
-			netif_rx(lro_desc->parent);
-	}
+	if (lro_mgr->features & LRO_F_NAPI)
+		netif_receive_skb(lro_desc->parent);
+	else
+		netif_rx(lro_desc->parent);
 
 	LRO_INC_STATS(lro_mgr, flushed);
 	lro_clear_desc(lro_desc);
 }
 
 static int __lro_proc_skb(struct net_lro_mgr *lro_mgr, struct sk_buff *skb,
-			  struct vlan_group *vgrp, u16 vlan_tag, void *priv)
+			  void *priv)
 {
 	struct net_lro_desc *lro_desc;
 	struct iphdr *iph;
@@ -360,7 +345,7 @@ static int __lro_proc_skb(struct net_lro_mgr *lro_mgr, struct sk_buff *skb,
 			goto out;
 
 		skb->ip_summed = lro_mgr->ip_summed_aggr;
-		lro_init_desc(lro_desc, skb, iph, tcph, vlan_tag, vgrp);
+		lro_init_desc(lro_desc, skb, iph, tcph);
 		LRO_INC_STATS(lro_mgr, aggregated);
 		return 0;
 	}
@@ -433,8 +418,7 @@ static struct sk_buff *lro_gen_skb(struct net_lro_mgr *lro_mgr,
 static struct sk_buff *__lro_proc_segment(struct net_lro_mgr *lro_mgr,
 					  struct skb_frag_struct *frags,
 					  int len, int true_size,
-					  struct vlan_group *vgrp,
-					  u16 vlan_tag, void *priv, __wsum sum)
+					  void *priv, __wsum sum)
 {
 	struct net_lro_desc *lro_desc;
 	struct iphdr *iph;
@@ -480,7 +464,7 @@ static struct sk_buff *__lro_proc_segment(struct net_lro_mgr *lro_mgr,
 		tcph = (void *)((u8 *)skb->data + vlan_hdr_len
 				+ IP_HDR_LEN(iph));
 
-		lro_init_desc(lro_desc, skb, iph, tcph, 0, NULL);
+		lro_init_desc(lro_desc, skb, iph, tcph);
 		LRO_INC_STATS(lro_mgr, aggregated);
 		return NULL;
 	}
@@ -514,7 +498,7 @@ void lro_receive_skb(struct net_lro_mgr *lro_mgr,
 		     struct sk_buff *skb,
 		     void *priv)
 {
-	if (__lro_proc_skb(lro_mgr, skb, NULL, 0, priv)) {
+	if (__lro_proc_skb(lro_mgr, skb, priv)) {
 		if (lro_mgr->features & LRO_F_NAPI)
 			netif_receive_skb(skb);
 		else
@@ -523,29 +507,13 @@ void lro_receive_skb(struct net_lro_mgr *lro_mgr,
 }
 EXPORT_SYMBOL(lro_receive_skb);
 
-void lro_vlan_hwaccel_receive_skb(struct net_lro_mgr *lro_mgr,
-				  struct sk_buff *skb,
-				  struct vlan_group *vgrp,
-				  u16 vlan_tag,
-				  void *priv)
-{
-	if (__lro_proc_skb(lro_mgr, skb, vgrp, vlan_tag, priv)) {
-		if (lro_mgr->features & LRO_F_NAPI)
-			vlan_hwaccel_receive_skb(skb, vgrp, vlan_tag);
-		else
-			vlan_hwaccel_rx(skb, vgrp, vlan_tag);
-	}
-}
-EXPORT_SYMBOL(lro_vlan_hwaccel_receive_skb);
-
 void lro_receive_frags(struct net_lro_mgr *lro_mgr,
 		       struct skb_frag_struct *frags,
 		       int len, int true_size, void *priv, __wsum sum)
 {
 	struct sk_buff *skb;
 
-	skb = __lro_proc_segment(lro_mgr, frags, len, true_size, NULL, 0,
-				 priv, sum);
+	skb = __lro_proc_segment(lro_mgr, frags, len, true_size, priv, sum);
 	if (!skb)
 		return;
 
@@ -556,26 +524,6 @@ void lro_receive_frags(struct net_lro_mgr *lro_mgr,
 }
 EXPORT_SYMBOL(lro_receive_frags);
 
-void lro_vlan_hwaccel_receive_frags(struct net_lro_mgr *lro_mgr,
-				    struct skb_frag_struct *frags,
-				    int len, int true_size,
-				    struct vlan_group *vgrp,
-				    u16 vlan_tag, void *priv, __wsum sum)
-{
-	struct sk_buff *skb;
-
-	skb = __lro_proc_segment(lro_mgr, frags, len, true_size, vgrp,
-				 vlan_tag, priv, sum);
-	if (!skb)
-		return;
-
-	if (lro_mgr->features & LRO_F_NAPI)
-		vlan_hwaccel_receive_skb(skb, vgrp, vlan_tag);
-	else
-		vlan_hwaccel_rx(skb, vgrp, vlan_tag);
-}
-EXPORT_SYMBOL(lro_vlan_hwaccel_receive_frags);
-
 void lro_flush_all(struct net_lro_mgr *lro_mgr)
 {
 	int i;
-- 
1.7.0.4


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

* [RFC PATCH 6/7] bonding: Update bonding for new vlan model.
  2010-10-13 20:02 [RFC PATCH 0/7] Move vlan acceleration into networking core Jesse Gross
                   ` (4 preceding siblings ...)
  2010-10-13 20:02 ` [RFC PATCH 5/7] lro: Remove explicit vlan support Jesse Gross
@ 2010-10-13 20:02 ` Jesse Gross
  2010-10-13 20:02 ` [RFC PATCH 7/7] vlan: Remove accleration legacy functions Jesse Gross
  2010-10-19  9:50 ` [RFC PATCH 0/7] Move vlan acceleration into networking core David Miller
  7 siblings, 0 replies; 15+ messages in thread
From: Jesse Gross @ 2010-10-13 20:02 UTC (permalink / raw)
  To: davem; +Cc: netdev

It is no longer necessary to register vlan groups, so update bonding
to not do that on its slaves.  Although the new vlan accleration
model allows additional flexibility, bonding continues to require vlan
devices since it needs addtional system state to handle ARP/IGMP.  This
also removes fallback code for non-vlan acclerated slaves since core
networking now handles that.

Signed-off-by: Jesse Gross <jesse@nicira.com>
--
This patch can only be applied once all drivers that use vlan acceleration
have been converted over to the new model.
---
 drivers/net/bonding/bond_alb.c  |    8 +--
 drivers/net/bonding/bond_ipv6.c |    5 +-
 drivers/net/bonding/bond_main.c |  134 ++++++++-------------------------------
 drivers/net/bonding/bonding.h   |    1 -
 4 files changed, 30 insertions(+), 118 deletions(-)

diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
index 26bb118..c911456 100644
--- a/drivers/net/bonding/bond_alb.c
+++ b/drivers/net/bonding/bond_alb.c
@@ -685,10 +685,8 @@ static struct slave *rlb_choose_channel(struct sk_buff *skb, struct bonding *bon
 			client_info->ntt = 0;
 		}
 
-		if (bond->vlgrp) {
-			if (!vlan_get_tag(skb, &client_info->vlan_id))
-				client_info->tag = 1;
-		}
+		if (!vlan_get_tag(skb, &client_info->vlan_id))
+			client_info->tag = 1;
 
 		if (!client_info->assigned) {
 			u32 prev_tbl_head = bond_info->rx_hashtbl_head;
@@ -907,7 +905,7 @@ static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[])
 		skb->priority = TC_PRIO_CONTROL;
 		skb->dev = slave->dev;
 
-		if (bond->vlgrp) {
+		if (!list_empty(&bond->vlan_list)) {
 			struct vlan_entry *vlan;
 
 			vlan = bond_next_vlan(bond,
diff --git a/drivers/net/bonding/bond_ipv6.c b/drivers/net/bonding/bond_ipv6.c
index 121b073..c276b5a 100644
--- a/drivers/net/bonding/bond_ipv6.c
+++ b/drivers/net/bonding/bond_ipv6.c
@@ -178,10 +178,7 @@ static int bond_inet6addr_event(struct notifier_block *this,
 		}
 
 		list_for_each_entry(vlan, &bond->vlan_list, vlan_list) {
-			if (!bond->vlgrp)
-				continue;
-			vlan_dev = vlan_group_get_device(bond->vlgrp,
-							 vlan->vlan_id);
+			vlan_dev = vlan_find_dev(bond->dev, vlan->vlan_id);
 			if (vlan_dev == event_dev) {
 				switch (event) {
 				case NETDEV_UP:
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 7703d35..5600946 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -414,36 +414,11 @@ struct vlan_entry *bond_next_vlan(struct bonding *bond, struct vlan_entry *curr)
  * @bond: bond device that got this skb for tx.
  * @skb: hw accel VLAN tagged skb to transmit
  * @slave_dev: slave that is supposed to xmit this skbuff
- *
- * When the bond gets an skb to transmit that is
- * already hardware accelerated VLAN tagged, and it
- * needs to relay this skb to a slave that is not
- * hw accel capable, the skb needs to be "unaccelerated",
- * i.e. strip the hwaccel tag and re-insert it as part
- * of the payload.
  */
 int bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb,
 			struct net_device *slave_dev)
 {
-	unsigned short uninitialized_var(vlan_id);
-
-	/* Test vlan_list not vlgrp to catch and handle 802.1p tags */
-	if (!list_empty(&bond->vlan_list) &&
-	    !(slave_dev->features & NETIF_F_HW_VLAN_TX) &&
-	    vlan_get_tag(skb, &vlan_id) == 0) {
-		skb->dev = slave_dev;
-		skb = vlan_put_tag(skb, vlan_id);
-		if (!skb) {
-			/* vlan_put_tag() frees the skb in case of error,
-			 * so return success here so the calling functions
-			 * won't attempt to free is again.
-			 */
-			return 0;
-		}
-	} else {
-		skb->dev = slave_dev;
-	}
-
+	skb->dev = slave_dev;
 	skb->priority = 1;
 #ifdef CONFIG_NET_POLL_CONTROLLER
 	if (unlikely(bond->dev->priv_flags & IFF_IN_NETPOLL)) {
@@ -462,8 +437,8 @@ int bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb,
 }
 
 /*
- * In the following 3 functions, bond_vlan_rx_register(), bond_vlan_rx_add_vid
- * and bond_vlan_rx_kill_vid, We don't protect the slave list iteration with a
+ * In the following 2 functions, bond_vlan_rx_add_vid and
+ * bond_vlan_rx_kill_vid, We don't protect the slave list iteration with a
  * lock because:
  * a. This operation is performed in IOCTL context,
  * b. The operation is protected by the RTNL semaphore in the 8021q code,
@@ -480,33 +455,6 @@ int bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb,
 */
 
 /**
- * bond_vlan_rx_register - Propagates registration to slaves
- * @bond_dev: bonding net device that got called
- * @grp: vlan group being registered
- */
-static void bond_vlan_rx_register(struct net_device *bond_dev,
-				  struct vlan_group *grp)
-{
-	struct bonding *bond = netdev_priv(bond_dev);
-	struct slave *slave;
-	int i;
-
-	write_lock(&bond->lock);
-	bond->vlgrp = grp;
-	write_unlock(&bond->lock);
-
-	bond_for_each_slave(bond, slave, i) {
-		struct net_device *slave_dev = slave->dev;
-		const struct net_device_ops *slave_ops = slave_dev->netdev_ops;
-
-		if ((slave_dev->features & NETIF_F_HW_VLAN_RX) &&
-		    slave_ops->ndo_vlan_rx_register) {
-			slave_ops->ndo_vlan_rx_register(slave_dev, grp);
-		}
-	}
-}
-
-/**
  * bond_vlan_rx_add_vid - Propagates adding an id to slaves
  * @bond_dev: bonding net device that got called
  * @vid: vlan id being added
@@ -543,7 +491,6 @@ static void bond_vlan_rx_kill_vid(struct net_device *bond_dev, uint16_t vid)
 {
 	struct bonding *bond = netdev_priv(bond_dev);
 	struct slave *slave;
-	struct net_device *vlan_dev;
 	int i, res;
 
 	bond_for_each_slave(bond, slave, i) {
@@ -551,14 +498,8 @@ static void bond_vlan_rx_kill_vid(struct net_device *bond_dev, uint16_t vid)
 		const struct net_device_ops *slave_ops = slave_dev->netdev_ops;
 
 		if ((slave_dev->features & NETIF_F_HW_VLAN_FILTER) &&
-		    slave_ops->ndo_vlan_rx_kill_vid) {
-			/* Save and then restore vlan_dev in the grp array,
-			 * since the slave's driver might clear it.
-			 */
-			vlan_dev = vlan_group_get_device(bond->vlgrp, vid);
+		    slave_ops->ndo_vlan_rx_kill_vid)
 			slave_ops->ndo_vlan_rx_kill_vid(slave_dev, vid);
-			vlan_group_set_device(bond->vlgrp, vid, vlan_dev);
-		}
 	}
 
 	res = bond_del_vlan(bond, vid);
@@ -573,13 +514,6 @@ static void bond_add_vlans_on_slave(struct bonding *bond, struct net_device *sla
 	struct vlan_entry *vlan;
 	const struct net_device_ops *slave_ops = slave_dev->netdev_ops;
 
-	if (!bond->vlgrp)
-		return;
-
-	if ((slave_dev->features & NETIF_F_HW_VLAN_RX) &&
-	    slave_ops->ndo_vlan_rx_register)
-		slave_ops->ndo_vlan_rx_register(slave_dev, bond->vlgrp);
-
 	if (!(slave_dev->features & NETIF_F_HW_VLAN_FILTER) ||
 	    !(slave_ops->ndo_vlan_rx_add_vid))
 		return;
@@ -593,30 +527,17 @@ static void bond_del_vlans_from_slave(struct bonding *bond,
 {
 	const struct net_device_ops *slave_ops = slave_dev->netdev_ops;
 	struct vlan_entry *vlan;
-	struct net_device *vlan_dev;
-
-	if (!bond->vlgrp)
-		return;
 
 	if (!(slave_dev->features & NETIF_F_HW_VLAN_FILTER) ||
 	    !(slave_ops->ndo_vlan_rx_kill_vid))
-		goto unreg;
+		return;
 
 	list_for_each_entry(vlan, &bond->vlan_list, vlan_list) {
 		if (!vlan->vlan_id)
 			continue;
-		/* Save and then restore vlan_dev in the grp array,
-		 * since the slave's driver might clear it.
-		 */
-		vlan_dev = vlan_group_get_device(bond->vlgrp, vlan->vlan_id);
+
 		slave_ops->ndo_vlan_rx_kill_vid(slave_dev, vlan->vlan_id);
-		vlan_group_set_device(bond->vlgrp, vlan->vlan_id, vlan_dev);
 	}
-
-unreg:
-	if ((slave_dev->features & NETIF_F_HW_VLAN_RX) &&
-	    slave_ops->ndo_vlan_rx_register)
-		slave_ops->ndo_vlan_rx_register(slave_dev, NULL);
 }
 
 /*------------------------------- Link status -------------------------------*/
@@ -894,23 +815,22 @@ static void bond_resend_igmp_join_requests(struct bonding *bond)
 	struct vlan_entry *vlan;
 
 	read_lock(&bond->lock);
+	rcu_read_lock();
 
 	/* rejoin all groups on bond device */
 	__bond_resend_igmp_join_requests(bond->dev);
 
 	/* rejoin all groups on vlan devices */
-	if (bond->vlgrp) {
-		list_for_each_entry(vlan, &bond->vlan_list, vlan_list) {
-			vlan_dev = vlan_group_get_device(bond->vlgrp,
-							 vlan->vlan_id);
-			if (vlan_dev)
-				__bond_resend_igmp_join_requests(vlan_dev);
-		}
+	list_for_each_entry(vlan, &bond->vlan_list, vlan_list) {
+		vlan_dev = vlan_find_dev(bond->dev, vlan->vlan_id);
+		if (vlan_dev)
+			__bond_resend_igmp_join_requests(vlan_dev);
 	}
 
 	if (--bond->igmp_retrans > 0)
 		queue_delayed_work(bond->wq, &bond->mcast_work, HZ/5);
 
+	rcu_read_unlock();
 	read_unlock(&bond->lock);
 }
 
@@ -1476,7 +1396,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
 	/* no need to lock since we're protected by rtnl_lock */
 	if (slave_dev->features & NETIF_F_VLAN_CHALLENGED) {
 		pr_debug("%s: NETIF_F_VLAN_CHALLENGED\n", slave_dev->name);
-		if (bond->vlgrp) {
+		if (!list_empty(&bond->vlan_list)) {
 			pr_err("%s: Error: cannot enslave VLAN challenged slave %s on VLAN enabled bond %s\n",
 			       bond_dev->name, slave_dev->name, bond_dev->name);
 			return -EPERM;
@@ -1975,9 +1895,7 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev)
 		 */
 		memset(bond_dev->dev_addr, 0, bond_dev->addr_len);
 
-		if (!bond->vlgrp) {
-			bond_dev->features |= NETIF_F_VLAN_CHALLENGED;
-		} else {
+		if (!list_empty(&bond->vlan_list)) {
 			pr_warning("%s: Warning: clearing HW address of %s while it still has VLANs.\n",
 				   bond_dev->name, bond_dev->name);
 			pr_warning("%s: When re-adding slaves, make sure the bond's HW address matches its VLANs'.\n",
@@ -2167,9 +2085,7 @@ static int bond_release_all(struct net_device *bond_dev)
 	 */
 	memset(bond_dev->dev_addr, 0, bond_dev->addr_len);
 
-	if (!bond->vlgrp) {
-		bond_dev->features |= NETIF_F_VLAN_CHALLENGED;
-	} else {
+	if (!list_empty(&bond->vlan_list)) {
 		pr_warning("%s: Warning: clearing HW address of %s while it still has VLANs.\n",
 			   bond_dev->name, bond_dev->name);
 		pr_warning("%s: When re-adding slaves, make sure the bond's HW address matches its VLANs'.\n",
@@ -2601,11 +2517,13 @@ static void bond_arp_send_all(struct bonding *bond, struct slave *slave)
 	struct flowi fl;
 	struct rtable *rt;
 
+	rcu_read_lock();
+
 	for (i = 0; (i < BOND_MAX_ARP_TARGETS); i++) {
 		if (!targets[i])
 			break;
 		pr_debug("basa: target %x\n", targets[i]);
-		if (!bond->vlgrp) {
+		if (list_empty(&bond->vlan_list)) {
 			pr_debug("basa: empty vlan: arp_send\n");
 			bond_arp_send(slave->dev, ARPOP_REQUEST, targets[i],
 				      bond->master_ip, 0);
@@ -2643,7 +2561,7 @@ static void bond_arp_send_all(struct bonding *bond, struct slave *slave)
 
 		vlan_id = 0;
 		list_for_each_entry(vlan, &bond->vlan_list, vlan_list) {
-			vlan_dev = vlan_group_get_device(bond->vlgrp, vlan->vlan_id);
+			vlan_dev = vlan_find_dev(bond->dev, vlan->vlan_id);
 			if (vlan_dev == rt->dst.dev) {
 				vlan_id = vlan->vlan_id;
 				pr_debug("basa: vlan match on %s %d\n",
@@ -2666,6 +2584,8 @@ static void bond_arp_send_all(struct bonding *bond, struct slave *slave)
 		}
 		ip_rt_put(rt);
 	}
+
+	rcu_read_unlock();
 }
 
 /*
@@ -2694,16 +2614,17 @@ static void bond_send_gratuitous_arp(struct bonding *bond)
 				bond->master_ip, 0);
 	}
 
-	if (!bond->vlgrp)
-		return;
+	rcu_read_lock();
 
 	list_for_each_entry(vlan, &bond->vlan_list, vlan_list) {
-		vlan_dev = vlan_group_get_device(bond->vlgrp, vlan->vlan_id);
+		vlan_dev = vlan_find_dev(bond->dev, vlan->vlan_id);
 		if (vlan->vlan_ip) {
 			bond_arp_send(slave->dev, ARPOP_REPLY, vlan->vlan_ip,
 				      vlan->vlan_ip, vlan->vlan_id);
 		}
 	}
+
+	rcu_read_unlock();
 }
 
 static void bond_validate_arp(struct bonding *bond, struct slave *slave, __be32 sip, __be32 tip)
@@ -3653,9 +3574,7 @@ static int bond_inetaddr_event(struct notifier_block *this, unsigned long event,
 		}
 
 		list_for_each_entry(vlan, &bond->vlan_list, vlan_list) {
-			if (!bond->vlgrp)
-				continue;
-			vlan_dev = vlan_group_get_device(bond->vlgrp, vlan->vlan_id);
+			vlan_dev = vlan_find_dev(bond->dev, vlan->vlan_id);
 			if (vlan_dev == event_dev) {
 				switch (event) {
 				case NETDEV_UP:
@@ -4656,7 +4575,6 @@ static const struct net_device_ops bond_netdev_ops = {
 	.ndo_change_mtu		= bond_change_mtu,
 	.ndo_set_mac_address 	= bond_set_mac_address,
 	.ndo_neigh_setup	= bond_neigh_setup,
-	.ndo_vlan_rx_register	= bond_vlan_rx_register,
 	.ndo_vlan_rx_add_vid 	= bond_vlan_rx_add_vid,
 	.ndo_vlan_rx_kill_vid	= bond_vlan_rx_kill_vid,
 #ifdef CONFIG_NET_POLL_CONTROLLER
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index c15f213..999746b 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -218,7 +218,6 @@ struct bonding {
 	struct   alb_bond_info alb_info;
 	struct   bond_params params;
 	struct   list_head vlan_list;
-	struct   vlan_group *vlgrp;
 	struct   packet_type arp_mon_pt;
 	struct   workqueue_struct *wq;
 	struct   delayed_work mii_work;
-- 
1.7.0.4


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

* [RFC PATCH 7/7] vlan: Remove accleration legacy functions.
  2010-10-13 20:02 [RFC PATCH 0/7] Move vlan acceleration into networking core Jesse Gross
                   ` (5 preceding siblings ...)
  2010-10-13 20:02 ` [RFC PATCH 6/7] bonding: Update bonding for new vlan model Jesse Gross
@ 2010-10-13 20:02 ` Jesse Gross
  2010-10-19  9:50 ` [RFC PATCH 0/7] Move vlan acceleration into networking core David Miller
  7 siblings, 0 replies; 15+ messages in thread
From: Jesse Gross @ 2010-10-13 20:02 UTC (permalink / raw)
  To: davem; +Cc: netdev

This removes the explicit vlan accleration functions that acted
as shims in favor of the main receive functions that can now
handle vlans.

Signed-off-by: Jesse Gross <jesse@nicira.com>
--
This patch can only be applied once all drivers that use vlan acceleration
have been converted over to the new model.
---
 include/linux/if_vlan.h   |   66 +++-----------------------------------------
 include/linux/netdevice.h |    8 -----
 net/8021q/vlan.c          |    8 +-----
 net/8021q/vlan_core.c     |   25 -----------------
 4 files changed, 6 insertions(+), 101 deletions(-)

diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index e21028b..c6952af 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -73,13 +73,16 @@ static inline struct vlan_ethhdr *vlan_eth_hdr(const struct sk_buff *skb)
 /* found in socket.c */
 extern void vlan_ioctl_set(int (*hook)(struct net *, void __user *));
 
+#define vlan_tx_tag_present(__skb)	((__skb)->vlan_tci & VLAN_TAG_PRESENT)
+#define vlan_tx_tag_get(__skb)		((__skb)->vlan_tci & ~VLAN_TAG_PRESENT)
+
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
 /* if this changes, algorithm will have to be reworked because this
  * depends on completely exhausting the VLAN identifier space.  Thus
  * it gives constant time look-up, but in many cases it wastes memory.
  */
-#define VLAN_GROUP_ARRAY_LEN          VLAN_N_VID
 #define VLAN_GROUP_ARRAY_SPLIT_PARTS  8
-#define VLAN_GROUP_ARRAY_PART_LEN     (VLAN_GROUP_ARRAY_LEN/VLAN_GROUP_ARRAY_SPLIT_PARTS)
+#define VLAN_GROUP_ARRAY_PART_LEN     (VLAN_N_VID/VLAN_GROUP_ARRAY_SPLIT_PARTS)
 
 struct vlan_group {
 	struct net_device	*real_dev; /* The ethernet(like) device
@@ -111,10 +114,6 @@ static inline void vlan_group_set_device(struct vlan_group *vg,
 	array[vlan_id % VLAN_GROUP_ARRAY_PART_LEN] = dev;
 }
 
-#define vlan_tx_tag_present(__skb)	((__skb)->vlan_tci & VLAN_TAG_PRESENT)
-#define vlan_tx_tag_get(__skb)		((__skb)->vlan_tci & ~VLAN_TAG_PRESENT)
-
-#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
 /* Must be invoked with rcu_read_lock or with RTNL. */
 static inline struct net_device *vlan_find_dev(struct net_device *real_dev,
 					       u16 vlan_id)
@@ -130,15 +129,7 @@ static inline struct net_device *vlan_find_dev(struct net_device *real_dev,
 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,
-			     u16 vlan_tci, int polling);
 extern int vlan_hwaccel_do_receive(struct sk_buff *skb);
-extern gro_result_t
-vlan_gro_receive(struct napi_struct *napi, struct vlan_group *grp,
-		 unsigned int vlan_tci, struct sk_buff *skb);
-extern gro_result_t
-vlan_gro_frags(struct napi_struct *napi, struct vlan_group *grp,
-	       unsigned int vlan_tci);
 
 #else
 static inline struct net_device *vlan_find_dev(struct net_device *real_dev,
@@ -159,61 +150,14 @@ static inline u16 vlan_dev_vlan_id(const struct net_device *dev)
 	return 0;
 }
 
-static inline int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp,
-				    u16 vlan_tci, int polling)
-{
-	BUG();
-	return NET_XMIT_SUCCESS;
-}
-
 static inline int vlan_hwaccel_do_receive(struct sk_buff *skb)
 {
 	BUG();
 	return 0;
 }
-
-static inline gro_result_t
-vlan_gro_receive(struct napi_struct *napi, struct vlan_group *grp,
-		 unsigned int vlan_tci, struct sk_buff *skb)
-{
-	return GRO_DROP;
-}
-
-static inline gro_result_t
-vlan_gro_frags(struct napi_struct *napi, struct vlan_group *grp,
-	       unsigned int vlan_tci)
-{
-	return GRO_DROP;
-}
 #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,
-				  u16 vlan_tci)
-{
-	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,
-					   u16 vlan_tci)
-{
-	return __vlan_hwaccel_rx(skb, grp, vlan_tci, 1);
-}
-
-/**
  * __vlan_put_tag - regular VLAN tag inserting
  * @skb: skbuff to tag
  * @vlan_tci: VLAN TCI to insert
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index ef4bbcb..0444994 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -682,12 +682,6 @@ struct netdev_rx_queue {
  *	3. Update dev->stats asynchronously and atomically, and define
  *	   neither operation.
  *
- * void (*ndo_vlan_rx_register)(struct net_device *dev, struct vlan_group *grp);
- *	If device support VLAN receive accleration
- *	(ie. dev->features & NETIF_F_HW_VLAN_RX), then this function is called
- *	when vlan groups for the device changes.  Note: grp is NULL
- *	if no vlan's groups are being used.
- *
  * void (*ndo_vlan_rx_add_vid)(struct net_device *dev, unsigned short vid);
  *	If device support VLAN filtering (dev->features & NETIF_F_HW_VLAN_FILTER)
  *	this function is called when a VLAN id is registered.
@@ -739,8 +733,6 @@ struct net_device_ops {
 						     struct rtnl_link_stats64 *storage);
 	struct net_device_stats* (*ndo_get_stats)(struct net_device *dev);
 
-	void			(*ndo_vlan_rx_register)(struct net_device *dev,
-						        struct vlan_group *grp);
 	void			(*ndo_vlan_rx_add_vid)(struct net_device *dev,
 						       unsigned short vid);
 	void			(*ndo_vlan_rx_kill_vid)(struct net_device *dev,
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index 77634b9..5b26ca9 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -132,9 +132,6 @@ void unregister_vlan_dev(struct net_device *dev, struct list_head *head)
 		struct vlan_group *vlgrp = real_dev->vlgrp;
 
 		rcu_assign_pointer(real_dev->vlgrp, NULL);
-		if (ops->ndo_vlan_rx_register)
-			ops->ndo_vlan_rx_register(real_dev, NULL);
-
 		vlan_gvrp_uninit_applicant(real_dev);
 
 		/* Free the group, after all cpu's are done. */
@@ -206,11 +203,8 @@ int register_vlan_dev(struct net_device *dev)
 	vlan_group_set_device(grp, vlan_id, dev);
 	grp->nr_vlans++;
 
-	if (ngrp) {
-		if (ops->ndo_vlan_rx_register)
-			ops->ndo_vlan_rx_register(real_dev, ngrp);
+	if (ngrp)
 		rcu_assign_pointer(real_dev->vlgrp, ngrp);
-	}
 	if (real_dev->features & NETIF_F_HW_VLAN_FILTER)
 		ops->ndo_vlan_rx_add_vid(real_dev, vlan_id);
 
diff --git a/net/8021q/vlan_core.c b/net/8021q/vlan_core.c
index df90412..ac8fcc5 100644
--- a/net/8021q/vlan_core.c
+++ b/net/8021q/vlan_core.c
@@ -67,28 +67,3 @@ u16 vlan_dev_vlan_id(const struct net_device *dev)
 	return vlan_dev_info(dev)->vlan_id;
 }
 EXPORT_SYMBOL(vlan_dev_vlan_id);
-
-/* VLAN rx hw acceleration helper.  This acts like netif_{rx,receive_skb}(). */
-int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp,
-		      u16 vlan_tci, int polling)
-{
-	__vlan_hwaccel_put_tag(skb, vlan_tci);
-	return polling ? netif_receive_skb(skb) : netif_rx(skb);
-}
-EXPORT_SYMBOL(__vlan_hwaccel_rx);
-
-gro_result_t vlan_gro_receive(struct napi_struct *napi, struct vlan_group *grp,
-			      unsigned int vlan_tci, struct sk_buff *skb)
-{
-	__vlan_hwaccel_put_tag(skb, vlan_tci);
-	return napi_gro_receive(napi, skb);
-}
-EXPORT_SYMBOL(vlan_gro_receive);
-
-gro_result_t vlan_gro_frags(struct napi_struct *napi, struct vlan_group *grp,
-			    unsigned int vlan_tci)
-{
-	__vlan_hwaccel_put_tag(napi->skb, vlan_tci);
-	return napi_gro_frags(napi);
-}
-EXPORT_SYMBOL(vlan_gro_frags);
-- 
1.7.0.4


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

* Re: [RFC PATCH 2/7] vlan: Centralize handling of hardware acceleration.
  2010-10-13 20:02 ` [RFC PATCH 2/7] vlan: Centralize handling of hardware acceleration Jesse Gross
@ 2010-10-13 21:12   ` Eric Dumazet
  2010-10-14 22:23     ` Jesse Gross
  0 siblings, 1 reply; 15+ messages in thread
From: Eric Dumazet @ 2010-10-13 21:12 UTC (permalink / raw)
  To: Jesse Gross; +Cc: davem, netdev

Le mercredi 13 octobre 2010 à 13:02 -0700, Jesse Gross a écrit :
> Currently each driver that is capable of vlan hardware acceleration
> must be aware of the vlan groups that are configured and then pass
> the stripped tag to a specialized receive function.  This is
> different from other types of hardware offload in that it places a
> significant amount of knowledge in the driver itself rather keeping
> it in the networking core.
> 
> This makes vlan offloading function more similarly to other forms
> of offloading (such as checksum offloading or TSO) by doing the
> following:
> * On receive, stripped vlans are passed directly to the network
> core, without attempting to check for vlan groups or reconstructing
> the header if no group
> * vlans are made less special by folding the logic into the main
> receive routines
> * On transmit, the device layer will add the vlan header in software
> if the hardware doesn't support it, instead of spreading that logic
> out in upper layers, such as bonding.
> 
> There are a number of advantages to this:
> * Fixes all bugs with drivers incorrectly dropping vlan headers at once.
> * Avoids having to disable VLAN acceleration when in promiscuous mode
> (good for bridging since it always puts devices in promiscuous mode).
> * Keeps VLAN tag separate until given to ultimate consumer, which
> avoids needing to do header reconstruction as in tg3 unless absolutely
> necessary.
> * Consolidates common code in core networking.
> 
> Signed-off-by: Jesse Gross <jesse@nicira.com>


Hi Jesse !

Very nice and exciting code consolidation, but please read on :)

> ---
>  include/linux/if_vlan.h         |   27 ++++++++-
>  include/linux/netdevice.h       |   12 +++-
>  net/8021q/vlan.c                |  102 ++++++++-----------------------
>  net/8021q/vlan.h                |   17 -----
>  net/8021q/vlan_core.c           |  125 +++++++++------------------------------
>  net/8021q/vlan_dev.c            |    2 +-
>  net/bridge/netfilter/ebt_vlan.c |    4 +-
>  net/core/dev.c                  |   42 ++++++++++++--
>  8 files changed, 129 insertions(+), 202 deletions(-)
> 
> diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
> index a523207..e21028b 100644
> --- a/include/linux/if_vlan.h
> +++ b/include/linux/if_vlan.h
> @@ -68,6 +68,7 @@ static inline struct vlan_ethhdr *vlan_eth_hdr(const struct sk_buff *skb)
>  #define VLAN_CFI_MASK		0x1000 /* Canonical Format Indicator */
>  #define VLAN_TAG_PRESENT	VLAN_CFI_MASK
>  #define VLAN_VID_MASK		0x0fff /* VLAN Identifier */
> +#define VLAN_N_VID		4096
>  

This should be a patch on its own (change VLAN_GROUP_ARRAY_LEN to
VLAN_N_ID), because this patch is too big.

Please try to not change too many things at once, you remove many
temporary variables and this only makes review very time consuming.

>  /* found in socket.c */
>  extern void vlan_ioctl_set(int (*hook)(struct net *, void __user *));
> @@ -76,7 +77,7 @@ extern void vlan_ioctl_set(int (*hook)(struct net *, void __user *));
>   * depends on completely exhausting the VLAN identifier space.  Thus
>   * it gives constant time look-up, but in many cases it wastes memory.
>   */
> -#define VLAN_GROUP_ARRAY_LEN          4096
> +#define VLAN_GROUP_ARRAY_LEN          VLAN_N_VID
>  #define VLAN_GROUP_ARRAY_SPLIT_PARTS  8
>  #define VLAN_GROUP_ARRAY_PART_LEN     (VLAN_GROUP_ARRAY_LEN/VLAN_GROUP_ARRAY_SPLIT_PARTS)
>  
> @@ -114,12 +115,24 @@ static inline void vlan_group_set_device(struct vlan_group *vg,
>  #define vlan_tx_tag_get(__skb)		((__skb)->vlan_tci & ~VLAN_TAG_PRESENT)
>  
>  #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
> +/* Must be invoked with rcu_read_lock or with RTNL. */
> +static inline struct net_device *vlan_find_dev(struct net_device *real_dev,
> +					       u16 vlan_id)
> +{
> +	struct vlan_group *grp = rcu_dereference(real_dev->vlgrp);
> +

This rcu_dereference() doesnt match the comment.

You might want rcu_dereference_rtnl() instead and use CONFIG_PROVE_RCU

> +	if (grp)
> +		return vlan_group_get_device(grp, vlan_id);
> +
> +	return NULL;
> +}
> +
>  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,
>  			     u16 vlan_tci, int polling);
> -extern void vlan_hwaccel_do_receive(struct sk_buff *skb);
> +extern int vlan_hwaccel_do_receive(struct sk_buff *skb);
>  extern gro_result_t
>  vlan_gro_receive(struct napi_struct *napi, struct vlan_group *grp,
>  		 unsigned int vlan_tci, struct sk_buff *skb);
> @@ -128,6 +141,12 @@ vlan_gro_frags(struct napi_struct *napi, struct vlan_group *grp,
>  	       unsigned int vlan_tci);
>  
>  #else
> +static inline struct net_device *vlan_find_dev(struct net_device *real_dev,
> +					       u16 vlan_id)
> +{
> +	return NULL;
> +}
> +
>  static inline struct net_device *vlan_dev_real_dev(const struct net_device *dev)
>  {
>  	BUG();
> @@ -147,8 +166,10 @@ static inline int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp,
>  	return NET_XMIT_SUCCESS;
>  }
>  
> -static inline void vlan_hwaccel_do_receive(struct sk_buff *skb)
> +static inline int vlan_hwaccel_do_receive(struct sk_buff *skb)
>  {
> +	BUG();
> +	return 0;
>  }
>  
>  static inline gro_result_t
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index 14fbb04..ef4bbcb 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -942,7 +942,10 @@ struct net_device {
>  
> 
>  	/* Protocol specific pointers */
> -	
> +
> +#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
> +	struct vlan_group	*vlgrp;		/* VLAN group */
> +#endif
>  #ifdef CONFIG_NET_DSA
>  	void			*dsa_ptr;	/* dsa specific data */
>  #endif
> @@ -2248,8 +2251,13 @@ static inline int skb_gso_ok(struct sk_buff *skb, int features)
>  
>  static inline int netif_needs_gso(struct net_device *dev, struct sk_buff *skb)
>  {
> +	int features = dev->features;
> +
> +	if (skb->protocol == htons(ETH_P_8021Q) || skb->vlan_tci)
> +		features &= dev->vlan_features;
> +
>  	return skb_is_gso(skb) &&
> -	       (!skb_gso_ok(skb, dev->features) ||
> +	       (!skb_gso_ok(skb, features) ||
>  		unlikely(skb->ip_summed != CHECKSUM_PARTIAL));


Maybe reorder tests to common case, avoiding some uneeded computations
if !skb_is_gso()

	if (skb_is_gso(skb)) {
		int features = dev->features;

		if (skb->protocol == htons(ETH_P_8021Q) || skb->vlan_tci)
			features &= dev->vlan_features;
		
		return !skb_gso_ok(skb, features) ||
			skb->ip_summed != CHECKSUM_PARTIAL;

	}
	return 0;

>  }
>  
> diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
> index 25c2133..77634b9 100644
> --- a/net/8021q/vlan.c
> +++ b/net/8021q/vlan.c
> @@ -44,9 +44,6 @@
>  
>  int vlan_net_id __read_mostly;
>  
> -/* Our listing of VLAN group(s) */
> -static struct hlist_head vlan_group_hash[VLAN_GRP_HASH_SIZE];
> -
>  const char vlan_fullname[] = "802.1Q VLAN Support";
>  const char vlan_version[] = DRV_VERSION;
>  static const char vlan_copyright[] = "Ben Greear <greearb@candelatech.com>";
> @@ -59,40 +56,6 @@ static struct packet_type vlan_packet_type __read_mostly = {
>  
>  /* End of global variables definitions. */
>  
> -static inline unsigned int vlan_grp_hashfn(unsigned int idx)
> -{
> -	return ((idx >> VLAN_GRP_HASH_SHIFT) ^ idx) & VLAN_GRP_HASH_MASK;
> -}
> -
> -/* Must be invoked with RCU read lock (no preempt) */
> -static struct vlan_group *__vlan_find_group(struct net_device *real_dev)
> -{
> -	struct vlan_group *grp;
> -	struct hlist_node *n;
> -	int hash = vlan_grp_hashfn(real_dev->ifindex);
> -
> -	hlist_for_each_entry_rcu(grp, n, &vlan_group_hash[hash], hlist) {
> -		if (grp->real_dev == real_dev)
> -			return grp;
> -	}
> -
> -	return NULL;
> -}
> -
> -/*  Find the protocol handler.  Assumes VID < VLAN_VID_MASK.
> - *
> - * Must be invoked with RCU read lock (no preempt)
> - */
> -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, vlan_id);
> -
> -	return NULL;
> -}
> -
>  static void vlan_group_free(struct vlan_group *grp)
>  {
>  	int i;
> @@ -111,8 +74,6 @@ static struct vlan_group *vlan_group_alloc(struct net_device *real_dev)
>  		return NULL;
>  
>  	grp->real_dev = real_dev;
> -	hlist_add_head_rcu(&grp->hlist,
> -			&vlan_group_hash[vlan_grp_hashfn(real_dev->ifindex)]);
>  	return grp;
>  }
>  
> @@ -146,13 +107,10 @@ void unregister_vlan_dev(struct net_device *dev, struct list_head *head)
>  	struct vlan_dev_info *vlan = vlan_dev_info(dev);
>  	struct net_device *real_dev = vlan->real_dev;
>  	const struct net_device_ops *ops = real_dev->netdev_ops;
> -	struct vlan_group *grp;
>  	u16 vlan_id = vlan->vlan_id;
>  
>  	ASSERT_RTNL();
> -
> -	grp = __vlan_find_group(real_dev);
> -	BUG_ON(!grp);
> +	BUG_ON(!real_dev->vlgrp);
>  
>  	/* Take it out of our own structures, but be sure to interlock with
>  	 * HW accelerating devices or SW vlan input packet processing if
> @@ -161,25 +119,26 @@ void unregister_vlan_dev(struct net_device *dev, struct list_head *head)
>  	if (vlan_id && (real_dev->features & NETIF_F_HW_VLAN_FILTER))
>  		ops->ndo_vlan_rx_kill_vid(real_dev, vlan_id);
>  
> -	grp->nr_vlans--;
> +	real_dev->vlgrp->nr_vlans--;
>  
> -	vlan_group_set_device(grp, vlan_id, NULL);
> -	if (!grp->killall)
> +	vlan_group_set_device(real_dev->vlgrp, vlan_id, NULL);
> +	if (!real_dev->vlgrp->killall)
>  		synchronize_net();
>  
>  	unregister_netdevice_queue(dev, head);
>  
>  	/* If the group is now empty, kill off the group. */
> -	if (grp->nr_vlans == 0) {
> -		vlan_gvrp_uninit_applicant(real_dev);
> +	if (real_dev->vlgrp->nr_vlans == 0) {
> +		struct vlan_group *vlgrp = real_dev->vlgrp;
>  
> -		if (real_dev->features & NETIF_F_HW_VLAN_RX)
> +		rcu_assign_pointer(real_dev->vlgrp, NULL);
> +		if (ops->ndo_vlan_rx_register)
>  			ops->ndo_vlan_rx_register(real_dev, NULL);
>  
> -		hlist_del_rcu(&grp->hlist);
> +		vlan_gvrp_uninit_applicant(real_dev);
>  
>  		/* Free the group, after all cpu's are done. */
> -		call_rcu(&grp->rcu, vlan_rcu_free);
> +		call_rcu(&vlgrp->rcu, vlan_rcu_free);
>  	}
>  
>  	/* Get rid of the vlan's reference to real_dev */
> @@ -196,18 +155,13 @@ int vlan_check_real_dev(struct net_device *real_dev, u16 vlan_id)
>  		return -EOPNOTSUPP;
>  	}
>  
> -	if ((real_dev->features & NETIF_F_HW_VLAN_RX) && !ops->ndo_vlan_rx_register) {
> -		pr_info("8021q: device %s has buggy VLAN hw accel\n", name);
> -		return -EOPNOTSUPP;
> -	}
> -
>  	if ((real_dev->features & NETIF_F_HW_VLAN_FILTER) &&
>  	    (!ops->ndo_vlan_rx_add_vid || !ops->ndo_vlan_rx_kill_vid)) {
>  		pr_info("8021q: Device %s has buggy VLAN hw accel\n", name);
>  		return -EOPNOTSUPP;
>  	}
>  
> -	if (__find_vlan_dev(real_dev, vlan_id) != NULL)
> +	if (vlan_find_dev(real_dev, vlan_id) != NULL)
>  		return -EEXIST;
>  
>  	return 0;
> @@ -222,7 +176,7 @@ int register_vlan_dev(struct net_device *dev)
>  	struct vlan_group *grp, *ngrp = NULL;
>  	int err;
>  
> -	grp = __vlan_find_group(real_dev);
> +	grp = real_dev->vlgrp;
>  	if (!grp) {
>  		ngrp = grp = vlan_group_alloc(real_dev);
>  		if (!grp)
> @@ -252,8 +206,11 @@ int register_vlan_dev(struct net_device *dev)
>  	vlan_group_set_device(grp, vlan_id, dev);
>  	grp->nr_vlans++;
>  
> -	if (ngrp && real_dev->features & NETIF_F_HW_VLAN_RX)
> -		ops->ndo_vlan_rx_register(real_dev, ngrp);
> +	if (ngrp) {
> +		if (ops->ndo_vlan_rx_register)
> +			ops->ndo_vlan_rx_register(real_dev, ngrp);
> +		rcu_assign_pointer(real_dev->vlgrp, ngrp);
> +	}
>  	if (real_dev->features & NETIF_F_HW_VLAN_FILTER)
>  		ops->ndo_vlan_rx_add_vid(real_dev, vlan_id);
>  
> @@ -264,7 +221,6 @@ out_uninit_applicant:
>  		vlan_gvrp_uninit_applicant(real_dev);
>  out_free_group:
>  	if (ngrp) {
> -		hlist_del_rcu(&ngrp->hlist);
>  		/* Free the group, after all cpu's are done. */
>  		call_rcu(&ngrp->rcu, vlan_rcu_free);
>  	}
> @@ -428,7 +384,7 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
>  		dev->netdev_ops->ndo_vlan_rx_add_vid(dev, 0);
>  	}
>  
> -	grp = __vlan_find_group(dev);
> +	grp = dev->vlgrp;
>  	if (!grp)
>  		goto out;
>  
> @@ -439,7 +395,7 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
>  	switch (event) {
>  	case NETDEV_CHANGE:
>  		/* Propagate real device state to vlan devices */
> -		for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) {
> +		for (i = 0; i < VLAN_N_VID; i++) {
>  			vlandev = vlan_group_get_device(grp, i);
>  			if (!vlandev)
>  				continue;
> @@ -450,7 +406,7 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
>  
>  	case NETDEV_CHANGEADDR:
>  		/* Adjust unicast filters on underlying device */
> -		for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) {
> +		for (i = 0; i < VLAN_N_VID; i++) {
>  			vlandev = vlan_group_get_device(grp, i);
>  			if (!vlandev)
>  				continue;
> @@ -464,7 +420,7 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
>  		break;
>  
>  	case NETDEV_CHANGEMTU:
> -		for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) {
> +		for (i = 0; i < VLAN_N_VID; i++) {
>  			vlandev = vlan_group_get_device(grp, i);
>  			if (!vlandev)
>  				continue;
> @@ -478,7 +434,7 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
>  
>  	case NETDEV_FEAT_CHANGE:
>  		/* Propagate device features to underlying device */
> -		for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) {
> +		for (i = 0; i < VLAN_N_VID; i++) {

cleanup patch please


>  			vlandev = vlan_group_get_device(grp, i);
>  			if (!vlandev)
>  				continue;
> @@ -490,7 +446,7 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
>  
>  	case NETDEV_DOWN:
>  		/* Put all VLANs for this dev in the down state too.  */
> -		for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) {
> +		for (i = 0; i < VLAN_N_VID; i++) {

cleanup patch please

>  			vlandev = vlan_group_get_device(grp, i);
>  			if (!vlandev)
>  				continue;
> @@ -508,7 +464,7 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
>  
>  	case NETDEV_UP:
>  		/* Put all VLANs for this dev in the up state too.  */
> -		for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) {
> +		for (i = 0; i < VLAN_N_VID; i++) {

cleanup patch please

>  			vlandev = vlan_group_get_device(grp, i);
>  			if (!vlandev)
>  				continue;
> @@ -532,7 +488,7 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
>  		/* Delete all VLANs for this dev. */
>  		grp->killall = 1;
>  
> -		for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) {
> +		for (i = 0; i < VLAN_N_VID; i++) {

cleanup patch please

>  			vlandev = vlan_group_get_device(grp, i);
>  			if (!vlandev)
>  				continue;
> @@ -540,7 +496,7 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
>  			/* unregistration of last vlan destroys group, abort
>  			 * afterwards */
>  			if (grp->nr_vlans == 1)
> -				i = VLAN_GROUP_ARRAY_LEN;
> +				i = VLAN_N_VID;
>  
>  			unregister_vlan_dev(vlandev, &list);
>  		}
> @@ -746,8 +702,6 @@ err0:
>  
>  static void __exit vlan_cleanup_module(void)
>  {
> -	unsigned int i;
> -
>  	vlan_ioctl_set(NULL);
>  	vlan_netlink_fini();
>  
> @@ -755,10 +709,6 @@ static void __exit vlan_cleanup_module(void)
>  
>  	dev_remove_pack(&vlan_packet_type);
>  
> -	/* This table must be empty if there are no module references left. */
> -	for (i = 0; i < VLAN_GRP_HASH_SIZE; i++)
> -		BUG_ON(!hlist_empty(&vlan_group_hash[i]));
> -
>  	unregister_pernet_subsys(&vlan_net_ops);
>  	rcu_barrier(); /* Wait for completion of call_rcu()'s */
>  
> diff --git a/net/8021q/vlan.h b/net/8021q/vlan.h
> index 8d9503a..db01b31 100644
> --- a/net/8021q/vlan.h
> +++ b/net/8021q/vlan.h
> @@ -72,23 +72,6 @@ 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)
> -
> -/*  Find a VLAN device by the MAC address of its Ethernet device, and
> - *  it's VLAN ID.  The default configuration is to have VLAN's scope
> - *  to be box-wide, so the MAC will be ignored.  The mac will only be
> - *  looked at if we are configured to have a separate set of VLANs per
> - *  each MAC addressable interface.  Note that this latter option does
> - *  NOT follow the spec for VLANs, but may be useful for doing very
> - *  large quantities of VLAN MUX/DEMUX onto FrameRelay or ATM PVCs.
> - *
> - *  Must be invoked with rcu_read_lock (ie preempt disabled)
> - *  or with RTNL.
> - */
> -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);
> diff --git a/net/8021q/vlan_core.c b/net/8021q/vlan_core.c
> index dee727c..df90412 100644
> --- a/net/8021q/vlan_core.c
> +++ b/net/8021q/vlan_core.c
> @@ -4,54 +4,33 @@
>  #include <linux/netpoll.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,
> -		      u16 vlan_tci, int polling)
> +int vlan_hwaccel_do_receive(struct sk_buff *skb)
>  {
> +	u16 vlan_id = skb->vlan_tci & VLAN_VID_MASK;
>  	struct net_device *vlan_dev;
> -	u16 vlan_id;
> -
> -	if (netpoll_rx(skb))
> -		return NET_RX_DROP;
> -
> -	if (skb_bond_should_drop(skb, ACCESS_ONCE(skb->dev->master)))
> -		skb->deliver_no_wcard = 1;
> -
> -	skb->skb_iif = skb->dev->ifindex;
> -	__vlan_hwaccel_put_tag(skb, vlan_tci);
> -	vlan_id = vlan_tci & VLAN_VID_MASK;
> -	vlan_dev = vlan_group_get_device(grp, vlan_id);
> +	struct vlan_rx_stats *rx_stats;
>  
> -	if (vlan_dev)
> -		skb->dev = vlan_dev;
> -	else if (vlan_id) {
> -		if (!(skb->dev->flags & IFF_PROMISC))
> -			goto drop;
> -		skb->pkt_type = PACKET_OTHERHOST;
> +	vlan_dev = vlan_find_dev(skb->dev, vlan_id);
> +	if (!vlan_dev) {
> +		if (vlan_id)
> +			skb->pkt_type = PACKET_OTHERHOST;
> +		return NET_RX_SUCCESS;
>  	}
>  
> -	return polling ? netif_receive_skb(skb) : netif_rx(skb);
> -
> -drop:
> -	atomic_long_inc(&skb->dev->rx_dropped);
> -	dev_kfree_skb_any(skb);
> -	return NET_RX_DROP;
> -}
> -EXPORT_SYMBOL(__vlan_hwaccel_rx);
> -
> -void vlan_hwaccel_do_receive(struct sk_buff *skb)
> -{
> -	struct net_device *dev = skb->dev;

this temporary variable was nice for a better code readability

> -	struct vlan_rx_stats     *rx_stats;
> +	if (netpoll_receive_skb(skb))
> +		return NET_RX_DROP;
>  
> -	skb->dev = vlan_dev_real_dev(dev);

>  	netif_nit_deliver(skb);
Strange you dont change netif_nit_deliver() ?

>  
> -	skb->dev = dev;
> -	skb->priority = vlan_get_ingress_priority(dev, skb->vlan_tci);
> +	skb->skb_iif = skb->dev->ifindex;
> +	if (skb_bond_should_drop(skb, ACCESS_ONCE(skb->dev->master)))
> +		skb->deliver_no_wcard = 1;
> +
> +	skb->dev = vlan_dev;
> +	skb->priority = vlan_get_ingress_priority(skb->dev, skb->vlan_tci);
>  	skb->vlan_tci = 0;
>  
> -	rx_stats = this_cpu_ptr(vlan_dev_info(dev)->vlan_rx_stats);
> +	rx_stats = this_cpu_ptr(vlan_dev_info(skb->dev)->vlan_rx_stats);

vlan_dev here, instead of skb->dev ?

>  
>  	u64_stats_update_begin(&rx_stats->syncp);
>  	rx_stats->rx_packets++;
> @@ -68,11 +47,13 @@ void vlan_hwaccel_do_receive(struct sk_buff *skb)
>  		 * 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,
> -					dev->dev_addr))
> +					skb->dev->dev_addr))

all this skb->dev->... are really hard to understand

>  			skb->pkt_type = PACKET_HOST;
>  		break;
>  	}
>  	u64_stats_update_end(&rx_stats->syncp);
> +
> +	return NET_RX_SUCCESS;
>  }
>  
>  struct net_device *vlan_dev_real_dev(const struct net_device *dev)
> @@ -87,75 +68,27 @@ u16 vlan_dev_vlan_id(const struct net_device *dev)
>  }
>  EXPORT_SYMBOL(vlan_dev_vlan_id);
>  
> -static gro_result_t
> -vlan_gro_common(struct napi_struct *napi, struct vlan_group *grp,
> -		unsigned int vlan_tci, struct sk_buff *skb)
> +/* VLAN rx hw acceleration helper.  This acts like netif_{rx,receive_skb}(). */
> +int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp,
> +		      u16 vlan_tci, int polling)
>  {
> -	struct sk_buff *p;
> -	struct net_device *vlan_dev;
> -	u16 vlan_id;
> -
> -	if (skb_bond_should_drop(skb, ACCESS_ONCE(skb->dev->master)))
> -		skb->deliver_no_wcard = 1;
> -
> -	skb->skb_iif = skb->dev->ifindex;
>  	__vlan_hwaccel_put_tag(skb, vlan_tci);
> -	vlan_id = vlan_tci & VLAN_VID_MASK;
> -	vlan_dev = vlan_group_get_device(grp, vlan_id);
> -
> -	if (vlan_dev)
> -		skb->dev = vlan_dev;
> -	else if (vlan_id) {
> -		if (!(skb->dev->flags & IFF_PROMISC))
> -			goto drop;
> -		skb->pkt_type = PACKET_OTHERHOST;
> -	}
> -
> -	for (p = napi->gro_list; p; p = p->next) {
> -		unsigned long diffs;
> -
> -		diffs = (unsigned long)p->dev ^ (unsigned long)skb->dev;
> -		diffs |= compare_ether_header(skb_mac_header(p),
> -					      skb_gro_mac_header(skb));
> -		NAPI_GRO_CB(p)->same_flow = !diffs;
> -		NAPI_GRO_CB(p)->flush = 0;
> -	}
> -
> -	return dev_gro_receive(napi, skb);
> -
> -drop:
> -	atomic_long_inc(&skb->dev->rx_dropped);
> -	return GRO_DROP;
> +	return polling ? netif_receive_skb(skb) : netif_rx(skb);
>  }
> +EXPORT_SYMBOL(__vlan_hwaccel_rx);
>  
>  gro_result_t vlan_gro_receive(struct napi_struct *napi, struct vlan_group *grp,
>  			      unsigned int vlan_tci, struct sk_buff *skb)
>  {
> -	if (netpoll_rx_on(skb))
> -		return vlan_hwaccel_receive_skb(skb, grp, vlan_tci)
> -			? GRO_DROP : GRO_NORMAL;
> -
> -	skb_gro_reset_offset(skb);
> -
> -	return napi_skb_finish(vlan_gro_common(napi, grp, vlan_tci, skb), skb);
> +	__vlan_hwaccel_put_tag(skb, vlan_tci);
> +	return napi_gro_receive(napi, skb);
>  }
>  EXPORT_SYMBOL(vlan_gro_receive);
>  
>  gro_result_t vlan_gro_frags(struct napi_struct *napi, struct vlan_group *grp,
>  			    unsigned int vlan_tci)
>  {
> -	struct sk_buff *skb = napi_frags_skb(napi);
> -
> -	if (!skb)
> -		return GRO_DROP;
> -
> -	if (netpoll_rx_on(skb)) {
> -		skb->protocol = eth_type_trans(skb, skb->dev);
> -		return vlan_hwaccel_receive_skb(skb, grp, vlan_tci)
> -			? GRO_DROP : GRO_NORMAL;
> -	}
> -
> -	return napi_frags_finish(napi, skb,
> -				 vlan_gro_common(napi, grp, vlan_tci, skb));
> +	__vlan_hwaccel_put_tag(napi->skb, vlan_tci);
> +	return napi_gro_frags(napi);
>  }
>  EXPORT_SYMBOL(vlan_gro_frags);
> diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
> index f54251e..14e3d1f 100644
> --- a/net/8021q/vlan_dev.c
> +++ b/net/8021q/vlan_dev.c
> @@ -158,7 +158,7 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
>  	vlan_id = vlan_tci & VLAN_VID_MASK;
>  
>  	rcu_read_lock();
> -	vlan_dev = __find_vlan_dev(dev, vlan_id);
> +	vlan_dev = vlan_find_dev(dev, vlan_id);
>  
>  	/* If the VLAN device is defined, we use it.
>  	 * If not, and the VID is 0, it is a 802.1p packet (not
> diff --git a/net/bridge/netfilter/ebt_vlan.c b/net/bridge/netfilter/ebt_vlan.c
> index a39d92d..e724720 100644
> --- a/net/bridge/netfilter/ebt_vlan.c
> +++ b/net/bridge/netfilter/ebt_vlan.c
> @@ -119,10 +119,10 @@ static int ebt_vlan_mt_check(const struct xt_mtchk_param *par)
>  	 * 0 - The null VLAN ID.
>  	 * 1 - The default Port VID (PVID)
>  	 * 0x0FFF - Reserved for implementation use.
> -	 * if_vlan.h: VLAN_GROUP_ARRAY_LEN 4096. */
> +	 * if_vlan.h: VLAN_N_VID 4096. */
>  	if (GET_BITMASK(EBT_VLAN_ID)) {
>  		if (!!info->id) { /* if id!=0 => check vid range */
> -			if (info->id > VLAN_GROUP_ARRAY_LEN) {
> +			if (info->id > VLAN_N_VID) {
>  				pr_debug("id %d is out of range (1-4096)\n",
>  					 info->id);
>  				return -EINVAL;
> diff --git a/net/core/dev.c b/net/core/dev.c
> index 04972a4..9586aff 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -1692,7 +1692,12 @@ static bool can_checksum_protocol(unsigned long features, __be16 protocol)
>  
>  static bool dev_can_checksum(struct net_device *dev, struct sk_buff *skb)
>  {
> -	if (can_checksum_protocol(dev->features, skb->protocol))
> +	int features = dev->features;
> +
> +	if (vlan_tx_tag_present(skb))
> +		features &= dev->vlan_features;
> +
> +	if (can_checksum_protocol(features, skb->protocol))
>  		return true;
>  
>  	if (skb->protocol == htons(ETH_P_8021Q)) {
> @@ -1791,6 +1796,16 @@ struct sk_buff *skb_gso_segment(struct sk_buff *skb, int features)
>  	__be16 type = skb->protocol;
>  	int err;
>  
> +	if (type == htons(ETH_P_8021Q)) {
> +		struct vlan_ethhdr *veh;
> +
> +		if (unlikely(!pskb_may_pull(skb, VLAN_ETH_HLEN)))
> +			return ERR_PTR(-EINVAL);
> +
> +		veh = (struct vlan_ethhdr *)skb->data;
> +		type = veh->h_vlan_encapsulated_proto;
> +	}
> +
>  	skb_reset_mac_header(skb);
>  	skb->mac_len = skb->network_header - skb->mac_header;
>  	__skb_pull(skb, skb->mac_len);
> @@ -1962,9 +1977,14 @@ static inline void skb_orphan_try(struct sk_buff *skb)
>  static inline int skb_needs_linearize(struct sk_buff *skb,
>  				      struct net_device *dev)
>  {
> +	int features = dev->features;
> +
> +	if (skb->protocol == htons(ETH_P_8021Q) || vlan_tx_tag_present(skb))
> +		features &= dev->vlan_features;
> +
>  	return skb_is_nonlinear(skb) &&
> -	       ((skb_has_frag_list(skb) && !(dev->features & NETIF_F_FRAGLIST)) ||
> -	        (skb_shinfo(skb)->nr_frags && (!(dev->features & NETIF_F_SG) ||
> +	       ((skb_has_frag_list(skb) && !(features & NETIF_F_FRAGLIST)) ||
> +	        (skb_shinfo(skb)->nr_frags && (!(features & NETIF_F_SG) ||
>  					      illegal_highdma(dev, skb))));
>  }
>  
> @@ -1987,6 +2007,15 @@ int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev,
>  
>  		skb_orphan_try(skb);
>  
> +		if (vlan_tx_tag_present(skb) &&
> +		    !(dev->features & NETIF_F_HW_VLAN_TX)) {
> +			skb = __vlan_put_tag(skb, vlan_tx_tag_get(skb));
> +			if (unlikely(!skb))
> +				goto out;
> +
> +			skb->vlan_tci = 0;
> +		}
> +
>  		if (netif_needs_gso(dev, skb)) {
>  			if (unlikely(dev_gso_segment(skb)))
>  				goto out_kfree_skb;
> @@ -2048,6 +2077,7 @@ out_kfree_gso_skb:
>  		skb->destructor = DEV_GSO_CB(skb)->destructor;
>  out_kfree_skb:
>  	kfree_skb(skb);
> +out:
>  	return rc;
>  }
>  
> @@ -2893,8 +2923,8 @@ static int __netif_receive_skb(struct sk_buff *skb)
>  	if (!netdev_tstamp_prequeue)
>  		net_timestamp_check(skb);
>  
> -	if (vlan_tx_tag_present(skb))
> -		vlan_hwaccel_do_receive(skb);
> +	if (vlan_tx_tag_present(skb) && vlan_hwaccel_do_receive(skb))
> +		return NET_RX_DROP;
>  
>  	/* if we've gotten here through NAPI, check netpoll */
>  	if (netpoll_receive_skb(skb))
> @@ -3232,6 +3262,7 @@ __napi_gro_receive(struct napi_struct *napi, struct sk_buff *skb)
>  		unsigned long diffs;
>  
>  		diffs = (unsigned long)p->dev ^ (unsigned long)skb->dev;
> +		diffs |= p->vlan_tci ^ skb->vlan_tci;
>  		diffs |= compare_ether_header(skb_mac_header(p),
>  					      skb_gro_mac_header(skb));
>  		NAPI_GRO_CB(p)->same_flow = !diffs;
> @@ -3291,6 +3322,7 @@ void napi_reuse_skb(struct napi_struct *napi, struct sk_buff *skb)
>  {
>  	__skb_pull(skb, skb_headlen(skb));
>  	skb_reserve(skb, NET_IP_ALIGN - skb_headroom(skb));
> +	skb->vlan_tci = 0;
>  
>  	napi->skb = skb;
>  }


I believe this stuff is a great idea, but you should take more time to
make your patches more understandable.

Given 2.6.36 is about to be released, and Netfilter Workshop 2010 begins
in few days, there is no hurry, because there is no chance we add so
many fundamental changes before three weeks at least.

I believe this patch (2/7), should be split in small units, maybe 3 or 4
different patches.

Thanks



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

* Re: [RFC PATCH 2/7] vlan: Centralize handling of hardware acceleration.
  2010-10-13 21:12   ` Eric Dumazet
@ 2010-10-14 22:23     ` Jesse Gross
  0 siblings, 0 replies; 15+ messages in thread
From: Jesse Gross @ 2010-10-14 22:23 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: davem, netdev

On Wed, Oct 13, 2010 at 2:12 PM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
> Le mercredi 13 octobre 2010 à 13:02 -0700, Jesse Gross a écrit :
>> +#define VLAN_N_VID           4096
>>
>
> This should be a patch on its own (change VLAN_GROUP_ARRAY_LEN to
> VLAN_N_ID), because this patch is too big.

That's fine, I separated it out.

>
> Please try to not change too many things at once, you remove many
> temporary variables and this only makes review very time consuming.

For what's worth, it used to be worse: originally all seven of these
patches were one...

>>  #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
>> +/* Must be invoked with rcu_read_lock or with RTNL. */
>> +static inline struct net_device *vlan_find_dev(struct net_device *real_dev,
>> +                                            u16 vlan_id)
>> +{
>> +     struct vlan_group *grp = rcu_dereference(real_dev->vlgrp);
>> +
>
> This rcu_dereference() doesnt match the comment.
>
> You might want rcu_dereference_rtnl() instead and use CONFIG_PROVE_RCU

Sure, I changed it to use rcu_dereference_rtnl().

>>  static inline int netif_needs_gso(struct net_device *dev, struct sk_buff *skb)
>>  {
>> +     int features = dev->features;
>> +
>> +     if (skb->protocol == htons(ETH_P_8021Q) || skb->vlan_tci)
>> +             features &= dev->vlan_features;
>> +
>>       return skb_is_gso(skb) &&
>> -            (!skb_gso_ok(skb, dev->features) ||
>> +            (!skb_gso_ok(skb, features) ||
>>               unlikely(skb->ip_summed != CHECKSUM_PARTIAL));
>
>
> Maybe reorder tests to common case, avoiding some uneeded computations
> if !skb_is_gso()

That's a good idea, thanks.

>> -void vlan_hwaccel_do_receive(struct sk_buff *skb)
>> -{
>> -     struct net_device *dev = skb->dev;
>
> this temporary variable was nice for a better code readability

I changed all these references to use vlan_dev.

>
>> -     struct vlan_rx_stats     *rx_stats;
>> +     if (netpoll_receive_skb(skb))
>> +             return NET_RX_DROP;
>>
>> -     skb->dev = vlan_dev_real_dev(dev);
>
>>       netif_nit_deliver(skb);
> Strange you dont change netif_nit_deliver() ?

netif_nit_deliver() is used in pretty much the same manner that it was
before, which is why I didn't change it.  Specifically, it can already
handle pulling the tag out of skb->vlan_tci on the underlying device.
tcpdump works as expected after my changes.  Is there something that
you think I'm missing?

> I believe this stuff is a great idea, but you should take more time to
> make your patches more understandable.
>
> Given 2.6.36 is about to be released, and Netfilter Workshop 2010 begins
> in few days, there is no hurry, because there is no chance we add so
> many fundamental changes before three weeks at least.
>
> I believe this patch (2/7), should be split in small units, maybe 3 or 4
> different patches.

Thanks for the review Eric.  I made the above changes plus broke this
patch down into 4 separate components (and you're right, it is much
easier to look through).  I'll hold onto the series until things open
up again.  In the meantime I'll also try to convert over more of the
drivers.

Thanks again.

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

* Re: [RFC PATCH 3/7] bnx2: Update bnx2 to use new vlan accleration.
  2010-10-13 20:02 ` [RFC PATCH 3/7] bnx2: Update bnx2 to use new vlan accleration Jesse Gross
@ 2010-10-14 22:56   ` Michael Chan
  2010-10-15  1:36     ` Jesse Gross
  0 siblings, 1 reply; 15+ messages in thread
From: Michael Chan @ 2010-10-14 22:56 UTC (permalink / raw)
  To: Jesse Gross; +Cc: davem, netdev


On Wed, 2010-10-13 at 13:02 -0700, Jesse Gross wrote:
> Make the bnx2 driver use the new vlan accleration model.
> 
> Signed-off-by: Jesse Gross <jesse@nicira.com>
> CC: Michael Chan <mchan@broadcom.com>
> ---
>  drivers/net/bnx2.c |   75 +++------------------------------------------------
>  drivers/net/bnx2.h |    4 ---
>  2 files changed, 5 insertions(+), 74 deletions(-)
> 
> diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
> index ae894bc..2d306f4 100644
> --- a/drivers/net/bnx2.c
> +++ b/drivers/net/bnx2.c
> @@ -37,9 +37,6 @@
>  #include <linux/ethtool.h>
>  #include <linux/mii.h>
>  #include <linux/if_vlan.h>
> -#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
> -#define BCM_VLAN 1
> -#endif
>  #include <net/ip.h>
>  #include <net/tcp.h>
>  #include <net/checksum.h>
> @@ -3087,8 +3084,6 @@ bnx2_rx_int(struct bnx2 *bp, struct bnx2_napi *bnapi, int budget)
>  		struct sw_bd *rx_buf, *next_rx_buf;
>  		struct sk_buff *skb;
>  		dma_addr_t dma_addr;
> -		u16 vtag = 0;
> -		int hw_vlan __maybe_unused = 0;
>  
>  		sw_ring_cons = RX_RING_IDX(sw_cons);
>  		sw_ring_prod = RX_RING_IDX(sw_prod);
> @@ -3168,23 +3163,8 @@ bnx2_rx_int(struct bnx2 *bp, struct bnx2_napi *bnapi, int budget)
>  			goto next_rx;
>  
>  		if ((status & L2_FHDR_STATUS_L2_VLAN_TAG) &&
> -		    !(bp->rx_mode & BNX2_EMAC_RX_MODE_KEEP_VLAN_TAG)) {
> -			vtag = rx_hdr->l2_fhdr_vlan_tag;
> -#ifdef BCM_VLAN
> -			if (bp->vlgrp)
> -				hw_vlan = 1;
> -			else
> -#endif
> -			{
> -				struct vlan_ethhdr *ve = (struct vlan_ethhdr *)
> -					__skb_push(skb, 4);
> -
> -				memmove(ve, skb->data + 4, ETH_ALEN * 2);
> -				ve->h_vlan_proto = htons(ETH_P_8021Q);
> -				ve->h_vlan_TCI = htons(vtag);
> -				len += 4;
> -			}
> -		}
> +		    !(bp->rx_mode & BNX2_EMAC_RX_MODE_KEEP_VLAN_TAG))

This check for the rx_mode bit is no longer necessary if we always
configure the chip to strip out the vlan tag.


> +			__vlan_hwaccel_put_tag(skb, rx_hdr->l2_fhdr_vlan_tag);
>  
>  		skb->protocol = eth_type_trans(skb, bp->dev);
>  
> @@ -3211,14 +3191,7 @@ bnx2_rx_int(struct bnx2 *bp, struct bnx2_napi *bnapi, int budget)
>  			skb->rxhash = rx_hdr->l2_fhdr_hash;
>  
>  		skb_record_rx_queue(skb, bnapi - &bp->bnx2_napi[0]);
> -
> -#ifdef BCM_VLAN
> -		if (hw_vlan)
> -			vlan_gro_receive(&bnapi->napi, bp->vlgrp, vtag, skb);
> -		else
> -#endif
> -			napi_gro_receive(&bnapi->napi, skb);
> -
> +		napi_gro_receive(&bnapi->napi, skb);
>  		rx_pkt++;
>  
>  next_rx:
> @@ -3533,13 +3506,6 @@ bnx2_set_rx_mode(struct net_device *dev)
>  	rx_mode = bp->rx_mode & ~(BNX2_EMAC_RX_MODE_PROMISCUOUS |
>  				  BNX2_EMAC_RX_MODE_KEEP_VLAN_TAG);
>  	sort_mode = 1 | BNX2_RPM_SORT_USER0_BC_EN;
> -#ifdef BCM_VLAN
> -	if (!bp->vlgrp && (bp->flags & BNX2_FLAG_CAN_KEEP_VLAN))
> -		rx_mode |= BNX2_EMAC_RX_MODE_KEEP_VLAN_TAG;
> -#else
> -	if (bp->flags & BNX2_FLAG_CAN_KEEP_VLAN)
> -		rx_mode |= BNX2_EMAC_RX_MODE_KEEP_VLAN_TAG;
> -#endif
>  	if (dev->flags & IFF_PROMISC) {
>  		/* Promiscuous mode. */
>  		rx_mode |= BNX2_EMAC_RX_MODE_PROMISCUOUS;
> @@ -6365,29 +6331,6 @@ bnx2_tx_timeout(struct net_device *dev)
>  	schedule_work(&bp->reset_task);
>  }
>  
> -#ifdef BCM_VLAN
> -/* Called with rtnl_lock */
> -static void
> -bnx2_vlan_rx_register(struct net_device *dev, struct vlan_group *vlgrp)
> -{
> -	struct bnx2 *bp = netdev_priv(dev);
> -
> -	if (netif_running(dev))
> -		bnx2_netif_stop(bp, false);
> -
> -	bp->vlgrp = vlgrp;
> -
> -	if (!netif_running(dev))
> -		return;
> -
> -	bnx2_set_rx_mode(dev);
> -	if (bp->flags & BNX2_FLAG_CAN_KEEP_VLAN)
> -		bnx2_fw_sync(bp, BNX2_DRV_MSG_CODE_KEEP_VLAN_UPDATE, 0, 1);
> -
> -	bnx2_netif_start(bp, false);
> -}
> -#endif
> -
>  /* Called with netif_tx_lock.
>   * bnx2_tx_int() runs without netif_tx_lock unless it needs to call
>   * netif_wake_queue().
> @@ -6428,12 +6371,11 @@ bnx2_start_xmit(struct sk_buff *skb, struct net_device *dev)
>  		vlan_tag_flags |= TX_BD_FLAGS_TCP_UDP_CKSUM;
>  	}
>  
> -#ifdef BCM_VLAN
> -	if (bp->vlgrp && vlan_tx_tag_present(skb)) {
> +	if (vlan_tx_tag_present(skb)) {
>  		vlan_tag_flags |=
>  			(TX_BD_FLAGS_VLAN_TAG | (vlan_tx_tag_get(skb) << 16));
>  	}
> -#endif
> +
>  	if ((mss = skb_shinfo(skb)->gso_size)) {
>  		u32 tcp_opt_len;
>  		struct iphdr *iph;
> @@ -8318,9 +8260,6 @@ static const struct net_device_ops bnx2_netdev_ops = {
>  	.ndo_set_mac_address	= bnx2_change_mac_addr,
>  	.ndo_change_mtu		= bnx2_change_mtu,
>  	.ndo_tx_timeout		= bnx2_tx_timeout,
> -#ifdef BCM_VLAN
> -	.ndo_vlan_rx_register	= bnx2_vlan_rx_register,
> -#endif
>  #ifdef CONFIG_NET_POLL_CONTROLLER
>  	.ndo_poll_controller	= poll_bnx2,
>  #endif
> @@ -8328,9 +8267,7 @@ static const struct net_device_ops bnx2_netdev_ops = {
>  
>  static void inline vlan_features_add(struct net_device *dev, unsigned long flags)
>  {
> -#ifdef BCM_VLAN
>  	dev->vlan_features |= flags;
> -#endif
>  }
>  
>  static int __devinit
> @@ -8379,9 +8316,7 @@ bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
>  		dev->features |= NETIF_F_IPV6_CSUM;
>  		vlan_features_add(dev, NETIF_F_IPV6_CSUM);
>  	}
> -#ifdef BCM_VLAN
>  	dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
> -#endif
>  	dev->features |= NETIF_F_TSO | NETIF_F_TSO_ECN;
>  	vlan_features_add(dev, NETIF_F_TSO | NETIF_F_TSO_ECN);
>  	if (CHIP_NUM(bp) == CHIP_NUM_5709) {
> diff --git a/drivers/net/bnx2.h b/drivers/net/bnx2.h
> index efdfbc2..4f44db6 100644
> --- a/drivers/net/bnx2.h
> +++ b/drivers/net/bnx2.h
> @@ -6742,10 +6742,6 @@ struct bnx2 {
>  
>  	struct bnx2_napi	bnx2_napi[BNX2_MAX_MSIX_VEC];
>  
> -#ifdef BCM_VLAN
> -	struct			vlan_group *vlgrp;
> -#endif
> -
>  	u32			rx_buf_use_size;	/* useable size */
>  	u32			rx_buf_size;		/* with alignment */
>  	u32			rx_copy_thresh;



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

* Re: [RFC PATCH 3/7] bnx2: Update bnx2 to use new vlan accleration.
  2010-10-14 22:56   ` Michael Chan
@ 2010-10-15  1:36     ` Jesse Gross
  0 siblings, 0 replies; 15+ messages in thread
From: Jesse Gross @ 2010-10-15  1:36 UTC (permalink / raw)
  To: Michael Chan; +Cc: davem, netdev

On Thu, Oct 14, 2010 at 3:56 PM, Michael Chan <mchan@broadcom.com> wrote:
>>               if ((status & L2_FHDR_STATUS_L2_VLAN_TAG) &&
>> -                 !(bp->rx_mode & BNX2_EMAC_RX_MODE_KEEP_VLAN_TAG)) {
>> -                     vtag = rx_hdr->l2_fhdr_vlan_tag;
>> -#ifdef BCM_VLAN
>> -                     if (bp->vlgrp)
>> -                             hw_vlan = 1;
>> -                     else
>> -#endif
>> -                     {
>> -                             struct vlan_ethhdr *ve = (struct vlan_ethhdr *)
>> -                                     __skb_push(skb, 4);
>> -
>> -                             memmove(ve, skb->data + 4, ETH_ALEN * 2);
>> -                             ve->h_vlan_proto = htons(ETH_P_8021Q);
>> -                             ve->h_vlan_TCI = htons(vtag);
>> -                             len += 4;
>> -                     }
>> -             }
>> +                 !(bp->rx_mode & BNX2_EMAC_RX_MODE_KEEP_VLAN_TAG))
>
> This check for the rx_mode bit is no longer necessary if we always
> configure the chip to strip out the vlan tag.

Thanks, I've dropped it from my local tree.  I may add support for
ethtool to disable vlan stripping in the future, so I might have to
add it back.

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

* Re: [RFC PATCH 1/7] ebtables: Allow filtering of hardware accelerated vlan frames.
  2010-10-13 20:02 ` [RFC PATCH 1/7] ebtables: Allow filtering of hardware accelerated vlan frames Jesse Gross
@ 2010-10-18 19:58   ` Ben Hutchings
  2010-10-19  3:14     ` Jesse Gross
  0 siblings, 1 reply; 15+ messages in thread
From: Ben Hutchings @ 2010-10-18 19:58 UTC (permalink / raw)
  To: Jesse Gross; +Cc: davem, netdev

On Wed, 2010-10-13 at 13:02 -0700, Jesse Gross wrote:
> An upcoming commit will allow packets with hardware vlan acceleration
> information to be passed though more parts of the network stack, including
> packets trunked through the bridge.  This adds support for matching and
> filtering those packets through ebtables.
> 
> Signed-off-by: Jesse Gross <jesse@nicira.com>
> ---
>  net/bridge/br_netfilter.c       |   16 +++++++++-------
>  net/bridge/netfilter/ebt_vlan.c |   38 +++++++++++++++++++++++---------------
>  net/bridge/netfilter/ebtables.c |   15 +++++++++++----
>  3 files changed, 43 insertions(+), 26 deletions(-)
> 
> diff --git a/net/bridge/br_netfilter.c b/net/bridge/br_netfilter.c
> index 7f9ce96..d6a4fec 100644
> --- a/net/bridge/br_netfilter.c
> +++ b/net/bridge/br_netfilter.c
> @@ -64,22 +64,24 @@ static int brnf_filter_pppoe_tagged __read_mostly = 0;
>  
>  static inline __be16 vlan_proto(const struct sk_buff *skb)
>  {
> -	return vlan_eth_hdr(skb)->h_vlan_encapsulated_proto;
> +	if (skb->protocol == htons(ETH_P_8021Q))
> +		return vlan_eth_hdr(skb)->h_vlan_encapsulated_proto;
> +	else if (vlan_tx_tag_present(skb))
> +		return skb->protocol;

If there are two levels of VLAN-encapsulation, this will return either
the inner or outer tag depending on whether VLAN acceleration is being
used.  It should behave consistently.

> +	else
> +		return 0;
>  }
>  
>  #define IS_VLAN_IP(skb) \
> -	(skb->protocol == htons(ETH_P_8021Q) && \
> -	 vlan_proto(skb) == htons(ETH_P_IP) && 	\
> +	(vlan_proto(skb) == htons(ETH_P_IP) && 	\
>  	 brnf_filter_vlan_tagged)
>  
>  #define IS_VLAN_IPV6(skb) \
> -	(skb->protocol == htons(ETH_P_8021Q) && \
> -	 vlan_proto(skb) == htons(ETH_P_IPV6) &&\
> +	(vlan_proto(skb) == htons(ETH_P_IPV6) &&\
>  	 brnf_filter_vlan_tagged)
>  
>  #define IS_VLAN_ARP(skb) \
> -	(skb->protocol == htons(ETH_P_8021Q) &&	\
> -	 vlan_proto(skb) == htons(ETH_P_ARP) &&	\
> +	(vlan_proto(skb) == htons(ETH_P_ARP) &&	\
>  	 brnf_filter_vlan_tagged)
>  
>  static inline __be16 pppoe_proto(const struct sk_buff *skb)
> diff --git a/net/bridge/netfilter/ebt_vlan.c b/net/bridge/netfilter/ebt_vlan.c
> index 87b53b3..a39d92d 100644
> --- a/net/bridge/netfilter/ebt_vlan.c
> +++ b/net/bridge/netfilter/ebt_vlan.c
> @@ -39,8 +39,6 @@ static bool
>  ebt_vlan_mt(const struct sk_buff *skb, struct xt_action_param *par)
>  {
>  	const struct ebt_vlan_info *info = par->matchinfo;
> -	const struct vlan_hdr *fp;
> -	struct vlan_hdr _frame;
>  
>  	unsigned short TCI;	/* Whole TCI, given from parsed frame */
>  	unsigned short id;	/* VLAN ID, given from frame TCI */
> @@ -48,21 +46,31 @@ ebt_vlan_mt(const struct sk_buff *skb, struct xt_action_param *par)
>  	/* VLAN encapsulated Type/Length field, given from orig frame */
>  	__be16 encap;
>  
> -	fp = skb_header_pointer(skb, 0, sizeof(_frame), &_frame);
> -	if (fp == NULL)
> -		return false;
> -
> -	/* Tag Control Information (TCI) consists of the following elements:
> -	 * - User_priority. The user_priority field is three bits in length,
> -	 * interpreted as a binary number.
> -	 * - Canonical Format Indicator (CFI). The Canonical Format Indicator
> -	 * (CFI) is a single bit flag value. Currently ignored.
> -	 * - VLAN Identifier (VID). The VID is encoded as
> -	 * an unsigned binary number. */
> -	TCI = ntohs(fp->h_vlan_TCI);
> +	if (skb->protocol == htons(ETH_P_8021Q)) {
> +		const struct vlan_hdr *fp;
> +		struct vlan_hdr _frame;
> +
> +		fp = skb_header_pointer(skb, 0, sizeof(_frame), &_frame);
> +		if (fp == NULL)
> +			return false;
> +
> +		/* Tag Control Information (TCI) consists of the following elements:
> +		 * - User_priority. The user_priority field is three bits in length,
> +		 * interpreted as a binary number.
> +		 * - Canonical Format Indicator (CFI). The Canonical Format Indicator
> +		 * (CFI) is a single bit flag value. Currently ignored.
> +		 * - VLAN Identifier (VID). The VID is encoded as
> +		 * an unsigned binary number. */
> +		TCI = ntohs(fp->h_vlan_TCI);
> +
> +		encap = fp->h_vlan_encapsulated_proto;
> +	} else {
> +		TCI = vlan_tx_tag_get(skb);
> +		encap = skb->protocol;
> +	}
> +
[...]

This has the same problem.

Ben.

-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.


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

* Re: [RFC PATCH 1/7] ebtables: Allow filtering of hardware accelerated vlan frames.
  2010-10-18 19:58   ` Ben Hutchings
@ 2010-10-19  3:14     ` Jesse Gross
  0 siblings, 0 replies; 15+ messages in thread
From: Jesse Gross @ 2010-10-19  3:14 UTC (permalink / raw)
  To: Ben Hutchings; +Cc: davem, netdev

On Mon, Oct 18, 2010 at 12:58 PM, Ben Hutchings
<bhutchings@solarflare.com> wrote:
> On Wed, 2010-10-13 at 13:02 -0700, Jesse Gross wrote:
>> An upcoming commit will allow packets with hardware vlan acceleration
>> information to be passed though more parts of the network stack, including
>> packets trunked through the bridge.  This adds support for matching and
>> filtering those packets through ebtables.
>>
>> Signed-off-by: Jesse Gross <jesse@nicira.com>
>> ---
>>  net/bridge/br_netfilter.c       |   16 +++++++++-------
>>  net/bridge/netfilter/ebt_vlan.c |   38 +++++++++++++++++++++++---------------
>>  net/bridge/netfilter/ebtables.c |   15 +++++++++++----
>>  3 files changed, 43 insertions(+), 26 deletions(-)
>>
>> diff --git a/net/bridge/br_netfilter.c b/net/bridge/br_netfilter.c
>> index 7f9ce96..d6a4fec 100644
>> --- a/net/bridge/br_netfilter.c
>> +++ b/net/bridge/br_netfilter.c
>> @@ -64,22 +64,24 @@ static int brnf_filter_pppoe_tagged __read_mostly = 0;
>>
>>  static inline __be16 vlan_proto(const struct sk_buff *skb)
>>  {
>> -     return vlan_eth_hdr(skb)->h_vlan_encapsulated_proto;
>> +     if (skb->protocol == htons(ETH_P_8021Q))
>> +             return vlan_eth_hdr(skb)->h_vlan_encapsulated_proto;
>> +     else if (vlan_tx_tag_present(skb))
>> +             return skb->protocol;
>
> If there are two levels of VLAN-encapsulation, this will return either
> the inner or outer tag depending on whether VLAN acceleration is being
> used.  It should behave consistently.

Thanks, you're right.  I fixed it to always use the outer tag (same as
previous behavior).

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

* Re: [RFC PATCH 0/7] Move vlan acceleration into networking core.
  2010-10-13 20:02 [RFC PATCH 0/7] Move vlan acceleration into networking core Jesse Gross
                   ` (6 preceding siblings ...)
  2010-10-13 20:02 ` [RFC PATCH 7/7] vlan: Remove accleration legacy functions Jesse Gross
@ 2010-10-19  9:50 ` David Miller
  7 siblings, 0 replies; 15+ messages in thread
From: David Miller @ 2010-10-19  9:50 UTC (permalink / raw)
  To: jesse; +Cc: netdev

From: Jesse Gross <jesse@nicira.com>
Date: Wed, 13 Oct 2010 13:02:50 -0700

> Hardware vlan acceleration behaves fairly differently from other
> types of offloading, which limits its usefulness.  This patch series
> aims to bring it more in line with other common forms of
> acceleration, such as checksum offloading and TSO.  In doing this it
> eliminates common driver bugs, increases flexibility, and improves
> performance, while reducing the number of lines of code.
> 
> The first four patches can be applied immediately, while the last
> three need to wait until all drivers that support vlan acceleration
> are updated.  If people agree that this patch set makes sense I will
> go ahead and switch over the dozen or so drivers that would need to
> change.

These changes look great (and everyone I've asked tends to agree)
so please submit the updated series with feedback integrated
and I'll add at least the first 4 patches to net-next-2.6

Thanks!

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

end of thread, other threads:[~2010-10-19  9:50 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-13 20:02 [RFC PATCH 0/7] Move vlan acceleration into networking core Jesse Gross
2010-10-13 20:02 ` [RFC PATCH 1/7] ebtables: Allow filtering of hardware accelerated vlan frames Jesse Gross
2010-10-18 19:58   ` Ben Hutchings
2010-10-19  3:14     ` Jesse Gross
2010-10-13 20:02 ` [RFC PATCH 2/7] vlan: Centralize handling of hardware acceleration Jesse Gross
2010-10-13 21:12   ` Eric Dumazet
2010-10-14 22:23     ` Jesse Gross
2010-10-13 20:02 ` [RFC PATCH 3/7] bnx2: Update bnx2 to use new vlan accleration Jesse Gross
2010-10-14 22:56   ` Michael Chan
2010-10-15  1:36     ` Jesse Gross
2010-10-13 20:02 ` [RFC PATCH 4/7] ixgbe: Update ixgbe " Jesse Gross
2010-10-13 20:02 ` [RFC PATCH 5/7] lro: Remove explicit vlan support Jesse Gross
2010-10-13 20:02 ` [RFC PATCH 6/7] bonding: Update bonding for new vlan model Jesse Gross
2010-10-13 20:02 ` [RFC PATCH 7/7] vlan: Remove accleration legacy functions Jesse Gross
2010-10-19  9:50 ` [RFC PATCH 0/7] Move vlan acceleration into networking core David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.