From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id B9911A04C1; Thu, 21 Nov 2019 14:18:50 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 918E72BA3; Thu, 21 Nov 2019 14:18:50 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id D4A161F5 for ; Thu, 21 Nov 2019 14:18:48 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from orika@mellanox.com) with ESMTPS (AES256-SHA encrypted); 21 Nov 2019 15:18:43 +0200 Received: from pegasus04.mtr.labs.mlnx. (pegasus04.mtr.labs.mlnx [10.210.16.126]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id xALDIg3V015754; Thu, 21 Nov 2019 15:18:42 +0200 From: Ori Kam To: Matan Azrad , Shahaf Shuler , Viacheslav Ovsiienko Cc: dev@dpdk.org, orika@mellanox.com, dekelp@mellanox.com, bingz@mellanox.com Date: Thu, 21 Nov 2019 13:18:31 +0000 Message-Id: <1574342311-13619-1-git-send-email-orika@mellanox.com> X-Mailer: git-send-email 1.8.3.1 Subject: [dpdk-dev] [PATCH] net/mlx5: fix selection between encap and decap 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" The current raw_encap function selects if to decap or encap based on the egress/ingress attribute. This concepts doesn't work in case of FDB since all flows are considered ingress. To solve this issue we moved to check the encap size. if the encap size is larger then eth + ipv4 it means we are trying to encap. Fixes: 8ba9eee4ce32 ("net/mlx5: add raw data encap/decap to Direct Verbs") Cc: dekelp@mellanox.com Cc: bingz@mellanox.com Signed-off-by: Ori Kam Acked-by: Matan Azrad --- drivers/net/mlx5/mlx5_flow_dv.c | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index c402a8d..02f20fb 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -51,6 +51,8 @@ #define MLX5DV_DR_ACTION_FLAGS_ROOT_LEVEL 1 #endif +#define MLX5_ENCAPSULATION_DECISION_SIZE (sizeof(struct rte_flow_item_eth) + \ + sizeof(struct rte_flow_item_ipv4)) /* VLAN header definitions */ #define MLX5DV_FLOW_VLAN_PCP_SHIFT 13 #define MLX5DV_FLOW_VLAN_PCP_MASK (0x7 << MLX5DV_FLOW_VLAN_PCP_SHIFT) @@ -2171,6 +2173,8 @@ struct field_modify_info modify_tcp[] = { const struct rte_flow_attr *attr, struct rte_flow_error *error) { + const struct rte_flow_action_raw_decap *decap = action->conf; + if (action_flags & MLX5_FLOW_ACTION_DROP) return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, NULL, @@ -2186,22 +2190,19 @@ struct field_modify_info modify_tcp[] = { "can only have a single decap" " action in a flow"); /* decap action is valid on egress only if it is followed by encap */ - if (attr->egress) { - for (; action->type != RTE_FLOW_ACTION_TYPE_END && - action->type != RTE_FLOW_ACTION_TYPE_RAW_ENCAP; - action++) { - } - if (action->type != RTE_FLOW_ACTION_TYPE_RAW_ENCAP) - return rte_flow_error_set - (error, ENOTSUP, - RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, - NULL, "decap action not supported" - " for egress"); - } else if (action_flags & MLX5_FLOW_MODIFY_HDR_ACTIONS) { + if (attr->egress && decap && + decap->size > MLX5_ENCAPSULATION_DECISION_SIZE) { + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, + NULL, "decap action not supported" + " for egress"); + } else if (decap && decap->size > MLX5_ENCAPSULATION_DECISION_SIZE && + (action_flags & MLX5_FLOW_MODIFY_HDR_ACTIONS)) { return rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ACTION, NULL, - "can't have decap action after" - " modify action"); + RTE_FLOW_ERROR_TYPE_ACTION, + NULL, + "can't have decap action " + "after modify action"); } return 0; } @@ -2879,9 +2880,9 @@ struct field_modify_info modify_tcp[] = { encap_data = (const struct rte_flow_action_raw_encap *)action->conf; res.size = encap_data->size; memcpy(res.buf, encap_data->data, res.size); - res.reformat_type = attr->egress ? - MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TO_L3_TUNNEL : - MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L3_TUNNEL_TO_L2; + res.reformat_type = res.size < MLX5_ENCAPSULATION_DECISION_SIZE ? + MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L3_TUNNEL_TO_L2 : + MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TO_L3_TUNNEL; if (attr->transfer) res.ft_type = MLX5DV_FLOW_TABLE_TYPE_FDB; else -- 1.8.3.1