Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/1267643/?format=api
{ "id": 1267643, "url": "http://patchwork.ozlabs.org/api/patches/1267643/?format=api", "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20200407210711.24371-5-andre.guedes@intel.com/", "project": { "id": 46, "url": "http://patchwork.ozlabs.org/api/projects/46/?format=api", "name": "Intel Wired Ethernet development", "link_name": "intel-wired-lan", "list_id": "intel-wired-lan.osuosl.org", "list_email": "intel-wired-lan@osuosl.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20200407210711.24371-5-andre.guedes@intel.com>", "list_archive_url": null, "date": "2020-04-07T21:07:10", "name": "[4/5] igc: Refactor ethertype filtering code", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "f64fb2ede048014098dc7a4858773aa4cc2fd676", "submitter": { "id": 72323, "url": "http://patchwork.ozlabs.org/api/people/72323/?format=api", "name": "Andre Guedes", "email": "andre.guedes@intel.com" }, "delegate": { "id": 68, "url": "http://patchwork.ozlabs.org/api/users/68/?format=api", "username": "jtkirshe", "first_name": "Jeff", "last_name": "Kirsher", "email": "jeffrey.t.kirsher@intel.com" }, "mbox": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20200407210711.24371-5-andre.guedes@intel.com/mbox/", "series": [ { "id": 169099, "url": "http://patchwork.ozlabs.org/api/series/169099/?format=api", "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/list/?series=169099", "date": "2020-04-07T21:07:08", "name": "igc: Fixes for ethertype filtering code", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/169099/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/1267643/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/1267643/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<intel-wired-lan-bounces@osuosl.org>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "intel-wired-lan@lists.osuosl.org" ], "Delivered-To": [ "patchwork-incoming@bilbo.ozlabs.org", "intel-wired-lan@lists.osuosl.org" ], "Authentication-Results": [ "ozlabs.org; spf=pass (sender SPF authorized)\n\tsmtp.mailfrom=osuosl.org (client-ip=140.211.166.136;\n\thelo=silver.osuosl.org;\n\tenvelope-from=intel-wired-lan-bounces@osuosl.org;\n\treceiver=<UNKNOWN>)", "ozlabs.org;\n\tdmarc=fail (p=none dis=none) header.from=intel.com" ], "Received": [ "from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 48xg385WNPz9sQx\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 8 Apr 2020 07:07:32 +1000 (AEST)", "from localhost (localhost [127.0.0.1])\n\tby silver.osuosl.org (Postfix) with ESMTP id C004221556;\n\tTue, 7 Apr 2020 21:07:29 +0000 (UTC)", "from silver.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id u2U9fACb7Ik9; Tue, 7 Apr 2020 21:07:26 +0000 (UTC)", "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby silver.osuosl.org (Postfix) with ESMTP id 780EB21538;\n\tTue, 7 Apr 2020 21:07:26 +0000 (UTC)", "from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138])\n\tby ash.osuosl.org (Postfix) with ESMTP id B3E621BF616\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tTue, 7 Apr 2020 21:07:24 +0000 (UTC)", "from localhost (localhost [127.0.0.1])\n\tby whitealder.osuosl.org (Postfix) with ESMTP id AE8B287D48\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tTue, 7 Apr 2020 21:07:24 +0000 (UTC)", "from whitealder.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id 7CLZYKlp50Z8 for <intel-wired-lan@lists.osuosl.org>;\n\tTue, 7 Apr 2020 21:07:23 +0000 (UTC)", "from mga02.intel.com (mga02.intel.com [134.134.136.20])\n\tby whitealder.osuosl.org (Postfix) with ESMTPS id CDC5886D53\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tTue, 7 Apr 2020 21:07:22 +0000 (UTC)", "from fmsmga006.fm.intel.com ([10.253.24.20])\n\tby orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; \n\t07 Apr 2020 14:07:21 -0700", "from jyguan-mobl1.amr.corp.intel.com ([10.212.37.126])\n\tby fmsmga006.fm.intel.com with ESMTP; 07 Apr 2020 14:07:21 -0700" ], "X-Virus-Scanned": [ "amavisd-new at osuosl.org", "amavisd-new at osuosl.org" ], "X-Greylist": "domain auto-whitelisted by SQLgrey-1.7.6", "IronPort-SDR": [ "c5yx42z4H1VeDAi3c+3nrcpMNILE06oJLxzjOQmzT974dCx8+xCOgK/dYv/BsFQ74sfl0mlKqW\n\tEi9cYJptx4vQ==", "6EU1VjJIoLa4CH7V1BD/0rVToCUmwuT7X9YAEFtZK9OtFc9tq8ZVytjIS35hBRfdDgX0gYumi7\n\tU7mZ7YUtIqJw==" ], "X-Amp-Result": "SKIPPED(no attachment in message)", "X-Amp-File-Uploaded": "False", "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.72,356,1580803200\"; d=\"scan'208\";a=\"452593256\"", "From": "Andre Guedes <andre.guedes@intel.com>", "To": "intel-wired-lan@lists.osuosl.org", "Date": "Tue, 7 Apr 2020 14:07:10 -0700", "Message-Id": "<20200407210711.24371-5-andre.guedes@intel.com>", "X-Mailer": "git-send-email 2.26.0", "In-Reply-To": "<20200407210711.24371-1-andre.guedes@intel.com>", "References": "<20200407210711.24371-1-andre.guedes@intel.com>", "MIME-Version": "1.0", "Subject": "[Intel-wired-lan] [PATCH 4/5] igc: Refactor ethertype filtering 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\n\t<intel-wired-lan.osuosl.org>", "List-Unsubscribe": "<https://lists.osuosl.org/mailman/options/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@osuosl.org?subject=unsubscribe>", "List-Archive": "<http://lists.osuosl.org/pipermail/intel-wired-lan/>", "List-Post": "<mailto:intel-wired-lan@osuosl.org>", "List-Help": "<mailto:intel-wired-lan-request@osuosl.org?subject=help>", "List-Subscribe": "<https://lists.osuosl.org/mailman/listinfo/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@osuosl.org?subject=subscribe>", "Content-Type": "text/plain; charset=\"us-ascii\"", "Content-Transfer-Encoding": "7bit", "Errors-To": "intel-wired-lan-bounces@osuosl.org", "Sender": "\"Intel-wired-lan\" <intel-wired-lan-bounces@osuosl.org>" }, "content": "The whole ethertype filtering code is implemented in igc_ethtool.c and\nmixes logic from ethtool and core parts. This patch refactors it so core\nlogic is moved to igc_main.c, aligning the ethertype filtering code\norganization with the rest of the filtering code from the driver (MAC\naddress and VLAN priority).\n\nBesides moving code to igc_main.c, this patch also does some minor\nimprovements to the code. Below are some highlights.\n\nIn case all filters are already in use and the user tries to add another\nfilter, we return -ENOSPC instead of -EINVAL so a more meaningful error\ncode is provided. This also aligns with the behavior implemented in MAC\naddress filtering code.\n\nWith this code refactoring, 'etype_bitmap' array in struct igc_adapter\nand 'etype_reg_index' in struct igc_nfc_filter are not needed anymore\nand are removed.\n\nLog messages are added to help debugging the ethertype filtering code.\n\nSigned-off-by: Andre Guedes <andre.guedes@intel.com>\n---\n drivers/net/ethernet/intel/igc/igc.h | 4 +-\n drivers/net/ethernet/intel/igc/igc_ethtool.c | 67 ++------------\n drivers/net/ethernet/intel/igc/igc_main.c | 93 ++++++++++++++++++++\n 3 files changed, 103 insertions(+), 61 deletions(-)", "diff": "diff --git a/drivers/net/ethernet/intel/igc/igc.h b/drivers/net/ethernet/intel/igc/igc.h\nindex c20ac078fdef..22dde0590a23 100644\n--- a/drivers/net/ethernet/intel/igc/igc.h\n+++ b/drivers/net/ethernet/intel/igc/igc.h\n@@ -189,7 +189,6 @@ struct igc_adapter {\n \n \t/* lock for RX network flow classification filter */\n \tspinlock_t nfc_lock;\n-\tbool etype_bitmap[MAX_ETYPE_FILTER];\n \n \tstruct igc_mac_addr *mac_table;\n \n@@ -238,6 +237,8 @@ int igc_del_mac_filter(struct igc_adapter *adapter, const u8 *addr,\n int igc_add_vlan_prio_filter(struct igc_adapter *adapter, int prio,\n \t\t\t int queue);\n void igc_del_vlan_prio_filter(struct igc_adapter *adapter, int prio);\n+int igc_add_etype_filter(struct igc_adapter *adapter, u16 etype, int queue);\n+int igc_del_etype_filter(struct igc_adapter *adapter, u16 etype);\n void igc_update_stats(struct igc_adapter *adapter);\n \n /* igc_dump declarations */\n@@ -466,7 +467,6 @@ struct igc_nfc_filter {\n \tstruct hlist_node nfc_node;\n \tstruct igc_nfc_input filter;\n \tunsigned long cookie;\n-\tu16 etype_reg_index;\n \tu16 sw_idx;\n \tu16 action;\n };\ndiff --git a/drivers/net/ethernet/intel/igc/igc_ethtool.c b/drivers/net/ethernet/intel/igc/igc_ethtool.c\nindex a66b04755b2a..5a53bf6ee1e5 100644\n--- a/drivers/net/ethernet/intel/igc/igc_ethtool.c\n+++ b/drivers/net/ethernet/intel/igc/igc_ethtool.c\n@@ -1183,46 +1183,6 @@ static int igc_set_rss_hash_opt(struct igc_adapter *adapter,\n \treturn 0;\n }\n \n-static int igc_rxnfc_write_etype_filter(struct igc_adapter *adapter,\n-\t\t\t\t\tstruct igc_nfc_filter *input)\n-{\n-\tstruct igc_hw *hw = &adapter->hw;\n-\tu8 i;\n-\tu32 etqf;\n-\tu16 etype;\n-\n-\t/* find an empty etype filter register */\n-\tfor (i = 0; i < MAX_ETYPE_FILTER; ++i) {\n-\t\tif (!adapter->etype_bitmap[i])\n-\t\t\tbreak;\n-\t}\n-\tif (i == MAX_ETYPE_FILTER) {\n-\t\tnetdev_err(adapter->netdev,\n-\t\t\t \"ethtool -N: etype filters are all used\");\n-\t\treturn -EINVAL;\n-\t}\n-\n-\tadapter->etype_bitmap[i] = true;\n-\n-\tetqf = rd32(IGC_ETQF(i));\n-\tetype = ntohs(input->filter.etype & ETHER_TYPE_FULL_MASK);\n-\n-\tetqf |= IGC_ETQF_FILTER_ENABLE;\n-\tetqf &= ~IGC_ETQF_ETYPE_MASK;\n-\tetqf |= (etype & IGC_ETQF_ETYPE_MASK);\n-\n-\tetqf &= ~IGC_ETQF_QUEUE_MASK;\n-\tetqf |= ((input->action << IGC_ETQF_QUEUE_SHIFT)\n-\t\t& IGC_ETQF_QUEUE_MASK);\n-\tetqf |= IGC_ETQF_QUEUE_ENABLE;\n-\n-\twr32(IGC_ETQF(i), etqf);\n-\n-\tinput->etype_reg_index = i;\n-\n-\treturn 0;\n-}\n-\n int igc_add_filter(struct igc_adapter *adapter, struct igc_nfc_filter *input)\n {\n \tstruct igc_hw *hw = &adapter->hw;\n@@ -1236,7 +1196,9 @@ int igc_add_filter(struct igc_adapter *adapter, struct igc_nfc_filter *input)\n \t}\n \n \tif (input->filter.match_flags & IGC_FILTER_FLAG_ETHER_TYPE) {\n-\t\terr = igc_rxnfc_write_etype_filter(adapter, input);\n+\t\tu16 etype = ntohs(input->filter.etype);\n+\n+\t\terr = igc_add_etype_filter(adapter, etype, input->action);\n \t\tif (err)\n \t\t\treturn err;\n \t}\n@@ -1267,26 +1229,13 @@ int igc_add_filter(struct igc_adapter *adapter, struct igc_nfc_filter *input)\n \treturn 0;\n }\n \n-static void igc_clear_etype_filter_regs(struct igc_adapter *adapter,\n-\t\t\t\t\tu16 reg_index)\n-{\n-\tstruct igc_hw *hw = &adapter->hw;\n-\tu32 etqf = rd32(IGC_ETQF(reg_index));\n-\n-\tetqf &= ~IGC_ETQF_QUEUE_ENABLE;\n-\tetqf &= ~IGC_ETQF_QUEUE_MASK;\n-\tetqf &= ~IGC_ETQF_FILTER_ENABLE;\n-\n-\twr32(IGC_ETQF(reg_index), etqf);\n-\n-\tadapter->etype_bitmap[reg_index] = false;\n-}\n-\n int igc_erase_filter(struct igc_adapter *adapter, struct igc_nfc_filter *input)\n {\n-\tif (input->filter.match_flags & IGC_FILTER_FLAG_ETHER_TYPE)\n-\t\tigc_clear_etype_filter_regs(adapter,\n-\t\t\t\t\t input->etype_reg_index);\n+\tif (input->filter.match_flags & IGC_FILTER_FLAG_ETHER_TYPE) {\n+\t\tu16 etype = ntohs(input->filter.etype);\n+\n+\t\tigc_del_etype_filter(adapter, etype);\n+\t}\n \n \tif (input->filter.match_flags & IGC_FILTER_FLAG_VLAN_TCI) {\n \t\tint prio = (ntohs(input->filter.vlan_tci) & VLAN_PRIO_MASK)\ndiff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c\nindex 150f4c6c029e..9c2d487803b2 100644\n--- a/drivers/net/ethernet/intel/igc/igc_main.c\n+++ b/drivers/net/ethernet/intel/igc/igc_main.c\n@@ -2367,6 +2367,99 @@ void igc_del_vlan_prio_filter(struct igc_adapter *adapter, int prio)\n \t\t prio);\n }\n \n+static int igc_get_avail_etype_filter_slot(struct igc_adapter *adapter)\n+{\n+\tstruct igc_hw *hw = &adapter->hw;\n+\tint i;\n+\n+\tfor (i = 0; i < MAX_ETYPE_FILTER; i++) {\n+\t\tu32 etqf = rd32(IGC_ETQF(i));\n+\n+\t\tif (!(etqf & IGC_ETQF_FILTER_ENABLE))\n+\t\t\treturn i;\n+\t}\n+\n+\treturn -1;\n+}\n+\n+/**\n+ * igc_add_etype_filter() - Add ethertype filter.\n+ * @adapter: Pointer to adapter where the filter should be added.\n+ * @etype: Ethertype value.\n+ * @queue: If non-negative, queue assignment feature is enabled and frames\n+ * matching the filter are enqueued onto 'queue'. Otherwise, queue\n+ * assignment is disabled.\n+ *\n+ * Return: 0 in case of success, negative errno code otherwise.\n+ */\n+int igc_add_etype_filter(struct igc_adapter *adapter, u16 etype, int queue)\n+{\n+\tstruct igc_hw *hw = &adapter->hw;\n+\tint index;\n+\tu32 etqf;\n+\n+\tindex = igc_get_avail_etype_filter_slot(adapter);\n+\tif (index < 0)\n+\t\treturn -ENOSPC;\n+\n+\tetqf = rd32(IGC_ETQF(index));\n+\n+\tetqf &= ~IGC_ETQF_ETYPE_MASK;\n+\tetqf |= etype;\n+\n+\tif (queue >= 0) {\n+\t\tetqf &= ~IGC_ETQF_QUEUE_MASK;\n+\t\tetqf |= (queue << IGC_ETQF_QUEUE_SHIFT);\n+\t\tetqf |= IGC_ETQF_QUEUE_ENABLE;\n+\t}\n+\n+\tetqf |= IGC_ETQF_FILTER_ENABLE;\n+\n+\twr32(IGC_ETQF(index), etqf);\n+\n+\tnetdev_dbg(adapter->netdev, \"Add ethertype filter: etype %04x queue %d\",\n+\t\t etype, queue);\n+\treturn 0;\n+}\n+\n+static int igc_find_etype_filter(struct igc_adapter *adapter, u16 etype)\n+{\n+\tstruct igc_hw *hw = &adapter->hw;\n+\tint i;\n+\n+\tfor (i = 0; i < MAX_ETYPE_FILTER; i++) {\n+\t\tu32 etqf = rd32(IGC_ETQF(i));\n+\n+\t\tif ((etqf & IGC_ETQF_ETYPE_MASK) == etype)\n+\t\t\treturn i;\n+\t}\n+\n+\treturn -1;\n+}\n+\n+/**\n+ * igc_del_etype_filter() - Delete ethertype filter.\n+ * @adapter: Pointer to adapter where the filter should be deleted from.\n+ * @etype: Ethertype value.\n+ *\n+ * Return: 0 in case of success, negative errno code otherwise.\n+ */\n+int igc_del_etype_filter(struct igc_adapter *adapter, u16 etype)\n+{\n+\tstruct igc_hw *hw = &adapter->hw;\n+\tint index;\n+\n+\tindex = igc_find_etype_filter(adapter, etype);\n+\tif (index < 0)\n+\t\treturn -ENOENT;\n+\n+\twr32(IGC_ETQF(index), 0);\n+\n+\tnetdev_dbg(adapter->netdev, \"Delete ethertype filter: etype %04x\",\n+\t\t etype);\n+\treturn 0;\n+}\n+\n static int igc_uc_sync(struct net_device *netdev, const unsigned char *addr)\n {\n \tstruct igc_adapter *adapter = netdev_priv(netdev);\n", "prefixes": [ "4/5" ] }