get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 96461,
    "url": "http://patchwork.dpdk.org/api/patches/96461/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20210730135533.417611-2-thomas@monjalon.net/",
    "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": "<20210730135533.417611-2-thomas@monjalon.net>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20210730135533.417611-2-thomas@monjalon.net",
    "date": "2021-07-30T13:55:27",
    "name": "[RFC,v2,1/7] hcdev: introduce heterogeneous computing device library",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "f5556e96954bb0ef4b102b79e835565487020a84",
    "submitter": {
        "id": 685,
        "url": "http://patchwork.dpdk.org/api/people/685/?format=api",
        "name": "Thomas Monjalon",
        "email": "thomas@monjalon.net"
    },
    "delegate": {
        "id": 1,
        "url": "http://patchwork.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/20210730135533.417611-2-thomas@monjalon.net/mbox/",
    "series": [
        {
            "id": 18101,
            "url": "http://patchwork.dpdk.org/api/series/18101/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=18101",
            "date": "2021-07-30T13:55:26",
            "name": "heterogeneous computing library",
            "version": 2,
            "mbox": "http://patchwork.dpdk.org/series/18101/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/96461/comments/",
    "check": "warning",
    "checks": "http://patchwork.dpdk.org/api/patches/96461/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 mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 19FE8A0A0C;\n\tFri, 30 Jul 2021 15:56:02 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id F3B1D40DDC;\n\tFri, 30 Jul 2021 15:56:01 +0200 (CEST)",
            "from new3-smtp.messagingengine.com (new3-smtp.messagingengine.com\n [66.111.4.229]) by mails.dpdk.org (Postfix) with ESMTP id 13DE34003F\n for <dev@dpdk.org>; Fri, 30 Jul 2021 15:56:01 +0200 (CEST)",
            "from compute3.internal (compute3.nyi.internal [10.202.2.43])\n by mailnew.nyi.internal (Postfix) with ESMTP id 74260580B57;\n Fri, 30 Jul 2021 09:56:00 -0400 (EDT)",
            "from mailfrontend1 ([10.202.2.162])\n by compute3.internal (MEProxy); Fri, 30 Jul 2021 09:56:00 -0400",
            "by mail.messagingengine.com (Postfix) with ESMTPA; Fri,\n 30 Jul 2021 09:55:58 -0400 (EDT)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h=\n from:to:cc:subject:date:message-id:in-reply-to:references\n :mime-version:content-transfer-encoding; s=fm1; bh=K8i8dm1sDmZTc\n ocXfM5rBLJqtqZvru1/YJey02esa0E=; b=wRSVvgPByGKZCs8yeqi03jhvQWtcu\n rMdAUWvgOIQZrpB0d2Wu+/cwED73NbqRasOA66SMYTJtNCENvNWtmUQmw02s/RFQ\n AIWj3Otj3MCb+1MHhuquJfwqg5zdJqWBntTWI71OELKfGAFimfqL+/ZAGCxkDnFS\n jzMZ24xa/uMr9vFFSuvnLPUHgZoPuiX/y7ljcEaaK+Wr2afuazSm0lvPHLCgGqpj\n PQLV1vwf5jyboGGutBOXlAC6nEwMZDYTMgBB7txMjRi/W0q5rmMtF1Mh0/qH+514\n qgWbQ3BQi0KdWZ4Jn8mUACsKud9P4G+/shU+UechNsDRSf9KBf3w/2l9w==",
            "v=1; a=rsa-sha256; c=relaxed/relaxed; d=\n messagingengine.com; h=cc:content-transfer-encoding:date:from\n :in-reply-to:message-id:mime-version:references:subject:to\n :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=\n fm3; bh=K8i8dm1sDmZTcocXfM5rBLJqtqZvru1/YJey02esa0E=; b=rKg5/TVn\n RXkdr2jhfCuhWSsV0jbhl1KZl3yvuEmszEF8/oNCttgTiSGr7Quo0COZddw2VewK\n rCe1To3bAZ3431yOSCUjvXrTJY4ZuY/NIcG1+aBY5caCh0rVNZbIb3vIagwd596g\n /vxEEzSfVBPrAL/nsw0WZsOzGfGyRqc/pBw+lXIZ0nVwCaTiuL+gYHNPkDm6/cUr\n iE4Awu70YcXZZHtVVePbQZEd8UGknbUK+0gqMTGrg2nbbeSRsyNjFatlTOzt/R1F\n Rd+HzRSi51pVk/qdq9aRdNi3RnyK3aymZThfo8e5wUlDuBNzCupyMMocB6zAVz4A\n kd1Nr1666mUEuA=="
        ],
        "X-ME-Sender": "<xms:8AQEYQ2CGKfEWkigWASW8kJcozGl4khPsg20lCB0lgL_9TASdIBc0Q>\n <xme:8AQEYbEpOZxbZywOK-37OFOpsrmNwjyM0G8LTAIaRUKliVIBicLCgy9Er5MBz7swC\n lGbyvdUXDCz77YznA>",
        "X-ME-Received": "\n <xmr:8AQEYY4eWMRprt6o_h54g_xgSM3pUKgEnlJimyByzzoxpcEepzbIzTkZDD3AE-NKpFWi12H8w3o6TLDtV5dYwXW7NV_m1RU>",
        "X-ME-Proxy-Cause": "\n gggruggvucftvghtrhhoucdtuddrgedvtddrheehgdeiiecutefuodetggdotefrodftvf\n curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu\n uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc\n fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhmrghs\n ucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenucggtf\n frrghtthgvrhhnpeeghfeuteeutedthffgteejuefgudeukeejlefgheeiffdtfeffjedv\n feduiefhtdenucffohhmrghinheptghonhhfrdhinhdpughpughkrdhorhhgnecuvehluh\n hsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhmrghssehm\n ohhnjhgrlhhonhdrnhgvth",
        "X-ME-Proxy": "<xmx:8AQEYZ0CxFgi7gpNSUcdsGQVJmR0ebGGyJd9ZoXHt-XyaP_LWY6ceg>\n <xmx:8AQEYTHvzbARPOoYcwWF2kys8YeQ1rwFedjR_4ofXx_vuWgyWaNGNA>\n <xmx:8AQEYS96p8yqAGmCbIsmcZ_ImsIMGem-EdcsB2kLz9AskkeRHEuhag>\n <xmx:8AQEYaAEAz5SORkVgsBvV32vFwo3i00JR7GvZneunyd6vlqayeKaBQ>",
        "From": "Thomas Monjalon <thomas@monjalon.net>",
        "To": "dev@dpdk.org",
        "Cc": "Stephen Hemminger <stephen@networkplumber.org>,\n David Marchand <david.marchand@redhat.com>,\n Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>,\n Haiyue Wang <haiyue.wang@intel.com>,\n Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>,\n Jerin Jacob <jerinj@marvell.com>, Ferruh Yigit <ferruh.yigit@intel.com>,\n Elena Agostini <eagostini@nvidia.com>, Ray Kinsella <mdr@ashroe.eu>,\n Anatoly Burakov <anatoly.burakov@intel.com>",
        "Date": "Fri, 30 Jul 2021 15:55:27 +0200",
        "Message-Id": "<20210730135533.417611-2-thomas@monjalon.net>",
        "X-Mailer": "git-send-email 2.31.1",
        "In-Reply-To": "<20210730135533.417611-1-thomas@monjalon.net>",
        "References": "<20210602203531.2288645-1-thomas@monjalon.net>\n <20210730135533.417611-1-thomas@monjalon.net>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[dpdk-dev] [RFC PATCH v2 1/7] hcdev: introduce heterogeneous\n computing device library",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "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": "From: Elena Agostini <eagostini@nvidia.com>\n\nIn heterogeneous computing system, processing is not only in the CPU.\nSome tasks can be delegated to devices working in parallel.\n\nThe new library hcdev is for dealing with computing devices\nfrom a DPDK application running on the CPU.\n\nThe infrastructure is prepared to welcome drivers in drivers/hc/.\n\nSigned-off-by: Elena Agostini <eagostini@nvidia.com>\nSigned-off-by: Thomas Monjalon <thomas@monjalon.net>\n---\n .gitignore                             |   1 +\n MAINTAINERS                            |   6 +\n doc/api/doxy-api-index.md              |   1 +\n doc/api/doxy-api.conf.in               |   1 +\n doc/guides/conf.py                     |   8 +\n doc/guides/hcdevs/features/default.ini |  10 +\n doc/guides/hcdevs/index.rst            |  11 ++\n doc/guides/hcdevs/overview.rst         |  11 ++\n doc/guides/index.rst                   |   1 +\n doc/guides/prog_guide/hcdev.rst        |   5 +\n doc/guides/prog_guide/index.rst        |   1 +\n doc/guides/rel_notes/release_21_08.rst |   4 +\n drivers/hc/meson.build                 |   4 +\n drivers/meson.build                    |   1 +\n lib/hcdev/hcdev.c                      | 249 +++++++++++++++++++++++++\n lib/hcdev/hcdev_driver.h               |  67 +++++++\n lib/hcdev/meson.build                  |  10 +\n lib/hcdev/rte_hcdev.h                  | 169 +++++++++++++++++\n lib/hcdev/version.map                  |  20 ++\n lib/meson.build                        |   1 +\n 20 files changed, 581 insertions(+)\n create mode 100644 doc/guides/hcdevs/features/default.ini\n create mode 100644 doc/guides/hcdevs/index.rst\n create mode 100644 doc/guides/hcdevs/overview.rst\n create mode 100644 doc/guides/prog_guide/hcdev.rst\n create mode 100644 drivers/hc/meson.build\n create mode 100644 lib/hcdev/hcdev.c\n create mode 100644 lib/hcdev/hcdev_driver.h\n create mode 100644 lib/hcdev/meson.build\n create mode 100644 lib/hcdev/rte_hcdev.h\n create mode 100644 lib/hcdev/version.map",
    "diff": "diff --git a/.gitignore b/.gitignore\nindex b19c0717e6..97e57e5897 100644\n--- a/.gitignore\n+++ b/.gitignore\n@@ -14,6 +14,7 @@ doc/guides/compressdevs/overview_feature_table.txt\n doc/guides/regexdevs/overview_feature_table.txt\n doc/guides/vdpadevs/overview_feature_table.txt\n doc/guides/bbdevs/overview_feature_table.txt\n+doc/guides/hcdevs/overview_feature_table.txt\n \n # ignore generated ctags/cscope files\n cscope.out.po\ndiff --git a/MAINTAINERS b/MAINTAINERS\nindex 8013ba1f14..71e850ae44 100644\n--- a/MAINTAINERS\n+++ b/MAINTAINERS\n@@ -452,6 +452,12 @@ F: app/test-regex/\n F: doc/guides/prog_guide/regexdev.rst\n F: doc/guides/regexdevs/features/default.ini\n \n+Heterogeneous Computing API - EXPERIMENTAL\n+M: Elena Agostini <eagostini@nvidia.com>\n+F: lib/hcdev/\n+F: doc/guides/prog_guide/hcdev.rst\n+F: doc/guides/hcdevs/features/default.ini\n+\n Eventdev API\n M: Jerin Jacob <jerinj@marvell.com>\n T: git://dpdk.org/next/dpdk-next-eventdev\ndiff --git a/doc/api/doxy-api-index.md b/doc/api/doxy-api-index.md\nindex 1992107a03..2e5256ccc1 100644\n--- a/doc/api/doxy-api-index.md\n+++ b/doc/api/doxy-api-index.md\n@@ -21,6 +21,7 @@ The public API headers are grouped by topics:\n   [compressdev]        (@ref rte_compressdev.h),\n   [compress]           (@ref rte_comp.h),\n   [regexdev]           (@ref rte_regexdev.h),\n+  [hcdev]              (@ref rte_hcdev.h),\n   [eventdev]           (@ref rte_eventdev.h),\n   [event_eth_rx_adapter]   (@ref rte_event_eth_rx_adapter.h),\n   [event_eth_tx_adapter]   (@ref rte_event_eth_tx_adapter.h),\ndiff --git a/doc/api/doxy-api.conf.in b/doc/api/doxy-api.conf.in\nindex 325a0195c6..549f373b8a 100644\n--- a/doc/api/doxy-api.conf.in\n+++ b/doc/api/doxy-api.conf.in\n@@ -44,6 +44,7 @@ INPUT                   = @TOPDIR@/doc/api/doxy-api-index.md \\\n                           @TOPDIR@/lib/gro \\\n                           @TOPDIR@/lib/gso \\\n                           @TOPDIR@/lib/hash \\\n+                          @TOPDIR@/lib/hcdev \\\n                           @TOPDIR@/lib/ip_frag \\\n                           @TOPDIR@/lib/ipsec \\\n                           @TOPDIR@/lib/jobstats \\\ndiff --git a/doc/guides/conf.py b/doc/guides/conf.py\nindex 67d2dd62c7..67ad2c8090 100644\n--- a/doc/guides/conf.py\n+++ b/doc/guides/conf.py\n@@ -152,6 +152,9 @@ def generate_overview_table(output_filename, table_id, section, table_name, titl\n         name = ini_filename[:-4]\n         name = name.replace('_vf', 'vf')\n         pmd_names.append(name)\n+    if not pmd_names:\n+        # Add an empty column if table is empty (required by RST syntax)\n+        pmd_names.append(' ')\n \n     # Pad the table header names.\n     max_header_len = len(max(pmd_names, key=len))\n@@ -388,6 +391,11 @@ def setup(app):\n                             'Features',\n                             'Features availability in bbdev drivers',\n                             'Feature')\n+    table_file = dirname(__file__) + '/hcdevs/overview_feature_table.txt'\n+    generate_overview_table(table_file, 1,\n+                            'Features',\n+                            'Features availability in hcdev drivers',\n+                            'Feature')\n \n     if LooseVersion(sphinx_version) < LooseVersion('1.3.1'):\n         print('Upgrade sphinx to version >= 1.3.1 for '\ndiff --git a/doc/guides/hcdevs/features/default.ini b/doc/guides/hcdevs/features/default.ini\nnew file mode 100644\nindex 0000000000..f988ee73d4\n--- /dev/null\n+++ b/doc/guides/hcdevs/features/default.ini\n@@ -0,0 +1,10 @@\n+;\n+; Features of heterogeneous device driver.\n+;\n+; This file defines the features that are valid for inclusion in\n+; the other driver files and also the order that they appear in\n+; the features table in the documentation. The feature description\n+; string should not exceed feature_str_len defined in conf.py.\n+;\n+[Features]\n+Get device info                =\ndiff --git a/doc/guides/hcdevs/index.rst b/doc/guides/hcdevs/index.rst\nnew file mode 100644\nindex 0000000000..4c217ec0c2\n--- /dev/null\n+++ b/doc/guides/hcdevs/index.rst\n@@ -0,0 +1,11 @@\n+.. SPDX-License-Identifier: BSD-3-Clause\n+   Copyright (c) 2021 NVIDIA Corporation & Affiliates\n+\n+Heterogeneous Computing Device Drivers\n+======================================\n+\n+.. toctree::\n+   :maxdepth: 2\n+   :numbered:\n+\n+   overview\ndiff --git a/doc/guides/hcdevs/overview.rst b/doc/guides/hcdevs/overview.rst\nnew file mode 100644\nindex 0000000000..aedce33792\n--- /dev/null\n+++ b/doc/guides/hcdevs/overview.rst\n@@ -0,0 +1,11 @@\n+.. SPDX-License-Identifier: BSD-3-Clause\n+   Copyright (c) 2021 NVIDIA Corporation & Affiliates\n+\n+Overview of Heterogeneous Computing Drivers\n+===========================================\n+\n+Heterogeneous computing device may refer to any computing unit\n+able to process data and to share some memory with the CPU.\n+Examples are GPU or specialized processor in a SoC.\n+\n+.. include:: overview_feature_table.txt\ndiff --git a/doc/guides/index.rst b/doc/guides/index.rst\nindex 857f0363d3..643c52d8f9 100644\n--- a/doc/guides/index.rst\n+++ b/doc/guides/index.rst\n@@ -21,6 +21,7 @@ DPDK documentation\n    compressdevs/index\n    vdpadevs/index\n    regexdevs/index\n+   hcdevs/index\n    eventdevs/index\n    rawdevs/index\n    mempool/index\ndiff --git a/doc/guides/prog_guide/hcdev.rst b/doc/guides/prog_guide/hcdev.rst\nnew file mode 100644\nindex 0000000000..0b5bd3cb1c\n--- /dev/null\n+++ b/doc/guides/prog_guide/hcdev.rst\n@@ -0,0 +1,5 @@\n+.. SPDX-License-Identifier: BSD-3-Clause\n+   Copyright (c) 2021 NVIDIA Corporation & Affiliates\n+\n+Heterogeneous Computing Device Library\n+======================================\ndiff --git a/doc/guides/prog_guide/index.rst b/doc/guides/prog_guide/index.rst\nindex 2dce507f46..12e7ea3e20 100644\n--- a/doc/guides/prog_guide/index.rst\n+++ b/doc/guides/prog_guide/index.rst\n@@ -27,6 +27,7 @@ Programmer's Guide\n     cryptodev_lib\n     compressdev\n     regexdev\n+    hcdev\n     rte_security\n     rawdev\n     link_bonding_poll_mode_drv_lib\ndiff --git a/doc/guides/rel_notes/release_21_08.rst b/doc/guides/rel_notes/release_21_08.rst\nindex 16bb9ce19e..fb350b4706 100644\n--- a/doc/guides/rel_notes/release_21_08.rst\n+++ b/doc/guides/rel_notes/release_21_08.rst\n@@ -55,6 +55,10 @@ New Features\n      Also, make sure to start the actual text at the margin.\n      =======================================================\n \n+* **Introduced Heterogeneous Computing Device library with first features:**\n+\n+  * Device information\n+\n * **Added auxiliary bus support.**\n \n   Auxiliary bus provides a way to split function into child-devices\ndiff --git a/drivers/hc/meson.build b/drivers/hc/meson.build\nnew file mode 100644\nindex 0000000000..e51ad3381b\n--- /dev/null\n+++ b/drivers/hc/meson.build\n@@ -0,0 +1,4 @@\n+# SPDX-License-Identifier: BSD-3-Clause\n+# Copyright (c) 2021 NVIDIA Corporation & Affiliates\n+\n+drivers = []\ndiff --git a/drivers/meson.build b/drivers/meson.build\nindex bc6f4f567f..b0dbee1b54 100644\n--- a/drivers/meson.build\n+++ b/drivers/meson.build\n@@ -18,6 +18,7 @@ subdirs = [\n         'vdpa',           # depends on common, bus and mempool.\n         'event',          # depends on common, bus, mempool and net.\n         'baseband',       # depends on common and bus.\n+        'hc',             # depends on common and bus.\n ]\n \n if meson.is_cross_build()\ndiff --git a/lib/hcdev/hcdev.c b/lib/hcdev/hcdev.c\nnew file mode 100644\nindex 0000000000..ea587b3713\n--- /dev/null\n+++ b/lib/hcdev/hcdev.c\n@@ -0,0 +1,249 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright (c) 2021 NVIDIA Corporation & Affiliates\n+ */\n+\n+#include <rte_eal.h>\n+#include <rte_string_fns.h>\n+#include <rte_errno.h>\n+#include <rte_log.h>\n+\n+#include \"rte_hcdev.h\"\n+#include \"hcdev_driver.h\"\n+\n+/* Logging */\n+RTE_LOG_REGISTER_DEFAULT(hcdev_logtype, NOTICE);\n+#define HCDEV_LOG(level, ...) \\\n+\trte_log(RTE_LOG_ ## level, hcdev_logtype, RTE_FMT(\"hcdev: \" \\\n+\t\tRTE_FMT_HEAD(__VA_ARGS__,) \"\\n\", RTE_FMT_TAIL(__VA_ARGS__,)))\n+\n+/* Set any driver error as EPERM */\n+#define HCDEV_DRV_RET(function) \\\n+\t((function != 0) ? -(rte_errno = EPERM) : (rte_errno = 0))\n+\n+/* Array of devices */\n+static struct rte_hcdev *hcdevs;\n+/* Number of currently valid devices */\n+static int16_t hcdev_max;\n+/* Number of currently valid devices */\n+static int16_t hcdev_count;\n+\n+int\n+rte_hcdev_init(size_t dev_max)\n+{\n+\tif (dev_max == 0 || dev_max > INT16_MAX) {\n+\t\tHCDEV_LOG(ERR, \"invalid array size\");\n+\t\trte_errno = EINVAL;\n+\t\treturn -rte_errno;\n+\t}\n+\n+\t/* No lock, it must be called before or during first probing. */\n+\tif (hcdevs != NULL) {\n+\t\tHCDEV_LOG(ERR, \"already initialized\");\n+\t\trte_errno = EBUSY;\n+\t\treturn -rte_errno;\n+\t}\n+\n+\thcdevs = calloc(dev_max, sizeof(struct rte_hcdev));\n+\tif (hcdevs == NULL) {\n+\t\tHCDEV_LOG(ERR, \"cannot initialize library\");\n+\t\trte_errno = ENOMEM;\n+\t\treturn -rte_errno;\n+\t}\n+\n+\thcdev_max = dev_max;\n+\treturn 0;\n+}\n+\n+uint16_t\n+rte_hcdev_count_avail(void)\n+{\n+\treturn hcdev_count;\n+}\n+\n+bool\n+rte_hcdev_is_valid(int16_t dev_id)\n+{\n+\tif (dev_id >= 0 && dev_id < hcdev_max &&\n+\t\thcdevs[dev_id].state == RTE_HCDEV_STATE_INITIALIZED)\n+\t\treturn true;\n+\treturn false;\n+}\n+\n+int16_t\n+rte_hcdev_find_next(int16_t dev_id)\n+{\n+\tif (dev_id < 0)\n+\t\tdev_id = 0;\n+\twhile (dev_id < hcdev_max &&\n+\t\t\thcdevs[dev_id].state == RTE_HCDEV_STATE_UNUSED)\n+\t\tdev_id++;\n+\n+\tif (dev_id >= hcdev_max)\n+\t\treturn RTE_HCDEV_ID_NONE;\n+\treturn dev_id;\n+}\n+\n+static int16_t\n+hcdev_find_free_id(void)\n+{\n+\tint16_t dev_id;\n+\n+\tfor (dev_id = 0; dev_id < hcdev_max; dev_id++) {\n+\t\tif (hcdevs[dev_id].state == RTE_HCDEV_STATE_UNUSED)\n+\t\t\treturn dev_id;\n+\t}\n+\treturn RTE_HCDEV_ID_NONE;\n+}\n+\n+static struct rte_hcdev *\n+hcdev_get_by_id(int16_t dev_id)\n+{\n+\tif (!rte_hcdev_is_valid(dev_id))\n+\t\treturn NULL;\n+\treturn &hcdevs[dev_id];\n+}\n+\n+struct rte_hcdev *\n+rte_hcdev_get_by_name(const char *name)\n+{\n+\tint16_t dev_id;\n+\tstruct rte_hcdev *dev;\n+\n+\tif (name == NULL) {\n+\t\trte_errno = EINVAL;\n+\t\treturn NULL;\n+\t}\n+\n+\tRTE_HCDEV_FOREACH(dev_id) {\n+\t\tdev = &hcdevs[dev_id];\n+\t\tif (strncmp(name, dev->name, RTE_DEV_NAME_MAX_LEN) == 0)\n+\t\t\treturn dev;\n+\t}\n+\treturn NULL;\n+}\n+\n+struct rte_hcdev *\n+rte_hcdev_allocate(const char *name)\n+{\n+\tint16_t dev_id;\n+\tstruct rte_hcdev *dev;\n+\n+\tif (rte_eal_process_type() != RTE_PROC_PRIMARY) {\n+\t\tHCDEV_LOG(ERR, \"only primary process can allocate device\");\n+\t\trte_errno = EPERM;\n+\t\treturn NULL;\n+\t}\n+\tif (name == NULL) {\n+\t\tHCDEV_LOG(ERR, \"allocate device without a name\");\n+\t\trte_errno = EINVAL;\n+\t\treturn NULL;\n+\t}\n+\n+\t/* implicit initialization of library before adding first device */\n+\tif (hcdevs == NULL && rte_hcdev_init(RTE_HCDEV_DEFAULT_MAX) < 0)\n+\t\treturn NULL;\n+\n+\tif (rte_hcdev_get_by_name(name) != NULL) {\n+\t\tHCDEV_LOG(ERR, \"device with name %s already exists\", name);\n+\t\trte_errno = EEXIST;\n+\t\treturn NULL;\n+\t}\n+\tdev_id = hcdev_find_free_id();\n+\tif (dev_id == RTE_HCDEV_ID_NONE) {\n+\t\tHCDEV_LOG(ERR, \"reached maximum number of devices\");\n+\t\trte_errno = ENOENT;\n+\t\treturn NULL;\n+\t}\n+\n+\tdev = &hcdevs[dev_id];\n+\tmemset(dev, 0, sizeof(*dev));\n+\n+\tif (rte_strscpy(dev->name, name, RTE_DEV_NAME_MAX_LEN) < 0) {\n+\t\tHCDEV_LOG(ERR, \"device name too long: %s\", name);\n+\t\trte_errno = ENAMETOOLONG;\n+\t\treturn NULL;\n+\t}\n+\tdev->info.name = dev->name;\n+\tdev->info.dev_id = dev_id;\n+\tdev->info.numa_node = -1;\n+\n+\thcdev_count++;\n+\tHCDEV_LOG(DEBUG, \"new device %s (id %d) of total %d\",\n+\t\t\tname, dev_id, hcdev_count);\n+\treturn dev;\n+}\n+\n+void\n+rte_hcdev_complete_new(struct rte_hcdev *dev)\n+{\n+\tif (dev == NULL)\n+\t\treturn;\n+\n+\tdev->state = RTE_HCDEV_STATE_INITIALIZED;\n+}\n+\n+int\n+rte_hcdev_release(struct rte_hcdev *dev)\n+{\n+\tif (dev == NULL) {\n+\t\trte_errno = ENODEV;\n+\t\treturn -rte_errno;\n+\t}\n+\n+\tHCDEV_LOG(DEBUG, \"free device %s (id %d)\",\n+\t\t\tdev->info.name, dev->info.dev_id);\n+\tdev->state = RTE_HCDEV_STATE_UNUSED;\n+\thcdev_count--;\n+\n+\treturn 0;\n+}\n+\n+int\n+rte_hcdev_close(int16_t dev_id)\n+{\n+\tint firsterr, binerr;\n+\tint *lasterr = &firsterr;\n+\tstruct rte_hcdev *dev;\n+\n+\tdev = hcdev_get_by_id(dev_id);\n+\tif (dev == NULL) {\n+\t\tHCDEV_LOG(ERR, \"close invalid device ID %d\", dev_id);\n+\t\trte_errno = ENODEV;\n+\t\treturn -rte_errno;\n+\t}\n+\n+\tif (dev->ops.dev_close != NULL) {\n+\t\t*lasterr = HCDEV_DRV_RET(dev->ops.dev_close(dev));\n+\t\tif (*lasterr != 0)\n+\t\t\tlasterr = &binerr;\n+\t}\n+\n+\t*lasterr = rte_hcdev_release(dev);\n+\n+\trte_errno = -firsterr;\n+\treturn firsterr;\n+}\n+\n+int\n+rte_hcdev_info_get(int16_t dev_id, struct rte_hcdev_info *info)\n+{\n+\tstruct rte_hcdev *dev;\n+\n+\tdev = hcdev_get_by_id(dev_id);\n+\tif (dev == NULL) {\n+\t\tHCDEV_LOG(ERR, \"query invalid device ID %d\", dev_id);\n+\t\trte_errno = ENODEV;\n+\t\treturn -rte_errno;\n+\t}\n+\tif (info == NULL) {\n+\t\tHCDEV_LOG(ERR, \"query without storage\");\n+\t\trte_errno = EINVAL;\n+\t\treturn -rte_errno;\n+\t}\n+\n+\tif (dev->ops.dev_info_get == NULL) {\n+\t\t*info = dev->info;\n+\t\treturn 0;\n+\t}\n+\treturn HCDEV_DRV_RET(dev->ops.dev_info_get(dev, info));\n+}\ndiff --git a/lib/hcdev/hcdev_driver.h b/lib/hcdev/hcdev_driver.h\nnew file mode 100644\nindex 0000000000..ca23cb9b9f\n--- /dev/null\n+++ b/lib/hcdev/hcdev_driver.h\n@@ -0,0 +1,67 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright (c) 2021 NVIDIA Corporation & Affiliates\n+ */\n+\n+/*\n+ * This header file must be included only by drivers.\n+ * It is considered internal, i.e. hidden for the application.\n+ * The prefix rte_ is used to avoid namespace clash in drivers.\n+ */\n+\n+#ifndef RTE_HCDEV_DRIVER_H\n+#define RTE_HCDEV_DRIVER_H\n+\n+#include <stdint.h>\n+\n+#include <rte_dev.h>\n+\n+#include \"rte_hcdev.h\"\n+\n+/* Flags indicate current state of device. */\n+enum rte_hcdev_state {\n+\tRTE_HCDEV_STATE_UNUSED,        /* not initialized */\n+\tRTE_HCDEV_STATE_INITIALIZED,   /* initialized */\n+};\n+\n+struct rte_hcdev;\n+typedef int (rte_hcdev_close_t)(struct rte_hcdev *dev);\n+typedef int (rte_hcdev_info_get_t)(struct rte_hcdev *dev, struct rte_hcdev_info *info);\n+\n+struct rte_hcdev_ops {\n+\t/* Get device info. If NULL, info is just copied. */\n+\trte_hcdev_info_get_t *dev_info_get;\n+\t/* Close device. */\n+\trte_hcdev_close_t *dev_close;\n+};\n+\n+struct rte_hcdev {\n+\t/* Backing device. */\n+\tstruct rte_device *device;\n+\t/* Unique identifier name. */\n+\tchar name[RTE_DEV_NAME_MAX_LEN]; /* Updated by this library. */\n+\t/* Device info structure. */\n+\tstruct rte_hcdev_info info;\n+\t/* Driver functions. */\n+\tstruct rte_hcdev_ops ops;\n+\t/* Current state (used or not) in the running process. */\n+\tenum rte_hcdev_state state; /* Updated by this library. */\n+\t/* Driver-specific private data for the running process. */\n+\tvoid *process_private;\n+} __rte_cache_aligned;\n+\n+__rte_internal\n+struct rte_hcdev *rte_hcdev_get_by_name(const char *name);\n+\n+/* First step of initialization */\n+__rte_internal\n+struct rte_hcdev *rte_hcdev_allocate(const char *name);\n+\n+/* Last step of initialization. */\n+__rte_internal\n+void rte_hcdev_complete_new(struct rte_hcdev *dev);\n+\n+/* Last step of removal. */\n+__rte_internal\n+int rte_hcdev_release(struct rte_hcdev *dev);\n+\n+#endif /* RTE_HCDEV_DRIVER_H */\ndiff --git a/lib/hcdev/meson.build b/lib/hcdev/meson.build\nnew file mode 100644\nindex 0000000000..565c3cb623\n--- /dev/null\n+++ b/lib/hcdev/meson.build\n@@ -0,0 +1,10 @@\n+# SPDX-License-Identifier: BSD-3-Clause\n+# Copyright (c) 2021 NVIDIA Corporation & Affiliates\n+\n+headers = files(\n+        'rte_hcdev.h',\n+)\n+\n+sources = files(\n+        'hcdev.c',\n+)\ndiff --git a/lib/hcdev/rte_hcdev.h b/lib/hcdev/rte_hcdev.h\nnew file mode 100644\nindex 0000000000..83f58193c1\n--- /dev/null\n+++ b/lib/hcdev/rte_hcdev.h\n@@ -0,0 +1,169 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright (c) 2021 NVIDIA Corporation & Affiliates\n+ */\n+\n+#ifndef RTE_HCDEV_H\n+#define RTE_HCDEV_H\n+\n+#include <stddef.h>\n+#include <stdint.h>\n+#include <stdbool.h>\n+\n+#include <rte_compat.h>\n+\n+/**\n+ * @file\n+ * Generic library to interact with heterogeneous computing device.\n+ *\n+ * The API is not thread-safe.\n+ * Device management must be done by a single thread.\n+ *\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change without prior notice.\n+ */\n+\n+#ifdef __cplusplus\n+extern \"C\" {\n+#endif\n+\n+/** Maximum number of devices if rte_hcdev_init() is not called. */\n+#define RTE_HCDEV_DEFAULT_MAX 32\n+\n+/** Empty device ID. */\n+#define RTE_HCDEV_ID_NONE -1\n+\n+/** Store device info. */\n+struct rte_hcdev_info {\n+\t/** Unique identifier name. */\n+\tconst char *name;\n+\t/** Device ID. */\n+\tint16_t dev_id;\n+\t/** Total processors available on device. */\n+\tuint32_t processor_count;\n+\t/** Total memory available on device. */\n+\tsize_t total_memory;\n+\t/* Local NUMA memory ID. -1 if unknown. */\n+\tint16_t numa_node;\n+};\n+\n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change without prior notice.\n+ *\n+ * Initialize the device array before probing devices.\n+ * If not called, the maximum of probed devices is RTE_HCDEV_DEFAULT_MAX.\n+ *\n+ * @param dev_max\n+ *   Maximum number of devices.\n+ *\n+ * @return\n+ *   0 on success, -rte_errno otherwise:\n+ *   - ENOMEM if out of memory\n+ *   - EINVAL if 0 size\n+ *   - EBUSY if already initialized\n+ */\n+__rte_experimental\n+int rte_hcdev_init(size_t dev_max);\n+\n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change without prior notice.\n+ *\n+ * Return the number of heterogeneous computing devices detected\n+ * and associated to DPDK.\n+ *\n+ * @return\n+ *   The number of available computing devices.\n+ */\n+__rte_experimental\n+uint16_t rte_hcdev_count_avail(void);\n+\n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change without prior notice.\n+ *\n+ * Check if the device is valid and initialized in DPDK.\n+ *\n+ * @param dev_id\n+ *   The input device ID.\n+ *\n+ * @return\n+ *   - True if dev_id is a valid and initialized computing device.\n+ *   - False otherwise.\n+ */\n+__rte_experimental\n+bool rte_hcdev_is_valid(int16_t dev_id);\n+\n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change without prior notice.\n+ *\n+ * Get the ID of the next valid computing device initialized in DPDK.\n+ *\n+ * @param dev_id\n+ *   The initial device ID to start the research.\n+ *\n+ * @return\n+ *   Next device ID corresponding to a valid and initialized computing device,\n+ *   RTE_HCDEV_ID_NONE if there is none.\n+ */\n+__rte_experimental\n+int16_t rte_hcdev_find_next(int16_t dev_id);\n+\n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change without prior notice.\n+ *\n+ * Macro to iterate over all valid computing devices.\n+ *\n+ * @param dev_id\n+ *   The ID of the next possible valid device, usually 0 to iterate all.\n+ */\n+#define RTE_HCDEV_FOREACH(dev_id) \\\n+\tfor (dev_id = rte_hcdev_find_next(0); \\\n+\t     dev_id > 0; \\\n+\t     dev_id = rte_hcdev_find_next(dev_id + 1))\n+\n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change without prior notice.\n+ *\n+ * Close device.\n+ * All resources are released.\n+ *\n+ * @param dev_id\n+ *   Device ID to close.\n+ *\n+ * @return\n+ *   0 on success, -rte_errno otherwise:\n+ *   - ENODEV if invalid dev_id\n+ *   - EPERM if driver error\n+ */\n+__rte_experimental\n+int rte_hcdev_close(int16_t dev_id);\n+\n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change without prior notice.\n+ *\n+ * Return device specific info.\n+ *\n+ * @param dev_id\n+ *   Device ID to get info.\n+ * @param info\n+ *   Memory structure to fill with the info.\n+ *\n+ * @return\n+ *   0 on success, -rte_errno otherwise:\n+ *   - ENODEV if invalid dev_id\n+ *   - EINVAL if NULL info\n+ *   - EPERM if driver error\n+ */\n+__rte_experimental\n+int rte_hcdev_info_get(int16_t dev_id, struct rte_hcdev_info *info);\n+\n+#ifdef __cplusplus\n+}\n+#endif\n+\n+#endif /* RTE_HCDEV_H */\ndiff --git a/lib/hcdev/version.map b/lib/hcdev/version.map\nnew file mode 100644\nindex 0000000000..bc6dae6de7\n--- /dev/null\n+++ b/lib/hcdev/version.map\n@@ -0,0 +1,20 @@\n+EXPERIMENTAL {\n+\tglobal:\n+\n+\t# added in 21.11\n+\trte_hcdev_close;\n+\trte_hcdev_count_avail;\n+\trte_hcdev_find_next;\n+\trte_hcdev_info_get;\n+\trte_hcdev_init;\n+\trte_hcdev_is_valid;\n+};\n+\n+INTERNAL {\n+\tglobal:\n+\n+\trte_hcdev_allocate;\n+\trte_hcdev_complete_new;\n+\trte_hcdev_get_by_name;\n+\trte_hcdev_release;\n+};\ndiff --git a/lib/meson.build b/lib/meson.build\nindex 1673ca4323..3239182c03 100644\n--- a/lib/meson.build\n+++ b/lib/meson.build\n@@ -35,6 +35,7 @@ libraries = [\n         'eventdev',\n         'gro',\n         'gso',\n+        'hcdev',\n         'ip_frag',\n         'jobstats',\n         'kni',\n",
    "prefixes": [
        "RFC",
        "v2",
        "1/7"
    ]
}