From patchwork Fri Apr 24 20:16:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Guedes X-Patchwork-Id: 1276661 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.133; helo=hemlock.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 hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49857c3PFGz9sSG for ; Sat, 25 Apr 2020 06:17:29 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id C1B12886DC; Fri, 24 Apr 2020 20:17:27 +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 8XFRCU35gBYQ; Fri, 24 Apr 2020 20:17:27 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id 409028817D; Fri, 24 Apr 2020 20:17:27 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 2C7E51BF83C for ; Fri, 24 Apr 2020 20:17:26 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 26EDA86BF7 for ; Fri, 24 Apr 2020 20:17:26 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id iRl2fan9Bn9H for ; Fri, 24 Apr 2020 20:17:25 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 81144868BC for ; Fri, 24 Apr 2020 20:17:25 +0000 (UTC) IronPort-SDR: WvDUA4feNpNHLALkVp9vc2qqV1xUlwgDSQ3B1Bz6gJ7foRq3lL3gsPo0dFUHV0eMEK5321imiP AVVd7o2hMtEA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2020 13:17:24 -0700 IronPort-SDR: wxKfjWOnDur/HFOk8Y8l6xgPN9k8nykTLGKpArnbU4ftFH21jSph5M++D8J4FMhggnjWwq2ocA EVzDar2hwD5g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,313,1583222400"; d="scan'208";a="335474497" Received: from kleandre-mobl.amr.corp.intel.com ([10.213.164.39]) by orsmga001.jf.intel.com with ESMTP; 24 Apr 2020 13:17:24 -0700 From: Andre Guedes To: intel-wired-lan@lists.osuosl.org Date: Fri, 24 Apr 2020 13:16:05 -0700 Message-Id: <20200424201623.10971-2-andre.guedes@intel.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200424201623.10971-1-andre.guedes@intel.com> References: <20200424201623.10971-1-andre.guedes@intel.com> MIME-Version: 1.0 Subject: [Intel-wired-lan] [PATCH 01/19] igc: Remove unused field from igc_nfc_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" The 'cookie' field is not used anywhere in the code so this patch removes it from struct igc_nfc_filter. Signed-off-by: Andre Guedes Tested-by: Aaron Brown --- drivers/net/ethernet/intel/igc/igc.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/net/ethernet/intel/igc/igc.h b/drivers/net/ethernet/intel/igc/igc.h index b501be243536..7c92fc7703be 100644 --- a/drivers/net/ethernet/intel/igc/igc.h +++ b/drivers/net/ethernet/intel/igc/igc.h @@ -470,7 +470,6 @@ struct igc_nfc_input { struct igc_nfc_filter { struct hlist_node nfc_node; struct igc_nfc_input filter; - unsigned long cookie; u16 sw_idx; u16 action; }; From patchwork Fri Apr 24 20:16:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Guedes X-Patchwork-Id: 1276663 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.138; helo=whitealder.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 whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49857g2GmVz9sSG for ; Sat, 25 Apr 2020 06:17:35 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id DECCE87FE8; Fri, 24 Apr 2020 20:17:33 +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 AGxlB8F0Lcqg; Fri, 24 Apr 2020 20:17:31 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id 5D9D387FEF; Fri, 24 Apr 2020 20:17:31 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id DD8E01BF83C for ; Fri, 24 Apr 2020 20:17:26 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id DA8B086B89 for ; Fri, 24 Apr 2020 20:17:26 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id iCTqOLn7iurR for ; Fri, 24 Apr 2020 20:17:25 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by fraxinus.osuosl.org (Postfix) with ESMTPS id A1BCD868C9 for ; Fri, 24 Apr 2020 20:17:25 +0000 (UTC) IronPort-SDR: 6JWxpcLdySDRr//eYO2KiRYxbsp3vODPFB9XPTsYSHDB1eJ2Hepxj/5Bv4KJM2Nq6uSB5affZK ca6VibkwIKPQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2020 13:17:25 -0700 IronPort-SDR: J2s5o8nejo0DtFgq3RkPZtm75acgxRk5M9YVdbbWKeV6mFD5NuSpK9p8toiQJ8L/slG4X8cUo/ wuLaE5YsJ1Ig== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,313,1583222400"; d="scan'208";a="335474501" Received: from kleandre-mobl.amr.corp.intel.com ([10.213.164.39]) by orsmga001.jf.intel.com with ESMTP; 24 Apr 2020 13:17:24 -0700 From: Andre Guedes To: intel-wired-lan@lists.osuosl.org Date: Fri, 24 Apr 2020 13:16:06 -0700 Message-Id: <20200424201623.10971-3-andre.guedes@intel.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200424201623.10971-1-andre.guedes@intel.com> References: <20200424201623.10971-1-andre.guedes@intel.com> MIME-Version: 1.0 Subject: [Intel-wired-lan] [PATCH 02/19] igc: Get rid of igc_max_channels() 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 local function igc_max_channels() is a pointless wrapper around igc_get_max_rss_queues(). This patch removes it and updates the callers accordingly. It also does some cleanup on igc_get_max_rss_queues(). Signed-off-by: Andre Guedes Tested-by: Aaron Brown --- drivers/net/ethernet/intel/igc/igc_ethtool.c | 9 ++------- drivers/net/ethernet/intel/igc/igc_main.c | 7 +------ 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/intel/igc/igc_ethtool.c b/drivers/net/ethernet/intel/igc/igc_ethtool.c index 9023dc2a2446..ee2563ef24ac 100644 --- a/drivers/net/ethernet/intel/igc/igc_ethtool.c +++ b/drivers/net/ethernet/intel/igc/igc_ethtool.c @@ -1508,18 +1508,13 @@ static int igc_set_rxfh(struct net_device *netdev, const u32 *indir, return 0; } -static unsigned int igc_max_channels(struct igc_adapter *adapter) -{ - return igc_get_max_rss_queues(adapter); -} - static void igc_get_channels(struct net_device *netdev, struct ethtool_channels *ch) { struct igc_adapter *adapter = netdev_priv(netdev); /* Report maximum channels */ - ch->max_combined = igc_max_channels(adapter); + ch->max_combined = igc_get_max_rss_queues(adapter); /* Report info for other vector */ if (adapter->flags & IGC_FLAG_HAS_MSIX) { @@ -1546,7 +1541,7 @@ static int igc_set_channels(struct net_device *netdev, return -EINVAL; /* Verify the number of channels doesn't exceed hw limits */ - max_combined = igc_max_channels(adapter); + max_combined = igc_get_max_rss_queues(adapter); if (count > max_combined) return -EINVAL; diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c index 73140938ec2c..04f7f4112205 100644 --- a/drivers/net/ethernet/intel/igc/igc_main.c +++ b/drivers/net/ethernet/intel/igc/igc_main.c @@ -2732,12 +2732,7 @@ void igc_set_flag_queue_pairs(struct igc_adapter *adapter, unsigned int igc_get_max_rss_queues(struct igc_adapter *adapter) { - unsigned int max_rss_queues; - - /* Determine the maximum number of RSS queues supported. */ - max_rss_queues = IGC_MAX_RX_QUEUES; - - return max_rss_queues; + return IGC_MAX_RX_QUEUES; } static void igc_init_queue_configuration(struct igc_adapter *adapter) From patchwork Fri Apr 24 20:16:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Guedes X-Patchwork-Id: 1276660 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.138; helo=whitealder.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 whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49857c3V2Cz9sSJ for ; Sat, 25 Apr 2020 06:17:31 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 9157B87FD6; Fri, 24 Apr 2020 20:17:28 +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 tp-HH+NRGCzT; Fri, 24 Apr 2020 20:17:27 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id 9926B87847; Fri, 24 Apr 2020 20:17:27 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 4DD4F1BF9C2 for ; Fri, 24 Apr 2020 20:17:26 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 4AC17868BC for ; Fri, 24 Apr 2020 20:17:26 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Q0zMax_lpK7N for ; Fri, 24 Apr 2020 20:17:25 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by fraxinus.osuosl.org (Postfix) with ESMTPS id C59CC86B59 for ; Fri, 24 Apr 2020 20:17:25 +0000 (UTC) IronPort-SDR: WiCtfAgP8/BY2H/RZNFIHkD4plnjm/qhjpJl5Fb1H0qXak87R+l6D2BzT/jg1xAesLfvvUUnNe vQuejrHcVBfw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2020 13:17:25 -0700 IronPort-SDR: ivaEIbqkFpE9S+7GVndo4I/GRzp8CXUgT1/4M0VpPR676mlvOPSdrX71PYtS2DgUObntqyjEW5 WSYz+N3WWByA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,313,1583222400"; d="scan'208";a="335474503" Received: from kleandre-mobl.amr.corp.intel.com ([10.213.164.39]) by orsmga001.jf.intel.com with ESMTP; 24 Apr 2020 13:17:25 -0700 From: Andre Guedes To: intel-wired-lan@lists.osuosl.org Date: Fri, 24 Apr 2020 13:16:07 -0700 Message-Id: <20200424201623.10971-4-andre.guedes@intel.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200424201623.10971-1-andre.guedes@intel.com> References: <20200424201623.10971-1-andre.guedes@intel.com> MIME-Version: 1.0 Subject: [Intel-wired-lan] [PATCH 03/19] igc: Cleanup _get|set_rxnfc ethtool ops 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" This patch does a trivial change in igc_ethtool_get_rxnfc() and igc_ethtool_set_rxnfc() to simplify their logic. Signed-off-by: Andre Guedes Tested-by: Aaron Brown --- drivers/net/ethernet/intel/igc/igc_ethtool.c | 33 ++++++-------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/drivers/net/ethernet/intel/igc/igc_ethtool.c b/drivers/net/ethernet/intel/igc/igc_ethtool.c index ee2563ef24ac..c67c3ead323f 100644 --- a/drivers/net/ethernet/intel/igc/igc_ethtool.c +++ b/drivers/net/ethernet/intel/igc/igc_ethtool.c @@ -1055,31 +1055,23 @@ static int igc_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd, u32 *rule_locs) { struct igc_adapter *adapter = netdev_priv(dev); - int ret = -EOPNOTSUPP; switch (cmd->cmd) { case ETHTOOL_GRXRINGS: cmd->data = adapter->num_rx_queues; - ret = 0; - break; + return 0; case ETHTOOL_GRXCLSRLCNT: cmd->rule_cnt = adapter->nfc_filter_count; - ret = 0; - break; + return 0; case ETHTOOL_GRXCLSRULE: - ret = igc_get_ethtool_nfc_entry(adapter, cmd); - break; + return igc_get_ethtool_nfc_entry(adapter, cmd); case ETHTOOL_GRXCLSRLALL: - ret = igc_get_ethtool_nfc_all(adapter, cmd, rule_locs); - break; + return igc_get_ethtool_nfc_all(adapter, cmd, rule_locs); case ETHTOOL_GRXFH: - ret = igc_get_rss_hash_opts(adapter, cmd); - break; + return igc_get_rss_hash_opts(adapter, cmd); default: - break; + return -EOPNOTSUPP; } - - return ret; } #define UDP_RSS_FLAGS (IGC_FLAG_RSS_FIELD_IPV4_UDP | \ @@ -1418,22 +1410,17 @@ static int igc_del_ethtool_nfc_entry(struct igc_adapter *adapter, static int igc_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd) { struct igc_adapter *adapter = netdev_priv(dev); - int ret = -EOPNOTSUPP; switch (cmd->cmd) { case ETHTOOL_SRXFH: - ret = igc_set_rss_hash_opt(adapter, cmd); - break; + return igc_set_rss_hash_opt(adapter, cmd); case ETHTOOL_SRXCLSRLINS: - ret = igc_add_ethtool_nfc_entry(adapter, cmd); - break; + return igc_add_ethtool_nfc_entry(adapter, cmd); case ETHTOOL_SRXCLSRLDEL: - ret = igc_del_ethtool_nfc_entry(adapter, cmd); + return igc_del_ethtool_nfc_entry(adapter, cmd); default: - break; + return -EOPNOTSUPP; } - - return ret; } void igc_write_rss_indir_tbl(struct igc_adapter *adapter) From patchwork Fri Apr 24 20:16:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Guedes X-Patchwork-Id: 1276659 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.138; helo=whitealder.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 whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49857c3qsgz9sSd for ; Sat, 25 Apr 2020 06:17:31 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 36A0788020; Fri, 24 Apr 2020 20:17:30 +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 bjbAPRTolfpe; Fri, 24 Apr 2020 20:17:28 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id F381D87FCD; Fri, 24 Apr 2020 20:17:27 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 69DCA1BF83C for ; Fri, 24 Apr 2020 20:17:26 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 66BBF86B59 for ; Fri, 24 Apr 2020 20:17:26 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id KkIF7bX243Bh for ; Fri, 24 Apr 2020 20:17:26 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by fraxinus.osuosl.org (Postfix) with ESMTPS id E5F1486B89 for ; Fri, 24 Apr 2020 20:17:25 +0000 (UTC) IronPort-SDR: zuNvlSoGGnvWeD7T7+l0N5CtYqWIMGuqW1RxCL8k4QShaPlLmW4bo1jCVgaIJqGQ04O8wRGUdf nZaPpOD0qsDw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2020 13:17:25 -0700 IronPort-SDR: CEuIPDecYFBHF1HtP0QSt6CtZlCn8jtLPwqun6Vhr6mGhdLPvqPV5ylBOeotMWOELfq890ca5L eIMmu79ztMKQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,313,1583222400"; d="scan'208";a="335474504" Received: from kleandre-mobl.amr.corp.intel.com ([10.213.164.39]) by orsmga001.jf.intel.com with ESMTP; 24 Apr 2020 13:17:25 -0700 From: Andre Guedes To: intel-wired-lan@lists.osuosl.org Date: Fri, 24 Apr 2020 13:16:08 -0700 Message-Id: <20200424201623.10971-5-andre.guedes@intel.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200424201623.10971-1-andre.guedes@intel.com> References: <20200424201623.10971-1-andre.guedes@intel.com> MIME-Version: 1.0 Subject: [Intel-wired-lan] [PATCH 04/19] igc: Early return in igc_get_ethtool_nfc_entry() 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" This patch re-writes the second half of igc_ethtool_get_nfc_entry() to follow the 'return early' pattern seen in other parts of the driver and removes some duplicate comments. Signed-off-by: Andre Guedes Tested-by: Aaron Brown --- drivers/net/ethernet/intel/igc/igc_ethtool.c | 58 ++++++++++---------- 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/drivers/net/ethernet/intel/igc/igc_ethtool.c b/drivers/net/ethernet/intel/igc/igc_ethtool.c index c67c3ead323f..45481b1c9ee3 100644 --- a/drivers/net/ethernet/intel/igc/igc_ethtool.c +++ b/drivers/net/ethernet/intel/igc/igc_ethtool.c @@ -945,38 +945,36 @@ static int igc_get_ethtool_nfc_entry(struct igc_adapter *adapter, if (!rule || fsp->location != rule->sw_idx) return -EINVAL; - if (rule->filter.match_flags) { - fsp->flow_type = ETHER_FLOW; - fsp->ring_cookie = rule->action; - if (rule->filter.match_flags & IGC_FILTER_FLAG_ETHER_TYPE) { - fsp->h_u.ether_spec.h_proto = rule->filter.etype; - fsp->m_u.ether_spec.h_proto = ETHER_TYPE_FULL_MASK; - } - if (rule->filter.match_flags & IGC_FILTER_FLAG_VLAN_TCI) { - fsp->flow_type |= FLOW_EXT; - fsp->h_ext.vlan_tci = rule->filter.vlan_tci; - fsp->m_ext.vlan_tci = htons(VLAN_PRIO_MASK); - } - if (rule->filter.match_flags & IGC_FILTER_FLAG_DST_MAC_ADDR) { - ether_addr_copy(fsp->h_u.ether_spec.h_dest, - rule->filter.dst_addr); - /* As we only support matching by the full - * mask, return the mask to userspace - */ - eth_broadcast_addr(fsp->m_u.ether_spec.h_dest); - } - if (rule->filter.match_flags & IGC_FILTER_FLAG_SRC_MAC_ADDR) { - ether_addr_copy(fsp->h_u.ether_spec.h_source, - rule->filter.src_addr); - /* As we only support matching by the full - * mask, return the mask to userspace - */ - eth_broadcast_addr(fsp->m_u.ether_spec.h_source); - } + if (!rule->filter.match_flags) + return -EINVAL; - return 0; + fsp->flow_type = ETHER_FLOW; + fsp->ring_cookie = rule->action; + + if (rule->filter.match_flags & IGC_FILTER_FLAG_ETHER_TYPE) { + fsp->h_u.ether_spec.h_proto = rule->filter.etype; + fsp->m_u.ether_spec.h_proto = ETHER_TYPE_FULL_MASK; } - return -EINVAL; + + if (rule->filter.match_flags & IGC_FILTER_FLAG_VLAN_TCI) { + fsp->flow_type |= FLOW_EXT; + fsp->h_ext.vlan_tci = rule->filter.vlan_tci; + fsp->m_ext.vlan_tci = htons(VLAN_PRIO_MASK); + } + + if (rule->filter.match_flags & IGC_FILTER_FLAG_DST_MAC_ADDR) { + ether_addr_copy(fsp->h_u.ether_spec.h_dest, + rule->filter.dst_addr); + eth_broadcast_addr(fsp->m_u.ether_spec.h_dest); + } + + if (rule->filter.match_flags & IGC_FILTER_FLAG_SRC_MAC_ADDR) { + ether_addr_copy(fsp->h_u.ether_spec.h_source, + rule->filter.src_addr); + eth_broadcast_addr(fsp->m_u.ether_spec.h_source); + } + + return 0; } static int igc_get_ethtool_nfc_all(struct igc_adapter *adapter, From patchwork Fri Apr 24 20:16:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Guedes X-Patchwork-Id: 1276675 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 49857t2rLyz9sSG for ; Sat, 25 Apr 2020 06:17:46 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id BA46A204C0; Fri, 24 Apr 2020 20:17:44 +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 XXsWpJoGlz+h; Fri, 24 Apr 2020 20:17:33 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 8327F204C3; Fri, 24 Apr 2020 20:17:32 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 9BCC41BF83C for ; Fri, 24 Apr 2020 20:17:27 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 989EA86B59 for ; Fri, 24 Apr 2020 20:17:27 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wePsgUU1SOMi for ; Fri, 24 Apr 2020 20:17:26 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 19FB986BA9 for ; Fri, 24 Apr 2020 20:17:26 +0000 (UTC) IronPort-SDR: dWaFFuj+DlygMhxUtcFtIcuGxHXm5Nv+EvtCBiiJjRYf7Bq2MBVcYWkhKuiYbxVbHmv/cFxkaT rXp8detPi2zg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2020 13:17:25 -0700 IronPort-SDR: q5g7EZVKKxYtYkTsD1kKe0jDWu7yGRbcIDHu7CyEqHcriE3+eMuGgnwa8w918wQkXbAbsOKJlg /PTVCPh+i1HA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,313,1583222400"; d="scan'208";a="335474505" Received: from kleandre-mobl.amr.corp.intel.com ([10.213.164.39]) by orsmga001.jf.intel.com with ESMTP; 24 Apr 2020 13:17:25 -0700 From: Andre Guedes To: intel-wired-lan@lists.osuosl.org Date: Fri, 24 Apr 2020 13:16:09 -0700 Message-Id: <20200424201623.10971-6-andre.guedes@intel.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200424201623.10971-1-andre.guedes@intel.com> References: <20200424201623.10971-1-andre.guedes@intel.com> MIME-Version: 1.0 Subject: [Intel-wired-lan] [PATCH 05/19] igc: Add 'igc_ethtool_' prefix to functions in igc_ethtool.c 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" This patch adds the prefix 'igc_ethtool_' to all functions defined in igc_ethtool.c so they align with the name convention already followed by other parts of the driver (e.g. igc_tsn, igc_ptp). Also, this avoids some name clashing with functions added to igc_main.c by upcoming patches in this series. No functionality is changed by this patch, just function renaming. Signed-off-by: Andre Guedes Tested-by: Aaron Brown --- drivers/net/ethernet/intel/igc/igc.h | 3 +- drivers/net/ethernet/intel/igc/igc_ethtool.c | 215 ++++++++++--------- drivers/net/ethernet/intel/igc/igc_main.c | 2 +- 3 files changed, 112 insertions(+), 108 deletions(-) diff --git a/drivers/net/ethernet/intel/igc/igc.h b/drivers/net/ethernet/intel/igc/igc.h index 7c92fc7703be..359ac40908f6 100644 --- a/drivers/net/ethernet/intel/igc/igc.h +++ b/drivers/net/ethernet/intel/igc/igc.h @@ -16,8 +16,7 @@ #include "igc_hw.h" -/* forward declaration */ -void igc_set_ethtool_ops(struct net_device *); +void igc_ethtool_set_ops(struct net_device *); /* Transmit and receive queues */ #define IGC_MAX_RX_QUEUES 4 diff --git a/drivers/net/ethernet/intel/igc/igc_ethtool.c b/drivers/net/ethernet/intel/igc/igc_ethtool.c index 45481b1c9ee3..4ee040607c0b 100644 --- a/drivers/net/ethernet/intel/igc/igc_ethtool.c +++ b/drivers/net/ethernet/intel/igc/igc_ethtool.c @@ -124,8 +124,8 @@ static const char igc_priv_flags_strings[][ETH_GSTRING_LEN] = { #define IGC_PRIV_FLAGS_STR_LEN ARRAY_SIZE(igc_priv_flags_strings) -static void igc_get_drvinfo(struct net_device *netdev, - struct ethtool_drvinfo *drvinfo) +static void igc_ethtool_get_drvinfo(struct net_device *netdev, + struct ethtool_drvinfo *drvinfo) { struct igc_adapter *adapter = netdev_priv(netdev); @@ -139,13 +139,13 @@ static void igc_get_drvinfo(struct net_device *netdev, drvinfo->n_priv_flags = IGC_PRIV_FLAGS_STR_LEN; } -static int igc_get_regs_len(struct net_device *netdev) +static int igc_ethtool_get_regs_len(struct net_device *netdev) { return IGC_REGS_LEN * sizeof(u32); } -static void igc_get_regs(struct net_device *netdev, - struct ethtool_regs *regs, void *p) +static void igc_ethtool_get_regs(struct net_device *netdev, + struct ethtool_regs *regs, void *p) { struct igc_adapter *adapter = netdev_priv(netdev); struct igc_hw *hw = &adapter->hw; @@ -323,7 +323,8 @@ static void igc_get_regs(struct net_device *netdev, regs_buff[205 + i] = rd32(IGC_ETQF(i)); } -static void igc_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) +static void igc_ethtool_get_wol(struct net_device *netdev, + struct ethtool_wolinfo *wol) { struct igc_adapter *adapter = netdev_priv(netdev); @@ -354,7 +355,8 @@ static void igc_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) wol->wolopts |= WAKE_PHY; } -static int igc_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) +static int igc_ethtool_set_wol(struct net_device *netdev, + struct ethtool_wolinfo *wol) { struct igc_adapter *adapter = netdev_priv(netdev); @@ -382,21 +384,21 @@ static int igc_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) return 0; } -static u32 igc_get_msglevel(struct net_device *netdev) +static u32 igc_ethtool_get_msglevel(struct net_device *netdev) { struct igc_adapter *adapter = netdev_priv(netdev); return adapter->msg_enable; } -static void igc_set_msglevel(struct net_device *netdev, u32 data) +static void igc_ethtool_set_msglevel(struct net_device *netdev, u32 data) { struct igc_adapter *adapter = netdev_priv(netdev); adapter->msg_enable = data; } -static int igc_nway_reset(struct net_device *netdev) +static int igc_ethtool_nway_reset(struct net_device *netdev) { struct igc_adapter *adapter = netdev_priv(netdev); @@ -405,7 +407,7 @@ static int igc_nway_reset(struct net_device *netdev) return 0; } -static u32 igc_get_link(struct net_device *netdev) +static u32 igc_ethtool_get_link(struct net_device *netdev) { struct igc_adapter *adapter = netdev_priv(netdev); struct igc_mac_info *mac = &adapter->hw.mac; @@ -422,15 +424,15 @@ static u32 igc_get_link(struct net_device *netdev) return igc_has_link(adapter); } -static int igc_get_eeprom_len(struct net_device *netdev) +static int igc_ethtool_get_eeprom_len(struct net_device *netdev) { struct igc_adapter *adapter = netdev_priv(netdev); return adapter->hw.nvm.word_size * 2; } -static int igc_get_eeprom(struct net_device *netdev, - struct ethtool_eeprom *eeprom, u8 *bytes) +static int igc_ethtool_get_eeprom(struct net_device *netdev, + struct ethtool_eeprom *eeprom, u8 *bytes) { struct igc_adapter *adapter = netdev_priv(netdev); struct igc_hw *hw = &adapter->hw; @@ -476,8 +478,8 @@ static int igc_get_eeprom(struct net_device *netdev, return ret_val; } -static int igc_set_eeprom(struct net_device *netdev, - struct ethtool_eeprom *eeprom, u8 *bytes) +static int igc_ethtool_set_eeprom(struct net_device *netdev, + struct ethtool_eeprom *eeprom, u8 *bytes) { struct igc_adapter *adapter = netdev_priv(netdev); struct igc_hw *hw = &adapter->hw; @@ -544,8 +546,8 @@ static int igc_set_eeprom(struct net_device *netdev, return ret_val; } -static void igc_get_ringparam(struct net_device *netdev, - struct ethtool_ringparam *ring) +static void igc_ethtool_get_ringparam(struct net_device *netdev, + struct ethtool_ringparam *ring) { struct igc_adapter *adapter = netdev_priv(netdev); @@ -555,8 +557,8 @@ static void igc_get_ringparam(struct net_device *netdev, ring->tx_pending = adapter->tx_ring_count; } -static int igc_set_ringparam(struct net_device *netdev, - struct ethtool_ringparam *ring) +static int igc_ethtool_set_ringparam(struct net_device *netdev, + struct ethtool_ringparam *ring) { struct igc_adapter *adapter = netdev_priv(netdev); struct igc_ring *temp_ring; @@ -670,8 +672,8 @@ static int igc_set_ringparam(struct net_device *netdev, return err; } -static void igc_get_pauseparam(struct net_device *netdev, - struct ethtool_pauseparam *pause) +static void igc_ethtool_get_pauseparam(struct net_device *netdev, + struct ethtool_pauseparam *pause) { struct igc_adapter *adapter = netdev_priv(netdev); struct igc_hw *hw = &adapter->hw; @@ -689,8 +691,8 @@ static void igc_get_pauseparam(struct net_device *netdev, } } -static int igc_set_pauseparam(struct net_device *netdev, - struct ethtool_pauseparam *pause) +static int igc_ethtool_set_pauseparam(struct net_device *netdev, + struct ethtool_pauseparam *pause) { struct igc_adapter *adapter = netdev_priv(netdev); struct igc_hw *hw = &adapter->hw; @@ -729,7 +731,8 @@ static int igc_set_pauseparam(struct net_device *netdev, return retval; } -static void igc_get_strings(struct net_device *netdev, u32 stringset, u8 *data) +static void igc_ethtool_get_strings(struct net_device *netdev, u32 stringset, + u8 *data) { struct igc_adapter *adapter = netdev_priv(netdev); u8 *p = data; @@ -780,7 +783,7 @@ static void igc_get_strings(struct net_device *netdev, u32 stringset, u8 *data) } } -static int igc_get_sset_count(struct net_device *netdev, int sset) +static int igc_ethtool_get_sset_count(struct net_device *netdev, int sset) { switch (sset) { case ETH_SS_STATS: @@ -794,7 +797,7 @@ static int igc_get_sset_count(struct net_device *netdev, int sset) } } -static void igc_get_ethtool_stats(struct net_device *netdev, +static void igc_ethtool_get_stats(struct net_device *netdev, struct ethtool_stats *stats, u64 *data) { struct igc_adapter *adapter = netdev_priv(netdev); @@ -850,8 +853,8 @@ static void igc_get_ethtool_stats(struct net_device *netdev, spin_unlock(&adapter->stats64_lock); } -static int igc_get_coalesce(struct net_device *netdev, - struct ethtool_coalesce *ec) +static int igc_ethtool_get_coalesce(struct net_device *netdev, + struct ethtool_coalesce *ec) { struct igc_adapter *adapter = netdev_priv(netdev); @@ -870,8 +873,8 @@ static int igc_get_coalesce(struct net_device *netdev, return 0; } -static int igc_set_coalesce(struct net_device *netdev, - struct ethtool_coalesce *ec) +static int igc_ethtool_set_coalesce(struct net_device *netdev, + struct ethtool_coalesce *ec) { struct igc_adapter *adapter = netdev_priv(netdev); int i; @@ -928,7 +931,7 @@ static int igc_set_coalesce(struct net_device *netdev, } #define ETHER_TYPE_FULL_MASK ((__force __be16)~0) -static int igc_get_ethtool_nfc_entry(struct igc_adapter *adapter, +static int igc_ethtool_get_nfc_entry(struct igc_adapter *adapter, struct ethtool_rxnfc *cmd) { struct ethtool_rx_flow_spec *fsp = &cmd->fs; @@ -977,7 +980,7 @@ static int igc_get_ethtool_nfc_entry(struct igc_adapter *adapter, return 0; } -static int igc_get_ethtool_nfc_all(struct igc_adapter *adapter, +static int igc_ethtool_get_nfc_all(struct igc_adapter *adapter, struct ethtool_rxnfc *cmd, u32 *rule_locs) { @@ -999,8 +1002,8 @@ static int igc_get_ethtool_nfc_all(struct igc_adapter *adapter, return 0; } -static int igc_get_rss_hash_opts(struct igc_adapter *adapter, - struct ethtool_rxnfc *cmd) +static int igc_ethtool_get_rss_hash_opts(struct igc_adapter *adapter, + struct ethtool_rxnfc *cmd) { cmd->data = 0; @@ -1049,8 +1052,8 @@ static int igc_get_rss_hash_opts(struct igc_adapter *adapter, return 0; } -static int igc_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd, - u32 *rule_locs) +static int igc_ethtool_get_rxnfc(struct net_device *dev, + struct ethtool_rxnfc *cmd, u32 *rule_locs) { struct igc_adapter *adapter = netdev_priv(dev); @@ -1062,11 +1065,11 @@ static int igc_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd, cmd->rule_cnt = adapter->nfc_filter_count; return 0; case ETHTOOL_GRXCLSRULE: - return igc_get_ethtool_nfc_entry(adapter, cmd); + return igc_ethtool_get_nfc_entry(adapter, cmd); case ETHTOOL_GRXCLSRLALL: - return igc_get_ethtool_nfc_all(adapter, cmd, rule_locs); + return igc_ethtool_get_nfc_all(adapter, cmd, rule_locs); case ETHTOOL_GRXFH: - return igc_get_rss_hash_opts(adapter, cmd); + return igc_ethtool_get_rss_hash_opts(adapter, cmd); default: return -EOPNOTSUPP; } @@ -1074,8 +1077,8 @@ static int igc_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd, #define UDP_RSS_FLAGS (IGC_FLAG_RSS_FIELD_IPV4_UDP | \ IGC_FLAG_RSS_FIELD_IPV6_UDP) -static int igc_set_rss_hash_opt(struct igc_adapter *adapter, - struct ethtool_rxnfc *nfc) +static int igc_ethtool_set_rss_hash_opt(struct igc_adapter *adapter, + struct ethtool_rxnfc *nfc) { u32 flags = adapter->flags; @@ -1240,7 +1243,7 @@ int igc_erase_filter(struct igc_adapter *adapter, struct igc_nfc_filter *input) return 0; } -static int igc_update_ethtool_nfc_entry(struct igc_adapter *adapter, +static int igc_ethtool_update_nfc_entry(struct igc_adapter *adapter, struct igc_nfc_filter *input, u16 sw_idx) { @@ -1288,7 +1291,7 @@ static int igc_update_ethtool_nfc_entry(struct igc_adapter *adapter, return 0; } -static int igc_add_ethtool_nfc_entry(struct igc_adapter *adapter, +static int igc_ethtool_add_nfc_entry(struct igc_adapter *adapter, struct ethtool_rxnfc *cmd) { struct net_device *netdev = adapter->netdev; @@ -1379,7 +1382,7 @@ static int igc_add_ethtool_nfc_entry(struct igc_adapter *adapter, if (err) goto err_out_w_lock; - igc_update_ethtool_nfc_entry(adapter, input, input->sw_idx); + igc_ethtool_update_nfc_entry(adapter, input, input->sw_idx); spin_unlock(&adapter->nfc_lock); return 0; @@ -1391,7 +1394,7 @@ static int igc_add_ethtool_nfc_entry(struct igc_adapter *adapter, return err; } -static int igc_del_ethtool_nfc_entry(struct igc_adapter *adapter, +static int igc_ethtool_del_nfc_entry(struct igc_adapter *adapter, struct ethtool_rxnfc *cmd) { struct ethtool_rx_flow_spec *fsp = @@ -1399,23 +1402,24 @@ static int igc_del_ethtool_nfc_entry(struct igc_adapter *adapter, int err; spin_lock(&adapter->nfc_lock); - err = igc_update_ethtool_nfc_entry(adapter, NULL, fsp->location); + err = igc_ethtool_update_nfc_entry(adapter, NULL, fsp->location); spin_unlock(&adapter->nfc_lock); return err; } -static int igc_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd) +static int igc_ethtool_set_rxnfc(struct net_device *dev, + struct ethtool_rxnfc *cmd) { struct igc_adapter *adapter = netdev_priv(dev); switch (cmd->cmd) { case ETHTOOL_SRXFH: - return igc_set_rss_hash_opt(adapter, cmd); + return igc_ethtool_set_rss_hash_opt(adapter, cmd); case ETHTOOL_SRXCLSRLINS: - return igc_add_ethtool_nfc_entry(adapter, cmd); + return igc_ethtool_add_nfc_entry(adapter, cmd); case ETHTOOL_SRXCLSRLDEL: - return igc_del_ethtool_nfc_entry(adapter, cmd); + return igc_ethtool_del_nfc_entry(adapter, cmd); default: return -EOPNOTSUPP; } @@ -1443,13 +1447,13 @@ void igc_write_rss_indir_tbl(struct igc_adapter *adapter) } } -static u32 igc_get_rxfh_indir_size(struct net_device *netdev) +static u32 igc_ethtool_get_rxfh_indir_size(struct net_device *netdev) { return IGC_RETA_SIZE; } -static int igc_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key, - u8 *hfunc) +static int igc_ethtool_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key, + u8 *hfunc) { struct igc_adapter *adapter = netdev_priv(netdev); int i; @@ -1464,8 +1468,8 @@ static int igc_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key, return 0; } -static int igc_set_rxfh(struct net_device *netdev, const u32 *indir, - const u8 *key, const u8 hfunc) +static int igc_ethtool_set_rxfh(struct net_device *netdev, const u32 *indir, + const u8 *key, const u8 hfunc) { struct igc_adapter *adapter = netdev_priv(netdev); u32 num_queues; @@ -1493,8 +1497,8 @@ static int igc_set_rxfh(struct net_device *netdev, const u32 *indir, return 0; } -static void igc_get_channels(struct net_device *netdev, - struct ethtool_channels *ch) +static void igc_ethtool_get_channels(struct net_device *netdev, + struct ethtool_channels *ch) { struct igc_adapter *adapter = netdev_priv(netdev); @@ -1510,8 +1514,8 @@ static void igc_get_channels(struct net_device *netdev, ch->combined_count = adapter->rss_queues; } -static int igc_set_channels(struct net_device *netdev, - struct ethtool_channels *ch) +static int igc_ethtool_set_channels(struct net_device *netdev, + struct ethtool_channels *ch) { struct igc_adapter *adapter = netdev_priv(netdev); unsigned int count = ch->combined_count; @@ -1543,8 +1547,8 @@ static int igc_set_channels(struct net_device *netdev, return 0; } -static int igc_get_ts_info(struct net_device *dev, - struct ethtool_ts_info *info) +static int igc_ethtool_get_ts_info(struct net_device *dev, + struct ethtool_ts_info *info) { struct igc_adapter *adapter = netdev_priv(dev); @@ -1576,7 +1580,7 @@ static int igc_get_ts_info(struct net_device *dev, } } -static u32 igc_get_priv_flags(struct net_device *netdev) +static u32 igc_ethtool_get_priv_flags(struct net_device *netdev) { struct igc_adapter *adapter = netdev_priv(netdev); u32 priv_flags = 0; @@ -1587,7 +1591,7 @@ static u32 igc_get_priv_flags(struct net_device *netdev) return priv_flags; } -static int igc_set_priv_flags(struct net_device *netdev, u32 priv_flags) +static int igc_ethtool_set_priv_flags(struct net_device *netdev, u32 priv_flags) { struct igc_adapter *adapter = netdev_priv(netdev); unsigned int flags = adapter->flags; @@ -1622,8 +1626,8 @@ static void igc_ethtool_complete(struct net_device *netdev) pm_runtime_put(&adapter->pdev->dev); } -static int igc_get_link_ksettings(struct net_device *netdev, - struct ethtool_link_ksettings *cmd) +static int igc_ethtool_get_link_ksettings(struct net_device *netdev, + struct ethtool_link_ksettings *cmd) { struct igc_adapter *adapter = netdev_priv(netdev); struct igc_hw *hw = &adapter->hw; @@ -1729,8 +1733,9 @@ static int igc_get_link_ksettings(struct net_device *netdev, return 0; } -static int igc_set_link_ksettings(struct net_device *netdev, - const struct ethtool_link_ksettings *cmd) +static int +igc_ethtool_set_link_ksettings(struct net_device *netdev, + const struct ethtool_link_ksettings *cmd) { struct igc_adapter *adapter = netdev_priv(netdev); struct net_device *dev = adapter->netdev; @@ -1796,8 +1801,8 @@ static int igc_set_link_ksettings(struct net_device *netdev, return 0; } -static void igc_diag_test(struct net_device *netdev, - struct ethtool_test *eth_test, u64 *data) +static void igc_ethtool_diag_test(struct net_device *netdev, + struct ethtool_test *eth_test, u64 *data) { struct igc_adapter *adapter = netdev_priv(netdev); bool if_running = netif_running(netdev); @@ -1859,45 +1864,45 @@ static void igc_diag_test(struct net_device *netdev, static const struct ethtool_ops igc_ethtool_ops = { .supported_coalesce_params = ETHTOOL_COALESCE_USECS, - .get_drvinfo = igc_get_drvinfo, - .get_regs_len = igc_get_regs_len, - .get_regs = igc_get_regs, - .get_wol = igc_get_wol, - .set_wol = igc_set_wol, - .get_msglevel = igc_get_msglevel, - .set_msglevel = igc_set_msglevel, - .nway_reset = igc_nway_reset, - .get_link = igc_get_link, - .get_eeprom_len = igc_get_eeprom_len, - .get_eeprom = igc_get_eeprom, - .set_eeprom = igc_set_eeprom, - .get_ringparam = igc_get_ringparam, - .set_ringparam = igc_set_ringparam, - .get_pauseparam = igc_get_pauseparam, - .set_pauseparam = igc_set_pauseparam, - .get_strings = igc_get_strings, - .get_sset_count = igc_get_sset_count, - .get_ethtool_stats = igc_get_ethtool_stats, - .get_coalesce = igc_get_coalesce, - .set_coalesce = igc_set_coalesce, - .get_rxnfc = igc_get_rxnfc, - .set_rxnfc = igc_set_rxnfc, - .get_rxfh_indir_size = igc_get_rxfh_indir_size, - .get_rxfh = igc_get_rxfh, - .set_rxfh = igc_set_rxfh, - .get_ts_info = igc_get_ts_info, - .get_channels = igc_get_channels, - .set_channels = igc_set_channels, - .get_priv_flags = igc_get_priv_flags, - .set_priv_flags = igc_set_priv_flags, + .get_drvinfo = igc_ethtool_get_drvinfo, + .get_regs_len = igc_ethtool_get_regs_len, + .get_regs = igc_ethtool_get_regs, + .get_wol = igc_ethtool_get_wol, + .set_wol = igc_ethtool_set_wol, + .get_msglevel = igc_ethtool_get_msglevel, + .set_msglevel = igc_ethtool_set_msglevel, + .nway_reset = igc_ethtool_nway_reset, + .get_link = igc_ethtool_get_link, + .get_eeprom_len = igc_ethtool_get_eeprom_len, + .get_eeprom = igc_ethtool_get_eeprom, + .set_eeprom = igc_ethtool_set_eeprom, + .get_ringparam = igc_ethtool_get_ringparam, + .set_ringparam = igc_ethtool_set_ringparam, + .get_pauseparam = igc_ethtool_get_pauseparam, + .set_pauseparam = igc_ethtool_set_pauseparam, + .get_strings = igc_ethtool_get_strings, + .get_sset_count = igc_ethtool_get_sset_count, + .get_ethtool_stats = igc_ethtool_get_stats, + .get_coalesce = igc_ethtool_get_coalesce, + .set_coalesce = igc_ethtool_set_coalesce, + .get_rxnfc = igc_ethtool_get_rxnfc, + .set_rxnfc = igc_ethtool_set_rxnfc, + .get_rxfh_indir_size = igc_ethtool_get_rxfh_indir_size, + .get_rxfh = igc_ethtool_get_rxfh, + .set_rxfh = igc_ethtool_set_rxfh, + .get_ts_info = igc_ethtool_get_ts_info, + .get_channels = igc_ethtool_get_channels, + .set_channels = igc_ethtool_set_channels, + .get_priv_flags = igc_ethtool_get_priv_flags, + .set_priv_flags = igc_ethtool_set_priv_flags, .begin = igc_ethtool_begin, .complete = igc_ethtool_complete, - .get_link_ksettings = igc_get_link_ksettings, - .set_link_ksettings = igc_set_link_ksettings, - .self_test = igc_diag_test, + .get_link_ksettings = igc_ethtool_get_link_ksettings, + .set_link_ksettings = igc_ethtool_set_link_ksettings, + .self_test = igc_ethtool_diag_test, }; -void igc_set_ethtool_ops(struct net_device *netdev) +void igc_ethtool_set_ops(struct net_device *netdev) { netdev->ethtool_ops = &igc_ethtool_ops; } diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c index 04f7f4112205..ecdc0548f24e 100644 --- a/drivers/net/ethernet/intel/igc/igc_main.c +++ b/drivers/net/ethernet/intel/igc/igc_main.c @@ -4935,7 +4935,7 @@ static int igc_probe(struct pci_dev *pdev, hw->hw_addr = adapter->io_addr; netdev->netdev_ops = &igc_netdev_ops; - igc_set_ethtool_ops(netdev); + igc_ethtool_set_ops(netdev); netdev->watchdog_timeo = 5 * HZ; netdev->mem_start = pci_resource_start(pdev, 0); From patchwork Fri Apr 24 20:16:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Guedes X-Patchwork-Id: 1276666 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.137; helo=fraxinus.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 fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49857j0Wtxz9sSG for ; Sat, 25 Apr 2020 06:17:37 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id A093386B59; Fri, 24 Apr 2020 20:17:35 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id IoEetx5iF0v1; Fri, 24 Apr 2020 20:17:33 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id 8020B86BA9; Fri, 24 Apr 2020 20:17:33 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 0A7F81BF9C2 for ; Fri, 24 Apr 2020 20:17:29 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 0750686BF7 for ; Fri, 24 Apr 2020 20:17:29 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id AXtAiAh4xzlL for ; Fri, 24 Apr 2020 20:17:26 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 5C9D4868BC for ; Fri, 24 Apr 2020 20:17:26 +0000 (UTC) IronPort-SDR: qJyKxzeb2CU5zCHr9L+wD1Kcg6Afy0uwFvZJF8/3nA/4ic8oJ1o/RDxxtzLiOoOCXxcBpQxVCb rJLG/aUVUbgg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2020 13:17:26 -0700 IronPort-SDR: pG+g8zMGKdGoOWNwJzVkkLW4yYtVSqP4KBsd5NBWVJK8riGWELM+GzmMYiEbVz3tMiZM/Ipdmn LVVFdvsxMyYw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,313,1583222400"; d="scan'208";a="335474506" Received: from kleandre-mobl.amr.corp.intel.com ([10.213.164.39]) by orsmga001.jf.intel.com with ESMTP; 24 Apr 2020 13:17:25 -0700 From: Andre Guedes To: intel-wired-lan@lists.osuosl.org Date: Fri, 24 Apr 2020 13:16:10 -0700 Message-Id: <20200424201623.10971-7-andre.guedes@intel.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200424201623.10971-1-andre.guedes@intel.com> References: <20200424201623.10971-1-andre.guedes@intel.com> MIME-Version: 1.0 Subject: [Intel-wired-lan] [PATCH 06/19] igc: Align terms used in NFC support code 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 Network Flow Classification (NFC) support code from IGC driver uses terms such as 'rule', 'filter', 'entry', 'input' interchangeably when referring to NFC rules, making it harder to follow the code. This patch renames IGC's internal APIs, structs, and variables so we stick with the term 'rule' since this is the term used in ethtool APIs. It also removes some not applicable comments along the way. No functionality is changed by this patch. Signed-off-by: Andre Guedes Tested-by: Aaron Brown --- drivers/net/ethernet/intel/igc/igc.h | 29 ++-- drivers/net/ethernet/intel/igc/igc_ethtool.c | 160 +++++++++---------- drivers/net/ethernet/intel/igc/igc_main.c | 42 ++--- 3 files changed, 114 insertions(+), 117 deletions(-) diff --git a/drivers/net/ethernet/intel/igc/igc.h b/drivers/net/ethernet/intel/igc/igc.h index 359ac40908f6..7124ba254b89 100644 --- a/drivers/net/ethernet/intel/igc/igc.h +++ b/drivers/net/ethernet/intel/igc/igc.h @@ -187,12 +187,12 @@ struct igc_adapter { u32 rss_queues; u32 rss_indir_tbl_init; - /* RX network flow classification support */ - struct hlist_head nfc_filter_list; - unsigned int nfc_filter_count; - - /* lock for RX network flow classification filter */ - spinlock_t nfc_lock; + /* Any access to elements in nfc_rule_list is protected by the + * nfc_rule_lock. + */ + spinlock_t nfc_rule_lock; + struct hlist_head nfc_rule_list; + unsigned int nfc_rule_count; u8 rss_indir_tbl[IGC_RETA_SIZE]; @@ -453,7 +453,7 @@ enum igc_filter_match_flags { }; /* RX network flow classification data structure */ -struct igc_nfc_input { +struct igc_nfc_filter { /* Byte layout in order, all values with MSB first: * match_flags - 1 byte * etype - 2 bytes @@ -466,14 +466,14 @@ struct igc_nfc_input { u8 dst_addr[ETH_ALEN]; }; -struct igc_nfc_filter { +struct igc_nfc_rule { struct hlist_node nfc_node; - struct igc_nfc_input filter; + struct igc_nfc_filter filter; u16 sw_idx; u16 action; }; -#define IGC_MAX_RXNFC_FILTERS 16 +#define IGC_MAX_RXNFC_RULES 16 /* igc_desc_unused - calculate if we have unused descriptors */ static inline u16 igc_desc_unused(const struct igc_ring *ring) @@ -549,12 +549,11 @@ static inline s32 igc_read_phy_reg(struct igc_hw *hw, u32 offset, u16 *data) return 0; } -/* forward declaration */ void igc_reinit_locked(struct igc_adapter *); -int igc_add_filter(struct igc_adapter *adapter, - struct igc_nfc_filter *input); -int igc_erase_filter(struct igc_adapter *adapter, - struct igc_nfc_filter *input); +int igc_enable_nfc_rule(struct igc_adapter *adapter, + const struct igc_nfc_rule *rule); +int igc_disable_nfc_rule(struct igc_adapter *adapter, + const struct igc_nfc_rule *rule); void igc_ptp_init(struct igc_adapter *adapter); void igc_ptp_reset(struct igc_adapter *adapter); diff --git a/drivers/net/ethernet/intel/igc/igc_ethtool.c b/drivers/net/ethernet/intel/igc/igc_ethtool.c index 4ee040607c0b..46599ee7f0b9 100644 --- a/drivers/net/ethernet/intel/igc/igc_ethtool.c +++ b/drivers/net/ethernet/intel/igc/igc_ethtool.c @@ -931,16 +931,15 @@ static int igc_ethtool_set_coalesce(struct net_device *netdev, } #define ETHER_TYPE_FULL_MASK ((__force __be16)~0) -static int igc_ethtool_get_nfc_entry(struct igc_adapter *adapter, - struct ethtool_rxnfc *cmd) +static int igc_ethtool_get_nfc_rule(struct igc_adapter *adapter, + struct ethtool_rxnfc *cmd) { struct ethtool_rx_flow_spec *fsp = &cmd->fs; - struct igc_nfc_filter *rule = NULL; + struct igc_nfc_rule *rule = NULL; - /* report total rule count */ - cmd->data = IGC_MAX_RXNFC_FILTERS; + cmd->data = IGC_MAX_RXNFC_RULES; - hlist_for_each_entry(rule, &adapter->nfc_filter_list, nfc_node) { + hlist_for_each_entry(rule, &adapter->nfc_rule_list, nfc_node) { if (fsp->location <= rule->sw_idx) break; } @@ -980,17 +979,16 @@ static int igc_ethtool_get_nfc_entry(struct igc_adapter *adapter, return 0; } -static int igc_ethtool_get_nfc_all(struct igc_adapter *adapter, - struct ethtool_rxnfc *cmd, - u32 *rule_locs) +static int igc_ethtool_get_nfc_rules(struct igc_adapter *adapter, + struct ethtool_rxnfc *cmd, + u32 *rule_locs) { - struct igc_nfc_filter *rule; + struct igc_nfc_rule *rule; int cnt = 0; - /* report total rule count */ - cmd->data = IGC_MAX_RXNFC_FILTERS; + cmd->data = IGC_MAX_RXNFC_RULES; - hlist_for_each_entry(rule, &adapter->nfc_filter_list, nfc_node) { + hlist_for_each_entry(rule, &adapter->nfc_rule_list, nfc_node) { if (cnt == cmd->rule_cnt) return -EMSGSIZE; rule_locs[cnt] = rule->sw_idx; @@ -1062,12 +1060,12 @@ static int igc_ethtool_get_rxnfc(struct net_device *dev, cmd->data = adapter->num_rx_queues; return 0; case ETHTOOL_GRXCLSRLCNT: - cmd->rule_cnt = adapter->nfc_filter_count; + cmd->rule_cnt = adapter->nfc_rule_count; return 0; case ETHTOOL_GRXCLSRULE: - return igc_ethtool_get_nfc_entry(adapter, cmd); + return igc_ethtool_get_nfc_rule(adapter, cmd); case ETHTOOL_GRXCLSRLALL: - return igc_ethtool_get_nfc_all(adapter, cmd, rule_locs); + return igc_ethtool_get_nfc_rules(adapter, cmd, rule_locs); case ETHTOOL_GRXFH: return igc_ethtool_get_rss_hash_opts(adapter, cmd); default: @@ -1179,38 +1177,37 @@ static int igc_ethtool_set_rss_hash_opt(struct igc_adapter *adapter, return 0; } -int igc_add_filter(struct igc_adapter *adapter, struct igc_nfc_filter *input) +int igc_enable_nfc_rule(struct igc_adapter *adapter, + const struct igc_nfc_rule *rule) { int err = -EINVAL; - if (input->filter.match_flags & IGC_FILTER_FLAG_ETHER_TYPE) { - u16 etype = ntohs(input->filter.etype); + if (rule->filter.match_flags & IGC_FILTER_FLAG_ETHER_TYPE) { + u16 etype = ntohs(rule->filter.etype); - err = igc_add_etype_filter(adapter, etype, input->action); + err = igc_add_etype_filter(adapter, etype, rule->action); if (err) return err; } - if (input->filter.match_flags & IGC_FILTER_FLAG_SRC_MAC_ADDR) { + if (rule->filter.match_flags & IGC_FILTER_FLAG_SRC_MAC_ADDR) { err = igc_add_mac_filter(adapter, IGC_MAC_FILTER_TYPE_SRC, - input->filter.src_addr, - input->action); + rule->filter.src_addr, rule->action); if (err) return err; } - if (input->filter.match_flags & IGC_FILTER_FLAG_DST_MAC_ADDR) { + if (rule->filter.match_flags & IGC_FILTER_FLAG_DST_MAC_ADDR) { err = igc_add_mac_filter(adapter, IGC_MAC_FILTER_TYPE_DST, - input->filter.dst_addr, - input->action); + rule->filter.dst_addr, rule->action); if (err) return err; } - if (input->filter.match_flags & IGC_FILTER_FLAG_VLAN_TCI) { - int prio = (ntohs(input->filter.vlan_tci) & VLAN_PRIO_MASK) + if (rule->filter.match_flags & IGC_FILTER_FLAG_VLAN_TCI) { + int prio = (ntohs(rule->filter.vlan_tci) & VLAN_PRIO_MASK) >> VLAN_PRIO_SHIFT; - err = igc_add_vlan_prio_filter(adapter, prio, input->action); + err = igc_add_vlan_prio_filter(adapter, prio, rule->action); if (err) return err; } @@ -1218,42 +1215,43 @@ int igc_add_filter(struct igc_adapter *adapter, struct igc_nfc_filter *input) return 0; } -int igc_erase_filter(struct igc_adapter *adapter, struct igc_nfc_filter *input) +int igc_disable_nfc_rule(struct igc_adapter *adapter, + const struct igc_nfc_rule *rule) { - if (input->filter.match_flags & IGC_FILTER_FLAG_ETHER_TYPE) { - u16 etype = ntohs(input->filter.etype); + if (rule->filter.match_flags & IGC_FILTER_FLAG_ETHER_TYPE) { + u16 etype = ntohs(rule->filter.etype); igc_del_etype_filter(adapter, etype); } - if (input->filter.match_flags & IGC_FILTER_FLAG_VLAN_TCI) { - int prio = (ntohs(input->filter.vlan_tci) & VLAN_PRIO_MASK) + if (rule->filter.match_flags & IGC_FILTER_FLAG_VLAN_TCI) { + int prio = (ntohs(rule->filter.vlan_tci) & VLAN_PRIO_MASK) >> VLAN_PRIO_SHIFT; igc_del_vlan_prio_filter(adapter, prio); } - if (input->filter.match_flags & IGC_FILTER_FLAG_SRC_MAC_ADDR) + if (rule->filter.match_flags & IGC_FILTER_FLAG_SRC_MAC_ADDR) igc_del_mac_filter(adapter, IGC_MAC_FILTER_TYPE_SRC, - input->filter.src_addr); + rule->filter.src_addr); - if (input->filter.match_flags & IGC_FILTER_FLAG_DST_MAC_ADDR) + if (rule->filter.match_flags & IGC_FILTER_FLAG_DST_MAC_ADDR) igc_del_mac_filter(adapter, IGC_MAC_FILTER_TYPE_DST, - input->filter.dst_addr); + rule->filter.dst_addr); return 0; } -static int igc_ethtool_update_nfc_entry(struct igc_adapter *adapter, - struct igc_nfc_filter *input, - u16 sw_idx) +static int igc_ethtool_update_nfc_rule(struct igc_adapter *adapter, + struct igc_nfc_rule *input, + u16 sw_idx) { - struct igc_nfc_filter *rule, *parent; + struct igc_nfc_rule *rule, *parent; int err = -EINVAL; parent = NULL; rule = NULL; - hlist_for_each_entry(rule, &adapter->nfc_filter_list, nfc_node) { + hlist_for_each_entry(rule, &adapter->nfc_rule_list, nfc_node) { /* hash found, or no matching entry */ if (rule->sw_idx >= sw_idx) break; @@ -1263,11 +1261,11 @@ static int igc_ethtool_update_nfc_entry(struct igc_adapter *adapter, /* if there is an old rule occupying our place remove it */ if (rule && rule->sw_idx == sw_idx) { if (!input) - err = igc_erase_filter(adapter, rule); + err = igc_disable_nfc_rule(adapter, rule); hlist_del(&rule->nfc_node); kfree(rule); - adapter->nfc_filter_count--; + adapter->nfc_rule_count--; } /* If no input this was a delete, err should be 0 if a rule was @@ -1283,21 +1281,21 @@ static int igc_ethtool_update_nfc_entry(struct igc_adapter *adapter, if (parent) hlist_add_behind(&input->nfc_node, &parent->nfc_node); else - hlist_add_head(&input->nfc_node, &adapter->nfc_filter_list); + hlist_add_head(&input->nfc_node, &adapter->nfc_rule_list); /* update counts */ - adapter->nfc_filter_count++; + adapter->nfc_rule_count++; return 0; } -static int igc_ethtool_add_nfc_entry(struct igc_adapter *adapter, - struct ethtool_rxnfc *cmd) +static int igc_ethtool_add_nfc_rule(struct igc_adapter *adapter, + struct ethtool_rxnfc *cmd) { struct net_device *netdev = adapter->netdev; struct ethtool_rx_flow_spec *fsp = (struct ethtool_rx_flow_spec *)&cmd->fs; - struct igc_nfc_filter *input, *rule; + struct igc_nfc_rule *rule, *tmp; int err = 0; if (!(netdev->hw_features & NETIF_F_NTUPLE)) @@ -1314,7 +1312,7 @@ static int igc_ethtool_add_nfc_entry(struct igc_adapter *adapter, } /* Don't allow indexes to exist outside of available space */ - if (fsp->location >= IGC_MAX_RXNFC_FILTERS) { + if (fsp->location >= IGC_MAX_RXNFC_RULES) { netdev_err(netdev, "Location out of range"); return -EINVAL; } @@ -1322,32 +1320,32 @@ static int igc_ethtool_add_nfc_entry(struct igc_adapter *adapter, if ((fsp->flow_type & ~FLOW_EXT) != ETHER_FLOW) return -EINVAL; - input = kzalloc(sizeof(*input), GFP_KERNEL); - if (!input) + rule = kzalloc(sizeof(*rule), GFP_KERNEL); + if (!rule) return -ENOMEM; if (fsp->m_u.ether_spec.h_proto == ETHER_TYPE_FULL_MASK) { - input->filter.etype = fsp->h_u.ether_spec.h_proto; - input->filter.match_flags = IGC_FILTER_FLAG_ETHER_TYPE; + rule->filter.etype = fsp->h_u.ether_spec.h_proto; + rule->filter.match_flags = IGC_FILTER_FLAG_ETHER_TYPE; } /* Both source and destination address filters only support the full * mask. */ if (is_broadcast_ether_addr(fsp->m_u.ether_spec.h_source)) { - input->filter.match_flags |= IGC_FILTER_FLAG_SRC_MAC_ADDR; - ether_addr_copy(input->filter.src_addr, + rule->filter.match_flags |= IGC_FILTER_FLAG_SRC_MAC_ADDR; + ether_addr_copy(rule->filter.src_addr, fsp->h_u.ether_spec.h_source); } if (is_broadcast_ether_addr(fsp->m_u.ether_spec.h_dest)) { - input->filter.match_flags |= IGC_FILTER_FLAG_DST_MAC_ADDR; - ether_addr_copy(input->filter.dst_addr, + rule->filter.match_flags |= IGC_FILTER_FLAG_DST_MAC_ADDR; + ether_addr_copy(rule->filter.dst_addr, fsp->h_u.ether_spec.h_dest); } - if (input->filter.match_flags & IGC_FILTER_FLAG_DST_MAC_ADDR && - input->filter.match_flags & IGC_FILTER_FLAG_SRC_MAC_ADDR) { + if (rule->filter.match_flags & IGC_FILTER_FLAG_DST_MAC_ADDR && + rule->filter.match_flags & IGC_FILTER_FLAG_SRC_MAC_ADDR) { netdev_dbg(netdev, "Filters with both dst and src are not supported"); err = -EOPNOTSUPP; goto err_out; @@ -1359,18 +1357,18 @@ static int igc_ethtool_add_nfc_entry(struct igc_adapter *adapter, err = -EOPNOTSUPP; goto err_out; } - input->filter.vlan_tci = fsp->h_ext.vlan_tci; - input->filter.match_flags |= IGC_FILTER_FLAG_VLAN_TCI; + rule->filter.vlan_tci = fsp->h_ext.vlan_tci; + rule->filter.match_flags |= IGC_FILTER_FLAG_VLAN_TCI; } - input->action = fsp->ring_cookie; - input->sw_idx = fsp->location; + rule->action = fsp->ring_cookie; + rule->sw_idx = fsp->location; - spin_lock(&adapter->nfc_lock); + spin_lock(&adapter->nfc_rule_lock); - hlist_for_each_entry(rule, &adapter->nfc_filter_list, nfc_node) { - if (!memcmp(&input->filter, &rule->filter, - sizeof(input->filter))) { + hlist_for_each_entry(tmp, &adapter->nfc_rule_list, nfc_node) { + if (!memcmp(&rule->filter, &tmp->filter, + sizeof(rule->filter))) { err = -EEXIST; netdev_err(netdev, "ethtool: this filter is already set"); @@ -1378,32 +1376,32 @@ static int igc_ethtool_add_nfc_entry(struct igc_adapter *adapter, } } - err = igc_add_filter(adapter, input); + err = igc_enable_nfc_rule(adapter, rule); if (err) goto err_out_w_lock; - igc_ethtool_update_nfc_entry(adapter, input, input->sw_idx); + igc_ethtool_update_nfc_rule(adapter, rule, rule->sw_idx); - spin_unlock(&adapter->nfc_lock); + spin_unlock(&adapter->nfc_rule_lock); return 0; err_out_w_lock: - spin_unlock(&adapter->nfc_lock); + spin_unlock(&adapter->nfc_rule_lock); err_out: - kfree(input); + kfree(rule); return err; } -static int igc_ethtool_del_nfc_entry(struct igc_adapter *adapter, - struct ethtool_rxnfc *cmd) +static int igc_ethtool_del_nfc_rule(struct igc_adapter *adapter, + struct ethtool_rxnfc *cmd) { struct ethtool_rx_flow_spec *fsp = (struct ethtool_rx_flow_spec *)&cmd->fs; int err; - spin_lock(&adapter->nfc_lock); - err = igc_ethtool_update_nfc_entry(adapter, NULL, fsp->location); - spin_unlock(&adapter->nfc_lock); + spin_lock(&adapter->nfc_rule_lock); + err = igc_ethtool_update_nfc_rule(adapter, NULL, fsp->location); + spin_unlock(&adapter->nfc_rule_lock); return err; } @@ -1417,9 +1415,9 @@ static int igc_ethtool_set_rxnfc(struct net_device *dev, case ETHTOOL_SRXFH: return igc_ethtool_set_rss_hash_opt(adapter, cmd); case ETHTOOL_SRXCLSRLINS: - return igc_ethtool_add_nfc_entry(adapter, cmd); + return igc_ethtool_add_nfc_rule(adapter, cmd); case ETHTOOL_SRXCLSRLDEL: - return igc_ethtool_del_nfc_entry(adapter, cmd); + return igc_ethtool_del_nfc_rule(adapter, cmd); default: return -EOPNOTSUPP; } diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c index ecdc0548f24e..7d9a2da4feee 100644 --- a/drivers/net/ethernet/intel/igc/igc_main.c +++ b/drivers/net/ethernet/intel/igc/igc_main.c @@ -2175,16 +2175,16 @@ static bool igc_clean_tx_irq(struct igc_q_vector *q_vector, int napi_budget) return !!budget; } -static void igc_nfc_filter_restore(struct igc_adapter *adapter) +static void igc_restore_nfc_rules(struct igc_adapter *adapter) { - struct igc_nfc_filter *rule; + struct igc_nfc_rule *rule; - spin_lock(&adapter->nfc_lock); + spin_lock(&adapter->nfc_rule_lock); - hlist_for_each_entry(rule, &adapter->nfc_filter_list, nfc_node) - igc_add_filter(adapter, rule); + hlist_for_each_entry(rule, &adapter->nfc_rule_list, nfc_node) + igc_enable_nfc_rule(adapter, rule); - spin_unlock(&adapter->nfc_lock); + spin_unlock(&adapter->nfc_rule_lock); } static int igc_find_mac_filter(struct igc_adapter *adapter, @@ -2538,7 +2538,7 @@ static void igc_configure(struct igc_adapter *adapter) igc_setup_rctl(adapter); igc_set_default_mac_filter(adapter); - igc_nfc_filter_restore(adapter); + igc_restore_nfc_rules(adapter); igc_configure_tx(adapter); igc_configure_rx(adapter); @@ -3425,7 +3425,7 @@ static int igc_sw_init(struct igc_adapter *adapter) VLAN_HLEN; adapter->min_frame_size = ETH_ZLEN + ETH_FCS_LEN; - spin_lock_init(&adapter->nfc_lock); + spin_lock_init(&adapter->nfc_rule_lock); spin_lock_init(&adapter->stats64_lock); /* Assume MSI-X interrupts, will be checked during IRQ allocation */ adapter->flags |= IGC_FLAG_HAS_MSIX; @@ -3652,16 +3652,16 @@ void igc_update_stats(struct igc_adapter *adapter) adapter->stats.mgpdc += rd32(IGC_MGTPDC); } -static void igc_nfc_filter_exit(struct igc_adapter *adapter) +static void igc_nfc_rule_exit(struct igc_adapter *adapter) { - struct igc_nfc_filter *rule; + struct igc_nfc_rule *rule; - spin_lock(&adapter->nfc_lock); + spin_lock(&adapter->nfc_rule_lock); - hlist_for_each_entry(rule, &adapter->nfc_filter_list, nfc_node) - igc_erase_filter(adapter, rule); + hlist_for_each_entry(rule, &adapter->nfc_rule_list, nfc_node) + igc_disable_nfc_rule(adapter, rule); - spin_unlock(&adapter->nfc_lock); + spin_unlock(&adapter->nfc_rule_lock); } /** @@ -3682,7 +3682,7 @@ void igc_down(struct igc_adapter *adapter) wr32(IGC_RCTL, rctl & ~IGC_RCTL_EN); /* flush and sleep below */ - igc_nfc_filter_exit(adapter); + igc_nfc_rule_exit(adapter); /* set trans_start so we don't get spurious watchdogs during reset */ netif_trans_update(netdev); @@ -3834,17 +3834,17 @@ static int igc_set_features(struct net_device *netdev, if (!(features & NETIF_F_NTUPLE)) { struct hlist_node *node2; - struct igc_nfc_filter *rule; + struct igc_nfc_rule *rule; - spin_lock(&adapter->nfc_lock); + spin_lock(&adapter->nfc_rule_lock); hlist_for_each_entry_safe(rule, node2, - &adapter->nfc_filter_list, nfc_node) { - igc_erase_filter(adapter, rule); + &adapter->nfc_rule_list, nfc_node) { + igc_disable_nfc_rule(adapter, rule); hlist_del(&rule->nfc_node); kfree(rule); } - spin_unlock(&adapter->nfc_lock); - adapter->nfc_filter_count = 0; + spin_unlock(&adapter->nfc_rule_lock); + adapter->nfc_rule_count = 0; } netdev->features = features; From patchwork Fri Apr 24 20:16:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Guedes X-Patchwork-Id: 1276664 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 49857g6TFJz9sSd for ; Sat, 25 Apr 2020 06:17:35 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 86235204DC; Fri, 24 Apr 2020 20:17:33 +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 hUf2Zpf+-dnW; Fri, 24 Apr 2020 20:17:32 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 1DCE420448; Fri, 24 Apr 2020 20:17:32 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 474E61BF83C for ; Fri, 24 Apr 2020 20:17:27 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 4468C86B89 for ; Fri, 24 Apr 2020 20:17:27 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0948LTtFIDAv for ; Fri, 24 Apr 2020 20:17:26 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 981E386B59 for ; Fri, 24 Apr 2020 20:17:26 +0000 (UTC) IronPort-SDR: Jz8+mX6z1qKhtV8hQ7RdqwAFmFqNhiO2kpRLhJTEZsNCT97jm3ZZtwPkWeq3qPeKEQabFFOYlk ofbdxtIAzAnA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2020 13:17:26 -0700 IronPort-SDR: NY/Bwas+hU8RxitxSlSz9+PSU5PGhekae3k250NT95KYbiaCGYsTMUpEutOzducVcbUYsGPDwt OmePds16K12g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,313,1583222400"; d="scan'208";a="335474508" Received: from kleandre-mobl.amr.corp.intel.com ([10.213.164.39]) by orsmga001.jf.intel.com with ESMTP; 24 Apr 2020 13:17:26 -0700 From: Andre Guedes To: intel-wired-lan@lists.osuosl.org Date: Fri, 24 Apr 2020 13:16:11 -0700 Message-Id: <20200424201623.10971-8-andre.guedes@intel.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200424201623.10971-1-andre.guedes@intel.com> References: <20200424201623.10971-1-andre.guedes@intel.com> MIME-Version: 1.0 Subject: [Intel-wired-lan] [PATCH 07/19] igc: Change byte order in struct igc_nfc_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" Every time we access the 'etype' and 'vlan_tci' fields from struct igc_nfc_filter to enable or disable filters in hardware we have to convert them from big endian to host order so it makes more sense to simply have these fields in host order. The byte order conversion should take place in igc_ethtool_get_nfc_ rule() and igc_ethtool_add_nfc_rule(), which are called by .get_rxnfc and .set_rxnfc ethtool ops, since ethtool subsystem is the one who deals with them in big endian order. Signed-off-by: Andre Guedes Tested-by: Aaron Brown --- drivers/net/ethernet/intel/igc/igc.h | 10 ++------ drivers/net/ethernet/intel/igc/igc_ethtool.c | 25 +++++++++----------- 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/drivers/net/ethernet/intel/igc/igc.h b/drivers/net/ethernet/intel/igc/igc.h index 7124ba254b89..fcc6261d7f67 100644 --- a/drivers/net/ethernet/intel/igc/igc.h +++ b/drivers/net/ethernet/intel/igc/igc.h @@ -452,16 +452,10 @@ enum igc_filter_match_flags { IGC_FILTER_FLAG_DST_MAC_ADDR = 0x8, }; -/* RX network flow classification data structure */ struct igc_nfc_filter { - /* Byte layout in order, all values with MSB first: - * match_flags - 1 byte - * etype - 2 bytes - * vlan_tci - 2 bytes - */ u8 match_flags; - __be16 etype; - __be16 vlan_tci; + u16 etype; + u16 vlan_tci; u8 src_addr[ETH_ALEN]; u8 dst_addr[ETH_ALEN]; }; diff --git a/drivers/net/ethernet/intel/igc/igc_ethtool.c b/drivers/net/ethernet/intel/igc/igc_ethtool.c index 46599ee7f0b9..f9518aa1375b 100644 --- a/drivers/net/ethernet/intel/igc/igc_ethtool.c +++ b/drivers/net/ethernet/intel/igc/igc_ethtool.c @@ -954,13 +954,13 @@ static int igc_ethtool_get_nfc_rule(struct igc_adapter *adapter, fsp->ring_cookie = rule->action; if (rule->filter.match_flags & IGC_FILTER_FLAG_ETHER_TYPE) { - fsp->h_u.ether_spec.h_proto = rule->filter.etype; + fsp->h_u.ether_spec.h_proto = htons(rule->filter.etype); fsp->m_u.ether_spec.h_proto = ETHER_TYPE_FULL_MASK; } if (rule->filter.match_flags & IGC_FILTER_FLAG_VLAN_TCI) { fsp->flow_type |= FLOW_EXT; - fsp->h_ext.vlan_tci = rule->filter.vlan_tci; + fsp->h_ext.vlan_tci = htons(rule->filter.vlan_tci); fsp->m_ext.vlan_tci = htons(VLAN_PRIO_MASK); } @@ -1183,9 +1183,8 @@ int igc_enable_nfc_rule(struct igc_adapter *adapter, int err = -EINVAL; if (rule->filter.match_flags & IGC_FILTER_FLAG_ETHER_TYPE) { - u16 etype = ntohs(rule->filter.etype); - - err = igc_add_etype_filter(adapter, etype, rule->action); + err = igc_add_etype_filter(adapter, rule->filter.etype, + rule->action); if (err) return err; } @@ -1205,8 +1204,9 @@ int igc_enable_nfc_rule(struct igc_adapter *adapter, } if (rule->filter.match_flags & IGC_FILTER_FLAG_VLAN_TCI) { - int prio = (ntohs(rule->filter.vlan_tci) & VLAN_PRIO_MASK) + int prio = (rule->filter.vlan_tci & VLAN_PRIO_MASK) >> VLAN_PRIO_SHIFT; + err = igc_add_vlan_prio_filter(adapter, prio, rule->action); if (err) return err; @@ -1218,14 +1218,11 @@ int igc_enable_nfc_rule(struct igc_adapter *adapter, int igc_disable_nfc_rule(struct igc_adapter *adapter, const struct igc_nfc_rule *rule) { - if (rule->filter.match_flags & IGC_FILTER_FLAG_ETHER_TYPE) { - u16 etype = ntohs(rule->filter.etype); - - igc_del_etype_filter(adapter, etype); - } + if (rule->filter.match_flags & IGC_FILTER_FLAG_ETHER_TYPE) + igc_del_etype_filter(adapter, rule->filter.etype); if (rule->filter.match_flags & IGC_FILTER_FLAG_VLAN_TCI) { - int prio = (ntohs(rule->filter.vlan_tci) & VLAN_PRIO_MASK) + int prio = (rule->filter.vlan_tci & VLAN_PRIO_MASK) >> VLAN_PRIO_SHIFT; igc_del_vlan_prio_filter(adapter, prio); } @@ -1325,7 +1322,7 @@ static int igc_ethtool_add_nfc_rule(struct igc_adapter *adapter, return -ENOMEM; if (fsp->m_u.ether_spec.h_proto == ETHER_TYPE_FULL_MASK) { - rule->filter.etype = fsp->h_u.ether_spec.h_proto; + rule->filter.etype = ntohs(fsp->h_u.ether_spec.h_proto); rule->filter.match_flags = IGC_FILTER_FLAG_ETHER_TYPE; } @@ -1357,7 +1354,7 @@ static int igc_ethtool_add_nfc_rule(struct igc_adapter *adapter, err = -EOPNOTSUPP; goto err_out; } - rule->filter.vlan_tci = fsp->h_ext.vlan_tci; + rule->filter.vlan_tci = ntohs(fsp->h_ext.vlan_tci); rule->filter.match_flags |= IGC_FILTER_FLAG_VLAN_TCI; } From patchwork Fri Apr 24 20:16:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Guedes X-Patchwork-Id: 1276665 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.137; helo=fraxinus.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 fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49857h155Pz9sSJ for ; Sat, 25 Apr 2020 06:17:35 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id BE755868A9; Fri, 24 Apr 2020 20:17:33 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1-UAKOEzJ0T0; Fri, 24 Apr 2020 20:17:32 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id E224B868BC; Fri, 24 Apr 2020 20:17:32 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id BB6141BF9C2 for ; Fri, 24 Apr 2020 20:17:27 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id B279E86B59 for ; Fri, 24 Apr 2020 20:17:27 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Zh844B2ZICuX for ; Fri, 24 Apr 2020 20:17:27 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by fraxinus.osuosl.org (Postfix) with ESMTPS id F1387868C9 for ; Fri, 24 Apr 2020 20:17:26 +0000 (UTC) IronPort-SDR: Th0tszmc3hYS0yzlPGDGYF2/yfwzo0QsJ54w1hUL8EsJCuSnjiQDny7G3dT0YSzqz/0IoD9dIt 6yeCS/IXxaJw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2020 13:17:26 -0700 IronPort-SDR: G1jvgECB+GOj/nQJbnHDvqpuLm3I6+JF2EUprSIwrl5k+GxxDuuzBFrZL0d08B91cxa737vr6N O7NKG/pYJLhA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,313,1583222400"; d="scan'208";a="335474510" Received: from kleandre-mobl.amr.corp.intel.com ([10.213.164.39]) by orsmga001.jf.intel.com with ESMTP; 24 Apr 2020 13:17:26 -0700 From: Andre Guedes To: intel-wired-lan@lists.osuosl.org Date: Fri, 24 Apr 2020 13:16:12 -0700 Message-Id: <20200424201623.10971-9-andre.guedes@intel.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200424201623.10971-1-andre.guedes@intel.com> References: <20200424201623.10971-1-andre.guedes@intel.com> MIME-Version: 1.0 Subject: [Intel-wired-lan] [PATCH 08/19] igc: Refactor igc_ethtool_add_nfc_rule() 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 implementation of igc_ethtool_add_nfc_rule() is quite long and a bit convoluted so this patch does a code refactoring to improve the code. Code related to NFC rule object initialization is refactored out to the local helper function igc_ethtool_init_nfc_rule(). Likewise, code related to NFC rule validation is refactored out to another local helper, igc_ethtool_is_nfc_rule_valid(). RX_CLS_FLOW_DISC check is removed since it is redundant. The macro is defined as the max value fsp->ring_cookie can have, so checking if fsp->ring_cookie >= adapter->num_rx_queues is already sufficient. Finally, some log messages are improved or added, and obvious comments are removed. Signed-off-by: Andre Guedes Tested-by: Aaron Brown --- drivers/net/ethernet/intel/igc/igc_ethtool.c | 150 ++++++++++++------- 1 file changed, 92 insertions(+), 58 deletions(-) diff --git a/drivers/net/ethernet/intel/igc/igc_ethtool.c b/drivers/net/ethernet/intel/igc/igc_ethtool.c index f9518aa1375b..bdb7c99f66be 100644 --- a/drivers/net/ethernet/intel/igc/igc_ethtool.c +++ b/drivers/net/ethernet/intel/igc/igc_ethtool.c @@ -1271,9 +1271,6 @@ static int igc_ethtool_update_nfc_rule(struct igc_adapter *adapter, if (!input) return err; - /* initialize node */ - INIT_HLIST_NODE(&input->nfc_node); - /* add filter to the list */ if (parent) hlist_add_behind(&input->nfc_node, &parent->nfc_node); @@ -1286,41 +1283,19 @@ static int igc_ethtool_update_nfc_rule(struct igc_adapter *adapter, return 0; } -static int igc_ethtool_add_nfc_rule(struct igc_adapter *adapter, - struct ethtool_rxnfc *cmd) +static void igc_ethtool_init_nfc_rule(struct igc_nfc_rule *rule, + const struct ethtool_rx_flow_spec *fsp) { - struct net_device *netdev = adapter->netdev; - struct ethtool_rx_flow_spec *fsp = - (struct ethtool_rx_flow_spec *)&cmd->fs; - struct igc_nfc_rule *rule, *tmp; - int err = 0; - - if (!(netdev->hw_features & NETIF_F_NTUPLE)) - return -EOPNOTSUPP; + INIT_HLIST_NODE(&rule->nfc_node); - /* Don't allow programming if the action is a queue greater than - * the number of online Rx queues. - */ - if (fsp->ring_cookie == RX_CLS_FLOW_DISC || - fsp->ring_cookie >= adapter->num_rx_queues) { - netdev_err(netdev, - "ethtool -N: The specified action is invalid"); - return -EINVAL; - } + rule->action = fsp->ring_cookie; + rule->sw_idx = fsp->location; - /* Don't allow indexes to exist outside of available space */ - if (fsp->location >= IGC_MAX_RXNFC_RULES) { - netdev_err(netdev, "Location out of range"); - return -EINVAL; + if ((fsp->flow_type & FLOW_EXT) && fsp->m_ext.vlan_tci) { + rule->filter.vlan_tci = ntohs(fsp->h_ext.vlan_tci); + rule->filter.match_flags |= IGC_FILTER_FLAG_VLAN_TCI; } - if ((fsp->flow_type & ~FLOW_EXT) != ETHER_FLOW) - return -EINVAL; - - rule = kzalloc(sizeof(*rule), GFP_KERNEL); - if (!rule) - return -ENOMEM; - if (fsp->m_u.ether_spec.h_proto == ETHER_TYPE_FULL_MASK) { rule->filter.etype = ntohs(fsp->h_u.ether_spec.h_proto); rule->filter.match_flags = IGC_FILTER_FLAG_ETHER_TYPE; @@ -1340,51 +1315,110 @@ static int igc_ethtool_add_nfc_rule(struct igc_adapter *adapter, ether_addr_copy(rule->filter.dst_addr, fsp->h_u.ether_spec.h_dest); } +} - if (rule->filter.match_flags & IGC_FILTER_FLAG_DST_MAC_ADDR && - rule->filter.match_flags & IGC_FILTER_FLAG_SRC_MAC_ADDR) { - netdev_dbg(netdev, "Filters with both dst and src are not supported"); - err = -EOPNOTSUPP; - goto err_out; - } +/** + * igc_ethtool_check_nfc_rule() - Check if NFC rule is valid. + * @adapter: Pointer to adapter. + * @rule: Rule under evaluation. + * + * Rules with both destination and source MAC addresses are considered invalid + * since the driver doesn't support them. + * + * Also, if there is already another rule with the same filter, @rule is + * considered invalid. + * + * Context: Expects adapter->nfc_rule_lock to be held by caller. + * + * Return: 0 in case of success, negative errno code otherwise. + */ +static int igc_ethtool_check_nfc_rule(struct igc_adapter *adapter, + struct igc_nfc_rule *rule) +{ + struct net_device *dev = adapter->netdev; + u8 flags = rule->filter.match_flags; + struct igc_nfc_rule *tmp; - if ((fsp->flow_type & FLOW_EXT) && fsp->m_ext.vlan_tci) { - if (fsp->m_ext.vlan_tci != htons(VLAN_PRIO_MASK)) { - netdev_dbg(netdev, "VLAN mask not supported"); - err = -EOPNOTSUPP; - goto err_out; - } - rule->filter.vlan_tci = ntohs(fsp->h_ext.vlan_tci); - rule->filter.match_flags |= IGC_FILTER_FLAG_VLAN_TCI; + if (!flags) { + netdev_dbg(dev, "Rule with no match"); + return -EINVAL; } - rule->action = fsp->ring_cookie; - rule->sw_idx = fsp->location; - - spin_lock(&adapter->nfc_rule_lock); + if (flags & IGC_FILTER_FLAG_DST_MAC_ADDR && + flags & IGC_FILTER_FLAG_SRC_MAC_ADDR) { + netdev_dbg(dev, "Filters with both dst and src are not supported"); + return -EOPNOTSUPP; + } hlist_for_each_entry(tmp, &adapter->nfc_rule_list, nfc_node) { if (!memcmp(&rule->filter, &tmp->filter, sizeof(rule->filter))) { - err = -EEXIST; - netdev_err(netdev, - "ethtool: this filter is already set"); - goto err_out_w_lock; + netdev_dbg(dev, "Rule already exists"); + return -EEXIST; } } + return 0; +} + +static int igc_ethtool_add_nfc_rule(struct igc_adapter *adapter, + struct ethtool_rxnfc *cmd) +{ + struct net_device *netdev = adapter->netdev; + struct ethtool_rx_flow_spec *fsp = + (struct ethtool_rx_flow_spec *)&cmd->fs; + struct igc_nfc_rule *rule; + int err; + + if (!(netdev->hw_features & NETIF_F_NTUPLE)) { + netdev_dbg(netdev, "N-tuple filters disabled"); + return -EOPNOTSUPP; + } + + if ((fsp->flow_type & ~FLOW_EXT) != ETHER_FLOW) { + netdev_dbg(netdev, "Only ethernet flow type is supported"); + return -EOPNOTSUPP; + } + + if ((fsp->flow_type & FLOW_EXT) && + fsp->m_ext.vlan_tci != htons(VLAN_PRIO_MASK)) { + netdev_dbg(netdev, "VLAN mask not supported"); + return -EOPNOTSUPP; + } + + if (fsp->ring_cookie >= adapter->num_rx_queues) { + netdev_dbg(netdev, "Invalid action"); + return -EINVAL; + } + + if (fsp->location >= IGC_MAX_RXNFC_RULES) { + netdev_dbg(netdev, "Invalid location"); + return -EINVAL; + } + + rule = kzalloc(sizeof(*rule), GFP_KERNEL); + if (!rule) + return -ENOMEM; + + igc_ethtool_init_nfc_rule(rule, fsp); + + spin_lock(&adapter->nfc_rule_lock); + + err = igc_ethtool_check_nfc_rule(adapter, rule); + if (err) + goto err; + err = igc_enable_nfc_rule(adapter, rule); if (err) - goto err_out_w_lock; + goto err; igc_ethtool_update_nfc_rule(adapter, rule, rule->sw_idx); spin_unlock(&adapter->nfc_rule_lock); return 0; -err_out_w_lock: +err: spin_unlock(&adapter->nfc_rule_lock); -err_out: kfree(rule); return err; } From patchwork Fri Apr 24 20:16:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Guedes X-Patchwork-Id: 1276670 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 49857m6VvWz9sSG for ; Sat, 25 Apr 2020 06:17:40 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 77D232156E; Fri, 24 Apr 2020 20:17:39 +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 ndOKckyCQduK; Fri, 24 Apr 2020 20:17:34 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id BCFC520526; Fri, 24 Apr 2020 20:17:33 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 26E2C1BF83C for ; Fri, 24 Apr 2020 20:17:29 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 22D78868BC for ; Fri, 24 Apr 2020 20:17:29 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WKTuAxrnf1QK for ; Fri, 24 Apr 2020 20:17:27 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 277F4868A9 for ; Fri, 24 Apr 2020 20:17:27 +0000 (UTC) IronPort-SDR: TFVNB2O/CXHwP+2elRb6Mya5q0WgAEm5fEjIZlNheHObSv+Z1gAa0rrcMubzsePB8vr3k8o4HT vjvUV/hRc7nw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2020 13:17:26 -0700 IronPort-SDR: UCr2dySd9tBn1DDNlrvO1navv2qN8uRszplTLAh1KM6YcuYBG09ZxprcY2iLOoL1HNhEvk/Yp7 hsEYvdI4J8OQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,313,1583222400"; d="scan'208";a="335474511" Received: from kleandre-mobl.amr.corp.intel.com ([10.213.164.39]) by orsmga001.jf.intel.com with ESMTP; 24 Apr 2020 13:17:26 -0700 From: Andre Guedes To: intel-wired-lan@lists.osuosl.org Date: Fri, 24 Apr 2020 13:16:13 -0700 Message-Id: <20200424201623.10971-10-andre.guedes@intel.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200424201623.10971-1-andre.guedes@intel.com> References: <20200424201623.10971-1-andre.guedes@intel.com> MIME-Version: 1.0 Subject: [Intel-wired-lan] [PATCH 09/19] igc: Fix 'sw_idx' type in struct igc_nfc_rule 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 'sw_idx' field from 'struct igc_nfc_rule' is u16 type but it is assigned an u32 value in igc_ethtool_init_nfc_rule(). This patch changes 'sw_idx' type to u32 so they match. Also, it makes more sense to call this field 'location' since it holds the NFC rule location. Signed-off-by: Andre Guedes Tested-by: Aaron Brown --- drivers/net/ethernet/intel/igc/igc.h | 2 +- drivers/net/ethernet/intel/igc/igc_ethtool.c | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/intel/igc/igc.h b/drivers/net/ethernet/intel/igc/igc.h index fcc6261d7f67..ae7d48070ee2 100644 --- a/drivers/net/ethernet/intel/igc/igc.h +++ b/drivers/net/ethernet/intel/igc/igc.h @@ -463,7 +463,7 @@ struct igc_nfc_filter { struct igc_nfc_rule { struct hlist_node nfc_node; struct igc_nfc_filter filter; - u16 sw_idx; + u32 location; u16 action; }; diff --git a/drivers/net/ethernet/intel/igc/igc_ethtool.c b/drivers/net/ethernet/intel/igc/igc_ethtool.c index bdb7c99f66be..93274e75e8c5 100644 --- a/drivers/net/ethernet/intel/igc/igc_ethtool.c +++ b/drivers/net/ethernet/intel/igc/igc_ethtool.c @@ -940,11 +940,11 @@ static int igc_ethtool_get_nfc_rule(struct igc_adapter *adapter, cmd->data = IGC_MAX_RXNFC_RULES; hlist_for_each_entry(rule, &adapter->nfc_rule_list, nfc_node) { - if (fsp->location <= rule->sw_idx) + if (fsp->location <= rule->location) break; } - if (!rule || fsp->location != rule->sw_idx) + if (!rule || fsp->location != rule->location) return -EINVAL; if (!rule->filter.match_flags) @@ -991,7 +991,7 @@ static int igc_ethtool_get_nfc_rules(struct igc_adapter *adapter, hlist_for_each_entry(rule, &adapter->nfc_rule_list, nfc_node) { if (cnt == cmd->rule_cnt) return -EMSGSIZE; - rule_locs[cnt] = rule->sw_idx; + rule_locs[cnt] = rule->location; cnt++; } @@ -1240,7 +1240,7 @@ int igc_disable_nfc_rule(struct igc_adapter *adapter, static int igc_ethtool_update_nfc_rule(struct igc_adapter *adapter, struct igc_nfc_rule *input, - u16 sw_idx) + u32 location) { struct igc_nfc_rule *rule, *parent; int err = -EINVAL; @@ -1250,13 +1250,13 @@ static int igc_ethtool_update_nfc_rule(struct igc_adapter *adapter, hlist_for_each_entry(rule, &adapter->nfc_rule_list, nfc_node) { /* hash found, or no matching entry */ - if (rule->sw_idx >= sw_idx) + if (rule->location >= location) break; parent = rule; } /* if there is an old rule occupying our place remove it */ - if (rule && rule->sw_idx == sw_idx) { + if (rule && rule->location == location) { if (!input) err = igc_disable_nfc_rule(adapter, rule); @@ -1289,7 +1289,7 @@ static void igc_ethtool_init_nfc_rule(struct igc_nfc_rule *rule, INIT_HLIST_NODE(&rule->nfc_node); rule->action = fsp->ring_cookie; - rule->sw_idx = fsp->location; + rule->location = fsp->location; if ((fsp->flow_type & FLOW_EXT) && fsp->m_ext.vlan_tci) { rule->filter.vlan_tci = ntohs(fsp->h_ext.vlan_tci); @@ -1412,7 +1412,7 @@ static int igc_ethtool_add_nfc_rule(struct igc_adapter *adapter, if (err) goto err; - igc_ethtool_update_nfc_rule(adapter, rule, rule->sw_idx); + igc_ethtool_update_nfc_rule(adapter, rule, rule->location); spin_unlock(&adapter->nfc_rule_lock); return 0; From patchwork Fri Apr 24 20:16:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Guedes X-Patchwork-Id: 1276668 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.138; helo=whitealder.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 whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49857j5YHcz9sSJ for ; Sat, 25 Apr 2020 06:17:37 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 468BC87F92; Fri, 24 Apr 2020 20:17:36 +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 IsKHLh2Ytk0Y; Fri, 24 Apr 2020 20:17:33 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id 3A0D488021; Fri, 24 Apr 2020 20:17:33 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id BDE101BF83C for ; Fri, 24 Apr 2020 20:17:28 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id BA53786BA9 for ; Fri, 24 Apr 2020 20:17:28 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5W2pcpmhSAcU for ; Fri, 24 Apr 2020 20:17:28 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 42257868C9 for ; Fri, 24 Apr 2020 20:17:28 +0000 (UTC) IronPort-SDR: aiwywdPN/KP3JYGqyOBl5Rb4wB48BQMHdfhQlWkjk7qbaPCNdg1Tudj2ywtIk3FEsNis+QpVLq Q/v9KTplGmLw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2020 13:17:27 -0700 IronPort-SDR: nnCDQnp47gU/Z5gaEq4fc0Ang0IZ74K5ErWZ29KNayt38J7r+YoT73s50lpeGr7BsI0m66uObe b9JgXTtMhfWA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,313,1583222400"; d="scan'208";a="335474512" Received: from kleandre-mobl.amr.corp.intel.com ([10.213.164.39]) by orsmga001.jf.intel.com with ESMTP; 24 Apr 2020 13:17:26 -0700 From: Andre Guedes To: intel-wired-lan@lists.osuosl.org Date: Fri, 24 Apr 2020 13:16:14 -0700 Message-Id: <20200424201623.10971-11-andre.guedes@intel.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200424201623.10971-1-andre.guedes@intel.com> References: <20200424201623.10971-1-andre.guedes@intel.com> MIME-Version: 1.0 Subject: [Intel-wired-lan] [PATCH 10/19] igc: Fix locking issue when retrieving NFC rules 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" Access to NFC rules stored in adapter->nfc_rule_list is protect by adapter->nfc_rule_lock. The functions igc_ethtool_get_nfc_rule() and igc_ethtool_get_nfc_rules() are missing to hold the lock while accessing rule objects. Signed-off-by: Andre Guedes Tested-by: Aaron Brown --- drivers/net/ethernet/intel/igc/igc_ethtool.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/intel/igc/igc_ethtool.c b/drivers/net/ethernet/intel/igc/igc_ethtool.c index 93274e75e8c5..38ac61c04e5c 100644 --- a/drivers/net/ethernet/intel/igc/igc_ethtool.c +++ b/drivers/net/ethernet/intel/igc/igc_ethtool.c @@ -939,16 +939,18 @@ static int igc_ethtool_get_nfc_rule(struct igc_adapter *adapter, cmd->data = IGC_MAX_RXNFC_RULES; + spin_lock(&adapter->nfc_rule_lock); + hlist_for_each_entry(rule, &adapter->nfc_rule_list, nfc_node) { if (fsp->location <= rule->location) break; } if (!rule || fsp->location != rule->location) - return -EINVAL; + goto out; if (!rule->filter.match_flags) - return -EINVAL; + goto out; fsp->flow_type = ETHER_FLOW; fsp->ring_cookie = rule->action; @@ -976,7 +978,12 @@ static int igc_ethtool_get_nfc_rule(struct igc_adapter *adapter, eth_broadcast_addr(fsp->m_u.ether_spec.h_source); } + spin_unlock(&adapter->nfc_rule_lock); return 0; + +out: + spin_unlock(&adapter->nfc_rule_lock); + return -EINVAL; } static int igc_ethtool_get_nfc_rules(struct igc_adapter *adapter, @@ -988,13 +995,19 @@ static int igc_ethtool_get_nfc_rules(struct igc_adapter *adapter, cmd->data = IGC_MAX_RXNFC_RULES; + spin_lock(&adapter->nfc_rule_lock); + hlist_for_each_entry(rule, &adapter->nfc_rule_list, nfc_node) { - if (cnt == cmd->rule_cnt) + if (cnt == cmd->rule_cnt) { + spin_unlock(&adapter->nfc_rule_lock); return -EMSGSIZE; + } rule_locs[cnt] = rule->location; cnt++; } + spin_unlock(&adapter->nfc_rule_lock); + cmd->rule_cnt = cnt; return 0; From patchwork Fri Apr 24 20:16:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Guedes X-Patchwork-Id: 1276671 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 49857p6R6Fz9sSG for ; Sat, 25 Apr 2020 06:17:42 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 40DCB204BD; Fri, 24 Apr 2020 20:17:41 +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 kLvUoAeDaaTr; Fri, 24 Apr 2020 20:17:38 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 3B83D2202E; Fri, 24 Apr 2020 20:17:34 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 9189E1BF83C for ; Fri, 24 Apr 2020 20:17:29 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 8E356868A9 for ; Fri, 24 Apr 2020 20:17:29 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id I7-Ug73YXNQ3 for ; Fri, 24 Apr 2020 20:17:28 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 8E12886B59 for ; Fri, 24 Apr 2020 20:17:28 +0000 (UTC) IronPort-SDR: +EYm+G8qTWVk/SwUMyokdJWC9Orh5M4ZZnCAnwXNhHrpHAvQRQHVkDkDkmM/V1cjYwhgNFx4+R B50lyXZeBlxA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2020 13:17:27 -0700 IronPort-SDR: SREIDNVVBjWpiHq9iy0TaCCsSWGpydT0b3QX5irCG7SylbahV7mK9aPkowt5JuupflH1BSxVxW drhm4pRAE54A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,313,1583222400"; d="scan'208";a="335474513" Received: from kleandre-mobl.amr.corp.intel.com ([10.213.164.39]) by orsmga001.jf.intel.com with ESMTP; 24 Apr 2020 13:17:27 -0700 From: Andre Guedes To: intel-wired-lan@lists.osuosl.org Date: Fri, 24 Apr 2020 13:16:15 -0700 Message-Id: <20200424201623.10971-12-andre.guedes@intel.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200424201623.10971-1-andre.guedes@intel.com> References: <20200424201623.10971-1-andre.guedes@intel.com> MIME-Version: 1.0 Subject: [Intel-wired-lan] [PATCH 11/19] igc: Fix NFC rule overwrite cases 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" When the 'loc' argument is passed in ethtool, the input rule overwrites any rule present in that location. In this situation we must disable the old rule otherwise it is left enabled in hardware. This patch fixes the issue by always calling igc_disable_nfc_rule() when deleting the old rule, no matter the value of 'input' argument. Signed-off-by: Andre Guedes Tested-by: Aaron Brown --- drivers/net/ethernet/intel/igc/igc_ethtool.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/igc/igc_ethtool.c b/drivers/net/ethernet/intel/igc/igc_ethtool.c index 38ac61c04e5c..e975efea4a15 100644 --- a/drivers/net/ethernet/intel/igc/igc_ethtool.c +++ b/drivers/net/ethernet/intel/igc/igc_ethtool.c @@ -1270,8 +1270,7 @@ static int igc_ethtool_update_nfc_rule(struct igc_adapter *adapter, /* if there is an old rule occupying our place remove it */ if (rule && rule->location == location) { - if (!input) - err = igc_disable_nfc_rule(adapter, rule); + err = igc_disable_nfc_rule(adapter, rule); hlist_del(&rule->nfc_node); kfree(rule); From patchwork Fri Apr 24 20:16:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Guedes X-Patchwork-Id: 1276667 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.133; helo=hemlock.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 hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49857j1GLKz9sSd for ; Sat, 25 Apr 2020 06:17:37 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id AEAEA8871E; Fri, 24 Apr 2020 20:17:35 +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 CJ3HxPHUavM0; Fri, 24 Apr 2020 20:17:34 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id AD3D2886DC; Fri, 24 Apr 2020 20:17:34 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id F1F721BF83C for ; Fri, 24 Apr 2020 20:17:29 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id EEE4C868A9 for ; Fri, 24 Apr 2020 20:17:29 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id HCKYskyz6yPj for ; Fri, 24 Apr 2020 20:17:28 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by fraxinus.osuosl.org (Postfix) with ESMTPS id B189686B89 for ; Fri, 24 Apr 2020 20:17:28 +0000 (UTC) IronPort-SDR: cB2p7ocYMgSBrWwSNZWS0fn674EqcrcApriKQWZ7z1H6IX7C2DexYGwCDY8ezDonWwLMjH30VT bxzjR0buhMNw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2020 13:17:28 -0700 IronPort-SDR: 4I8tNb1SqJo1aYzd/SfDEARWBI0I6n8RW1W1KZtNDtBTytPWCyn3hJvi6ICDaNIWxXO7ojIfKk dCwW51/w4W7Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,313,1583222400"; d="scan'208";a="335474517" Received: from kleandre-mobl.amr.corp.intel.com ([10.213.164.39]) by orsmga001.jf.intel.com with ESMTP; 24 Apr 2020 13:17:27 -0700 From: Andre Guedes To: intel-wired-lan@lists.osuosl.org Date: Fri, 24 Apr 2020 13:16:16 -0700 Message-Id: <20200424201623.10971-13-andre.guedes@intel.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200424201623.10971-1-andre.guedes@intel.com> References: <20200424201623.10971-1-andre.guedes@intel.com> MIME-Version: 1.0 Subject: [Intel-wired-lan] [PATCH 12/19] igc: Fix NFC rules with multicast addresses 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" Multicast MAC addresses are valid address for NFC rules but igc_add_mac_filter() is currently rejecting them. In fact, the I225 controller doesn't impose any constraint on the address value so this patch gets rid of the address validation check in MAC filter APIs. Signed-off-by: Andre Guedes Tested-by: Aaron Brown --- drivers/net/ethernet/intel/igc/igc_main.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c index 7d9a2da4feee..b0c4206f9c7d 100644 --- a/drivers/net/ethernet/intel/igc/igc_main.c +++ b/drivers/net/ethernet/intel/igc/igc_main.c @@ -2250,9 +2250,6 @@ int igc_add_mac_filter(struct igc_adapter *adapter, struct net_device *dev = adapter->netdev; int index; - if (!is_valid_ether_addr(addr)) - return -EINVAL; - index = igc_find_mac_filter(adapter, type, addr); if (index >= 0) goto update_filter; @@ -2284,9 +2281,6 @@ int igc_del_mac_filter(struct igc_adapter *adapter, struct net_device *dev = adapter->netdev; int index; - if (!is_valid_ether_addr(addr)) - return -EINVAL; - index = igc_find_mac_filter(adapter, type, addr); if (index < 0) return -ENOENT; From patchwork Fri Apr 24 20:16:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Guedes X-Patchwork-Id: 1276669 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.133; helo=hemlock.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 hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49857k11tvz9sSG for ; Sat, 25 Apr 2020 06:17:38 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 825A08872E; Fri, 24 Apr 2020 20:17:36 +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 hHI-WLQtBZk3; Fri, 24 Apr 2020 20:17:35 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id CD60888723; Fri, 24 Apr 2020 20:17:35 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 137C31BF83C for ; Fri, 24 Apr 2020 20:17:31 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 104A0868A9 for ; Fri, 24 Apr 2020 20:17:31 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id n9GGdxYPBqjl for ; Fri, 24 Apr 2020 20:17:29 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by fraxinus.osuosl.org (Postfix) with ESMTPS id D8208868C9 for ; Fri, 24 Apr 2020 20:17:28 +0000 (UTC) IronPort-SDR: qzGswhDC2KaR/S/3OuvTSX8lOZugtxH0aV2R9r+OJqF+X+xn67Qe3fV4lprSM0M7aUEEDg4IrS 2ivHeHRt88aQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2020 13:17:28 -0700 IronPort-SDR: GhZcn5qdrOJ1rfcqm8Z1Or4SoErvee5gOIn0Yx8hhtksOmGH68vgqCROPeGiE/bM0v/yXyeLWu KD5b9qY9N6WQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,313,1583222400"; d="scan'208";a="335474518" Received: from kleandre-mobl.amr.corp.intel.com ([10.213.164.39]) by orsmga001.jf.intel.com with ESMTP; 24 Apr 2020 13:17:28 -0700 From: Andre Guedes To: intel-wired-lan@lists.osuosl.org Date: Fri, 24 Apr 2020 13:16:17 -0700 Message-Id: <20200424201623.10971-14-andre.guedes@intel.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200424201623.10971-1-andre.guedes@intel.com> References: <20200424201623.10971-1-andre.guedes@intel.com> MIME-Version: 1.0 Subject: [Intel-wired-lan] [PATCH 13/19] igc: Fix NFC rules restoration 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" When network interface is brought up, the driver re-enables the NFC rules previously configured. However, this is done in reverse order the rules were added and hardware filters are configured differently. For example, consider the following rules: $ ethtool -N eth0 flow-type ether dst 00:00:00:00:00:AA queue 0 $ ethtool -N eth0 flow-type ether dst 00:00:00:00:00:BB queue 1 $ ethtool -N eth0 flow-type ether dst 00:00:00:00:00:CC queue 2 $ ethtool -N eth0 flow-type ether dst 00:00:00:00:00:DD queue 3 RAL/RAH registers are configure so filter index 1 has address ending with AA, filter index 2 has address ending in BB, and so on. If we bring the interface down and up again, RAL/RAH registers are configured so filter index 1 has address ending in DD, filter index 2 has CC, and so on. IOW, in reverse order we had before bringing the interface down. This issue can be fixed by traversing adapter->nfc_rule_list in backwards when restoring the rules. Since hlist doesn't support backwards traversal, this patch replaces it by list_head and fixes igc_restore_nfc_rules() accordingly. Signed-off-by: Andre Guedes Tested-by: Aaron Brown --- drivers/net/ethernet/intel/igc/igc.h | 4 ++-- drivers/net/ethernet/intel/igc/igc_ethtool.c | 19 ++++++++----------- drivers/net/ethernet/intel/igc/igc_main.c | 16 +++++++++------- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/drivers/net/ethernet/intel/igc/igc.h b/drivers/net/ethernet/intel/igc/igc.h index ae7d48070ee2..76bc3a51ad70 100644 --- a/drivers/net/ethernet/intel/igc/igc.h +++ b/drivers/net/ethernet/intel/igc/igc.h @@ -191,7 +191,7 @@ struct igc_adapter { * nfc_rule_lock. */ spinlock_t nfc_rule_lock; - struct hlist_head nfc_rule_list; + struct list_head nfc_rule_list; unsigned int nfc_rule_count; u8 rss_indir_tbl[IGC_RETA_SIZE]; @@ -461,7 +461,7 @@ struct igc_nfc_filter { }; struct igc_nfc_rule { - struct hlist_node nfc_node; + struct list_head list; struct igc_nfc_filter filter; u32 location; u16 action; diff --git a/drivers/net/ethernet/intel/igc/igc_ethtool.c b/drivers/net/ethernet/intel/igc/igc_ethtool.c index e975efea4a15..944cad748e61 100644 --- a/drivers/net/ethernet/intel/igc/igc_ethtool.c +++ b/drivers/net/ethernet/intel/igc/igc_ethtool.c @@ -941,7 +941,7 @@ static int igc_ethtool_get_nfc_rule(struct igc_adapter *adapter, spin_lock(&adapter->nfc_rule_lock); - hlist_for_each_entry(rule, &adapter->nfc_rule_list, nfc_node) { + list_for_each_entry(rule, &adapter->nfc_rule_list, list) { if (fsp->location <= rule->location) break; } @@ -997,7 +997,7 @@ static int igc_ethtool_get_nfc_rules(struct igc_adapter *adapter, spin_lock(&adapter->nfc_rule_lock); - hlist_for_each_entry(rule, &adapter->nfc_rule_list, nfc_node) { + list_for_each_entry(rule, &adapter->nfc_rule_list, list) { if (cnt == cmd->rule_cnt) { spin_unlock(&adapter->nfc_rule_lock); return -EMSGSIZE; @@ -1261,7 +1261,7 @@ static int igc_ethtool_update_nfc_rule(struct igc_adapter *adapter, parent = NULL; rule = NULL; - hlist_for_each_entry(rule, &adapter->nfc_rule_list, nfc_node) { + list_for_each_entry(rule, &adapter->nfc_rule_list, list) { /* hash found, or no matching entry */ if (rule->location >= location) break; @@ -1272,7 +1272,7 @@ static int igc_ethtool_update_nfc_rule(struct igc_adapter *adapter, if (rule && rule->location == location) { err = igc_disable_nfc_rule(adapter, rule); - hlist_del(&rule->nfc_node); + list_del(&rule->list); kfree(rule); adapter->nfc_rule_count--; } @@ -1283,11 +1283,8 @@ static int igc_ethtool_update_nfc_rule(struct igc_adapter *adapter, if (!input) return err; - /* add filter to the list */ - if (parent) - hlist_add_behind(&input->nfc_node, &parent->nfc_node); - else - hlist_add_head(&input->nfc_node, &adapter->nfc_rule_list); + list_add(&input->list, parent ? &parent->list : + &adapter->nfc_rule_list); /* update counts */ adapter->nfc_rule_count++; @@ -1298,7 +1295,7 @@ static int igc_ethtool_update_nfc_rule(struct igc_adapter *adapter, static void igc_ethtool_init_nfc_rule(struct igc_nfc_rule *rule, const struct ethtool_rx_flow_spec *fsp) { - INIT_HLIST_NODE(&rule->nfc_node); + INIT_LIST_HEAD(&rule->list); rule->action = fsp->ring_cookie; rule->location = fsp->location; @@ -1362,7 +1359,7 @@ static int igc_ethtool_check_nfc_rule(struct igc_adapter *adapter, return -EOPNOTSUPP; } - hlist_for_each_entry(tmp, &adapter->nfc_rule_list, nfc_node) { + list_for_each_entry(tmp, &adapter->nfc_rule_list, list) { if (!memcmp(&rule->filter, &tmp->filter, sizeof(rule->filter))) { netdev_dbg(dev, "Rule already exists"); diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c index b0c4206f9c7d..1b554b3a63c2 100644 --- a/drivers/net/ethernet/intel/igc/igc_main.c +++ b/drivers/net/ethernet/intel/igc/igc_main.c @@ -2181,7 +2181,7 @@ static void igc_restore_nfc_rules(struct igc_adapter *adapter) spin_lock(&adapter->nfc_rule_lock); - hlist_for_each_entry(rule, &adapter->nfc_rule_list, nfc_node) + list_for_each_entry_reverse(rule, &adapter->nfc_rule_list, list) igc_enable_nfc_rule(adapter, rule); spin_unlock(&adapter->nfc_rule_lock); @@ -3420,6 +3420,9 @@ static int igc_sw_init(struct igc_adapter *adapter) adapter->min_frame_size = ETH_ZLEN + ETH_FCS_LEN; spin_lock_init(&adapter->nfc_rule_lock); + INIT_LIST_HEAD(&adapter->nfc_rule_list); + adapter->nfc_rule_count = 0; + spin_lock_init(&adapter->stats64_lock); /* Assume MSI-X interrupts, will be checked during IRQ allocation */ adapter->flags |= IGC_FLAG_HAS_MSIX; @@ -3652,7 +3655,7 @@ static void igc_nfc_rule_exit(struct igc_adapter *adapter) spin_lock(&adapter->nfc_rule_lock); - hlist_for_each_entry(rule, &adapter->nfc_rule_list, nfc_node) + list_for_each_entry(rule, &adapter->nfc_rule_list, list) igc_disable_nfc_rule(adapter, rule); spin_unlock(&adapter->nfc_rule_lock); @@ -3827,14 +3830,13 @@ static int igc_set_features(struct net_device *netdev, return 0; if (!(features & NETIF_F_NTUPLE)) { - struct hlist_node *node2; - struct igc_nfc_rule *rule; + struct igc_nfc_rule *rule, *tmp; spin_lock(&adapter->nfc_rule_lock); - hlist_for_each_entry_safe(rule, node2, - &adapter->nfc_rule_list, nfc_node) { + list_for_each_entry_safe(rule, tmp, + &adapter->nfc_rule_list, list) { igc_disable_nfc_rule(adapter, rule); - hlist_del(&rule->nfc_node); + list_del(&rule->list); kfree(rule); } spin_unlock(&adapter->nfc_rule_lock); From patchwork Fri Apr 24 20:16:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Guedes X-Patchwork-Id: 1276678 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 4985802cpCz9sSG for ; Sat, 25 Apr 2020 06:17:52 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 6ABBE21519; Fri, 24 Apr 2020 20:17:50 +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 vrDN3GJEDCtF; Fri, 24 Apr 2020 20:17:40 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 2640F22851; Fri, 24 Apr 2020 20:17:35 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 304D21BF9C2 for ; Fri, 24 Apr 2020 20:17:30 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 2D27B868A9 for ; Fri, 24 Apr 2020 20:17:30 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id JFygBYAS0LBk for ; Fri, 24 Apr 2020 20:17:29 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by fraxinus.osuosl.org (Postfix) with ESMTPS id E05CE86BA9 for ; Fri, 24 Apr 2020 20:17:28 +0000 (UTC) IronPort-SDR: rud4VtJEu4mf6vQRS8XUSlFP+zRW7mh1OsN9Z2vyn6UUgexSvh+NDSZDAKM9h68WfZl6MJZWRJ XAVP1xNLBxFw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2020 13:17:28 -0700 IronPort-SDR: L5P+LlqYNzgNHU/h8NEazdaePqKG6rjVP6Lyldb8+KHtpg9iP66vS3y+UtCOQCTQCIeRevC3rr zkFdktifFITA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,313,1583222400"; d="scan'208";a="335474520" Received: from kleandre-mobl.amr.corp.intel.com ([10.213.164.39]) by orsmga001.jf.intel.com with ESMTP; 24 Apr 2020 13:17:28 -0700 From: Andre Guedes To: intel-wired-lan@lists.osuosl.org Date: Fri, 24 Apr 2020 13:16:18 -0700 Message-Id: <20200424201623.10971-15-andre.guedes@intel.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200424201623.10971-1-andre.guedes@intel.com> References: <20200424201623.10971-1-andre.guedes@intel.com> MIME-Version: 1.0 Subject: [Intel-wired-lan] [PATCH 14/19] igc: Refactor igc_ethtool_update_nfc_rule() 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 implementation of igc_ethtool_update_nfc_rule() is a bit convoluted since it handles too many things: rule lookup, deletion and addition. This patch breaks it into three functions so we simplify the code and improve code reuse. Code related to rule lookup is refactored out to a new function called igc_get_nfc_rule(). Code related to rule addition is refactored out to a new function called igc_add_nfc_rule(). This function enables the rule in hardware and adds it to the adapter's list. Code related to rule deletion is refactored out to a new function called igc_del_nfc_rule(). This function disables the rule in hardware, removes it from adapter's list, and deletes it. As a byproduct of this refactoring, igc_enable_nfc_rule() and igc_disable_nfc_rule() are moved to igc_main.c since they are not used in igc_ethtool.c anymore, and igc_restore_nfc_rules() and igc_nfc_rule_ exit() are moved around to avoid forward declaration. Also, since this patch already touches igc_ethtool_get_nfc_rule(), it takes the opportunity to remove the 'match_flags' check. Empty flags are not allowed to be added so no need to check that. Signed-off-by: Andre Guedes Tested-by: Aaron Brown --- drivers/net/ethernet/intel/igc/igc.h | 18 +- drivers/net/ethernet/intel/igc/igc_ethtool.c | 138 ++----------- drivers/net/ethernet/intel/igc/igc_main.c | 205 ++++++++++++++++--- 3 files changed, 195 insertions(+), 166 deletions(-) diff --git a/drivers/net/ethernet/intel/igc/igc.h b/drivers/net/ethernet/intel/igc/igc.h index 76bc3a51ad70..a484b328268b 100644 --- a/drivers/net/ethernet/intel/igc/igc.h +++ b/drivers/net/ethernet/intel/igc/igc.h @@ -232,16 +232,6 @@ void igc_write_rss_indir_tbl(struct igc_adapter *adapter); bool igc_has_link(struct igc_adapter *adapter); void igc_reset(struct igc_adapter *adapter); int igc_set_spd_dplx(struct igc_adapter *adapter, u32 spd, u8 dplx); -int igc_add_mac_filter(struct igc_adapter *adapter, - enum igc_mac_filter_type type, const u8 *addr, - int queue); -int igc_del_mac_filter(struct igc_adapter *adapter, - enum igc_mac_filter_type type, const u8 *addr); -int igc_add_vlan_prio_filter(struct igc_adapter *adapter, int prio, - int queue); -void igc_del_vlan_prio_filter(struct igc_adapter *adapter, int prio); -int igc_add_etype_filter(struct igc_adapter *adapter, u16 etype, int queue); -int igc_del_etype_filter(struct igc_adapter *adapter, u16 etype); void igc_update_stats(struct igc_adapter *adapter); /* igc_dump declarations */ @@ -544,10 +534,10 @@ static inline s32 igc_read_phy_reg(struct igc_hw *hw, u32 offset, u16 *data) } void igc_reinit_locked(struct igc_adapter *); -int igc_enable_nfc_rule(struct igc_adapter *adapter, - const struct igc_nfc_rule *rule); -int igc_disable_nfc_rule(struct igc_adapter *adapter, - const struct igc_nfc_rule *rule); +struct igc_nfc_rule *igc_get_nfc_rule(struct igc_adapter *adapter, + u32 location); +int igc_add_nfc_rule(struct igc_adapter *adapter, struct igc_nfc_rule *rule); +void igc_del_nfc_rule(struct igc_adapter *adapter, struct igc_nfc_rule *rule); void igc_ptp_init(struct igc_adapter *adapter); void igc_ptp_reset(struct igc_adapter *adapter); diff --git a/drivers/net/ethernet/intel/igc/igc_ethtool.c b/drivers/net/ethernet/intel/igc/igc_ethtool.c index 944cad748e61..de9ab3c8179a 100644 --- a/drivers/net/ethernet/intel/igc/igc_ethtool.c +++ b/drivers/net/ethernet/intel/igc/igc_ethtool.c @@ -941,15 +941,8 @@ static int igc_ethtool_get_nfc_rule(struct igc_adapter *adapter, spin_lock(&adapter->nfc_rule_lock); - list_for_each_entry(rule, &adapter->nfc_rule_list, list) { - if (fsp->location <= rule->location) - break; - } - - if (!rule || fsp->location != rule->location) - goto out; - - if (!rule->filter.match_flags) + rule = igc_get_nfc_rule(adapter, fsp->location); + if (!rule) goto out; fsp->flow_type = ETHER_FLOW; @@ -1190,108 +1183,6 @@ static int igc_ethtool_set_rss_hash_opt(struct igc_adapter *adapter, return 0; } -int igc_enable_nfc_rule(struct igc_adapter *adapter, - const struct igc_nfc_rule *rule) -{ - int err = -EINVAL; - - if (rule->filter.match_flags & IGC_FILTER_FLAG_ETHER_TYPE) { - err = igc_add_etype_filter(adapter, rule->filter.etype, - rule->action); - if (err) - return err; - } - - if (rule->filter.match_flags & IGC_FILTER_FLAG_SRC_MAC_ADDR) { - err = igc_add_mac_filter(adapter, IGC_MAC_FILTER_TYPE_SRC, - rule->filter.src_addr, rule->action); - if (err) - return err; - } - - if (rule->filter.match_flags & IGC_FILTER_FLAG_DST_MAC_ADDR) { - err = igc_add_mac_filter(adapter, IGC_MAC_FILTER_TYPE_DST, - rule->filter.dst_addr, rule->action); - if (err) - return err; - } - - if (rule->filter.match_flags & IGC_FILTER_FLAG_VLAN_TCI) { - int prio = (rule->filter.vlan_tci & VLAN_PRIO_MASK) - >> VLAN_PRIO_SHIFT; - - err = igc_add_vlan_prio_filter(adapter, prio, rule->action); - if (err) - return err; - } - - return 0; -} - -int igc_disable_nfc_rule(struct igc_adapter *adapter, - const struct igc_nfc_rule *rule) -{ - if (rule->filter.match_flags & IGC_FILTER_FLAG_ETHER_TYPE) - igc_del_etype_filter(adapter, rule->filter.etype); - - if (rule->filter.match_flags & IGC_FILTER_FLAG_VLAN_TCI) { - int prio = (rule->filter.vlan_tci & VLAN_PRIO_MASK) - >> VLAN_PRIO_SHIFT; - igc_del_vlan_prio_filter(adapter, prio); - } - - if (rule->filter.match_flags & IGC_FILTER_FLAG_SRC_MAC_ADDR) - igc_del_mac_filter(adapter, IGC_MAC_FILTER_TYPE_SRC, - rule->filter.src_addr); - - if (rule->filter.match_flags & IGC_FILTER_FLAG_DST_MAC_ADDR) - igc_del_mac_filter(adapter, IGC_MAC_FILTER_TYPE_DST, - rule->filter.dst_addr); - - return 0; -} - -static int igc_ethtool_update_nfc_rule(struct igc_adapter *adapter, - struct igc_nfc_rule *input, - u32 location) -{ - struct igc_nfc_rule *rule, *parent; - int err = -EINVAL; - - parent = NULL; - rule = NULL; - - list_for_each_entry(rule, &adapter->nfc_rule_list, list) { - /* hash found, or no matching entry */ - if (rule->location >= location) - break; - parent = rule; - } - - /* if there is an old rule occupying our place remove it */ - if (rule && rule->location == location) { - err = igc_disable_nfc_rule(adapter, rule); - - list_del(&rule->list); - kfree(rule); - adapter->nfc_rule_count--; - } - - /* If no input this was a delete, err should be 0 if a rule was - * successfully found and removed from the list else -EINVAL - */ - if (!input) - return err; - - list_add(&input->list, parent ? &parent->list : - &adapter->nfc_rule_list); - - /* update counts */ - adapter->nfc_rule_count++; - - return 0; -} - static void igc_ethtool_init_nfc_rule(struct igc_nfc_rule *rule, const struct ethtool_rx_flow_spec *fsp) { @@ -1376,7 +1267,7 @@ static int igc_ethtool_add_nfc_rule(struct igc_adapter *adapter, struct net_device *netdev = adapter->netdev; struct ethtool_rx_flow_spec *fsp = (struct ethtool_rx_flow_spec *)&cmd->fs; - struct igc_nfc_rule *rule; + struct igc_nfc_rule *rule, *old_rule; int err; if (!(netdev->hw_features & NETIF_F_NTUPLE)) { @@ -1417,12 +1308,14 @@ static int igc_ethtool_add_nfc_rule(struct igc_adapter *adapter, if (err) goto err; - err = igc_enable_nfc_rule(adapter, rule); + old_rule = igc_get_nfc_rule(adapter, fsp->location); + if (old_rule) + igc_del_nfc_rule(adapter, old_rule); + + err = igc_add_nfc_rule(adapter, rule); if (err) goto err; - igc_ethtool_update_nfc_rule(adapter, rule, rule->location); - spin_unlock(&adapter->nfc_rule_lock); return 0; @@ -1437,13 +1330,20 @@ static int igc_ethtool_del_nfc_rule(struct igc_adapter *adapter, { struct ethtool_rx_flow_spec *fsp = (struct ethtool_rx_flow_spec *)&cmd->fs; - int err; + struct igc_nfc_rule *rule; spin_lock(&adapter->nfc_rule_lock); - err = igc_ethtool_update_nfc_rule(adapter, NULL, fsp->location); - spin_unlock(&adapter->nfc_rule_lock); - return err; + rule = igc_get_nfc_rule(adapter, fsp->location); + if (!rule) { + spin_unlock(&adapter->nfc_rule_lock); + return -EINVAL; + } + + igc_del_nfc_rule(adapter, rule); + + spin_unlock(&adapter->nfc_rule_lock); + return 0; } static int igc_ethtool_set_rxnfc(struct net_device *dev, diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c index 1b554b3a63c2..e09d74331257 100644 --- a/drivers/net/ethernet/intel/igc/igc_main.c +++ b/drivers/net/ethernet/intel/igc/igc_main.c @@ -2175,18 +2175,6 @@ static bool igc_clean_tx_irq(struct igc_q_vector *q_vector, int napi_budget) return !!budget; } -static void igc_restore_nfc_rules(struct igc_adapter *adapter) -{ - struct igc_nfc_rule *rule; - - spin_lock(&adapter->nfc_rule_lock); - - list_for_each_entry_reverse(rule, &adapter->nfc_rule_list, list) - igc_enable_nfc_rule(adapter, rule); - - spin_unlock(&adapter->nfc_rule_lock); -} - static int igc_find_mac_filter(struct igc_adapter *adapter, enum igc_mac_filter_type type, const u8 *addr) { @@ -2243,9 +2231,9 @@ static int igc_get_avail_mac_filter_slot(struct igc_adapter *adapter) * * Return: 0 in case of success, negative errno code otherwise. */ -int igc_add_mac_filter(struct igc_adapter *adapter, - enum igc_mac_filter_type type, const u8 *addr, - int queue) +static int igc_add_mac_filter(struct igc_adapter *adapter, + enum igc_mac_filter_type type, const u8 *addr, + int queue) { struct net_device *dev = adapter->netdev; int index; @@ -2275,8 +2263,8 @@ int igc_add_mac_filter(struct igc_adapter *adapter, * * Return: 0 in case of success, negative errno code otherwise. */ -int igc_del_mac_filter(struct igc_adapter *adapter, - enum igc_mac_filter_type type, const u8 *addr) +static int igc_del_mac_filter(struct igc_adapter *adapter, + enum igc_mac_filter_type type, const u8 *addr) { struct net_device *dev = adapter->netdev; int index; @@ -2313,7 +2301,8 @@ int igc_del_mac_filter(struct igc_adapter *adapter, * * Return: 0 in case of success, negative errno code otherwise. */ -int igc_add_vlan_prio_filter(struct igc_adapter *adapter, int prio, int queue) +static int igc_add_vlan_prio_filter(struct igc_adapter *adapter, int prio, + int queue) { struct net_device *dev = adapter->netdev; struct igc_hw *hw = &adapter->hw; @@ -2341,7 +2330,7 @@ int igc_add_vlan_prio_filter(struct igc_adapter *adapter, int prio, int queue) * @adapter: Pointer to adapter where the filter should be deleted from. * @prio: VLAN priority value. */ -void igc_del_vlan_prio_filter(struct igc_adapter *adapter, int prio) +static void igc_del_vlan_prio_filter(struct igc_adapter *adapter, int prio) { struct igc_hw *hw = &adapter->hw; u32 vlanpqf; @@ -2382,7 +2371,8 @@ static int igc_get_avail_etype_filter_slot(struct igc_adapter *adapter) * * Return: 0 in case of success, negative errno code otherwise. */ -int igc_add_etype_filter(struct igc_adapter *adapter, u16 etype, int queue) +static int igc_add_etype_filter(struct igc_adapter *adapter, u16 etype, + int queue) { struct igc_hw *hw = &adapter->hw; int index; @@ -2434,7 +2424,7 @@ static int igc_find_etype_filter(struct igc_adapter *adapter, u16 etype) * * Return: 0 in case of success, negative errno code otherwise. */ -int igc_del_etype_filter(struct igc_adapter *adapter, u16 etype) +static int igc_del_etype_filter(struct igc_adapter *adapter, u16 etype) { struct igc_hw *hw = &adapter->hw; int index; @@ -2450,6 +2440,167 @@ int igc_del_etype_filter(struct igc_adapter *adapter, u16 etype) return 0; } +static int igc_enable_nfc_rule(struct igc_adapter *adapter, + const struct igc_nfc_rule *rule) +{ + int err; + + if (rule->filter.match_flags & IGC_FILTER_FLAG_ETHER_TYPE) { + err = igc_add_etype_filter(adapter, rule->filter.etype, + rule->action); + if (err) + return err; + } + + if (rule->filter.match_flags & IGC_FILTER_FLAG_SRC_MAC_ADDR) { + err = igc_add_mac_filter(adapter, IGC_MAC_FILTER_TYPE_SRC, + rule->filter.src_addr, rule->action); + if (err) + return err; + } + + if (rule->filter.match_flags & IGC_FILTER_FLAG_DST_MAC_ADDR) { + err = igc_add_mac_filter(adapter, IGC_MAC_FILTER_TYPE_DST, + rule->filter.dst_addr, rule->action); + if (err) + return err; + } + + if (rule->filter.match_flags & IGC_FILTER_FLAG_VLAN_TCI) { + int prio = (rule->filter.vlan_tci & VLAN_PRIO_MASK) + >> VLAN_PRIO_SHIFT; + + err = igc_add_vlan_prio_filter(adapter, prio, rule->action); + if (err) + return err; + } + + return 0; +} + +static int igc_disable_nfc_rule(struct igc_adapter *adapter, + const struct igc_nfc_rule *rule) +{ + if (rule->filter.match_flags & IGC_FILTER_FLAG_ETHER_TYPE) + igc_del_etype_filter(adapter, rule->filter.etype); + + if (rule->filter.match_flags & IGC_FILTER_FLAG_VLAN_TCI) { + int prio = (rule->filter.vlan_tci & VLAN_PRIO_MASK) + >> VLAN_PRIO_SHIFT; + + igc_del_vlan_prio_filter(adapter, prio); + } + + if (rule->filter.match_flags & IGC_FILTER_FLAG_SRC_MAC_ADDR) + igc_del_mac_filter(adapter, IGC_MAC_FILTER_TYPE_SRC, + rule->filter.src_addr); + + if (rule->filter.match_flags & IGC_FILTER_FLAG_DST_MAC_ADDR) + igc_del_mac_filter(adapter, IGC_MAC_FILTER_TYPE_DST, + rule->filter.dst_addr); + + return 0; +} + +/** + * igc_get_nfc_rule() - Get NFC rule. + * @adapter: Pointer to adapter. + * @location: Rule location. + * + * Context: Expects adapter->nfc_rule_lock to be held by caller. + * + * Return: Pointer to NFC rule at @location. If not found, NULL. + */ +struct igc_nfc_rule *igc_get_nfc_rule(struct igc_adapter *adapter, + u32 location) +{ + struct igc_nfc_rule *rule; + + list_for_each_entry(rule, &adapter->nfc_rule_list, list) { + if (rule->location == location) + return rule; + if (rule->location > location) + break; + } + + return NULL; +} + +/** + * igc_del_nfc_rule() - Delete NFC rule. + * @adapter: Pointer to adapter. + * @rule: Pointer to rule to be deleted. + * + * Disable NFC rule in hardware and delete it from adapter. + * + * Context: Expects adapter->nfc_rule_lock to be held by caller. + */ +void igc_del_nfc_rule(struct igc_adapter *adapter, struct igc_nfc_rule *rule) +{ + igc_disable_nfc_rule(adapter, rule); + + list_del(&rule->list); + adapter->nfc_rule_count--; + + kfree(rule); +} + +/** + * igc_add_nfc_rule() - Add NFC rule. + * @adapter: Pointer to adapter. + * @rule: Pointer to rule to be added. + * + * Enable NFC rule in hardware and add it to adapter. + * + * Context: Expects adapter->nfc_rule_lock to be held by caller. + * + * Return: 0 on success, negative errno on failure. + */ +int igc_add_nfc_rule(struct igc_adapter *adapter, struct igc_nfc_rule *rule) +{ + struct igc_nfc_rule *pred, *cur; + int err; + + err = igc_enable_nfc_rule(adapter, rule); + if (err) + return err; + + pred = NULL; + list_for_each_entry(cur, &adapter->nfc_rule_list, list) { + if (cur->location >= rule->location) + break; + pred = cur; + } + + list_add(&rule->list, pred ? &pred->list : &adapter->nfc_rule_list); + adapter->nfc_rule_count++; + return 0; +} + +static void igc_restore_nfc_rules(struct igc_adapter *adapter) +{ + struct igc_nfc_rule *rule; + + spin_lock(&adapter->nfc_rule_lock); + + list_for_each_entry_reverse(rule, &adapter->nfc_rule_list, list) + igc_enable_nfc_rule(adapter, rule); + + spin_unlock(&adapter->nfc_rule_lock); +} + +static void igc_nfc_rule_exit(struct igc_adapter *adapter) +{ + struct igc_nfc_rule *rule; + + spin_lock(&adapter->nfc_rule_lock); + + list_for_each_entry(rule, &adapter->nfc_rule_list, list) + igc_disable_nfc_rule(adapter, rule); + + spin_unlock(&adapter->nfc_rule_lock); +} + static int igc_uc_sync(struct net_device *netdev, const unsigned char *addr) { struct igc_adapter *adapter = netdev_priv(netdev); @@ -3649,18 +3800,6 @@ void igc_update_stats(struct igc_adapter *adapter) adapter->stats.mgpdc += rd32(IGC_MGTPDC); } -static void igc_nfc_rule_exit(struct igc_adapter *adapter) -{ - struct igc_nfc_rule *rule; - - spin_lock(&adapter->nfc_rule_lock); - - list_for_each_entry(rule, &adapter->nfc_rule_list, list) - igc_disable_nfc_rule(adapter, rule); - - spin_unlock(&adapter->nfc_rule_lock); -} - /** * igc_down - Close the interface * @adapter: board private structure From patchwork Fri Apr 24 20:16:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Guedes X-Patchwork-Id: 1276672 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.137; helo=fraxinus.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 fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49857q6Dd7z9sSd for ; Sat, 25 Apr 2020 06:17:43 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 42852868A9; Fri, 24 Apr 2020 20:17:42 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mUstwowf0FTz; Fri, 24 Apr 2020 20:17:41 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id BB6C386B59; Fri, 24 Apr 2020 20:17:41 +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 82DC01BF83C for ; Fri, 24 Apr 2020 20:17:32 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 7E38C87FCC for ; Fri, 24 Apr 2020 20:17:32 +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 Fw8feYW3Difg for ; Fri, 24 Apr 2020 20:17:30 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by whitealder.osuosl.org (Postfix) with ESMTPS id 804DB87FEA for ; Fri, 24 Apr 2020 20:17:29 +0000 (UTC) IronPort-SDR: a052hZaPiZxAAHebYHCd0mHJvAAHnCyVUHhBXRtxQHzJtmuVqpPsVZd+J3nq4K1FHGbMhLelum eTti8C2vFPvw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2020 13:17:28 -0700 IronPort-SDR: 83t1QgCc8hTmTpFWXZnOYcC5WVaJkaEXN3S5LmvTtdJ+JKnLnQ0DiMtizpm+4HDQuvtSPbjHx2 1P+SkmfgGHtQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,313,1583222400"; d="scan'208";a="335474522" Received: from kleandre-mobl.amr.corp.intel.com ([10.213.164.39]) by orsmga001.jf.intel.com with ESMTP; 24 Apr 2020 13:17:28 -0700 From: Andre Guedes To: intel-wired-lan@lists.osuosl.org Date: Fri, 24 Apr 2020 13:16:19 -0700 Message-Id: <20200424201623.10971-16-andre.guedes@intel.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200424201623.10971-1-andre.guedes@intel.com> References: <20200424201623.10971-1-andre.guedes@intel.com> MIME-Version: 1.0 Subject: [Intel-wired-lan] [PATCH 15/19] igc: Fix NFC rules leak when driver is unloaded 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" If we have RFC rules in adapter->nfc_rule_list when the IGC driver is unloaded, all rules are leaked. This patch fixes the issue by introducing the helper igc_flush_nfc_rules() and calling it in igc_remove(). It also updates igc_set_features() so is reuses the new helper instead of re-implementing it. Signed-off-by: Andre Guedes Tested-by: Aaron Brown --- drivers/net/ethernet/intel/igc/igc_main.c | 29 +++++++++++++---------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c index e09d74331257..64e372f38c6b 100644 --- a/drivers/net/ethernet/intel/igc/igc_main.c +++ b/drivers/net/ethernet/intel/igc/igc_main.c @@ -2545,6 +2545,18 @@ void igc_del_nfc_rule(struct igc_adapter *adapter, struct igc_nfc_rule *rule) kfree(rule); } +static void igc_flush_nfc_rules(struct igc_adapter *adapter) +{ + struct igc_nfc_rule *rule, *tmp; + + spin_lock(&adapter->nfc_rule_lock); + + list_for_each_entry_safe(rule, tmp, &adapter->nfc_rule_list, list) + igc_del_nfc_rule(adapter, rule); + + spin_unlock(&adapter->nfc_rule_lock); +} + /** * igc_add_nfc_rule() - Add NFC rule. * @adapter: Pointer to adapter. @@ -3968,19 +3980,8 @@ static int igc_set_features(struct net_device *netdev, if (!(changed & (NETIF_F_RXALL | NETIF_F_NTUPLE))) return 0; - if (!(features & NETIF_F_NTUPLE)) { - struct igc_nfc_rule *rule, *tmp; - - spin_lock(&adapter->nfc_rule_lock); - list_for_each_entry_safe(rule, tmp, - &adapter->nfc_rule_list, list) { - igc_disable_nfc_rule(adapter, rule); - list_del(&rule->list); - kfree(rule); - } - spin_unlock(&adapter->nfc_rule_lock); - adapter->nfc_rule_count = 0; - } + if (!(features & NETIF_F_NTUPLE)) + igc_flush_nfc_rules(adapter); netdev->features = features; @@ -5250,6 +5251,8 @@ static void igc_remove(struct pci_dev *pdev) pm_runtime_get_noresume(&pdev->dev); + igc_flush_nfc_rules(adapter); + igc_ptp_stop(adapter); set_bit(__IGC_DOWN, &adapter->state); From patchwork Fri Apr 24 20:16:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Guedes X-Patchwork-Id: 1276673 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.137; helo=fraxinus.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 fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49857r4MByz9sSG for ; Sat, 25 Apr 2020 06:17:44 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 3398486D78; Fri, 24 Apr 2020 20:17:43 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZUIQANNLT5LM; Fri, 24 Apr 2020 20:17:42 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id B0C5986C7A; Fri, 24 Apr 2020 20:17:42 +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 848A81BF83C for ; Fri, 24 Apr 2020 20:17:35 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 6F64687F94 for ; Fri, 24 Apr 2020 20:17:35 +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 Gj6J6tjCqy6s for ; Fri, 24 Apr 2020 20:17:30 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by whitealder.osuosl.org (Postfix) with ESMTPS id AC4FF87FED for ; Fri, 24 Apr 2020 20:17:29 +0000 (UTC) IronPort-SDR: du274H7SiaT/Mvhi7MDqQufgx/9Oh4UDRrVpRYu95jFtmqPCdZTfgBWcX4+lIuUzaPxWyFRHLo rR8PD/yb2bgg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2020 13:17:29 -0700 IronPort-SDR: 9gT3KZT1Xxz/M2i7+hGM1vWB8AQIvMctQrV9am0KHG3DbOEK8KYmbZDuPUp1xULL8vgWxVUrfS H3yJ73PFqsEw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,313,1583222400"; d="scan'208";a="335474524" Received: from kleandre-mobl.amr.corp.intel.com ([10.213.164.39]) by orsmga001.jf.intel.com with ESMTP; 24 Apr 2020 13:17:28 -0700 From: Andre Guedes To: intel-wired-lan@lists.osuosl.org Date: Fri, 24 Apr 2020 13:16:20 -0700 Message-Id: <20200424201623.10971-17-andre.guedes@intel.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200424201623.10971-1-andre.guedes@intel.com> References: <20200424201623.10971-1-andre.guedes@intel.com> MIME-Version: 1.0 Subject: [Intel-wired-lan] [PATCH 16/19] igc: Fix NFC rule validation 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" If we try to overwrite an existing rule with the same filter but different action, we get EEXIST error as shown below. $ ethtool -N eth0 flow-type ether dst action 1 loc 10 $ ethtool -N eth0 flow-type ether dst action 2 loc 10 rmgr: Cannot insert RX class rule: File exists The second command is expected to overwrite the previous rule in location 10 and succeed. This patch fixes igc_ethtool_check_nfc_rule() so it also checks the rules location. In case they match, the rule under evaluation should not be considered invalid. Signed-off-by: Andre Guedes Tested-by: Aaron Brown --- drivers/net/ethernet/intel/igc/igc_ethtool.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/intel/igc/igc_ethtool.c b/drivers/net/ethernet/intel/igc/igc_ethtool.c index de9ab3c8179a..32bc77af71dd 100644 --- a/drivers/net/ethernet/intel/igc/igc_ethtool.c +++ b/drivers/net/ethernet/intel/igc/igc_ethtool.c @@ -1225,8 +1225,8 @@ static void igc_ethtool_init_nfc_rule(struct igc_nfc_rule *rule, * Rules with both destination and source MAC addresses are considered invalid * since the driver doesn't support them. * - * Also, if there is already another rule with the same filter, @rule is - * considered invalid. + * Also, if there is already another rule with the same filter in a different + * location, @rule is considered invalid. * * Context: Expects adapter->nfc_rule_lock to be held by caller. * @@ -1252,7 +1252,8 @@ static int igc_ethtool_check_nfc_rule(struct igc_adapter *adapter, list_for_each_entry(tmp, &adapter->nfc_rule_list, list) { if (!memcmp(&rule->filter, &tmp->filter, - sizeof(rule->filter))) { + sizeof(rule->filter)) && + tmp->location != rule->location) { netdev_dbg(dev, "Rule already exists"); return -EEXIST; } From patchwork Fri Apr 24 20:16:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Guedes X-Patchwork-Id: 1276674 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.138; helo=whitealder.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 whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49857s34QZz9sSd for ; Sat, 25 Apr 2020 06:17:45 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id C863587FD6; Fri, 24 Apr 2020 20:17:43 +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 3hMap4xRaMTZ; Fri, 24 Apr 2020 20:17:42 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id 11F0387F92; Fri, 24 Apr 2020 20:17:42 +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 8FE9F1BF83C for ; Fri, 24 Apr 2020 20:17:33 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 8C8928803D for ; Fri, 24 Apr 2020 20:17:33 +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 VfyrXC6f3exc for ; Fri, 24 Apr 2020 20:17:30 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by whitealder.osuosl.org (Postfix) with ESMTPS id D80F188005 for ; Fri, 24 Apr 2020 20:17:29 +0000 (UTC) IronPort-SDR: Wob5vgvSiFTwXSTkfJW6k1eXFGGvnM4kyo/z5Dx6XEnD1rOTsi2Bn6GpbzvbPD0cwwyDVA9i57 qoGDKJbwd4rg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2020 13:17:29 -0700 IronPort-SDR: 66GEftB/VnoZWnfeceGq/fnhQ3Ds0RcTi7DvR+x0gDsW+JvCEoqWUzp047R3ZnCHddeKHDaiiC 1F7GKKOSm75g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,313,1583222400"; d="scan'208";a="335474525" Received: from kleandre-mobl.amr.corp.intel.com ([10.213.164.39]) by orsmga001.jf.intel.com with ESMTP; 24 Apr 2020 13:17:29 -0700 From: Andre Guedes To: intel-wired-lan@lists.osuosl.org Date: Fri, 24 Apr 2020 13:16:21 -0700 Message-Id: <20200424201623.10971-18-andre.guedes@intel.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200424201623.10971-1-andre.guedes@intel.com> References: <20200424201623.10971-1-andre.guedes@intel.com> MIME-Version: 1.0 Subject: [Intel-wired-lan] [PATCH 17/19] igc: Change return type from igc_disable_nfc_rule() 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" None of igc_disable_nfc_rule() callers actually check its returning value. A closer look at why this function would fail shows that the only situation is when we try to delete an ethertype or mac filter that doesn't exist. That situation is very unlikely so we can change igc_del_etype_filter() and igc_del_mac_filter() logic to "if the filter doesn't exist, we are done", and keep the logic in igc_disable_nfc_rule() callers simple. Signed-off-by: Andre Guedes Tested-by: Aaron Brown --- drivers/net/ethernet/intel/igc/igc_main.c | 26 ++++++++--------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c index 64e372f38c6b..134523064fe9 100644 --- a/drivers/net/ethernet/intel/igc/igc_main.c +++ b/drivers/net/ethernet/intel/igc/igc_main.c @@ -2260,18 +2260,16 @@ static int igc_add_mac_filter(struct igc_adapter *adapter, * @adapter: Pointer to adapter where the filter should be deleted from * @type: MAC address filter type (source or destination) * @addr: MAC address - * - * Return: 0 in case of success, negative errno code otherwise. */ -static int igc_del_mac_filter(struct igc_adapter *adapter, - enum igc_mac_filter_type type, const u8 *addr) +static void igc_del_mac_filter(struct igc_adapter *adapter, + enum igc_mac_filter_type type, const u8 *addr) { struct net_device *dev = adapter->netdev; int index; index = igc_find_mac_filter(adapter, type, addr); if (index < 0) - return -ENOENT; + return; if (index == 0) { /* If this is the default filter, we don't actually delete it. @@ -2289,8 +2287,6 @@ static int igc_del_mac_filter(struct igc_adapter *adapter, igc_clear_mac_filter_hw(adapter, index); } - - return 0; } /** @@ -2421,23 +2417,20 @@ static int igc_find_etype_filter(struct igc_adapter *adapter, u16 etype) * igc_del_etype_filter() - Delete ethertype filter. * @adapter: Pointer to adapter where the filter should be deleted from. * @etype: Ethertype value. - * - * Return: 0 in case of success, negative errno code otherwise. */ -static int igc_del_etype_filter(struct igc_adapter *adapter, u16 etype) +static void igc_del_etype_filter(struct igc_adapter *adapter, u16 etype) { struct igc_hw *hw = &adapter->hw; int index; index = igc_find_etype_filter(adapter, etype); if (index < 0) - return -ENOENT; + return; wr32(IGC_ETQF(index), 0); netdev_dbg(adapter->netdev, "Delete ethertype filter: etype %04x", etype); - return 0; } static int igc_enable_nfc_rule(struct igc_adapter *adapter, @@ -2478,8 +2471,8 @@ static int igc_enable_nfc_rule(struct igc_adapter *adapter, return 0; } -static int igc_disable_nfc_rule(struct igc_adapter *adapter, - const struct igc_nfc_rule *rule) +static void igc_disable_nfc_rule(struct igc_adapter *adapter, + const struct igc_nfc_rule *rule) { if (rule->filter.match_flags & IGC_FILTER_FLAG_ETHER_TYPE) igc_del_etype_filter(adapter, rule->filter.etype); @@ -2498,8 +2491,6 @@ static int igc_disable_nfc_rule(struct igc_adapter *adapter, if (rule->filter.match_flags & IGC_FILTER_FLAG_DST_MAC_ADDR) igc_del_mac_filter(adapter, IGC_MAC_FILTER_TYPE_DST, rule->filter.dst_addr); - - return 0; } /** @@ -2624,7 +2615,8 @@ 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, IGC_MAC_FILTER_TYPE_DST, addr); + igc_del_mac_filter(adapter, IGC_MAC_FILTER_TYPE_DST, addr); + return 0; } /** From patchwork Fri Apr 24 20:16:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Guedes X-Patchwork-Id: 1276676 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.138; helo=whitealder.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 whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49857v3dtVz9sSJ for ; Sat, 25 Apr 2020 06:17:47 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 119308756D; Fri, 24 Apr 2020 20:17:46 +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 COnXWHYpWAyI; Fri, 24 Apr 2020 20:17:44 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id 6461D88005; Fri, 24 Apr 2020 20:17:42 +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 3C4671BF83C for ; Fri, 24 Apr 2020 20:17:34 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 392F787FEF for ; Fri, 24 Apr 2020 20:17:34 +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 yc7gu90QfhrG for ; Fri, 24 Apr 2020 20:17:30 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by whitealder.osuosl.org (Postfix) with ESMTPS id 1FD7E87F94 for ; Fri, 24 Apr 2020 20:17:30 +0000 (UTC) IronPort-SDR: wsgiBNqVvQ8Y6sJHcj/LpIBORVgOSWryOo5AI9Hg6m551oCLp1sKGbbDGF0NmfwmbM5LpULYBq nKgIhBJn5pCA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2020 13:17:30 -0700 IronPort-SDR: x0ERnLCgk6e9CB0KzLzXfMvAz6xN9at2mYRjE2htCRen+HWH96W8RWJxH/7vaJ2ERpa050GWal XdYDmouYfR5w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,313,1583222400"; d="scan'208";a="335474527" Received: from kleandre-mobl.amr.corp.intel.com ([10.213.164.39]) by orsmga001.jf.intel.com with ESMTP; 24 Apr 2020 13:17:29 -0700 From: Andre Guedes To: intel-wired-lan@lists.osuosl.org Date: Fri, 24 Apr 2020 13:16:22 -0700 Message-Id: <20200424201623.10971-19-andre.guedes@intel.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200424201623.10971-1-andre.guedes@intel.com> References: <20200424201623.10971-1-andre.guedes@intel.com> MIME-Version: 1.0 Subject: [Intel-wired-lan] [PATCH 18/19] igc: Change adapter->nfc_rule_lock to mutex 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" This patch changes adapter->nfc_rule_lock type from spin_lock to mutex so we avoid unnecessary busy waiting on lock contention. A closer look at the execution context of NFC rule API users shows that all of them run in process context. The API users are: ethtool ops, igc_configure(), called when interface is brought up by user or reset workequeue thread, igc_down(), called when interface is brought down, and igc_remove(), called when driver is unloaded. Signed-off-by: Andre Guedes Tested-by: Aaron Brown Tested-by: Aaron Brown --- Note that checkpatch.pl reports an issue with this patch. The issue is a false positive. There is a comment right above that line referring to the lock. Here is the report: CHECK: struct mutex definition without comment #31: FILE: drivers/net/ethernet/intel/igc/igc.h:193: + struct mutex nfc_rule_lock; --- drivers/net/ethernet/intel/igc/igc.h | 2 +- drivers/net/ethernet/intel/igc/igc_ethtool.c | 24 ++++++++++---------- drivers/net/ethernet/intel/igc/igc_main.c | 14 ++++++------ 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/drivers/net/ethernet/intel/igc/igc.h b/drivers/net/ethernet/intel/igc/igc.h index a484b328268b..14f9edaaaf83 100644 --- a/drivers/net/ethernet/intel/igc/igc.h +++ b/drivers/net/ethernet/intel/igc/igc.h @@ -190,7 +190,7 @@ struct igc_adapter { /* Any access to elements in nfc_rule_list is protected by the * nfc_rule_lock. */ - spinlock_t nfc_rule_lock; + struct mutex nfc_rule_lock; struct list_head nfc_rule_list; unsigned int nfc_rule_count; diff --git a/drivers/net/ethernet/intel/igc/igc_ethtool.c b/drivers/net/ethernet/intel/igc/igc_ethtool.c index 32bc77af71dd..db42dc046403 100644 --- a/drivers/net/ethernet/intel/igc/igc_ethtool.c +++ b/drivers/net/ethernet/intel/igc/igc_ethtool.c @@ -939,7 +939,7 @@ static int igc_ethtool_get_nfc_rule(struct igc_adapter *adapter, cmd->data = IGC_MAX_RXNFC_RULES; - spin_lock(&adapter->nfc_rule_lock); + mutex_lock(&adapter->nfc_rule_lock); rule = igc_get_nfc_rule(adapter, fsp->location); if (!rule) @@ -971,11 +971,11 @@ static int igc_ethtool_get_nfc_rule(struct igc_adapter *adapter, eth_broadcast_addr(fsp->m_u.ether_spec.h_source); } - spin_unlock(&adapter->nfc_rule_lock); + mutex_unlock(&adapter->nfc_rule_lock); return 0; out: - spin_unlock(&adapter->nfc_rule_lock); + mutex_unlock(&adapter->nfc_rule_lock); return -EINVAL; } @@ -988,18 +988,18 @@ static int igc_ethtool_get_nfc_rules(struct igc_adapter *adapter, cmd->data = IGC_MAX_RXNFC_RULES; - spin_lock(&adapter->nfc_rule_lock); + mutex_lock(&adapter->nfc_rule_lock); list_for_each_entry(rule, &adapter->nfc_rule_list, list) { if (cnt == cmd->rule_cnt) { - spin_unlock(&adapter->nfc_rule_lock); + mutex_unlock(&adapter->nfc_rule_lock); return -EMSGSIZE; } rule_locs[cnt] = rule->location; cnt++; } - spin_unlock(&adapter->nfc_rule_lock); + mutex_unlock(&adapter->nfc_rule_lock); cmd->rule_cnt = cnt; @@ -1303,7 +1303,7 @@ static int igc_ethtool_add_nfc_rule(struct igc_adapter *adapter, igc_ethtool_init_nfc_rule(rule, fsp); - spin_lock(&adapter->nfc_rule_lock); + mutex_lock(&adapter->nfc_rule_lock); err = igc_ethtool_check_nfc_rule(adapter, rule); if (err) @@ -1317,11 +1317,11 @@ static int igc_ethtool_add_nfc_rule(struct igc_adapter *adapter, if (err) goto err; - spin_unlock(&adapter->nfc_rule_lock); + mutex_unlock(&adapter->nfc_rule_lock); return 0; err: - spin_unlock(&adapter->nfc_rule_lock); + mutex_unlock(&adapter->nfc_rule_lock); kfree(rule); return err; } @@ -1333,17 +1333,17 @@ static int igc_ethtool_del_nfc_rule(struct igc_adapter *adapter, (struct ethtool_rx_flow_spec *)&cmd->fs; struct igc_nfc_rule *rule; - spin_lock(&adapter->nfc_rule_lock); + mutex_lock(&adapter->nfc_rule_lock); rule = igc_get_nfc_rule(adapter, fsp->location); if (!rule) { - spin_unlock(&adapter->nfc_rule_lock); + mutex_unlock(&adapter->nfc_rule_lock); return -EINVAL; } igc_del_nfc_rule(adapter, rule); - spin_unlock(&adapter->nfc_rule_lock); + mutex_unlock(&adapter->nfc_rule_lock); return 0; } diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c index 134523064fe9..38327d9ec385 100644 --- a/drivers/net/ethernet/intel/igc/igc_main.c +++ b/drivers/net/ethernet/intel/igc/igc_main.c @@ -2540,12 +2540,12 @@ static void igc_flush_nfc_rules(struct igc_adapter *adapter) { struct igc_nfc_rule *rule, *tmp; - spin_lock(&adapter->nfc_rule_lock); + mutex_lock(&adapter->nfc_rule_lock); list_for_each_entry_safe(rule, tmp, &adapter->nfc_rule_list, list) igc_del_nfc_rule(adapter, rule); - spin_unlock(&adapter->nfc_rule_lock); + mutex_unlock(&adapter->nfc_rule_lock); } /** @@ -2584,24 +2584,24 @@ static void igc_restore_nfc_rules(struct igc_adapter *adapter) { struct igc_nfc_rule *rule; - spin_lock(&adapter->nfc_rule_lock); + mutex_lock(&adapter->nfc_rule_lock); list_for_each_entry_reverse(rule, &adapter->nfc_rule_list, list) igc_enable_nfc_rule(adapter, rule); - spin_unlock(&adapter->nfc_rule_lock); + mutex_unlock(&adapter->nfc_rule_lock); } static void igc_nfc_rule_exit(struct igc_adapter *adapter) { struct igc_nfc_rule *rule; - spin_lock(&adapter->nfc_rule_lock); + mutex_lock(&adapter->nfc_rule_lock); list_for_each_entry(rule, &adapter->nfc_rule_list, list) igc_disable_nfc_rule(adapter, rule); - spin_unlock(&adapter->nfc_rule_lock); + mutex_unlock(&adapter->nfc_rule_lock); } static int igc_uc_sync(struct net_device *netdev, const unsigned char *addr) @@ -3574,7 +3574,7 @@ static int igc_sw_init(struct igc_adapter *adapter) VLAN_HLEN; adapter->min_frame_size = ETH_ZLEN + ETH_FCS_LEN; - spin_lock_init(&adapter->nfc_rule_lock); + mutex_init(&adapter->nfc_rule_lock); INIT_LIST_HEAD(&adapter->nfc_rule_list); adapter->nfc_rule_count = 0; From patchwork Fri Apr 24 20:16:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Guedes X-Patchwork-Id: 1276677 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 49857w2jw5z9sSG for ; Sat, 25 Apr 2020 06:17:48 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id DE768204CA; Fri, 24 Apr 2020 20:17:46 +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 rsF8g--f3Ccx; Fri, 24 Apr 2020 20:17:44 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 4C0FD22026; Fri, 24 Apr 2020 20:17:41 +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 24DBA1BF83C for ; Fri, 24 Apr 2020 20:17:32 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 1EA8087FF7 for ; Fri, 24 Apr 2020 20:17:32 +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 VDwgJp-cuE1p for ; Fri, 24 Apr 2020 20:17:30 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by whitealder.osuosl.org (Postfix) with ESMTPS id 5357A88021 for ; Fri, 24 Apr 2020 20:17:30 +0000 (UTC) IronPort-SDR: w1YQUq+OUmGihPgOjm1GOIcv4nxnwUR6ZgupsPqlcXfz4IFGe4b6oBpYNiLR7HE8iFBGMUdCOg qJuDF4RdXl1A== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2020 13:17:30 -0700 IronPort-SDR: q5N0OVd9FAl6OxPfnDzmivB/GnxcWAkqJ3RqrM2Rhpjq74e9WMua+QQ2ELpiV8ybASQVTTzU8h UdgGg10LudKg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,313,1583222400"; d="scan'208";a="335474528" Received: from kleandre-mobl.amr.corp.intel.com ([10.213.164.39]) by orsmga001.jf.intel.com with ESMTP; 24 Apr 2020 13:17:30 -0700 From: Andre Guedes To: intel-wired-lan@lists.osuosl.org Date: Fri, 24 Apr 2020 13:16:23 -0700 Message-Id: <20200424201623.10971-20-andre.guedes@intel.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200424201623.10971-1-andre.guedes@intel.com> References: <20200424201623.10971-1-andre.guedes@intel.com> MIME-Version: 1.0 Subject: [Intel-wired-lan] [PATCH 19/19] igc: Remove igc_nfc_rule_exit() 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" During igc_down(), we call igc_nfc_rule_exit() which traverse the NFC rule list disabling filters one by one. Later on in igc_down() flow we issue an hardware reset which also clear all filters. Since we already reset the hardware, we don't actually need to disable each filter manually. In order to simplify the code, this patch removes igc_nfc_rule() altogether. Signed-off-by: Andre Guedes Tested-by: Aaron Brown --- drivers/net/ethernet/intel/igc/igc_main.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c index 38327d9ec385..eaf797fcf581 100644 --- a/drivers/net/ethernet/intel/igc/igc_main.c +++ b/drivers/net/ethernet/intel/igc/igc_main.c @@ -2592,18 +2592,6 @@ static void igc_restore_nfc_rules(struct igc_adapter *adapter) mutex_unlock(&adapter->nfc_rule_lock); } -static void igc_nfc_rule_exit(struct igc_adapter *adapter) -{ - struct igc_nfc_rule *rule; - - mutex_lock(&adapter->nfc_rule_lock); - - list_for_each_entry(rule, &adapter->nfc_rule_list, list) - igc_disable_nfc_rule(adapter, rule); - - mutex_unlock(&adapter->nfc_rule_lock); -} - static int igc_uc_sync(struct net_device *netdev, const unsigned char *addr) { struct igc_adapter *adapter = netdev_priv(netdev); @@ -3822,8 +3810,6 @@ void igc_down(struct igc_adapter *adapter) wr32(IGC_RCTL, rctl & ~IGC_RCTL_EN); /* flush and sleep below */ - igc_nfc_rule_exit(adapter); - /* set trans_start so we don't get spurious watchdogs during reset */ netif_trans_update(netdev);