get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 49943,
    "url": "http://patches.dpdk.org/api/patches/49943/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/2101fda2f9030723c662419ec9b4a33d2dc7aded.1547807046.git.anatoly.burakov@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": "<2101fda2f9030723c662419ec9b4a33d2dc7aded.1547807046.git.anatoly.burakov@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/2101fda2f9030723c662419ec9b4a33d2dc7aded.1547807046.git.anatoly.burakov@intel.com",
    "date": "2019-01-18T10:24:41",
    "name": "[v2] vfio: allow secondary process to query IOMMU type",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "cc302cf7fceeed6a876008edc341d10cc0defe65",
    "submitter": {
        "id": 4,
        "url": "http://patches.dpdk.org/api/people/4/?format=api",
        "name": "Anatoly Burakov",
        "email": "anatoly.burakov@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/2101fda2f9030723c662419ec9b4a33d2dc7aded.1547807046.git.anatoly.burakov@intel.com/mbox/",
    "series": [
        {
            "id": 3257,
            "url": "http://patches.dpdk.org/api/series/3257/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=3257",
            "date": "2019-01-18T10:24:41",
            "name": "[v2] vfio: allow secondary process to query IOMMU type",
            "version": 2,
            "mbox": "http://patches.dpdk.org/series/3257/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/49943/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/49943/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 893F428FD;\n\tFri, 18 Jan 2019 11:24:50 +0100 (CET)",
            "from mga02.intel.com (mga02.intel.com [134.134.136.20])\n\tby dpdk.org (Postfix) with ESMTP id 0B5E110A3;\n\tFri, 18 Jan 2019 11:24:48 +0100 (CET)",
            "from fmsmga006.fm.intel.com ([10.253.24.20])\n\tby orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t18 Jan 2019 02:24:47 -0800",
            "from irvmail001.ir.intel.com ([163.33.26.43])\n\tby fmsmga006.fm.intel.com with ESMTP; 18 Jan 2019 02:24:46 -0800",
            "from sivswdev05.ir.intel.com (sivswdev05.ir.intel.com\n\t[10.243.17.64])\n\tby irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id\n\tx0IAOjOn015022; Fri, 18 Jan 2019 10:24:45 GMT",
            "from sivswdev05.ir.intel.com (localhost [127.0.0.1])\n\tby sivswdev05.ir.intel.com with ESMTP id x0IAOjF9032233;\n\tFri, 18 Jan 2019 10:24:45 GMT",
            "(from aburakov@localhost)\n\tby sivswdev05.ir.intel.com with LOCAL id x0IAOfON032225;\n\tFri, 18 Jan 2019 10:24:41 GMT"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.56,489,1539673200\"; d=\"scan'208\";a=\"311494358\"",
        "From": "Anatoly Burakov <anatoly.burakov@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "xiao.w.wang@intel.com, qi.z.zhang@intel.com, qingfu.cqf@alibaba-inc.com, \n\tthomas@monjalon.net, dariusz.stojaczyk@intel.com, stable@dpdk.org",
        "Date": "Fri, 18 Jan 2019 10:24:41 +0000",
        "Message-Id": "<2101fda2f9030723c662419ec9b4a33d2dc7aded.1547807046.git.anatoly.burakov@intel.com>",
        "X-Mailer": "git-send-email 1.7.0.7",
        "In-Reply-To": "<a306fe2084c9f99dc00d18309c730bdce1817e37.1547746215.git.anatoly.burakov@intel.com>",
        "References": "<a306fe2084c9f99dc00d18309c730bdce1817e37.1547746215.git.anatoly.burakov@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v2] vfio: allow secondary process to query IOMMU\n\ttype",
        "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": "It is only possible to know IOMMU type of a given VFIO container\nby attempting to initialize it. Since secondary process never\nattempts to set up VFIO container itself (because they're shared\nbetween primary and secondary), it never knows which IOMMU type\nthe container is using, and never sets up the appropriate config\nstructures. This results in inability to perform DMA mappings in\nsecondary process.\n\nFix this by allowing secondary process to query IOMMU type of\nprimary's default container at device initialization.\n\nNote that this fix is assuming we're only interested in default\ncontainer.\n\nBugzilla ID: 174\n\nFixes: 6bcb7c95fe14 (\"vfio: share default container in multi-process\")\nCc: dariusz.stojaczyk@intel.com\nCc: stable@dpdk.org\n\nSigned-off-by: Anatoly Burakov <anatoly.burakov@intel.com>\n---\n\nNotes:\n    v2:\n    - Check if we found our IOMMU type within list of IOMMU types\n    - Don't request new default container fd as this should have\n      been done during rte_vfio_enable()\n\n lib/librte_eal/linuxapp/eal/eal_vfio.c        | 88 +++++++++++++++++++\n lib/librte_eal/linuxapp/eal/eal_vfio.h        | 12 ++-\n .../linuxapp/eal/eal_vfio_mp_sync.c           | 16 ++++\n 3 files changed, 115 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/lib/librte_eal/linuxapp/eal/eal_vfio.c b/lib/librte_eal/linuxapp/eal/eal_vfio.c\nindex 72cc65151..c821e8382 100644\n--- a/lib/librte_eal/linuxapp/eal/eal_vfio.c\n+++ b/lib/librte_eal/linuxapp/eal/eal_vfio.c\n@@ -549,6 +549,65 @@ vfio_mem_event_callback(enum rte_mem_event type, const void *addr, size_t len,\n \t}\n }\n \n+static int\n+vfio_sync_default_container(void)\n+{\n+\tstruct rte_mp_msg mp_req, *mp_rep;\n+\tstruct rte_mp_reply mp_reply;\n+\tstruct timespec ts = {.tv_sec = 5, .tv_nsec = 0};\n+\tstruct vfio_mp_param *p = (struct vfio_mp_param *)mp_req.param;\n+\tint iommu_type_id;\n+\tunsigned int i;\n+\n+\t/* cannot be called from primary */\n+\tif (rte_eal_process_type() != RTE_PROC_SECONDARY)\n+\t\treturn -1;\n+\n+\t/* default container fd should have been opened in rte_vfio_enable() */\n+\tif (!default_vfio_cfg->vfio_enabled ||\n+\t\t\tdefault_vfio_cfg->vfio_container_fd < 0) {\n+\t\tRTE_LOG(ERR, EAL, \"VFIO support is not initialized\\n\");\n+\t\treturn -1;\n+\t}\n+\n+\t/* find default container's IOMMU type */\n+\tp->req = SOCKET_REQ_IOMMU_TYPE;\n+\tstrcpy(mp_req.name, EAL_VFIO_MP);\n+\tmp_req.len_param = sizeof(*p);\n+\tmp_req.num_fds = 0;\n+\n+\tiommu_type_id = -1;\n+\tif (rte_mp_request_sync(&mp_req, &mp_reply, &ts) == 0 &&\n+\t\t\tmp_reply.nb_received == 1) {\n+\t\tmp_rep = &mp_reply.msgs[0];\n+\t\tp = (struct vfio_mp_param *)mp_rep->param;\n+\t\tif (p->result == SOCKET_OK)\n+\t\t\tiommu_type_id = p->iommu_type_id;\n+\t\tfree(mp_reply.msgs);\n+\t}\n+\tif (iommu_type_id < 0) {\n+\t\tRTE_LOG(ERR, EAL, \"Could not get IOMMU type for default container\\n\");\n+\t\treturn -1;\n+\t}\n+\n+\t/* we now have an fd for default container, as well as its IOMMU type.\n+\t * now, set up default VFIO container config to match.\n+\t */\n+\tfor (i = 0; i < RTE_DIM(iommu_types); i++) {\n+\t\tconst struct vfio_iommu_type *t = &iommu_types[i];\n+\t\tif (t->type_id != iommu_type_id)\n+\t\t\tcontinue;\n+\n+\t\t/* we found our IOMMU type */\n+\t\tdefault_vfio_cfg->vfio_iommu_type = t;\n+\n+\t\treturn 0;\n+\t}\n+\tRTE_LOG(ERR, EAL, \"Could not find IOMMU type id (%i)\\n\",\n+\t\t\tiommu_type_id);\n+\treturn -1;\n+}\n+\n int\n rte_vfio_clear_group(int vfio_group_fd)\n {\n@@ -745,6 +804,26 @@ rte_vfio_setup_device(const char *sysfs_base, const char *dev_addr,\n \t\t\telse\n \t\t\t\tRTE_LOG(DEBUG, EAL, \"Installed memory event callback for VFIO\\n\");\n \t\t}\n+\t} else if (rte_eal_process_type() != RTE_PROC_PRIMARY &&\n+\t\t\tvfio_cfg == default_vfio_cfg &&\n+\t\t\tvfio_cfg->vfio_iommu_type == NULL) {\n+\t\t/* if we're not a primary process, we do not set up the VFIO\n+\t\t * container because it's already been set up by the primary\n+\t\t * process. instead, we simply ask the primary about VFIO type\n+\t\t * we are using, and set the VFIO config up appropriately.\n+\t\t */\n+\t\tret = vfio_sync_default_container();\n+\t\tif (ret < 0) {\n+\t\t\tRTE_LOG(ERR, EAL, \"Could not sync default VFIO container\\n\");\n+\t\t\tclose(vfio_group_fd);\n+\t\t\trte_vfio_clear_group(vfio_group_fd);\n+\t\t\treturn -1;\n+\t\t}\n+\t\t/* we have successfully initialized VFIO, notify user */\n+\t\tconst struct vfio_iommu_type *t =\n+\t\t\t\tdefault_vfio_cfg->vfio_iommu_type;\n+\t\tRTE_LOG(NOTICE, EAL, \"  using IOMMU type %d (%s)\\n\",\n+\t\t\t\tt->type_id, t->name);\n \t}\n \n \t/* get a file descriptor for the device */\n@@ -978,6 +1057,15 @@ vfio_get_default_container_fd(void)\n \treturn -1;\n }\n \n+int\n+vfio_get_iommu_type(void)\n+{\n+\tif (default_vfio_cfg->vfio_iommu_type == NULL)\n+\t\treturn -1;\n+\n+\treturn default_vfio_cfg->vfio_iommu_type->type_id;\n+}\n+\n const struct vfio_iommu_type *\n vfio_set_iommu_type(int vfio_container_fd)\n {\ndiff --git a/lib/librte_eal/linuxapp/eal/eal_vfio.h b/lib/librte_eal/linuxapp/eal/eal_vfio.h\nindex 63ae115c3..cb2d35fb1 100644\n--- a/lib/librte_eal/linuxapp/eal/eal_vfio.h\n+++ b/lib/librte_eal/linuxapp/eal/eal_vfio.h\n@@ -5,6 +5,8 @@\n #ifndef EAL_VFIO_H_\n #define EAL_VFIO_H_\n \n+#include <rte_common.h>\n+\n /*\n  * determine if VFIO is present on the system\n  */\n@@ -122,6 +124,9 @@ int vfio_get_default_container_fd(void);\n const struct vfio_iommu_type *\n vfio_set_iommu_type(int vfio_container_fd);\n \n+int\n+vfio_get_iommu_type(void);\n+\n /* check if we have any supported extensions */\n int\n vfio_has_supported_extensions(int vfio_container_fd);\n@@ -133,6 +138,7 @@ int vfio_mp_sync_setup(void);\n #define SOCKET_REQ_CONTAINER 0x100\n #define SOCKET_REQ_GROUP 0x200\n #define SOCKET_REQ_DEFAULT_CONTAINER 0x400\n+#define SOCKET_REQ_IOMMU_TYPE 0x800\n #define SOCKET_OK 0x0\n #define SOCKET_NO_FD 0x1\n #define SOCKET_ERR 0xFF\n@@ -140,7 +146,11 @@ int vfio_mp_sync_setup(void);\n struct vfio_mp_param {\n \tint req;\n \tint result;\n-\tint group_num;\n+\tRTE_STD_C11\n+\tunion {\n+\t\tint group_num;\n+\t\tint iommu_type_id;\n+\t};\n };\n \n #endif /* VFIO_PRESENT */\ndiff --git a/lib/librte_eal/linuxapp/eal/eal_vfio_mp_sync.c b/lib/librte_eal/linuxapp/eal/eal_vfio_mp_sync.c\nindex a1e8c834f..2a47f29d5 100644\n--- a/lib/librte_eal/linuxapp/eal/eal_vfio_mp_sync.c\n+++ b/lib/librte_eal/linuxapp/eal/eal_vfio_mp_sync.c\n@@ -77,6 +77,22 @@ vfio_mp_primary(const struct rte_mp_msg *msg, const void *peer)\n \t\t\treply.fds[0] = fd;\n \t\t}\n \t\tbreak;\n+\tcase SOCKET_REQ_IOMMU_TYPE:\n+\t{\n+\t\tint iommu_type_id;\n+\n+\t\tr->req = SOCKET_REQ_IOMMU_TYPE;\n+\n+\t\tiommu_type_id = vfio_get_iommu_type();\n+\n+\t\tif (iommu_type_id < 0)\n+\t\t\tr->result = SOCKET_ERR;\n+\t\telse {\n+\t\t\tr->iommu_type_id = iommu_type_id;\n+\t\t\tr->result = SOCKET_OK;\n+\t\t}\n+\t\tbreak;\n+\t}\n \tdefault:\n \t\tRTE_LOG(ERR, EAL, \"vfio received invalid message!\\n\");\n \t\treturn -1;\n",
    "prefixes": [
        "v2"
    ]
}