get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 1257851,
    "url": "http://patchwork.ozlabs.org/api/patches/1257851/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20200318230102.36952-11-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-11-andre.guedes@intel.com>",
    "list_archive_url": null,
    "date": "2020-03-18T23:01:00",
    "name": "[10/12] igc: Refactor igc_mac_entry_can_be_used()",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "4b05bdfcac7c932b23731380292b7d163d3a8e8e",
    "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-11-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/1257851/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/1257851/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.137;\n\thelo=fraxinus.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 fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137])\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 48jQXt3Khpz9sQt\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 19 Mar 2020 10:02:22 +1100 (AEDT)",
            "from localhost (localhost [127.0.0.1])\n\tby fraxinus.osuosl.org (Postfix) with ESMTP id 0A838866C8;\n\tWed, 18 Mar 2020 23:02:21 +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 635u6UPoRMW7; Wed, 18 Mar 2020 23:02:19 +0000 (UTC)",
            "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby fraxinus.osuosl.org (Postfix) with ESMTP id D057D86637;\n\tWed, 18 Mar 2020 23:02:19 +0000 (UTC)",
            "from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136])\n\tby ash.osuosl.org (Postfix) with ESMTP id E778A1BF335\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tWed, 18 Mar 2020 23:02:16 +0000 (UTC)",
            "from localhost (localhost [127.0.0.1])\n\tby silver.osuosl.org (Postfix) with ESMTP id E29042044A\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tWed, 18 Mar 2020 23:02:16 +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 Xr-QoVEUO1fr for <intel-wired-lan@lists.osuosl.org>;\n\tWed, 18 Mar 2020 23:02:11 +0000 (UTC)",
            "from mga09.intel.com (mga09.intel.com [134.134.136.24])\n\tby silver.osuosl.org (Postfix) with ESMTPS id AE0E4203EE\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tWed, 18 Mar 2020 23:02:11 +0000 (UTC)",
            "from orsmga006.jf.intel.com ([10.7.209.51])\n\tby orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; \n\t18 Mar 2020 16:02:10 -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:10 -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": [
            "HRqL4UmIV2rLy/7Q5m99XcUCHKpU7GGgBDtnLWUqUj/gKZSv4zgCKT39OXqIk6tefmNLfJuK/V\n\tvIT8A8nO8ihg==",
            "E2Ugk9ivmcSk1Otmchxk5rlhecm7aABUstEro/0Eq35Qa8jLH0+oeFhCWRW0NY5V6A5dCTCGAs\n\tKo24/wevQKpg=="
        ],
        "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=\"248341790\"",
        "From": "Andre Guedes <andre.guedes@intel.com>",
        "To": "intel-wired-lan@lists.osuosl.org",
        "Date": "Wed, 18 Mar 2020 16:01:00 -0700",
        "Message-Id": "<20200318230102.36952-11-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 10/12] igc: Refactor\n\tigc_mac_entry_can_be_used()",
        "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 helper igc_mac_entry_can_be_used() implementation is a bit\nconvoluted since it does two different things: find a not-in-use slot\nin mac_table or find an in-use slot where the address and address type\nmatch. This patch does a code refactoring and break it up into two\nhelper functions.\n\nWith this patch we might traverse mac_table twice in some situations,\nbut this is not harmful performance-wise (mac_table has only 16 entries\nand adding mac filters is not hot-path), and it improves igc_add_mac_\nfilter() readability considerably.\n\nSigned-off-by: Andre Guedes <andre.guedes@intel.com>\n---\n drivers/net/ethernet/intel/igc/igc_main.c | 80 +++++++++++++----------\n 1 file changed, 47 insertions(+), 33 deletions(-)",
    "diff": "diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c\nindex 25d0431f4f4a..0264e424bd07 100644\n--- a/drivers/net/ethernet/intel/igc/igc_main.c\n+++ b/drivers/net/ethernet/intel/igc/igc_main.c\n@@ -2177,25 +2177,44 @@ static void igc_nfc_filter_restore(struct igc_adapter *adapter)\n \tspin_unlock(&adapter->nfc_lock);\n }\n \n-/* If the filter to be added and an already existing filter express\n- * the same address and address type, it should be possible to only\n- * override the other configurations, for example the queue to steer\n- * traffic.\n- */\n-static bool igc_mac_entry_can_be_used(const struct igc_mac_addr *entry,\n-\t\t\t\t      const u8 *addr, const u8 flags)\n+static int igc_find_mac_filter(struct igc_adapter *adapter, const u8 *addr,\n+\t\t\t       u8 flags)\n {\n-\tif (!(entry->state & IGC_MAC_STATE_IN_USE))\n-\t\treturn true;\n+\tint max_entries = adapter->hw.mac.rar_entry_count;\n+\tstruct igc_mac_addr *entry;\n+\tint i;\n \n-\tif ((entry->state & IGC_MAC_STATE_SRC_ADDR) !=\n-\t    (flags & IGC_MAC_STATE_SRC_ADDR))\n-\t\treturn false;\n+\tfor (i = 0; i < max_entries; i++) {\n+\t\tentry = &adapter->mac_table[i];\n \n-\tif (!ether_addr_equal(addr, entry->addr))\n-\t\treturn false;\n+\t\tif (!(entry->state & IGC_MAC_STATE_IN_USE))\n+\t\t\tcontinue;\n+\t\tif (!ether_addr_equal(addr, entry->addr))\n+\t\t\tcontinue;\n+\t\tif ((entry->state & IGC_MAC_STATE_SRC_ADDR) !=\n+\t\t    (flags & IGC_MAC_STATE_SRC_ADDR))\n+\t\t\tcontinue;\n \n-\treturn true;\n+\t\treturn i;\n+\t}\n+\n+\treturn -1;\n+}\n+\n+static int igc_get_avail_mac_filter_slot(struct igc_adapter *adapter)\n+{\n+\tint max_entries = adapter->hw.mac.rar_entry_count;\n+\tstruct igc_mac_addr *entry;\n+\tint i;\n+\n+\tfor (i = 0; i < max_entries; i++) {\n+\t\tentry = &adapter->mac_table[i];\n+\n+\t\tif (!(entry->state & IGC_MAC_STATE_IN_USE))\n+\t\t\treturn i;\n+\t}\n+\n+\treturn -1;\n }\n \n /* Add MAC address filter to adapter.\n@@ -2213,33 +2232,28 @@ static bool igc_mac_entry_can_be_used(const struct igc_mac_addr *entry,\n int igc_add_mac_filter(struct igc_adapter *adapter, const u8 *addr,\n \t\t       const s8 queue, const u8 flags)\n {\n-\tstruct igc_hw *hw = &adapter->hw;\n-\tint rar_entries = hw->mac.rar_entry_count;\n-\tint i;\n+\tint index;\n \n \tif (!is_valid_ether_addr(addr))\n \t\treturn -EINVAL;\n \tif (flags & IGC_MAC_STATE_SRC_ADDR)\n \t\treturn -ENOTSUPP;\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+\tindex = igc_find_mac_filter(adapter, addr, flags);\n+\tif (index >= 0)\n+\t\tgoto update_queue_assignment;\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+\tindex = igc_get_avail_mac_filter_slot(adapter);\n+\tif (index < 0)\n+\t\treturn -ENOSPC;\n \n-\t\tigc_set_mac_filter_hw(adapter, i, addr, queue);\n-\t\treturn 0;\n-\t}\n+\tether_addr_copy(adapter->mac_table[index].addr, addr);\n+\tadapter->mac_table[index].state |= IGC_MAC_STATE_IN_USE | flags;\n+update_queue_assignment:\n+\tadapter->mac_table[index].queue = queue;\n \n-\treturn -ENOSPC;\n+\tigc_set_mac_filter_hw(adapter, index, addr, queue);\n+\treturn 0;\n }\n \n /* Delete MAC address filter from adapter.\n",
    "prefixes": [
        "10/12"
    ]
}