Intel-Wired-Lan Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Andre Guedes <andre.guedes@intel.com>
To: intel-wired-lan@osuosl.org
Subject: [Intel-wired-lan] [PATCH 08/12] igc: Remove IGC_MAC_STATE_QUEUE_STEERING
Date: Wed, 18 Mar 2020 16:00:58 -0700	[thread overview]
Message-ID: <20200318230102.36952-9-andre.guedes@intel.com> (raw)
In-Reply-To: <20200318230102.36952-1-andre.guedes@intel.com>

The IGC_MAC_STATE_QUEUE_STEERING bit in mac_table[i].state is
utilized to indicate that frames matching the filter are assigned to
mac_table[i].queue. This bit is not strictly necessary since we can
convey the same information as follows: queue == -1 means queue
assignment is disabled, otherwise it is enabled.

In addition to make the code simpler, this change fixes some awkward
situations where we pass a complete misleading 'queue' value such as in
igc_uc_sync().

So this patch removes IGC_MAC_STATE_QUEUE_STEERING and also takes the
opportunity to improve the igc_add_mac_filter documentation.

Signed-off-by: Andre Guedes <andre.guedes@intel.com>
---
 drivers/net/ethernet/intel/igc/igc.h      |  3 +-
 drivers/net/ethernet/intel/igc/igc_main.c | 34 +++++++++++++----------
 2 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/drivers/net/ethernet/intel/igc/igc.h b/drivers/net/ethernet/intel/igc/igc.h
index e743f92a27c6..192cef07bdf7 100644
--- a/drivers/net/ethernet/intel/igc/igc.h
+++ b/drivers/net/ethernet/intel/igc/igc.h
@@ -470,14 +470,13 @@ struct igc_nfc_filter {
 
 struct igc_mac_addr {
 	u8 addr[ETH_ALEN];
-	u8 queue;
+	s8 queue;
 	u8 state; /* bitmask */
 };
 
 #define IGC_MAC_STATE_DEFAULT		0x1
 #define IGC_MAC_STATE_IN_USE		0x2
 #define IGC_MAC_STATE_SRC_ADDR		0x4
-#define IGC_MAC_STATE_QUEUE_STEERING	0x8
 
 #define IGC_MAX_RXNFC_FILTERS		16
 
diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c
index 8a3cae2367d4..273817252823 100644
--- a/drivers/net/ethernet/intel/igc/igc_main.c
+++ b/drivers/net/ethernet/intel/igc/igc_main.c
@@ -820,8 +820,9 @@ static void igc_set_default_mac_filter(struct igc_adapter *adapter)
 
 	ether_addr_copy(mac_table->addr, adapter->hw.mac.addr);
 	mac_table->state = IGC_MAC_STATE_DEFAULT | IGC_MAC_STATE_IN_USE;
+	mac_table->queue = -1;
 
-	igc_set_mac_filter_hw(adapter, 0, mac_table->addr, -1);
+	igc_set_mac_filter_hw(adapter, 0, mac_table->addr, mac_table->queue);
 }
 
 /**
@@ -2197,13 +2198,20 @@ static bool igc_mac_entry_can_be_used(const struct igc_mac_addr *entry,
 	return true;
 }
 
-/* Add a MAC filter for 'addr' directing matching traffic to 'queue',
- * 'flags' is used to indicate what kind of match is made, match is by
- * default for the destination address, if matching by source address
- * is desired the flag IGC_MAC_STATE_SRC_ADDR can be used.
- */
+/* Add MAC address filter to adapter.
+ *
+ * @adapter: Pointer to adapter where the filter should be added.
+ * @addr: MAC address.
+ * @queue: If non-negative, queue assignment feature is enabled and frames
+ * matching the filter are enqueued onto 'queue'. Otherwise, queue assignment
+ * is disabled.
+ * @flags: Set IGC_MAC_STATE_SRC_ADDR bit to indicate @address is a source
+ * address.
+ *
+ * In case of success, returns 0. Otherwise, it returns a negative errno code.
+  */
 static int igc_add_mac_filter(struct igc_adapter *adapter, const u8 *addr,
-			      const u8 queue, const u8 flags)
+			      const s8 queue, const u8 flags)
 {
 	struct igc_hw *hw = &adapter->hw;
 	int rar_entries = hw->mac.rar_entry_count;
@@ -2267,11 +2275,11 @@ static int igc_del_mac_filter(struct igc_adapter *adapter, const u8 *addr,
 		if (adapter->mac_table[i].state & IGC_MAC_STATE_DEFAULT) {
 			adapter->mac_table[i].state =
 				IGC_MAC_STATE_DEFAULT | IGC_MAC_STATE_IN_USE;
-			adapter->mac_table[i].queue = 0;
+			adapter->mac_table[i].queue = -1;
 			igc_set_mac_filter_hw(adapter, 0, addr, -1);
 		} else {
 			adapter->mac_table[i].state = 0;
-			adapter->mac_table[i].queue = 0;
+			adapter->mac_table[i].queue = -1;
 			memset(adapter->mac_table[i].addr, 0, ETH_ALEN);
 			igc_clear_mac_filter_hw(adapter, i);
 		}
@@ -2286,7 +2294,7 @@ static int igc_uc_sync(struct net_device *netdev, const unsigned char *addr)
 {
 	struct igc_adapter *adapter = netdev_priv(netdev);
 
-	return igc_add_mac_filter(adapter, addr, adapter->num_rx_queues, 0);
+	return igc_add_mac_filter(adapter, addr, -1, 0);
 }
 
 static int igc_uc_unsync(struct net_device *netdev, const unsigned char *addr)
@@ -3731,15 +3739,13 @@ igc_features_check(struct sk_buff *skb, struct net_device *dev,
 int igc_add_mac_steering_filter(struct igc_adapter *adapter,
 				const u8 *addr, u8 queue, u8 flags)
 {
-	return igc_add_mac_filter(adapter, addr, queue,
-				  IGC_MAC_STATE_QUEUE_STEERING | flags);
+	return igc_add_mac_filter(adapter, addr, queue, flags);
 }
 
 int igc_del_mac_steering_filter(struct igc_adapter *adapter,
 				const u8 *addr, u8 queue, u8 flags)
 {
-	return igc_del_mac_filter(adapter, addr,
-				  IGC_MAC_STATE_QUEUE_STEERING | flags);
+	return igc_del_mac_filter(adapter, addr, flags);
 }
 
 static void igc_tsync_interrupt(struct igc_adapter *adapter)
-- 
2.25.0


  parent reply	other threads:[~2020-03-18 23:00 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-18 23:00 [Intel-wired-lan] [PATCH 00/12] igc: Refactor MAC address filtering code Andre Guedes
2020-03-18 23:00 ` [Intel-wired-lan] [PATCH 01/12] igc: Remove duplicate code in MAC filtering logic Andre Guedes
2020-03-31 19:58   ` Brown, Aaron F
2020-03-18 23:00 ` [Intel-wired-lan] [PATCH 02/12] igc: Check unsupported flag in igc_add_mac_filter() Andre Guedes
2020-03-31 19:58   ` Brown, Aaron F
2020-03-31 20:59     ` Brown, Aaron F
2020-03-18 23:00 ` [Intel-wired-lan] [PATCH 03/12] igc: Change igc_add_mac_filter() returning value Andre Guedes
2020-03-31 19:59   ` Brown, Aaron F
2020-03-18 23:00 ` [Intel-wired-lan] [PATCH 04/12] igc: Fix igc_uc_unsync() Andre Guedes
2020-03-31 19:59   ` Brown, Aaron F
2020-03-18 23:00 ` [Intel-wired-lan] [PATCH 05/12] igc: Refactor igc_rar_set_index() Andre Guedes
2020-03-31 11:22   ` Neftin, Sasha
2020-03-31 21:12     ` Andre Guedes
2020-04-01 21:51       ` Andre Guedes
2020-03-31 20:00   ` Brown, Aaron F
2020-04-01 21:36   ` [Intel-wired-lan] [PATCH v2 " Andre Guedes
2020-03-18 23:00 ` [Intel-wired-lan] [PATCH 06/12] igc: Improve address check in igc_del_mac_filter() Andre Guedes
2020-03-31 20:01   ` Brown, Aaron F
2020-03-18 23:00 ` [Intel-wired-lan] [PATCH 07/12] igc: Remove 'queue' " Andre Guedes
2020-03-31 15:53   ` Neftin, Sasha
2020-03-31 20:48     ` Brown, Aaron F
2020-03-31 20:50       ` Kirsher, Jeffrey T
2020-04-01 21:41   ` [Intel-wired-lan] [PATCH v2 " Andre Guedes
2020-03-18 23:00 ` Andre Guedes [this message]
2020-03-31 20:55   ` [Intel-wired-lan] [PATCH 08/12] igc: Remove IGC_MAC_STATE_QUEUE_STEERING Brown, Aaron F
2020-04-01  5:44   ` Neftin, Sasha
2020-04-01 21:43   ` [Intel-wired-lan] [PATCH v2 " Andre Guedes
2020-03-18 23:00 ` [Intel-wired-lan] [PATCH 09/12] igc: Remove igc_*_mac_steering_filter() wrappers Andre Guedes
2020-03-31 20:56   ` Brown, Aaron F
2020-03-18 23:01 ` [Intel-wired-lan] [PATCH 10/12] igc: Refactor igc_mac_entry_can_be_used() Andre Guedes
2020-03-31 20:56   ` Brown, Aaron F
2020-03-18 23:01 ` [Intel-wired-lan] [PATCH 11/12] igc: Refactor igc_del_mac_filter() Andre Guedes
2020-03-31 20:57   ` Brown, Aaron F
2020-03-18 23:01 ` [Intel-wired-lan] [PATCH 12/12] igc: Add debug messages to MAC filter code Andre Guedes
2020-03-31 20:57   ` Brown, Aaron F

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=20200318230102.36952-9-andre.guedes@intel.com \
    --to=andre.guedes@intel.com \
    --cc=intel-wired-lan@osuosl.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