Show a patch.

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

{
    "id": 42037,
    "url": "http://patches.dpdk.org/api/patches/42037/",
    "web_url": "http://patches.dpdk.org/patch/42037/",
    "project": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/projects/1/",
        "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": "<20180702054450.29269-6-qi.z.zhang@intel.com>",
    "date": "2018-07-02T05:44:36",
    "name": "[v8,05/19] ethdev: support attach or detach share device from secondary",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "af2076cd975a206390bbe2acfc8fcdf9c364c829",
    "submitter": {
        "id": 504,
        "url": "http://patches.dpdk.org/api/people/504/",
        "name": "Zhang, Qi Z",
        "email": "qi.z.zhang@intel.com"
    },
    "delegate": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/users/1/",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patches.dpdk.org/patch/42037/mbox/",
    "series": [
        {
            "id": 344,
            "url": "http://patches.dpdk.org/api/series/344/",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=344",
            "date": "2018-07-02T05:44:31",
            "name": "enable hotplug on multi-process",
            "version": 8,
            "mbox": "http://patches.dpdk.org/series/344/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/42037/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/42037/checks/",
    "tags": {},
    "headers": {
        "X-Mailman-Version": "2.1.15",
        "X-ExtLoop1": "1",
        "Errors-To": "dev-bounces@dpdk.org",
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Mailer": "git-send-email 2.13.6",
        "Received": [
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 37B8D58FE;\n\tMon,  2 Jul 2018 07:44:31 +0200 (CEST)",
            "from mga11.intel.com (mga11.intel.com [192.55.52.93])\n\tby dpdk.org (Postfix) with ESMTP id A5C1B4F9B\n\tfor <dev@dpdk.org>; Mon,  2 Jul 2018 07:44:26 +0200 (CEST)",
            "from orsmga007.jf.intel.com ([10.7.209.58])\n\tby fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t01 Jul 2018 22:44:24 -0700",
            "from dpdk51.sh.intel.com ([10.67.110.190])\n\tby orsmga007.jf.intel.com with ESMTP; 01 Jul 2018 22:44:23 -0700"
        ],
        "References": "<20180607123849.14439-1-qi.z.zhang@intel.com>\n\t<20180702054450.29269-1-qi.z.zhang@intel.com>",
        "X-Amp-File-Uploaded": "False",
        "X-BeenThere": "dev@dpdk.org",
        "Message-Id": "<20180702054450.29269-6-qi.z.zhang@intel.com>",
        "X-IronPort-AV": "E=Sophos;i=\"5.51,298,1526367600\"; d=\"scan'208\";a=\"53378953\"",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "Precedence": "list",
        "From": "Qi Zhang <qi.z.zhang@intel.com>",
        "X-Original-To": "patchwork@dpdk.org",
        "List-Post": "<mailto:dev@dpdk.org>",
        "Return-Path": "<dev-bounces@dpdk.org>",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "In-Reply-To": "<20180702054450.29269-1-qi.z.zhang@intel.com>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "To": "thomas@monjalon.net,\n\tanatoly.burakov@intel.com",
        "Delivered-To": "patchwork@dpdk.org",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "Date": "Mon,  2 Jul 2018 13:44:36 +0800",
        "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-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "Subject": "[dpdk-dev] [PATCH v8 05/19] ethdev: support attach or detach share\n\tdevice from secondary"
    },
    "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>\nReviewed-by: Anatoly Burakov <anatoly.burakov@intel.com>\n---\n lib/librte_ethdev/ethdev_mp.c | 179 ++++++++++++++++++++++++++++++++++++++++--\n 1 file changed, 173 insertions(+), 6 deletions(-)",
    "diff": "diff --git a/lib/librte_ethdev/ethdev_mp.c b/lib/librte_ethdev/ethdev_mp.c\nindex 1d148cd5e..8d13da591 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,122 @@ 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\tgoto finish;\n+\n+\t\ttmp_req.port_id = port_id;\n+\t\tret = eth_dev_request_to_secondary(&tmp_req);\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\t\tgoto finish;\n+\t\t}\n+\n+\t\tret = process_lock_callbacks(req->port_id);\n+\t\tif (ret)\n+\t\t\tgoto finish;\n+\n+\t\ttmp_req.t = REQ_TYPE_PRE_DETACH;\n+\t\tret = eth_dev_request_to_secondary(&tmp_req);\n+\t\tif (ret)\n+\t\t\tgoto finish;\n+\n+\t\tif (!tmp_req.result) {\n+\t\t\ttmp_req.t = REQ_TYPE_DETACH;\n+\t\t\tret = eth_dev_request_to_secondary(&tmp_req);\n+\t\t\tif (ret)\n+\t\t\t\tgoto finish;\n+\n+\t\t\tret = do_eth_dev_detach(req->port_id);\n+\t\t} else {\n+\t\t\tret = tmp_req.result;\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+finish:\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+\t/**\n+\t * We are at IPC callback thread, sync IPC is not allowed due to\n+\t * dead lock, so we delegate the task to interrupt thread.\n+\t */\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@@ -183,8 +330,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": [
        "v8",
        "05/19"
    ]
}