Netdev List
 help / color / mirror / Atom feed
From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
To: davem@davemloft.net
Cc: Jacob Keller <jacob.e.keller@intel.com>,
	netdev@vger.kernel.org, nhorman@redhat.com, sassmann@redhat.com,
	jogreene@redhat.com, guru.anbalagane@oracle.com,
	Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Subject: [net-next v2 05/19] i40e: remove code to handle dev_addr specially
Date: Wed,  7 Dec 2016 14:19:04 -0800	[thread overview]
Message-ID: <20161207221918.57932-6-jeffrey.t.kirsher@intel.com> (raw)
In-Reply-To: <20161207221918.57932-1-jeffrey.t.kirsher@intel.com>

From: Jacob Keller <jacob.e.keller@intel.com>

The netdev->dev_addr MAC filter already exists in the
MAC/VLAN hash table, as it is added when we configure
the netdev in i40e_configure_netdev. Because we already
know that this address will be updated in the
hash_for_each loops, we do not need to handle it
specially. This removes duplicate code and simplifies
the i40e_vsi_add_vlan and i40e_vsi_kill_vlan functions.
Because we know these filters must be part of the
MAC/VLAN hash table, this should not have any functional
impact on what filters are included and is merely a code
simplification.

Change-ID: I5e648302dbdd7cc29efc6d203b7019c11f0b5705
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/i40e/i40e_main.c | 43 +++++------------------------
 1 file changed, 7 insertions(+), 36 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index c467cc4..ae4a2b2 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -2515,17 +2515,6 @@ int i40e_vsi_add_vlan(struct i40e_vsi *vsi, s16 vid)
 	/* Locked once because all functions invoked below iterates list*/
 	spin_lock_bh(&vsi->mac_filter_hash_lock);
 
-	if (vsi->netdev) {
-		add_f = i40e_add_filter(vsi, vsi->netdev->dev_addr, vid);
-		if (!add_f) {
-			dev_info(&vsi->back->pdev->dev,
-				 "Could not add vlan filter %d for %pM\n",
-				 vid, vsi->netdev->dev_addr);
-			spin_unlock_bh(&vsi->mac_filter_hash_lock);
-			return -ENOMEM;
-		}
-	}
-
 	hash_for_each_safe(vsi->mac_filter_hash, bkt, h, f, hlist) {
 		if (f->state == I40E_FILTER_REMOVE)
 			continue;
@@ -2539,28 +2528,14 @@ int i40e_vsi_add_vlan(struct i40e_vsi *vsi, s16 vid)
 		}
 	}
 
-	/* Now if we add a vlan tag, make sure to check if it is the first
-	 * tag (i.e. a "tag" -1 does exist) and if so replace the -1 "tag"
-	 * with 0, so we now accept untagged and specified tagged traffic
-	 * (and not all tags along with untagged)
+	/* When we add a new VLAN filter, we need to make sure that all existing
+	 * filters which are marked as vid=-1 (I40E_VLAN_ANY) are converted to
+	 * vid=0. The simplest way is just search for all filters marked as
+	 * vid=-1 and replace them with vid=0. This converts all filters that
+	 * were marked to receive all traffic (tagged or untagged) into
+	 * filters to receive only untagged traffic, so that we don't receive
+	 * tagged traffic for VLANs which we have not configured.
 	 */
-	if (vid > 0 && vsi->netdev) {
-		del_f = i40e_find_filter(vsi, vsi->netdev->dev_addr,
-					 I40E_VLAN_ANY);
-		if (del_f) {
-			__i40e_del_filter(vsi, del_f);
-			add_f = i40e_add_filter(vsi, vsi->netdev->dev_addr, 0);
-			if (!add_f) {
-				dev_info(&vsi->back->pdev->dev,
-					 "Could not add filter 0 for %pM\n",
-					 vsi->netdev->dev_addr);
-				spin_unlock_bh(&vsi->mac_filter_hash_lock);
-				return -ENOMEM;
-			}
-		}
-	}
-
-	/* Do not assume that I40E_VLAN_ANY should be reset to VLAN 0 */
 	if (vid > 0 && !vsi->info.pvid) {
 		hash_for_each_safe(vsi->mac_filter_hash, bkt, h, f, hlist) {
 			if (f->state == I40E_FILTER_REMOVE)
@@ -2597,7 +2572,6 @@ int i40e_vsi_add_vlan(struct i40e_vsi *vsi, s16 vid)
  **/
 void i40e_vsi_kill_vlan(struct i40e_vsi *vsi, s16 vid)
 {
-	struct net_device *netdev = vsi->netdev;
 	struct i40e_mac_filter *f;
 	struct hlist_node *h;
 	int bkt;
@@ -2605,9 +2579,6 @@ void i40e_vsi_kill_vlan(struct i40e_vsi *vsi, s16 vid)
 	/* Locked once because all functions invoked below iterates list */
 	spin_lock_bh(&vsi->mac_filter_hash_lock);
 
-	if (vsi->netdev)
-		i40e_del_filter(vsi, netdev->dev_addr, vid);
-
 	hash_for_each_safe(vsi->mac_filter_hash, bkt, h, f, hlist) {
 		if (f->vlan == vid)
 			__i40e_del_filter(vsi, f);
-- 
2.9.3

  parent reply	other threads:[~2016-12-07 22:20 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-07 22:18 [net-next v2 00/19][pull request] 40GbE Intel Wired LAN Driver Updates 2016-12-07 Jeff Kirsher
2016-12-07 22:19 ` [net-next v2 01/19] i40e: Driver prints log message on link speed change Jeff Kirsher
2016-12-07 22:19 ` [net-next v2 02/19] i40e: simplify txd use count calculation Jeff Kirsher
2016-12-08  0:16   ` Eric Dumazet
2016-12-08  0:35     ` Duyck, Alexander H
2016-12-08  1:03       ` Eric Dumazet
2016-12-08  1:09         ` Duyck, Alexander H
2016-12-07 22:19 ` [net-next v2 03/19] i40e: restore workaround for removing default MAC filter Jeff Kirsher
2016-12-07 22:19 ` [net-next v2 04/19] i40e/i40evf: napi_poll must return the work done Jeff Kirsher
2016-12-07 22:19 ` Jeff Kirsher [this message]
2016-12-07 22:19 ` [net-next v2 06/19] i40e: Blink LED on 1G BaseT boards Jeff Kirsher
2016-12-07 22:19 ` [net-next v2 07/19] Changed version from 1.6.21 to 1.6.25 Jeff Kirsher
2016-12-07 22:19 ` [net-next v2 08/19] i40e: use unsigned printf format specifier for active_filters count Jeff Kirsher
2016-12-07 22:19 ` [net-next v2 09/19] i40e: Add support for 25G devices Jeff Kirsher
2016-12-07 22:19 ` [net-next v2 10/19] i40e: Add FEC for 25g Jeff Kirsher
2016-12-07 22:19 ` [net-next v2 11/19] i40e: Add functions which apply correct PHY access method for read and write operation Jeff Kirsher
2016-12-07 22:19 ` [net-next v2 12/19] i40e: lock service task correctly Jeff Kirsher
2016-12-07 22:19 ` [net-next v2 13/19] i40e: defeature support for PTP L4 frame detection on XL710 Jeff Kirsher
2016-12-07 22:19 ` [net-next v2 14/19] i40e: recalculate vsi->active_filters from hash contents Jeff Kirsher
2016-12-07 22:19 ` [net-next v2 15/19] i40e: refactor i40e_update_filter_state to avoid passing aq_err Jeff Kirsher
2016-12-07 22:19 ` [net-next v2 16/19] i40e: delete filter after adding its replacement when converting Jeff Kirsher
2016-12-07 22:19 ` [net-next v2 17/19] i40e: factor out addition/deletion of VLAN per each MAC address Jeff Kirsher
2016-12-07 22:19 ` [net-next v2 18/19] i40e: use (add|rm)_vlan_all_mac helper functions when changing PVID Jeff Kirsher
2016-12-07 22:19 ` [net-next v2 19/19] i40e: move all updates for VLAN mode into i40e_sync_vsi_filters Jeff Kirsher
2016-12-08  0:15 ` [net-next v2 00/19][pull request] 40GbE Intel Wired LAN Driver Updates 2016-12-07 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=20161207221918.57932-6-jeffrey.t.kirsher@intel.com \
    --to=jeffrey.t.kirsher@intel.com \
    --cc=davem@davemloft.net \
    --cc=guru.anbalagane@oracle.com \
    --cc=jacob.e.keller@intel.com \
    --cc=jogreene@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=nhorman@redhat.com \
    --cc=sassmann@redhat.com \
    /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