Show a patch.

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

{
    "id": 74550,
    "url": "https://patches.dpdk.org/api/patches/74550/",
    "web_url": "https://patches.dpdk.org/patch/74550/",
    "project": {
        "id": 1,
        "url": "https://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": "<20200721095140.719297-12-bruce.richardson@intel.com>",
    "date": "2020-07-21T09:51:31",
    "name": "[20.11,11/20] raw/ioat: create rawdev instances for idxd vdevs",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "40ef0eae34f39211fac35c0b1089e81b65e3f69a",
    "submitter": {
        "id": 20,
        "url": "https://patches.dpdk.org/api/people/20/",
        "name": "Bruce Richardson",
        "email": "bruce.richardson@intel.com"
    },
    "delegate": {
        "id": 1,
        "url": "https://patches.dpdk.org/api/users/1/",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "https://patches.dpdk.org/patch/74550/mbox/",
    "series": [
        {
            "id": 11200,
            "url": "https://patches.dpdk.org/api/series/11200/",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=11200",
            "date": "2020-07-21T09:51:20",
            "name": "raw/ioat: enhancements and new hardware support",
            "version": 1,
            "mbox": "https://patches.dpdk.org/series/11200/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/74550/comments/",
    "check": "fail",
    "checks": "https://patches.dpdk.org/api/patches/74550/checks/",
    "tags": {},
    "headers": {
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>",
        "X-IronPort-AV": [
            "E=McAfee;i=\"6000,8403,9688\"; a=\"138191436\"",
            "E=Sophos;i=\"5.75,378,1589266800\"; d=\"scan'208\";a=\"138191436\"",
            "E=Sophos;i=\"5.75,378,1589266800\"; d=\"scan'208\";a=\"488024427\""
        ],
        "IronPort-SDR": [
            "\n +sfUcKbeBjIueg1Xd66reC+7QfoKzZsYCa1+zsGxZiHrzacVzLWf2HMhn76dwopKtJvZcel8YG\n DFFoWeD19qhw==",
            "\n 67GkL+qgTxOD6/AikW0Rt5iwyPa+1i8SjM3NVAjFcIB3NWX1M23ZMUNmotFQCU0JpzaCQYDokU\n nWZHfAKVMIvg=="
        ],
        "X-Amp-File-Uploaded": "False",
        "Precedence": "list",
        "X-Mailman-Version": "2.1.15",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "List-Post": "<mailto:dev@dpdk.org>",
        "MIME-Version": "1.0",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "X-BeenThere": "dev@dpdk.org",
        "References": "<20200721095140.719297-1-bruce.richardson@intel.com>",
        "Subject": "[dpdk-dev] [PATCH 20.11 11/20] raw/ioat: create rawdev instances\n\tfor idxd vdevs",
        "Sender": "\"dev\" <dev-bounces@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 22E53A0526;\n\tTue, 21 Jul 2020 11:56:14 +0200 (CEST)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 0ABCD1C025;\n\tTue, 21 Jul 2020 11:56:10 +0200 (CEST)",
            "from mga02.intel.com (mga02.intel.com [134.134.136.20])\n by dpdk.org (Postfix) with ESMTP id 8C7BB1C002\n for <dev@dpdk.org>; Tue, 21 Jul 2020 11:56:06 +0200 (CEST)",
            "from fmsmga005.fm.intel.com ([10.253.24.32])\n by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 21 Jul 2020 02:56:06 -0700",
            "from silpixa00399126.ir.intel.com ([10.237.222.36])\n by fmsmga005.fm.intel.com with ESMTP; 21 Jul 2020 02:56:04 -0700"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "X-Mailer": "git-send-email 2.25.1",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "X-ExtLoop1": "1",
        "Date": "Tue, 21 Jul 2020 10:51:31 +0100",
        "Content-Transfer-Encoding": "8bit",
        "To": "dev@dpdk.org",
        "From": "Bruce Richardson <bruce.richardson@intel.com>",
        "In-Reply-To": "<20200721095140.719297-1-bruce.richardson@intel.com>",
        "Cc": "cheng1.jiang@intel.com, patrick.fu@intel.com, kevin.laatz@intel.com,\n Bruce Richardson <bruce.richardson@intel.com>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Message-Id": "<20200721095140.719297-12-bruce.richardson@intel.com>",
        "Return-Path": "<dev-bounces@dpdk.org>"
    },
    "content": "From: Kevin Laatz <kevin.laatz@intel.com>\n\nFor each vdev (DSA work queue) instance, create a rawdev instance. Since\nthe vdev support depends upon the accel-config libraries, make the vdev\nsupport conditional upon that in meson.build.\n\nSigned-off-by: Kevin Laatz <kevin.laatz@intel.com>\nSigned-off-by: Bruce Richardson <bruce.richardson@intel.com>\n---\n drivers/raw/ioat/idxd_vdev.c | 163 ++++++++++++++++++++++++++++++++++-\n drivers/raw/ioat/meson.build |   9 +-\n 2 files changed, 169 insertions(+), 3 deletions(-)",
    "diff": "diff --git a/drivers/raw/ioat/idxd_vdev.c b/drivers/raw/ioat/idxd_vdev.c\nindex 73fce6d87..e81bd7326 100644\n--- a/drivers/raw/ioat/idxd_vdev.c\n+++ b/drivers/raw/ioat/idxd_vdev.c\n@@ -2,6 +2,12 @@\n  * Copyright(c) 2020 Intel Corporation\n  */\n \n+#include <fcntl.h>\n+#include <limits.h>\n+#include <sys/mman.h>\n+#include <accel-config/libaccel_config.h>\n+\n+#include <rte_memzone.h>\n #include <rte_bus_vdev.h>\n #include <rte_kvargs.h>\n #include <rte_string_fns.h>\n@@ -26,6 +32,79 @@ struct idxd_vdev_args {\n \tuint8_t wq_id;\n };\n \n+static const struct rte_rawdev_ops idxd_vdev_ops = {\n+\t\t.dev_selftest = idxd_rawdev_test,\n+};\n+\n+static void *\n+idxd_vdev_mmap_wq(struct accfg_device *dsa_dev, struct accfg_wq *wq)\n+{\n+\tvoid *addr;\n+\tint major, minor;\n+\tchar path[PATH_MAX];\n+\tint fd;\n+\n+\tmajor = accfg_device_get_cdev_major(dsa_dev);\n+\tif (major < 0) {\n+\t\tIOAT_PMD_ERR(\"Invalid major version %d\", major);\n+\t\treturn NULL;\n+\t}\n+\n+\tminor = accfg_wq_get_cdev_minor(wq);\n+\tif (minor < 0) {\n+\t\tIOAT_PMD_ERR(\"Invalid minor version %d\", minor);\n+\t\treturn NULL;\n+\t}\n+\n+\tsnprintf(path, sizeof(path), \"/dev/char/%u:%u\", major, minor);\n+\tfd = open(path, O_RDWR);\n+\tif (fd < 0) {\n+\t\tIOAT_PMD_ERR(\"Failed to open device path\");\n+\t\treturn NULL;\n+\t}\n+\n+\taddr = mmap(NULL, 0x1000, PROT_WRITE, MAP_SHARED | MAP_POPULATE, fd, 0);\n+\tif (addr == MAP_FAILED) {\n+\t\tIOAT_PMD_ERR(\"Failed to mmap device\");\n+\t\treturn NULL;\n+\t}\n+\n+\treturn addr;\n+}\n+\n+static int\n+idxd_rawdev_vdev_config(struct idxd_rawdev *idxd, struct idxd_vdev_args *args)\n+{\n+\tstruct accfg_ctx *dsa_ctx;\n+\tstruct accfg_device *dsa_dev;\n+\tstruct accfg_wq *dsa_wq;\n+\tint ret;\n+\n+\tret = accfg_new(&dsa_ctx);\n+\tif (ret < 0) {\n+\t\tIOAT_PMD_ERR(\"Failed to create device context\");\n+\t\tret = -ENOMEM;\n+\t}\n+\n+\tdsa_dev = accfg_ctx_device_get_by_id(dsa_ctx, args->device_id);\n+\tif (dsa_dev == NULL) {\n+\t\tIOAT_PMD_ERR(\"device not found: %u\", args->device_id);\n+\t\treturn -1;\n+\t}\n+\tdsa_wq = accfg_device_wq_get_by_id(dsa_dev, args->wq_id);\n+\tif (dsa_wq == NULL) {\n+\t\tIOAT_PMD_ERR(\"queue not found: %u\", args->wq_id);\n+\t\treturn -1;\n+\t}\n+\n+\tidxd->u.vdev.ctx = dsa_ctx;\n+\tidxd->u.vdev.device = dsa_dev;\n+\tidxd->u.vdev.wq = dsa_wq;\n+\tidxd->max_batches = accfg_wq_get_size(dsa_wq);\n+\n+\treturn ret;\n+}\n+\n static int\n idxd_rawdev_parse_wq(const char *key __rte_unused, const char *value,\n \t\t\t  void *extra_args)\n@@ -76,6 +155,7 @@ static int\n idxd_rawdev_probe_vdev(struct rte_vdev_device *vdev)\n {\n \tstruct rte_kvargs *kvlist;\n+\tstruct idxd_rawdev idxd = {0};\n \tstruct idxd_vdev_args vdev_args;\n \tconst char *name;\n \tint ret = 0;\n@@ -98,15 +178,52 @@ idxd_rawdev_probe_vdev(struct rte_vdev_device *vdev)\n \t\treturn -EINVAL;\n \t}\n \n+\tret = idxd_rawdev_vdev_config(&idxd, &vdev_args);\n+\tif (ret) {\n+\t\tIOAT_PMD_ERR(\"Failed to init vdev context\");\n+\t\treturn ret;\n+\t}\n+\n+\tidxd.qid = vdev_args.wq_id;\n+\tidxd.public.portal = idxd_vdev_mmap_wq(idxd.u.vdev.device, idxd.u.vdev.wq);\n+\tif (idxd.public.portal == NULL) {\n+\t\tIOAT_PMD_ERR(\"WQ mmap failed\");\n+\t\treturn -ENOMEM;\n+\t}\n+\n \tvdev->device.driver = &idxd_rawdev_drv_vdev.driver;\n \n+\tret = idxd_rawdev_create(name, &vdev->device, &idxd, &idxd_vdev_ops);\n+\tif (ret) {\n+\t\tIOAT_PMD_ERR(\"Failed to create rawdev %s\", name);\n+\t\treturn ret;\n+\t}\n+\n+\t/* enable the device itself */\n+\tif (accfg_device_is_active(idxd.u.vdev.device)) {\n+\t\tIOAT_PMD_INFO(\"Device %s already enabled\",\n+\t\t\t\taccfg_device_get_devname(idxd.u.vdev.device));\n+\t} else {\n+\t\tret = accfg_device_enable(idxd.u.vdev.device);\n+\t\tif (ret) {\n+\t\t\tIOAT_PMD_ERR(\"Error enabling device %s\",\n+\t\t\t\t\taccfg_device_get_devname(idxd.u.vdev.device));\n+\t\t\treturn -1;\n+\t\t}\n+\t\tIOAT_PMD_DEBUG(\"Enabling device %s OK\",\n+\t\t\t\taccfg_device_get_devname(idxd.u.vdev.device));\n+\t}\n+\n \treturn 0;\n }\n \n static int\n idxd_rawdev_remove_vdev(struct rte_vdev_device *vdev)\n {\n+\tstruct idxd_rawdev *idxd;\n \tconst char *name;\n+\tstruct rte_rawdev *rdev;\n+\tint ret = 0;\n \n \tname = rte_vdev_device_name(vdev);\n \tif (name == NULL)\n@@ -114,7 +231,51 @@ idxd_rawdev_remove_vdev(struct rte_vdev_device *vdev)\n \n \tIOAT_PMD_INFO(\"Remove DSA vdev %p\", name);\n \n-\treturn 0;\n+\trdev = rte_rawdev_pmd_get_named_dev(name);\n+\tif (!rdev) {\n+\t\tIOAT_PMD_ERR(\"Invalid device name (%s)\", name);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tidxd = rdev->dev_private;\n+\n+\t/* disable the device */\n+\tif (!accfg_device_is_active(idxd->u.vdev.device)) {\n+\t\tIOAT_PMD_ERR(\"Device %s already disabled\",\n+\t\t\t\taccfg_device_get_devname(idxd->u.vdev.device));\n+\t}\n+\n+\tret = accfg_device_disable(idxd->u.vdev.device);\n+\tif (ret) {\n+\t\tIOAT_PMD_ERR(\"Not able to disable device %s\",\n+\t\t\t\taccfg_device_get_devname(idxd->u.vdev.device));\n+\t\treturn ret;\n+\t}\n+\tIOAT_PMD_DEBUG(\"Disabling device %s OK\",\n+\t\t\taccfg_device_get_devname(idxd->u.vdev.device));\n+\n+\t/* free context and memory */\n+\tif (rdev->dev_private != NULL) {\n+\t\tIOAT_PMD_DEBUG(\"Freeing device driver memory\");\n+\t\trdev->dev_private = NULL;\n+\t\taccfg_unref(idxd->u.vdev.ctx);\n+\n+\t\tif (munmap(idxd->public.portal, 0x1000) < 0) {\n+\t\t\tIOAT_PMD_ERR(\"Error unmapping %s\",\n+\t\t\t\taccfg_wq_get_devname(idxd->u.vdev.wq));\n+\t\t\tret = -errno;\n+\t\t}\n+\n+\t\trte_free(idxd->public.batch_ring);\n+\t\trte_free(idxd->public.hdl_ring);\n+\n+\t\trte_memzone_free(idxd->mz);\n+\t}\n+\n+\tif (rte_rawdev_pmd_release(rdev))\n+\t\tIOAT_PMD_ERR(\"Device cleanup failed\");\n+\n+\treturn ret;\n }\n \n struct rte_vdev_driver idxd_rawdev_drv_vdev = {\ndiff --git a/drivers/raw/ioat/meson.build b/drivers/raw/ioat/meson.build\nindex 5eff76a1a..a730953f8 100644\n--- a/drivers/raw/ioat/meson.build\n+++ b/drivers/raw/ioat/meson.build\n@@ -5,14 +5,19 @@ build = dpdk_conf.has('RTE_ARCH_X86')\n reason = 'only supported on x86'\n sources = files(\n \t'idxd_pci.c',\n-\t'idxd_vdev.c',\n \t'ioat_common.c',\n \t'ioat_rawdev.c',\n \t'ioat_rawdev_test.c')\n deps += ['bus_pci',\n-\t'bus_vdev',\n \t'mbuf',\n \t'rawdev']\n \n install_headers('rte_ioat_rawdev.h',\n \t\t'rte_ioat_rawdev_fns.h')\n+\n+accfg_dep = dependency('libaccel-config', required: false)\n+if accfg_dep.found()\n+\tsources += files('idxd_vdev.c')\n+\tdeps += ['bus_vdev']\n+\text_deps += accfg_dep\n+endif\n",
    "prefixes": [
        "20.11",
        "11/20"
    ]
}