get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 69827,
    "url": "http://patchwork.dpdk.org/api/patches/69827/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20200506113524.30205-3-haiyue.wang@intel.com/",
    "project": {
        "id": 1,
        "url": "http://patchwork.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": "<20200506113524.30205-3-haiyue.wang@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20200506113524.30205-3-haiyue.wang@intel.com",
    "date": "2020-05-06T11:35:24",
    "name": "[v13,2/2] eal: support for VFIO-PCI VF token",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "3a3a90abe4247d140794b16c45f211cf950a91ac",
    "submitter": {
        "id": 1044,
        "url": "http://patchwork.dpdk.org/api/people/1044/?format=api",
        "name": "Wang, Haiyue",
        "email": "haiyue.wang@intel.com"
    },
    "delegate": {
        "id": 24651,
        "url": "http://patchwork.dpdk.org/api/users/24651/?format=api",
        "username": "dmarchand",
        "first_name": "David",
        "last_name": "Marchand",
        "email": "david.marchand@redhat.com"
    },
    "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/20200506113524.30205-3-haiyue.wang@intel.com/mbox/",
    "series": [
        {
            "id": 9869,
            "url": "http://patchwork.dpdk.org/api/series/9869/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=9869",
            "date": "2020-05-06T11:35:22",
            "name": "support for VFIO-PCI VF token interface",
            "version": 13,
            "mbox": "http://patchwork.dpdk.org/series/9869/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/69827/comments/",
    "check": "success",
    "checks": "http://patchwork.dpdk.org/api/patches/69827/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 55CA2A034F;\n\tWed,  6 May 2020 13:51:07 +0200 (CEST)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 8D4CF1D982;\n\tWed,  6 May 2020 13:50:54 +0200 (CEST)",
            "from mga01.intel.com (mga01.intel.com [192.55.52.88])\n by dpdk.org (Postfix) with ESMTP id 23B841D975\n for <dev@dpdk.org>; Wed,  6 May 2020 13:50:51 +0200 (CEST)",
            "from fmsmga006.fm.intel.com ([10.253.24.20])\n by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 06 May 2020 04:50:51 -0700",
            "from npg-dpdk-haiyue-2.sh.intel.com ([10.67.119.70])\n by fmsmga006.fm.intel.com with ESMTP; 06 May 2020 04:50:50 -0700"
        ],
        "IronPort-SDR": [
            "\n SaAkbTju4Ic1b/iM4dk1DI0wr6AlH8I73Nsszoois8JcU+6PZQEdHoXU8BntVlAohJJSfqgJgY\n qnXyCF1wyyOg==",
            "\n J2oX7q53cfL2SPkfr1UqMHwtShtazFWNKTNptQPYh1L6gv/oMLo6XU3mN/M3ZaznKfAfaz9l7n\n nM7hyovS4ZTA=="
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.73,358,1583222400\"; d=\"scan'208\";a=\"461738602\"",
        "From": "Haiyue Wang <haiyue.wang@intel.com>",
        "To": "dev@dpdk.org, anatoly.burakov@intel.com, thomas@monjalon.net,\n jerinj@marvell.com, david.marchand@redhat.com",
        "Cc": "Haiyue Wang <haiyue.wang@intel.com>",
        "Date": "Wed,  6 May 2020 19:35:24 +0800",
        "Message-Id": "<20200506113524.30205-3-haiyue.wang@intel.com>",
        "X-Mailer": "git-send-email 2.26.2",
        "In-Reply-To": "<20200506113524.30205-1-haiyue.wang@intel.com>",
        "References": "<20200305043311.17065-1-vattunuru@marvell.com>\n <20200506113524.30205-1-haiyue.wang@intel.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[dpdk-dev] [PATCH v13 2/2] eal: support for VFIO-PCI VF token",
        "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 <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 <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "The kernel module vfio-pci introduces the VF token to enable SR-IOV\nsupport since 5.7.\n\nThe VF token can be set by a vfio-pci based PF driver and must be known\nby the vfio-pci based VF driver in order to gain access to the device.\n\nSigned-off-by: Haiyue Wang <haiyue.wang@intel.com>\nAcked-by: Anatoly Burakov <anatoly.burakov@intel.com>\n---\n doc/guides/linux_gsg/linux_drivers.rst        | 35 ++++++++++++++++++-\n doc/guides/linux_gsg/linux_eal_parameters.rst |  4 +++\n doc/guides/rel_notes/release_20_05.rst        |  6 ++++\n lib/librte_eal/common/eal_common_options.c    |  2 ++\n lib/librte_eal/common/eal_internal_cfg.h      |  2 ++\n lib/librte_eal/common/eal_options.h           |  2 ++\n lib/librte_eal/freebsd/eal.c                  |  4 +++\n lib/librte_eal/include/rte_eal.h              | 12 +++++++\n lib/librte_eal/linux/eal.c                    | 29 +++++++++++++++\n lib/librte_eal/linux/eal_vfio.c               | 19 ++++++++++\n lib/librte_eal/rte_eal_version.map            |  1 +\n 11 files changed, 115 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/doc/guides/linux_gsg/linux_drivers.rst b/doc/guides/linux_gsg/linux_drivers.rst\nindex 238f3e900..910397243 100644\n--- a/doc/guides/linux_gsg/linux_drivers.rst\n+++ b/doc/guides/linux_gsg/linux_drivers.rst\n@@ -72,11 +72,44 @@ Note that in order to use VFIO, your kernel must support it.\n VFIO kernel modules have been included in the Linux kernel since version 3.6.0 and are usually present by default,\n however please consult your distributions documentation to make sure that is the case.\n \n+The ``vfio-pci`` module since Linux version 5.7 supports the creation of virtual\n+functions. After the PF is bound to vfio-pci module, the user can create the VFs\n+by sysfs interface, and these VFs are bound to vfio-pci module automatically.\n+\n+When the PF is bound to vfio-pci, it has initial VF token generated by random. For\n+security reason, this token is write only, the user can't read it from the kernel\n+directly. For accessing the VF, the user needs to start the PF with token parameter\n+to setup a VF token (uuid format), then the VF can be accessed with this new known\n+VF token.\n+\n+DPDK will use the EAL parameter ``--vfio-vf-token`` to specify the VF token value to\n+PF and its related VFs, this VF token will be shared in all VFIO devices, including\n+the different PFs.\n+\n+.. code-block:: console\n+\n+    1. Generate the VF token by uuid command\n+        14d63f20-8445-11ea-8900-1f9ce7d5650d\n+\n+    2. sudo modprobe vfio-pci enable_sriov=1\n+\n+    2. ./usertools/dpdk-devbind.py -b vfio-pci 0000:86:00.0\n+\n+    3. echo 2 > /sys/bus/pci/devices/0000:86:00.0/sriov_numvfs\n+\n+    4. Start the PF:\n+        ./x86_64-native-linux-gcc/app/testpmd -l 22-25 -n 4 -w 86:00.0 \\\n+         --vfio-vf-token=14d63f20-8445-11ea-8900-1f9ce7d5650d --file-prefix=pf -- -i\n+\n+    5. Start the VF:\n+        ./x86_64-native-linux-gcc/app/testpmd -l 26-29 -n 4 -w 86:02.0 \\\n+         --vfio-vf-token=14d63f20-8445-11ea-8900-1f9ce7d5650d --file-prefix=vf0 -- -i\n+\n Also, to use VFIO, both kernel and BIOS must support and be configured to use IO virtualization (such as Intel® VT-d).\n \n .. note::\n \n-    ``vfio-pci`` module doesn't support the creation of virtual functions.\n+    ``vfio-pci`` module doesn't support the creation of virtual functions before Linux version 5.7.\n \n For proper operation of VFIO when running DPDK applications as a non-privileged user, correct permissions should also be set up.\n This can be done by using the DPDK setup script (called dpdk-setup.sh and located in the usertools directory).\ndiff --git a/doc/guides/linux_gsg/linux_eal_parameters.rst b/doc/guides/linux_gsg/linux_eal_parameters.rst\nindex b2cc60e44..bd3977cb3 100644\n--- a/doc/guides/linux_gsg/linux_eal_parameters.rst\n+++ b/doc/guides/linux_gsg/linux_eal_parameters.rst\n@@ -40,6 +40,10 @@ Device-related options\n \n     Use specified interrupt mode for devices bound to VFIO kernel driver.\n \n+*   ``--vfio-vf-token <uuid>``\n+\n+    Use specified VF token for devices bound to VFIO kernel driver.\n+\n Multiprocessing-related options\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n \ndiff --git a/doc/guides/rel_notes/release_20_05.rst b/doc/guides/rel_notes/release_20_05.rst\nindex c287cb48a..b19b03f83 100644\n--- a/doc/guides/rel_notes/release_20_05.rst\n+++ b/doc/guides/rel_notes/release_20_05.rst\n@@ -93,6 +93,12 @@ New Features\n   * Added new query: ``rte_flow_get_aged_flows`` to get the aged-out flows\n     contexts from the port.\n \n+* **Added the support for vfio-pci new VF token interface.**\n+\n+  Since Linux version 5.7, vfio-pci supports a shared VF token (UUID) to represent\n+  the trust between SR-IOV PF and the created VFs. Update the method to gain access\n+  to the PF and VFs devices by appending the VF token parameter.\n+\n * **Updated Amazon ena driver.**\n \n   Updated ena PMD with new features and improvements, including:\ndiff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c\nindex 418731ca4..dbce919ad 100644\n--- a/lib/librte_eal/common/eal_common_options.c\n+++ b/lib/librte_eal/common/eal_common_options.c\n@@ -89,6 +89,7 @@ eal_long_options[] = {\n \t{OPT_SYSLOG,            1, NULL, OPT_SYSLOG_NUM           },\n \t{OPT_VDEV,              1, NULL, OPT_VDEV_NUM             },\n \t{OPT_VFIO_INTR,         1, NULL, OPT_VFIO_INTR_NUM        },\n+\t{OPT_VFIO_VF_TOKEN,     1, NULL, OPT_VFIO_VF_TOKEN_NUM    },\n \t{OPT_VMWARE_TSC_MAP,    0, NULL, OPT_VMWARE_TSC_MAP_NUM   },\n \t{OPT_LEGACY_MEM,        0, NULL, OPT_LEGACY_MEM_NUM       },\n \t{OPT_SINGLE_FILE_SEGMENTS, 0, NULL, OPT_SINGLE_FILE_SEGMENTS_NUM},\n@@ -222,6 +223,7 @@ eal_reset_internal_config(struct internal_config *internal_cfg)\n \n \t/* if set to NONE, interrupt mode is determined automatically */\n \tinternal_cfg->vfio_intr_mode = RTE_INTR_MODE_NONE;\n+\tmemset(internal_cfg->vfio_vf_token, 0, sizeof(rte_uuid_t));\n \n #ifdef RTE_LIBEAL_USE_HPET\n \tinternal_cfg->no_hpet = 0;\ndiff --git a/lib/librte_eal/common/eal_internal_cfg.h b/lib/librte_eal/common/eal_internal_cfg.h\nindex a42f34923..28154f0ef 100644\n--- a/lib/librte_eal/common/eal_internal_cfg.h\n+++ b/lib/librte_eal/common/eal_internal_cfg.h\n@@ -72,6 +72,8 @@ struct internal_config {\n \tvolatile int syslog_facility;\t  /**< facility passed to openlog() */\n \t/** default interrupt mode for VFIO */\n \tvolatile enum rte_intr_mode vfio_intr_mode;\n+\t/** the shared VF token for VFIO-PCI bound PF and VFs devices */\n+\trte_uuid_t vfio_vf_token;\n \tchar *hugefile_prefix;      /**< the base filename of hugetlbfs files */\n \tchar *hugepage_dir;         /**< specific hugetlbfs directory to use */\n \tchar *user_mbuf_pool_ops_name;\ndiff --git a/lib/librte_eal/common/eal_options.h b/lib/librte_eal/common/eal_options.h\nindex 90ead1b7c..cd5fd01f2 100644\n--- a/lib/librte_eal/common/eal_options.h\n+++ b/lib/librte_eal/common/eal_options.h\n@@ -67,6 +67,8 @@ enum {\n \tOPT_VDEV_NUM,\n #define OPT_VFIO_INTR         \"vfio-intr\"\n \tOPT_VFIO_INTR_NUM,\n+#define OPT_VFIO_VF_TOKEN     \"vfio-vf-token\"\n+\tOPT_VFIO_VF_TOKEN_NUM,\n #define OPT_VMWARE_TSC_MAP    \"vmware-tsc-map\"\n \tOPT_VMWARE_TSC_MAP_NUM,\n #define OPT_LEGACY_MEM    \"legacy-mem\"\ndiff --git a/lib/librte_eal/freebsd/eal.c b/lib/librte_eal/freebsd/eal.c\nindex 540b7d38c..07f17f182 100644\n--- a/lib/librte_eal/freebsd/eal.c\n+++ b/lib/librte_eal/freebsd/eal.c\n@@ -1002,6 +1002,10 @@ rte_eal_vfio_intr_mode(void)\n \treturn RTE_INTR_MODE_NONE;\n }\n \n+void rte_eal_vfio_get_vf_token(__rte_unused rte_uuid_t vf_token)\n+{\n+}\n+\n int rte_vfio_setup_device(__rte_unused const char *sysfs_base,\n \t\t      __rte_unused const char *dev_addr,\n \t\t      __rte_unused int *vfio_dev_fd,\ndiff --git a/lib/librte_eal/include/rte_eal.h b/lib/librte_eal/include/rte_eal.h\nindex 2f9ed298d..744370013 100644\n--- a/lib/librte_eal/include/rte_eal.h\n+++ b/lib/librte_eal/include/rte_eal.h\n@@ -21,6 +21,7 @@\n #include <rte_bus.h>\n \n #include <rte_pci_dev_feature_defs.h>\n+#include <rte_uuid.h>\n \n #ifdef __cplusplus\n extern \"C\" {\n@@ -438,6 +439,17 @@ int rte_eal_create_uio_dev(void);\n  */\n enum rte_intr_mode rte_eal_vfio_intr_mode(void);\n \n+\n+/**\n+ * Copy the user-configured vfio VF token.\n+ *\n+ * @param vf_token\n+ *   vfio VF token configured with the command line is copied\n+ *   into this parameter, zero uuid by default.\n+ */\n+__rte_experimental\n+void rte_eal_vfio_get_vf_token(rte_uuid_t vf_token);\n+\n /**\n  * A wrap API for syscall gettid.\n  *\ndiff --git a/lib/librte_eal/linux/eal.c b/lib/librte_eal/linux/eal.c\nindex aa72d3650..f394c281c 100644\n--- a/lib/librte_eal/linux/eal.c\n+++ b/lib/librte_eal/linux/eal.c\n@@ -558,6 +558,7 @@ eal_usage(const char *prgname)\n \t       \"  --\"OPT_FILE_PREFIX\"       Prefix for hugepage filenames\\n\"\n \t       \"  --\"OPT_CREATE_UIO_DEV\"    Create /dev/uioX (usually done by hotplug)\\n\"\n \t       \"  --\"OPT_VFIO_INTR\"         Interrupt mode for VFIO (legacy|msi|msix)\\n\"\n+\t       \"  --\"OPT_VFIO_VF_TOKEN\"     VF token (UUID) shared between SR-IOV PF and VFs\\n\"\n \t       \"  --\"OPT_LEGACY_MEM\"        Legacy memory mode (no dynamic allocation, contiguous segments)\\n\"\n \t       \"  --\"OPT_SINGLE_FILE_SEGMENTS\" Put all hugepage memory in single files\\n\"\n \t       \"  --\"OPT_MATCH_ALLOCATIONS\" Free hugepages exactly as allocated\\n\"\n@@ -649,6 +650,19 @@ eal_parse_vfio_intr(const char *mode)\n \treturn -1;\n }\n \n+static int\n+eal_parse_vfio_vf_token(const char *vf_token)\n+{\n+\trte_uuid_t uuid;\n+\n+\tif (!rte_uuid_parse(vf_token, uuid)) {\n+\t\trte_uuid_copy(internal_config.vfio_vf_token, uuid);\n+\t\treturn 0;\n+\t}\n+\n+\treturn -1;\n+}\n+\n /* Parse the arguments for --log-level only */\n static void\n eal_log_level_parse(int argc, char **argv)\n@@ -795,6 +809,16 @@ eal_parse_args(int argc, char **argv)\n \t\t\t}\n \t\t\tbreak;\n \n+\t\tcase OPT_VFIO_VF_TOKEN_NUM:\n+\t\t\tif (eal_parse_vfio_vf_token(optarg) < 0) {\n+\t\t\t\tRTE_LOG(ERR, EAL, \"invalid parameters for --\"\n+\t\t\t\t\t\tOPT_VFIO_VF_TOKEN \"\\n\");\n+\t\t\t\teal_usage(prgname);\n+\t\t\t\tret = -1;\n+\t\t\t\tgoto out;\n+\t\t\t}\n+\t\t\tbreak;\n+\n \t\tcase OPT_CREATE_UIO_DEV_NUM:\n \t\t\tinternal_config.create_uio_dev = 1;\n \t\t\tbreak;\n@@ -1367,6 +1391,11 @@ rte_eal_vfio_intr_mode(void)\n \treturn internal_config.vfio_intr_mode;\n }\n \n+void rte_eal_vfio_get_vf_token(rte_uuid_t vf_token)\n+{\n+\trte_uuid_copy(vf_token, internal_config.vfio_vf_token);\n+}\n+\n int\n rte_eal_check_module(const char *module_name)\n {\ndiff --git a/lib/librte_eal/linux/eal_vfio.c b/lib/librte_eal/linux/eal_vfio.c\nindex d26e1649a..5b2f6b305 100644\n--- a/lib/librte_eal/linux/eal_vfio.c\n+++ b/lib/librte_eal/linux/eal_vfio.c\n@@ -712,6 +712,7 @@ rte_vfio_setup_device(const char *sysfs_base, const char *dev_addr,\n \tint vfio_container_fd;\n \tint vfio_group_fd;\n \tint iommu_group_num;\n+\trte_uuid_t vf_token;\n \tint i, ret;\n \n \t/* get group number */\n@@ -895,6 +896,23 @@ rte_vfio_setup_device(const char *sysfs_base, const char *dev_addr,\n \t\t\t\tt->type_id, t->name);\n \t}\n \n+\trte_eal_vfio_get_vf_token(vf_token);\n+\n+\t/* get a file descriptor for the device with VF token firstly */\n+\tif (!rte_uuid_is_null(vf_token)) {\n+\t\tchar vf_token_str[RTE_UUID_STRLEN];\n+\t\tchar dev[PATH_MAX];\n+\n+\t\trte_uuid_unparse(vf_token, vf_token_str, sizeof(vf_token_str));\n+\t\tsnprintf(dev, sizeof(dev),\n+\t\t\t \"%s vf_token=%s\", dev_addr, vf_token_str);\n+\n+\t\t*vfio_dev_fd = ioctl(vfio_group_fd, VFIO_GROUP_GET_DEVICE_FD,\n+\t\t\t\t     dev);\n+\t\tif (*vfio_dev_fd >= 0)\n+\t\t\tgoto dev_get_info;\n+\t}\n+\n \t/* get a file descriptor for the device */\n \t*vfio_dev_fd = ioctl(vfio_group_fd, VFIO_GROUP_GET_DEVICE_FD, dev_addr);\n \tif (*vfio_dev_fd < 0) {\n@@ -909,6 +927,7 @@ rte_vfio_setup_device(const char *sysfs_base, const char *dev_addr,\n \t\treturn -1;\n \t}\n \n+dev_get_info:\n \t/* test and setup the device */\n \tret = ioctl(*vfio_dev_fd, VFIO_DEVICE_GET_INFO, device_info);\n \tif (ret) {\ndiff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map\nindex 6088e7f6c..f7043af69 100644\n--- a/lib/librte_eal/rte_eal_version.map\n+++ b/lib/librte_eal/rte_eal_version.map\n@@ -373,6 +373,7 @@ EXPERIMENTAL {\n \t__rte_trace_point_register;\n \tper_lcore_trace_mem;\n \tper_lcore_trace_point_sz;\n+\trte_eal_vfio_get_vf_token;\n \trte_log_can_log;\n \trte_thread_getname;\n \trte_trace_dump;\n",
    "prefixes": [
        "v13",
        "2/2"
    ]
}