Show a patch.

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

{
    "id": 42961,
    "url": "http://patches.dpdk.org/api/patches/42961/",
    "web_url": "http://patches.dpdk.org/patch/42961/",
    "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": "<ca3c660f70689b6eee77e3d13198eedfea840ec6.1531387413.git.nelio.laranjeiro@6wind.com>",
    "date": "2018-07-12T09:31:00",
    "name": "[v4,14/21] net/mlx5: add RSS flow action",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "6643e304eb06986bfcbc70a3b005cb033d2dd0c4",
    "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/42961/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/42961/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/42961/checks/",
    "tags": {},
    "headers": {
        "X-Mailman-Version": "2.1.15",
        "In-Reply-To": "<cover.1531387413.git.nelio.laranjeiro@6wind.com>",
        "Errors-To": "dev-bounces@dpdk.org",
        "X-Mailer": "git-send-email 2.18.0",
        "Received": [
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 006B31B642;\n\tThu, 12 Jul 2018 11:32:00 +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 8EB211B5A2\n\tfor <dev@dpdk.org>; Thu, 12 Jul 2018 11:31:37 +0200 (CEST)",
            "by mail-wm0-f68.google.com with SMTP id z13-v6so5288495wma.5\n\tfor <dev@dpdk.org>; Thu, 12 Jul 2018 02:31:37 -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.36\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tThu, 12 Jul 2018 02:31:36 -0700 (PDT)"
        ],
        "References": "<cover.1531293415.git.nelio.laranjeiro@6wind.com>\n\t<cover.1531387413.git.nelio.laranjeiro@6wind.com>",
        "X-Google-Smtp-Source": "AAOMgpdcEf8R+9fUHUaR60PQ/Jlf9lHSPpn8fAg3nXUSwpmW459Aij8OgTcuS6ePFztUl1tDl/NOqw==",
        "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=VDaYWt6LWnDDBh63e54oqX1qEkdHy6dBxk+xl+NZ1ek=;\n\tb=k2jDd9dkThi8Pj83tcgZZ2h3kZBC6S4/BLJ7plg5M6TgTJcVEdpXchCpf8jKGICpLf\n\tE/XOu3ZOZ8xm26vqJUjz42LdrtaMs+pSkhpTVIhsFPn2axwhoCH2mlNSdtWjvgNBSRGn\n\typpeRK8DSgP3qwuqg4W7sNzXI+6o6ix+CINtzU3XpdJeCrensWdlxowG8FUSrxWqGnJL\n\t9PN/eA2UJf1ghXl6fasmHMk2hpEfp8QIW7HTLUijdtHdl56fvRPOBjCBBO1aogZj7lQt\n\tAKwoRxDAORjA0s2uYLNZtwvx8p0S0QSVCC3G13TTv6ZUPjAeSjB2npQzI+WJhN8RGEE2\n\tQlIg==",
        "X-BeenThere": "dev@dpdk.org",
        "X-Received": "by 2002:a1c:69c6:: with SMTP id\n\tz67-v6mr811991wmh.159.1531387896965; \n\tThu, 12 Jul 2018 02:31:36 -0700 (PDT)",
        "Message-Id": "<ca3c660f70689b6eee77e3d13198eedfea840ec6.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=VDaYWt6LWnDDBh63e54oqX1qEkdHy6dBxk+xl+NZ1ek=;\n\tb=t8Xwdt3WQX4nrXdJKDxC8D6nf+taax+JaVSpXVtkPN/9g3+gqSiRAFn09HquNJIs6V\n\tqya+ynvA83VBEPEF+wi8xHLjSsCZP0OQU2ya7fZtSgD3io35QzCWKc0N6MR2LXiDDPa+\n\tHwc0Kqh/67Bb2uYRtSozm3Vrkkg6kyFw+ypJVU6gr9FRB/A7Qvdd1cnHiLpLu4G2c64Y\n\tjp+aOKUhk6pXq7YPTMn/dNjbgl/RJzoOfv3ukaBdwUxqlDQjOhGfJpInTPQwuT0Ez0I8\n\tiUD1aeMPLq8hFdZ7ZJW2ng5ZpWW1CG2QT82/WznHkZo4XL8+c3nWdzKc0CEhMuh5AqbX\n\tXoXA==",
        "Delivered-To": "patchwork@dpdk.org",
        "Precedence": "list",
        "From": "Nelio Laranjeiro <nelio.laranjeiro@6wind.com>",
        "X-Original-To": "patchwork@dpdk.org",
        "List-Post": "<mailto:dev@dpdk.org>",
        "Return-Path": "<dev-bounces@dpdk.org>",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "To": "dev@dpdk.org,\n\tYongseok Koh <yskoh@mellanox.com>",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "Date": "Thu, 12 Jul 2018 11:31:00 +0200",
        "X-Gm-Message-State": "AOUpUlF+mMzw+4UogDAdW7AJU5r/KxgtbcLRMqrEXPprYydBd+WSGk9w\n\tKCNMKmjJ33fs9lDzTLVlDOKItZGHpA==",
        "Cc": "Adrien Mazarguil <adrien.mazarguil@6wind.com>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "Subject": "[dpdk-dev] [PATCH v4 14/21] net/mlx5: add RSS flow action"
    },
    "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 | 686 +++++++++++++++++++++++++++--------\n 1 file changed, 541 insertions(+), 145 deletions(-)",
    "diff": "diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c\nindex 77483bd1f..758c611a6 100644\n--- a/drivers/net/mlx5/mlx5_flow.c\n+++ b/drivers/net/mlx5/mlx5_flow.c\n@@ -51,6 +51,7 @@ extern const struct eth_dev_ops mlx5_dev_ops_isolate;\n /* Actions that modify the fate of matching traffic. */\n #define MLX5_FLOW_FATE_DROP (1u << 0)\n #define MLX5_FLOW_FATE_QUEUE (1u << 1)\n+#define MLX5_FLOW_FATE_RSS (1u << 2)\n \n /* Modify a packet. */\n #define MLX5_FLOW_MOD_FLAG (1u << 0)\n@@ -60,8 +61,68 @@ extern const struct eth_dev_ops mlx5_dev_ops_isolate;\n #define MLX5_IP_PROTOCOL_TCP 6\n #define MLX5_IP_PROTOCOL_UDP 17\n \n+/* Priority reserved for default flows. */\n+#define MLX5_FLOW_PRIO_RSVD ((uint32_t)-1)\n+\n+enum mlx5_expansion {\n+\tMLX5_EXPANSION_ROOT,\n+\tMLX5_EXPANSION_ETH,\n+\tMLX5_EXPANSION_IPV4,\n+\tMLX5_EXPANSION_IPV4_UDP,\n+\tMLX5_EXPANSION_IPV4_TCP,\n+\tMLX5_EXPANSION_IPV6,\n+\tMLX5_EXPANSION_IPV6_UDP,\n+\tMLX5_EXPANSION_IPV6_TCP,\n+};\n+\n+/** Supported expansion of items. */\n+static const struct rte_flow_expand_node mlx5_support_expansion[] = {\n+\t[MLX5_EXPANSION_ROOT] = {\n+\t\t.next = RTE_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_ETH,\n+\t\t\t\t\t\t MLX5_EXPANSION_IPV4,\n+\t\t\t\t\t\t MLX5_EXPANSION_IPV6),\n+\t\t.type = RTE_FLOW_ITEM_TYPE_END,\n+\t},\n+\t[MLX5_EXPANSION_ETH] = {\n+\t\t.next = RTE_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_IPV4,\n+\t\t\t\t\t\t MLX5_EXPANSION_IPV6),\n+\t\t.type = RTE_FLOW_ITEM_TYPE_ETH,\n+\t},\n+\t[MLX5_EXPANSION_IPV4] = {\n+\t\t.next = RTE_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_IPV4_UDP,\n+\t\t\t\t\t\t MLX5_EXPANSION_IPV4_TCP),\n+\t\t.type = RTE_FLOW_ITEM_TYPE_IPV4,\n+\t\t.rss_types = ETH_RSS_IPV4 | ETH_RSS_FRAG_IPV4 |\n+\t\t\tETH_RSS_NONFRAG_IPV4_OTHER,\n+\t},\n+\t[MLX5_EXPANSION_IPV4_UDP] = {\n+\t\t.type = RTE_FLOW_ITEM_TYPE_UDP,\n+\t\t.rss_types = ETH_RSS_NONFRAG_IPV4_UDP,\n+\t},\n+\t[MLX5_EXPANSION_IPV4_TCP] = {\n+\t\t.type = RTE_FLOW_ITEM_TYPE_TCP,\n+\t\t.rss_types = ETH_RSS_NONFRAG_IPV4_TCP,\n+\t},\n+\t[MLX5_EXPANSION_IPV6] = {\n+\t\t.next = RTE_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_IPV6_UDP,\n+\t\t\t\t\t\t MLX5_EXPANSION_IPV6_TCP),\n+\t\t.type = RTE_FLOW_ITEM_TYPE_IPV6,\n+\t\t.rss_types = ETH_RSS_IPV6 | ETH_RSS_FRAG_IPV6 |\n+\t\t\tETH_RSS_NONFRAG_IPV6_OTHER,\n+\t},\n+\t[MLX5_EXPANSION_IPV6_UDP] = {\n+\t\t.type = RTE_FLOW_ITEM_TYPE_UDP,\n+\t\t.rss_types = ETH_RSS_NONFRAG_IPV6_UDP,\n+\t},\n+\t[MLX5_EXPANSION_IPV6_TCP] = {\n+\t\t.type = RTE_FLOW_ITEM_TYPE_TCP,\n+\t\t.rss_types = ETH_RSS_NONFRAG_IPV6_TCP,\n+\t},\n+};\n+\n /** Handles information leading to a drop fate. */\n struct mlx5_flow_verbs {\n+\tLIST_ENTRY(mlx5_flow_verbs) next;\n \tunsigned int size; /**< Size of the attribute. */\n \tstruct {\n \t\tstruct ibv_flow_attr *attr;\n@@ -70,6 +131,7 @@ struct mlx5_flow_verbs {\n \t};\n \tstruct ibv_flow *flow; /**< Verbs flow pointer. */\n \tstruct mlx5_hrxq *hrxq; /**< Hash Rx queue object. */\n+\tuint64_t hash_fields; /**< Verbs hash Rx queue hash fields. */\n };\n \n /* Flow structure. */\n@@ -84,8 +146,12 @@ struct rte_flow {\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+\tLIST_HEAD(verbs, mlx5_flow_verbs) verbs; /**< Verbs flows list. */\n+\tstruct mlx5_flow_verbs *cur_verbs;\n+\t/**< Current Verbs flow structure being filled. */\n+\tstruct rte_flow_action_rss rss;/**< RSS context. */\n+\tuint8_t key[MLX5_RSS_HASH_KEY_LEN]; /**< RSS hash key. */\n+\tuint16_t (*queue)[]; /**< Destination queues to redirect traffic to. */\n };\n \n static const struct rte_flow_ops mlx5_flow_ops = {\n@@ -128,16 +194,38 @@ struct ibv_spec_header {\n \tuint16_t size;\n };\n \n- /**\n-  * Discover the maximum number of priority available.\n-  *\n-  * @param[in] dev\n-  *   Pointer to Ethernet device.\n-  *\n-  * @return\n-  *   number of supported flow priority on success, a negative errno value\n-  *   otherwise and rte_errno is set.\n-  */\n+/*\n+ * Number of sub priorities.\n+ * For each kind of pattern matching i.e. L2, L3, L4 to have a correct\n+ * matching on the NIC (firmware dependent) L4 most have the higher priority\n+ * followed by L3 and ending with L2.\n+ */\n+#define MLX5_PRIORITY_MAP_L2 2\n+#define MLX5_PRIORITY_MAP_L3 1\n+#define MLX5_PRIORITY_MAP_L4 0\n+#define MLX5_PRIORITY_MAP_MAX 3\n+\n+/* Map of Verbs to Flow priority with 8 Verbs priorities. */\n+static const uint32_t priority_map_3[][MLX5_PRIORITY_MAP_MAX] = {\n+\t{ 0, 1, 2 }, { 2, 3, 4 }, { 5, 6, 7 },\n+};\n+\n+/* Map of Verbs to Flow priority with 16 Verbs priorities. */\n+static const uint32_t priority_map_5[][MLX5_PRIORITY_MAP_MAX] = {\n+\t{ 0, 1, 2 }, { 3, 4, 5 }, { 6, 7, 8 },\n+\t{ 9, 10, 11 }, { 12, 13, 14 },\n+};\n+\n+/**\n+ * Discover the maximum number of priority available.\n+ *\n+ * @param[in] dev\n+ *   Pointer to Ethernet device.\n+ *\n+ * @return\n+ *   number of supported flow priority on success, a negative errno\n+ *   value otherwise and rte_errno is set.\n+ */\n int\n mlx5_flow_discover_priorities(struct rte_eth_dev *dev)\n {\n@@ -162,6 +250,7 @@ mlx5_flow_discover_priorities(struct rte_eth_dev *dev)\n \tstruct mlx5_hrxq *drop = mlx5_hrxq_drop_new(dev);\n \tuint16_t vprio[] = { 8, 16 };\n \tint i;\n+\tint priority = 0;\n \n \tif (!drop) {\n \t\trte_errno = ENOTSUP;\n@@ -173,11 +262,52 @@ mlx5_flow_discover_priorities(struct rte_eth_dev *dev)\n \t\tif (!flow)\n \t\t\tbreak;\n \t\tclaim_zero(mlx5_glue->destroy_flow(flow));\n+\t\tpriority = vprio[i];\n+\t}\n+\tswitch (priority) {\n+\tcase 8:\n+\t\tpriority = RTE_DIM(priority_map_3);\n+\t\tbreak;\n+\tcase 16:\n+\t\tpriority = RTE_DIM(priority_map_5);\n+\t\tbreak;\n+\tdefault:\n+\t\trte_errno = ENOTSUP;\n+\t\tDRV_LOG(ERR,\n+\t\t\t\"port %u verbs maximum priority: %d expected 8/16\",\n+\t\t\tdev->data->port_id, vprio[i]);\n+\t\treturn -rte_errno;\n \t}\n \tmlx5_hrxq_drop_release(dev);\n \tDRV_LOG(INFO, \"port %u flow maximum priority: %d\",\n-\t\tdev->data->port_id, vprio[i - 1]);\n-\treturn vprio[i - 1];\n+\t\tdev->data->port_id, priority);\n+\treturn priority;\n+}\n+\n+/**\n+ * Adjust flow priority.\n+ *\n+ * @param dev\n+ *   Pointer to Ethernet device.\n+ * @param flow\n+ *   Pointer to an rte flow.\n+ */\n+static void\n+mlx5_flow_adjust_priority(struct rte_eth_dev *dev, struct rte_flow *flow)\n+{\n+\tstruct priv *priv = dev->data->dev_private;\n+\tuint32_t priority = flow->attributes.priority;\n+\tuint32_t subpriority = flow->cur_verbs->attr->priority;\n+\n+\tswitch (priv->config.flow_prio) {\n+\tcase RTE_DIM(priority_map_3):\n+\t\tpriority = priority_map_3[priority][subpriority];\n+\t\tbreak;\n+\tcase RTE_DIM(priority_map_5):\n+\t\tpriority = priority_map_5[priority][subpriority];\n+\t\tbreak;\n+\t}\n+\tflow->cur_verbs->attr->priority = priority;\n }\n \n /**\n@@ -203,14 +333,15 @@ mlx5_flow_attributes(struct rte_eth_dev *dev,\n \t\t     struct rte_flow_error *error)\n {\n \tuint32_t priority_max =\n-\t\t((struct priv *)dev->data->dev_private)->config.flow_prio;\n+\t\t((struct priv *)dev->data->dev_private)->config.flow_prio - 1;\n \n \tif (attributes->group)\n \t\treturn rte_flow_error_set(error, ENOTSUP,\n \t\t\t\t\t  RTE_FLOW_ERROR_TYPE_ATTR_GROUP,\n \t\t\t\t\t  NULL,\n \t\t\t\t\t  \"groups is not supported\");\n-\tif (attributes->priority >= priority_max)\n+\tif (attributes->priority != MLX5_FLOW_PRIO_RSVD &&\n+\t    attributes->priority >= priority_max)\n \t\treturn rte_flow_error_set(error, ENOTSUP,\n \t\t\t\t\t  RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY,\n \t\t\t\t\t  NULL,\n@@ -231,6 +362,8 @@ mlx5_flow_attributes(struct rte_eth_dev *dev,\n \t\t\t\t\t  NULL,\n \t\t\t\t\t  \"ingress attribute is mandatory\");\n \tflow->attributes = *attributes;\n+\tif (attributes->priority == MLX5_FLOW_PRIO_RSVD)\n+\t\tflow->attributes.priority = priority_max;\n \treturn 0;\n }\n \n@@ -296,7 +429,7 @@ mlx5_flow_item_acceptable(const struct rte_flow_item *item,\n }\n \n /**\n- * Add a verbs specification into @p flow.\n+ * Add a verbs item specification into @p flow.\n  *\n  * @param[in, out] flow\n  *   Pointer to flow structure.\n@@ -308,14 +441,16 @@ mlx5_flow_item_acceptable(const struct rte_flow_item *item,\n static void\n mlx5_flow_spec_verbs_add(struct rte_flow *flow, void *src, unsigned int size)\n {\n-\tif (flow->verbs.specs) {\n+\tstruct mlx5_flow_verbs *verbs = flow->cur_verbs;\n+\n+\tif (verbs->specs) {\n \t\tvoid *dst;\n \n-\t\tdst = (void *)(flow->verbs.specs + flow->verbs.size);\n+\t\tdst = (void *)(verbs->specs + verbs->size);\n \t\tmemcpy(dst, src, size);\n-\t\t++flow->verbs.attr->num_of_specs;\n+\t\t++verbs->attr->num_of_specs;\n \t}\n-\tflow->verbs.size += size;\n+\tverbs->size += size;\n }\n \n /**\n@@ -390,6 +525,7 @@ mlx5_flow_item_eth(const struct rte_flow_item *item, struct rte_flow *flow,\n \t\t}\n \t\teth.val.ether_type &= eth.mask.ether_type;\n \t}\n+\tflow->cur_verbs->attr->priority = MLX5_PRIORITY_MAP_L2;\n \tmlx5_flow_spec_verbs_add(flow, &eth, size);\n \treturn size;\n }\n@@ -460,6 +596,7 @@ mlx5_flow_item_vlan(const struct rte_flow_item *item, struct rte_flow *flow,\n \t\t.inner_type = RTE_BE16(0xffff),\n \t};\n \tunsigned int size = sizeof(struct ibv_flow_spec_eth);\n+\tstruct mlx5_flow_verbs *verbs = flow->cur_verbs;\n \tstruct ibv_flow_spec_eth eth = {\n \t\t.type = IBV_FLOW_SPEC_ETH,\n \t\t.size = size,\n@@ -506,15 +643,16 @@ mlx5_flow_item_vlan(const struct rte_flow_item *item, struct rte_flow *flow,\n \t\t\t\t\t  item->spec,\n \t\t\t\t\t  \"VLAN cannot be empty\");\n \tif (!(flow->layers & l2m)) {\n-\t\tif (size <= flow_size)\n+\t\tif (size <= flow_size) {\n+\t\t\tflow->cur_verbs->attr->priority = MLX5_PRIORITY_MAP_L2;\n \t\t\tmlx5_flow_spec_verbs_add(flow, &eth, size);\n+\t\t}\n \t} else {\n-\t\tif (flow->verbs.attr)\n-\t\t\tmlx5_flow_item_vlan_update(flow->verbs.attr, &eth);\n+\t\tif (verbs->attr)\n+\t\t\tmlx5_flow_item_vlan_update(verbs->attr, &eth);\n \t\tsize = 0; /* Only an update is done in eth specification. */\n \t}\n-\tflow->layers |= MLX5_FLOW_LAYER_OUTER_L2 |\n-\t\tMLX5_FLOW_LAYER_OUTER_VLAN;\n+\tflow->layers |= MLX5_FLOW_LAYER_OUTER_L2 | MLX5_FLOW_LAYER_OUTER_VLAN;\n \treturn size;\n }\n \n@@ -601,8 +739,18 @@ mlx5_flow_item_ipv4(const struct rte_flow_item *item, struct rte_flow *flow,\n \t}\n \tflow->l3_protocol_en = !!ipv4.mask.proto;\n \tflow->l3_protocol = ipv4.val.proto;\n-\tif (size <= flow_size)\n+\tif (size <= flow_size) {\n+\t\tuint64_t hash_fields = IBV_RX_HASH_SRC_IPV4 |\n+\t\t\tIBV_RX_HASH_DST_IPV4;\n+\n+\t\tif (!(flow->rss.types &\n+\t\t      (ETH_RSS_IPV4 | ETH_RSS_FRAG_IPV4 |\n+\t\t       ETH_RSS_NONFRAG_IPV4_OTHER)))\n+\t\t\thash_fields = 0;\n+\t\tflow->cur_verbs->hash_fields |= hash_fields;\n+\t\tflow->cur_verbs->attr->priority = MLX5_PRIORITY_MAP_L3;\n \t\tmlx5_flow_spec_verbs_add(flow, &ipv4, size);\n+\t}\n \treturn size;\n }\n \n@@ -714,8 +862,17 @@ mlx5_flow_item_ipv6(const struct rte_flow_item *item, struct rte_flow *flow,\n \t}\n \tflow->l3_protocol_en = !!ipv6.mask.next_hdr;\n \tflow->l3_protocol = ipv6.val.next_hdr;\n-\tif (size <= flow_size)\n+\tif (size <= flow_size) {\n+\t\tuint64_t hash_fields = IBV_RX_HASH_SRC_IPV6 |\n+\t\t\tIBV_RX_HASH_DST_IPV6;\n+\n+\t\tif (!(flow->rss.types &\n+\t\t      (ETH_RSS_IPV6 | ETH_RSS_NONFRAG_IPV6_OTHER)))\n+\t\t\thash_fields = 0;\n+\t\tflow->cur_verbs->hash_fields |= hash_fields;\n+\t\tflow->cur_verbs->attr->priority = MLX5_PRIORITY_MAP_L3;\n \t\tmlx5_flow_spec_verbs_add(flow, &ipv6, size);\n+\t}\n \treturn size;\n }\n \n@@ -754,22 +911,24 @@ mlx5_flow_item_udp(const struct rte_flow_item *item, struct rte_flow *flow,\n \t};\n \tint ret;\n \n-\tif (!(flow->layers & MLX5_FLOW_LAYER_OUTER_L3))\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  \"L3 is mandatory to filter on L4\");\n-\tif (flow->layers & MLX5_FLOW_LAYER_OUTER_L4)\n+\t\t\t\t\t  \"protocol filtering not compatible\"\n+\t\t\t\t\t  \" with UDP layer\");\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  \"L4 layer is already present\");\n-\tif (flow->l3_protocol_en && flow->l3_protocol != MLX5_IP_PROTOCOL_UDP)\n+\t\t\t\t\t  \"L3 is mandatory to filter\"\n+\t\t\t\t\t  \" 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  \"protocol filtering not compatible\"\n-\t\t\t\t\t  \" with UDP layer\");\n+\t\t\t\t\t  \"L4 layer is already\"\n+\t\t\t\t\t  \" present\");\n \tif (!mask)\n \t\tmask = &rte_flow_item_udp_mask;\n \tret = mlx5_flow_item_acceptable\n@@ -779,8 +938,6 @@ mlx5_flow_item_udp(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_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@@ -790,7 +947,16 @@ mlx5_flow_item_udp(const struct rte_flow_item *item, struct rte_flow *flow,\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+\tif (size <= flow_size) {\n+\t\tuint64_t hash_fields = IBV_RX_HASH_SRC_PORT_UDP |\n+\t\t\tIBV_RX_HASH_DST_PORT_UDP;\n+\n+\t\tif (!(flow->rss.types & ETH_RSS_UDP))\n+\t\t\thash_fields = 0;\n+\t\tflow->cur_verbs->hash_fields |= hash_fields;\n+\t\tflow->cur_verbs->attr->priority = MLX5_PRIORITY_MAP_L4;\n+\t\tmlx5_flow_spec_verbs_add(flow, &udp, size);\n+\t}\n \treturn size;\n }\n \n@@ -854,8 +1020,6 @@ mlx5_flow_item_tcp(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_L4_TCP;\n-\tif (size > flow_size)\n-\t\treturn size;\n \tif (spec) {\n \t\ttcp.val.dst_port = spec->hdr.dst_port;\n \t\ttcp.val.src_port = spec->hdr.src_port;\n@@ -865,7 +1029,16 @@ mlx5_flow_item_tcp(const struct rte_flow_item *item, struct rte_flow *flow,\n \t\ttcp.val.src_port &= tcp.mask.src_port;\n \t\ttcp.val.dst_port &= tcp.mask.dst_port;\n \t}\n-\tmlx5_flow_spec_verbs_add(flow, &tcp, size);\n+\tif (size <= flow_size) {\n+\t\tuint64_t hash_fields = IBV_RX_HASH_SRC_PORT_TCP |\n+\t\t\tIBV_RX_HASH_DST_PORT_TCP;\n+\n+\t\tif (!(flow->rss.types & ETH_RSS_TCP))\n+\t\t\thash_fields = 0;\n+\t\tflow->cur_verbs->hash_fields |= hash_fields;\n+\t\tflow->cur_verbs->attr->priority = MLX5_PRIORITY_MAP_L4;\n+\t\tmlx5_flow_spec_verbs_add(flow, &tcp, size);\n+\t}\n \treturn size;\n }\n \n@@ -1043,11 +1216,95 @@ mlx5_flow_action_queue(struct rte_eth_dev *dev,\n \t\t\t\t\t  RTE_FLOW_ERROR_TYPE_ACTION_CONF,\n \t\t\t\t\t  &queue->index,\n \t\t\t\t\t  \"queue is not configured\");\n-\tflow->queue = queue->index;\n+\tif (flow->queue)\n+\t\t(*flow->queue)[0] = queue->index;\n+\tflow->rss.queue_num = 1;\n \tflow->fate |= MLX5_FLOW_FATE_QUEUE;\n \treturn 0;\n }\n \n+/**\n+ * Ensure the @p action will be understood and used correctly by the  NIC.\n+ *\n+ * @param dev\n+ *   Pointer to Ethernet device structure.\n+ * @param action[in]\n+ *   Pointer to flow actions array.\n+ * @param flow[in, out]\n+ *   Pointer to the rte_flow structure.\n+ * @param error[in, out]\n+ *   Pointer to error structure.\n+ *\n+ * @return\n+ *   On success @p flow->queue array and @p flow->rss are filled and valid.\n+ *   On error, a negative errno value is returned and rte_errno is set.\n+ */\n+static int\n+mlx5_flow_action_rss(struct rte_eth_dev *dev,\n+\t\t     const struct rte_flow_action *action,\n+\t\t     struct rte_flow *flow,\n+\t\t     struct rte_flow_error *error)\n+{\n+\tstruct priv *priv = dev->data->dev_private;\n+\tconst struct rte_flow_action_rss *rss = action->conf;\n+\tunsigned int i;\n+\n+\tif (flow->fate)\n+\t\treturn rte_flow_error_set(error, ENOTSUP,\n+\t\t\t\t\t  RTE_FLOW_ERROR_TYPE_ACTION,\n+\t\t\t\t\t  action,\n+\t\t\t\t\t  \"multiple fate actions are not\"\n+\t\t\t\t\t  \" supported\");\n+\tif (rss->func != RTE_ETH_HASH_FUNCTION_DEFAULT &&\n+\t    rss->func != RTE_ETH_HASH_FUNCTION_TOEPLITZ)\n+\t\treturn rte_flow_error_set(error, ENOTSUP,\n+\t\t\t\t\t  RTE_FLOW_ERROR_TYPE_ACTION_CONF,\n+\t\t\t\t\t  &rss->func,\n+\t\t\t\t\t  \"RSS hash function not supported\");\n+\tif (rss->level > 1)\n+\t\treturn rte_flow_error_set(error, ENOTSUP,\n+\t\t\t\t\t  RTE_FLOW_ERROR_TYPE_ACTION_CONF,\n+\t\t\t\t\t  &rss->level,\n+\t\t\t\t\t  \"tunnel RSS is not supported\");\n+\tif (rss->key_len < MLX5_RSS_HASH_KEY_LEN)\n+\t\treturn rte_flow_error_set(error, ENOTSUP,\n+\t\t\t\t\t  RTE_FLOW_ERROR_TYPE_ACTION_CONF,\n+\t\t\t\t\t  &rss->key_len,\n+\t\t\t\t\t  \"RSS hash key too small\");\n+\tif (rss->key_len > MLX5_RSS_HASH_KEY_LEN)\n+\t\treturn rte_flow_error_set(error, ENOTSUP,\n+\t\t\t\t\t  RTE_FLOW_ERROR_TYPE_ACTION_CONF,\n+\t\t\t\t\t  &rss->key_len,\n+\t\t\t\t\t  \"RSS hash key too large\");\n+\tif (rss->queue_num > priv->config.ind_table_max_size)\n+\t\treturn rte_flow_error_set(error, ENOTSUP,\n+\t\t\t\t\t  RTE_FLOW_ERROR_TYPE_ACTION_CONF,\n+\t\t\t\t\t  &rss->queue_num,\n+\t\t\t\t\t  \"number of queues too large\");\n+\tif (rss->types & MLX5_RSS_HF_MASK)\n+\t\treturn rte_flow_error_set(error, ENOTSUP,\n+\t\t\t\t\t  RTE_FLOW_ERROR_TYPE_ACTION_CONF,\n+\t\t\t\t\t  &rss->types,\n+\t\t\t\t\t  \"some RSS protocols are not\"\n+\t\t\t\t\t  \" supported\");\n+\tfor (i = 0; i != rss->queue_num; ++i) {\n+\t\tif (!(*priv->rxqs)[rss->queue[i]])\n+\t\t\treturn rte_flow_error_set\n+\t\t\t\t(error, EINVAL,\n+\t\t\t\t RTE_FLOW_ERROR_TYPE_ACTION_CONF,\n+\t\t\t\t &rss->queue[i],\n+\t\t\t\t \"queue is not configured\");\n+\t}\n+\tif (flow->queue)\n+\t\tmemcpy((*flow->queue), rss->queue,\n+\t\t       rss->queue_num * sizeof(uint16_t));\n+\tflow->rss.queue_num = rss->queue_num;\n+\tmemcpy(flow->key, rss->key, MLX5_RSS_HASH_KEY_LEN);\n+\tflow->rss.types = rss->types;\n+\tflow->fate |= MLX5_FLOW_FATE_RSS;\n+\treturn 0;\n+}\n+\n /**\n  * Convert the @p action into a Verbs specification after ensuring the NIC\n  * will understand and process it correctly.\n@@ -1082,6 +1339,7 @@ mlx5_flow_action_flag(const struct rte_flow_action *action,\n \t\t.size = size,\n \t\t.tag_id = mlx5_flow_mark_set(MLX5_FLOW_MARK_DEFAULT),\n \t};\n+\tstruct mlx5_flow_verbs *verbs = flow->cur_verbs;\n \n \tif (flow->modifier & MLX5_FLOW_MOD_FLAG)\n \t\treturn rte_flow_error_set(error, ENOTSUP,\n@@ -1095,32 +1353,34 @@ mlx5_flow_action_flag(const struct rte_flow_action *action,\n \t\t\t\t\t  \"flag is not compatible with drop\"\n \t\t\t\t\t  \" action\");\n \tif (flow->modifier & MLX5_FLOW_MOD_MARK)\n-\t\treturn 0;\n-\tflow->modifier |= MLX5_FLOW_MOD_FLAG;\n-\tif (size <= flow_size)\n+\t\tsize = 0;\n+\telse if (size <= flow_size && verbs)\n \t\tmlx5_flow_spec_verbs_add(flow, &tag, size);\n+\tflow->modifier |= MLX5_FLOW_MOD_FLAG;\n \treturn size;\n }\n \n /**\n  * Update verbs specification to modify the flag to mark.\n  *\n- * @param[in, out] flow\n- *   Pointer to the rte_flow structure.\n+ * @param[in, out] verbs\n+ *   Pointer to the mlx5_flow_verbs structure.\n  * @param[in] mark_id\n  *   Mark identifier to replace the flag.\n  */\n static void\n-mlx5_flow_verbs_mark_update(struct rte_flow *flow, uint32_t mark_id)\n+mlx5_flow_verbs_mark_update(struct mlx5_flow_verbs *verbs, uint32_t mark_id)\n {\n \tstruct ibv_spec_header *hdr;\n \tint i;\n \n+\tif (!verbs)\n+\t\treturn;\n \t/* Update Verbs specification. */\n-\thdr = (struct ibv_spec_header *)flow->verbs.specs;\n+\thdr = (struct ibv_spec_header *)verbs->specs;\n \tif (!hdr)\n \t\treturn;\n-\tfor (i = 0; i != flow->verbs.attr->num_of_specs; ++i) {\n+\tfor (i = 0; i != verbs->attr->num_of_specs; ++i) {\n \t\tif (hdr->type == IBV_FLOW_SPEC_ACTION_TAG) {\n \t\t\tstruct ibv_flow_spec_action_tag *t =\n \t\t\t\t(struct ibv_flow_spec_action_tag *)hdr;\n@@ -1166,6 +1426,7 @@ mlx5_flow_action_mark(const struct rte_flow_action *action,\n \t\t.type = IBV_FLOW_SPEC_ACTION_TAG,\n \t\t.size = size,\n \t};\n+\tstruct mlx5_flow_verbs *verbs = flow->cur_verbs;\n \n \tif (!mark)\n \t\treturn rte_flow_error_set(error, EINVAL,\n@@ -1190,14 +1451,11 @@ mlx5_flow_action_mark(const struct rte_flow_action *action,\n \t\t\t\t\t  \"mark is not compatible with drop\"\n \t\t\t\t\t  \" action\");\n \tif (flow->modifier & MLX5_FLOW_MOD_FLAG) {\n-\t\tmlx5_flow_verbs_mark_update(flow, mark->id);\n-\t\tsize = 0; /**< Only an update is done in the specification. */\n-\t} else {\n+\t\tmlx5_flow_verbs_mark_update(verbs, mark->id);\n+\t\tsize = 0;\n+\t} else if (size <= flow_size) {\n \t\ttag.tag_id = mlx5_flow_mark_set(mark->id);\n-\t\tif (size <= flow_size) {\n-\t\t\ttag.tag_id = mlx5_flow_mark_set(mark->id);\n-\t\t\tmlx5_flow_spec_verbs_add(flow, &tag, size);\n-\t\t}\n+\t\tmlx5_flow_spec_verbs_add(flow, &tag, size);\n \t}\n \tflow->modifier |= MLX5_FLOW_MOD_MARK;\n \treturn size;\n@@ -1259,6 +1517,9 @@ mlx5_flow_actions(struct rte_eth_dev *dev,\n \t\tcase RTE_FLOW_ACTION_TYPE_QUEUE:\n \t\t\tret = mlx5_flow_action_queue(dev, actions, flow, error);\n \t\t\tbreak;\n+\t\tcase RTE_FLOW_ACTION_TYPE_RSS:\n+\t\t\tret = mlx5_flow_action_rss(dev, actions, flow, 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_ACTION,\n@@ -1322,26 +1583,126 @@ mlx5_flow_merge(struct rte_eth_dev *dev, struct rte_flow *flow,\n \t\tstruct rte_flow_error *error)\n {\n \tstruct rte_flow local_flow = { .layers = 0, };\n-\tsize_t size = sizeof(*flow) + sizeof(struct ibv_flow_attr);\n-\tint remain = (flow_size > size) ? flow_size - size : 0;\n+\tsize_t size = sizeof(*flow);\n+\tunion {\n+\t\tstruct rte_flow_expand_rss buf;\n+\t\tuint8_t buffer[2048];\n+\t} expand_buffer;\n+\tstruct rte_flow_expand_rss *buf = &expand_buffer.buf;\n+\tstruct mlx5_flow_verbs *original_verbs = NULL;\n+\tsize_t original_verbs_size = 0;\n+\tuint32_t original_layers = 0;\n+\tint expanded_pattern_idx = 0;\n \tint ret;\n+\tuint32_t i;\n \n-\tif (!remain)\n+\tif (size > flow_size)\n \t\tflow = &local_flow;\n \tret = mlx5_flow_attributes(dev, attributes, flow, error);\n \tif (ret < 0)\n \t\treturn ret;\n-\tret = mlx5_flow_items(pattern, flow, remain, error);\n-\tif (ret < 0)\n-\t\treturn ret;\n-\tsize += ret;\n-\tremain = (flow_size > size) ? flow_size - size : 0;\n-\tret = mlx5_flow_actions(dev, actions, flow, remain, error);\n+\tret = mlx5_flow_actions(dev, actions, &local_flow, 0, error);\n \tif (ret < 0)\n \t\treturn ret;\n-\tsize += ret;\n+\tif (local_flow.rss.types) {\n+\t\tret = rte_flow_expand_rss(buf, sizeof(expand_buffer.buffer),\n+\t\t\t\t\t  pattern, local_flow.rss.types,\n+\t\t\t\t\t  mlx5_support_expansion,\n+\t\t\t\t\t  MLX5_EXPANSION_ROOT);\n+\t\tassert(ret > 0 &&\n+\t\t       (unsigned int)ret < sizeof(expand_buffer.buffer));\n+\t} else {\n+\t\tbuf->entries = 1;\n+\t\tbuf->entry[0].pattern = (void *)(uintptr_t)pattern;\n+\t}\n+\tsize += RTE_ALIGN_CEIL(local_flow.rss.queue_num * sizeof(uint16_t),\n+\t\t\t       sizeof(void *));\n \tif (size <= flow_size)\n-\t\tflow->verbs.attr->priority = flow->attributes.priority;\n+\t\tflow->queue = (void *)(flow + 1);\n+\tLIST_INIT(&flow->verbs);\n+\tflow->layers = 0;\n+\tflow->modifier = 0;\n+\tflow->fate = 0;\n+\tfor (i = 0; i != buf->entries; ++i) {\n+\t\tsize_t off = size;\n+\t\tsize_t off2;\n+\n+\t\tflow->layers = original_layers;\n+\t\tsize += sizeof(struct ibv_flow_attr) +\n+\t\t\tsizeof(struct mlx5_flow_verbs);\n+\t\toff2 = size;\n+\t\tif (size < flow_size) {\n+\t\t\tflow->cur_verbs = (void *)((uintptr_t)flow + off);\n+\t\t\tflow->cur_verbs->attr = (void *)(flow->cur_verbs + 1);\n+\t\t\tflow->cur_verbs->specs =\n+\t\t\t\t(void *)(flow->cur_verbs->attr + 1);\n+\t\t}\n+\t\t/* First iteration convert the pattern into Verbs. */\n+\t\tif (i == 0) {\n+\t\t\t/* Actions don't need to be converted several time. */\n+\t\t\tret = mlx5_flow_actions(dev, actions, flow,\n+\t\t\t\t\t\t(size < flow_size) ?\n+\t\t\t\t\t\tflow_size - size : 0,\n+\t\t\t\t\t\terror);\n+\t\t\tif (ret < 0)\n+\t\t\t\treturn ret;\n+\t\t\tsize += ret;\n+\t\t} else {\n+\t\t\t/*\n+\t\t\t * Next iteration means the pattern has already been\n+\t\t\t * converted and an expansion is necessary to match\n+\t\t\t * the user RSS request.  For that only the expanded\n+\t\t\t * items will be converted, the common part with the\n+\t\t\t * user pattern are just copied into the next buffer\n+\t\t\t * zone.\n+\t\t\t */\n+\t\t\tsize += original_verbs_size;\n+\t\t\tif (size < flow_size) {\n+\t\t\t\trte_memcpy(flow->cur_verbs->attr,\n+\t\t\t\t\t   original_verbs->attr,\n+\t\t\t\t\t   original_verbs_size +\n+\t\t\t\t\t   sizeof(struct ibv_flow_attr));\n+\t\t\t\tflow->cur_verbs->size = original_verbs_size;\n+\t\t\t}\n+\t\t}\n+\t\tret = mlx5_flow_items\n+\t\t\t((const struct rte_flow_item *)\n+\t\t\t &buf->entry[i].pattern[expanded_pattern_idx],\n+\t\t\t flow,\n+\t\t\t (size < flow_size) ? flow_size - size : 0, error);\n+\t\tif (ret < 0)\n+\t\t\treturn ret;\n+\t\tsize += ret;\n+\t\tif (size <= flow_size) {\n+\t\t\tmlx5_flow_adjust_priority(dev, flow);\n+\t\t\tLIST_INSERT_HEAD(&flow->verbs, flow->cur_verbs, next);\n+\t\t}\n+\t\t/*\n+\t\t * Keep a pointer of the first verbs conversion and the layers\n+\t\t * it has encountered.\n+\t\t */\n+\t\tif (i == 0) {\n+\t\t\toriginal_verbs = flow->cur_verbs;\n+\t\t\toriginal_verbs_size = size - off2;\n+\t\t\toriginal_layers = flow->layers;\n+\t\t\t/*\n+\t\t\t * move the index of the expanded pattern to the\n+\t\t\t * first item not addressed yet.\n+\t\t\t */\n+\t\t\tif (pattern->type == RTE_FLOW_ITEM_TYPE_END) {\n+\t\t\t\texpanded_pattern_idx++;\n+\t\t\t} else {\n+\t\t\t\tconst struct rte_flow_item *item = pattern;\n+\n+\t\t\t\tfor (item = pattern;\n+\t\t\t\t     item->type != RTE_FLOW_ITEM_TYPE_END;\n+\t\t\t\t     ++item)\n+\t\t\t\t\texpanded_pattern_idx++;\n+\t\t\t}\n+\t\t}\n+\t}\n+\t/* Restore the origin layers in the flow. */\n+\tflow->layers = original_layers;\n \treturn size;\n }\n \n@@ -1359,12 +1720,17 @@ mlx5_flow_rxq_mark_set(struct rte_eth_dev *dev, struct rte_flow *flow)\n \tstruct priv *priv = dev->data->dev_private;\n \n \tif (flow->modifier & (MLX5_FLOW_MOD_FLAG | MLX5_FLOW_MOD_MARK)) {\n-\t\tstruct mlx5_rxq_ctrl *rxq_ctrl =\n-\t\t\tcontainer_of((*priv->rxqs)[flow->queue],\n-\t\t\t\t     struct mlx5_rxq_ctrl, rxq);\n+\t\tunsigned int i;\n+\n+\t\tfor (i = 0; i != flow->rss.queue_num; ++i) {\n+\t\t\tint idx = (*flow->queue)[i];\n+\t\t\tstruct mlx5_rxq_ctrl *rxq_ctrl =\n+\t\t\t\tcontainer_of((*priv->rxqs)[idx],\n+\t\t\t\t\t     struct mlx5_rxq_ctrl, rxq);\n \n-\t\trxq_ctrl->rxq.mark = 1;\n-\t\trxq_ctrl->flow_mark_n++;\n+\t\t\trxq_ctrl->rxq.mark = 1;\n+\t\t\trxq_ctrl->flow_mark_n++;\n+\t\t}\n \t}\n }\n \n@@ -1383,12 +1749,17 @@ mlx5_flow_rxq_mark_trim(struct rte_eth_dev *dev, struct rte_flow *flow)\n \tstruct priv *priv = dev->data->dev_private;\n \n \tif (flow->modifier & (MLX5_FLOW_MOD_FLAG | MLX5_FLOW_MOD_MARK)) {\n-\t\tstruct mlx5_rxq_ctrl *rxq_ctrl =\n-\t\t\tcontainer_of((*priv->rxqs)[flow->queue],\n-\t\t\t\t     struct mlx5_rxq_ctrl, rxq);\n+\t\tunsigned int i;\n+\n+\t\tfor (i = 0; i != flow->rss.queue_num; ++i) {\n+\t\t\tint idx = (*flow->queue)[i];\n+\t\t\tstruct mlx5_rxq_ctrl *rxq_ctrl =\n+\t\t\t\tcontainer_of((*priv->rxqs)[idx],\n+\t\t\t\t\t     struct mlx5_rxq_ctrl, rxq);\n \n-\t\trxq_ctrl->flow_mark_n--;\n-\t\trxq_ctrl->rxq.mark = !!rxq_ctrl->flow_mark_n;\n+\t\t\trxq_ctrl->flow_mark_n--;\n+\t\t\trxq_ctrl->rxq.mark = !!rxq_ctrl->flow_mark_n;\n+\t\t}\n \t}\n }\n \n@@ -1449,18 +1820,20 @@ mlx5_flow_validate(struct rte_eth_dev *dev,\n static void\n mlx5_flow_remove(struct rte_eth_dev *dev, struct rte_flow *flow)\n {\n-\tif (flow->fate & MLX5_FLOW_FATE_DROP) {\n-\t\tif (flow->verbs.flow) {\n-\t\t\tclaim_zero(mlx5_glue->destroy_flow(flow->verbs.flow));\n-\t\t\tflow->verbs.flow = NULL;\n+\tstruct mlx5_flow_verbs *verbs;\n+\n+\tLIST_FOREACH(verbs, &flow->verbs, next) {\n+\t\tif (verbs->flow) {\n+\t\t\tclaim_zero(mlx5_glue->destroy_flow(verbs->flow));\n+\t\t\tverbs->flow = NULL;\n+\t\t}\n+\t\tif (verbs->hrxq) {\n+\t\t\tif (flow->fate & MLX5_FLOW_FATE_DROP)\n+\t\t\t\tmlx5_hrxq_drop_release(dev);\n+\t\t\telse\n+\t\t\t\tmlx5_hrxq_release(dev, verbs->hrxq);\n+\t\t\tverbs->hrxq = NULL;\n \t\t}\n-\t}\n-\tif (flow->verbs.hrxq) {\n-\t\tif (flow->fate & MLX5_FLOW_FATE_DROP)\n-\t\t\tmlx5_hrxq_drop_release(dev);\n-\t\telse if (flow->fate & MLX5_FLOW_FATE_QUEUE)\n-\t\t\tmlx5_hrxq_release(dev, flow->verbs.hrxq);\n-\t\tflow->verbs.hrxq = NULL;\n \t}\n }\n \n@@ -1481,46 +1854,68 @@ static int\n mlx5_flow_apply(struct rte_eth_dev *dev, struct rte_flow *flow,\n \t\tstruct rte_flow_error *error)\n {\n-\tif (flow->fate & MLX5_FLOW_FATE_DROP) {\n-\t\tflow->verbs.hrxq = mlx5_hrxq_drop_new(dev);\n-\t\tif (!flow->verbs.hrxq)\n-\t\t\treturn rte_flow_error_set\n-\t\t\t\t(error, errno,\n-\t\t\t\t RTE_FLOW_ERROR_TYPE_UNSPECIFIED,\n-\t\t\t\t NULL,\n-\t\t\t\t \"cannot allocate Drop queue\");\n-\t} else if (flow->fate & MLX5_FLOW_FATE_QUEUE) {\n-\t\tstruct mlx5_hrxq *hrxq;\n-\n-\t\thrxq = mlx5_hrxq_get(dev, rss_hash_default_key,\n-\t\t\t\t     MLX5_RSS_HASH_KEY_LEN, 0,\n-\t\t\t\t     &flow->queue, 1, 0, 0);\n-\t\tif (!hrxq)\n-\t\t\thrxq = mlx5_hrxq_new(dev, rss_hash_default_key,\n-\t\t\t\t\t     MLX5_RSS_HASH_KEY_LEN, 0,\n-\t\t\t\t\t     &flow->queue, 1, 0, 0);\n-\t\tif (!hrxq)\n-\t\t\treturn rte_flow_error_set(error, rte_errno,\n-\t\t\t\t\tRTE_FLOW_ERROR_TYPE_UNSPECIFIED,\n-\t\t\t\t\tNULL,\n-\t\t\t\t\t\"cannot create flow\");\n-\t\tflow->verbs.hrxq = hrxq;\n-\t}\n-\tflow->verbs.flow =\n-\t\tmlx5_glue->create_flow(flow->verbs.hrxq->qp, flow->verbs.attr);\n-\tif (!flow->verbs.flow) {\n-\t\tif (flow->fate & MLX5_FLOW_FATE_DROP)\n-\t\t\tmlx5_hrxq_drop_release(dev);\n-\t\telse\n-\t\t\tmlx5_hrxq_release(dev, flow->verbs.hrxq);\n-\t\tflow->verbs.hrxq = NULL;\n-\t\treturn rte_flow_error_set(error, errno,\n-\t\t\t\t\t  RTE_FLOW_ERROR_TYPE_UNSPECIFIED,\n-\t\t\t\t\t  NULL,\n-\t\t\t\t\t  \"kernel module refuses to create\"\n-\t\t\t\t\t  \" flow\");\n+\tstruct mlx5_flow_verbs *verbs;\n+\tint err;\n+\n+\tLIST_FOREACH(verbs, &flow->verbs, next) {\n+\t\tif (flow->fate & MLX5_FLOW_FATE_DROP) {\n+\t\t\tverbs->hrxq = mlx5_hrxq_drop_new(dev);\n+\t\t\tif (!verbs->hrxq) {\n+\t\t\t\trte_flow_error_set\n+\t\t\t\t\t(error, errno,\n+\t\t\t\t\t RTE_FLOW_ERROR_TYPE_UNSPECIFIED,\n+\t\t\t\t\t NULL,\n+\t\t\t\t\t \"cannot get drop hash queue\");\n+\t\t\t\tgoto error;\n+\t\t\t}\n+\t\t} else {\n+\t\t\tstruct mlx5_hrxq *hrxq;\n+\n+\t\t\thrxq = mlx5_hrxq_get(dev, flow->key,\n+\t\t\t\t\t     MLX5_RSS_HASH_KEY_LEN,\n+\t\t\t\t\t     verbs->hash_fields,\n+\t\t\t\t\t     (*flow->queue),\n+\t\t\t\t\t     flow->rss.queue_num, 0, 0);\n+\t\t\tif (!hrxq)\n+\t\t\t\thrxq = mlx5_hrxq_new(dev, flow->key,\n+\t\t\t\t\t\t     MLX5_RSS_HASH_KEY_LEN,\n+\t\t\t\t\t\t     verbs->hash_fields,\n+\t\t\t\t\t\t     (*flow->queue),\n+\t\t\t\t\t\t     flow->rss.queue_num, 0, 0);\n+\t\t\tif (!hrxq) {\n+\t\t\t\trte_flow_error_set\n+\t\t\t\t\t(error, rte_errno,\n+\t\t\t\t\t RTE_FLOW_ERROR_TYPE_UNSPECIFIED,\n+\t\t\t\t\t NULL,\n+\t\t\t\t\t \"cannot get hash queue\");\n+\t\t\t\tgoto error;\n+\t\t\t}\n+\t\t\tverbs->hrxq = hrxq;\n+\t\t}\n+\t\tverbs->flow =\n+\t\t\tmlx5_glue->create_flow(verbs->hrxq->qp, verbs->attr);\n+\t\tif (!verbs->flow) {\n+\t\t\trte_flow_error_set(error, errno,\n+\t\t\t\t\t   RTE_FLOW_ERROR_TYPE_UNSPECIFIED,\n+\t\t\t\t\t   NULL,\n+\t\t\t\t\t   \"hardware refuses to create flow\");\n+\t\t\tgoto error;\n+\t\t}\n \t}\n \treturn 0;\n+error:\n+\terr = rte_errno; /* Save rte_errno before cleanup. */\n+\tLIST_FOREACH(verbs, &flow->verbs, next) {\n+\t\tif (verbs->hrxq) {\n+\t\t\tif (flow->fate & MLX5_FLOW_FATE_DROP)\n+\t\t\t\tmlx5_hrxq_drop_release(dev);\n+\t\t\telse\n+\t\t\t\tmlx5_hrxq_release(dev, verbs->hrxq);\n+\t\t\tverbs->hrxq = NULL;\n+\t\t}\n+\t}\n+\trte_errno = err; /* Restore rte_errno. */\n+\treturn -rte_errno;\n }\n \n /**\n@@ -1550,42 +1945,43 @@ mlx5_flow_list_create(struct rte_eth_dev *dev,\n \t\t      const struct rte_flow_action actions[],\n \t\t      struct rte_flow_error *error)\n {\n-\tstruct rte_flow *flow;\n-\tsize_t size;\n+\tstruct rte_flow *flow = NULL;\n+\tsize_t size = 0;\n \tint ret;\n \n-\tret = mlx5_flow_merge(dev, NULL, 0, attr, items, actions, error);\n+\tret = mlx5_flow_merge(dev, flow, size, attr, items, actions, error);\n \tif (ret < 0)\n \t\treturn NULL;\n \tsize = ret;\n-\tflow = rte_zmalloc(__func__, size, 0);\n+\tflow = rte_calloc(__func__, 1, size, 0);\n \tif (!flow) {\n \t\trte_flow_error_set(error, ENOMEM,\n \t\t\t\t   RTE_FLOW_ERROR_TYPE_UNSPECIFIED,\n \t\t\t\t   NULL,\n-\t\t\t\t   \"cannot allocate memory\");\n+\t\t\t\t   \"not enough memory to create flow\");\n \t\treturn NULL;\n \t}\n-\tflow->verbs.attr = (struct ibv_flow_attr *)(flow + 1);\n-\tflow->verbs.specs = (uint8_t *)(flow->verbs.attr + 1);\n \tret = mlx5_flow_merge(dev, flow, size, attr, items, actions, error);\n-\tif (ret < 0)\n-\t\tgoto error;\n+\tif (ret < 0) {\n+\t\trte_free(flow);\n+\t\treturn NULL;\n+\t}\n \tassert((size_t)ret == size);\n \tif (dev->data->dev_started) {\n \t\tret = mlx5_flow_apply(dev, flow, error);\n-\t\tif (ret < 0)\n-\t\t\tgoto error;\n+\t\tif (ret < 0) {\n+\t\t\tret = rte_errno; /* Save rte_errno before cleanup. */\n+\t\t\tif (flow) {\n+\t\t\t\tmlx5_flow_remove(dev, flow);\n+\t\t\t\trte_free(flow);\n+\t\t\t}\n+\t\t\trte_errno = ret; /* Restore rte_errno. */\n+\t\t\treturn NULL;\n+\t\t}\n \t}\n \tmlx5_flow_rxq_mark_set(dev, flow);\n \tTAILQ_INSERT_TAIL(list, flow, next);\n \treturn flow;\n-error:\n-\tret = rte_errno; /* Save rte_errno before cleanup. */\n-\tmlx5_flow_remove(dev, flow);\n-\trte_free(flow);\n-\trte_errno = ret; /* Restore rte_errno. */\n-\treturn NULL;\n }\n \n /**\n@@ -1745,7 +2141,7 @@ mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev,\n \tstruct priv *priv = dev->data->dev_private;\n \tconst struct rte_flow_attr attr = {\n \t\t.ingress = 1,\n-\t\t.priority = priv->config.flow_prio - 1,\n+\t\t.priority = MLX5_FLOW_PRIO_RSVD,\n \t};\n \tstruct rte_flow_item items[] = {\n \t\t{\n",
    "prefixes": [
        "v4",
        "14/21"
    ]
}