get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 1265354,
    "url": "http://patchwork.ozlabs.org/api/patches/1265354/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20200401213645.2566-1-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": "<20200401213645.2566-1-andre.guedes@intel.com>",
    "list_archive_url": null,
    "date": "2020-04-01T21:36:45",
    "name": "[v2,05/12] igc: Refactor igc_rar_set_index()",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "c8f8673bca793f72f4d25ccd9a14f77326df992c",
    "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/20200401213645.2566-1-andre.guedes@intel.com/mbox/",
    "series": [
        {
            "id": 168116,
            "url": "http://patchwork.ozlabs.org/api/series/168116/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/list/?series=168116",
            "date": "2020-04-01T21:36:45",
            "name": null,
            "version": 2,
            "mbox": "http://patchwork.ozlabs.org/series/168116/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/1265354/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/1265354/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 48t00C6TZqz9sP7\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu,  2 Apr 2020 08:37:13 +1100 (AEDT)",
            "from localhost (localhost [127.0.0.1])\n\tby silver.osuosl.org (Postfix) with ESMTP id 73A5F25CA8;\n\tWed,  1 Apr 2020 21:37:11 +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 p8S4vZPz7q7M; Wed,  1 Apr 2020 21:37:09 +0000 (UTC)",
            "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby silver.osuosl.org (Postfix) with ESMTP id 485D52549C;\n\tWed,  1 Apr 2020 21:37:09 +0000 (UTC)",
            "from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136])\n\tby ash.osuosl.org (Postfix) with ESMTP id 22A641BF47E\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tWed,  1 Apr 2020 21:37:08 +0000 (UTC)",
            "from localhost (localhost [127.0.0.1])\n\tby silver.osuosl.org (Postfix) with ESMTP id 1CC1E25AB8\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tWed,  1 Apr 2020 21:37:08 +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 YzXUiNirv56d for <intel-wired-lan@lists.osuosl.org>;\n\tWed,  1 Apr 2020 21:37:06 +0000 (UTC)",
            "from mga17.intel.com (mga17.intel.com [192.55.52.151])\n\tby silver.osuosl.org (Postfix) with ESMTPS id CDCDF20511\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tWed,  1 Apr 2020 21:37:06 +0000 (UTC)",
            "from fmsmga006.fm.intel.com ([10.253.24.20])\n\tby fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; \n\t01 Apr 2020 14:37:06 -0700",
            "from khsantac-mobl1.amr.corp.intel.com ([10.251.8.15])\n\tby fmsmga006.fm.intel.com with ESMTP; 01 Apr 2020 14:37:05 -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": [
            "c0iRa2olkQkoiuw9/dKlRp+zX/an0tdAJCpa8E6SHnuWjNdMD+ONMwzqmG11aZjzWB0vB7plNw\n\tJLjXa244i9vA==",
            "HBwXwOQQhkeccwi8fQJowYeDaIxHD4D2NLSFq55RNskL0O14+g9lB8RNHT8vZZnJ/YBEAEvWcD\n\tObl3rrx8G8gg=="
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.72,333,1580803200\"; d=\"scan'208\";a=\"450710960\"",
        "From": "Andre Guedes <andre.guedes@intel.com>",
        "To": "intel-wired-lan@lists.osuosl.org",
        "Date": "Wed,  1 Apr 2020 14:36:45 -0700",
        "Message-Id": "<20200401213645.2566-1-andre.guedes@intel.com>",
        "X-Mailer": "git-send-email 2.26.0",
        "In-Reply-To": "<20200318230102.36952-6-andre.guedes@intel.com>",
        "References": "<20200318230102.36952-6-andre.guedes@intel.com>",
        "MIME-Version": "1.0",
        "Subject": "[Intel-wired-lan] [PATCH v2 05/12] igc: Refactor igc_rar_set_index()",
        "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": "Current igc_rar_set_index() implementation is a bit convoluted so this\npatch does some code refactoring to improve it.\n\nThe helper igc_rar_set_index() is about writing MAC filter settings into\nhardware registers. Logic such as address validation belongs to\nfunctions upper in the call chain such as igc_set_mac() and\nigc_add_mac_filter(). So this patch moves the is_valid_ether_addr() call\nto igc_add_mac_filter(). No need to touch igc_set_mac() since it already\nchecks it.\n\nThe variables 'rar_low' and 'rar_high' represent the value in registers\nRAL and RAH so we rename them to 'ral' and 'rah', respectivelly, to\nmatch the registers names.\n\nTo make it explicity, filter settings are passed as arguments to the\nfunction instead of reading them from adapter->mac_table \"under the\nhood\". Also, the function was renamed to igc_set_mac_filter_hw to make\nit more clear what it does.\n\nFinally, the patch removes some wrfl() calls and comments not needed.\n\nSigned-off-by: Andre Guedes <andre.guedes@intel.com>\nTested-by: Aaron Brown <aaron.f.brown@intel.com>\n---\nv2: Fix function documentation to follow kernel-doc style.\n---\n drivers/net/ethernet/intel/igc/igc_main.c | 73 +++++++++++++----------\n 1 file changed, 42 insertions(+), 31 deletions(-)",
    "diff": "diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c\nindex cc1e1b0286b3..c94e4e31e04b 100644\n--- a/drivers/net/ethernet/intel/igc/igc_main.c\n+++ b/drivers/net/ethernet/intel/igc/igc_main.c\n@@ -765,42 +765,52 @@ static void igc_setup_tctl(struct igc_adapter *adapter)\n }\n \n /**\n- * igc_rar_set_index - Sync RAL[index] and RAH[index] registers with MAC table\n- * @adapter: address of board private structure\n- * @index: Index of the RAR entry which need to be synced with MAC table\n+ * igc_set_mac_filter_hw() - Set MAC address filter in hardware.\n+ * @adapter: Pointer to adapter where the filter should be set.\n+ * @index: Filter index.\n+ * @addr: Destination MAC address.\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-static void igc_rar_set_index(struct igc_adapter *adapter, u32 index)\n+static void igc_set_mac_filter_hw(struct igc_adapter *adapter, int index,\n+\t\t\t\t  const u8 *addr, int queue)\n {\n-\tu8 *addr = adapter->mac_table[index].addr;\n \tstruct igc_hw *hw = &adapter->hw;\n-\tu32 rar_low, rar_high;\n+\tu32 ral, rah;\n \n-\t/* HW expects these to be in network order when they are plugged\n-\t * into the registers which are little endian.  In order to guarantee\n-\t * that ordering we need to do an leXX_to_cpup here in order to be\n-\t * ready for the byteswap that occurs with writel\n-\t */\n-\trar_low = le32_to_cpup((__le32 *)(addr));\n-\trar_high = le16_to_cpup((__le16 *)(addr + 4));\n+\tif (WARN_ON(index >= hw->mac.rar_entry_count))\n+\t\treturn;\n \n-\tif (adapter->mac_table[index].state & IGC_MAC_STATE_QUEUE_STEERING) {\n-\t\tu8 queue = adapter->mac_table[index].queue;\n-\t\tu32 qsel = IGC_RAH_QSEL_MASK & (queue << IGC_RAH_QSEL_SHIFT);\n+\tral = le32_to_cpup((__le32 *)(addr));\n+\trah = le16_to_cpup((__le16 *)(addr + 4));\n \n-\t\trar_high |= qsel;\n-\t\trar_high |= IGC_RAH_QSEL_ENABLE;\n+\tif (queue >= 0) {\n+\t\trah &= ~IGC_RAH_QSEL_MASK;\n+\t\trah |= (queue << IGC_RAH_QSEL_SHIFT);\n+\t\trah |= IGC_RAH_QSEL_ENABLE;\n \t}\n \n-\t/* Indicate to hardware the Address is Valid. */\n-\tif (adapter->mac_table[index].state & IGC_MAC_STATE_IN_USE) {\n-\t\tif (is_valid_ether_addr(addr))\n-\t\t\trar_high |= IGC_RAH_AV;\n-\t}\n+\trah |= IGC_RAH_AV;\n \n-\twr32(IGC_RAL(index), rar_low);\n-\twrfl();\n-\twr32(IGC_RAH(index), rar_high);\n-\twrfl();\n+\twr32(IGC_RAL(index), ral);\n+\twr32(IGC_RAH(index), rah);\n+}\n+\n+/**\n+ * igc_clear_mac_filter_hw() - Clear MAC address filter in hardware.\n+ * @adapter: Pointer to adapter where the filter should be cleared.\n+ * @index: Filter index.\n+ */\n+static void igc_clear_mac_filter_hw(struct igc_adapter *adapter, int index)\n+{\n+\tstruct igc_hw *hw = &adapter->hw;\n+\n+\tif (WARN_ON(index >= hw->mac.rar_entry_count))\n+\t\treturn;\n+\n+\twr32(IGC_RAL(index), 0);\n+\twr32(IGC_RAH(index), 0);\n }\n \n /* Set default MAC address for the PF in the first RAR entry */\n@@ -811,7 +821,7 @@ static void igc_set_default_mac_filter(struct igc_adapter *adapter)\n \tether_addr_copy(mac_table->addr, adapter->hw.mac.addr);\n \tmac_table->state = IGC_MAC_STATE_DEFAULT | IGC_MAC_STATE_IN_USE;\n \n-\tigc_rar_set_index(adapter, 0);\n+\tigc_set_mac_filter_hw(adapter, 0, mac_table->addr, -1);\n }\n \n /**\n@@ -2199,7 +2209,7 @@ static int igc_add_mac_filter(struct igc_adapter *adapter, const u8 *addr,\n \tint rar_entries = hw->mac.rar_entry_count;\n \tint i;\n \n-\tif (is_zero_ether_addr(addr))\n+\tif (!is_valid_ether_addr(addr))\n \t\treturn -EINVAL;\n \tif (flags & IGC_MAC_STATE_SRC_ADDR)\n \t\treturn -ENOTSUPP;\n@@ -2217,7 +2227,7 @@ static int igc_add_mac_filter(struct igc_adapter *adapter, const u8 *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\tigc_set_mac_filter_hw(adapter, i, addr, queue);\n \t\treturn 0;\n \t}\n \n@@ -2261,13 +2271,14 @@ static int igc_del_mac_filter(struct igc_adapter *adapter, const u8 *addr,\n \t\t\tadapter->mac_table[i].state =\n \t\t\t\tIGC_MAC_STATE_DEFAULT | IGC_MAC_STATE_IN_USE;\n \t\t\tadapter->mac_table[i].queue = 0;\n+\t\t\tigc_set_mac_filter_hw(adapter, 0, addr, -1);\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\tigc_clear_mac_filter_hw(adapter, i);\n \t\t}\n \n-\t\tigc_rar_set_index(adapter, i);\n \t\treturn 0;\n \t}\n \n",
    "prefixes": [
        "v2",
        "05/12"
    ]
}