[v5,6/7] net/mlx5: supp modify VLAN ID on new VLAN header
Checks
Commit Message
This commit adds support for modifying the VLAN ID (VID) field
in an about-to-be-pushed VLAN header.
This feature can only modify the VID field of a new VLAN header yet
to be pushed. It does not support modifying an existing or already
pushed VLAN headers.
Signed-off-by: Moti Haimovsky <motih@mellanox.com>
---
v4:
- Fixed typo in an error message.
- Fixed bug in verifying VLAN VID value, used 0xFFFE instead of 0xFFE.
---
doc/guides/nics/mlx5.rst | 5 ++-
doc/guides/rel_notes/release_19_11.rst | 1 +
drivers/net/mlx5/mlx5_flow_dv.c | 59 ++++++++++++++++++++++++++++++++++
3 files changed, 64 insertions(+), 1 deletion(-)
@@ -134,6 +134,8 @@ 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
@@ -1045,7 +1047,8 @@ Supported hardware offloads
| | VLAN | | DPDK 19.11 | | DPDK 19.11 |
| | (of_pop_vlan / | | OFED 4.6-4 | | OFED 4.6-4 |
| | of_push_vlan / | | ConnectX-5 | | ConnectX-5 |
- | | of_set_vlan_pcp) | | |
+ | | of_set_vlan_pcp / | | |
+ | | of_set_vlan_vid) | | |
+-----------------------+-----------------+-----------------+
Notes for testpmd
@@ -230,4 +230,5 @@ Tested Platforms
* Added support for VLAN pop flow offload command.
* Added support for VLAN push flow offload command.
* Added support for VLAN set PCP offload command.
+ * Added support for VLAN set VID offload command.
@@ -1015,6 +1015,47 @@ struct field_modify_info modify_tcp[] = {
}
/**
+ * Validate the set VLAN VID.
+ *
+ * @param[in] action_flags
+ * Holds the actions detected until now.
+ * @param[in] actions
+ * Pointer to the list of actions remaining in the flow rule.
+ * @param[in] attr
+ * Pointer to flow attributes
+ * @param[out] error
+ * Pointer to error structure.
+ *
+ * @return
+ * 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,
+ const struct rte_flow_action actions[],
+ struct rte_flow_error *error)
+{
+ const struct rte_flow_action *action = actions;
+ const struct rte_flow_action_of_set_vlan_vid *conf = action->conf;
+
+ if (conf->vlan_vid > RTE_BE16(0xFFE))
+ return rte_flow_error_set(error, EINVAL,
+ RTE_FLOW_ERROR_TYPE_ACTION, action,
+ "VLAN VID value is too big");
+ if (mlx5_flow_find_action(actions,
+ RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN) == NULL)
+ 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,
+ RTE_FLOW_ERROR_TYPE_ACTION, action,
+ "set VLAN VID action must precede "
+ "the push VLAN action");
+ return 0;
+}
+
+/**
* Validate count action.
*
* @param[in] dev
@@ -3444,6 +3485,13 @@ struct field_modify_info modify_tcp[] = {
return ret;
/* Count PCP with push_vlan command. */
break;
+ case RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID:
+ ret = flow_dv_validate_action_set_vlan_vid
+ (action_flags, actions, error);
+ if (ret < 0)
+ return ret;
+ /* Count VID with push_vlan command. */
+ break;
case RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP:
case RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP:
ret = flow_dv_validate_action_l2_encap(action_flags,
@@ -5180,6 +5228,17 @@ struct field_modify_info modify_tcp[] = {
vlan.vlan_tci |= vlan_tci;
/* Push VLAN command will use this value */
break;
+ case RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID:
+ if (!vlan_inherited) {
+ flow_dev_get_vlan_info_from_items(items, &vlan);
+ vlan_inherited = true;
+ }
+ vlan.vlan_tci &= ~MLX5DV_FLOW_VLAN_VID_MASK;
+ vlan.vlan_tci |= rte_be_to_cpu_16
+ (((const struct rte_flow_action_of_set_vlan_vid *)
+ actions->conf)->vlan_vid);
+ /* Push VLAN command will use this value */
+ break;
case RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP:
case RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP:
if (flow_dv_create_action_l2_encap(dev, actions,