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 8E535A0524; Wed, 5 May 2021 09:21:16 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C640241162; Wed, 5 May 2021 09:20:05 +0200 (CEST) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2073.outbound.protection.outlook.com [40.107.92.73]) by mails.dpdk.org (Postfix) with ESMTP id 64BB141157 for ; Wed, 5 May 2021 09:20:03 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z8U96T5zDuXHrR19TDAe3eoZWfv69BtQsEwoJdai+yNaEBE4dUctUNBVnK5uyzBTo0tD6hY6wvxKmvIrhC9fgMjVZX+xbJyq9anpovmJo1D3pr0KXWdL4wS15Ld8oxF9Zdlchq/e3lX7DyQTqyszEFRVOJnVSs8eNj/Mi665t6vW4wf0KE67G5oiJ/bMYz4Zn7hM1sMYsgCySAs3WHgS/qcNxtBhrWiS0nxdALGEnUBnJnLJWvNeHk5YLrFPOvqNfHXxa9Pyqn5cu0pJxvpMZY5SOinKKAfr5sjkUbM2LZNQHmluU5rowLWfftK7sjbypH70KflT7ZlahY9OHkFtXw== 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=gwRisU5foCxWW7VAT5x1st8Bz7MHy2fhYOjJLo5dA2Vjr+vBi0R+AYzN4zcYtJ537KbKJQrNdqKR8srilcXiNpkwXZca/4bAjEe7yqk1A+lelclY+InSyVX47eOT3eZGkf72IsLaNRGuTfcZfeWdTexENbTU6Ia//FYtkMXmX4P2SuUpaM76LcuevhEB/MDmmUn/Me84gTjUmhXsclpMDhTfeaGjy276nMbS7ojVgWMCrWy2NH6bLuqin4R6vRqJz04uRa2wPZD1wn8lf388QcfsMAFMWfecQbfyjvq+P5aSdSSr3XPVGMdXwtgIAKOlet31c9M5dxKOQNZdNwhNGw== 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=Zm3R76UcDf9APVEhs5becEcsSy3PRKbUGgI30Li+y7UQ6zu5Bc1Vnq0som09uAzeoN2bQ9kQX8xBfbGk89nqPDnB/h9IB6Di2RZt+gU51C6OxGzeo7S7ozvDgjeS4BGEh1FkNzg3oEggIhHXbAsFMI4Rmq6jwkX6fqinMKPUp/Nj9hN7zBeX0I5ldrlg1+AXepE2rsL+CVWJDEmiG8CuT9etYgmZH/rj0W0BB5L2jc/BpQgPv8LVQQAi594Nfi6kbRVBqm4qg4QjaXYx48PfQuMMsSgLjlCGJf7UyP6mzqgB+mFZLyU+Wt2+66FwdeFK22qqvT6ggei05lNIdokPYQ== Received: from DM5PR07CA0133.namprd07.prod.outlook.com (2603:10b6:3:13e::23) by MN2PR12MB4845.namprd12.prod.outlook.com (2603:10b6:208:183::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25; Wed, 5 May 2021 07:20:02 +0000 Received: from DM6NAM11FT037.eop-nam11.prod.protection.outlook.com (2603:10b6:3:13e:cafe::15) by DM5PR07CA0133.outlook.office365.com (2603:10b6:3:13e::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.22 via Frontend Transport; Wed, 5 May 2021 07:20:02 +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 DM6NAM11FT037.mail.protection.outlook.com (10.13.172.122) 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 07:20:02 +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 07:20:00 +0000 From: Bing Zhao To: , , CC: , , Date: Wed, 5 May 2021 10:19:14 +0300 Message-ID: <20210505071917.31802-15-bingz@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210505071917.31802-1-bingz@nvidia.com> References: <20210427153811.11554-1-bingz@nvidia.com> <20210505071917.31802-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: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: da8fcf3c-63a4-4978-c633-08d90f9632d1 X-MS-TrafficTypeDiagnostic: MN2PR12MB4845: 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: d394SRU2YyOr+6KCO5Q31pwM2youtQLxdilkTerxa2XkWP9wYH6HkjWCR2SsZ0J31I/cneM/Y3ZAXLdZgwSZKExKNBchXBcVoy1iGcL9lh7dhAKU56OWcM+AwHMtdxPWs0jKmaDjUSVMcopYwfQVKlbptifv9Vz97rAO8b3lg4YvyAu5WA4ln91BHdQN4yBOf1jWAPmxuOhzezg+yTAZCJuiMGfYM6xBqyHOaq23eSO6O7ChcjVgJ3XN5+M6jENd9M8f4yOrP5bFIis5wETfONOpI2oZ8sM00VMJOP6Yj9oaMIBeGmd43kG3Tzh36Sw8WNcvJ34Z6Av8OXgLCWWC0izGTTLTLaxX0lFbeKYnYQkov/wfwVgoGfdBYoBDjQ/dINl4kEyrFR0Nffo9zXk8NBXDyR7lG5aVKZVblFN/7nTTWrhUeJ/9yfr7e9tUSUovIok7JKjUWmELd76Tp4iUEvV/sWMqGTXTEcvOEW0bqMSce4B7lAsRF+74jNNrO7nxR6pzDbhTbXzhtV6RpsJbpQOb75G+w5oylct/Th+T/kBtQMmC/pKZsavA8OwWhSAHcjVWBnuKbmdDgCkPiQZHlQNI85InxfYb+klhbsiGgP4YsAJIli0X0438tp/BWbgbeLRDwHW+Fa4eQZn6WSZBxveTcK2/59VVeGHwmYXwbf0LpDKoFLSdrYeFmBtGzp1Y 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)(346002)(39860400002)(376002)(136003)(396003)(36840700001)(46966006)(26005)(6666004)(8676002)(478600001)(8936002)(36906005)(6286002)(36756003)(70586007)(70206006)(16526019)(55016002)(2616005)(186003)(5660300002)(107886003)(316002)(110136005)(54906003)(336012)(426003)(2906002)(83380400001)(36860700001)(86362001)(356005)(47076005)(82310400003)(7696005)(4326008)(82740400003)(1076003)(7636003)(309714004); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 May 2021 07:20:02.0596 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: da8fcf3c-63a4-4978-c633-08d90f9632d1 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: DM6NAM11FT037.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4845 Subject: [dpdk-dev] [PATCH v4 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