get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 42863,
    "url": "http://patches.dpdk.org/api/patches/42863/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20180711134808.254054-7-qi.z.zhang@intel.com/",
    "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",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<20180711134808.254054-7-qi.z.zhang@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20180711134808.254054-7-qi.z.zhang@intel.com",
    "date": "2018-07-11T13:47:55",
    "name": "[v12,06/19] eal: support attach or detach share device from secondary",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "ca8c68654cf1122a32963beae5fdee862ed07be3",
    "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/project/dpdk/patch/20180711134808.254054-7-qi.z.zhang@intel.com/mbox/",
    "series": [
        {
            "id": 524,
            "url": "http://patches.dpdk.org/api/series/524/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=524",
            "date": "2018-07-11T13:47:49",
            "name": "enable hotplug on multi-process",
            "version": 12,
            "mbox": "http://patches.dpdk.org/series/524/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/42863/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/42863/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@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 49E4D1B5C9;\n\tWed, 11 Jul 2018 15:47:50 +0200 (CEST)",
            "from mga04.intel.com (mga04.intel.com [192.55.52.120])\n\tby dpdk.org (Postfix) with ESMTP id 4E9711B5A5\n\tfor <dev@dpdk.org>; Wed, 11 Jul 2018 15:47:41 +0200 (CEST)",
            "from fmsmga003.fm.intel.com ([10.253.24.29])\n\tby fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t11 Jul 2018 06:47:40 -0700",
            "from dpdk51.sh.intel.com ([10.67.110.190])\n\tby FMSMGA003.fm.intel.com with ESMTP; 11 Jul 2018 06:47:39 -0700"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.51,338,1526367600\"; d=\"scan'208\";a=\"63905286\"",
        "From": "Qi Zhang <qi.z.zhang@intel.com>",
        "To": "thomas@monjalon.net,\n\tanatoly.burakov@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>",
        "Date": "Wed, 11 Jul 2018 21:47:55 +0800",
        "Message-Id": "<20180711134808.254054-7-qi.z.zhang@intel.com>",
        "X-Mailer": "git-send-email 2.13.6",
        "In-Reply-To": "<20180711134808.254054-1-qi.z.zhang@intel.com>",
        "References": "<20180607123849.14439-1-qi.z.zhang@intel.com>\n\t<20180711134808.254054-1-qi.z.zhang@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v12 06/19] eal: support attach or detach share\n\tdevice from secondary",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "This patch cover the multi-process hotplug case when a device\nattach/detach request be issued from a secondary process\n\ndevice attach on secondary:\na) secondary send sync request to the primary.\nb) primary receive the request and attach the new device if\n   failed goto i).\nc) primary forward attach sync request to all secondary.\nd) secondary receive the request and attach the device and send a reply.\ne) primary check the reply if all success goes to j).\nf) primary send attach rollback sync request to all secondary.\ng) secondary receive the request and detach the device and send a reply.\nh) primary receive the reply and detach device as rollback action.\ni) send attach fail to secondary as a reply of step a), goto k).\nj) send attach success to secondary as a reply of step a).\nk) secondary receive reply and return.\n\ndevice detach on secondary:\na) secondary send sync request to the primary.\nb) primary send detach sync request to all secondary.\nc) secondary detach the device and send a reply.\nd) primary check the reply if all success goes to g).\ne) primary send detach rollback sync request to all secondary.\nf) secondary receive the request and attach back device. goto h).\ng) primary detach the device if success goto i), else goto e).\nh) primary send detach fail to secondary as a reply of step a), goto j).\ni) primary send detach success to secondary as a reply of step a).\nj) secondary receive reply and return.\n\nSigned-off-by: Qi Zhang <qi.z.zhang@intel.com>\n---\n lib/librte_eal/common/hotplug_mp.c | 177 +++++++++++++++++++++++++++++++++++--\n 1 file changed, 172 insertions(+), 5 deletions(-)",
    "diff": "diff --git a/lib/librte_eal/common/hotplug_mp.c b/lib/librte_eal/common/hotplug_mp.c\nindex d3a8a5576..e24a72c9d 100644\n--- a/lib/librte_eal/common/hotplug_mp.c\n+++ b/lib/librte_eal/common/hotplug_mp.c\n@@ -17,12 +17,158 @@ struct mp_reply_bundle {\n \tvoid *peer;\n };\n \n+/**\n+ * Secondary to primary request.\n+ * start from function eal_dev_hotplug_request_to_primary.\n+ *\n+ * device attach on secondary:\n+ * a) secondary send sync request to the primary.\n+ * b) primary receive the request and attach the new device if\n+ *    failed goto i).\n+ * c) primary forward attach sync request to all secondary.\n+ * d) secondary receive the request and attach the device and send a reply.\n+ * e) primary check the reply if all success goes to j).\n+ * f) primary send attach rollback sync request to all secondary.\n+ * g) secondary receive the request and detach the device and send a reply.\n+ * h) primary receive the reply and detach device as rollback action.\n+ * i) send attach fail to secondary as a reply of step a), goto k).\n+ * j) send attach success to secondary as a reply of step a).\n+ * k) secondary receive reply and return.\n+ *\n+ * device detach on secondary:\n+ * a) secondary send sync request to the primary.\n+ * b) primary send detach sync request to all secondary.\n+ * c) secondary detach the device and send a reply.\n+ * d) primary check the reply if all success goes to g).\n+ * e) primary send detach rollback sync request to all secondary.\n+ * f) secondary receive the request and attach back device. goto h).\n+ * g) primary detach the device if success goto i), else goto e).\n+ * h) primary send detach fail to secondary as a reply of step a), goto j).\n+ * i) primary send detach success to secondary as a reply of step a).\n+ * j) secondary receive reply and return.\n+ */\n+static int\n+send_response_to_secondary(const struct eal_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 eal_dev_mp_req *resp =\n+\t\t(struct eal_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+\tstrlcpy(mp_resp.name, EAL_DEV_MP_ACTION_REQUEST, sizeof(mp_resp.name));\n+\tmemcpy(resp, req, sizeof(*req));\n+\tresp->result = result;\n+\n+\tret = rte_mp_reply(&mp_resp, peer);\n+\tif (ret)\n+\t\tRTE_LOG(ERR, EAL, \"failed to send response to secondary\\n\");\n+\n+\treturn ret;\n+}\n+\n+static void\n+__handle_secondary_request(void *param)\n+{\n+\tstruct mp_reply_bundle *bundle = param;\n+\t\tconst struct rte_mp_msg *msg = &bundle->msg;\n+\tconst struct eal_dev_mp_req *req =\n+\t\t(const struct eal_dev_mp_req *)msg->param;\n+\tstruct eal_dev_mp_req tmp_req;\n+\tint ret = 0;\n+\n+\ttmp_req = *req;\n+\n+\tif (req->t == EAL_DEV_REQ_TYPE_ATTACH) {\n+\t\tret = do_dev_hotplug_add(req->busname, req->devname,\n+\t\t\t\t\treq->devargs);\n+\t\tif (ret) {\n+\t\t\tRTE_LOG(ERR, EAL, \"Failed to hotplug add device on primary\\n\");\n+\t\t\tgoto finish;\n+\t\t}\n+\t\tret = eal_dev_hotplug_request_to_secondary(&tmp_req);\n+\t\tif (ret) {\n+\t\t\tRTE_LOG(ERR, EAL, \"Failed to send hotplug request to secondary\\n\");\n+\t\t\tgoto finish;\n+\t\t}\n+\t\tif (tmp_req.result) {\n+\t\t\tret = tmp_req.result;\n+\t\t\tRTE_LOG(ERR, EAL, \"Failed to hotplug add device on secondary\\n\");\n+\t\t}\n+\t} else if (req->t == EAL_DEV_REQ_TYPE_DETACH) {\n+\t\tret = eal_dev_hotplug_request_to_secondary(&tmp_req);\n+\t\tif (ret) {\n+\t\t\tRTE_LOG(ERR, EAL, \"Failed to send hotplug request to secondary\\n\");\n+\t\t\tgoto finish;\n+\t\t}\n+\t\tif (!tmp_req.result) {\n+\t\t\tret = do_dev_hotplug_remove(req->busname,\n+\t\t\t\t\t\treq->devname);\n+\t\t\tif (ret) {\n+\t\t\t\tRTE_LOG(ERR, EAL, \"Failed to hotplug remove device on primary\\n\");\n+\t\t\t\tgoto rollback;\n+\t\t\t}\n+\t\t} else {\n+\t\t\tRTE_LOG(ERR, EAL, \"Failed to hotplug remove device on secondary\\n\");\n+\t\t\tret = tmp_req.result;\n+\t\t\tgoto rollback;\n+\t\t}\n+\t} else {\n+\t\tRTE_LOG(ERR, EAL, \"unsupported secondary to primary request\\n\");\n+\t\tret = -ENOTSUP;\n+\t}\n+\tgoto finish;\n+\n+rollback:\n+\ttmp_req.t = EAL_DEV_REQ_TYPE_DETACH_ROLLBACK;\n+\tret = eal_dev_hotplug_request_to_secondary(&tmp_req);\n+\tif (ret)\n+\t\tRTE_LOG(ERR, EAL, \"Failed to send hotplug rollback request to secondary\\n\");\n+\n+finish:\n+\tret = send_response_to_secondary(&tmp_req, ret, bundle->peer);\n+\tif (ret)\n+\t\tRTE_LOG(ERR, EAL, \"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, const 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 eal_dev_mp_req *req =\n+\t\t(const struct eal_dev_mp_req *)msg->param;\n+\tint ret = 0;\n+\n+\tbundle = malloc(sizeof(*bundle));\n+\tif (bundle == NULL) {\n+\t\tRTE_LOG(ERR, EAL, \"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\tRTE_LOG(ERR, EAL, \"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@@ -114,8 +260,29 @@ handle_primary_request(const struct rte_mp_msg *msg, const void *peer)\n \n int eal_dev_hotplug_request_to_primary(struct eal_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 eal_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, EAL_DEV_MP_ACTION_REQUEST, sizeof(mp_req.name));\n+\n+\tret = rte_mp_request_sync(&mp_req, &mp_reply, &ts);\n+\tif (ret || mp_reply.nb_received != 1) {\n+\t\tRTE_LOG(ERR, EAL, \"cannot send request to primary\");\n+\t\tif (!ret)\n+\t\t\treturn -1;\n+\t\treturn ret;\n+\t}\n+\n+\tresp = (struct eal_dev_mp_req *)mp_reply.msgs[0].param;\n+\treq->result = resp->result;\n+\n+\treturn ret;\n }\n \n int eal_dev_hotplug_request_to_secondary(struct eal_dev_mp_req *req)\n",
    "prefixes": [
        "v12",
        "06/19"
    ]
}