Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/1032818/?format=api
{ "id": 1032818, "url": "http://patchwork.ozlabs.org/api/patches/1032818/?format=api", "web_url": "http://patchwork.ozlabs.org/project/netdev/patch/20190129150143.12681-24-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-24-mika.westerberg@linux.intel.com>", "list_archive_url": null, "date": "2019-01-29T15:01:38", "name": "[23/28] thunderbolt: Add XDomain UUID exchange support", "commit_ref": null, "pull_url": null, "state": "not-applicable", "archived": false, "hash": "aa97e5287c86db5c1962b0c5c0cd054771b9b25e", "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-24-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/1032818/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/1032818/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 43pqVF2rsbz9sDL\n\tfor <patchwork-incoming-netdev@ozlabs.org>;\n\tWed, 30 Jan 2019 02:02:29 +1100 (AEDT)", "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1728791AbfA2PC2 (ORCPT\n\t<rfc822;patchwork-incoming-netdev@ozlabs.org>);\n\tTue, 29 Jan 2019 10:02:28 -0500", "from mga17.intel.com ([192.55.52.151]:45434 \"EHLO mga17.intel.com\"\n\trhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP\n\tid S1728509AbfA2PB4 (ORCPT <rfc822;netdev@vger.kernel.org>);\n\tTue, 29 Jan 2019 10:01:56 -0500", "from orsmga008.jf.intel.com ([10.7.209.65])\n\tby fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t29 Jan 2019 07:01:55 -0800", "from black.fi.intel.com ([10.237.72.28])\n\tby orsmga008.jf.intel.com with ESMTP; 29 Jan 2019 07:01:52 -0800", "by black.fi.intel.com (Postfix, from userid 1001)\n\tid 4A223B97; Tue, 29 Jan 2019 17:01:45 +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=\"113610581\"", "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 23/28] thunderbolt: Add XDomain UUID exchange support", "Date": "Tue, 29 Jan 2019 18:01:38 +0300", "Message-Id": "<20190129150143.12681-24-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": "Currently ICM has been handling XDomain UUID exchange so there was no\nneed to have it in the driver yet. However, since now we are going to\nadd the same capabilities to the software connection manager it needs to\nbe handled properly.\n\nFor this reason modify the driver XDomain protocol handling so that if\nthe remote domain UUID is not filled in the core will query it first and\nonly then start the normal property exchange flow.\n\nSigned-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>\n---\n drivers/thunderbolt/tb_msgs.h | 11 +++\n drivers/thunderbolt/xdomain.c | 136 +++++++++++++++++++++++++++++++---\n include/linux/thunderbolt.h | 8 ++\n 3 files changed, 145 insertions(+), 10 deletions(-)", "diff": "diff --git a/drivers/thunderbolt/tb_msgs.h b/drivers/thunderbolt/tb_msgs.h\nindex 02c84aa3d018..afbe1d29bb03 100644\n--- a/drivers/thunderbolt/tb_msgs.h\n+++ b/drivers/thunderbolt/tb_msgs.h\n@@ -492,6 +492,17 @@ struct tb_xdp_header {\n \tu32 type;\n };\n \n+struct tb_xdp_uuid {\n+\tstruct tb_xdp_header hdr;\n+};\n+\n+struct tb_xdp_uuid_response {\n+\tstruct tb_xdp_header hdr;\n+\tuuid_t src_uuid;\n+\tu32 src_route_hi;\n+\tu32 src_route_lo;\n+};\n+\n struct tb_xdp_properties {\n \tstruct tb_xdp_header hdr;\n \tuuid_t src_uuid;\ndiff --git a/drivers/thunderbolt/xdomain.c b/drivers/thunderbolt/xdomain.c\nindex 59789bdd93ac..7aa8b9da78c1 100644\n--- a/drivers/thunderbolt/xdomain.c\n+++ b/drivers/thunderbolt/xdomain.c\n@@ -18,6 +18,7 @@\n #include \"tb.h\"\n \n #define XDOMAIN_DEFAULT_TIMEOUT\t\t\t5000 /* ms */\n+#define XDOMAIN_UUID_RETRIES\t\t\t10\n #define XDOMAIN_PROPERTIES_RETRIES\t\t60\n #define XDOMAIN_PROPERTIES_CHANGED_RETRIES\t10\n \n@@ -222,6 +223,50 @@ static int tb_xdp_handle_error(const struct tb_xdp_header *hdr)\n \treturn 0;\n }\n \n+static int tb_xdp_uuid_request(struct tb_ctl *ctl, u64 route, int retry,\n+\t\t\t uuid_t *uuid)\n+{\n+\tstruct tb_xdp_uuid_response res;\n+\tstruct tb_xdp_uuid req;\n+\tint ret;\n+\n+\tmemset(&req, 0, sizeof(req));\n+\ttb_xdp_fill_header(&req.hdr, route, retry % 4, UUID_REQUEST,\n+\t\t\t sizeof(req));\n+\n+\tmemset(&res, 0, sizeof(res));\n+\tret = __tb_xdomain_request(ctl, &req, sizeof(req),\n+\t\t\t\t TB_CFG_PKG_XDOMAIN_REQ, &res, sizeof(res),\n+\t\t\t\t TB_CFG_PKG_XDOMAIN_RESP,\n+\t\t\t\t XDOMAIN_DEFAULT_TIMEOUT);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tret = tb_xdp_handle_error(&res.hdr);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tuuid_copy(uuid, &res.src_uuid);\n+\treturn 0;\n+}\n+\n+static int tb_xdp_uuid_response(struct tb_ctl *ctl, u64 route, u8 sequence,\n+\t\t\t\tconst uuid_t *uuid)\n+{\n+\tstruct tb_xdp_uuid_response res;\n+\n+\tmemset(&res, 0, sizeof(res));\n+\ttb_xdp_fill_header(&res.hdr, route, sequence, UUID_RESPONSE,\n+\t\t\t sizeof(res));\n+\n+\tuuid_copy(&res.src_uuid, uuid);\n+\tres.src_route_hi = upper_32_bits(route);\n+\tres.src_route_lo = lower_32_bits(route);\n+\n+\treturn __tb_xdomain_response(ctl, &res, sizeof(res),\n+\t\t\t\t TB_CFG_PKG_XDOMAIN_RESP);\n+}\n+\n static int tb_xdp_error_response(struct tb_ctl *ctl, u64 route, u8 sequence,\n \t\t\t\t enum tb_xdp_error error)\n {\n@@ -512,7 +557,14 @@ static void tb_xdp_handle_request(struct work_struct *work)\n \t\tbreak;\n \t}\n \n+\tcase UUID_REQUEST_OLD:\n+\tcase UUID_REQUEST:\n+\t\tret = tb_xdp_uuid_response(ctl, route, sequence, uuid);\n+\t\tbreak;\n+\n \tdefault:\n+\t\ttb_xdp_error_response(ctl, route, sequence,\n+\t\t\t\t ERROR_NOT_SUPPORTED);\n \t\tbreak;\n \t}\n \n@@ -828,6 +880,55 @@ static void tb_xdomain_restore_paths(struct tb_xdomain *xd)\n \t}\n }\n \n+static void tb_xdomain_get_uuid(struct work_struct *work)\n+{\n+\tstruct tb_xdomain *xd = container_of(work, typeof(*xd),\n+\t\t\t\t\t get_uuid_work.work);\n+\tstruct tb *tb = xd->tb;\n+\tuuid_t uuid;\n+\tint ret;\n+\n+\tret = tb_xdp_uuid_request(tb->ctl, xd->route, xd->uuid_retries, &uuid);\n+\tif (ret < 0) {\n+\t\tif (xd->uuid_retries-- > 0) {\n+\t\t\tqueue_delayed_work(xd->tb->wq, &xd->get_uuid_work,\n+\t\t\t\t\t msecs_to_jiffies(100));\n+\t\t} else {\n+\t\t\tdev_dbg(&xd->dev, \"failed to read remote UUID\\n\");\n+\t\t}\n+\t\treturn;\n+\t}\n+\n+\tif (uuid_equal(&uuid, xd->local_uuid)) {\n+\t\tdev_dbg(&xd->dev, \"intra-domain loop detected\\n\");\n+\t\treturn;\n+\t}\n+\n+\t/*\n+\t * If the UUID is different, there is another domain connected\n+\t * so mark this one unplugged and wait for the connection\n+\t * manager to replace it.\n+\t */\n+\tif (xd->remote_uuid && !uuid_equal(&uuid, xd->remote_uuid)) {\n+\t\tdev_dbg(&xd->dev, \"remote UUID is different, unplugging\\n\");\n+\t\txd->is_unplugged = true;\n+\t\treturn;\n+\t}\n+\n+\t/* First time fill in the missing UUID */\n+\tif (!xd->remote_uuid) {\n+\t\txd->remote_uuid = kmemdup(&uuid, sizeof(uuid_t), GFP_KERNEL);\n+\t\tif (!xd->remote_uuid)\n+\t\t\treturn;\n+\t}\n+\n+\t/* Now we can start the normal properties exchange */\n+\tqueue_delayed_work(xd->tb->wq, &xd->properties_changed_work,\n+\t\t\t msecs_to_jiffies(100));\n+\tqueue_delayed_work(xd->tb->wq, &xd->get_properties_work,\n+\t\t\t msecs_to_jiffies(1000));\n+}\n+\n static void tb_xdomain_get_properties(struct work_struct *work)\n {\n \tstruct tb_xdomain *xd = container_of(work, typeof(*xd),\n@@ -1034,21 +1135,29 @@ static void tb_xdomain_release(struct device *dev)\n \n static void start_handshake(struct tb_xdomain *xd)\n {\n+\txd->uuid_retries = XDOMAIN_UUID_RETRIES;\n \txd->properties_retries = XDOMAIN_PROPERTIES_RETRIES;\n \txd->properties_changed_retries = XDOMAIN_PROPERTIES_CHANGED_RETRIES;\n \n-\t/* Start exchanging properties with the other host */\n-\tqueue_delayed_work(xd->tb->wq, &xd->properties_changed_work,\n-\t\t\t msecs_to_jiffies(100));\n-\tqueue_delayed_work(xd->tb->wq, &xd->get_properties_work,\n-\t\t\t msecs_to_jiffies(1000));\n+\tif (xd->needs_uuid) {\n+\t\tqueue_delayed_work(xd->tb->wq, &xd->get_uuid_work,\n+\t\t\t\t msecs_to_jiffies(100));\n+\t} else {\n+\t\t/* Start exchanging properties with the other host */\n+\t\tqueue_delayed_work(xd->tb->wq, &xd->properties_changed_work,\n+\t\t\t\t msecs_to_jiffies(100));\n+\t\tqueue_delayed_work(xd->tb->wq, &xd->get_properties_work,\n+\t\t\t\t msecs_to_jiffies(1000));\n+\t}\n }\n \n static void stop_handshake(struct tb_xdomain *xd)\n {\n+\txd->uuid_retries = 0;\n \txd->properties_retries = 0;\n \txd->properties_changed_retries = 0;\n \n+\tcancel_delayed_work_sync(&xd->get_uuid_work);\n \tcancel_delayed_work_sync(&xd->get_properties_work);\n \tcancel_delayed_work_sync(&xd->properties_changed_work);\n }\n@@ -1091,7 +1200,7 @@ EXPORT_SYMBOL_GPL(tb_xdomain_type);\n *\t other domain is reached).\n * @route: Route string used to reach the other domain\n * @local_uuid: Our local domain UUID\n- * @remote_uuid: UUID of the other domain\n+ * @remote_uuid: UUID of the other domain (optional)\n *\n * Allocates new XDomain structure and returns pointer to that. The\n * object must be released by calling tb_xdomain_put().\n@@ -1110,6 +1219,7 @@ struct tb_xdomain *tb_xdomain_alloc(struct tb *tb, struct device *parent,\n \txd->route = route;\n \tida_init(&xd->service_ids);\n \tmutex_init(&xd->lock);\n+\tINIT_DELAYED_WORK(&xd->get_uuid_work, tb_xdomain_get_uuid);\n \tINIT_DELAYED_WORK(&xd->get_properties_work, tb_xdomain_get_properties);\n \tINIT_DELAYED_WORK(&xd->properties_changed_work,\n \t\t\t tb_xdomain_properties_changed);\n@@ -1118,9 +1228,14 @@ struct tb_xdomain *tb_xdomain_alloc(struct tb *tb, struct device *parent,\n \tif (!xd->local_uuid)\n \t\tgoto err_free;\n \n-\txd->remote_uuid = kmemdup(remote_uuid, sizeof(uuid_t), GFP_KERNEL);\n-\tif (!xd->remote_uuid)\n-\t\tgoto err_free_local_uuid;\n+\tif (remote_uuid) {\n+\t\txd->remote_uuid = kmemdup(remote_uuid, sizeof(uuid_t),\n+\t\t\t\t\t GFP_KERNEL);\n+\t\tif (!xd->remote_uuid)\n+\t\t\tgoto err_free_local_uuid;\n+\t} else {\n+\t\txd->needs_uuid = true;\n+\t}\n \n \tdevice_initialize(&xd->dev);\n \txd->dev.parent = get_device(parent);\n@@ -1291,7 +1406,8 @@ static struct tb_xdomain *switch_find_xdomain(struct tb_switch *sw,\n \t\t\txd = port->xdomain;\n \n \t\t\tif (lookup->uuid) {\n-\t\t\t\tif (uuid_equal(xd->remote_uuid, lookup->uuid))\n+\t\t\t\tif (xd->remote_uuid &&\n+\t\t\t\t uuid_equal(xd->remote_uuid, lookup->uuid))\n \t\t\t\t\treturn xd;\n \t\t\t} else if (lookup->link &&\n \t\t\t\t lookup->link == xd->link &&\ndiff --git a/include/linux/thunderbolt.h b/include/linux/thunderbolt.h\nindex bf6ec83e60ee..2d7e012db03f 100644\n--- a/include/linux/thunderbolt.h\n+++ b/include/linux/thunderbolt.h\n@@ -181,6 +181,8 @@ void tb_unregister_property_dir(const char *key, struct tb_property_dir *dir);\n * @device_name: Name of the device (or %NULL if not known)\n * @is_unplugged: The XDomain is unplugged\n * @resume: The XDomain is being resumed\n+ * @needs_uuid: If the XDomain does not have @remote_uuid it will be\n+ *\t\tqueried first\n * @transmit_path: HopID which the remote end expects us to transmit\n * @transmit_ring: Local ring (hop) where outgoing packets are pushed\n * @receive_path: HopID which we expect the remote end to transmit\n@@ -189,6 +191,9 @@ void tb_unregister_property_dir(const char *key, struct tb_property_dir *dir);\n * @properties: Properties exported by the remote domain\n * @property_block_gen: Generation of @properties\n * @properties_lock: Lock protecting @properties.\n+ * @get_uuid_work: Work used to retrieve @remote_uuid\n+ * @uuid_retries: Number of times left @remote_uuid is requested before\n+ *\t\t giving up\n * @get_properties_work: Work used to get remote domain properties\n * @properties_retries: Number of times left to read properties\n * @properties_changed_work: Work used to notify the remote domain that\n@@ -220,6 +225,7 @@ struct tb_xdomain {\n \tconst char *device_name;\n \tbool is_unplugged;\n \tbool resume;\n+\tbool needs_uuid;\n \tu16 transmit_path;\n \tu16 transmit_ring;\n \tu16 receive_path;\n@@ -227,6 +233,8 @@ struct tb_xdomain {\n \tstruct ida service_ids;\n \tstruct tb_property_dir *properties;\n \tu32 property_block_gen;\n+\tstruct delayed_work get_uuid_work;\n+\tint uuid_retries;\n \tstruct delayed_work get_properties_work;\n \tint properties_retries;\n \tstruct delayed_work properties_changed_work;\n", "prefixes": [ "23/28" ] }