From: Moti Haimovsky <motih@mellanox.com>
To: viacheslavo@mellanox.com, rasland@mellanox.com
Cc: dev@dpdk.org
Subject: [dpdk-dev] [PATCH v3 7/7] net/mlx5: supp modify VLAN ID on existing VLAN hdr
Date: Mon, 2 Sep 2019 18:00:52 +0300 [thread overview]
Message-ID: <1fd98f4a7fa413600594f159392dcf8e2e2649db.1567436185.git.motih@mellanox.com> (raw)
In-Reply-To: <cover.1567436185.git.motih@mellanox.com>
This commit adds support for modifying the VID of the outermost VLAN
header already present in the packet.
Signed-off-by: Moti Haimovsky <motih@mellanox.com>
---
doc/guides/nics/mlx5.rst | 20 ++++-----
drivers/net/mlx5/mlx5_flow.h | 3 +-
drivers/net/mlx5/mlx5_flow_dv.c | 90 +++++++++++++++++++++++++++++++++++------
drivers/net/mlx5/mlx5_prm.h | 1 +
4 files changed, 92 insertions(+), 22 deletions(-)
diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst
index c492635..6e2e18a 100644
--- a/doc/guides/nics/mlx5.rst
+++ b/doc/guides/nics/mlx5.rst
@@ -130,8 +130,6 @@ Limitations
- VLAN set PCP offload is not supported on existing headers.
-- VLAN set VID offload is not supported on existing headers.
-
- A multi segment packet must have not more segments than reported by dev_infos_get()
in tx_desc_lim.nb_seg_max field. This value depends on maximal supported Tx descriptor
size and ``txq_inline_min`` settings and may be from 2 (worst case forced by maximal
@@ -1017,13 +1015,17 @@ Supported hardware offloads
| | (set_ipv4_src / | | OFED 4.6-2 | | OFED 4.6-2 |
| | set_ipv4_dst / | | rdma-core 24 | | rdma-core 23 |
| | set_ipv6_src / | | ConnectX-5 | | ConnectX-5 |
- | | set_ipv6_dst / | | |
- | | set_tp_src / | | |
- | | set_tp_dst / | | |
- | | dec_ttl / | | |
- | | set_ttl / | | |
- | | set_mac_src / | | |
- | | set_mac_dst) | | |
+ | | set_ipv6_dst / | | | | |
+ | | set_tp_src / | | | | |
+ | | set_tp_dst / | | | | |
+ | | dec_ttl / | | | | |
+ | | set_ttl / | | | | |
+ | | set_mac_src / | | | | |
+ | | set_mac_dst) | | | | |
+ | | | | | | |
+ | | (of_set_vlan_vid) | | DPDK 19.11 | | DPDK 19.11 |
+ | | | OFED 4.6-4 | | OFED 4.6-4 |
+ | | | ConnectX-5 | | ConnectX-5 |
+-----------------------+-----------------+-----------------+
| Jump | | DPDK 19.05 | | DPDK 19.02 |
| | | OFED 4.6-4 | | OFED 4.6-4 |
diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index 15c9c04..95abbb8 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -171,7 +171,8 @@
MLX5_FLOW_ACTION_INC_TCP_SEQ | \
MLX5_FLOW_ACTION_DEC_TCP_SEQ | \
MLX5_FLOW_ACTION_INC_TCP_ACK | \
- MLX5_FLOW_ACTION_DEC_TCP_ACK)
+ MLX5_FLOW_ACTION_DEC_TCP_ACK | \
+ MLX5_FLOW_ACTION_OF_SET_VLAN_VID)
#define MLX5_FLOW_VLAN_ACTIONS (MLX5_FLOW_ACTION_OF_POP_VLAN | \
MLX5_FLOW_ACTION_OF_PUSH_VLAN)
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index ea51805..8463327 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -123,6 +123,12 @@ struct field_modify_info modify_eth[] = {
{0, 0, 0},
};
+struct field_modify_info modify_vlan_out_first_vid[] = {
+ /* Size in bits !!! */
+ {12, 0, MLX5_MODI_OUT_FIRST_VID},
+ {0, 0, 0},
+};
+
struct field_modify_info modify_ipv4[] = {
{1, 8, MLX5_MODI_OUT_IPV4_TTL},
{4, 12, MLX5_MODI_OUT_SIPV4},
@@ -405,6 +411,46 @@ struct field_modify_info modify_tcp[] = {
}
/**
+ * Convert modify-header set VLAN VID action to DV specification.
+ *
+ * @param[in,out] resource
+ * Pointer to the modify-header resource.
+ * @param[in] action
+ * Pointer to action specification.
+ * @param[out] error
+ * Pointer to the error structure.
+ *
+ * @return
+ * 0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+static int
+flow_dv_convert_action_modify_vlan_vid
+ (struct mlx5_flow_dv_modify_hdr_resource *resource,
+ const struct rte_flow_action *action,
+ struct rte_flow_error *error)
+{
+ const struct rte_flow_action_of_set_vlan_vid *conf =
+ (const struct rte_flow_action_of_set_vlan_vid *)(action->conf);
+ int i = resource->actions_num;
+ struct mlx5_modification_cmd *actions = &resource->actions[i];
+ struct field_modify_info *field = modify_vlan_out_first_vid;
+
+ if (i >= MLX5_MODIFY_NUM)
+ return rte_flow_error_set(error, EINVAL,
+ RTE_FLOW_ERROR_TYPE_ACTION, NULL,
+ "too many items to modify");
+ actions[i].action_type = MLX5_MODIFICATION_TYPE_SET;
+ actions[i].field = field->id;
+ actions[i].length = field->size;
+ actions[i].offset = field->offset;
+ actions[i].data0 = rte_cpu_to_be_32(actions[i].data0);
+ actions[i].data1 = conf->vlan_vid;
+ actions[i].data1 = actions[i].data1 << 16;
+ resource->actions_num = ++i;
+ return 0;
+}
+
+/**
* Convert modify-header set TP action to DV specification.
*
* @param[in,out] resource
@@ -1010,8 +1056,8 @@ struct field_modify_info modify_tcp[] = {
/**
* Validate the set VLAN VID.
*
- * @param[in] action_flags
- * Holds the actions detected until now.
+ * @param[in] item_flags
+ * Holds the items detected in this rule.
* @param[in] actions
* Pointer to the list of actions remaining in the flow rule.
* @param[in] attr
@@ -1023,7 +1069,7 @@ struct field_modify_info modify_tcp[] = {
* 0 on success, a negative errno value otherwise and rte_errno is set.
*/
static int
-flow_dv_validate_action_set_vlan_vid(uint64_t action_flags,
+flow_dv_validate_action_set_vlan_vid(uint64_t item_flags,
const struct rte_flow_action actions[],
struct rte_flow_error *error)
{
@@ -1034,17 +1080,27 @@ struct field_modify_info modify_tcp[] = {
return rte_flow_error_set(error, EINVAL,
RTE_FLOW_ERROR_TYPE_ACTION, action,
"VLAN VID value to too big");
+ /* If a push VLAN action follows then it will handle this action */
if (mlx5_flow_find_action(actions,
- RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN) == NULL)
+ RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN))
+ return 0;
+
+ /*
+ * Action is on an existing VLAN header:
+ * Need to verify this is a single modify CID action.
+ * Rule mast include a match on outer VLAN.
+ */
+ if (mlx5_flow_find_action(++action,
+ RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID))
return rte_flow_error_set(error, ENOTSUP,
RTE_FLOW_ERROR_TYPE_ACTION, action,
- "set VLAN VID can only be used "
- "with push VLAN action");
- if (action_flags & MLX5_FLOW_ACTION_OF_PUSH_VLAN)
- return rte_flow_error_set(error, ENOTSUP,
+ "Multiple VLAN VID modifications are "
+ "not supported");
+ if (!(item_flags & MLX5_FLOW_LAYER_OUTER_VLAN))
+ return rte_flow_error_set(error, EINVAL,
RTE_FLOW_ERROR_TYPE_ACTION, action,
- "set VLAN VID action must precede "
- "the push VLAN action");
+ "match on VLAN is required in order "
+ "to set VLAN VID");
return 0;
}
@@ -3474,7 +3530,7 @@ struct field_modify_info modify_tcp[] = {
break;
case RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID:
ret = flow_dv_validate_action_set_vlan_vid
- (action_flags, actions, error);
+ (item_flags, actions, error);
if (ret < 0)
return ret;
/* Count VID with push_vlan command. */
@@ -5196,6 +5252,8 @@ struct field_modify_info modify_tcp[] = {
dev_flow->dv.actions[actions_n++] =
dev_flow->dv.push_vlan_res->action;
action_flags |= MLX5_FLOW_ACTION_OF_PUSH_VLAN;
+ /* Push VLAN command is also handling this VLAN_VID */
+ action_flags &= ~MLX5_FLOW_ACTION_OF_SET_VLAN_VID;
break;
case RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP:
vlan_tci =
@@ -5211,7 +5269,15 @@ struct field_modify_info modify_tcp[] = {
vlan.tci |=
((const struct rte_flow_action_of_set_vlan_vid *)
actions->conf)->vlan_vid;
- /* Push VLAN command will use this value */
+ if (mlx5_flow_find_action
+ (actions,
+ RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN))
+ break;
+ /* If no VLAN push - this is a modify header action */
+ if (flow_dv_convert_action_modify_vlan_vid
+ (&res, actions, error))
+ return -rte_errno;
+ action_flags |= MLX5_FLOW_ACTION_OF_SET_VLAN_VID;
break;
case RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP:
case RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP:
diff --git a/drivers/net/mlx5/mlx5_prm.h b/drivers/net/mlx5/mlx5_prm.h
index d62837e..e5afc1c 100644
--- a/drivers/net/mlx5/mlx5_prm.h
+++ b/drivers/net/mlx5/mlx5_prm.h
@@ -413,6 +413,7 @@ enum mlx5_modification_field {
MLX5_MODI_OUT_DIPV6_31_0,
MLX5_MODI_OUT_SIPV4,
MLX5_MODI_OUT_DIPV4,
+ MLX5_MODI_OUT_FIRST_VID,
MLX5_MODI_IN_SMAC_47_16 = 0x31,
MLX5_MODI_IN_SMAC_15_0,
MLX5_MODI_IN_ETHERTYPE,
--
1.8.3.1
next prev parent reply other threads:[~2019-09-02 15:02 UTC|newest]
Thread overview: 78+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-16 15:20 [dpdk-dev] [RFC] net/mlx5: support for flow action on VLAN header Moti Haimovsky
2019-08-06 8:24 ` [dpdk-dev] [PATCH 0/7] " Moti Haimovsky
2019-08-06 8:24 ` [dpdk-dev] [PATCH 1/7] net/mlx5: support for an action search in a list Moti Haimovsky
2019-08-06 8:24 ` [dpdk-dev] [PATCH 2/7] net/mlx5: add VLAN push/pop DR commands to glue Moti Haimovsky
2019-08-06 8:24 ` [dpdk-dev] [PATCH 3/7] net/mlx5: support pop flow action on VLAN header Moti Haimovsky
2019-08-06 8:24 ` [dpdk-dev] [PATCH 4/7] net/mlx5: support push " Moti Haimovsky
2019-08-06 8:24 ` [dpdk-dev] [PATCH 5/7] net/mlx5: support modify VLAN priority on VLAN hdr Moti Haimovsky
2019-08-06 8:24 ` [dpdk-dev] [PATCH 6/7] net/mlx5: supp modify VLAN ID on new VLAN header Moti Haimovsky
2019-08-06 8:24 ` [dpdk-dev] [PATCH 7/7] net/mlx5: supp modify VLAN ID on existing VLAN hdr Moti Haimovsky
2019-09-01 10:40 ` [dpdk-dev] [PATCH v2 0/7] net/mlx5: support for flow action on VLAN header Moti Haimovsky
2019-09-01 10:40 ` [dpdk-dev] [PATCH v2 1/7] net/mlx5: support for an action search in a list Moti Haimovsky
2019-09-01 10:40 ` [dpdk-dev] [PATCH v2 2/7] net/mlx5: add VLAN push/pop DR commands to glue Moti Haimovsky
2019-09-01 10:40 ` [dpdk-dev] [PATCH v2 3/7] net/mlx5: support pop flow action on VLAN header Moti Haimovsky
2019-09-01 10:40 ` [dpdk-dev] [PATCH v2 4/7] net/mlx5: support push " Moti Haimovsky
2019-09-01 10:40 ` [dpdk-dev] [PATCH v2 5/7] net/mlx5: support modify VLAN priority on VLAN hdr Moti Haimovsky
2019-09-01 10:40 ` [dpdk-dev] [PATCH v2 6/7] net/mlx5: supp modify VLAN ID on new VLAN header Moti Haimovsky
2019-09-01 10:40 ` [dpdk-dev] [PATCH v2 7/7] net/mlx5: supp modify VLAN ID on existing VLAN hdr Moti Haimovsky
2019-09-02 15:00 ` [dpdk-dev] [PATCH v3 0/7] net/mlx5: support for flow action on VLAN header Moti Haimovsky
2019-09-02 15:00 ` [dpdk-dev] [PATCH v3 1/7] net/mlx5: support for an action search in a list Moti Haimovsky
2019-09-02 15:00 ` [dpdk-dev] [PATCH v3 2/7] net/mlx5: add VLAN push/pop DR commands to glue Moti Haimovsky
2019-09-02 15:00 ` [dpdk-dev] [PATCH v3 3/7] net/mlx5: support pop flow action on VLAN header Moti Haimovsky
2019-09-02 15:00 ` [dpdk-dev] [PATCH v3 4/7] net/mlx5: support push " Moti Haimovsky
2019-09-02 15:00 ` [dpdk-dev] [PATCH v3 5/7] net/mlx5: support modify VLAN priority on VLAN hdr Moti Haimovsky
2019-09-02 15:00 ` [dpdk-dev] [PATCH v3 6/7] net/mlx5: supp modify VLAN ID on new VLAN header Moti Haimovsky
2019-09-02 15:00 ` Moti Haimovsky [this message]
2019-09-03 15:13 ` [dpdk-dev] [PATCH v4 0/7] net/mlx5: support for flow action on " Moti Haimovsky
2019-09-03 15:13 ` [dpdk-dev] [PATCH v4 1/7] net/mlx5: support for an action search in a list Moti Haimovsky
2019-09-03 15:13 ` [dpdk-dev] [PATCH v4 2/7] net/mlx5: add VLAN push/pop DR commands to glue Moti Haimovsky
2019-09-03 15:13 ` [dpdk-dev] [PATCH v4 3/7] net/mlx5: support pop flow action on VLAN header Moti Haimovsky
2019-09-03 15:13 ` [dpdk-dev] [PATCH v4 4/7] net/mlx5: support push " Moti Haimovsky
2019-09-03 15:13 ` [dpdk-dev] [PATCH v4 5/7] net/mlx5: support modify VLAN priority on VLAN hdr Moti Haimovsky
2019-09-03 15:13 ` [dpdk-dev] [PATCH v4 6/7] net/mlx5: supp modify VLAN ID on new VLAN header Moti Haimovsky
2019-09-03 15:13 ` [dpdk-dev] [PATCH v4 7/7] net/mlx5: supp modify VLAN ID on existing VLAN hdr Moti Haimovsky
2019-09-09 15:56 ` [dpdk-dev] [PATCH v5 0/7] net/mlx5: support for flow action on VLAN header Moti Haimovsky
2019-09-09 15:56 ` [dpdk-dev] [PATCH v5 1/7] net/mlx5: support for an action search in a list Moti Haimovsky
2019-09-10 8:12 ` Slava Ovsiienko
2019-09-09 15:56 ` [dpdk-dev] [PATCH v5 2/7] net/mlx5: add VLAN push/pop DR commands to glue Moti Haimovsky
2019-09-10 8:12 ` Slava Ovsiienko
2019-09-09 15:56 ` [dpdk-dev] [PATCH v5 3/7] net/mlx5: support pop flow action on VLAN header Moti Haimovsky
2019-09-10 8:13 ` Slava Ovsiienko
2019-09-09 15:56 ` [dpdk-dev] [PATCH v5 4/7] net/mlx5: support push " Moti Haimovsky
2019-09-10 10:42 ` Slava Ovsiienko
2019-09-09 15:56 ` [dpdk-dev] [PATCH v5 5/7] net/mlx5: support modify VLAN priority on VLAN hdr Moti Haimovsky
2019-09-10 8:13 ` Slava Ovsiienko
2019-09-10 8:13 ` Slava Ovsiienko
2019-09-09 15:56 ` [dpdk-dev] [PATCH v5 6/7] net/mlx5: supp modify VLAN ID on new VLAN header Moti Haimovsky
2019-09-09 15:56 ` [dpdk-dev] [PATCH v5 7/7] net/mlx5: supp modify VLAN ID on existing VLAN hdr Moti Haimovsky
2019-09-10 8:13 ` Slava Ovsiienko
2019-09-10 6:10 ` [dpdk-dev] [PATCH v5 0/7] net/mlx5: support for flow action on VLAN header Slava Ovsiienko
2019-09-10 13:34 ` Raslan Darawsheh
2019-10-01 12:17 ` [dpdk-dev] [PATCH " Hideyuki Yamashita
2019-10-04 10:35 ` Hideyuki Yamashita
2019-10-04 10:51 ` Slava Ovsiienko
2019-10-18 10:55 ` Hideyuki Yamashita
2019-10-21 7:11 ` Hideyuki Yamashita
2019-10-21 7:29 ` Slava Ovsiienko
2019-10-25 4:48 ` Hideyuki Yamashita
2019-10-29 5:45 ` Slava Ovsiienko
2019-10-30 10:04 ` Hideyuki Yamashita
2019-10-30 10:08 ` Slava Ovsiienko
2019-10-30 10:46 ` Hideyuki Yamashita
2019-10-31 7:11 ` Slava Ovsiienko
2019-10-31 9:51 ` Hideyuki Yamashita
2019-10-31 10:36 ` Slava Ovsiienko
2019-11-05 10:26 ` Hideyuki Yamashita
2019-11-06 11:03 ` Hideyuki Yamashita
2019-11-06 16:35 ` Slava Ovsiienko
2019-11-07 4:46 ` Hideyuki Yamashita
2019-11-07 6:01 ` Slava Ovsiienko
2019-11-07 11:02 ` Hideyuki Yamashita
2019-11-14 5:01 ` Hideyuki Yamashita
2019-11-14 5:06 ` Hideyuki Yamashita
2019-11-15 7:16 ` Slava Ovsiienko
2019-11-18 6:11 ` Hideyuki Yamashita
2019-11-18 10:03 ` Matan Azrad
2019-11-19 11:36 ` Hideyuki Yamashita
2019-11-26 7:10 ` Hideyuki Yamashita
2019-12-04 2:43 ` Hideyuki Yamashita
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1fd98f4a7fa413600594f159392dcf8e2e2649db.1567436185.git.motih@mellanox.com \
--to=motih@mellanox.com \
--cc=dev@dpdk.org \
--cc=rasland@mellanox.com \
--cc=viacheslavo@mellanox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).