Show a patch.

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

{
    "id": 42957,
    "url": "http://patches.dpdk.org/api/patches/42957/",
    "web_url": "http://patches.dpdk.org/patch/42957/",
    "project": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/projects/1/",
        "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"
    },
    "msgid": "<4da6a61eba9065a78a4af8f4fa78d7ccb7fced26.1531387413.git.nelio.laranjeiro@6wind.com>",
    "date": "2018-07-12T09:30:56",
    "name": "[v4,10/21] net/mlx5: add flow UDP item",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "251f1ea4bdafea1b33ccab80cf9bf06eb6c60421",
    "submitter": {
        "id": 243,
        "url": "http://patches.dpdk.org/api/people/243/",
        "name": "Nélio Laranjeiro",
        "email": "nelio.laranjeiro@6wind.com"
    },
    "delegate": {
        "id": 6624,
        "url": "http://patches.dpdk.org/api/users/6624/",
        "username": "shahafs",
        "first_name": "Shahaf",
        "last_name": "Shuler",
        "email": "shahafs@mellanox.com"
    },
    "mbox": "http://patches.dpdk.org/patch/42957/mbox/",
    "series": [
        {
            "id": 544,
            "url": "http://patches.dpdk.org/api/series/544/",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=544",
            "date": "2018-07-12T09:30:46",
            "name": "net/mlx5: flow rework",
            "version": 4,
            "mbox": "http://patches.dpdk.org/series/544/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/42957/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/42957/checks/",
    "tags": {},
    "headers": {
        "X-Mailer": "git-send-email 2.18.0",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "From": "Nelio Laranjeiro <nelio.laranjeiro@6wind.com>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "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=j8VbX1jANxkfYceXfWDEHAqvwkXaiqVftC18KlRQkjc=;\n\tb=SpZURVBFYBguuw9Yi+ijDJGSZfUw84T2qQOMOeJDqihJuhTnFAYvu/MLdc7AOcABSz\n\tyiybWj4Ywlbyxx5fzGAQr/Zq7sL4w7ghq602fndwoMR+YTQddiKuuljh6tLLcAr9ifwe\n\tNQ+C/qKP+Ja3Z1r4CzaOdELSEHfRNgh9CT/UB0aqcN+3fdezmYZHTZpDORjBmqEfXVnz\n\tdti0xIaTWlCOGr0re5QwBCEc/Jaece9LL8Wj0kUB84Fn2T3sYku1fAbZBGfVO90fPx12\n\tMK3D//kd0dq2QvvIv77Sq6m6reI5Ys67TD+lkqnRuUwtpmjA38STXKdsuIWawjR4semR\n\tM/Fg==",
        "X-Mailman-Version": "2.1.15",
        "Delivered-To": "patchwork@dpdk.org",
        "X-Gm-Message-State": "AOUpUlFD/vPPB0x1boGd7+ploHF0ChqD/UCwAQK34DtNw1jH97fH9jiE\n\tP+6Hmb+yEOnSKhjX4TTY/q9kOYTApg==",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Cc": "Adrien Mazarguil <adrien.mazarguil@6wind.com>",
        "To": "dev@dpdk.org,\n\tYongseok Koh <yskoh@mellanox.com>",
        "Errors-To": "dev-bounces@dpdk.org",
        "References": "<cover.1531293415.git.nelio.laranjeiro@6wind.com>\n\t<cover.1531387413.git.nelio.laranjeiro@6wind.com>",
        "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=j8VbX1jANxkfYceXfWDEHAqvwkXaiqVftC18KlRQkjc=;\n\tb=bkgSjBQjsgXfaTG8UMj0sVW7o+jigIWMCaTcubw8p1ERhfTApwbU9qNRdJNB7BdHKp\n\tQ27SIb6alM8m7vK8S9+s330bElnWH3/gkwKwMH7V/xXx7kMw1Y1jOOzFvctWQZOfeUQ6\n\tDR6DEah7k3sCftZUBTautSzYRWiFMeCyfF53PZTgdkgEHo7nH40N20FwRR+U8ThKvW54\n\t1JULQuhO+ak1Q6dpXrWYJUeCeveo6idEcc0zkvIdROmeEXLuYLokknopwtpwxc2L7bq4\n\tf4Krwt8xrb5kjc8Wnzh69JzKLbaOvkKBeMfhkxxaaJ8EWflU81UN48oahMxhZQ0hD6pO\n\tdVHg==",
        "Return-Path": "<dev-bounces@dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "Received": [
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 3D6321B5F3;\n\tThu, 12 Jul 2018 11:31:49 +0200 (CEST)",
            "from mail-wm0-f68.google.com (mail-wm0-f68.google.com\n\t[74.125.82.68]) by dpdk.org (Postfix) with ESMTP id 006E21B535\n\tfor <dev@dpdk.org>; Thu, 12 Jul 2018 11:31:34 +0200 (CEST)",
            "by mail-wm0-f68.google.com with SMTP id z13-v6so5288293wma.5\n\tfor <dev@dpdk.org>; Thu, 12 Jul 2018 02:31:33 -0700 (PDT)",
            "from laranjeiro-vm.dev.6wind.com\n\t(host.78.145.23.62.rev.coltfrance.com. [62.23.145.78])\n\tby smtp.gmail.com with ESMTPSA id\n\ts2-v6sm18717603wrn.75.2018.07.12.02.31.32\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tThu, 12 Jul 2018 02:31:32 -0700 (PDT)"
        ],
        "Date": "Thu, 12 Jul 2018 11:30:56 +0200",
        "X-Received": "by 2002:a1c:b24c:: with SMTP id\n\tb73-v6mr620537wmf.141.1531387893545; \n\tThu, 12 Jul 2018 02:31:33 -0700 (PDT)",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>",
        "Subject": "[dpdk-dev] [PATCH v4 10/21] net/mlx5: add flow UDP item",
        "In-Reply-To": "<cover.1531387413.git.nelio.laranjeiro@6wind.com>",
        "Message-Id": "<4da6a61eba9065a78a4af8f4fa78d7ccb7fced26.1531387413.git.nelio.laranjeiro@6wind.com>",
        "Precedence": "list",
        "X-BeenThere": "dev@dpdk.org",
        "X-Original-To": "patchwork@dpdk.org",
        "X-Google-Smtp-Source": "AAOMgpcFPJrnE2w2WvGOGdKWnJ+0F4eD5WBVcZgotdMBl4ndUnsAsGfY2o3lZZzrIcPVOterAKT5HQ=="
    },
    "content": "Signed-off-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>\nAcked-by: Yongseok Koh <yskoh@mellanox.com>\n---\n drivers/net/mlx5/mlx5_flow.c | 97 +++++++++++++++++++++++++++++++++---\n 1 file changed, 91 insertions(+), 6 deletions(-)",
    "diff": "diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c\nindex 513f70d40..0096ed8a2 100644\n--- a/drivers/net/mlx5/mlx5_flow.c\n+++ b/drivers/net/mlx5/mlx5_flow.c\n@@ -52,6 +52,9 @@ extern const struct eth_dev_ops mlx5_dev_ops_isolate;\n #define MLX5_FLOW_FATE_DROP (1u << 0)\n #define MLX5_FLOW_FATE_QUEUE (1u << 1)\n \n+/* possible L3 layers protocols filtering. */\n+#define MLX5_IP_PROTOCOL_UDP 17\n+\n /** Handles information leading to a drop fate. */\n struct mlx5_flow_verbs {\n \tunsigned int size; /**< Size of the attribute. */\n@@ -68,10 +71,12 @@ struct mlx5_flow_verbs {\n struct rte_flow {\n \tTAILQ_ENTRY(rte_flow) next; /**< Pointer to the next flow structure. */\n \tstruct rte_flow_attr attributes; /**< User flow attribute. */\n+\tuint32_t l3_protocol_en:1; /**< Protocol filtering requested. */\n \tuint32_t layers;\n \t/**< Bit-fields of present layers see MLX5_FLOW_LAYER_*. */\n \tuint32_t fate;\n \t/**< Bit-fields of present fate see MLX5_FLOW_FATE_*. */\n+\tuint8_t l3_protocol; /**< valid when l3_protocol_en is set. */\n \tstruct mlx5_flow_verbs verbs; /* Verbs flow. */\n \tuint16_t queue; /**< Destination queue to redirect traffic to. */\n };\n@@ -568,8 +573,6 @@ mlx5_flow_item_ipv4(const struct rte_flow_item *item, struct rte_flow *flow,\n \tif (ret < 0)\n \t\treturn ret;\n \tflow->layers |= MLX5_FLOW_LAYER_OUTER_L3_IPV4;\n-\tif (size > flow_size)\n-\t\treturn size;\n \tif (spec) {\n \t\tipv4.val = (struct ibv_flow_ipv4_ext_filter){\n \t\t\t.src_ip = spec->hdr.src_addr,\n@@ -589,7 +592,10 @@ mlx5_flow_item_ipv4(const struct rte_flow_item *item, struct rte_flow *flow,\n \t\tipv4.val.proto &= ipv4.mask.proto;\n \t\tipv4.val.tos &= ipv4.mask.tos;\n \t}\n-\tmlx5_flow_spec_verbs_add(flow, &ipv4, size);\n+\tflow->l3_protocol_en = !!ipv4.mask.proto;\n+\tflow->l3_protocol = ipv4.val.proto;\n+\tif (size <= flow_size)\n+\t\tmlx5_flow_spec_verbs_add(flow, &ipv4, size);\n \treturn size;\n }\n \n@@ -660,8 +666,6 @@ mlx5_flow_item_ipv6(const struct rte_flow_item *item, struct rte_flow *flow,\n \tif (ret < 0)\n \t\treturn ret;\n \tflow->layers |= MLX5_FLOW_LAYER_OUTER_L3_IPV6;\n-\tif (size > flow_size)\n-\t\treturn size;\n \tif (spec) {\n \t\tunsigned int i;\n \t\tuint32_t vtc_flow_val;\n@@ -701,7 +705,85 @@ mlx5_flow_item_ipv6(const struct rte_flow_item *item, struct rte_flow *flow,\n \t\tipv6.val.next_hdr &= ipv6.mask.next_hdr;\n \t\tipv6.val.hop_limit &= ipv6.mask.hop_limit;\n \t}\n-\tmlx5_flow_spec_verbs_add(flow, &ipv6, size);\n+\tflow->l3_protocol_en = !!ipv6.mask.next_hdr;\n+\tflow->l3_protocol = ipv6.val.next_hdr;\n+\tif (size <= flow_size)\n+\t\tmlx5_flow_spec_verbs_add(flow, &ipv6, size);\n+\treturn size;\n+}\n+\n+/**\n+ * Convert the @p item into a Verbs specification after ensuring the NIC\n+ * will understand and process it correctly.\n+ * If the necessary size for the conversion is greater than the @p flow_size,\n+ * nothing is written in @p flow, the validation is still performed.\n+ *\n+ * @param[in] item\n+ *   Item specification.\n+ * @param[in, out] flow\n+ *   Pointer to flow structure.\n+ * @param[in] flow_size\n+ *   Size in bytes of the available space in @p flow, if too small, nothing is\n+ *   written.\n+ * @param[out] error\n+ *   Pointer to error structure.\n+ *\n+ * @return\n+ *   On success the number of bytes consumed/necessary, if the returned value\n+ *   is lesser or equal to @p flow_size, the @p item has fully been converted,\n+ *   otherwise another call with this returned memory size should be done.\n+ *   On error, a negative errno value is returned and rte_errno is set.\n+ */\n+static int\n+mlx5_flow_item_udp(const struct rte_flow_item *item, struct rte_flow *flow,\n+\t\t   const size_t flow_size, struct rte_flow_error *error)\n+{\n+\tconst struct rte_flow_item_udp *spec = item->spec;\n+\tconst struct rte_flow_item_udp *mask = item->mask;\n+\tunsigned int size = sizeof(struct ibv_flow_spec_tcp_udp);\n+\tstruct ibv_flow_spec_tcp_udp udp = {\n+\t\t.type = IBV_FLOW_SPEC_UDP,\n+\t\t.size = size,\n+\t};\n+\tint ret;\n+\n+\tif (!(flow->layers & MLX5_FLOW_LAYER_OUTER_L3))\n+\t\treturn rte_flow_error_set(error, ENOTSUP,\n+\t\t\t\t\t  RTE_FLOW_ERROR_TYPE_ITEM,\n+\t\t\t\t\t  item,\n+\t\t\t\t\t  \"L3 is mandatory to filter on L4\");\n+\tif (flow->layers & MLX5_FLOW_LAYER_OUTER_L4)\n+\t\treturn rte_flow_error_set(error, ENOTSUP,\n+\t\t\t\t\t  RTE_FLOW_ERROR_TYPE_ITEM,\n+\t\t\t\t\t  item,\n+\t\t\t\t\t  \"L4 layer is already present\");\n+\tif (flow->l3_protocol_en && flow->l3_protocol != MLX5_IP_PROTOCOL_UDP)\n+\t\treturn rte_flow_error_set(error, ENOTSUP,\n+\t\t\t\t\t  RTE_FLOW_ERROR_TYPE_ITEM,\n+\t\t\t\t\t  item,\n+\t\t\t\t\t  \"protocol filtering not compatible\"\n+\t\t\t\t\t  \" with UDP layer\");\n+\tif (!mask)\n+\t\tmask = &rte_flow_item_udp_mask;\n+\tret = mlx5_flow_item_acceptable\n+\t\t(item, (const uint8_t *)mask,\n+\t\t (const uint8_t *)&rte_flow_item_udp_mask,\n+\t\t sizeof(struct rte_flow_item_udp), error);\n+\tif (ret < 0)\n+\t\treturn ret;\n+\tflow->layers |= MLX5_FLOW_LAYER_OUTER_L4_UDP;\n+\tif (size > flow_size)\n+\t\treturn size;\n+\tif (spec) {\n+\t\tudp.val.dst_port = spec->hdr.dst_port;\n+\t\tudp.val.src_port = spec->hdr.src_port;\n+\t\tudp.mask.dst_port = mask->hdr.dst_port;\n+\t\tudp.mask.src_port = mask->hdr.src_port;\n+\t\t/* Remove unwanted bits from values. */\n+\t\tudp.val.src_port &= udp.mask.src_port;\n+\t\tudp.val.dst_port &= udp.mask.dst_port;\n+\t}\n+\tmlx5_flow_spec_verbs_add(flow, &udp, size);\n \treturn size;\n }\n \n@@ -756,6 +838,9 @@ mlx5_flow_items(const struct rte_flow_item pattern[],\n \t\tcase RTE_FLOW_ITEM_TYPE_IPV6:\n \t\t\tret = mlx5_flow_item_ipv6(pattern, flow, remain, error);\n \t\t\tbreak;\n+\t\tcase RTE_FLOW_ITEM_TYPE_UDP:\n+\t\t\tret = mlx5_flow_item_udp(pattern, flow, remain, error);\n+\t\t\tbreak;\n \t\tdefault:\n \t\t\treturn rte_flow_error_set(error, ENOTSUP,\n \t\t\t\t\t\t  RTE_FLOW_ERROR_TYPE_ITEM,\n",
    "prefixes": [
        "v4",
        "10/21"
    ]
}