From patchwork Mon Sep 9 15:56:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Moti Haimovsky X-Patchwork-Id: 59042 X-Patchwork-Delegate: rasland@nvidia.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4151B1EDB6; Mon, 9 Sep 2019 17:57:11 +0200 (CEST) Received: from git-send-mailer.rdmz.labs.mlnx (unknown [37.142.13.130]) by dpdk.org (Postfix) with ESMTP id F33A21ED66 for ; Mon, 9 Sep 2019 17:56:52 +0200 (CEST) From: Moti Haimovsky To: viacheslavo@mellanox.com, rasland@mellanox.com Cc: dev@dpdk.org Date: Mon, 9 Sep 2019 18:56:47 +0300 Message-Id: <672cb17b8fd1c7171bb2714840124de51c004fd0.1567951423.git.motih@mellanox.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: References: Subject: [dpdk-dev] [PATCH v5 5/7] net/mlx5: support modify VLAN priority on VLAN hdr X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This commit adds support for modifying the VLAN priority (PCP) field in about-to-be-pushed VLAN header. This feature can only modify the PCP 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 Acked-by: Viacheslav Ovsiienko Acked-by: Viacheslav Ovsiienko --- v4: - Fixed typo in an error message. --- doc/guides/nics/mlx5.rst | 5 ++- doc/guides/rel_notes/release_19_11.rst | 1 + drivers/net/mlx5/mlx5_flow_dv.c | 62 ++++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 1 deletion(-) diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst index 875a87f..01215f4 100644 --- a/doc/guides/nics/mlx5.rst +++ b/doc/guides/nics/mlx5.rst @@ -132,6 +132,8 @@ Limitations - VLAN push offload is not supported on ingress traffic. +- VLAN set PCP 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 @@ -1042,7 +1044,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_push_vlan / | | ConnectX-5 | | ConnectX-5 | + | | of_set_vlan_pcp) | | | +-----------------------+-----------------+-----------------+ Notes for testpmd diff --git a/doc/guides/rel_notes/release_19_11.rst b/doc/guides/rel_notes/release_19_11.rst index afe92ab..5067a1c 100644 --- a/doc/guides/rel_notes/release_19_11.rst +++ b/doc/guides/rel_notes/release_19_11.rst @@ -229,4 +229,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. diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 2780735..73459a0 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -974,6 +974,47 @@ struct field_modify_info modify_tcp[] = { } /** + * Validate the set VLAN PCP. + * + * @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_pcp(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_pcp *conf = action->conf; + + if (conf->vlan_pcp > 7) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, action, + "VLAN PCP 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 PCP 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 PCP action must precede " + "the push VLAN action"); + return 0; +} + +/** * Validate count action. * * @param[in] dev @@ -3396,6 +3437,13 @@ struct field_modify_info modify_tcp[] = { action_flags |= MLX5_FLOW_ACTION_OF_PUSH_VLAN; ++actions_n; break; + case RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP: + ret = flow_dv_validate_action_set_vlan_pcp + (action_flags, actions, error); + if (ret < 0) + return ret; + /* Count PCP 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, @@ -4989,6 +5037,7 @@ struct field_modify_info modify_tcp[] = { uint8_t next_protocol = 0xff; struct rte_vlan_hdr vlan = { 0 }; bool vlan_inherited = false; + uint16_t vlan_tci; flow->group = attr->group; if (attr->transfer) @@ -5118,6 +5167,19 @@ struct field_modify_info modify_tcp[] = { dev_flow->dv.push_vlan_res->action; action_flags |= MLX5_FLOW_ACTION_OF_PUSH_VLAN; break; + case RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP: + if (!vlan_inherited) { + flow_dev_get_vlan_info_from_items(items, &vlan); + vlan_inherited = true; + } + vlan_tci = + ((const struct rte_flow_action_of_set_vlan_pcp *) + actions->conf)->vlan_pcp; + vlan_tci = vlan_tci << MLX5DV_FLOW_VLAN_PCP_SHIFT; + vlan.vlan_tci &= ~MLX5DV_FLOW_VLAN_PCP_MASK; + vlan.vlan_tci |= vlan_tci; + /* 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,