get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 27024,
    "url": "http://patches.dpdk.org/api/patches/27024/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/bd1da84b6f6f97fab1178906eb49724f66881693.1500381641.git.gaetan.rivet@6wind.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": "<bd1da84b6f6f97fab1178906eb49724f66881693.1500381641.git.gaetan.rivet@6wind.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/bd1da84b6f6f97fab1178906eb49724f66881693.1500381641.git.gaetan.rivet@6wind.com",
    "date": "2017-07-18T12:48:16",
    "name": "[dpdk-dev,v11,05/11] net/failsafe: add flexible device definition",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "2cc8db5c55619f3b668d1028364f72a46817f02c",
    "submitter": {
        "id": 269,
        "url": "http://patches.dpdk.org/api/people/269/?format=api",
        "name": "Gaëtan Rivet",
        "email": "gaetan.rivet@6wind.com"
    },
    "delegate": {
        "id": 319,
        "url": "http://patches.dpdk.org/api/users/319/?format=api",
        "username": "fyigit",
        "first_name": "Ferruh",
        "last_name": "Yigit",
        "email": "ferruh.yigit@amd.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/bd1da84b6f6f97fab1178906eb49724f66881693.1500381641.git.gaetan.rivet@6wind.com/mbox/",
    "series": [],
    "comments": "http://patches.dpdk.org/api/patches/27024/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/27024/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 [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id 2203F7CB4;\n\tTue, 18 Jul 2017 14:48:56 +0200 (CEST)",
            "from mail-wr0-f178.google.com (mail-wr0-f178.google.com\n\t[209.85.128.178]) by dpdk.org (Postfix) with ESMTP id 984A258F6\n\tfor <dev@dpdk.org>; Tue, 18 Jul 2017 14:48:44 +0200 (CEST)",
            "by mail-wr0-f178.google.com with SMTP id y43so27864313wrd.3\n\tfor <dev@dpdk.org>; Tue, 18 Jul 2017 05:48:44 -0700 (PDT)",
            "from bidouze.dev.6wind.com (host.78.145.23.62.rev.coltfrance.com.\n\t[62.23.145.78]) by smtp.gmail.com with ESMTPSA id\n\tj8sm1033960wrj.10.2017.07.18.05.48.42\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);\n\tTue, 18 Jul 2017 05:48:43 -0700 (PDT)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=6wind-com.20150623.gappssmtp.com; s=20150623;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:in-reply-to:references;\n\tbh=fH9HD3QsGjVMAapAToHyc8VnmFDaB80FJSiNWnWpsK0=;\n\tb=zpGLZYGfyLXGUmGg4tvzyMtJ7PMQwZluADqVf/6u2ptKgHUjohtY8m/hyuaYh/j3uL\n\tjJcQyB6MWTyQwtURt7prfE+FklVAHaBcRU5OVpvX4mrA80+0TzyNGpZcchYg3q2gHuvL\n\t72aXGIK63aIZBBfBfL2HPW/LMqZGAkhEOuIndSK4iBEAk09dryrF0IVo76OnD3y9+oGT\n\tO8eTMAmP0rgRmpV4c5mCD8vJz4DqCeD2w8aZDe089ko2Ifj0qHrjeAKhjPqTN07aYubm\n\tSvuwHRROEgOZTSTa8WTTdWG43JcK98T1N98QZl4476Vb61iHDrPdHN4qJ2++LvoYBw/m\n\tM1Rg==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:in-reply-to:references;\n\tbh=fH9HD3QsGjVMAapAToHyc8VnmFDaB80FJSiNWnWpsK0=;\n\tb=Ur9n4yQEyzb1L4LJ+5v595pTjgG8s7GCqRzU1ZdTcXr4TQBUNsaR3Sm4OgxIPsYGsp\n\t5Scx13j7f0ErDUcXIB+OCihku7Lwf0U+uAQ8Sq3Vs/CeMzNgLqWfiNTrLl7Os6KjsUHr\n\tF8iX58c54LINAr725DXH5F3z0uK8yIvSXgyDQDhoE35kp/z7zLlNjtLBfWpjysPcfCxz\n\tEny+m3N2v0haakdrCPs3Pys82cMLRvELDjZn3oKHqOPSU+paBiEo50bKpoxcCW2Ued5Z\n\tTz+4dsmBgMchWGKpjNtlkh7Lk2NIJHcxZG3TdkczPwzZbIpgrb97v3TkbtoNs5/Q/hyi\n\ti10w==",
        "X-Gm-Message-State": "AIVw11180VbUnmpsrlIXin6iJLtCN8mS8JitSZyxgO4tv7EyEeXGH4BR\n\t3W15AJXPD0+HdMztrz4=",
        "X-Received": "by 10.28.174.204 with SMTP id x195mr1383300wme.116.1500382123731;\n\tTue, 18 Jul 2017 05:48:43 -0700 (PDT)",
        "From": "Gaetan Rivet <gaetan.rivet@6wind.com>",
        "To": "dev@dpdk.org",
        "Cc": "Gaetan Rivet <gaetan.rivet@6wind.com>",
        "Date": "Tue, 18 Jul 2017 14:48:16 +0200",
        "Message-Id": "<bd1da84b6f6f97fab1178906eb49724f66881693.1500381641.git.gaetan.rivet@6wind.com>",
        "X-Mailer": "git-send-email 2.1.4",
        "In-Reply-To": [
            "<cover.1500381641.git.gaetan.rivet@6wind.com>",
            "<cover.1500381641.git.gaetan.rivet@6wind.com>"
        ],
        "References": [
            "<cover.1500130634.git.gaetan.rivet@6wind.com>\n\t<cover.1500381641.git.gaetan.rivet@6wind.com>",
            "<cover.1500381641.git.gaetan.rivet@6wind.com>"
        ],
        "Subject": "[dpdk-dev] [PATCH v11 05/11] net/failsafe: add flexible device\n\tdefinition",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://dpdk.org/ml/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "Add the \"exec\" device type.\nThe parameters given to this type of device will be executed in a shell.\nThe output of this command is then used as a definition for a device.\n\nThat command can be re-interpreted if the related device is not\nplugged-in. It allows for a device definition to react to system\nchanges (e.g. changing PCI bus for a given device).\n\nSigned-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>\nAcked-by: Olga Shern <olgas@mellanox.com>\n---\n doc/guides/nics/fail_safe.rst           | 20 +++++++\n drivers/net/failsafe/failsafe_args.c    | 98 ++++++++++++++++++++++++++++++++-\n drivers/net/failsafe/failsafe_ether.c   |  7 +++\n drivers/net/failsafe/failsafe_private.h |  4 ++\n 4 files changed, 128 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/doc/guides/nics/fail_safe.rst b/doc/guides/nics/fail_safe.rst\nindex 0005892..c81f06a 100644\n--- a/doc/guides/nics/fail_safe.rst\n+++ b/doc/guides/nics/fail_safe.rst\n@@ -87,6 +87,19 @@ Fail-safe command line parameters\n   additional sub-device parameters if need be. They will be passed on to the\n   sub-device.\n \n+- **exec(<shell command>)** parameter\n+\n+  This parameter allows the user to provide a command to the fail-safe PMD to\n+  execute and define a sub-device.\n+  It is done within a regular shell context.\n+  The first line of its output is read by the fail-safe PMD and otherwise\n+  interpreted as if passed by the regular **dev** parameter.\n+  Any other line is discarded.\n+  If the command fail or output an incorrect string, the sub-device is not\n+  initialized.\n+  All commas within the ``shell command`` are replaced by spaces before\n+  executing the command. This helps using scripts to specify devices.\n+\n - **mac** parameter [MAC address]\n \n   This parameter allows the user to set a default MAC address to the fail-safe\n@@ -134,6 +147,13 @@ This section shows some example of using **testpmd** with a fail-safe PMD.\n          --vdev 'net_failsafe0,mac=de:ad:be:ef:01:02,dev(84:00.0),dev(net_ring0)'\n          -w 81:00.0 -- -i\n \n+#. Start testpmd using a flexible device definition\n+\n+   .. code-block:: console\n+\n+      $RTE_TARGET/build/app/testpmd -c 0xff -n 4 --no-pci \\\n+         --vdev='net_failsafe0,exec(echo 84:00.0)' -- -i\n+\n Using the Fail-safe PMD from an application\n -------------------------------------------\n \ndiff --git a/drivers/net/failsafe/failsafe_args.c b/drivers/net/failsafe/failsafe_args.c\nindex 733344e..ec3db55 100644\n--- a/drivers/net/failsafe/failsafe_args.c\n+++ b/drivers/net/failsafe/failsafe_args.c\n@@ -34,6 +34,7 @@\n #include <string.h>\n #include <errno.h>\n \n+#include <rte_debug.h>\n #include <rte_devargs.h>\n #include <rte_malloc.h>\n #include <rte_kvargs.h>\n@@ -97,6 +98,72 @@ fs_parse_device(struct sub_device *sdev, char *args)\n \treturn 0;\n }\n \n+static void\n+fs_sanitize_cmdline(char *args)\n+{\n+\tsize_t len;\n+\n+\tlen = strnlen(args, DEVARGS_MAXLEN);\n+\targs[len - 1] = '\\0';\n+}\n+\n+static int\n+fs_execute_cmd(struct sub_device *sdev, char *cmdline)\n+{\n+\tFILE *fp;\n+\t/* store possible newline as well */\n+\tchar output[DEVARGS_MAXLEN + 1];\n+\tsize_t len;\n+\tint old_err;\n+\tint ret;\n+\n+\tRTE_ASSERT(cmdline != NULL || sdev->cmdline != NULL);\n+\tif (sdev->cmdline == NULL) {\n+\t\tsize_t i;\n+\n+\t\tlen = strlen(cmdline) + 1;\n+\t\tsdev->cmdline = calloc(1, len);\n+\t\tif (sdev->cmdline == NULL) {\n+\t\t\tERROR(\"Command line allocation failed\");\n+\t\t\treturn -ENOMEM;\n+\t\t}\n+\t\tsnprintf(sdev->cmdline, len, \"%s\", cmdline);\n+\t\t/* Replace all commas in the command line by spaces */\n+\t\tfor (i = 0; i < len; i++)\n+\t\t\tif (sdev->cmdline[i] == ',')\n+\t\t\t\tsdev->cmdline[i] = ' ';\n+\t}\n+\tDEBUG(\"'%s'\", sdev->cmdline);\n+\told_err = errno;\n+\tfp = popen(sdev->cmdline, \"r\");\n+\tif (fp == NULL) {\n+\t\tret = errno;\n+\t\tERROR(\"popen: %s\", strerror(errno));\n+\t\terrno = old_err;\n+\t\treturn ret;\n+\t}\n+\t/* We only read one line */\n+\tif (fgets(output, sizeof(output) - 1, fp) == NULL) {\n+\t\tDEBUG(\"Could not read command output\");\n+\t\treturn -ENODEV;\n+\t}\n+\tfs_sanitize_cmdline(output);\n+\tret = fs_parse_device(sdev, output);\n+\tif (ret) {\n+\t\tERROR(\"Parsing device '%s' failed\", output);\n+\t\tgoto ret_pclose;\n+\t}\n+ret_pclose:\n+\tret = pclose(fp);\n+\tif (ret) {\n+\t\tret = errno;\n+\t\tERROR(\"pclose: %s\", strerror(errno));\n+\t\terrno = old_err;\n+\t\treturn ret;\n+\t}\n+\treturn ret;\n+}\n+\n static int\n fs_parse_device_param(struct rte_eth_dev *dev, const char *param,\n \t\tuint8_t head)\n@@ -131,6 +198,14 @@ fs_parse_device_param(struct rte_eth_dev *dev, const char *param,\n \t\tret = fs_parse_device(sdev, args);\n \t\tif (ret)\n \t\t\tgoto free_args;\n+\t} else if (strncmp(param, \"exec\", 4) == 0) {\n+\t\tret = fs_execute_cmd(sdev, args);\n+\t\tif (ret == -ENODEV) {\n+\t\t\tDEBUG(\"Reading device info from command line failed\");\n+\t\t\tret = 0;\n+\t\t}\n+\t\tif (ret)\n+\t\t\tgoto free_args;\n \t} else {\n \t\tERROR(\"Unrecognized device type: %.*s\", (int)b, param);\n \t\treturn -EINVAL;\n@@ -328,6 +403,8 @@ failsafe_args_free(struct rte_eth_dev *dev)\n \tuint8_t i;\n \n \tFOREACH_SUBDEV(sdev, i, dev) {\n+\t\trte_free(sdev->cmdline);\n+\t\tsdev->cmdline = NULL;\n \t\tfree(sdev->devargs.args);\n \t\tsdev->devargs.args = NULL;\n \t}\n@@ -342,7 +419,8 @@ fs_count_device(struct rte_eth_dev *dev, const char *param,\n \twhile  (param[b] != '(' &&\n \t\tparam[b] != '\\0')\n \t\tb++;\n-\tif (strncmp(param, \"dev\", b) != 0) {\n+\tif (strncmp(param, \"dev\", b) != 0 &&\n+\t    strncmp(param, \"exec\", b) != 0) {\n \t\tERROR(\"Unrecognized device type: %.*s\", (int)b, param);\n \t\treturn -EINVAL;\n \t}\n@@ -357,3 +435,21 @@ failsafe_args_count_subdevice(struct rte_eth_dev *dev,\n \treturn fs_parse_sub_devices(fs_count_device,\n \t\t\t\t    dev, params);\n }\n+\n+int\n+failsafe_args_parse_subs(struct rte_eth_dev *dev)\n+{\n+\tstruct sub_device *sdev;\n+\tuint8_t i;\n+\tint ret = 0;\n+\n+\tFOREACH_SUBDEV(sdev, i, dev) {\n+\t\tif (sdev->state >= DEV_PARSED)\n+\t\t\tcontinue;\n+\t\tif (sdev->cmdline)\n+\t\t\tret = fs_execute_cmd(sdev, sdev->cmdline);\n+\t\tif (ret == 0)\n+\t\t\tsdev->state = DEV_PARSED;\n+\t}\n+\treturn 0;\n+}\ndiff --git a/drivers/net/failsafe/failsafe_ether.c b/drivers/net/failsafe/failsafe_ether.c\nindex 7910952..2a1535e 100644\n--- a/drivers/net/failsafe/failsafe_ether.c\n+++ b/drivers/net/failsafe/failsafe_ether.c\n@@ -188,6 +188,13 @@ failsafe_eth_dev_state_sync(struct rte_eth_dev *dev)\n \tint ret;\n \tuint8_t i;\n \n+\tif (PRIV(dev)->state < DEV_PARSED)\n+\t\treturn 0;\n+\n+\tret = failsafe_args_parse_subs(dev);\n+\tif (ret)\n+\t\treturn ret;\n+\n \tif (PRIV(dev)->state < DEV_PROBED)\n \t\treturn 0;\n \tret = failsafe_eal_init(dev);\ndiff --git a/drivers/net/failsafe/failsafe_private.h b/drivers/net/failsafe/failsafe_private.h\nindex a46d1ea..2342646 100644\n--- a/drivers/net/failsafe/failsafe_private.h\n+++ b/drivers/net/failsafe/failsafe_private.h\n@@ -44,6 +44,7 @@\n #define PMD_FAILSAFE_HOTPLUG_POLL_KVARG \"hotplug_poll\"\n #define PMD_FAILSAFE_PARAM_STRING\t\\\n \t\"dev(<ifc>),\"\t\t\t\\\n+\t\"exec(<shell command>),\"\t\\\n \t\"mac=mac_addr,\"\t\t\t\\\n \t\"hotplug_poll=u64\"\t\t\\\n \t\"\"\n@@ -87,6 +88,8 @@ struct sub_device {\n \tstruct rte_eth_dev *edev;\n \t/* Device state machine */\n \tenum dev_state state;\n+\t/* Some device are defined as a command line */\n+\tchar *cmdline;\n };\n \n struct fs_priv {\n@@ -135,6 +138,7 @@ uint16_t failsafe_tx_burst(void *txq,\n int failsafe_args_parse(struct rte_eth_dev *dev, const char *params);\n void failsafe_args_free(struct rte_eth_dev *dev);\n int failsafe_args_count_subdevice(struct rte_eth_dev *dev, const char *params);\n+int failsafe_args_parse_subs(struct rte_eth_dev *dev);\n \n /* EAL */\n \n",
    "prefixes": [
        "dpdk-dev",
        "v11",
        "05/11"
    ]
}