get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 26674,
    "url": "http://patches.dpdk.org/api/patches/26674/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/be976d39ef26011ea0e415e560d88d8111f764b8.1499564333.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": "<be976d39ef26011ea0e415e560d88d8111f764b8.1499564333.git.gaetan.rivet@6wind.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/be976d39ef26011ea0e415e560d88d8111f764b8.1499564333.git.gaetan.rivet@6wind.com",
    "date": "2017-07-09T01:47:26",
    "name": "[dpdk-dev,v7,05/11] net/failsafe: add flexible device definition",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "f6ba02d87287acbb1f9907db4e00ac2b4674bc96",
    "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/be976d39ef26011ea0e415e560d88d8111f764b8.1499564333.git.gaetan.rivet@6wind.com/mbox/",
    "series": [],
    "comments": "http://patches.dpdk.org/api/patches/26674/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/26674/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 1566B7CE1;\n\tSun,  9 Jul 2017 03:48:02 +0200 (CEST)",
            "from mail-wr0-f171.google.com (mail-wr0-f171.google.com\n\t[209.85.128.171]) by dpdk.org (Postfix) with ESMTP id CF3F358EC\n\tfor <dev@dpdk.org>; Sun,  9 Jul 2017 03:47:51 +0200 (CEST)",
            "by mail-wr0-f171.google.com with SMTP id c11so93740681wrc.3\n\tfor <dev@dpdk.org>; Sat, 08 Jul 2017 18:47:51 -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\tl186sm4278642wma.10.2017.07.08.18.47.49\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);\n\tSat, 08 Jul 2017 18:47:50 -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=Sh7IubyovwjdUu0rOLcqWoBSR9XSHo8r0yo0IDZs9w4=;\n\tb=GGHs6hi8rrwbLIuoP9cWe8cpPCggBZztlWBj6uQFiJD45ocHDViI9IyU/eQJnAGfD0\n\twvIbofGEiX97iNJdIatcJqxM+r6RI9fEoUf2uX/YEfKu2GZfPMULFE03uANj0tafKjL/\n\tGUcwHTQAf9m6Nquvi/MFXt4xpYekhiR1SkNu14O40Sv5/fIxrg4uRHLmosb3+vIHWDPr\n\tNNkcQJi82ds1pDlXNrKM72Dmw0eqAtOuQWSJKZUYHwCMNr+eugc4Mf//VR6MoPr3cM6P\n\tBraHhyvkqSglod/ZagDIRorRaVE4GE7AaQG8HueykoNLm8fbP3s0Bgy1BotMQ36tm5ZP\n\tareQ==",
        "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=Sh7IubyovwjdUu0rOLcqWoBSR9XSHo8r0yo0IDZs9w4=;\n\tb=fXQEQBOpiCtLHcJldNX4B43IOToheFQQ2AJ5SBAcoYKxqTUJtBawE3awndJdySi0rY\n\tpBsxWb77cRXxgr5Igoq74/gxHmw0vlRwsncm6GXfgLCnbyx9Qx24g6rZVpykP+lCkYZ3\n\ttthYb6BmSBMd43/uBeG5lhUi3U1Apd9Yktrqb7O493KSStEzg51ulVFi11fWzTdIKSOv\n\tZlJT2gFannZkhRQqUj6GJZ10duvV8XSYbaHv/qh/o7whLeCOji8R7YbyGbtO1OGJNvhU\n\t/rUyP4/J/liP7BxuK/msyOBggk/XQnVANmGoKW+fy6kt5nPTSA1Jm+nOh6xnZirk/05f\n\tuUyg==",
        "X-Gm-Message-State": "AIVw110bjZDWecvOur7n/N/00Fig0q/xL+wFscaHvMl7aS+5kD4MtuEC\n\t1PpxpknZ8p/nCTix/Es=",
        "X-Received": "by 10.28.104.132 with SMTP id d126mr3372573wmc.49.1499564870843; \n\tSat, 08 Jul 2017 18:47:50 -0700 (PDT)",
        "From": "Gaetan Rivet <gaetan.rivet@6wind.com>",
        "To": "dev@dpdk.org",
        "Cc": "Gaetan Rivet <gaetan.rivet@6wind.com>",
        "Date": "Sun,  9 Jul 2017 03:47:26 +0200",
        "Message-Id": "<be976d39ef26011ea0e415e560d88d8111f764b8.1499564333.git.gaetan.rivet@6wind.com>",
        "X-Mailer": "git-send-email 2.1.4",
        "In-Reply-To": [
            "<cover.1499564333.git.gaetan.rivet@6wind.com>",
            "<cover.1499564333.git.gaetan.rivet@6wind.com>"
        ],
        "References": [
            "<cover.1499385281.git.gaetan.rivet@6wind.com>\n\t<cover.1499564333.git.gaetan.rivet@6wind.com>",
            "<cover.1499564333.git.gaetan.rivet@6wind.com>"
        ],
        "Subject": "[dpdk-dev] [PATCH v7 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    | 99 +++++++++++++++++++++++++++++++++\n drivers/net/failsafe/failsafe_ether.c   |  7 +++\n drivers/net/failsafe/failsafe_private.h |  4 ++\n 4 files changed, 130 insertions(+)",
    "diff": "diff --git a/doc/guides/nics/fail_safe.rst b/doc/guides/nics/fail_safe.rst\nindex c04891a..1b6e110 100644\n--- a/doc/guides/nics/fail_safe.rst\n+++ b/doc/guides/nics/fail_safe.rst\n@@ -91,6 +91,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@@ -126,6 +139,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,nodeaction=r1:0:CREATE)' -- \\\n          -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 8f334aa..c723ca3 100644\n--- a/drivers/net/failsafe/failsafe_args.c\n+++ b/drivers/net/failsafe/failsafe_args.c\n@@ -30,6 +30,8 @@\n  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n  */\n+\n+#include <assert.h>\n #include <string.h>\n #include <errno.h>\n \n@@ -96,6 +98,75 @@ 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+\tassert(cmdline != NULL || sdev->cmdline != NULL);\n+\tif (sdev->cmdline == NULL) {\n+\t\tchar *new_str;\n+\t\tsize_t i;\n+\n+\t\tlen = strlen(cmdline) + 1;\n+\t\tnew_str = rte_realloc(sdev->cmdline, len,\n+\t\t\t\tRTE_CACHE_LINE_SIZE);\n+\t\tif (new_str == NULL) {\n+\t\t\tERROR(\"Command line allocation failed\");\n+\t\t\treturn -ENOMEM;\n+\t\t}\n+\t\tsdev->cmdline = new_str;\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@@ -130,6 +201,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@@ -331,6 +410,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@@ -361,3 +442,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 8fb72fe..554d7a3 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_PLUG_IN_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",
        "v7",
        "05/11"
    ]
}