Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/1257845/?format=api
{ "id": 1257845, "url": "http://patchwork.ozlabs.org/api/patches/1257845/?format=api", "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20200318230102.36952-2-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": "<20200318230102.36952-2-andre.guedes@intel.com>", "list_archive_url": null, "date": "2020-03-18T23:00:51", "name": "[01/12] igc: Remove duplicate code in MAC filtering logic", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "e1b3d9917d85a1cf66f880a36ca992f8e40be21e", "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/20200318230102.36952-2-andre.guedes@intel.com/mbox/", "series": [ { "id": 165243, "url": "http://patchwork.ozlabs.org/api/series/165243/?format=api", "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/list/?series=165243", "date": "2020-03-18T23:00:52", "name": "igc: Refactor MAC address filtering code", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/165243/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/1257845/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/1257845/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 48jQXm46M3z9sR4\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 19 Mar 2020 10:02:16 +1100 (AEDT)", "from localhost (localhost [127.0.0.1])\n\tby silver.osuosl.org (Postfix) with ESMTP id 18D522041B;\n\tWed, 18 Mar 2020 23:02:15 +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 jNYtLyMt0aWw; Wed, 18 Mar 2020 23:02:11 +0000 (UTC)", "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby silver.osuosl.org (Postfix) with ESMTP id 82ADE20405;\n\tWed, 18 Mar 2020 23:02:11 +0000 (UTC)", "from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137])\n\tby ash.osuosl.org (Postfix) with ESMTP id 17C3F1BF335\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tWed, 18 Mar 2020 23:02:09 +0000 (UTC)", "from localhost (localhost [127.0.0.1])\n\tby fraxinus.osuosl.org (Postfix) with ESMTP id 1133386610\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tWed, 18 Mar 2020 23:02:09 +0000 (UTC)", "from fraxinus.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id Ukrf-whwqsto for <intel-wired-lan@lists.osuosl.org>;\n\tWed, 18 Mar 2020 23:02:07 +0000 (UTC)", "from mga17.intel.com (mga17.intel.com [192.55.52.151])\n\tby fraxinus.osuosl.org (Postfix) with ESMTPS id 4DBD486637\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tWed, 18 Mar 2020 23:02:07 +0000 (UTC)", "from orsmga006.jf.intel.com ([10.7.209.51])\n\tby fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; \n\t18 Mar 2020 16:02:06 -0700", "from ymtomada-mobl.amr.corp.intel.com ([10.251.21.179])\n\tby orsmga006.jf.intel.com with ESMTP; 18 Mar 2020 16:02:06 -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": [ "NILB+lWClM6tJrWKfJX+jbdnzD3BfIKx9qylBHweR9fC2Y8hueeq/mYnDI/PUe1tJ84Jjfep0O\n\t63Sp+z+9B8mg==", "R+As+uLWeSoaN1cCxio3CA8ec6Dh1EN3VReJ1obNZ3qj6kaVPCb4SUBU7kkOzvld8tik2Tx/ZQ\n\tkgyyEhJlLs1g==" ], "X-Amp-Result": "SKIPPED(no attachment in message)", "X-Amp-File-Uploaded": "False", "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.70,569,1574150400\"; d=\"scan'208\";a=\"248341767\"", "From": "Andre Guedes <andre.guedes@intel.com>", "To": "intel-wired-lan@lists.osuosl.org", "Date": "Wed, 18 Mar 2020 16:00:51 -0700", "Message-Id": "<20200318230102.36952-2-andre.guedes@intel.com>", "X-Mailer": "git-send-email 2.25.0", "In-Reply-To": "<20200318230102.36952-1-andre.guedes@intel.com>", "References": "<20200318230102.36952-1-andre.guedes@intel.com>", "MIME-Version": "1.0", "Subject": "[Intel-wired-lan] [PATCH 01/12] igc: Remove duplicate code in MAC\n\tfiltering logic", "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": "This patch does a code refactoring in the MAC address filtering logic to\nget rid of some duplicate code.\n\nIGC driver has two functions to add MAC address filters that are pretty\nmuch the same: igc_add_mac_filter() and igc_add_mac_filter_flags(). The\nonly difference is that the latter allows the callee to specify the\n'flags' parameter while the former has it hardcoded as zero. The same\nrationale applies to filter deletion counterparts.\n\nSo this patch refactors igc_add_mac_filter() and igc_del_mac_filter() so\nthey handle the 'flags' parameters, removes the _flags() functions, and\nfixes callees accordingly.\n\nSigned-off-by: Andre Guedes <andre.guedes@intel.com>\n---\n drivers/net/ethernet/intel/igc/igc_main.c | 112 +++-------------------\n 1 file changed, 13 insertions(+), 99 deletions(-)", "diff": "diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c\nindex a964ef18ac0c..107e9f86bd0a 100644\n--- a/drivers/net/ethernet/intel/igc/igc_main.c\n+++ b/drivers/net/ethernet/intel/igc/igc_main.c\n@@ -2192,8 +2192,8 @@ static bool igc_mac_entry_can_be_used(const struct igc_mac_addr *entry,\n * default for the destination address, if matching by source address\n * is desired the flag IGC_MAC_STATE_SRC_ADDR can be used.\n */\n-static int igc_add_mac_filter(struct igc_adapter *adapter,\n-\t\t\t const u8 *addr, const u8 queue)\n+static int igc_add_mac_filter(struct igc_adapter *adapter, const u8 *addr,\n+\t\t\t const u8 queue, const u8 flags)\n {\n \tstruct igc_hw *hw = &adapter->hw;\n \tint rar_entries = hw->mac.rar_entry_count;\n@@ -2208,12 +2208,12 @@ static int igc_add_mac_filter(struct igc_adapter *adapter,\n \t */\n \tfor (i = 0; i < rar_entries; i++) {\n \t\tif (!igc_mac_entry_can_be_used(&adapter->mac_table[i],\n-\t\t\t\t\t addr, 0))\n+\t\t\t\t\t addr, flags))\n \t\t\tcontinue;\n \n \t\tether_addr_copy(adapter->mac_table[i].addr, addr);\n \t\tadapter->mac_table[i].queue = queue;\n-\t\tadapter->mac_table[i].state |= IGC_MAC_STATE_IN_USE;\n+\t\tadapter->mac_table[i].state |= IGC_MAC_STATE_IN_USE | flags;\n \n \t\tigc_rar_set_index(adapter, i);\n \t\treturn i;\n@@ -2228,8 +2228,8 @@ static int igc_add_mac_filter(struct igc_adapter *adapter,\n * matching by source address is to be removed the flag\n * IGC_MAC_STATE_SRC_ADDR can be used.\n */\n-static int igc_del_mac_filter(struct igc_adapter *adapter,\n-\t\t\t const u8 *addr, const u8 queue)\n+static int igc_del_mac_filter(struct igc_adapter *adapter, const u8 *addr,\n+\t\t\t const u8 queue, const u8 flags)\n {\n \tstruct igc_hw *hw = &adapter->hw;\n \tint rar_entries = hw->mac.rar_entry_count;\n@@ -2245,7 +2245,7 @@ static int igc_del_mac_filter(struct igc_adapter *adapter,\n \tfor (i = 0; i < rar_entries; i++) {\n \t\tif (!(adapter->mac_table[i].state & IGC_MAC_STATE_IN_USE))\n \t\t\tcontinue;\n-\t\tif (adapter->mac_table[i].state != 0)\n+\t\tif (flags && (adapter->mac_table[i].state & flags) != flags)\n \t\t\tcontinue;\n \t\tif (adapter->mac_table[i].queue != queue)\n \t\t\tcontinue;\n@@ -2277,7 +2277,7 @@ static int igc_uc_sync(struct net_device *netdev, const unsigned char *addr)\n \tstruct igc_adapter *adapter = netdev_priv(netdev);\n \tint ret;\n \n-\tret = igc_add_mac_filter(adapter, addr, adapter->num_rx_queues);\n+\tret = igc_add_mac_filter(adapter, addr, adapter->num_rx_queues, 0);\n \n \treturn min_t(int, ret, 0);\n }\n@@ -2286,7 +2286,7 @@ static int igc_uc_unsync(struct net_device *netdev, const unsigned char *addr)\n {\n \tstruct igc_adapter *adapter = netdev_priv(netdev);\n \n-\tigc_del_mac_filter(adapter, addr, adapter->num_rx_queues);\n+\tigc_del_mac_filter(adapter, addr, adapter->num_rx_queues, 0);\n \n \treturn 0;\n }\n@@ -3723,104 +3723,18 @@ igc_features_check(struct sk_buff *skb, struct net_device *dev,\n \treturn features;\n }\n \n-/* Add a MAC filter for 'addr' directing matching traffic to 'queue',\n- * 'flags' is used to indicate what kind of match is made, match is by\n- * default for the destination address, if matching by source address\n- * is desired the flag IGC_MAC_STATE_SRC_ADDR can be used.\n- */\n-static int igc_add_mac_filter_flags(struct igc_adapter *adapter,\n-\t\t\t\t const u8 *addr, const u8 queue,\n-\t\t\t\t const u8 flags)\n-{\n-\tstruct igc_hw *hw = &adapter->hw;\n-\tint rar_entries = hw->mac.rar_entry_count;\n-\tint i;\n-\n-\tif (is_zero_ether_addr(addr))\n-\t\treturn -EINVAL;\n-\n-\t/* Search for the first empty entry in the MAC table.\n-\t * Do not touch entries at the end of the table reserved for the VF MAC\n-\t * addresses.\n-\t */\n-\tfor (i = 0; i < rar_entries; i++) {\n-\t\tif (!igc_mac_entry_can_be_used(&adapter->mac_table[i],\n-\t\t\t\t\t addr, flags))\n-\t\t\tcontinue;\n-\n-\t\tether_addr_copy(adapter->mac_table[i].addr, addr);\n-\t\tadapter->mac_table[i].queue = queue;\n-\t\tadapter->mac_table[i].state |= IGC_MAC_STATE_IN_USE | flags;\n-\n-\t\tigc_rar_set_index(adapter, i);\n-\t\treturn i;\n-\t}\n-\n-\treturn -ENOSPC;\n-}\n-\n int igc_add_mac_steering_filter(struct igc_adapter *adapter,\n \t\t\t\tconst u8 *addr, u8 queue, u8 flags)\n {\n-\treturn igc_add_mac_filter_flags(adapter, addr, queue,\n-\t\t\t\t\tIGC_MAC_STATE_QUEUE_STEERING | flags);\n-}\n-\n-/* Remove a MAC filter for 'addr' directing matching traffic to\n- * 'queue', 'flags' is used to indicate what kind of match need to be\n- * removed, match is by default for the destination address, if\n- * matching by source address is to be removed the flag\n- * IGC_MAC_STATE_SRC_ADDR can be used.\n- */\n-static int igc_del_mac_filter_flags(struct igc_adapter *adapter,\n-\t\t\t\t const u8 *addr, const u8 queue,\n-\t\t\t\t const u8 flags)\n-{\n-\tstruct igc_hw *hw = &adapter->hw;\n-\tint rar_entries = hw->mac.rar_entry_count;\n-\tint i;\n-\n-\tif (is_zero_ether_addr(addr))\n-\t\treturn -EINVAL;\n-\n-\t/* Search for matching entry in the MAC table based on given address\n-\t * and queue. Do not touch entries at the end of the table reserved\n-\t * for the VF MAC addresses.\n-\t */\n-\tfor (i = 0; i < rar_entries; i++) {\n-\t\tif (!(adapter->mac_table[i].state & IGC_MAC_STATE_IN_USE))\n-\t\t\tcontinue;\n-\t\tif ((adapter->mac_table[i].state & flags) != flags)\n-\t\t\tcontinue;\n-\t\tif (adapter->mac_table[i].queue != queue)\n-\t\t\tcontinue;\n-\t\tif (!ether_addr_equal(adapter->mac_table[i].addr, addr))\n-\t\t\tcontinue;\n-\n-\t\t/* When a filter for the default address is \"deleted\",\n-\t\t * we return it to its initial configuration\n-\t\t */\n-\t\tif (adapter->mac_table[i].state & IGC_MAC_STATE_DEFAULT) {\n-\t\t\tadapter->mac_table[i].state =\n-\t\t\t\tIGC_MAC_STATE_DEFAULT | IGC_MAC_STATE_IN_USE;\n-\t\t} else {\n-\t\t\tadapter->mac_table[i].state = 0;\n-\t\t\tadapter->mac_table[i].queue = 0;\n-\t\t\tmemset(adapter->mac_table[i].addr, 0, ETH_ALEN);\n-\t\t}\n-\n-\t\tigc_rar_set_index(adapter, i);\n-\t\treturn 0;\n-\t}\n-\n-\treturn -ENOENT;\n+\treturn igc_add_mac_filter(adapter, addr, queue,\n+\t\t\t\t IGC_MAC_STATE_QUEUE_STEERING | flags);\n }\n \n int igc_del_mac_steering_filter(struct igc_adapter *adapter,\n \t\t\t\tconst u8 *addr, u8 queue, u8 flags)\n {\n-\treturn igc_del_mac_filter_flags(adapter, addr, queue,\n-\t\t\t\t\tIGC_MAC_STATE_QUEUE_STEERING | flags);\n+\treturn igc_del_mac_filter(adapter, addr, queue,\n+\t\t\t\t IGC_MAC_STATE_QUEUE_STEERING | flags);\n }\n \n static void igc_tsync_interrupt(struct igc_adapter *adapter)\n", "prefixes": [ "01/12" ] }