Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/47443/?format=api
https://patches.dpdk.org/api/patches/47443/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/patch/1540498108-18358-7-git-send-email-dekelp@mellanox.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": "<1540498108-18358-7-git-send-email-dekelp@mellanox.com>", "list_archive_url": "https://inbox.dpdk.org/dev/1540498108-18358-7-git-send-email-dekelp@mellanox.com", "date": "2018-10-25T20:08:28", "name": "[v6,6/6] net/mlx5: add raw data encap decap to Direct Verbs", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "d98fd3613c59e083182fdb49423d677d099a7898", "submitter": { "id": 1082, "url": "https://patches.dpdk.org/api/people/1082/?format=api", "name": "Dekel Peled", "email": "dekelp@mellanox.com" }, "delegate": null, "mbox": "https://patches.dpdk.org/project/dpdk/patch/1540498108-18358-7-git-send-email-dekelp@mellanox.com/mbox/", "series": [ { "id": 1835, "url": "https://patches.dpdk.org/api/series/1835/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=1835", "date": "2018-10-11T12:12:43", "name": "add support of Direct Verbs encap and decap actions", "version": 5, "mbox": "https://patches.dpdk.org/series/1835/mbox/" } ], "comments": "https://patches.dpdk.org/api/patches/47443/comments/", "check": "success", "checks": "https://patches.dpdk.org/api/patches/47443/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 [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id C47481B12A;\n\tThu, 25 Oct 2018 22:09:52 +0200 (CEST)", "from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129])\n\tby dpdk.org (Postfix) with ESMTP id B65B55F36\n\tfor <dev@dpdk.org>; Thu, 25 Oct 2018 22:09:42 +0200 (CEST)", "from Internal Mail-Server by MTLPINE1 (envelope-from\n\tdekelp@mellanox.com)\n\twith ESMTPS (AES256-SHA encrypted); 25 Oct 2018 22:14:48 +0200", "from mtl-vdi-280.wap.labs.mlnx. (mtl-vdi-280.wap.labs.mlnx\n\t[10.128.130.87])\n\tby labmailer.mlnx (8.13.8/8.13.8) with ESMTP id w9PK9EZe028635;\n\tThu, 25 Oct 2018 23:09:38 +0300" ], "From": "Dekel Peled <dekelp@mellanox.com>", "To": "yskoh@mellanox.com, shahafs@mellanox.com", "Cc": "dev@dpdk.org, orika@mellanox.com", "Date": "Thu, 25 Oct 2018 23:08:28 +0300", "Message-Id": "<1540498108-18358-7-git-send-email-dekelp@mellanox.com>", "X-Mailer": "git-send-email 1.7.1", "In-Reply-To": "<1539259967-10975-1-git-send-email-dekelp@mellanox.com>", "References": "<1539259967-10975-1-git-send-email-dekelp@mellanox.com>", "Subject": "[dpdk-dev] [PATCH v6 6/6] net/mlx5: add raw data encap decap to\n\tDirect Verbs", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.15", "Precedence": "list", "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>", "List-Archive": "<http://mails.dpdk.org/archives/dev/>", "List-Post": "<mailto:dev@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>", "Errors-To": "dev-bounces@dpdk.org", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "This patch implements the encap and decap actions, using raw data,\nin DV flow for MLX5 PMD.\n\nSigned-off-by: Dekel Peled <dekelp@mellanox.com>\n---\n drivers/net/mlx5/mlx5_flow.h | 12 ++-\n drivers/net/mlx5/mlx5_flow_dv.c | 227 ++++++++++++++++++++++++++++++++++++++--\n 2 files changed, 224 insertions(+), 15 deletions(-)", "diff": "diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h\nindex 2d73a05..92ba111 100644\n--- a/drivers/net/mlx5/mlx5_flow.h\n+++ b/drivers/net/mlx5/mlx5_flow.h\n@@ -96,15 +96,19 @@\n #define MLX5_FLOW_ACTION_VXLAN_DECAP (1u << 23)\n #define MLX5_FLOW_ACTION_NVGRE_ENCAP (1u << 24)\n #define MLX5_FLOW_ACTION_NVGRE_DECAP (1u << 25)\n+#define MLX5_FLOW_ACTION_RAW_ENCAP (1u << 26)\n+#define MLX5_FLOW_ACTION_RAW_DECAP (1u << 27)\n \n #define MLX5_FLOW_FATE_ACTIONS \\\n \t(MLX5_FLOW_ACTION_DROP | MLX5_FLOW_ACTION_QUEUE | MLX5_FLOW_ACTION_RSS)\n \n-#define MLX5_FLOW_ENCAP_ACTIONS\t\\\n-\t(MLX5_FLOW_ACTION_VXLAN_ENCAP | MLX5_FLOW_ACTION_NVGRE_ENCAP)\n+#define MLX5_FLOW_ENCAP_ACTIONS\t(MLX5_FLOW_ACTION_VXLAN_ENCAP | \\\n+\t\t\t\t MLX5_FLOW_ACTION_NVGRE_ENCAP | \\\n+\t\t\t\t MLX5_FLOW_ACTION_RAW_ENCAP)\n \n-#define MLX5_FLOW_DECAP_ACTIONS\t\\\n-\t(MLX5_FLOW_ACTION_VXLAN_DECAP | MLX5_FLOW_ACTION_NVGRE_DECAP)\n+#define MLX5_FLOW_DECAP_ACTIONS\t(MLX5_FLOW_ACTION_VXLAN_DECAP | \\\n+\t\t\t\t MLX5_FLOW_ACTION_NVGRE_DECAP | \\\n+\t\t\t\t MLX5_FLOW_ACTION_RAW_DECAP)\n \n #ifndef IPPROTO_MPLS\n #define IPPROTO_MPLS 137\ndiff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c\nindex d7d0c6b..ca75645 100644\n--- a/drivers/net/mlx5/mlx5_flow_dv.c\n+++ b/drivers/net/mlx5/mlx5_flow_dv.c\n@@ -186,6 +186,82 @@\n }\n \n /**\n+ * Validate the raw encap action.\n+ *\n+ * @param[in] action_flags\n+ * Holds the actions detected until now.\n+ * @param[in] action\n+ * Pointer to the encap action.\n+ * @param[in] attr\n+ * Pointer to flow attributes\n+ * @param[out] error\n+ * Pointer to error structure.\n+ *\n+ * @return\n+ * 0 on success, a negative errno value otherwise and rte_errno is set.\n+ */\n+static int\n+flow_dv_validate_action_raw_encap(uint64_t action_flags,\n+\t\t\t\t const struct rte_flow_action *action,\n+\t\t\t\t const struct rte_flow_attr *attr,\n+\t\t\t\t struct rte_flow_error *error)\n+{\n+\tif (!(action->conf))\n+\t\treturn rte_flow_error_set(error, EINVAL,\n+\t\t\t\t\t RTE_FLOW_ERROR_TYPE_ACTION, action,\n+\t\t\t\t\t \"configuration cannot be null\");\n+\tif (action_flags & MLX5_FLOW_ACTION_DROP)\n+\t\treturn rte_flow_error_set(error, EINVAL,\n+\t\t\t\t\t RTE_FLOW_ERROR_TYPE_ACTION, NULL,\n+\t\t\t\t\t \"can't drop and encap in same flow\");\n+\tif (action_flags & MLX5_FLOW_ENCAP_ACTIONS)\n+\t\treturn rte_flow_error_set(error, EINVAL,\n+\t\t\t\t\t RTE_FLOW_ERROR_TYPE_ACTION, NULL,\n+\t\t\t\t\t \"can only have a single encap\"\n+\t\t\t\t\t \" action in a flow\");\n+\t/* encap without preceding decap is not supported for ingress */\n+\tif (attr->ingress && !(action_flags & MLX5_FLOW_ACTION_RAW_DECAP))\n+\t\treturn rte_flow_error_set(error, ENOTSUP,\n+\t\t\t\t\t RTE_FLOW_ERROR_TYPE_ATTR_INGRESS,\n+\t\t\t\t\t NULL,\n+\t\t\t\t\t \"encap action not supported for \"\n+\t\t\t\t\t \"ingress\");\n+\treturn 0;\n+}\n+\n+/**\n+ * Validate the raw decap action.\n+ *\n+ * @param[in] action_flags\n+ * Holds the actions detected until now.\n+ * @param[out] error\n+ * Pointer to error structure.\n+ *\n+ * @return\n+ * 0 on success, a negative errno value otherwise and rte_errno is set.\n+ */\n+static int\n+flow_dv_validate_action_raw_decap(uint64_t action_flags,\n+\t\t\t\t struct rte_flow_error *error)\n+{\n+\tif (action_flags & MLX5_FLOW_ACTION_DROP)\n+\t\treturn rte_flow_error_set(error, EINVAL,\n+\t\t\t\t\t RTE_FLOW_ERROR_TYPE_ACTION, NULL,\n+\t\t\t\t\t \"can't drop and decap in same flow\");\n+\tif (action_flags & MLX5_FLOW_ENCAP_ACTIONS)\n+\t\treturn rte_flow_error_set(error, EINVAL,\n+\t\t\t\t\t RTE_FLOW_ERROR_TYPE_ACTION, NULL,\n+\t\t\t\t\t \"can't have encap action before\"\n+\t\t\t\t\t \" decap action\");\n+\tif (action_flags & MLX5_FLOW_DECAP_ACTIONS)\n+\t\treturn rte_flow_error_set(error, EINVAL,\n+\t\t\t\t\t RTE_FLOW_ERROR_TYPE_ACTION, NULL,\n+\t\t\t\t\t \"can only have a single decap\"\n+\t\t\t\t\t \" action in a flow\");\n+\treturn 0;\n+}\n+\n+/**\n * Get the size of specific rte_flow_item_type\n *\n * @param[in] item_type\n@@ -396,6 +472,7 @@\n /**\n * Convert L2 encap action to DV specification.\n * Used for VXLAN and NVGRE encap actions.\n+ * Also used for raw encap action without preceding decap.\n *\n * @param[in] dev\n * Pointer to rte_eth_dev structure.\n@@ -414,23 +491,34 @@\n {\n \tstruct ibv_flow_action *verbs_action = NULL;\n \tconst struct rte_flow_item *encap_data;\n+\tconst struct rte_flow_action_raw_encap *raw_encap_data;\n \tstruct priv *priv = dev->data->dev_private;\n \tuint8_t buf[MLX5_ENCAP_MAX_LEN];\n+\tuint8_t *buf_ptr = buf;\n \tsize_t size = 0;\n \tint convert_result = 0;\n \n-\tif (action->type == RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP)\n-\t\tencap_data = ((const struct rte_flow_action_vxlan_encap *)\n+\tif (action->type == RTE_FLOW_ACTION_TYPE_RAW_ENCAP) {\n+\t\traw_encap_data =\n+\t\t\t(const struct rte_flow_action_raw_encap *)action->conf;\n+\t\tbuf_ptr = raw_encap_data->data;\n+\t\tsize = raw_encap_data->size;\n+\t} else {\n+\t\tif (action->type == RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP)\n+\t\t\tencap_data =\n+\t\t\t\t((const struct rte_flow_action_vxlan_encap *)\n \t\t\t\t\t\taction->conf)->definition;\n-\telse\n-\t\tencap_data = ((const struct rte_flow_action_nvgre_encap *)\n+\t\telse\n+\t\t\tencap_data =\n+\t\t\t\t((const struct rte_flow_action_nvgre_encap *)\n \t\t\t\t\t\taction->conf)->definition;\n-\tconvert_result = flow_dv_convert_encap_data(encap_data, buf,\n-\t\t\t\t\t\t &size, error);\n-\tif (convert_result)\n-\t\treturn NULL;\n+\t\tconvert_result = flow_dv_convert_encap_data(encap_data, buf,\n+\t\t\t\t\t\t\t &size, error);\n+\t\tif (convert_result)\n+\t\t\treturn NULL;\n+\t}\n \tverbs_action = mlx5_glue->dv_create_flow_action_packet_reformat\n-\t\t(priv->ctx, size, (size ? buf : NULL),\n+\t\t(priv->ctx, size, (size ? buf_ptr : NULL),\n \t\t MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TO_L2_TUNNEL,\n \t\t MLX5DV_FLOW_TABLE_TYPE_NIC_TX);\n \tif (!verbs_action)\n@@ -472,6 +560,50 @@\n }\n \n /**\n+ * Convert raw decap/encap (L3 tunnel) action to DV specification.\n+ *\n+ * @param[in] dev\n+ * Pointer to rte_eth_dev structure.\n+ * @param[in] action\n+ * Pointer to action structure.\n+ * @param[in] attr\n+ * Pointer to the flow attributes.\n+ * @param[out] error\n+ * Pointer to the error structure.\n+ *\n+ * @return\n+ * Pointer to action on success, NULL otherwise and rte_errno is set.\n+ */\n+static struct ibv_flow_action *\n+flow_dv_create_action_raw_encap(struct rte_eth_dev *dev,\n+\t\t\t\tconst struct rte_flow_action *action,\n+\t\t\t\tconst struct rte_flow_attr *attr,\n+\t\t\t\tstruct rte_flow_error *error)\n+{\n+\tstruct ibv_flow_action *verbs_action = NULL;\n+\tconst struct rte_flow_action_raw_encap *encap_data;\n+\tstruct priv *priv = dev->data->dev_private;\n+\tenum mlx5dv_flow_action_packet_reformat_type reformat_type;\n+\tenum mlx5dv_flow_table_type ft_type;\n+\n+\tencap_data = (const struct rte_flow_action_raw_encap *)action->conf;\n+\treformat_type = attr->egress ?\n+\t\tMLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TO_L3_TUNNEL :\n+\t\tMLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L3_TUNNEL_TO_L2;\n+\tft_type = attr->egress ?\n+\t\t\tMLX5DV_FLOW_TABLE_TYPE_NIC_TX :\n+\t\t\tMLX5DV_FLOW_TABLE_TYPE_NIC_RX;\n+\tverbs_action = mlx5_glue->dv_create_flow_action_packet_reformat\n+\t\t\t\t(priv->ctx, encap_data->size,\n+\t\t\t\t(encap_data->size ? encap_data->data : NULL),\n+\t\t\t\treformat_type, ft_type);\n+\tif (!verbs_action)\n+\t\trte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION,\n+\t\t\t\t NULL, \"cannot create encap action\");\n+\treturn verbs_action;\n+}\n+\n+/**\n * Verify the @p attributes will be correctly understood by the NIC and store\n * them in the @p flow if everything is correct.\n *\n@@ -726,7 +858,6 @@\n \t\t\t\t\tRTE_FLOW_ACTION_TYPE_VXLAN_ENCAP ?\n \t\t\t\t\tMLX5_FLOW_ACTION_VXLAN_ENCAP :\n \t\t\t\t\tMLX5_FLOW_ACTION_NVGRE_ENCAP;\n-\n \t\t\t++actions_n;\n \t\t\tbreak;\n \t\tcase RTE_FLOW_ACTION_TYPE_VXLAN_DECAP:\n@@ -740,7 +871,23 @@\n \t\t\t\t\tRTE_FLOW_ACTION_TYPE_VXLAN_DECAP ?\n \t\t\t\t\tMLX5_FLOW_ACTION_VXLAN_DECAP :\n \t\t\t\t\tMLX5_FLOW_ACTION_NVGRE_DECAP;\n-\n+\t\t\t++actions_n;\n+\t\t\tbreak;\n+\t\tcase RTE_FLOW_ACTION_TYPE_RAW_ENCAP:\n+\t\t\tret = flow_dv_validate_action_raw_encap(action_flags,\n+\t\t\t\t\t\t\t\tactions, attr,\n+\t\t\t\t\t\t\t\terror);\n+\t\t\tif (ret < 0)\n+\t\t\t\treturn ret;\n+\t\t\taction_flags |= MLX5_FLOW_ACTION_RAW_ENCAP;\n+\t\t\t++actions_n;\n+\t\t\tbreak;\n+\t\tcase RTE_FLOW_ACTION_TYPE_RAW_DECAP:\n+\t\t\tret = flow_dv_validate_action_raw_decap(action_flags,\n+\t\t\t\t\t\t\t\terror);\n+\t\t\tif (ret < 0)\n+\t\t\t\treturn ret;\n+\t\t\taction_flags |= MLX5_FLOW_ACTION_RAW_DECAP;\n \t\t\t++actions_n;\n \t\t\tbreak;\n \t\tdefault:\n@@ -1550,6 +1697,64 @@\n \t\t\t\t MLX5_FLOW_ACTION_NVGRE_DECAP;\n \t\tactions_n++;\n \t\tbreak;\n+\tcase RTE_FLOW_ACTION_TYPE_RAW_ENCAP:\n+\t\t/* Handle encap action with preceding decap */\n+\t\tif (flow->actions & MLX5_FLOW_ACTION_RAW_DECAP) {\n+\t\t\tdev_flow->dv.actions[actions_n].type =\n+\t\t\t\tMLX5DV_FLOW_ACTION_IBV_FLOW_ACTION;\n+\t\t\tdev_flow->dv.actions[actions_n].action =\n+\t\t\t\t\tflow_dv_create_action_raw_encap\n+\t\t\t\t\t\t\t\t(dev, action,\n+\t\t\t\t\t\t\t\t attr, error);\n+\t\t\tif (!(dev_flow->dv.actions[actions_n].action))\n+\t\t\t\treturn -rte_errno;\n+\t\t\tdev_flow->dv.verbs_action =\n+\t\t\t\tdev_flow->dv.actions[actions_n].action;\n+\t\t} else {\n+\t\t\t/* Handle encap action without preceding decap */\n+\t\t\tdev_flow->dv.actions[actions_n].type =\n+\t\t\t\tMLX5DV_FLOW_ACTION_IBV_FLOW_ACTION;\n+\t\t\tdev_flow->dv.actions[actions_n].action =\n+\t\t\t\t\tflow_dv_create_action_l2_encap\n+\t\t\t\t\t\t\t(dev, action, error);\n+\t\t\tif (!(dev_flow->dv.actions[actions_n].action))\n+\t\t\t\treturn -rte_errno;\n+\t\t\tdev_flow->dv.verbs_action =\n+\t\t\t\tdev_flow->dv.actions[actions_n].action;\n+\t\t}\n+\t\tflow->actions |= MLX5_FLOW_ACTION_RAW_ENCAP;\n+\t\tactions_n++;\n+\t\tbreak;\n+\tcase RTE_FLOW_ACTION_TYPE_RAW_DECAP:\n+\t\t/* Check if this decap action is followed by encap. */\n+\t\tfor (; action->type != RTE_FLOW_ACTION_TYPE_END &&\n+\t\t action->type != RTE_FLOW_ACTION_TYPE_RAW_ENCAP;\n+\t\t action++) {\n+\t\t}\n+\t\t/* Handle decap action only if it isn't followed by encap */\n+\t\tif (action->type != RTE_FLOW_ACTION_TYPE_RAW_ENCAP) {\n+\t\t\t/* on egress, decap without following encap is error. */\n+\t\t\tif (attr->egress)\n+\t\t\t\treturn rte_flow_error_set\n+\t\t\t\t\t(error, ENOTSUP,\n+\t\t\t\t\t RTE_FLOW_ERROR_TYPE_ATTR_EGRESS,\n+\t\t\t\t\t NULL,\n+\t\t\t\t\t \"decap action not supported for \"\n+\t\t\t\t\t \"egress\");\n+\t\t\tdev_flow->dv.actions[actions_n].type =\n+\t\t\t\tMLX5DV_FLOW_ACTION_IBV_FLOW_ACTION;\n+\t\t\tdev_flow->dv.actions[actions_n].action =\n+\t\t\t\t\tflow_dv_create_action_l2_decap\n+\t\t\t\t\t\t\t(dev, action, error);\n+\t\t\tif (!(dev_flow->dv.actions[actions_n].action))\n+\t\t\t\treturn -rte_errno;\n+\t\t\tdev_flow->dv.verbs_action =\n+\t\t\t\tdev_flow->dv.actions[actions_n].action;\n+\t\t\tactions_n++;\n+\t\t}\n+\t\t/* If decap is followed by encap, handle it at encap case. */\n+\t\tflow->actions |= MLX5_FLOW_ACTION_RAW_DECAP;\n+\t\tbreak;\n \tdefault:\n \t\tbreak;\n \t}\n", "prefixes": [ "v6", "6/6" ] }{ "id": 47443, "url": "