From patchwork Wed Apr 1 21:36:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Guedes X-Patchwork-Id: 1265354 X-Patchwork-Delegate: jeffrey.t.kirsher@intel.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.136; helo=silver.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=intel.com Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48t00C6TZqz9sP7 for ; Thu, 2 Apr 2020 08:37:13 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 73A5F25CA8; Wed, 1 Apr 2020 21:37:11 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id p8S4vZPz7q7M; Wed, 1 Apr 2020 21:37:09 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 485D52549C; Wed, 1 Apr 2020 21:37:09 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 22A641BF47E for ; Wed, 1 Apr 2020 21:37:08 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 1CC1E25AB8 for ; Wed, 1 Apr 2020 21:37:08 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YzXUiNirv56d for ; Wed, 1 Apr 2020 21:37:06 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by silver.osuosl.org (Postfix) with ESMTPS id CDCDF20511 for ; Wed, 1 Apr 2020 21:37:06 +0000 (UTC) IronPort-SDR: c0iRa2olkQkoiuw9/dKlRp+zX/an0tdAJCpa8E6SHnuWjNdMD+ONMwzqmG11aZjzWB0vB7plNw JLjXa244i9vA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Apr 2020 14:37:06 -0700 IronPort-SDR: HBwXwOQQhkeccwi8fQJowYeDaIxHD4D2NLSFq55RNskL0O14+g9lB8RNHT8vZZnJ/YBEAEvWcD Obl3rrx8G8gg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,333,1580803200"; d="scan'208";a="450710960" Received: from khsantac-mobl1.amr.corp.intel.com ([10.251.8.15]) by fmsmga006.fm.intel.com with ESMTP; 01 Apr 2020 14:37:05 -0700 From: Andre Guedes To: intel-wired-lan@lists.osuosl.org Date: Wed, 1 Apr 2020 14:36:45 -0700 Message-Id: <20200401213645.2566-1-andre.guedes@intel.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200318230102.36952-6-andre.guedes@intel.com> References: <20200318230102.36952-6-andre.guedes@intel.com> MIME-Version: 1.0 Subject: [Intel-wired-lan] [PATCH v2 05/12] igc: Refactor igc_rar_set_index() X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" Current igc_rar_set_index() implementation is a bit convoluted so this patch does some code refactoring to improve it. The helper igc_rar_set_index() is about writing MAC filter settings into hardware registers. Logic such as address validation belongs to functions upper in the call chain such as igc_set_mac() and igc_add_mac_filter(). So this patch moves the is_valid_ether_addr() call to igc_add_mac_filter(). No need to touch igc_set_mac() since it already checks it. The variables 'rar_low' and 'rar_high' represent the value in registers RAL and RAH so we rename them to 'ral' and 'rah', respectivelly, to match the registers names. To make it explicity, filter settings are passed as arguments to the function instead of reading them from adapter->mac_table "under the hood". Also, the function was renamed to igc_set_mac_filter_hw to make it more clear what it does. Finally, the patch removes some wrfl() calls and comments not needed. Signed-off-by: Andre Guedes Tested-by: Aaron Brown --- v2: Fix function documentation to follow kernel-doc style. --- drivers/net/ethernet/intel/igc/igc_main.c | 73 +++++++++++++---------- 1 file changed, 42 insertions(+), 31 deletions(-) diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c index cc1e1b0286b3..c94e4e31e04b 100644 --- a/drivers/net/ethernet/intel/igc/igc_main.c +++ b/drivers/net/ethernet/intel/igc/igc_main.c @@ -765,42 +765,52 @@ static void igc_setup_tctl(struct igc_adapter *adapter) } /** - * igc_rar_set_index - Sync RAL[index] and RAH[index] registers with MAC table - * @adapter: address of board private structure - * @index: Index of the RAR entry which need to be synced with MAC table + * igc_set_mac_filter_hw() - Set MAC address filter in hardware. + * @adapter: Pointer to adapter where the filter should be set. + * @index: Filter index. + * @addr: Destination 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. */ -static void igc_rar_set_index(struct igc_adapter *adapter, u32 index) +static void igc_set_mac_filter_hw(struct igc_adapter *adapter, int index, + const u8 *addr, int queue) { - u8 *addr = adapter->mac_table[index].addr; struct igc_hw *hw = &adapter->hw; - u32 rar_low, rar_high; + u32 ral, rah; - /* HW expects these to be in network order when they are plugged - * into the registers which are little endian. In order to guarantee - * that ordering we need to do an leXX_to_cpup here in order to be - * ready for the byteswap that occurs with writel - */ - rar_low = le32_to_cpup((__le32 *)(addr)); - rar_high = le16_to_cpup((__le16 *)(addr + 4)); + if (WARN_ON(index >= hw->mac.rar_entry_count)) + return; - if (adapter->mac_table[index].state & IGC_MAC_STATE_QUEUE_STEERING) { - u8 queue = adapter->mac_table[index].queue; - u32 qsel = IGC_RAH_QSEL_MASK & (queue << IGC_RAH_QSEL_SHIFT); + ral = le32_to_cpup((__le32 *)(addr)); + rah = le16_to_cpup((__le16 *)(addr + 4)); - rar_high |= qsel; - rar_high |= IGC_RAH_QSEL_ENABLE; + if (queue >= 0) { + rah &= ~IGC_RAH_QSEL_MASK; + rah |= (queue << IGC_RAH_QSEL_SHIFT); + rah |= IGC_RAH_QSEL_ENABLE; } - /* Indicate to hardware the Address is Valid. */ - if (adapter->mac_table[index].state & IGC_MAC_STATE_IN_USE) { - if (is_valid_ether_addr(addr)) - rar_high |= IGC_RAH_AV; - } + rah |= IGC_RAH_AV; - wr32(IGC_RAL(index), rar_low); - wrfl(); - wr32(IGC_RAH(index), rar_high); - wrfl(); + wr32(IGC_RAL(index), ral); + wr32(IGC_RAH(index), rah); +} + +/** + * igc_clear_mac_filter_hw() - Clear MAC address filter in hardware. + * @adapter: Pointer to adapter where the filter should be cleared. + * @index: Filter index. + */ +static void igc_clear_mac_filter_hw(struct igc_adapter *adapter, int index) +{ + struct igc_hw *hw = &adapter->hw; + + if (WARN_ON(index >= hw->mac.rar_entry_count)) + return; + + wr32(IGC_RAL(index), 0); + wr32(IGC_RAH(index), 0); } /* Set default MAC address for the PF in the first RAR entry */ @@ -811,7 +821,7 @@ 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; - igc_rar_set_index(adapter, 0); + igc_set_mac_filter_hw(adapter, 0, mac_table->addr, -1); } /** @@ -2199,7 +2209,7 @@ static int igc_add_mac_filter(struct igc_adapter *adapter, const u8 *addr, int rar_entries = hw->mac.rar_entry_count; int i; - if (is_zero_ether_addr(addr)) + if (!is_valid_ether_addr(addr)) return -EINVAL; if (flags & IGC_MAC_STATE_SRC_ADDR) return -ENOTSUPP; @@ -2217,7 +2227,7 @@ static int igc_add_mac_filter(struct igc_adapter *adapter, const u8 *addr, adapter->mac_table[i].queue = queue; adapter->mac_table[i].state |= IGC_MAC_STATE_IN_USE | flags; - igc_rar_set_index(adapter, i); + igc_set_mac_filter_hw(adapter, i, addr, queue); return 0; } @@ -2261,13 +2271,14 @@ static int igc_del_mac_filter(struct igc_adapter *adapter, const u8 *addr, adapter->mac_table[i].state = IGC_MAC_STATE_DEFAULT | IGC_MAC_STATE_IN_USE; adapter->mac_table[i].queue = 0; + igc_set_mac_filter_hw(adapter, 0, addr, -1); } else { adapter->mac_table[i].state = 0; adapter->mac_table[i].queue = 0; memset(adapter->mac_table[i].addr, 0, ETH_ALEN); + igc_clear_mac_filter_hw(adapter, i); } - igc_rar_set_index(adapter, i); return 0; } From patchwork Wed Apr 1 21:41:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Guedes X-Patchwork-Id: 1265361 X-Patchwork-Delegate: jeffrey.t.kirsher@intel.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.136; helo=silver.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=intel.com Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48t06F6R0Kz9sPF for ; Thu, 2 Apr 2020 08:42:29 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 04EDC2549C; Wed, 1 Apr 2020 21:42:28 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9AH7xNnjE1q3; Wed, 1 Apr 2020 21:42:25 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id A862620511; Wed, 1 Apr 2020 21:42:25 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 5C6E91BF47E for ; Wed, 1 Apr 2020 21:42:24 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 582BF87927 for ; Wed, 1 Apr 2020 21:42:24 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id EbToBJe4aCZR for ; Wed, 1 Apr 2020 21:42:23 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by whitealder.osuosl.org (Postfix) with ESMTPS id 638A387658 for ; Wed, 1 Apr 2020 21:42:23 +0000 (UTC) IronPort-SDR: YrY2JLjlEnR8GOayuVV48k9hft9uQ3mPbpHyPGEomlDy6Yosy2fFlc6KdPdRHBrNFwBUekvT0z MfJaBKuayvZA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Apr 2020 14:42:22 -0700 IronPort-SDR: wFNoXNT5y8xKrtnJ7dgYpxLrvHY5oNHR8bbgoyX1SD3pZrQ6Fsgb54ehOpuYgrp1nOrFIptJjA spRB3wkU8W4g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,333,1580803200"; d="scan'208";a="359985261" Received: from khsantac-mobl1.amr.corp.intel.com ([10.251.8.15]) by fmsmga001.fm.intel.com with ESMTP; 01 Apr 2020 14:42:21 -0700 From: Andre Guedes To: intel-wired-lan@lists.osuosl.org Date: Wed, 1 Apr 2020 14:41:43 -0700 Message-Id: <20200401214142.2779-1-andre.guedes@intel.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200318230102.36952-8-andre.guedes@intel.com> References: <20200318230102.36952-8-andre.guedes@intel.com> MIME-Version: 1.0 Subject: [Intel-wired-lan] [PATCH v2 07/12] igc: Remove 'queue' check in igc_del_mac_filter() X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" igc_add_mac_filter() doesn't allow us to have more than one entry with the same address and address type in adapter->mac_table so checking if 'queue' matches in igc_del_mac_filter() isn't necessary. This patch removes that check. This patch also takes the opportunity to improve the igc_del_mac_filter documentation and remove comment which is not applicable to this I225 controller. Signed-off-by: Andre Guedes Tested-by: Aaron Brown --- v2: Fix function documentation to follow kernel-doc style. --- drivers/net/ethernet/intel/igc/igc_main.c | 25 ++++++++++------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c index 37c8980a43a0..961a7c642e44 100644 --- a/drivers/net/ethernet/intel/igc/igc_main.c +++ b/drivers/net/ethernet/intel/igc/igc_main.c @@ -2234,14 +2234,17 @@ static int igc_add_mac_filter(struct igc_adapter *adapter, const u8 *addr, return -ENOSPC; } -/* Remove a MAC filter for 'addr' directing matching traffic to - * 'queue', 'flags' is used to indicate what kind of match need to be - * removed, match is by default for the destination address, if - * matching by source address is to be removed the flag - * IGC_MAC_STATE_SRC_ADDR can be used. +/** + * igc_del_mac_filter() - Delete MAC address filter. + * @adapter: Pointer to adapter where the filter should be deleted from. + * @addr: MAC address. + * @flags: Set IGC_MAC_STATE_SRC_ADDR bit to indicate @address is a source + * address. + * + * Return: 0 in case of success, negative errno code otherwise. */ static int igc_del_mac_filter(struct igc_adapter *adapter, const u8 *addr, - const u8 queue, const u8 flags) + const u8 flags) { struct igc_hw *hw = &adapter->hw; int rar_entries = hw->mac.rar_entry_count; @@ -2250,17 +2253,11 @@ static int igc_del_mac_filter(struct igc_adapter *adapter, const u8 *addr, if (!is_valid_ether_addr(addr)) return -EINVAL; - /* Search for matching entry in the MAC table based on given address - * and queue. Do not touch entries at the end of the table reserved - * for the VF MAC addresses. - */ for (i = 0; i < rar_entries; i++) { if (!(adapter->mac_table[i].state & IGC_MAC_STATE_IN_USE)) continue; if (flags && (adapter->mac_table[i].state & flags) != flags) continue; - if (adapter->mac_table[i].queue != queue) - continue; if (!ether_addr_equal(adapter->mac_table[i].addr, addr)) continue; @@ -2296,7 +2293,7 @@ static int igc_uc_unsync(struct net_device *netdev, const unsigned char *addr) { struct igc_adapter *adapter = netdev_priv(netdev); - return igc_del_mac_filter(adapter, addr, adapter->num_rx_queues, 0); + return igc_del_mac_filter(adapter, addr, 0); } /** @@ -3741,7 +3738,7 @@ int igc_add_mac_steering_filter(struct igc_adapter *adapter, int igc_del_mac_steering_filter(struct igc_adapter *adapter, const u8 *addr, u8 queue, u8 flags) { - return igc_del_mac_filter(adapter, addr, queue, + return igc_del_mac_filter(adapter, addr, IGC_MAC_STATE_QUEUE_STEERING | flags); } From patchwork Wed Apr 1 21:43:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Guedes X-Patchwork-Id: 1265363 X-Patchwork-Delegate: jeffrey.t.kirsher@intel.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.136; helo=silver.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=intel.com Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48t0932976z9sPF for ; Thu, 2 Apr 2020 08:44:55 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 77AEC25AB8; Wed, 1 Apr 2020 21:44:53 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cqf8HEzzViBp; Wed, 1 Apr 2020 21:44:50 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 73DB420517; Wed, 1 Apr 2020 21:44:50 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id B81BD1BF47E for ; Wed, 1 Apr 2020 21:44:48 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id B380D888FB for ; Wed, 1 Apr 2020 21:44:48 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id E22qWFx6jxlP for ; Wed, 1 Apr 2020 21:44:47 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by hemlock.osuosl.org (Postfix) with ESMTPS id D094387EA6 for ; Wed, 1 Apr 2020 21:44:47 +0000 (UTC) IronPort-SDR: mAzj0T0Vk+k05JT9i2QxTFhDXJKvzcHZuBDwcxzqnTzmPawxTLdRPMpSVxuReoyhG1vTzyZJeI opwBXoXLqQVA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Apr 2020 14:44:42 -0700 IronPort-SDR: 4V7l2JfwCuAGtTenL8YBYFeWLqzfTj/fYYPshI91S3U8GqP49nKifp3+0ow9Jo2wU04ekSHPAX SCgOGt+sNmsA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,333,1580803200"; d="scan'208";a="359985721" Received: from khsantac-mobl1.amr.corp.intel.com ([10.251.8.15]) by fmsmga001.fm.intel.com with ESMTP; 01 Apr 2020 14:44:42 -0700 From: Andre Guedes To: intel-wired-lan@lists.osuosl.org Date: Wed, 1 Apr 2020 14:43:58 -0700 Message-Id: <20200401214358.2838-1-andre.guedes@intel.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200318230102.36952-9-andre.guedes@intel.com> References: <20200318230102.36952-9-andre.guedes@intel.com> MIME-Version: 1.0 Subject: [Intel-wired-lan] [PATCH v2 08/12] igc: Remove IGC_MAC_STATE_QUEUE_STEERING X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" 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 Tested-by: Aaron Brown --- v2: Fix function documentation to follow kernel-doc style. --- drivers/net/ethernet/intel/igc/igc.h | 3 +-- drivers/net/ethernet/intel/igc/igc_main.c | 32 ++++++++++++++--------- 2 files changed, 20 insertions(+), 15 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 961a7c642e44..332ad5841a9f 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. +/** + * igc_add_mac_filter() - Add MAC address filter. + * @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. + * + * Return: 0 in case of success, negative errno code otherwise. */ 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)