get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 1032834,
    "url": "http://patchwork.ozlabs.org/api/patches/1032834/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/netdev/patch/20190129150143.12681-15-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-15-mika.westerberg@linux.intel.com>",
    "list_archive_url": null,
    "date": "2019-01-29T15:01:29",
    "name": "[14/28] thunderbolt: Extend tunnel creation to more than 2 adjacent switches",
    "commit_ref": null,
    "pull_url": null,
    "state": "not-applicable",
    "archived": false,
    "hash": "ffeef918e9bff3b27a94d44b3bc32e587e6f3587",
    "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-15-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/1032834/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/1032834/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 43pqYf0980z9sMM\n\tfor <patchwork-incoming-netdev@ozlabs.org>;\n\tWed, 30 Jan 2019 02:05:26 +1100 (AEDT)",
            "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1729207AbfA2PFI (ORCPT\n\t<rfc822;patchwork-incoming-netdev@ozlabs.org>);\n\tTue, 29 Jan 2019 10:05:08 -0500",
            "from mga02.intel.com ([134.134.136.20]:34504 \"EHLO mga02.intel.com\"\n\trhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP\n\tid S1728194AbfA2PBw (ORCPT <rfc822;netdev@vger.kernel.org>);\n\tTue, 29 Jan 2019 10:01:52 -0500",
            "from orsmga006.jf.intel.com ([10.7.209.51])\n\tby orsmga101.jf.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 orsmga006.jf.intel.com with ESMTP; 29 Jan 2019 07:01:48 -0800",
            "by black.fi.intel.com (Postfix, from userid 1001)\n\tid D5D627E5; 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=\"112013836\"",
        "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 14/28] thunderbolt: Extend tunnel creation to more than 2\n\tadjacent switches",
        "Date": "Tue, 29 Jan 2019 18:01:29 +0300",
        "Message-Id": "<20190129150143.12681-15-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": "Now that we can allocate hop IDs per port on a path, we can take\nadvantage of this and create tunnels covering longer paths than just\nbetween two adjacent switches. PCIe actually does not need this as it is\nalways a daisy chain between two adjacent switches but this way we do\nnot need to hard-code creation of the tunnel.\n\nSigned-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>\n---\n drivers/thunderbolt/path.c   | 94 ++++++++++++++++++++++++++++++++++--\n drivers/thunderbolt/tb.h     |  4 +-\n drivers/thunderbolt/tunnel.c | 54 +++++----------------\n 3 files changed, 106 insertions(+), 46 deletions(-)",
    "diff": "diff --git a/drivers/thunderbolt/path.c b/drivers/thunderbolt/path.c\nindex 48cb15ff4446..122e6a1daf34 100644\n--- a/drivers/thunderbolt/path.c\n+++ b/drivers/thunderbolt/path.c\n@@ -31,23 +31,97 @@ static void tb_dump_hop(struct tb_port *port, struct tb_regs_hop *hop)\n }\n \n /**\n- * tb_path_alloc() - allocate a thunderbolt path\n+ * tb_path_alloc() - allocate a thunderbolt path between two ports\n+ * @tb: Domain pointer\n+ * @src: Source port of the path\n+ * @dst: Destination port of the path\n+ * @start_hopid: Hop ID used for the first ingress port in the path\n+ * @end_hopid: Hop ID used for the last egress port in the path (%-1 for\n+ *\t       automatic allocation)\n+ * @link_nr: Preferred link if there are dual links on the path\n+ *\n+ * Creates path between two ports starting with given @start_hopid. Reserves\n+ * hop IDs for each port (they can be different from @start_hopid depending on\n+ * how many hop IDs each port already have reserved). If there are dual\n+ * links on the path, prioritizes using @link_nr.\n  *\n  * Return: Returns a tb_path on success or NULL on failure.\n  */\n-struct tb_path *tb_path_alloc(struct tb *tb, int num_hops)\n+struct tb_path *tb_path_alloc(struct tb *tb, struct tb_port *src,\n+\t\t\t      struct tb_port *dst, int start_hopid,\n+\t\t\t      int end_hopid, int link_nr)\n {\n-\tstruct tb_path *path = kzalloc(sizeof(*path), GFP_KERNEL);\n+\tstruct tb_port *in_port, *out_port;\n+\tint in_hopid, out_hopid;\n+\tstruct tb_path *path;\n+\tsize_t num_hops;\n+\tint i, ret;\n+\n+\tpath = kzalloc(sizeof(*path), GFP_KERNEL);\n \tif (!path)\n \t\treturn NULL;\n+\n+\ti = 0;\n+\ttb_for_each_port(in_port, src, dst)\n+\t\ti++;\n+\n+\t/* Each hop takes two ports */\n+\tnum_hops = i / 2;\n+\n \tpath->hops = kcalloc(num_hops, sizeof(*path->hops), GFP_KERNEL);\n \tif (!path->hops) {\n \t\tkfree(path);\n \t\treturn NULL;\n \t}\n+\n+\tin_hopid = start_hopid;\n+\tout_port = NULL;\n+\tout_hopid = -1;\n+\n+\tfor (i = 0; i < num_hops; i++) {\n+\t\tin_port = tb_port_get_next(src, dst, out_port);\n+\n+\t\tif (in_port->dual_link_port && in_port->link_nr != link_nr)\n+\t\t\tin_port = in_port->dual_link_port;\n+\n+\t\tret = tb_port_alloc_in_hopid(in_port, in_hopid, -1);\n+\t\tif (ret < 0)\n+\t\t\tgoto err;\n+\t\tin_hopid = ret;\n+\n+\t\tout_port = tb_port_get_next(src, dst, in_port);\n+\t\tif (!out_port)\n+\t\t\tgoto err;\n+\n+\t\tif (out_port->dual_link_port && out_port->link_nr != link_nr)\n+\t\t\tout_port = out_port->dual_link_port;\n+\n+\t\tif (end_hopid && i == num_hops - 1)\n+\t\t\tret = tb_port_alloc_out_hopid(out_port, end_hopid,\n+\t\t\t\t\t\t      end_hopid);\n+\t\telse\n+\t\t\tret = tb_port_alloc_out_hopid(out_port, -1, -1);\n+\n+\t\tif (ret < 0)\n+\t\t\tgoto err;\n+\t\tout_hopid = ret;\n+\n+\t\tpath->hops[i].in_hop_index = in_hopid;\n+\t\tpath->hops[i].in_port = in_port;\n+\t\tpath->hops[i].in_counter_index = -1;\n+\t\tpath->hops[i].out_port = out_port;\n+\t\tpath->hops[i].next_hop_index = out_hopid;\n+\n+\t\tin_hopid = out_hopid;\n+\t}\n+\n \tpath->tb = tb;\n \tpath->path_length = num_hops;\n \treturn path;\n+\n+err:\n+\ttb_path_free(path);\n+\treturn NULL;\n }\n \n /**\n@@ -55,10 +129,24 @@ struct tb_path *tb_path_alloc(struct tb *tb, int num_hops)\n  */\n void tb_path_free(struct tb_path *path)\n {\n+\tint i;\n+\n \tif (path->activated) {\n \t\ttb_WARN(path->tb, \"trying to free an activated path\\n\")\n \t\treturn;\n \t}\n+\n+\tfor (i = 0; i < path->path_length; i++) {\n+\t\tconst struct tb_path_hop *hop = &path->hops[i];\n+\n+\t\tif (hop->in_port)\n+\t\t\ttb_port_release_in_hopid(hop->in_port,\n+\t\t\t\t\t\t hop->in_hop_index);\n+\t\tif (hop->out_port)\n+\t\t\ttb_port_release_out_hopid(hop->out_port,\n+\t\t\t\t\t\t  hop->next_hop_index);\n+\t}\n+\n \tkfree(path->hops);\n \tkfree(path);\n }\ndiff --git a/drivers/thunderbolt/tb.h b/drivers/thunderbolt/tb.h\nindex 360333caa3c4..ceed33895105 100644\n--- a/drivers/thunderbolt/tb.h\n+++ b/drivers/thunderbolt/tb.h\n@@ -460,7 +460,9 @@ int tb_port_find_cap(struct tb_port *port, enum tb_port_cap cap);\n \n int tb_pci_port_enable(struct tb_port *port, bool enable);\n \n-struct tb_path *tb_path_alloc(struct tb *tb, int num_hops);\n+struct tb_path *tb_path_alloc(struct tb *tb, struct tb_port *src,\n+\t\t\t      struct tb_port *dst, int start_hopid,\n+\t\t\t      int end_hopid, int link_nr);\n void tb_path_free(struct tb_path *path);\n int tb_path_activate(struct tb_path *path);\n void tb_path_deactivate(struct tb_path *path);\ndiff --git a/drivers/thunderbolt/tunnel.c b/drivers/thunderbolt/tunnel.c\nindex 20ce28276f7a..cdf9ca1c043e 100644\n--- a/drivers/thunderbolt/tunnel.c\n+++ b/drivers/thunderbolt/tunnel.c\n@@ -12,6 +12,9 @@\n #include \"tunnel.h\"\n #include \"tb.h\"\n \n+/* PCIe adapters use always hop ID of 8 for both directions */\n+#define TB_PCI_HOPID\t\t\t8\n+\n #define TB_PCI_PATH_DOWN\t\t0\n #define TB_PCI_PATH_UP\t\t\t1\n \n@@ -86,21 +89,13 @@ static void tb_pci_init_path(struct tb_path *path)\n  * Allocate a PCI tunnel. The ports must be of type TB_TYPE_PCIE_UP and\n  * TB_TYPE_PCIE_DOWN.\n  *\n- * Currently only paths consisting of two hops are supported (that is the\n- * ports must be on \"adjacent\" switches).\n- *\n- * The paths are hard-coded to use hop 8 (the only working hop id available on\n- * my thunderbolt devices). Therefore at most ONE path per device may be\n- * activated.\n- *\n  * Return: Returns a tb_tunnel on success or NULL on failure.\n  */\n struct tb_tunnel *tb_tunnel_alloc_pci(struct tb *tb, struct tb_port *up,\n \t\t\t\t      struct tb_port *down)\n {\n-\tstruct tb_path *path_to_up;\n-\tstruct tb_path *path_to_down;\n \tstruct tb_tunnel *tunnel;\n+\tstruct tb_path *path;\n \n \ttunnel = tb_tunnel_alloc(tb, 2);\n \tif (!tunnel)\n@@ -110,46 +105,21 @@ struct tb_tunnel *tb_tunnel_alloc_pci(struct tb *tb, struct tb_port *up,\n \ttunnel->src_port = down;\n \ttunnel->dst_port = up;\n \n-\tpath_to_up = tb_path_alloc(tb, 2);\n-\tif (!path_to_up) {\n+\tpath = tb_path_alloc(tb, down, up, TB_PCI_HOPID, -1, 0);\n+\tif (!path) {\n \t\ttb_tunnel_free(tunnel);\n \t\treturn NULL;\n \t}\n-\ttunnel->paths[TB_PCI_PATH_UP] = path_to_up;\n+\ttb_pci_init_path(path);\n+\ttunnel->paths[TB_PCI_PATH_UP] = path;\n \n-\tpath_to_down = tb_path_alloc(tb, 2);\n-\tif (!path_to_down) {\n+\tpath = tb_path_alloc(tb, up, down, TB_PCI_HOPID, -1, 0);\n+\tif (!path) {\n \t\ttb_tunnel_free(tunnel);\n \t\treturn NULL;\n \t}\n-\ttunnel->paths[TB_PCI_PATH_DOWN] = path_to_down;\n-\n-\ttb_pci_init_path(path_to_up);\n-\ttb_pci_init_path(path_to_down);\n-\n-\tpath_to_up->hops[0].in_port = down;\n-\tpath_to_up->hops[0].in_hop_index = 8;\n-\tpath_to_up->hops[0].in_counter_index = -1;\n-\tpath_to_up->hops[0].out_port = tb_upstream_port(up->sw)->remote;\n-\tpath_to_up->hops[0].next_hop_index = 8;\n-\n-\tpath_to_up->hops[1].in_port = tb_upstream_port(up->sw);\n-\tpath_to_up->hops[1].in_hop_index = 8;\n-\tpath_to_up->hops[1].in_counter_index = -1;\n-\tpath_to_up->hops[1].out_port = up;\n-\tpath_to_up->hops[1].next_hop_index = 8;\n-\n-\tpath_to_down->hops[0].in_port = up;\n-\tpath_to_down->hops[0].in_hop_index = 8;\n-\tpath_to_down->hops[0].in_counter_index = -1;\n-\tpath_to_down->hops[0].out_port = tb_upstream_port(up->sw);\n-\tpath_to_down->hops[0].next_hop_index = 8;\n-\n-\tpath_to_down->hops[1].in_port = tb_upstream_port(up->sw)->remote;\n-\tpath_to_down->hops[1].in_hop_index = 8;\n-\tpath_to_down->hops[1].in_counter_index = -1;\n-\tpath_to_down->hops[1].out_port = down;\n-\tpath_to_down->hops[1].next_hop_index = 8;\n+\ttb_pci_init_path(path);\n+\ttunnel->paths[TB_PCI_PATH_DOWN] = path;\n \n \treturn tunnel;\n }\n",
    "prefixes": [
        "14/28"
    ]
}