From patchwork Sat Apr 11 00:28:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Guedes X-Patchwork-Id: 1269218 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 48zbN14pJXz9sSq for ; Sat, 11 Apr 2020 10:28:49 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 66E5285DD8; Sat, 11 Apr 2020 00:28:47 +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 ApAkJqC6lspP; Sat, 11 Apr 2020 00:28:46 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id C7708868B4; Sat, 11 Apr 2020 00:28:46 +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 C56661BF2C1 for ; Sat, 11 Apr 2020 00:28:42 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id C274D85DD8 for ; Sat, 11 Apr 2020 00:28: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 WONPUPyaDlza for ; Sat, 11 Apr 2020 00:28:41 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 8BEB48651D for ; Sat, 11 Apr 2020 00:28:41 +0000 (UTC) IronPort-SDR: s70cIrACooIfBLmQe9io7dqbvJBwg/10LXo7Tlx2nKuFUGWpkQB61JRAI1s/iJjAPjrjYnGZ9B aVKO16bVJ0PQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Apr 2020 17:28:40 -0700 IronPort-SDR: O6H1rPzbICqBbSF3iF23XElUwQf1mqT6HQz+xdn/QbTG1MakIzbpd+3MAOPtQ+JF9UavD/MYPA S5GpNvi4sxZw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,368,1580803200"; d="scan'208";a="362585535" Received: from nwu5-mobl1.amr.corp.intel.com ([10.134.124.160]) by fmsmga001.fm.intel.com with ESMTP; 10 Apr 2020 17:28:40 -0700 From: Andre Guedes To: intel-wired-lan@lists.osuosl.org Date: Fri, 10 Apr 2020 17:28:34 -0700 Message-Id: <20200411002834.13916-5-andre.guedes@intel.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200411002834.13916-1-andre.guedes@intel.com> References: <20200411002834.13916-1-andre.guedes@intel.com> MIME-Version: 1.0 Subject: [Intel-wired-lan] [PATCH 4/4] igc: Enable NFC rules based source MAC address 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 support for Network Flow Classification (NFC) rules based on source MAC address. Note that the controller doesn't support rules with both source and destination addresses set, so this special case is checked in igc_add_ethtool_nfc_entry(). Signed-off-by: Andre Guedes --- drivers/net/ethernet/intel/igc/igc_ethtool.c | 31 +++++++++++++------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/intel/igc/igc_ethtool.c b/drivers/net/ethernet/intel/igc/igc_ethtool.c index 20d22df52f09..9cd629b7d5f4 100644 --- a/drivers/net/ethernet/intel/igc/igc_ethtool.c +++ b/drivers/net/ethernet/intel/igc/igc_ethtool.c @@ -1188,16 +1188,8 @@ static int igc_set_rss_hash_opt(struct igc_adapter *adapter, int igc_add_filter(struct igc_adapter *adapter, struct igc_nfc_filter *input) { - struct igc_hw *hw = &adapter->hw; int err = -EINVAL; - if (hw->mac.type == igc_i225 && - !(input->filter.match_flags & ~IGC_FILTER_FLAG_SRC_MAC_ADDR)) { - netdev_err(adapter->netdev, - "i225 doesn't support flow classification rules specifying only source addresses"); - return -EOPNOTSUPP; - } - if (input->filter.match_flags & IGC_FILTER_FLAG_ETHER_TYPE) { u16 etype = ntohs(input->filter.etype); @@ -1206,6 +1198,14 @@ int igc_add_filter(struct igc_adapter *adapter, struct igc_nfc_filter *input) return err; } + if (input->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); + if (err) + return err; + } + if (input->filter.match_flags & IGC_FILTER_FLAG_DST_MAC_ADDR) { err = igc_add_mac_filter(adapter, IGC_MAC_FILTER_TYPE_DST, input->filter.dst_addr, @@ -1239,6 +1239,10 @@ int igc_erase_filter(struct igc_adapter *adapter, struct igc_nfc_filter *input) igc_del_vlan_prio_filter(adapter, prio); } + if (input->filter.match_flags & IGC_FILTER_FLAG_SRC_MAC_ADDR) + igc_del_mac_filter(adapter, IGC_MAC_FILTER_TYPE_SRC, + input->filter.src_addr); + if (input->filter.match_flags & IGC_FILTER_FLAG_DST_MAC_ADDR) igc_del_mac_filter(adapter, IGC_MAC_FILTER_TYPE_DST, input->filter.dst_addr); @@ -1334,20 +1338,27 @@ static int igc_add_ethtool_nfc_entry(struct igc_adapter *adapter, input->filter.match_flags = IGC_FILTER_FLAG_ETHER_TYPE; } - /* Only support matching addresses by the full mask */ + /* 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, fsp->h_u.ether_spec.h_source); } - /* Only support matching addresses by the full mask */ 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, 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) { + netdev_dbg(netdev, "Filters with both dst and src are not supported"); + return -EOPNOTSUPP; + } + 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");