get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 26555,
    "url": "https://patches.dpdk.org/api/patches/26555/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/4695f0b4603308f6e27a0f2518945172989165fd.1499360068.git.adrien.mazarguil@6wind.com/",
    "project": {
        "id": 1,
        "url": "https://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": "<4695f0b4603308f6e27a0f2518945172989165fd.1499360068.git.adrien.mazarguil@6wind.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/4695f0b4603308f6e27a0f2518945172989165fd.1499360068.git.adrien.mazarguil@6wind.com",
    "date": "2017-07-06T16:56:54",
    "name": "[dpdk-dev,v3] ethdev: add flow API rule copy function",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "7f405e51f82d0145175b0cc03321d6a576cd42da",
    "submitter": {
        "id": 165,
        "url": "https://patches.dpdk.org/api/people/165/?format=api",
        "name": "Adrien Mazarguil",
        "email": "adrien.mazarguil@6wind.com"
    },
    "delegate": null,
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/4695f0b4603308f6e27a0f2518945172989165fd.1499360068.git.adrien.mazarguil@6wind.com/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/26555/comments/",
    "check": "fail",
    "checks": "https://patches.dpdk.org/api/patches/26555/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 71D5D2B96;\n\tThu,  6 Jul 2017 18:57:08 +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 73BC01C0B\n\tfor <dev@dpdk.org>; Thu,  6 Jul 2017 18:57:07 +0200 (CEST)",
            "by mail-wr0-f171.google.com with SMTP id r103so10946370wrb.0\n\tfor <dev@dpdk.org>; Thu, 06 Jul 2017 09:57:07 -0700 (PDT)",
            "from 6wind.com (host.78.145.23.62.rev.coltfrance.com.\n\t[62.23.145.78]) by smtp.gmail.com with ESMTPSA id\n\tp7sm1163422wmf.11.2017.07.06.09.57.05\n\t(version=TLS1_2 cipher=AES128-SHA bits=128/128);\n\tThu, 06 Jul 2017 09:57:05 -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\tbh=SvfqX2z9TbxWeB+HhksmoaY+jZ2+afnX955lGp6hh38=;\n\tb=nb94ac00HNsokFl941HovZU0dw2e4Trgqcji4thTil1SP1KBNtpn6EhXeB+Uht+uRf\n\tdY2+vGQ75WO6gdNAFyfnfS4YeE5NDCA2+zcQi+sbaiW5L0w3Hr1Awb1GTES7FwbJxRQN\n\tB1OqTwqTligh/fQfAK17ynOErBMqsjUIH0Xnh+NO6HbKqTgv4vtRrNS64SWKGy7g0lna\n\ttnr4Ou3EwEzdvhZmmfp0lnv842hJy407+5yvFCS8nNF6UegZF2pNmOLo5+3dZZViMCyp\n\tEFhObw+9p97ydCevsS5zALOhZVbZbdBG04jAm1hOAGosbVCVcQFUxZe0QG4IIA8i9yoo\n\tf48g==",
        "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;\n\tbh=SvfqX2z9TbxWeB+HhksmoaY+jZ2+afnX955lGp6hh38=;\n\tb=HG4JzqQ2eEQklaGqvnGycCdovj4kGTvAcfi3wDynTyxxPDlS4OBxRrb23Y6fD+K2qx\n\tPCUFkmQKQIcX3NvN2HrQowKIfIYLWxFqKLGTTQdpAlhTx8xoXdhwW8RCmMH/trBs+TQx\n\tk1JyXssb8SM7FwyjWmtKiUWa2nJYGH5vt8zbhrPxQoFQ8PrKCwN5lc/KzzjfPjUfb6mP\n\tp6wmnwF+A/wATdSVDL3ypw8//mjZoSB8Klkl1dmQhzNo0qjvQe1HuhoYW+OAmtbn1HE1\n\tC5qxQk6lQ6R2P+9/B3pZ/mwIr1MCJnXycd8Du+LkOMwFIl9nZx45CIfnUDaPdVQfHec7\n\t40ig==",
        "X-Gm-Message-State": "AIVw113tKDapWxQ0Hym260vZC3/KaF4mCWmMOJEijUAwRkXZGvXNTqHs\n\tTKtqogVLZxwNgr0hXjo=",
        "X-Received": "by 10.28.71.76 with SMTP id u73mr121363wma.105.1499360226674;\n\tThu, 06 Jul 2017 09:57:06 -0700 (PDT)",
        "From": "Adrien Mazarguil <adrien.mazarguil@6wind.com>",
        "To": "Gaetan Rivet <gaetan.rivet@6wind.com>,\n\tThomas Monjalon <thomas@monjalon.net>",
        "Cc": "dev@dpdk.org",
        "Date": "Thu,  6 Jul 2017 18:56:54 +0200",
        "Message-Id": "<4695f0b4603308f6e27a0f2518945172989165fd.1499360068.git.adrien.mazarguil@6wind.com>",
        "X-Mailer": "git-send-email 2.1.4",
        "In-Reply-To": "<c3dbfe0bda1da236f10023f379329e985281b9c2.1495207150.git.gaetan.rivet@6wind.com>",
        "References": "<c3dbfe0bda1da236f10023f379329e985281b9c2.1495207150.git.gaetan.rivet@6wind.com>",
        "Subject": "[dpdk-dev] [PATCH v3] ethdev: add flow API rule copy function",
        "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": "From: Gaetan Rivet <gaetan.rivet@6wind.com>\n\nThis allows PMDs and applications to save flow rules in their generic\nformat for later processing. This is useful when rules cannot be applied\nimmediately, such as when the device is not properly initialized.\n\nSigned-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>\nSigned-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>\n\n---\n\nGaetan, sorry for taking over and modifying your patch, took me a while to\nreview it and given there is not much time left before RC1, here is my\nsuggestion in the form of an updated patch for reasons described below.\n\nI'm convinced exposing rte_flow_copy() is useful and mandatory not only for\nthe fail-safe PMD, but also to avoid code duplication later.\n\nHowever since you took this code from testpmd, you've inherited its main\ndrawback which is rte_flow_desc_item[] and rte_flow_desc_action[] are a\npain to maintain. Every time new flow item/action are added, one has to\nupdate these arrays as well.\n\nMoreover it forces you to expose and version a bunch of additional symbols\nso far only useful to testpmd.\n\nTherefore I'm thinking about generating these arrays automatically at\ncompilation time from enum definitions and not expose extra symbols at the\nsame time. I'll try to submit these changes before the next RC.\n\nSo in the meantime, here's a v3 in order not to break existing series that\ndepend on this patch and not introduce unnecessary symbols.\n\nv2 -> v3:\n\n * Revert testpmd changes.\n * Do not expose extra symbols (rte_flow_desc_action, rte_flow_desc_item,\n   rte_flow_nb_action and rte_flow_nb_item).\n * Do not expose struct rte_flow_desc_data.\n * Add missing #include directives to rte_flow.c.\n\nv1 -> v2:\n\n * fix checkpatch warnings\n---\n lib/librte_ether/rte_ether_version.map |   1 +\n lib/librte_ether/rte_flow.c            | 225 ++++++++++++++++++++++++++++\n lib/librte_ether/rte_flow.h            |  40 +++++\n 3 files changed, 266 insertions(+)",
    "diff": "diff --git a/lib/librte_ether/rte_ether_version.map b/lib/librte_ether/rte_ether_version.map\nindex 019a93d..6f65f83 100644\n--- a/lib/librte_ether/rte_ether_version.map\n+++ b/lib/librte_ether/rte_ether_version.map\n@@ -152,6 +152,7 @@ DPDK_17.08 {\n \tglobal:\n \n \t_rte_eth_dev_callback_process;\n+\trte_flow_copy;\n \trte_flow_isolate;\n \n } DPDK_17.05;\ndiff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c\nindex c1de31b..59ca85a 100644\n--- a/lib/librte_ether/rte_flow.c\n+++ b/lib/librte_ether/rte_flow.c\n@@ -31,14 +31,79 @@\n  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n  */\n \n+#include <errno.h>\n+#include <stddef.h>\n #include <stdint.h>\n+#include <string.h>\n \n+#include <rte_common.h>\n #include <rte_errno.h>\n #include <rte_branch_prediction.h>\n #include \"rte_ethdev.h\"\n #include \"rte_flow_driver.h\"\n #include \"rte_flow.h\"\n \n+/**\n+ * Flow elements description tables.\n+ */\n+struct rte_flow_desc_data {\n+\tconst char *name;\n+\tsize_t size;\n+};\n+\n+/** Generate flow_item[] entry. */\n+#define MK_FLOW_ITEM(t, s) \\\n+\t[RTE_FLOW_ITEM_TYPE_ ## t] = { \\\n+\t\t.name = # t, \\\n+\t\t.size = s, \\\n+\t}\n+\n+/** Information about known flow pattern items. */\n+static const struct rte_flow_desc_data rte_flow_desc_item[] = {\n+\tMK_FLOW_ITEM(END, 0),\n+\tMK_FLOW_ITEM(VOID, 0),\n+\tMK_FLOW_ITEM(INVERT, 0),\n+\tMK_FLOW_ITEM(ANY, sizeof(struct rte_flow_item_any)),\n+\tMK_FLOW_ITEM(PF, 0),\n+\tMK_FLOW_ITEM(VF, sizeof(struct rte_flow_item_vf)),\n+\tMK_FLOW_ITEM(PORT, sizeof(struct rte_flow_item_port)),\n+\tMK_FLOW_ITEM(RAW, sizeof(struct rte_flow_item_raw)), /* +pattern[] */\n+\tMK_FLOW_ITEM(ETH, sizeof(struct rte_flow_item_eth)),\n+\tMK_FLOW_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)),\n+\tMK_FLOW_ITEM(IPV4, sizeof(struct rte_flow_item_ipv4)),\n+\tMK_FLOW_ITEM(IPV6, sizeof(struct rte_flow_item_ipv6)),\n+\tMK_FLOW_ITEM(ICMP, sizeof(struct rte_flow_item_icmp)),\n+\tMK_FLOW_ITEM(UDP, sizeof(struct rte_flow_item_udp)),\n+\tMK_FLOW_ITEM(TCP, sizeof(struct rte_flow_item_tcp)),\n+\tMK_FLOW_ITEM(SCTP, sizeof(struct rte_flow_item_sctp)),\n+\tMK_FLOW_ITEM(VXLAN, sizeof(struct rte_flow_item_vxlan)),\n+\tMK_FLOW_ITEM(MPLS, sizeof(struct rte_flow_item_mpls)),\n+\tMK_FLOW_ITEM(GRE, sizeof(struct rte_flow_item_gre)),\n+};\n+\n+/** Generate flow_action[] entry. */\n+#define MK_FLOW_ACTION(t, s) \\\n+\t[RTE_FLOW_ACTION_TYPE_ ## t] = { \\\n+\t\t.name = # t, \\\n+\t\t.size = s, \\\n+\t}\n+\n+/** Information about known flow actions. */\n+static const struct rte_flow_desc_data rte_flow_desc_action[] = {\n+\tMK_FLOW_ACTION(END, 0),\n+\tMK_FLOW_ACTION(VOID, 0),\n+\tMK_FLOW_ACTION(PASSTHRU, 0),\n+\tMK_FLOW_ACTION(MARK, sizeof(struct rte_flow_action_mark)),\n+\tMK_FLOW_ACTION(FLAG, 0),\n+\tMK_FLOW_ACTION(QUEUE, sizeof(struct rte_flow_action_queue)),\n+\tMK_FLOW_ACTION(DROP, 0),\n+\tMK_FLOW_ACTION(COUNT, 0),\n+\tMK_FLOW_ACTION(DUP, sizeof(struct rte_flow_action_dup)),\n+\tMK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)), /* +queue[] */\n+\tMK_FLOW_ACTION(PF, 0),\n+\tMK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)),\n+};\n+\n /* Get generic flow operations structure from a port. */\n const struct rte_flow_ops *\n rte_flow_ops_get(uint8_t port_id, struct rte_flow_error *error)\n@@ -175,3 +240,163 @@ rte_flow_isolate(uint8_t port_id,\n \t\t\t\t   RTE_FLOW_ERROR_TYPE_UNSPECIFIED,\n \t\t\t\t   NULL, rte_strerror(ENOSYS));\n }\n+\n+/** Compute storage space needed by item specification. */\n+static void\n+flow_item_spec_size(const struct rte_flow_item *item,\n+\t\t    size_t *size, size_t *pad)\n+{\n+\tif (!item->spec)\n+\t\tgoto empty;\n+\tswitch (item->type) {\n+\t\tunion {\n+\t\t\tconst struct rte_flow_item_raw *raw;\n+\t\t} spec;\n+\n+\t/* Not a fall-through */\n+\tcase RTE_FLOW_ITEM_TYPE_RAW:\n+\t\tspec.raw = item->spec;\n+\t\t*size = offsetof(struct rte_flow_item_raw, pattern) +\n+\t\t\tspec.raw->length * sizeof(*spec.raw->pattern);\n+\t\tbreak;\n+\tdefault:\n+empty:\n+\t\t*size = 0;\n+\t\tbreak;\n+\t}\n+\t*pad = RTE_ALIGN_CEIL(*size, sizeof(double)) - *size;\n+}\n+\n+/** Compute storage space needed by action configuration. */\n+static void\n+flow_action_conf_size(const struct rte_flow_action *action,\n+\t\t      size_t *size, size_t *pad)\n+{\n+\tif (!action->conf)\n+\t\tgoto empty;\n+\tswitch (action->type) {\n+\t\tunion {\n+\t\t\tconst struct rte_flow_action_rss *rss;\n+\t\t} conf;\n+\n+\t/* Not a fall-through. */\n+\tcase RTE_FLOW_ACTION_TYPE_RSS:\n+\t\tconf.rss = action->conf;\n+\t\t*size = offsetof(struct rte_flow_action_rss, queue) +\n+\t\t\tconf.rss->num * sizeof(*conf.rss->queue);\n+\t\tbreak;\n+\tdefault:\n+empty:\n+\t\t*size = 0;\n+\t\tbreak;\n+\t}\n+\t*pad = RTE_ALIGN_CEIL(*size, sizeof(double)) - *size;\n+}\n+\n+/** Store a full rte_flow description. */\n+size_t\n+rte_flow_copy(struct rte_flow_desc *desc, size_t len,\n+\t      const struct rte_flow_attr *attr,\n+\t      const struct rte_flow_item *items,\n+\t      const struct rte_flow_action *actions)\n+{\n+\tstruct rte_flow_desc *fd = NULL;\n+\tsize_t tmp;\n+\tsize_t pad;\n+\tsize_t off1 = 0;\n+\tsize_t off2 = 0;\n+\tsize_t size = 0;\n+\n+store:\n+\tif (items) {\n+\t\tconst struct rte_flow_item *item;\n+\n+\t\titem = items;\n+\t\tif (fd)\n+\t\t\tfd->items = (void *)&fd->data[off1];\n+\t\tdo {\n+\t\t\tstruct rte_flow_item *dst = NULL;\n+\n+\t\t\tif ((size_t)item->type >=\n+\t\t\t\tRTE_DIM(rte_flow_desc_item) ||\n+\t\t\t    !rte_flow_desc_item[item->type].name) {\n+\t\t\t\trte_errno = ENOTSUP;\n+\t\t\t\treturn 0;\n+\t\t\t}\n+\t\t\tif (fd)\n+\t\t\t\tdst = memcpy(fd->data + off1, item,\n+\t\t\t\t\t     sizeof(*item));\n+\t\t\toff1 += sizeof(*item);\n+\t\t\tflow_item_spec_size(item, &tmp, &pad);\n+\t\t\tif (item->spec) {\n+\t\t\t\tif (fd)\n+\t\t\t\t\tdst->spec = memcpy(fd->data + off2,\n+\t\t\t\t\t\t\t   item->spec, tmp);\n+\t\t\t\toff2 += tmp + pad;\n+\t\t\t}\n+\t\t\tif (item->last) {\n+\t\t\t\tif (fd)\n+\t\t\t\t\tdst->last = memcpy(fd->data + off2,\n+\t\t\t\t\t\t\t   item->last, tmp);\n+\t\t\t\toff2 += tmp + pad;\n+\t\t\t}\n+\t\t\tif (item->mask) {\n+\t\t\t\tif (fd)\n+\t\t\t\t\tdst->mask = memcpy(fd->data + off2,\n+\t\t\t\t\t\t\t   item->mask, tmp);\n+\t\t\t\toff2 += tmp + pad;\n+\t\t\t}\n+\t\t\toff2 = RTE_ALIGN_CEIL(off2, sizeof(double));\n+\t\t} while ((item++)->type != RTE_FLOW_ITEM_TYPE_END);\n+\t\toff1 = RTE_ALIGN_CEIL(off1, sizeof(double));\n+\t}\n+\tif (actions) {\n+\t\tconst struct rte_flow_action *action;\n+\n+\t\taction = actions;\n+\t\tif (fd)\n+\t\t\tfd->actions = (void *)&fd->data[off1];\n+\t\tdo {\n+\t\t\tstruct rte_flow_action *dst = NULL;\n+\n+\t\t\tif ((size_t)action->type >=\n+\t\t\t\tRTE_DIM(rte_flow_desc_action) ||\n+\t\t\t    !rte_flow_desc_action[action->type].name) {\n+\t\t\t\trte_errno = ENOTSUP;\n+\t\t\t\treturn 0;\n+\t\t\t}\n+\t\t\tif (fd)\n+\t\t\t\tdst = memcpy(fd->data + off1, action,\n+\t\t\t\t\t     sizeof(*action));\n+\t\t\toff1 += sizeof(*action);\n+\t\t\tflow_action_conf_size(action, &tmp, &pad);\n+\t\t\tif (action->conf) {\n+\t\t\t\tif (fd)\n+\t\t\t\t\tdst->conf = memcpy(fd->data + off2,\n+\t\t\t\t\t\t\t   action->conf, tmp);\n+\t\t\t\toff2 += tmp + pad;\n+\t\t\t}\n+\t\t\toff2 = RTE_ALIGN_CEIL(off2, sizeof(double));\n+\t\t} while ((action++)->type != RTE_FLOW_ACTION_TYPE_END);\n+\t}\n+\tif (fd != NULL)\n+\t\treturn size;\n+\toff1 = RTE_ALIGN_CEIL(off1, sizeof(double));\n+\ttmp = RTE_ALIGN_CEIL(offsetof(struct rte_flow_desc, data),\n+\t\t\t     sizeof(double));\n+\tsize = tmp + off1 + off2;\n+\tif (size > len)\n+\t\treturn size;\n+\tfd = desc;\n+\tif (fd != NULL) {\n+\t\t*fd = (const struct rte_flow_desc) {\n+\t\t\t.size = size,\n+\t\t\t.attr = *attr,\n+\t\t};\n+\t\ttmp -= offsetof(struct rte_flow_desc, data);\n+\t\toff2 = tmp + off1;\n+\t\toff1 = tmp;\n+\t\tgoto store;\n+\t}\n+\treturn 0;\n+}\ndiff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h\nindex cfbed30..6ac7cdb 100644\n--- a/lib/librte_ether/rte_flow.h\n+++ b/lib/librte_ether/rte_flow.h\n@@ -1266,6 +1266,46 @@ rte_flow_query(uint8_t port_id,\n int\n rte_flow_isolate(uint8_t port_id, int set, struct rte_flow_error *error);\n \n+/**\n+ * Generic flow representation.\n+ *\n+ * This form is sufficient to describe an rte_flow independently from any\n+ * PMD implementation and allows for replayability and identification.\n+ */\n+struct rte_flow_desc {\n+\tsize_t size; /**< Allocated space including data[]. */\n+\tstruct rte_flow_attr attr; /**< Attributes. */\n+\tstruct rte_flow_item *items; /**< Items. */\n+\tstruct rte_flow_action *actions; /**< Actions. */\n+\tuint8_t data[]; /**< Storage for items/actions. */\n+};\n+\n+/**\n+ * Copy an rte_flow rule description.\n+ *\n+ * @param[in] fd\n+ *   Flow rule description.\n+ * @param[in] len\n+ *   Total size of allocated data for the flow description.\n+ * @param[in] attr\n+ *   Flow rule attributes.\n+ * @param[in] items\n+ *   Pattern specification (list terminated by the END pattern item).\n+ * @param[in] actions\n+ *   Associated actions (list terminated by the END action).\n+ *\n+ * @return\n+ *   If len is greater or equal to the size of the flow, the total size of the\n+ *   flow description and its data.\n+ *   If len is lower than the size of the flow, the number of bytes that would\n+ *   have been written to desc had it been sufficient. Nothing is written.\n+ */\n+size_t\n+rte_flow_copy(struct rte_flow_desc *fd, size_t len,\n+\t      const struct rte_flow_attr *attr,\n+\t      const struct rte_flow_item *items,\n+\t      const struct rte_flow_action *actions);\n+\n #ifdef __cplusplus\n }\n #endif\n",
    "prefixes": [
        "dpdk-dev",
        "v3"
    ]
}