From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2973EC3A5A4 for ; Sun, 1 Sep 2019 10:40:57 +0000 (UTC) Received: from dpdk.org (dpdk.org [92.243.14.124]) by mail.kernel.org (Postfix) with ESMTP id AAA9C21897 for ; Sun, 1 Sep 2019 10:40:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AAA9C21897 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mellanox.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dev-bounces@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B8F121C29A; Sun, 1 Sep 2019 12:40:28 +0200 (CEST) Received: from git-send-mailer.rdmz.labs.mlnx (unknown [37.142.13.130]) by dpdk.org (Postfix) with ESMTP id C81D11C22B for ; Sun, 1 Sep 2019 12:40:19 +0200 (CEST) From: Moti Haimovsky To: viacheslavo@mellanox.com, rasland@mellanox.com Cc: dev@dpdk.org Date: Sun, 1 Sep 2019 13:40:14 +0300 Message-Id: <30ce4acb70fd80077395c93a600e5e186f9196ca.1567332903.git.motih@mellanox.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: References: Subject: [dpdk-dev] [PATCH v2 6/7] net/mlx5: supp modify VLAN ID on new VLAN header 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 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 --- drivers/net/mlx5/mlx5_flow_dv.c | 55 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 30b0112..ea51805 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -1008,6 +1008,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(0xFFFE)) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, action, + "VLAN VID value to 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 @@ -3431,6 +3472,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, @@ -5158,6 +5206,13 @@ struct field_modify_info modify_tcp[] = { vlan.tci |= rte_cpu_to_be_16(vlan_tci); /* Push VLAN command will use this value */ break; + case RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID: + vlan.tci &= ~FLOW_DV_VLAN_VID_MASK; + vlan.tci |= + ((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, -- 1.8.3.1