get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 1032836,
    "url": "http://patchwork.ozlabs.org/api/patches/1032836/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/netdev/patch/20190129150143.12681-13-mika.westerberg@linux.intel.com/",
    "project": {
        "id": 7,
        "url": "http://patchwork.ozlabs.org/api/projects/7/?format=api",
        "name": "Linux network development",
        "link_name": "netdev",
        "list_id": "netdev.vger.kernel.org",
        "list_email": "netdev@vger.kernel.org",
        "web_url": null,
        "scm_url": null,
        "webscm_url": null,
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<20190129150143.12681-13-mika.westerberg@linux.intel.com>",
    "list_archive_url": null,
    "date": "2019-01-29T15:01:27",
    "name": "[12/28] thunderbolt: Add functions for allocating and releasing hop IDs",
    "commit_ref": null,
    "pull_url": null,
    "state": "not-applicable",
    "archived": false,
    "hash": "0d6439f7b24869d93187390efbdb11dde3b0da8f",
    "submitter": {
        "id": 14534,
        "url": "http://patchwork.ozlabs.org/api/people/14534/?format=api",
        "name": "Mika Westerberg",
        "email": "mika.westerberg@linux.intel.com"
    },
    "delegate": {
        "id": 34,
        "url": "http://patchwork.ozlabs.org/api/users/34/?format=api",
        "username": "davem",
        "first_name": "David",
        "last_name": "Miller",
        "email": "davem@davemloft.net"
    },
    "mbox": "http://patchwork.ozlabs.org/project/netdev/patch/20190129150143.12681-13-mika.westerberg@linux.intel.com/mbox/",
    "series": [
        {
            "id": 88859,
            "url": "http://patchwork.ozlabs.org/api/series/88859/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/netdev/list/?series=88859",
            "date": "2019-01-29T15:01:18",
            "name": "thunderbolt: Software connection manager improvements",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/88859/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/1032836/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/1032836/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<netdev-owner@vger.kernel.org>",
        "X-Original-To": "patchwork-incoming-netdev@ozlabs.org",
        "Delivered-To": "patchwork-incoming-netdev@ozlabs.org",
        "Authentication-Results": [
            "ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)",
            "ozlabs.org; dmarc=none (p=none dis=none)\n\theader.from=linux.intel.com"
        ],
        "Received": [
            "from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 43pqYj3x3pz9sDr\n\tfor <patchwork-incoming-netdev@ozlabs.org>;\n\tWed, 30 Jan 2019 02:05:29 +1100 (AEDT)",
            "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1729189AbfA2PFI (ORCPT\n\t<rfc822;patchwork-incoming-netdev@ozlabs.org>);\n\tTue, 29 Jan 2019 10:05:08 -0500",
            "from mga05.intel.com ([192.55.52.43]:51758 \"EHLO mga05.intel.com\"\n\trhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP\n\tid S1728201AbfA2PBw (ORCPT <rfc822;netdev@vger.kernel.org>);\n\tTue, 29 Jan 2019 10:01:52 -0500",
            "from orsmga005.jf.intel.com ([10.7.209.41])\n\tby fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t29 Jan 2019 07:01:51 -0800",
            "from black.fi.intel.com ([10.237.72.28])\n\tby orsmga005.jf.intel.com with ESMTP; 29 Jan 2019 07:01:48 -0800",
            "by black.fi.intel.com (Postfix, from userid 1001)\n\tid BDB117A8; Tue, 29 Jan 2019 17:01:44 +0200 (EET)"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.56,537,1539673200\"; d=\"scan'208\";a=\"295379818\"",
        "From": "Mika Westerberg <mika.westerberg@linux.intel.com>",
        "To": "linux-kernel@vger.kernel.org",
        "Cc": "Michael Jamet <michael.jamet@intel.com>,\n\tYehezkel Bernat <YehezkelShB@gmail.com>,\n\tAndreas Noever <andreas.noever@gmail.com>,\n\tLukas Wunner <lukas@wunner.de>, \"David S . Miller\" <davem@davemloft.net>,\n\tMika Westerberg <mika.westerberg@linux.intel.com>,\n\tAndy Shevchenko <andriy.shevchenko@linux.intel.com>,\n\tnetdev@vger.kernel.org",
        "Subject": "[PATCH 12/28] thunderbolt: Add functions for allocating and\n\treleasing hop IDs",
        "Date": "Tue, 29 Jan 2019 18:01:27 +0300",
        "Message-Id": "<20190129150143.12681-13-mika.westerberg@linux.intel.com>",
        "X-Mailer": "git-send-email 2.20.1",
        "In-Reply-To": "<20190129150143.12681-1-mika.westerberg@linux.intel.com>",
        "References": "<20190129150143.12681-1-mika.westerberg@linux.intel.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Sender": "netdev-owner@vger.kernel.org",
        "Precedence": "bulk",
        "List-ID": "<netdev.vger.kernel.org>",
        "X-Mailing-List": "netdev@vger.kernel.org"
    },
    "content": "Each port has a separate path configuration space that is used for\nfinding the next hop (switch) in the path. Hop ID is an index to this\nconfiguration space and hop IDs 0 - 7 are reserved.\n\nIn order to get next available hop ID for each direction we provide two\npairs of helper functions that can be used to allocate and release hop\nIDs for a given port.\n\nWhile there remove obsolete TODO comment.\n\nSigned-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>\n---\n drivers/thunderbolt/switch.c | 87 +++++++++++++++++++++++++++++++++++-\n drivers/thunderbolt/tb.h     |  8 ++++\n 2 files changed, 94 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c\nindex 93b26c901637..ae366c252c74 100644\n--- a/drivers/thunderbolt/switch.c\n+++ b/drivers/thunderbolt/switch.c\n@@ -601,11 +601,88 @@ static int tb_init_port(struct tb_port *port)\n \n \ttb_dump_port(port->sw->tb, &port->config);\n \n-\t/* TODO: Read dual link port, DP port and more from EEPROM. */\n+\t/* Control port does not need Hop ID allocation */\n+\tif (port->port) {\n+\t\tida_init(&port->in_hopids);\n+\t\tida_init(&port->out_hopids);\n+\t}\n+\n \treturn 0;\n \n }\n \n+static int tb_port_alloc_hopid(struct tb_port *port, bool in, int min_hopid,\n+\t\t\t       int max_hopid)\n+{\n+\tint port_max_hopid;\n+\tstruct ida *ida;\n+\n+\tif (in) {\n+\t\tport_max_hopid = port->config.max_in_hop_id;\n+\t\tida = &port->in_hopids;\n+\t} else {\n+\t\tport_max_hopid = port->config.max_out_hop_id;\n+\t\tida = &port->out_hopids;\n+\t}\n+\n+\t/* Hop IDs 0-7 are reserved */\n+\tif (min_hopid < 8)\n+\t\tmin_hopid = 8;\n+\n+\tif (max_hopid < 0 || max_hopid > port_max_hopid)\n+\t\tmax_hopid = port_max_hopid;\n+\n+\treturn ida_simple_get(ida, min_hopid, max_hopid + 1, GFP_KERNEL);\n+}\n+\n+/**\n+ * tb_port_alloc_in_hopid() - Allocate input hop ID from port\n+ * @port: Port to allocate hop ID for\n+ * @min_hopid: Minimum acceptable input hop ID\n+ * @max_hopid: Maximum acceptable input hop ID\n+ *\n+ * Return: Hop ID between @min_hopid and @max_hopid or negative errno in\n+ * case of error.\n+ */\n+int tb_port_alloc_in_hopid(struct tb_port *port, int min_hopid, int max_hopid)\n+{\n+\treturn tb_port_alloc_hopid(port, true, min_hopid, max_hopid);\n+}\n+\n+/**\n+ * tb_port_alloc_out_hopid() - Allocate output hop ID from port\n+ * @port: Port to allocate hop ID for\n+ * @min_hopid: Minimum acceptable output hop ID\n+ * @max_hopid: Maximum acceptable output hop ID\n+ *\n+ * Return: Hop ID between @min_hopid and @max_hopid or negative errno in\n+ * case of error.\n+ */\n+int tb_port_alloc_out_hopid(struct tb_port *port, int min_hopid, int max_hopid)\n+{\n+\treturn tb_port_alloc_hopid(port, false, min_hopid, max_hopid);\n+}\n+\n+/**\n+ * tb_port_release_in_hopid() - Release allocated input hop ID from port\n+ * @port: Port whose hop ID to release\n+ * @hopid: Hop ID to release\n+ */\n+void tb_port_release_in_hopid(struct tb_port *port, int hopid)\n+{\n+\tida_simple_remove(&port->in_hopids, hopid);\n+}\n+\n+/**\n+ * tb_port_release_out_hopid() - Release allocated output hop ID from port\n+ * @port: Port whose hop ID to release\n+ * @hopid: Hop ID to release\n+ */\n+void tb_port_release_out_hopid(struct tb_port *port, int hopid)\n+{\n+\tida_simple_remove(&port->out_hopids, hopid);\n+}\n+\n /**\n  * tb_pci_port_enable() - Enable PCIe adapter port\n  * @port: PCIe port to enable\n@@ -1080,9 +1157,17 @@ static const struct attribute_group *switch_groups[] = {\n static void tb_switch_release(struct device *dev)\n {\n \tstruct tb_switch *sw = tb_to_switch(dev);\n+\tint i;\n \n \tdma_port_free(sw->dma_port);\n \n+\tfor (i = 1; i <= sw->config.max_port_number; i++) {\n+\t\tif (!sw->ports[i].disabled) {\n+\t\t\tida_destroy(&sw->ports[i].in_hopids);\n+\t\t\tida_destroy(&sw->ports[i].out_hopids);\n+\t\t}\n+\t}\n+\n \tkfree(sw->uuid);\n \tkfree(sw->device_name);\n \tkfree(sw->vendor_name);\ndiff --git a/drivers/thunderbolt/tb.h b/drivers/thunderbolt/tb.h\nindex ca7e78190920..a4f835c4bdc2 100644\n--- a/drivers/thunderbolt/tb.h\n+++ b/drivers/thunderbolt/tb.h\n@@ -131,6 +131,8 @@ struct tb_switch {\n  * @dual_link_port: If the switch is connected using two ports, points\n  *\t\t    to the other port.\n  * @link_nr: Is this primary or secondary port on the dual_link.\n+ * @in_hopids: Currently allocated input hopids\n+ * @out_hopids: Currently allocated output hopids\n  */\n struct tb_port {\n \tstruct tb_regs_port_header config;\n@@ -143,6 +145,8 @@ struct tb_port {\n \tbool disabled;\n \tstruct tb_port *dual_link_port;\n \tu8 link_nr:1;\n+\tstruct ida in_hopids;\n+\tstruct ida out_hopids;\n };\n \n /**\n@@ -440,6 +444,10 @@ static inline struct tb_switch *tb_to_switch(struct device *dev)\n int tb_wait_for_port(struct tb_port *port, bool wait_if_unplugged);\n int tb_port_add_nfc_credits(struct tb_port *port, int credits);\n int tb_port_clear_counter(struct tb_port *port, int counter);\n+int tb_port_alloc_in_hopid(struct tb_port *port, int hopid, int max_hopid);\n+void tb_port_release_in_hopid(struct tb_port *port, int hopid);\n+int tb_port_alloc_out_hopid(struct tb_port *port, int hopid, int max_hopid);\n+void tb_port_release_out_hopid(struct tb_port *port, int hopid);\n \n int tb_switch_find_vse_cap(struct tb_switch *sw, enum tb_switch_vse_cap vsec);\n int tb_port_find_cap(struct tb_port *port, enum tb_port_cap cap);\n",
    "prefixes": [
        "12/28"
    ]
}