netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Pirko <jpirko@redhat.com>
To: netdev@vger.kernel.org
Cc: e1000-devel@lists.sourceforge.net, bruce.w.allan@intel.com,
	jesse.brandeburg@intel.com, mirqus@gmail.com,
	john.ronciak@intel.com, shemminger@linux-foundation.org,
	davem@davemloft.net
Subject: [patch net-next-2.6 37/47] igb: do vlan cleanup
Date: Wed, 20 Jul 2011 16:54:39 +0200	[thread overview]
Message-ID: <1311173689-17419-38-git-send-email-jpirko@redhat.com> (raw)
In-Reply-To: <1311173689-17419-1-git-send-email-jpirko@redhat.com>

- unify vlan and nonvlan rx path
- kill adapter->vlgrp and igb_vlan_rx_register

Signed-off-by: Jiri Pirko <jpirko@redhat.com>
---
 drivers/net/igb/igb.h      |    4 ++-
 drivers/net/igb/igb_main.c |   79 +++++++++++++++++++++-----------------------
 2 files changed, 41 insertions(+), 42 deletions(-)

diff --git a/drivers/net/igb/igb.h b/drivers/net/igb/igb.h
index 0389ff6..265e151 100644
--- a/drivers/net/igb/igb.h
+++ b/drivers/net/igb/igb.h
@@ -37,6 +37,8 @@
 #include <linux/clocksource.h>
 #include <linux/timecompare.h>
 #include <linux/net_tstamp.h>
+#include <linux/bitops.h>
+#include <linux/if_vlan.h>
 
 struct igb_adapter;
 
@@ -252,7 +254,7 @@ static inline int igb_desc_unused(struct igb_ring *ring)
 struct igb_adapter {
 	struct timer_list watchdog_timer;
 	struct timer_list phy_info_timer;
-	struct vlan_group *vlgrp;
+	unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
 	u16 mng_vlan_id;
 	u32 bd_number;
 	u32 wol;
diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c
index f4d82b2..50f264f 100644
--- a/drivers/net/igb/igb_main.c
+++ b/drivers/net/igb/igb_main.c
@@ -28,6 +28,7 @@
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/init.h>
+#include <linux/bitops.h>
 #include <linux/vmalloc.h>
 #include <linux/pagemap.h>
 #include <linux/netdevice.h>
@@ -46,6 +47,7 @@
 #include <linux/if_ether.h>
 #include <linux/aer.h>
 #include <linux/prefetch.h>
+#include <linux/if_vlan.h>
 #ifdef CONFIG_IGB_DCA
 #include <linux/dca.h>
 #endif
@@ -140,7 +142,7 @@ static bool igb_clean_rx_irq_adv(struct igb_q_vector *, int *, int);
 static int igb_ioctl(struct net_device *, struct ifreq *, int cmd);
 static void igb_tx_timeout(struct net_device *);
 static void igb_reset_task(struct work_struct *);
-static void igb_vlan_rx_register(struct net_device *, struct vlan_group *);
+static bool igb_vlan_used(struct igb_adapter *adapter);
 static void igb_vlan_rx_add_vid(struct net_device *, u16);
 static void igb_vlan_rx_kill_vid(struct net_device *, u16);
 static void igb_restore_vlan(struct igb_adapter *);
@@ -1362,7 +1364,7 @@ static void igb_update_mng_vlan(struct igb_adapter *adapter)
 
 	if ((old_vid != (u16)IGB_MNG_VLAN_NONE) &&
 	    (vid != old_vid) &&
-	    !vlan_group_get_device(adapter->vlgrp, old_vid)) {
+	    !test_bit(old_vid, adapter->active_vlans)) {
 		/* remove VID from filter table */
 		igb_vfta_set(hw, old_vid, false);
 	}
@@ -1775,7 +1777,6 @@ static const struct net_device_ops igb_netdev_ops = {
 	.ndo_do_ioctl		= igb_ioctl,
 	.ndo_tx_timeout		= igb_tx_timeout,
 	.ndo_validate_addr	= eth_validate_addr,
-	.ndo_vlan_rx_register	= igb_vlan_rx_register,
 	.ndo_vlan_rx_add_vid	= igb_vlan_rx_add_vid,
 	.ndo_vlan_rx_kill_vid	= igb_vlan_rx_kill_vid,
 	.ndo_set_vf_mac		= igb_ndo_set_vf_mac,
@@ -2943,7 +2944,7 @@ static void igb_rlpml_set(struct igb_adapter *adapter)
 	struct e1000_hw *hw = &adapter->hw;
 	u16 pf_id = adapter->vfs_allocated_count;
 
-	if (adapter->vlgrp)
+	if (igb_vlan_used(adapter))
 		max_frame_size += VLAN_TAG_SIZE;
 
 	/* if vfs are enabled we set RLPML to the largest possible request
@@ -5693,25 +5694,6 @@ static bool igb_clean_tx_irq(struct igb_q_vector *q_vector)
 	return count < tx_ring->count;
 }
 
-/**
- * igb_receive_skb - helper function to handle rx indications
- * @q_vector: structure containing interrupt and ring information
- * @skb: packet to send up
- * @vlan_tag: vlan tag for packet
- **/
-static void igb_receive_skb(struct igb_q_vector *q_vector,
-                            struct sk_buff *skb,
-                            u16 vlan_tag)
-{
-	struct igb_adapter *adapter = q_vector->adapter;
-
-	if (vlan_tag && adapter->vlgrp)
-		vlan_gro_receive(&q_vector->napi, adapter->vlgrp,
-		                 vlan_tag, skb);
-	else
-		napi_gro_receive(&q_vector->napi, skb);
-}
-
 static inline void igb_rx_checksum_adv(struct igb_ring *ring,
 				       u32 status_err, struct sk_buff *skb)
 {
@@ -5809,7 +5791,6 @@ static bool igb_clean_rx_irq_adv(struct igb_q_vector *q_vector,
 	unsigned int i;
 	u32 staterr;
 	u16 length;
-	u16 vlan_tag;
 
 	i = rx_ring->next_to_clean;
 	buffer_info = &rx_ring->buffer_info[i];
@@ -5894,10 +5875,12 @@ send_up:
 		skb->protocol = eth_type_trans(skb, netdev);
 		skb_record_rx_queue(skb, rx_ring->queue_index);
 
-		vlan_tag = ((staterr & E1000_RXD_STAT_VP) ?
-		            le16_to_cpu(rx_desc->wb.upper.vlan) : 0);
+		if (staterr & E1000_RXD_STAT_VP) {
+			u16 vid = le16_to_cpu(rx_desc->wb.upper.vlan);
 
-		igb_receive_skb(q_vector, skb, vlan_tag);
+			__vlan_hwaccel_put_tag(skb, vid);
+		}
+		napi_gro_receive(&q_vector->napi, skb);
 
 next_desc:
 		rx_desc->wb.upper.status_error = 0;
@@ -6290,17 +6273,24 @@ s32 igb_write_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value)
 	return 0;
 }
 
-static void igb_vlan_rx_register(struct net_device *netdev,
-				 struct vlan_group *grp)
+static bool igb_vlan_used(struct igb_adapter *adapter)
+{
+	u16 vid;
+
+	for_each_set_bit(vid, adapter->active_vlans, VLAN_N_VID)
+		return true;
+	return false;
+}
+
+static void igb_vlan_mode(struct net_device *netdev, bool vlan_on)
 {
 	struct igb_adapter *adapter = netdev_priv(netdev);
 	struct e1000_hw *hw = &adapter->hw;
 	u32 ctrl, rctl;
 
 	igb_irq_disable(adapter);
-	adapter->vlgrp = grp;
 
-	if (grp) {
+	if (vlan_on) {
 		/* enable VLAN tag insert/strip */
 		ctrl = rd32(E1000_CTRL);
 		ctrl |= E1000_CTRL_VME;
@@ -6329,11 +6319,16 @@ static void igb_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
 	struct e1000_hw *hw = &adapter->hw;
 	int pf_id = adapter->vfs_allocated_count;
 
+	if (!igb_vlan_used(adapter))
+		igb_vlan_mode(netdev, true);
+
 	/* attempt to add filter to vlvf array */
 	igb_vlvf_set(adapter, vid, true, pf_id);
 
 	/* add the filter since PF can receive vlans w/o entry in vlvf */
 	igb_vfta_set(hw, vid, true);
+
+	set_bit(vid, adapter->active_vlans);
 }
 
 static void igb_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
@@ -6344,7 +6339,6 @@ static void igb_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
 	s32 err;
 
 	igb_irq_disable(adapter);
-	vlan_group_set_device(adapter->vlgrp, vid, NULL);
 
 	if (!test_bit(__IGB_DOWN, &adapter->state))
 		igb_irq_enable(adapter);
@@ -6355,20 +6349,23 @@ static void igb_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
 	/* if vid was not present in VLVF just remove it from table */
 	if (err)
 		igb_vfta_set(hw, vid, false);
+
+	clear_bit(vid, adapter->active_vlans);
+
+	if (!igb_vlan_used(adapter))
+		igb_vlan_mode(netdev, false);
 }
 
 static void igb_restore_vlan(struct igb_adapter *adapter)
 {
-	igb_vlan_rx_register(adapter->netdev, adapter->vlgrp);
+	u16 vid;
 
-	if (adapter->vlgrp) {
-		u16 vid;
-		for (vid = 0; vid < VLAN_N_VID; vid++) {
-			if (!vlan_group_get_device(adapter->vlgrp, vid))
-				continue;
-			igb_vlan_rx_add_vid(adapter->netdev, vid);
-		}
-	}
+	if (!igb_vlan_used(adapter))
+		return;
+
+	igb_vlan_mode(adapter->netdev, true);
+	for_each_set_bit(vid, adapter->active_vlans, VLAN_N_VID)
+		igb_vlan_rx_add_vid(adapter->netdev, vid);
 }
 
 int igb_set_spd_dplx(struct igb_adapter *adapter, u32 spd, u8 dplx)
-- 
1.7.6


------------------------------------------------------------------------------
10 Tips for Better Web Security
Learn 10 ways to better secure your business today. Topics covered include:
Web security, SSL, hacker attacks & Denial of Service (DoS), private keys,
security Microsoft Exchange, secure Instant Messaging, and much more.
http://www.accelacomm.com/jaw/sfnl/114/51426210/
_______________________________________________
E1000-devel mailing list
E1000-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/e1000-devel
To learn more about Intel&#174; Ethernet, visit http://communities.intel.com/community/wired

  parent reply	other threads:[~2011-07-20 14:54 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-20 14:54 [patch net-next-2.6 00/47] vlan cleanup Jiri Pirko
2011-07-20 14:54 ` [patch net-next-2.6 01/47] gianfar: rx parser Jiri Pirko
2011-07-20 15:01   ` Jiri Pirko
2011-07-20 14:54 ` [patch net-next-2.6 02/47] vlan: finish removing vlan_find_dev from public header Jiri Pirko
2011-07-20 14:54 ` [patch net-next-2.6 03/47] vlan: introduce __vlan_find_dev_deep() Jiri Pirko
2011-07-20 14:54 ` [patch net-next-2.6 04/47] nes: do vlan cleanup Jiri Pirko
2011-07-20 15:45   ` Michał Mirosław
2011-07-20 16:01     ` Michał Mirosław
2011-07-20 19:00       ` Jiri Pirko
2011-07-20 14:54 ` [patch net-next-2.6 05/47] ehea: " Jiri Pirko
2011-07-20 14:54 ` [patch net-next-2.6 06/47] lro: kill lro_vlan_hwaccel_receive_skb Jiri Pirko
2011-07-20 14:54 ` [patch net-next-2.6 07/47] lro: kill lro_vlan_hwaccel_receive_frags Jiri Pirko
2011-07-20 14:54 ` [patch net-next-2.6 08/47] lro: do vlan cleanup Jiri Pirko
2011-07-20 14:54 ` [patch net-next-2.6 09/47] amd8111e: " Jiri Pirko
2011-07-20 14:54 ` [patch net-next-2.6 10/47] atl1c: " Jiri Pirko
2011-07-20 14:54 ` [patch net-next-2.6 11/47] atl1e: " Jiri Pirko
2011-07-20 14:54 ` [patch net-next-2.6 12/47] bnad: " Jiri Pirko
2011-07-20 14:54 ` [patch net-next-2.6 13/47] chelsio: " Jiri Pirko
2011-07-20 14:54 ` [patch net-next-2.6 14/47] cxgb4vf: " Jiri Pirko
2011-07-20 14:54 ` [patch net-next-2.6 15/47] cxgb4: remove forgotten unused vlan_group Jiri Pirko
2011-07-20 14:54 ` [patch net-next-2.6 16/47] enic: do vlan cleanup Jiri Pirko
2011-07-20 21:59   ` vkolluri
2011-07-20 14:54 ` [patch net-next-2.6 17/47] gianfar: " Jiri Pirko
2011-07-20 14:54 ` [patch net-next-2.6 18/47] igbvf: " Jiri Pirko
2011-07-20 17:26   ` Jesse Gross
2011-07-20 19:07     ` Jiri Pirko
2011-07-21 13:22   ` [patch net-next-2.6 18/47 V2] " Jiri Pirko
2011-07-21 15:57     ` Rose, Gregory V
2011-07-21 16:23       ` Jiri Pirko
2011-07-21 16:30     ` [patch net-next-2.6 18/47 V3] " Jiri Pirko
2011-07-20 14:54 ` [patch net-next-2.6 19/47] jme: " Jiri Pirko
2011-07-20 14:54 ` [patch net-next-2.6 20/47] mlx4: " Jiri Pirko
2011-07-20 14:54 ` [patch net-next-2.6 21/47] qlge: " Jiri Pirko
2011-07-21 13:24   ` [patch net-next-2.6 21/47 V2] " Jiri Pirko
2011-07-20 14:54 ` [patch net-next-2.6 22/47] s2io: " Jiri Pirko
2011-07-20 14:54 ` [patch net-next-2.6 23/47] spider_net: do not mention dying vlan_hwaccel_receive_skb Jiri Pirko
2011-07-20 14:54 ` [patch net-next-2.6 24/47] tehuti: do vlan cleanup Jiri Pirko
2011-07-20 14:54 ` [patch net-next-2.6 25/47] vlan: kill vlan_hwaccel_receive_skb Jiri Pirko
2011-07-20 14:54 ` [patch net-next-2.6 26/47] ixgbevf: do vlan cleanup Jiri Pirko
2011-07-21 13:25   ` [patch net-next-2.6 26/47 V2] " Jiri Pirko
2011-07-20 14:54 ` [patch net-next-2.6 27/47] acenic: " Jiri Pirko
2011-07-20 14:54 ` [patch net-next-2.6 28/47] via-velocity: " Jiri Pirko
2011-07-20 14:54 ` [patch net-next-2.6 29/47] starfire: " Jiri Pirko
2011-07-20 14:54 ` [patch net-next-2.6 30/47] ns83820: " Jiri Pirko
2011-07-20 14:54 ` [patch net-next-2.6 31/47] atl1: " Jiri Pirko
2011-07-20 14:54 ` [patch net-next-2.6 32/47] atl2: " Jiri Pirko
2011-07-20 14:54 ` [patch net-next-2.6 33/47] cxgb3: " Jiri Pirko
2011-07-20 14:54 ` [patch net-next-2.6 34/47] vlan: kill __vlan_hwaccel_rx and vlan_hwaccel_rx Jiri Pirko
2011-07-20 14:54 ` [patch net-next-2.6 35/47] e1000: do vlan cleanup Jiri Pirko
2011-07-20 17:48   ` Jesse Gross
2011-07-20 19:08     ` Jiri Pirko
2011-07-21 13:26   ` [patch net-next-2.6 35/47 V2] " Jiri Pirko
2011-07-20 14:54 ` [patch net-next-2.6 36/47] forcedeth: " Jiri Pirko
2011-07-20 14:54 ` Jiri Pirko [this message]
2011-07-20 17:35   ` [patch net-next-2.6 37/47] igb: " Jesse Gross
2011-07-20 19:10     ` Jiri Pirko
2011-07-20 23:58       ` Jesse Gross
2011-07-21  6:57         ` Jiri Pirko
2011-07-21 21:45           ` Jesse Gross
2011-07-21 13:27   ` [patch net-next-2.6 37/47 V2] " Jiri Pirko
2011-07-20 14:54 ` [patch net-next-2.6 38/47] vxge: " Jiri Pirko
2011-07-20 14:54 ` [patch net-next-2.6 39/47] qeth: " Jiri Pirko
2011-07-20 14:54 ` [patch net-next-2.6 40/47] vlan: kill vlan_gro_frags and vlan_gro_receive Jiri Pirko
2011-07-20 14:54 ` [patch net-next-2.6 41/47] stmmac: do vlan cleanup Jiri Pirko
2011-07-20 14:54 ` [patch net-next-2.6 42/47] qlcnic: remove usage of vlan_group_get_device Jiri Pirko
2011-07-20 14:54 ` [patch net-next-2.6 43/47] staging: et131x: remove unused prototype et131x_vlan_rx_register Jiri Pirko
2011-07-20 14:54 ` [patch net-next-2.6 44/47] bonding: do vlan cleanup Jiri Pirko
2011-07-20 14:54 ` [patch net-next-2.6 45/47] macvlan: " Jiri Pirko
2011-07-20 14:54 ` [patch net-next-2.6 46/47] vlan: kill ndo_vlan_rx_register Jiri Pirko
2011-07-20 14:54 ` [patch net-next-2.6 47/47] vlan: move vlan_group_[gs]et_device to public header Jiri Pirko
2011-07-21 20:57 ` [patch net-next-2.6 00/47] vlan cleanup David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1311173689-17419-38-git-send-email-jpirko@redhat.com \
    --to=jpirko@redhat.com \
    --cc=bruce.w.allan@intel.com \
    --cc=davem@davemloft.net \
    --cc=e1000-devel@lists.sourceforge.net \
    --cc=jesse.brandeburg@intel.com \
    --cc=john.ronciak@intel.com \
    --cc=mirqus@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=shemminger@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).