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 987AAA04A4; Sun, 24 May 2020 13:07:13 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D54A81D539; Sun, 24 May 2020 13:07:12 +0200 (CEST) Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by dpdk.org (Postfix) with ESMTP id D6A541C118; Sun, 24 May 2020 13:07:11 +0200 (CEST) Received: by mail-pf1-f194.google.com with SMTP id n18so7551878pfa.2; Sun, 24 May 2020 04:07:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Qe1Zdq0hI7g61fFI/3g89scw5nonVAt2E4ojKEueivc=; b=mTl2mgh5UnFukP/n4GRg1dpFq9SxKWXb9VP6ohVqIV39UqRubWkjQwptBxxBtEuoLP 3aCSfEaAHa0NJNvVav/+Wsq6z6ymU/RtjUi1o60BRclaAeTWNm+r1Yo7M+auLY2rz0UC 1Dcs6Ntb9T4sR3iOOVzXJc5Ihff59RXwoEa6fsxYYTgI/wVrH6khTYuJ5CGXpHnK43RF Qr8PaqjSgTqaDY2mEruOEk4DhLO2u2GVfeitG/ThIpWSTQaHrwHjCU8oSApkrng1xLtS +3n6uSeomUM7OlgybE/KD/4Y4imh2M3LSKWtRXiUYlWyxZ0iMbmWF/9OYXVkaNi6o2rR m8+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Qe1Zdq0hI7g61fFI/3g89scw5nonVAt2E4ojKEueivc=; b=GB1MTOiwJ8o0BMso9nGF1iD285a6i608kodZbQUThe7Z8KMnVEVuQv1hFBq53QAZNf Do1LdiOhihoeM9fwQt2BSQVlxKadfwR84vfb/Zl4xLEIgBfYhlmODUC3fWlJbUHwVB/j MrKZfSwcrbxEATTtKYMaVdJdo0dMXgQOvXpd6OgZxEp/UDDtOrQ9DjkqP4FAi3JrEMNc pAvc8yVdz1GTqg8Tzain2TyGgm7YdhurDTiNXFn4EHocP5D6g2Wy5PBJ2MeOnkEK8pc7 Zjpp82sa8o2AXJLxINyfebXkKzA7FlMvSCy9RGIYMUle/XG/rzPqUyCeo+EeMwCCKYXS 23vg== X-Gm-Message-State: AOAM533rr1IwDZbNkM+3uWRB/RsA74SjCdq53JMjXa5TG0Hy1MOp4wRp FcjZYkoijf7yqEUiZBWyA10= X-Google-Smtp-Source: ABdhPJyuxbh0tsTFH8wrx7WZ4LuJGb0Zb+yAdr1gCgQGX8UTaZ3beQQ7zNR9sntBe9PLNbsu7CmXwQ== X-Received: by 2002:a63:63c6:: with SMTP id x189mr21727914pgb.36.1590318430952; Sun, 24 May 2020 04:07:10 -0700 (PDT) Received: from localhost.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id w12sm9862228pjn.21.2020.05.24.04.07.08 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 May 2020 04:07:10 -0700 (PDT) From: xiangxia.m.yue@gmail.com To: viacheslavo@mellanox.com Cc: dev@dpdk.org, Tonghao Zhang , stable@dpdk.org Date: Sun, 24 May 2020 19:06:41 +0800 Message-Id: <20200524110641.72147-1-xiangxia.m.yue@gmail.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20200520013328.98838-1-xiangxia.m.yue@gmail.com> References: <20200520013328.98838-1-xiangxia.m.yue@gmail.com> Subject: [dpdk-dev] [PATCH dpdk-dev v2] net/mlx5: check the reg available for metadata action 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" From: Tonghao Zhang If user don't set the dv_xmeta_en to 1 or 2, in the flow_dv_convert_action_set_meta function: * flow_dv_get_metadata_reg may return the REG_NONE, when MLX5_METADATA_FDB enabled for metadata set action. * reg_to_field(REG_NONE) return MLX5_MODI_OUT_NONE which is invalid. The rdma-core calltrace: dr_action_create_modify_action dr_actions_convert_modify_header dr_action_modify_sw_to_hw dr_action_modify_sw_to_hw_set dr_ste_get_modify_hdr_hw_field sw_field [MLX5_MODI_OUT_NONE 4095] should not > ste_ctx->modify_hdr_field_arr_sz [92] As doc[1] says: | dv_xmeta_en 0, this is default value, defines the legacy mode, | the MARK and META related actions and items operate only within | NIC Tx and NIC Rx steering domains, no MARK and META information | crosses the domain boundaries. This patch add check for that case to warn that not supported. [1] - http://doc.dpdk.org/guides-20.02/nics/mlx5.html Fixes: fcc8d2f716fd ("net/mlx5: extend flow metadata support") Cc: stable@dpdk.org Signed-off-by: Tonghao Zhang --- drivers/net/mlx5/mlx5_flow_dv.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index e4818319507c..c77835270d60 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -1251,6 +1251,7 @@ flow_dv_convert_action_set_meta if (reg < 0) return reg; + MLX5_ASSERT(reg != REG_NONE); /* * In datapath code there is no endianness * coversions for perfromance reasons, all @@ -1449,7 +1450,6 @@ flow_dv_validate_item_meta(struct rte_eth_dev *dev __rte_unused, struct rte_flow_error *error) { struct mlx5_priv *priv = dev->data->dev_private; - struct mlx5_dev_config *config = &priv->config; const struct rte_flow_item_meta *spec = item->spec; const struct rte_flow_item_meta *mask = item->mask; struct rte_flow_item_meta nic_mask = { @@ -1463,23 +1463,25 @@ flow_dv_validate_item_meta(struct rte_eth_dev *dev __rte_unused, RTE_FLOW_ERROR_TYPE_ITEM_SPEC, item->spec, "data cannot be empty"); - if (config->dv_xmeta_en != MLX5_XMETA_MODE_LEGACY) { - if (!mlx5_flow_ext_mreg_supported(dev)) - return rte_flow_error_set(error, ENOTSUP, + if (!mlx5_flow_ext_mreg_supported(dev)) + return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ITEM, item, "extended metadata register" " isn't supported"); - reg = flow_dv_get_metadata_reg(dev, attr, error); - if (reg < 0) - return reg; - if (reg == REG_B) - return rte_flow_error_set(error, ENOTSUP, + reg = flow_dv_get_metadata_reg(dev, attr, error); + if (reg < 0) + return reg; + if (reg == REG_NONE) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "unavailable metadata register"); + if (reg == REG_B) + return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ITEM, item, "match on reg_b " "isn't supported"); - if (reg != REG_A) - nic_mask.data = priv->sh->dv_meta_mask; - } + if (reg != REG_A) + nic_mask.data = priv->sh->dv_meta_mask; if (!mask) mask = &rte_flow_item_meta_mask; if (!mask->data) @@ -2244,6 +2246,11 @@ flow_dv_validate_action_set_meta(struct rte_eth_dev *dev, reg = flow_dv_get_metadata_reg(dev, attr, error); if (reg < 0) return reg; + if (reg == REG_NONE) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ACTION, + action, "unavailable " + "metadata register"); if (reg != REG_A && reg != REG_B) { struct mlx5_priv *priv = dev->data->dev_private; -- 2.26.1