From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 27457A0524; Wed, 5 May 2021 10:08:06 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 104E04115C; Wed, 5 May 2021 10:07:08 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2070.outbound.protection.outlook.com [40.107.93.70]) by mails.dpdk.org (Postfix) with ESMTP id B9D8E41151 for ; Wed, 5 May 2021 10:07:05 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WM8ms4c35yCREdItmitjuSAYnRKZG9yW7F4j7zxnQV0FYQWFwidFp4nX/xW8e1yPoUiSfdJ3mbhYlU83xLsBGvWNQWkKr2ffxLBmqEHVFzFG0RBN16sEJIlGqPvXKobYUtMz44oCSwHv3s2xjQqkRzWeY7ilxHa4TaQVd0cpxWtce/wgIDwkyXSwGJTc5aAkeuxKs9eE5A2/l8aEjLYTVVg66jnIkKeObNMppPdOuc4UwQDMEsxSgzWQ14jYRjaX48uRih9BSaVh5/Is974Kt0uTR7FUzWnjnWnqLT7Rb6Zy63kJPmSm/ey2awuh4J6nmkJ3JjSc1LDIM9pew3ZWuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pVV4tzuozcUvQd2mRCQ4BpnUnOW1/SJxUjPmJAEnVA0=; b=lE/i2A2Prnhfjedw/qysmyt2v+wNpItSj/+BpfKJovJlMpGZUVwELqlShtRL9l9Ygx/CcluqSXGAxfRI1Hh1GxM1LSSNViWarVwhkAPnc0B0pV3mJslxf+UKHbR5Pzrle4Kou3+m/JO37GAy0aUiJhiZ8CZHHSbgsDc9INFM/8pGpb/j+6EZ10SrpsTcqVC8SUq5GR5e4tWQcDZO+UDl3oKTVtJh/e88BgC2clpsk2b6Ck5BpYTHVyn9zwsFnYVd9+xZjDvA0NKB/2eUboO0yaHkQdr8D0/hJWUIPLGmjSfuGScOLcyciBASUUIEPLBp5Ubqo1G5LuutisnwwWiCrA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pVV4tzuozcUvQd2mRCQ4BpnUnOW1/SJxUjPmJAEnVA0=; b=fpoyq7UEFu/5xqDTHxQwA4B8y0K65p33GkFmsGT4Kcc+sm9yFzjiyRvgQObUs13ECxnsgHoaFp6eBkE9lj9BTJhhA97MpvXJfkdXtgqGwejSoAkQpn8xJp/6Rh50O9zWUhZUMfwKslA49iA+iQXgVuUh1/H9eBE5qc+2WgSyPiZeqB74gDmMge5JAsaydeP5R5OhWVmU0lC7EaPycwzraInzuMK9bLkojheQzkHat5DCbTYy09pnOG373c9OUjWPjGzYBkjiREcnMu6spwVmDPU47SJKT95+VXIkQkaOAwAgDW6+KFn8fvjNCivx2q4klhsrCEqSJbEPqiQDGhZCTw== Received: from BN9PR03CA0703.namprd03.prod.outlook.com (2603:10b6:408:ef::18) by MN2PR12MB4798.namprd12.prod.outlook.com (2603:10b6:208:3d::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.38; Wed, 5 May 2021 08:07:00 +0000 Received: from BN8NAM11FT032.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ef:cafe::8a) by BN9PR03CA0703.outlook.office365.com (2603:10b6:408:ef::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25 via Frontend Transport; Wed, 5 May 2021 08:07:00 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by BN8NAM11FT032.mail.protection.outlook.com (10.13.177.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4108.25 via Frontend Transport; Wed, 5 May 2021 08:07:00 +0000 Received: from nvidia.com (172.20.145.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 5 May 2021 08:06:57 +0000 From: Bing Zhao To: , , CC: , , Date: Wed, 5 May 2021 11:05:57 +0300 Message-ID: <20210505080600.33749-15-bingz@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210505080600.33749-1-bingz@nvidia.com> References: <20210427153811.11554-1-bingz@nvidia.com> <20210505080600.33749-1-bingz@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.145.6] X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 27fe4d17-075c-4bcc-f549-08d90f9cc27c X-MS-TrafficTypeDiagnostic: MN2PR12MB4798: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PZkFfQkL6K8Z8sbMcpRCfDCWkEJir+VazHB8ktsc0t4nb6H5dj4/WwAIXRKoOX1AYOytq21zPYoKcV9XcZDUwctDUj9nBAS53+L+bBMntK5/eQn4NGEu/v3NsiZ+K0KqK1F9wbc/tvM2iPqTM6hHUuzCKZp7B/bM5i6M2wBlZRIv1i+6wm7DVtNgQb4kXnBj46FAkqNPOG4N6l+ApoVQodsTQ2PsDlA4DmD2EQai1R/n8vtWcoRcdXTObaenB4raJSYk+a6Z4nsMHFUbwdvCJbwFQ+NCK9DqS/29sameHGdWAkgFFexL+sf82twFjT4XLDOUDUl3jBmjx2h2Jn37Wnv1NWaAWAB/6aFDFYqjelRAhtiB+EsrwSrYOY/9jyTkwfPxQUJBwNolDOePs8CicIW1i9rVkjZSpCxLWJ8xORifORmiHq339AOzfgxX7FLAZ7JLhY+dkrsp2JF5OboseHI5JMXTlo2baQvglg5cLcjm9jD+ZxJnvnAditU7SKz+XKjqklk3yTKy7haxwzDhUM0CzCFz3H0yU4snym/0v2q9yqxhdBtJq06XBfMyvkbtQiHEm72Abo1t0lLwPwxax85mlAa1jl/IOWdp6HMnHdlsdsrcbJbrYjxih/fXRh6niNf2SqezYQWj+uovcgR2c6s50q98t49rsIURlE+9SzPJnC0sU8BK2Ddp0Xnsapx7 X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(39860400002)(346002)(376002)(396003)(136003)(36840700001)(46966006)(7696005)(2906002)(8936002)(107886003)(82310400003)(54906003)(426003)(478600001)(26005)(186003)(110136005)(36756003)(7636003)(36860700001)(4326008)(86362001)(70206006)(16526019)(316002)(336012)(5660300002)(36906005)(356005)(8676002)(70586007)(47076005)(83380400001)(2616005)(55016002)(82740400003)(1076003)(6286002)(309714004); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 May 2021 08:07:00.0110 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 27fe4d17-075c-4bcc-f549-08d90f9cc27c X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT032.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4798 Subject: [dpdk-dev] [PATCH v5 14/17] net/mlx5: validation of CT action X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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 validation of a CT action contains two parts. The first is the CT action configurations parameter. When creating a CT action context, some members need to be verified. The second is that when creating a flow, the DR action of CT should be validated with other actions and items as well. Currently, only the TCP protocol support connection tracking. Signed-off-by: Bing Zhao --- drivers/net/mlx5/mlx5.h | 4 ++ drivers/net/mlx5/mlx5_flow.c | 31 +++++++++++++++ drivers/net/mlx5/mlx5_flow_dv.c | 69 +++++++++++++++++++++++++++++++++ 3 files changed, 104 insertions(+) diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index d01a10ea54..36b7f05822 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -1611,6 +1611,10 @@ int mlx5_flow_dev_dump(struct rte_eth_dev *dev, struct rte_flow *flow, void mlx5_flow_rxq_dynf_metadata_set(struct rte_eth_dev *dev); int mlx5_flow_get_aged_flows(struct rte_eth_dev *dev, void **contexts, uint32_t nb_contexts, struct rte_flow_error *error); +int mlx5_validate_action_ct(struct rte_eth_dev *dev, + const struct rte_flow_action_conntrack *conntrack, + struct rte_flow_error *error); + /* mlx5_mp_os.c */ diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index f36eeae03f..6baaefbaba 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -1688,6 +1688,37 @@ mlx5_flow_validate_action_count(struct rte_eth_dev *dev __rte_unused, return 0; } +/* + * Validate the ASO CT action. + * + * @param[in] dev + * Pointer to the Ethernet device structure. + * @param[in] conntrack + * Pointer to the CT action profile. + * @param[out] error + * Pointer to error structure. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. + */ +int +mlx5_validate_action_ct(struct rte_eth_dev *dev, + const struct rte_flow_action_conntrack *conntrack, + struct rte_flow_error *error) +{ + RTE_SET_USED(dev); + + if (conntrack->state > RTE_FLOW_CONNTRACK_STATE_TIME_WAIT) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, NULL, + "Invalid CT state"); + if (conntrack->last_index > RTE_FLOW_CONNTRACK_FLAG_RST) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, NULL, + "Invalid last TCP packet flag"); + return 0; +} + /** * Verify the @p attributes will be correctly understood by the NIC and store * them in the @p flow if everything is correct. diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 6afbbbc4bb..f2a2c609e2 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -3400,6 +3400,57 @@ flow_dv_validate_action_raw_encap_decap return 0; } +/* + * Validate the ASO CT action. + * + * @param[in] dev + * Pointer to the rte_eth_dev structure. + * @param[in] action_flags + * Holds the actions detected until now. + * @param[in] item_flags + * The items found in this 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_aso_ct(struct rte_eth_dev *dev, + uint64_t action_flags, + uint64_t item_flags, + const struct rte_flow_attr *attr, + struct rte_flow_error *error) +{ + RTE_SET_USED(dev); + + if (attr->group == 0 && !attr->transfer) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, + "Only support non-root table"); + if (action_flags & MLX5_FLOW_FATE_ACTIONS) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ACTION, NULL, + "CT cannot follow a fate action"); + if ((action_flags & MLX5_FLOW_ACTION_METER) || + (action_flags & MLX5_FLOW_ACTION_AGE)) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, NULL, + "Only one ASO action is supported"); + if (action_flags & MLX5_FLOW_ACTION_ENCAP) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, NULL, + "Encap cannot exist before CT"); + if (!(item_flags & MLX5_FLOW_LAYER_OUTER_L4_TCP)) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, + "Not a outer TCP packet"); + return 0; +} + /** * Match encap_decap resource. * @@ -7205,6 +7256,14 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, action_flags |= MLX5_FLOW_ACTION_MODIFY_FIELD; rw_act_num += ret; break; + case RTE_FLOW_ACTION_TYPE_CONNTRACK: + ret = flow_dv_validate_action_aso_ct(dev, action_flags, + item_flags, attr, + error); + if (ret < 0) + return ret; + action_flags |= MLX5_FLOW_ACTION_CT; + break; default: return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, @@ -13861,6 +13920,10 @@ __flow_dv_action_ct_update(struct rte_eth_dev *dev, uint32_t idx, if (update->direction) ct->is_original = !!new_prf->is_original_dir; if (update->state) { + /* Only validate the profile when it needs to be updated. */ + ret = mlx5_validate_action_ct(dev, new_prf, error); + if (ret) + return ret; ret = mlx5_aso_ct_update_by_wqe(priv->sh, ct, new_prf); if (ret) return rte_flow_error_set(error, EIO, @@ -15732,6 +15795,12 @@ flow_dv_action_validate(struct rte_eth_dev *dev, NULL, "shared age action not supported"); return flow_dv_validate_action_age(0, action, dev, err); + case RTE_FLOW_ACTION_TYPE_CONNTRACK: + if (!priv->sh->ct_aso_en) + return rte_flow_error_set(err, ENOTSUP, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, + "ASO CT is not supported"); + return mlx5_validate_action_ct(dev, action->conf, err); default: return rte_flow_error_set(err, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, -- 2.27.0