get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 45792,
    "url": "http://patches.dpdk.org/api/patches/45792/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20181001205228.3503-5-thomas@monjalon.net/",
    "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": "<20181001205228.3503-5-thomas@monjalon.net>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20181001205228.3503-5-thomas@monjalon.net",
    "date": "2018-10-01T20:52:28",
    "name": "[v4,4/4] eal: simplify parameters of hotplug functions",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "d8f6f47a31b5a3b791bd1f5ad81056b09d4f22f3",
    "submitter": {
        "id": 685,
        "url": "http://patches.dpdk.org/api/people/685/?format=api",
        "name": "Thomas Monjalon",
        "email": "thomas@monjalon.net"
    },
    "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/20181001205228.3503-5-thomas@monjalon.net/mbox/",
    "series": [
        {
            "id": 1621,
            "url": "http://patches.dpdk.org/api/series/1621/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=1621",
            "date": "2018-10-01T20:52:24",
            "name": "eal: simplify devargs and hotplug functions",
            "version": 4,
            "mbox": "http://patches.dpdk.org/series/1621/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/45792/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/45792/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 02A0D5F38;\n\tMon,  1 Oct 2018 22:52:42 +0200 (CEST)",
            "from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com\n\t[66.111.4.27]) by dpdk.org (Postfix) with ESMTP id 0AF825B34\n\tfor <dev@dpdk.org>; Mon,  1 Oct 2018 22:52:36 +0200 (CEST)",
            "from compute1.internal (compute1.nyi.internal [10.202.2.41])\n\tby mailout.nyi.internal (Postfix) with ESMTP id AACC62202E;\n\tMon,  1 Oct 2018 16:52:35 -0400 (EDT)",
            "from mailfrontend1 ([10.202.2.162])\n\tby compute1.internal (MEProxy); Mon, 01 Oct 2018 16:52:35 -0400",
            "from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184])\n\tby mail.messagingengine.com (Postfix) with ESMTPA id ACBC0E474F;\n\tMon,  1 Oct 2018 16:52:34 -0400 (EDT)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h=\n\tcc:content-transfer-encoding:date:from:in-reply-to:message-id\n\t:mime-version:references:subject:to:x-me-sender:x-me-sender\n\t:x-sasl-enc; s=mesmtp; bh=2I656p67WrAipZZ+rGsuWslJItPOsRXgL//Bof\n\tcu51I=; b=kUYMya0u+AGMExmcXbbcEIeMVtTisTxOjh3wA3YaQY/YOAVkSqKy4c\n\tfvFXkjK2y4bwmV88+Umvfm6eZD64b8Db7idgJnS7UsKg5f4fZYfiLHQfnj9PFuzP\n\tyDACNTNFU+MsAZ54YqWx1qNdPeGMelvKtAs6hu1VQx2DW1kNvuJpU=",
            "v=1; a=rsa-sha256; c=relaxed/relaxed; d=\n\tmessagingengine.com; h=cc:content-transfer-encoding:date:from\n\t:in-reply-to:message-id:mime-version:references:subject:to\n\t:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=2I656p67WrAipZZ+r\n\tGsuWslJItPOsRXgL//Bofcu51I=; b=g3bkKJ2YkWnnEYXDJpmfkY9M7r+9cRq3B\n\thSC2G2elO9+28QQD0r6RtTtiX9hpolS2ihTecFdwKwwpFIgHiU18P8ULM0FgX5sM\n\tt7PIDzEwFh2zBsYw+YLW5AQceLYScpoSQr1YG09R7Nw39YbAiWXCX30Nr2zYQpuA\n\t68QRML+GTS2hfn3acxhSPTll9u+GlddKSv+ZHzsT51N+il5fBxBDIYw2bzZ8LjsY\n\tcUZsXkfr60TSUM47JyzDH5sRfcXXVLholZ/LOTZZNg1O3wligE5sCiY2JtMkAscK\n\tyoQMYXyLC+ZoZsja/iIUrtGz9yIdCt2Sd9OFgUTvl0oi5+1UBgHHw=="
        ],
        "X-ME-Sender": "<xms:E4myW25lmqHFHDSG-MXGlglEN1cYyGJZQj4aIurEdrVeG8UOp7W_GA>",
        "X-ME-Proxy": "<xmx:E4myW8NYWUdwIzt9V3qjFASlWKrPumiJ4uMmbQAA91aZbEJVLMNtkg>\n\t<xmx:E4myW60HOa-Xj6mBvxBOlkKox0LSqlbL22TfZqhTH8ocyizw_uGfyg>\n\t<xmx:E4myWyoSXaW4xxTHwkZptLCabFvlbwCFZOdYWDkRfgdBaaCEUoAR6w>\n\t<xmx:E4myW8f_-0WoM2-8V58NTNKAoomfjeN-tX2qs0vrk4073n9MP0GDBg>\n\t<xmx:E4myW8vvEnFYC3YUY71qPKzSBh3kDEnxmSlPGPwplmTtKp9WEeZ7sQ>\n\t<xmx:E4myW2ISn-M6aJgQhgtBlV0tCMNO2Jh_xG-MGF2f5cbdfzzZuJfaFA>",
        "From": "Thomas Monjalon <thomas@monjalon.net>",
        "To": "dev@dpdk.org",
        "Cc": "gaetan.rivet@6wind.com, ophirmu@mellanox.com, qi.z.zhang@intel.com,\n\tferruh.yigit@intel.com, ktraynor@redhat.com",
        "Date": "Mon,  1 Oct 2018 22:52:28 +0200",
        "Message-Id": "<20181001205228.3503-5-thomas@monjalon.net>",
        "X-Mailer": "git-send-email 2.19.0",
        "In-Reply-To": "<20181001205228.3503-1-thomas@monjalon.net>",
        "References": "<20180907222727.20521-1-thomas@monjalon.net>\n\t<20181001205228.3503-1-thomas@monjalon.net>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[dpdk-dev] [PATCH v4 4/4] eal: simplify parameters of hotplug\n\tfunctions",
        "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": "All information about a device to probe can be grouped\nin a common string, which is what we usually call devargs.\nAn application should not have to parse this string before\ncalling the EAL probe function.\nAnd the syntax could evolve to be more complex and support\nmatching multiple devices in one string.\nThat's why the bus name and device name should be removed from\nrte_eal_hotplug_add().\nInstead of changing this function, a simpler one is added\nand used in the old one, which may be deprecated later.\n\nWhen removing a device, we already know its rte_device handle\nwhich can be directly passed as parameter of rte_eal_hotplug_remove().\nIf the rte_device is not known, it can be retrieved with the devargs,\nby iterating in the device list (future RTE_DEV_FOREACH()).\nSimilarly to the probing case, a new function is added\nand used in the old one, which may be deprecated later.\nThe new function is used in failsafe, because the replacement is easy.\n\nSigned-off-by: Thomas Monjalon <thomas@monjalon.net>\nReviewed-by: Andrew Rybchenko <arybchenko@solarflare.com>\n---\n drivers/net/failsafe/failsafe_eal.c     |  3 +-\n drivers/net/failsafe/failsafe_ether.c   |  3 +-\n lib/librte_eal/common/eal_common_dev.c  | 80 ++++++++++++++++---------\n lib/librte_eal/common/include/rte_dev.h | 30 +++++++++-\n lib/librte_eal/rte_eal_version.map      |  2 +\n 5 files changed, 84 insertions(+), 34 deletions(-)",
    "diff": "diff --git a/drivers/net/failsafe/failsafe_eal.c b/drivers/net/failsafe/failsafe_eal.c\nindex ce1633f13..8a888b1ff 100644\n--- a/drivers/net/failsafe/failsafe_eal.c\n+++ b/drivers/net/failsafe/failsafe_eal.c\n@@ -144,8 +144,7 @@ fs_bus_uninit(struct rte_eth_dev *dev)\n \tint ret = 0;\n \n \tFOREACH_SUBDEV_STATE(sdev, i, dev, DEV_PROBED) {\n-\t\tsdev_ret = rte_eal_hotplug_remove(sdev->bus->name,\n-\t\t\t\t\t\t\tsdev->dev->name);\n+\t\tsdev_ret = rte_dev_remove(sdev->dev);\n \t\tif (sdev_ret) {\n \t\t\tERROR(\"Failed to remove requested device %s (err: %d)\",\n \t\t\t      sdev->dev->name, sdev_ret);\ndiff --git a/drivers/net/failsafe/failsafe_ether.c b/drivers/net/failsafe/failsafe_ether.c\nindex 51c96f78b..f2512c430 100644\n--- a/drivers/net/failsafe/failsafe_ether.c\n+++ b/drivers/net/failsafe/failsafe_ether.c\n@@ -282,8 +282,7 @@ fs_dev_remove(struct sub_device *sdev)\n \t\tsdev->state = DEV_PROBED;\n \t\t/* fallthrough */\n \tcase DEV_PROBED:\n-\t\tret = rte_eal_hotplug_remove(sdev->bus->name,\n-\t\t\t\t\t     sdev->dev->name);\n+\t\tret = rte_dev_remove(sdev->dev);\n \t\tif (ret) {\n \t\t\tERROR(\"Bus detach failed for sub_device %u\",\n \t\t\t      SUB_ID(sdev));\ndiff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c\nindex a9be58edf..713707b9a 100644\n--- a/lib/librte_eal/common/eal_common_dev.c\n+++ b/lib/librte_eal/common/eal_common_dev.c\n@@ -129,46 +129,61 @@ int rte_eal_dev_detach(struct rte_device *dev)\n \n int\n rte_eal_hotplug_add(const char *busname, const char *devname,\n-\t\t    const char *devargs)\n+\t\t    const char *drvargs)\n {\n-\tstruct rte_bus *bus;\n-\tstruct rte_device *dev;\n-\tstruct rte_devargs *da;\n \tint ret;\n+\tchar *devargs = NULL;\n+\tint size, length = -1;\n \n-\tbus = rte_bus_find_by_name(busname);\n-\tif (bus == NULL) {\n-\t\tRTE_LOG(ERR, EAL, \"Cannot find bus (%s)\\n\", busname);\n-\t\treturn -ENOENT;\n-\t}\n+\tdo { /* 2 iterations: first is to know string length */\n+\t\tsize = length + 1;\n+\t\tlength = snprintf(devargs, size, \"%s:%s,%s\", busname, devname, drvargs);\n+\t\tif (length >= size)\n+\t\t\tdevargs = malloc(length + 1);\n+\t\tif (devargs == NULL)\n+\t\t\treturn -ENOMEM;\n+\t} while (size == 0);\n \n-\tif (bus->plug == NULL) {\n-\t\tRTE_LOG(ERR, EAL, \"Function plug not supported by bus (%s)\\n\",\n-\t\t\tbus->name);\n-\t\treturn -ENOTSUP;\n-\t}\n+\tret = rte_dev_probe(devargs);\n+\n+\tfree(devargs);\n+\treturn ret;\n+}\n+\n+int __rte_experimental\n+rte_dev_probe(const char *devargs)\n+{\n+\tstruct rte_device *dev;\n+\tstruct rte_devargs *da;\n+\tint ret;\n \n \tda = calloc(1, sizeof(*da));\n \tif (da == NULL)\n \t\treturn -ENOMEM;\n \n-\tret = rte_devargs_parsef(da, \"%s:%s,%s\",\n-\t\t\t\t busname, devname, devargs);\n+\tret = rte_devargs_parse(da, devargs);\n \tif (ret)\n \t\tgoto err_devarg;\n \n+\tif (da->bus->plug == NULL) {\n+\t\tRTE_LOG(ERR, EAL, \"Function plug not supported by bus (%s)\\n\",\n+\t\t\tda->bus->name);\n+\t\tret = -ENOTSUP;\n+\t\tgoto err_devarg;\n+\t}\n+\n \tret = rte_devargs_insert(da);\n \tif (ret)\n \t\tgoto err_devarg;\n \n-\tret = bus->scan();\n+\tret = da->bus->scan();\n \tif (ret)\n \t\tgoto err_devarg;\n \n-\tdev = bus->find_device(NULL, cmp_dev_name, devname);\n+\tdev = da->bus->find_device(NULL, cmp_dev_name, da->name);\n \tif (dev == NULL) {\n \t\tRTE_LOG(ERR, EAL, \"Cannot find device (%s)\\n\",\n-\t\t\tdevname);\n+\t\t\tda->name);\n \t\tret = -ENODEV;\n \t\tgoto err_devarg;\n \t}\n@@ -178,7 +193,7 @@ rte_eal_hotplug_add(const char *busname, const char *devname,\n \t\treturn -EEXIST;\n \t}\n \n-\tret = bus->plug(dev);\n+\tret = da->bus->plug(dev);\n \tif (ret) {\n \t\tRTE_LOG(ERR, EAL, \"Driver cannot attach the device (%s)\\n\",\n \t\t\tdev->name);\n@@ -197,9 +212,8 @@ rte_eal_hotplug_add(const char *busname, const char *devname,\n int\n rte_eal_hotplug_remove(const char *busname, const char *devname)\n {\n-\tstruct rte_bus *bus;\n \tstruct rte_device *dev;\n-\tint ret;\n+\tstruct rte_bus *bus;\n \n \tbus = rte_bus_find_by_name(busname);\n \tif (bus == NULL) {\n@@ -207,23 +221,33 @@ rte_eal_hotplug_remove(const char *busname, const char *devname)\n \t\treturn -ENOENT;\n \t}\n \n-\tif (bus->unplug == NULL) {\n-\t\tRTE_LOG(ERR, EAL, \"Function unplug not supported by bus (%s)\\n\",\n-\t\t\tbus->name);\n-\t\treturn -ENOTSUP;\n-\t}\n-\n \tdev = bus->find_device(NULL, cmp_dev_name, devname);\n \tif (dev == NULL) {\n \t\tRTE_LOG(ERR, EAL, \"Cannot find plugged device (%s)\\n\", devname);\n \t\treturn -EINVAL;\n \t}\n \n+\treturn rte_dev_remove(dev);\n+}\n+\n+int __rte_experimental\n+rte_dev_remove(struct rte_device *dev)\n+{\n+\tstruct rte_bus *bus;\n+\tint ret;\n+\n \tif (dev->driver == NULL) {\n \t\tRTE_LOG(ERR, EAL, \"Device is already unplugged\\n\");\n \t\treturn -ENOENT;\n \t}\n \n+\tbus = dev->devargs->bus;\n+\tif (bus->unplug == NULL) {\n+\t\tRTE_LOG(ERR, EAL, \"Function unplug not supported by bus (%s)\\n\",\n+\t\t\tbus->name);\n+\t\treturn -ENOTSUP;\n+\t}\n+\n \tret = bus->unplug(dev);\n \tif (ret)\n \t\tRTE_LOG(ERR, EAL, \"Driver cannot detach the device (%s)\\n\",\ndiff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/common/include/rte_dev.h\nindex d440c4e58..ee77e4006 100644\n--- a/lib/librte_eal/common/include/rte_dev.h\n+++ b/lib/librte_eal/common/include/rte_dev.h\n@@ -196,13 +196,26 @@ int rte_eal_dev_detach(struct rte_device *dev);\n  * @param devname\n  *   The device name. Based on this device name, eal will identify a driver\n  *   capable of handling it and pass it to the driver probing function.\n- * @param devargs\n+ * @param drvargs\n  *   Device arguments to be passed to the driver.\n  * @return\n  *   0 on success, negative on error.\n  */\n int rte_eal_hotplug_add(const char *busname, const char *devname,\n-\t\t\tconst char *devargs);\n+\t\t\tconst char *drvargs);\n+\n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change without prior notice\n+ *\n+ * Add matching devices.\n+ *\n+ * @param devargs\n+ *   Device arguments including bus, class and driver properties.\n+ * @return\n+ *   0 on success, negative on error.\n+ */\n+int __rte_experimental rte_dev_probe(const char *devargs);\n \n /**\n  * Hotplug remove a given device from a specific bus.\n@@ -216,6 +229,19 @@ int rte_eal_hotplug_add(const char *busname, const char *devname,\n  */\n int rte_eal_hotplug_remove(const char *busname, const char *devname);\n \n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change without prior notice\n+ *\n+ * Remove one device.\n+ *\n+ * @param dev\n+ *   Data structure of the device to remove.\n+ * @return\n+ *   0 on success, negative on error.\n+ */\n+int __rte_experimental rte_dev_remove(struct rte_device *dev);\n+\n /**\n  * Device comparison function.\n  *\ndiff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map\nindex 6bff37f4b..2ea7a870a 100644\n--- a/lib/librte_eal/rte_eal_version.map\n+++ b/lib/librte_eal/rte_eal_version.map\n@@ -281,6 +281,8 @@ EXPERIMENTAL {\n \trte_dev_event_monitor_stop;\n \trte_dev_iterator_init;\n \trte_dev_iterator_next;\n+\trte_dev_probe;\n+\trte_dev_remove;\n \trte_devargs_add;\n \trte_devargs_dump;\n \trte_devargs_insert;\n",
    "prefixes": [
        "v4",
        "4/4"
    ]
}