Show a patch.

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

{
    "id": 41622,
    "url": "http://patches.dpdk.org/api/patches/41622/?format=api",
    "web_url": "http://patches.dpdk.org/patch/41622/",
    "project": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk"
    },
    "msgid": "<20180627071740.19870-8-qi.z.zhang@intel.com>",
    "date": "2018-06-27T07:17:23",
    "name": "[v5,07/24] ethdev: support attach or detach share device from secondary",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "5a138197bd7336e9ceedf3080a90de0c7b763212",
    "submitter": {
        "id": 504,
        "url": "http://patches.dpdk.org/api/people/504/?format=api",
        "name": "Qi Zhang",
        "email": "qi.z.zhang@intel.com"
    },
    "delegate": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patches.dpdk.org/patch/41622/mbox/",
    "series": [
        {
            "id": 252,
            "url": "http://patches.dpdk.org/api/series/252/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=252",
            "date": "2018-06-27T07:17:16",
            "name": "enable hotplug on multi-process",
            "version": 5,
            "mbox": "http://patches.dpdk.org/series/252/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/41622/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/41622/checks/",
    "tags": {},
    "headers": {
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "X-IronPort-AV": "E=Sophos;i=\"5.51,278,1526367600\"; d=\"scan'208\";a=\"52236161\"",
        "X-Amp-File-Uploaded": "False",
        "Precedence": "list",
        "X-Mailman-Version": "2.1.15",
        "X-Original-To": "patchwork@dpdk.org",
        "List-Post": "<mailto:dev@dpdk.org>",
        "References": "<20180607123849.14439-1-qi.z.zhang@intel.com>\n\t<20180627071740.19870-1-qi.z.zhang@intel.com>",
        "X-BeenThere": "dev@dpdk.org",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "Subject": "[dpdk-dev] [PATCH v5 07/24] ethdev: support attach or detach share\n\tdevice from secondary",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>",
        "Delivered-To": "patchwork@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 215171BDED;\n\tWed, 27 Jun 2018 09:17:37 +0200 (CEST)",
            "from mga09.intel.com (mga09.intel.com [134.134.136.24])\n\tby dpdk.org (Postfix) with ESMTP id 14F721BDCD\n\tfor <dev@dpdk.org>; Wed, 27 Jun 2018 09:17:21 +0200 (CEST)",
            "from orsmga007.jf.intel.com ([10.7.209.58])\n\tby orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t27 Jun 2018 00:17:21 -0700",
            "from dpdk51.sh.intel.com ([10.67.110.190])\n\tby orsmga007.jf.intel.com with ESMTP; 27 Jun 2018 00:17:20 -0700"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "X-Mailer": "git-send-email 2.13.6",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "X-ExtLoop1": "1",
        "Date": "Wed, 27 Jun 2018 15:17:23 +0800",
        "To": "thomas@monjalon.net,\n\tanatoly.burakov@intel.com",
        "From": "Qi Zhang <qi.z.zhang@intel.com>",
        "In-Reply-To": "<20180627071740.19870-1-qi.z.zhang@intel.com>",
        "Cc": "konstantin.ananyev@intel.com, dev@dpdk.org, bruce.richardson@intel.com, \n\tferruh.yigit@intel.com, benjamin.h.shelton@intel.com,\n\tnarender.vangati@intel.com, Qi Zhang <qi.z.zhang@intel.com>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Message-Id": "<20180627071740.19870-8-qi.z.zhang@intel.com>",
        "Return-Path": "<dev-bounces@dpdk.org>"
    },
    "content": "This patch cover the multi-process hotplug case when a share device\nattach/detach request be issued from secondary process\n\ndevice attach on secondary:\na) seconary send sync request to primary.\nb) primary receive the request and attach the new device if failed\n   goto i).\nc) primary forward attach sync request to all secondary.\nd) secondary receive request and attach device and send reply.\ne) primary check the reply if all success go to j).\nf) primary send attach rollback sync request to all secondary.\ng) secondary receive the request and detach device and send reply.\nh) primary receive the reply and detach device as rollback action.\ni) send fail reply to secondary, goto k).\nj) send success reply to secondary.\nk) secondary process receive reply of step a) and return.\n\ndevice detach on secondary:\na) secondary send sync request to primary\nb) primary receive the request and perform pre-detach check, if device\n   is locked, goto j).\nc) primary send pre-detach sync request to all secondary.\nd) secondary perform pre-detach check and send reply.\ne) primary check the reply if any fail goto j).\nf) primary send detach sync request to all secondary\ng) secondary detach the device and send reply\nh) primary detach the device.\ni) send success reply to secondary, goto k).\nj) send fail reply to secondary.\nk) secondary process receive reply of step a) and return.\n\nSigned-off-by: Qi Zhang <qi.z.zhang@intel.com>\n---\n lib/librte_ethdev/ethdev_mp.c | 167 ++++++++++++++++++++++++++++++++++++++++--\n 1 file changed, 161 insertions(+), 6 deletions(-)",
    "diff": "diff --git a/lib/librte_ethdev/ethdev_mp.c b/lib/librte_ethdev/ethdev_mp.c\nindex 0d9fcc77a..0a93fa669 100644\n--- a/lib/librte_ethdev/ethdev_mp.c\n+++ b/lib/librte_ethdev/ethdev_mp.c\n@@ -5,8 +5,44 @@\n #include <rte_alarm.h>\n \n #include \"rte_ethdev_driver.h\"\n+\n #include \"ethdev_mp.h\"\n #include \"ethdev_lock.h\"\n+#include \"ethdev_private.h\"\n+\n+/**\n+ *\n+ * secondary to primary request.\n+ * start from function eth_dev_request_to_primary.\n+ *\n+ * device attach on secondary:\n+ * a) seconary send sycn request to primary\n+ * b) primary receive the request and attach the new device thread,\n+ *    if failed goto i).\n+ * c) primary forward attach request to all secondary as sync request\n+ * d) secondary receive request and attach device and send reply.\n+ * e) primary check the reply if all success go to j).\n+ * f) primary send attach rollback sync request to all secondary.\n+ * g) secondary receive the request and detach device and send reply.\n+ * h) primary receive the reply and detach device as rollback action.\n+ * i) send fail sync reply to secondary, goto k).\n+ * j) send success sync reply to secondary.\n+ * k) secondary process receive reply of step a) and return.\n+ *\n+ * device detach on secondary:\n+ * a) secondary send detach sync request to primary\n+ * b) primary receive the request and perform pre-detach check, if device\n+ *    is locked, goto j).\n+ * c) primary send pre-detach sync request to all secondary.\n+ * d) secondary perform pre-detach check and send reply.\n+ * e) primary check the reply if any fail goto j).\n+ * f) primary send detach sync request to all secondary\n+ * g) secondary detach the device and send reply\n+ * h) primary detach the device.\n+ * i) send success sync reply to secondary, goto k).\n+ * j) send fail sync reply to secondary.\n+ * k) secondary process receive reply of step a) and return.\n+ */\n \n #define MP_TIMEOUT_S 5 /**< 5 seconds timeouts */\n \n@@ -84,11 +120,110 @@ static int attach_on_secondary(const char *devargs, uint16_t port_id)\n }\n \n static int\n-handle_secondary_request(const struct rte_mp_msg *msg, const void *peer)\n+send_response_to_secondary(const struct eth_dev_mp_req *req,\n+\t\t\tint result,\n+\t\t\tconst void *peer)\n+{\n+\tstruct rte_mp_msg mp_resp;\n+\tstruct eth_dev_mp_req *resp =\n+\t\t(struct eth_dev_mp_req *)mp_resp.param;\n+\tint ret;\n+\n+\tmemset(&mp_resp, 0, sizeof(mp_resp));\n+\tmp_resp.len_param = sizeof(*resp);\n+\tstrcpy(mp_resp.name, ETH_DEV_MP_ACTION_REQUEST);\n+\tmemcpy(resp, req, sizeof(*req));\n+\tresp->result = result;\n+\n+\tret = rte_mp_reply(&mp_resp, peer);\n+\tif (ret)\n+\t\tethdev_log(ERR, \"failed to send response to secondary\\n\");\n+\n+\treturn ret;\n+}\n+\n+int eth_dev_request_to_secondary(struct eth_dev_mp_req *req);\n+\n+static void\n+__handle_secondary_request(void *param)\n+{\n+\tstruct mp_reply_bundle *bundle = param;\n+\tconst struct rte_mp_msg *msg = &bundle->msg;\n+\tconst struct eth_dev_mp_req *req =\n+\t\t(const struct eth_dev_mp_req *)msg->param;\n+\tstruct eth_dev_mp_req tmp_req;\n+\tuint16_t port_id;\n+\tint ret = 0;\n+\n+\ttmp_req = *req;\n+\n+\tif (req->t == REQ_TYPE_ATTACH) {\n+\t\tret = do_eth_dev_attach(req->devargs, &port_id);\n+\t\tif (!ret) {\n+\t\t\ttmp_req.port_id = port_id;\n+\t\t\tret = eth_dev_request_to_secondary(&tmp_req);\n+\t\t}\n+\t} else if (req->t == REQ_TYPE_DETACH) {\n+\t\tif (!rte_eth_dev_is_valid_port(req->port_id))\n+\t\t\tret = -EINVAL;\n+\t\tif (!ret)\n+\t\t\tret = process_lock_callbacks(req->port_id);\n+\t\tif (!ret) {\n+\t\t\ttmp_req.t = REQ_TYPE_PRE_DETACH;\n+\t\t\tret = eth_dev_request_to_secondary(&tmp_req);\n+\t\t}\n+\t\tif (!ret) {\n+\t\t\tif (!tmp_req.result) {\n+\t\t\t\ttmp_req.t = REQ_TYPE_DETACH;\n+\t\t\t\tret = eth_dev_request_to_secondary(&tmp_req);\n+\t\t\t\tif (!ret)\n+\t\t\t\t\tret = do_eth_dev_detach(req->port_id);\n+\t\t\t} else {\n+\t\t\t\tret = tmp_req.result;\n+\t\t\t}\n+\t\t}\n+\t} else {\n+\t\tethdev_log(ERR, \"unsupported secondary to primary request\\n\");\n+\t\tret = -ENOTSUP;\n+\t}\n+\n+\tret = send_response_to_secondary(&tmp_req, ret, bundle->peer);\n+\tif (ret)\n+\t\tethdev_log(ERR, \"failed to send response to secondary\\n\");\n+\n+\tfree(bundle->peer);\n+\tfree(bundle);\n+}\n+\n+static int\n+handle_secondary_request(const struct rte_mp_msg *msg,\n+\t\t\tconst void *peer)\n {\n-\tRTE_SET_USED(msg);\n-\tRTE_SET_USED(peer);\n-\treturn -ENOTSUP;\n+\tstruct mp_reply_bundle *bundle;\n+\tconst struct eth_dev_mp_req *req =\n+\t\t(const struct eth_dev_mp_req *)msg->param;\n+\tint ret = 0;\n+\n+\tbundle = malloc(sizeof(*bundle));\n+\tif (bundle == NULL) {\n+\t\tethdev_log(ERR, \"not enough memory\\n\");\n+\t\treturn send_response_to_secondary(req, -ENOMEM, peer);\n+\t}\n+\n+\tbundle->msg = *msg;\n+\t/**\n+\t * We need to send reply on interrupt thread, but peer can't be\n+\t * parsed directly, so this is a temporal hack, need to be fixed\n+\t * when it is ready.\n+\t */\n+\tbundle->peer = strdup(peer);\n+\n+\tret = rte_eal_alarm_set(1, __handle_secondary_request, bundle);\n+\tif (ret) {\n+\t\tethdev_log(ERR, \"failed to add mp task\\n\");\n+\t\treturn send_response_to_secondary(req, ret, peer);\n+\t}\n+\treturn 0;\n }\n \n static void __handle_primary_request(void *param)\n@@ -179,8 +314,28 @@ handle_primary_request(const struct rte_mp_msg *msg, const void *peer)\n \n int eth_dev_request_to_primary(struct eth_dev_mp_req *req)\n {\n-\tRTE_SET_USED(req);\n-\treturn -ENOTSUP;\n+\tstruct rte_mp_msg mp_req;\n+\tstruct rte_mp_reply mp_reply;\n+\tstruct timespec ts = {.tv_sec = MP_TIMEOUT_S, .tv_nsec = 0};\n+\tstruct eth_dev_mp_req *resp;\n+\tint ret;\n+\n+\tmemset(&mp_req, 0, sizeof(mp_req));\n+\tmemcpy(mp_req.param, req, sizeof(*req));\n+\tmp_req.len_param = sizeof(*req);\n+\tstrlcpy(mp_req.name, ETH_DEV_MP_ACTION_REQUEST, sizeof(mp_req.name));\n+\n+\tret = rte_mp_request_sync(&mp_req, &mp_reply, &ts);\n+\tif (ret) {\n+\t\tethdev_log(ERR, \"cannot send request to primary\");\n+\t\treturn ret;\n+\t}\n+\n+\tresp = (struct eth_dev_mp_req *)mp_reply.msgs[0].param;\n+\treq->result = resp->result;\n+\treq->port_id = resp->port_id;\n+\n+\treturn ret;\n }\n \n /**\n",
    "prefixes": [
        "v5",
        "07/24"
    ]
}