get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 26597,
    "url": "https://patches.dpdk.org/api/patches/26597/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/97a26e6fbd6bcf04fafd2d68a2dad07405d151af.1499384906.git.gaetan.rivet@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": "<97a26e6fbd6bcf04fafd2d68a2dad07405d151af.1499384906.git.gaetan.rivet@6wind.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/97a26e6fbd6bcf04fafd2d68a2dad07405d151af.1499384906.git.gaetan.rivet@6wind.com",
    "date": "2017-07-07T00:09:18",
    "name": "[dpdk-dev,v6,11/23] ethdev: add flow API rule copy function",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "1c9c95d122dc349e0ee74de105ed0bf6c82b8a43",
    "submitter": {
        "id": 269,
        "url": "https://patches.dpdk.org/api/people/269/?format=api",
        "name": "Gaëtan Rivet",
        "email": "gaetan.rivet@6wind.com"
    },
    "delegate": null,
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/97a26e6fbd6bcf04fafd2d68a2dad07405d151af.1499384906.git.gaetan.rivet@6wind.com/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/26597/comments/",
    "check": "fail",
    "checks": "https://patches.dpdk.org/api/patches/26597/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 283657CD7;\n\tFri,  7 Jul 2017 02:10:30 +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 E32515905\n\tfor <dev@dpdk.org>; Fri,  7 Jul 2017 02:10:07 +0200 (CEST)",
            "by mail-wr0-f171.google.com with SMTP id k67so24226589wrc.2\n\tfor <dev@dpdk.org>; Thu, 06 Jul 2017 17:10:07 -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\tf45sm2391166wrf.2.2017.07.06.17.10.05\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);\n\tThu, 06 Jul 2017 17:10:06 -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=3DyIKIBwtygrKgYlNSD9i1QdcVmCZN2FgDATlg0DFaE=;\n\tb=ZsBy9Aoi0zSGPgyqR3UU4MvmXbimo6KnxezhmZzHw22z/Y0dNdRei8OJybDc4yB6/O\n\tlh9ek2gGchQ81L1sw8zl45p+b0Wcd/5CMUBzaiw/dL2ILMzPVVaFZcMOfTpuybFm2K71\n\t+lK46tMWjo+HVoEvN5aMfm1KwrvfnN1uGfxTlDsdIBqi+lbhvi75DoyU7DCkflri6aL4\n\tF9k8dqMKgCtNWsnhayWvVB95mBW1eZhfPsYNbeLMY9u4seK7Mapa9ozAAxA3GwoinBql\n\tdMwKDTSk8cV7f16H48XYd14G62twlBtHqXrfPkZ8117d0p9MNSfSKggiyhWhcfNFjOhJ\n\tN3ng==",
        "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=3DyIKIBwtygrKgYlNSD9i1QdcVmCZN2FgDATlg0DFaE=;\n\tb=uK87STnnfjKAmJJ7OH2mu24GmJ83gNHCDxHQi0gW4FDP+fVLB8Zz2Yx2zQXYsco5oI\n\tBkZ8jDBsCt5lpwpm97iJEcZljYjBh05GdfbCZ3kgTMC61C05ja6zuwUEgcRpl9GJi7bm\n\tCRejyWRdjw0rTQBz5+fJDmyKSGAHfDp7jL4eO7dzuuB74MB+pUDDMoMMnlNoGPFm4MNz\n\tW6NYbNFMkT/Xa1q2h5giSBb50NnU9pEdvszKeRxfaYpi4qlz8wvZl85sU9jQuWdsOA6E\n\tANyemHEphHXmRMZI/wp295ZvVXxaZfNxCCVERT50U3ASUGk7ni7zyiCvhcX2yZko7XTz\n\t2p9A==",
        "X-Gm-Message-State": "AIVw110bBaypKMnSjXoWsbnX3uN+vwaS/UI4cVNGpTYtEzcAdQPbslFk\n\tWsh7J7ijdPat55TYg1c=",
        "X-Received": "by 10.28.175.212 with SMTP id y203mr311953wme.2.1499386206975;\n\tThu, 06 Jul 2017 17:10:06 -0700 (PDT)",
        "From": "Gaetan Rivet <gaetan.rivet@6wind.com>",
        "To": "dev@dpdk.org",
        "Cc": "Gaetan Rivet <gaetan.rivet@6wind.com>,\n\tAdrien Mazarguil <adrien.mazarguil@6wind.com>",
        "Date": "Fri,  7 Jul 2017 02:09:18 +0200",
        "Message-Id": "<97a26e6fbd6bcf04fafd2d68a2dad07405d151af.1499384906.git.gaetan.rivet@6wind.com>",
        "X-Mailer": "git-send-email 2.1.4",
        "In-Reply-To": [
            "<cover.1499385281.git.gaetan.rivet@6wind.com>",
            "<cover.1499384906.git.gaetan.rivet@6wind.com>"
        ],
        "References": [
            "<cover.1496877105.git.gaetan.rivet@6wind.com>\n\t<cover.1499385281.git.gaetan.rivet@6wind.com>",
            "<cover.1499384906.git.gaetan.rivet@6wind.com>"
        ],
        "Subject": "[dpdk-dev] [PATCH v6 11/23] 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": "This 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 lib/librte_ether/rte_ether_version.map |   1 +\n lib/librte_ether/rte_flow.c            | 227 +++++++++++++++++++++++++++++++++\n lib/librte_ether/rte_flow.h            |  40 ++++++\n 3 files changed, 268 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..884e4f6 100644\n--- a/lib/librte_ether/rte_flow.c\n+++ b/lib/librte_ether/rte_flow.c\n@@ -31,14 +31,81 @@\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+\tMK_FLOW_ITEM(E_TAG, sizeof(struct rte_flow_item_e_tag)),\n+\tMK_FLOW_ITEM(NVGRE, sizeof(struct rte_flow_item_nvgre)),\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 +242,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",
        "v6",
        "11/23"
    ]
}