get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 1257847,
    "url": "http://patchwork.ozlabs.org/api/patches/1257847/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20200318230102.36952-6-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-6-andre.guedes@intel.com>",
    "list_archive_url": null,
    "date": "2020-03-18T23:00:55",
    "name": "[05/12] igc: Refactor igc_rar_set_index()",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "5c64b78931b5fd4c6cdddee356df8ab796664a9d",
    "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-6-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/1257847/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/1257847/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 48jQXn4scPz9sPk\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 19 Mar 2020 10:02:17 +1100 (AEDT)",
            "from localhost (localhost [127.0.0.1])\n\tby fraxinus.osuosl.org (Postfix) with ESMTP id 42BF286610;\n\tWed, 18 Mar 2020 23:02:16 +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 rS0HITlwjuPb; Wed, 18 Mar 2020 23:02:15 +0000 (UTC)",
            "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby fraxinus.osuosl.org (Postfix) with ESMTP id 9A5958665F;\n\tWed, 18 Mar 2020 23:02:15 +0000 (UTC)",
            "from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137])\n\tby ash.osuosl.org (Postfix) with ESMTP id 0D0BE1BF335\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tWed, 18 Mar 2020 23:02:12 +0000 (UTC)",
            "from localhost (localhost [127.0.0.1])\n\tby fraxinus.osuosl.org (Postfix) with ESMTP id 0A82986644\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tWed, 18 Mar 2020 23:02:12 +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 0o6X65KWlwim for <intel-wired-lan@lists.osuosl.org>;\n\tWed, 18 Mar 2020 23:02:09 +0000 (UTC)",
            "from mga17.intel.com (mga17.intel.com [192.55.52.151])\n\tby fraxinus.osuosl.org (Postfix) with ESMTPS id AE6E386640\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tWed, 18 Mar 2020 23:02:09 +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:09 -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:09 -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": [
            "zznTgVIEPssPyTOkkwa84shZN9GsMbSNOkF9cEgUpkbvLDMRBuSMI1QB2v/uhQdnvOMuyZ1xyH\n\ttrv5s4pJccgA==",
            "kgt9P5bXfdbfPUOPko4YP5JCRpHoWA8cJHkJLlV21YBPvUVdmRlJRInUcGUjdkgeopF01vXeHI\n\tyP9xn50JOvig=="
        ],
        "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=\"248341777\"",
        "From": "Andre Guedes <andre.guedes@intel.com>",
        "To": "intel-wired-lan@lists.osuosl.org",
        "Date": "Wed, 18 Mar 2020 16:00:55 -0700",
        "Message-Id": "<20200318230102.36952-6-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 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>\n---\n drivers/net/ethernet/intel/igc/igc_main.c | 75 +++++++++++++----------\n 1 file changed, 43 insertions(+), 32 deletions(-)",
    "diff": "diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c\nindex cc1e1b0286b3..0ca7afaf6fc7 100644\n--- a/drivers/net/ethernet/intel/igc/igc_main.c\n+++ b/drivers/net/ethernet/intel/igc/igc_main.c\n@@ -764,43 +764,53 @@ static void igc_setup_tctl(struct igc_adapter *adapter)\n \twr32(IGC_TCTL, tctl);\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+/* Set MAC address filter in hardware.\n+ *\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 assignment\n+ * 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+/* Clear MAC address filter in hardware.\n+ *\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": [
        "05/12"
    ]
}