get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/1276678/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 1276678,
    "url": "http://patchwork.ozlabs.org/api/patches/1276678/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20200424201623.10971-15-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": "<20200424201623.10971-15-andre.guedes@intel.com>",
    "list_archive_url": null,
    "date": "2020-04-24T20:16:18",
    "name": "[14/19] igc: Refactor igc_ethtool_update_nfc_rule()",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "10ff010b8d94e37783a283c7e5fc6ed017ac1ef7",
    "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/20200424201623.10971-15-andre.guedes@intel.com/mbox/",
    "series": [
        {
            "id": 172579,
            "url": "http://patchwork.ozlabs.org/api/series/172579/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/list/?series=172579",
            "date": "2020-04-24T20:16:07",
            "name": "igc: Fixes to NFC support code",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/172579/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/1276678/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/1276678/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;\n spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org\n (client-ip=140.211.166.136; helo=silver.osuosl.org;\n envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=<UNKNOWN>)",
            "ozlabs.org;\n dmarc=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 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 4985802cpCz9sSG\n\tfor <incoming@patchwork.ozlabs.org>; Sat, 25 Apr 2020 06:17:52 +1000 (AEST)",
            "from localhost (localhost [127.0.0.1])\n\tby silver.osuosl.org (Postfix) with ESMTP id 6ABBE21519;\n\tFri, 24 Apr 2020 20:17:50 +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 vrDN3GJEDCtF; Fri, 24 Apr 2020 20:17:40 +0000 (UTC)",
            "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby silver.osuosl.org (Postfix) with ESMTP id 2640F22851;\n\tFri, 24 Apr 2020 20:17:35 +0000 (UTC)",
            "from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137])\n by ash.osuosl.org (Postfix) with ESMTP id 304D21BF9C2\n for <intel-wired-lan@lists.osuosl.org>; Fri, 24 Apr 2020 20:17:30 +0000 (UTC)",
            "from localhost (localhost [127.0.0.1])\n by fraxinus.osuosl.org (Postfix) with ESMTP id 2D27B868A9\n for <intel-wired-lan@lists.osuosl.org>; Fri, 24 Apr 2020 20:17:30 +0000 (UTC)",
            "from fraxinus.osuosl.org ([127.0.0.1])\n by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n with ESMTP id JFygBYAS0LBk for <intel-wired-lan@lists.osuosl.org>;\n Fri, 24 Apr 2020 20:17:29 +0000 (UTC)",
            "from mga04.intel.com (mga04.intel.com [192.55.52.120])\n by fraxinus.osuosl.org (Postfix) with ESMTPS id E05CE86BA9\n for <intel-wired-lan@lists.osuosl.org>; Fri, 24 Apr 2020 20:17:28 +0000 (UTC)",
            "from orsmga001.jf.intel.com ([10.7.209.18])\n by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 24 Apr 2020 13:17:28 -0700",
            "from kleandre-mobl.amr.corp.intel.com ([10.213.164.39])\n by orsmga001.jf.intel.com with ESMTP; 24 Apr 2020 13:17:28 -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": [
            "\n rud4VtJEu4mf6vQRS8XUSlFP+zRW7mh1OsN9Z2vyn6UUgexSvh+NDSZDAKM9h68WfZl6MJZWRJ\n XAVP1xNLBxFw==",
            "\n L5P+LlqYNzgNHU/h8NEazdaePqKG6rjVP6Lyldb8+KHtpg9iP66vS3y+UtCOQCTQCIeRevC3rr\n zkFdktifFITA=="
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.73,313,1583222400\"; d=\"scan'208\";a=\"335474520\"",
        "From": "Andre Guedes <andre.guedes@intel.com>",
        "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\n 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\n <intel-wired-lan.osuosl.org>",
        "List-Unsubscribe": "<https://lists.osuosl.org/mailman/options/intel-wired-lan>,\n <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 <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": "Current implementation of igc_ethtool_update_nfc_rule() is a bit\nconvoluted since it handles too many things: rule lookup, deletion\nand addition. This patch breaks it into three functions so we simplify\nthe code and improve code reuse.\n\nCode related to rule lookup is refactored out to a new function called\nigc_get_nfc_rule().\n\nCode related to rule addition is refactored out to a new function called\nigc_add_nfc_rule(). This function enables the rule in hardware and adds\nit to the adapter's list.\n\nCode related to rule deletion is refactored out to a new function called\nigc_del_nfc_rule(). This function disables the rule in hardware, removes\nit from adapter's list, and deletes it.\n\nAs a byproduct of this refactoring, igc_enable_nfc_rule() and\nigc_disable_nfc_rule() are moved to igc_main.c since they are not used\nin igc_ethtool.c anymore, and igc_restore_nfc_rules() and igc_nfc_rule_\nexit() are moved around to avoid forward declaration.\n\nAlso, since this patch already touches igc_ethtool_get_nfc_rule(), it\ntakes the opportunity to remove the 'match_flags' check. Empty flags\nare not allowed to be added so no need to check that.\n\nSigned-off-by: Andre Guedes <andre.guedes@intel.com>\n---\n drivers/net/ethernet/intel/igc/igc.h         |  18 +-\n drivers/net/ethernet/intel/igc/igc_ethtool.c | 138 ++-----------\n drivers/net/ethernet/intel/igc/igc_main.c    | 205 ++++++++++++++++---\n 3 files changed, 195 insertions(+), 166 deletions(-)",
    "diff": "diff --git a/drivers/net/ethernet/intel/igc/igc.h b/drivers/net/ethernet/intel/igc/igc.h\nindex 76bc3a51ad70..a484b328268b 100644\n--- a/drivers/net/ethernet/intel/igc/igc.h\n+++ b/drivers/net/ethernet/intel/igc/igc.h\n@@ -232,16 +232,6 @@ void igc_write_rss_indir_tbl(struct igc_adapter *adapter);\n bool igc_has_link(struct igc_adapter *adapter);\n void igc_reset(struct igc_adapter *adapter);\n int igc_set_spd_dplx(struct igc_adapter *adapter, u32 spd, u8 dplx);\n-int igc_add_mac_filter(struct igc_adapter *adapter,\n-\t\t       enum igc_mac_filter_type type, const u8 *addr,\n-\t\t       int queue);\n-int igc_del_mac_filter(struct igc_adapter *adapter,\n-\t\t       enum igc_mac_filter_type type, 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@@ -544,10 +534,10 @@ static inline s32 igc_read_phy_reg(struct igc_hw *hw, u32 offset, u16 *data)\n }\n \n void igc_reinit_locked(struct igc_adapter *);\n-int igc_enable_nfc_rule(struct igc_adapter *adapter,\n-\t\t\tconst struct igc_nfc_rule *rule);\n-int igc_disable_nfc_rule(struct igc_adapter *adapter,\n-\t\t\t const struct igc_nfc_rule *rule);\n+struct igc_nfc_rule *igc_get_nfc_rule(struct igc_adapter *adapter,\n+\t\t\t\t      u32 location);\n+int igc_add_nfc_rule(struct igc_adapter *adapter, struct igc_nfc_rule *rule);\n+void igc_del_nfc_rule(struct igc_adapter *adapter, struct igc_nfc_rule *rule);\n \n void igc_ptp_init(struct igc_adapter *adapter);\n void igc_ptp_reset(struct igc_adapter *adapter);\ndiff --git a/drivers/net/ethernet/intel/igc/igc_ethtool.c b/drivers/net/ethernet/intel/igc/igc_ethtool.c\nindex 944cad748e61..de9ab3c8179a 100644\n--- a/drivers/net/ethernet/intel/igc/igc_ethtool.c\n+++ b/drivers/net/ethernet/intel/igc/igc_ethtool.c\n@@ -941,15 +941,8 @@ static int igc_ethtool_get_nfc_rule(struct igc_adapter *adapter,\n \n \tspin_lock(&adapter->nfc_rule_lock);\n \n-\tlist_for_each_entry(rule, &adapter->nfc_rule_list, list) {\n-\t\tif (fsp->location <= rule->location)\n-\t\t\tbreak;\n-\t}\n-\n-\tif (!rule || fsp->location != rule->location)\n-\t\tgoto out;\n-\n-\tif (!rule->filter.match_flags)\n+\trule = igc_get_nfc_rule(adapter, fsp->location);\n+\tif (!rule)\n \t\tgoto out;\n \n \tfsp->flow_type = ETHER_FLOW;\n@@ -1190,108 +1183,6 @@ static int igc_ethtool_set_rss_hash_opt(struct igc_adapter *adapter,\n \treturn 0;\n }\n \n-int igc_enable_nfc_rule(struct igc_adapter *adapter,\n-\t\t\tconst struct igc_nfc_rule *rule)\n-{\n-\tint err = -EINVAL;\n-\n-\tif (rule->filter.match_flags & IGC_FILTER_FLAG_ETHER_TYPE) {\n-\t\terr = igc_add_etype_filter(adapter, rule->filter.etype,\n-\t\t\t\t\t   rule->action);\n-\t\tif (err)\n-\t\t\treturn err;\n-\t}\n-\n-\tif (rule->filter.match_flags & IGC_FILTER_FLAG_SRC_MAC_ADDR) {\n-\t\terr = igc_add_mac_filter(adapter, IGC_MAC_FILTER_TYPE_SRC,\n-\t\t\t\t\t rule->filter.src_addr, rule->action);\n-\t\tif (err)\n-\t\t\treturn err;\n-\t}\n-\n-\tif (rule->filter.match_flags & IGC_FILTER_FLAG_DST_MAC_ADDR) {\n-\t\terr = igc_add_mac_filter(adapter, IGC_MAC_FILTER_TYPE_DST,\n-\t\t\t\t\t rule->filter.dst_addr, rule->action);\n-\t\tif (err)\n-\t\t\treturn err;\n-\t}\n-\n-\tif (rule->filter.match_flags & IGC_FILTER_FLAG_VLAN_TCI) {\n-\t\tint prio = (rule->filter.vlan_tci & VLAN_PRIO_MASK)\n-\t\t\t\t>> VLAN_PRIO_SHIFT;\n-\n-\t\terr = igc_add_vlan_prio_filter(adapter, prio, rule->action);\n-\t\tif (err)\n-\t\t\treturn err;\n-\t}\n-\n-\treturn 0;\n-}\n-\n-int igc_disable_nfc_rule(struct igc_adapter *adapter,\n-\t\t\t const struct igc_nfc_rule *rule)\n-{\n-\tif (rule->filter.match_flags & IGC_FILTER_FLAG_ETHER_TYPE)\n-\t\tigc_del_etype_filter(adapter, rule->filter.etype);\n-\n-\tif (rule->filter.match_flags & IGC_FILTER_FLAG_VLAN_TCI) {\n-\t\tint prio = (rule->filter.vlan_tci & VLAN_PRIO_MASK)\n-\t\t\t\t>> VLAN_PRIO_SHIFT;\n-\t\tigc_del_vlan_prio_filter(adapter, prio);\n-\t}\n-\n-\tif (rule->filter.match_flags & IGC_FILTER_FLAG_SRC_MAC_ADDR)\n-\t\tigc_del_mac_filter(adapter, IGC_MAC_FILTER_TYPE_SRC,\n-\t\t\t\t   rule->filter.src_addr);\n-\n-\tif (rule->filter.match_flags & IGC_FILTER_FLAG_DST_MAC_ADDR)\n-\t\tigc_del_mac_filter(adapter, IGC_MAC_FILTER_TYPE_DST,\n-\t\t\t\t   rule->filter.dst_addr);\n-\n-\treturn 0;\n-}\n-\n-static int igc_ethtool_update_nfc_rule(struct igc_adapter *adapter,\n-\t\t\t\t       struct igc_nfc_rule *input,\n-\t\t\t\t       u32 location)\n-{\n-\tstruct igc_nfc_rule *rule, *parent;\n-\tint err = -EINVAL;\n-\n-\tparent = NULL;\n-\trule = NULL;\n-\n-\tlist_for_each_entry(rule, &adapter->nfc_rule_list, list) {\n-\t\t/* hash found, or no matching entry */\n-\t\tif (rule->location >= location)\n-\t\t\tbreak;\n-\t\tparent = rule;\n-\t}\n-\n-\t/* if there is an old rule occupying our place remove it */\n-\tif (rule && rule->location == location) {\n-\t\terr = igc_disable_nfc_rule(adapter, rule);\n-\n-\t\tlist_del(&rule->list);\n-\t\tkfree(rule);\n-\t\tadapter->nfc_rule_count--;\n-\t}\n-\n-\t/* If no input this was a delete, err should be 0 if a rule was\n-\t * successfully found and removed from the list else -EINVAL\n-\t */\n-\tif (!input)\n-\t\treturn err;\n-\n-\tlist_add(&input->list, parent ? &parent->list :\n-\t\t\t\t\t&adapter->nfc_rule_list);\n-\n-\t/* update counts */\n-\tadapter->nfc_rule_count++;\n-\n-\treturn 0;\n-}\n-\n static void igc_ethtool_init_nfc_rule(struct igc_nfc_rule *rule,\n \t\t\t\t      const struct ethtool_rx_flow_spec *fsp)\n {\n@@ -1376,7 +1267,7 @@ static int igc_ethtool_add_nfc_rule(struct igc_adapter *adapter,\n \tstruct net_device *netdev = adapter->netdev;\n \tstruct ethtool_rx_flow_spec *fsp =\n \t\t(struct ethtool_rx_flow_spec *)&cmd->fs;\n-\tstruct igc_nfc_rule *rule;\n+\tstruct igc_nfc_rule *rule, *old_rule;\n \tint err;\n \n \tif (!(netdev->hw_features & NETIF_F_NTUPLE)) {\n@@ -1417,12 +1308,14 @@ static int igc_ethtool_add_nfc_rule(struct igc_adapter *adapter,\n \tif (err)\n \t\tgoto err;\n \n-\terr = igc_enable_nfc_rule(adapter, rule);\n+\told_rule = igc_get_nfc_rule(adapter, fsp->location);\n+\tif (old_rule)\n+\t\tigc_del_nfc_rule(adapter, old_rule);\n+\n+\terr = igc_add_nfc_rule(adapter, rule);\n \tif (err)\n \t\tgoto err;\n \n-\tigc_ethtool_update_nfc_rule(adapter, rule, rule->location);\n-\n \tspin_unlock(&adapter->nfc_rule_lock);\n \treturn 0;\n \n@@ -1437,13 +1330,20 @@ static int igc_ethtool_del_nfc_rule(struct igc_adapter *adapter,\n {\n \tstruct ethtool_rx_flow_spec *fsp =\n \t\t(struct ethtool_rx_flow_spec *)&cmd->fs;\n-\tint err;\n+\tstruct igc_nfc_rule *rule;\n \n \tspin_lock(&adapter->nfc_rule_lock);\n-\terr = igc_ethtool_update_nfc_rule(adapter, NULL, fsp->location);\n-\tspin_unlock(&adapter->nfc_rule_lock);\n \n-\treturn err;\n+\trule = igc_get_nfc_rule(adapter, fsp->location);\n+\tif (!rule) {\n+\t\tspin_unlock(&adapter->nfc_rule_lock);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tigc_del_nfc_rule(adapter, rule);\n+\n+\tspin_unlock(&adapter->nfc_rule_lock);\n+\treturn 0;\n }\n \n static int igc_ethtool_set_rxnfc(struct net_device *dev,\ndiff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c\nindex 1b554b3a63c2..e09d74331257 100644\n--- a/drivers/net/ethernet/intel/igc/igc_main.c\n+++ b/drivers/net/ethernet/intel/igc/igc_main.c\n@@ -2175,18 +2175,6 @@ static bool igc_clean_tx_irq(struct igc_q_vector *q_vector, int napi_budget)\n \treturn !!budget;\n }\n \n-static void igc_restore_nfc_rules(struct igc_adapter *adapter)\n-{\n-\tstruct igc_nfc_rule *rule;\n-\n-\tspin_lock(&adapter->nfc_rule_lock);\n-\n-\tlist_for_each_entry_reverse(rule, &adapter->nfc_rule_list, list)\n-\t\tigc_enable_nfc_rule(adapter, rule);\n-\n-\tspin_unlock(&adapter->nfc_rule_lock);\n-}\n-\n static int igc_find_mac_filter(struct igc_adapter *adapter,\n \t\t\t       enum igc_mac_filter_type type, const u8 *addr)\n {\n@@ -2243,9 +2231,9 @@ static int igc_get_avail_mac_filter_slot(struct igc_adapter *adapter)\n  *\n  * Return: 0 in case of success, negative errno code otherwise.\n  */\n-int igc_add_mac_filter(struct igc_adapter *adapter,\n-\t\t       enum igc_mac_filter_type type, const u8 *addr,\n-\t\t       int queue)\n+static int igc_add_mac_filter(struct igc_adapter *adapter,\n+\t\t\t      enum igc_mac_filter_type type, const u8 *addr,\n+\t\t\t      int queue)\n {\n \tstruct net_device *dev = adapter->netdev;\n \tint index;\n@@ -2275,8 +2263,8 @@ int igc_add_mac_filter(struct igc_adapter *adapter,\n  *\n  * Return: 0 in case of success, negative errno code otherwise.\n  */\n-int igc_del_mac_filter(struct igc_adapter *adapter,\n-\t\t       enum igc_mac_filter_type type, const u8 *addr)\n+static int igc_del_mac_filter(struct igc_adapter *adapter,\n+\t\t\t      enum igc_mac_filter_type type, const u8 *addr)\n {\n \tstruct net_device *dev = adapter->netdev;\n \tint index;\n@@ -2313,7 +2301,8 @@ int igc_del_mac_filter(struct igc_adapter *adapter,\n  *\n  * Return: 0 in case of success, negative errno code otherwise.\n  */\n-int igc_add_vlan_prio_filter(struct igc_adapter *adapter, int prio, int queue)\n+static int igc_add_vlan_prio_filter(struct igc_adapter *adapter, int prio,\n+\t\t\t\t    int queue)\n {\n \tstruct net_device *dev = adapter->netdev;\n \tstruct igc_hw *hw = &adapter->hw;\n@@ -2341,7 +2330,7 @@ int igc_add_vlan_prio_filter(struct igc_adapter *adapter, int prio, int queue)\n  * @adapter: Pointer to adapter where the filter should be deleted from.\n  * @prio: VLAN priority value.\n  */\n-void igc_del_vlan_prio_filter(struct igc_adapter *adapter, int prio)\n+static void igc_del_vlan_prio_filter(struct igc_adapter *adapter, int prio)\n {\n \tstruct igc_hw *hw = &adapter->hw;\n \tu32 vlanpqf;\n@@ -2382,7 +2371,8 @@ static int igc_get_avail_etype_filter_slot(struct igc_adapter *adapter)\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+static int igc_add_etype_filter(struct igc_adapter *adapter, u16 etype,\n+\t\t\t\tint queue)\n {\n \tstruct igc_hw *hw = &adapter->hw;\n \tint index;\n@@ -2434,7 +2424,7 @@ static int igc_find_etype_filter(struct igc_adapter *adapter, u16 etype)\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+static int igc_del_etype_filter(struct igc_adapter *adapter, u16 etype)\n {\n \tstruct igc_hw *hw = &adapter->hw;\n \tint index;\n@@ -2450,6 +2440,167 @@ int igc_del_etype_filter(struct igc_adapter *adapter, u16 etype)\n \treturn 0;\n }\n \n+static int igc_enable_nfc_rule(struct igc_adapter *adapter,\n+\t\t\t       const struct igc_nfc_rule *rule)\n+{\n+\tint err;\n+\n+\tif (rule->filter.match_flags & IGC_FILTER_FLAG_ETHER_TYPE) {\n+\t\terr = igc_add_etype_filter(adapter, rule->filter.etype,\n+\t\t\t\t\t   rule->action);\n+\t\tif (err)\n+\t\t\treturn err;\n+\t}\n+\n+\tif (rule->filter.match_flags & IGC_FILTER_FLAG_SRC_MAC_ADDR) {\n+\t\terr = igc_add_mac_filter(adapter, IGC_MAC_FILTER_TYPE_SRC,\n+\t\t\t\t\t rule->filter.src_addr, rule->action);\n+\t\tif (err)\n+\t\t\treturn err;\n+\t}\n+\n+\tif (rule->filter.match_flags & IGC_FILTER_FLAG_DST_MAC_ADDR) {\n+\t\terr = igc_add_mac_filter(adapter, IGC_MAC_FILTER_TYPE_DST,\n+\t\t\t\t\t rule->filter.dst_addr, rule->action);\n+\t\tif (err)\n+\t\t\treturn err;\n+\t}\n+\n+\tif (rule->filter.match_flags & IGC_FILTER_FLAG_VLAN_TCI) {\n+\t\tint prio = (rule->filter.vlan_tci & VLAN_PRIO_MASK)\n+\t\t\t\t>> VLAN_PRIO_SHIFT;\n+\n+\t\terr = igc_add_vlan_prio_filter(adapter, prio, rule->action);\n+\t\tif (err)\n+\t\t\treturn err;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static int igc_disable_nfc_rule(struct igc_adapter *adapter,\n+\t\t\t\tconst struct igc_nfc_rule *rule)\n+{\n+\tif (rule->filter.match_flags & IGC_FILTER_FLAG_ETHER_TYPE)\n+\t\tigc_del_etype_filter(adapter, rule->filter.etype);\n+\n+\tif (rule->filter.match_flags & IGC_FILTER_FLAG_VLAN_TCI) {\n+\t\tint prio = (rule->filter.vlan_tci & VLAN_PRIO_MASK)\n+\t\t\t\t>> VLAN_PRIO_SHIFT;\n+\n+\t\tigc_del_vlan_prio_filter(adapter, prio);\n+\t}\n+\n+\tif (rule->filter.match_flags & IGC_FILTER_FLAG_SRC_MAC_ADDR)\n+\t\tigc_del_mac_filter(adapter, IGC_MAC_FILTER_TYPE_SRC,\n+\t\t\t\t   rule->filter.src_addr);\n+\n+\tif (rule->filter.match_flags & IGC_FILTER_FLAG_DST_MAC_ADDR)\n+\t\tigc_del_mac_filter(adapter, IGC_MAC_FILTER_TYPE_DST,\n+\t\t\t\t   rule->filter.dst_addr);\n+\n+\treturn 0;\n+}\n+\n+/**\n+ * igc_get_nfc_rule() - Get NFC rule.\n+ * @adapter: Pointer to adapter.\n+ * @location: Rule location.\n+ *\n+ * Context: Expects adapter->nfc_rule_lock to be held by caller.\n+ *\n+ * Return: Pointer to NFC rule at @location. If not found, NULL.\n+ */\n+struct igc_nfc_rule *igc_get_nfc_rule(struct igc_adapter *adapter,\n+\t\t\t\t      u32 location)\n+{\n+\tstruct igc_nfc_rule *rule;\n+\n+\tlist_for_each_entry(rule, &adapter->nfc_rule_list, list) {\n+\t\tif (rule->location == location)\n+\t\t\treturn rule;\n+\t\tif (rule->location > location)\n+\t\t\tbreak;\n+\t}\n+\n+\treturn NULL;\n+}\n+\n+/**\n+ * igc_del_nfc_rule() - Delete NFC rule.\n+ * @adapter: Pointer to adapter.\n+ * @rule: Pointer to rule to be deleted.\n+ *\n+ * Disable NFC rule in hardware and delete it from adapter.\n+ *\n+ * Context: Expects adapter->nfc_rule_lock to be held by caller.\n+ */\n+void igc_del_nfc_rule(struct igc_adapter *adapter, struct igc_nfc_rule *rule)\n+{\n+\tigc_disable_nfc_rule(adapter, rule);\n+\n+\tlist_del(&rule->list);\n+\tadapter->nfc_rule_count--;\n+\n+\tkfree(rule);\n+}\n+\n+/**\n+ * igc_add_nfc_rule() - Add NFC rule.\n+ * @adapter: Pointer to adapter.\n+ * @rule: Pointer to rule to be added.\n+ *\n+ * Enable NFC rule in hardware and add it to adapter.\n+ *\n+ * Context: Expects adapter->nfc_rule_lock to be held by caller.\n+ *\n+ * Return: 0 on success, negative errno on failure.\n+ */\n+int igc_add_nfc_rule(struct igc_adapter *adapter, struct igc_nfc_rule *rule)\n+{\n+\tstruct igc_nfc_rule *pred, *cur;\n+\tint err;\n+\n+\terr = igc_enable_nfc_rule(adapter, rule);\n+\tif (err)\n+\t\treturn err;\n+\n+\tpred = NULL;\n+\tlist_for_each_entry(cur, &adapter->nfc_rule_list, list) {\n+\t\tif (cur->location >= rule->location)\n+\t\t\tbreak;\n+\t\tpred = cur;\n+\t}\n+\n+\tlist_add(&rule->list, pred ? &pred->list : &adapter->nfc_rule_list);\n+\tadapter->nfc_rule_count++;\n+\treturn 0;\n+}\n+\n+static void igc_restore_nfc_rules(struct igc_adapter *adapter)\n+{\n+\tstruct igc_nfc_rule *rule;\n+\n+\tspin_lock(&adapter->nfc_rule_lock);\n+\n+\tlist_for_each_entry_reverse(rule, &adapter->nfc_rule_list, list)\n+\t\tigc_enable_nfc_rule(adapter, rule);\n+\n+\tspin_unlock(&adapter->nfc_rule_lock);\n+}\n+\n+static void igc_nfc_rule_exit(struct igc_adapter *adapter)\n+{\n+\tstruct igc_nfc_rule *rule;\n+\n+\tspin_lock(&adapter->nfc_rule_lock);\n+\n+\tlist_for_each_entry(rule, &adapter->nfc_rule_list, list)\n+\t\tigc_disable_nfc_rule(adapter, rule);\n+\n+\tspin_unlock(&adapter->nfc_rule_lock);\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@@ -3649,18 +3800,6 @@ void igc_update_stats(struct igc_adapter *adapter)\n \tadapter->stats.mgpdc += rd32(IGC_MGTPDC);\n }\n \n-static void igc_nfc_rule_exit(struct igc_adapter *adapter)\n-{\n-\tstruct igc_nfc_rule *rule;\n-\n-\tspin_lock(&adapter->nfc_rule_lock);\n-\n-\tlist_for_each_entry(rule, &adapter->nfc_rule_list, list)\n-\t\tigc_disable_nfc_rule(adapter, rule);\n-\n-\tspin_unlock(&adapter->nfc_rule_lock);\n-}\n-\n /**\n  * igc_down - Close the interface\n  * @adapter: board private structure\n",
    "prefixes": [
        "14/19"
    ]
}