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 13090A0524; Wed, 5 May 2021 08:43:19 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1A98D4110A; Wed, 5 May 2021 08:43:12 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2068.outbound.protection.outlook.com [40.107.220.68]) by mails.dpdk.org (Postfix) with ESMTP id EE6C34110B for ; Wed, 5 May 2021 08:43:10 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eLBoAtTQ7NJAXjLtciqnQeVbEzh4jtuEDNHkFVxjXuJrOemInHba6kkLZdM5uH1+fsjs5ynheyNZKjGxT8Hq7Hn+PU5c+0ThOcnS01v0N0UOI6ah3PSnEwJMcxFdtxlCUj7t+QeKlKygy8dQcaFvis9UhQ5cZz7xOQko35THmkGePxd44Oc++Jl0UpGSUB5Gp4cwTAkUFahBOB+9Ej0r4D/7uvffbdQlyQgQ8uG2f6BPqYV+f9V92bdTf4HiMvG9pRwymDavNy9qJhtzmwH8SO2ItrbNTl/77xmk0sZ73ZGHF77KJ6qH+LoZj7P9817ubxcS+E9gE+lrrcmh6MXPtg== 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=NYLvC5spM/ouE/jus6FtELSBe8/ci104BJ6oXHgqSMXZv6joPZZyMKj+mMUeG8hVtGtGLjkoOy7Ff1DeZEDLsAEJXaVdJyq8ti2PnzSTEtsD4yjij9HScPGec3cD+IljTMeN3OqMj691Brde4OD6VipTmOmDFTIgyvn3+x7V/8XNx+NMUbm2ZChjDCv4fnYoe4Jl2tdx3pVj5Bh30yx6zd2/fNjG7+rN/pkYiCNwdRTLWUOYBUWBBqWetnfja4Aa5bGAmTxxQjA7YgxdCirUbQhQX1T7AGwvxWxmVefhzb3akF4M03CbwaleDE9PU4Orpd6duJfqKKDRx5elXS+I4Q== 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=dO9a4fNE+Q7iodMSvd+7V0mb9DbA/ZcWZZw/dC8L7pfVFo0MtcyFJmLjeu7FRUyUJKZvFM6ltC4MrovwaDPZeabzwZIPLSxyonk5wb/wHq/dzybaeCEVU8uDgbpfQOJY/N7j/23AuQsw2i5/Q1zqJIdhfi1jFFYO22zlEjlmZYhTVU7Z/SNZEsvo5tOsxntuV4jNo3HH58MM3kXLNKZQLab9xVio3Fufi3F2Sd3vXAxJXyXwwMAWmOQeqLJ4xbRvJFNa0uPTp/a9ZVPWQAeYv/nBpEC/Vu4WWYPrVUoqXQuULdXeYWpSzqViNymzzohSKGQM/t9CO+MYNN+hECFhSw== Received: from BN6PR13CA0007.namprd13.prod.outlook.com (2603:10b6:404:10a::17) by DM5PR12MB1548.namprd12.prod.outlook.com (2603:10b6:4:a::23) 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 06:43:09 +0000 Received: from BN8NAM11FT039.eop-nam11.prod.protection.outlook.com (2603:10b6:404:10a:cafe::68) by BN6PR13CA0007.outlook.office365.com (2603:10b6:404:10a::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.8 via Frontend Transport; Wed, 5 May 2021 06:43:09 +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 BN8NAM11FT039.mail.protection.outlook.com (10.13.177.169) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4087.32 via Frontend Transport; Wed, 5 May 2021 06:43:09 +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 06:43:02 +0000 From: Bing Zhao To: , , CC: , , Date: Wed, 5 May 2021 09:41:01 +0300 Message-ID: <20210505064104.30248-15-bingz@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210505064104.30248-1-bingz@nvidia.com> References: <20210427153811.11554-1-bingz@nvidia.com> <20210505064104.30248-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: caa38769-ae17-4fc0-58b1-08d90f910be3 X-MS-TrafficTypeDiagnostic: DM5PR12MB1548: 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: ehdrYQbKC8g80uN7VdFtW5i+Jhk1jvQWva5X8oGNcbTH0HvD4BeeAQ5wq9z0TZSNUeRcmDFZ1Wk2QghHZEoimYwZAuFllAYvsv/0priRTn63BKYwMd8qiFt74EjZXAxhUqetnQLJmEQrnkw+p1GabguNOXDZ+LVOE/mYVYalDF8nxbeZCue5hwLJn+AEwBwsyRZgGKwlzH8N78oVkwmQDAmFmtABr3tQamtJy7p5aHvMWoIwQe+af0qVYfS5foytUSLCrsTSgbLFYrf7vC+6py6OPncrFUQ8sf0IksUeKhe0CXG9iLDIZf6dVWpFJi3pQlRTPf3eGkOFN53aB2Zb4szssbmoPGF8q/XZ6y6cMBLmOvdRoXQp7Ww88dzJPxrSMfBl6TQh02/qFm7aLY/M+8N1VGUfvlyVppMD2VPelbsrZ8l7re/iaqjSOZ7u1RGgJZ/USRbykgiOG11hFt/qdo/fBU3P4j7HISF2XY4rHpUOGngE5RWuIZwjpl7fugdwkPy5CUB66RdlWe2lr3MQAZVa2EdPgS+pkOUxGnUoRnW9MU2DytjkFakvLrZLF/ZNO03A+TF3IGl6QT9RKYe0TZ3JZ0FvhgaYx2PtPOgmecYe6XgYqp/3ZMwXoe7ALeNoDTIXJkp80K3Q4nbdXCQzZ8XzHr/Y4I4qN50i+3+kwJ1llBxQNNQ5aZTWLdAUGn5+ 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)(376002)(136003)(39860400002)(396003)(46966006)(36840700001)(86362001)(26005)(8936002)(356005)(4326008)(70206006)(110136005)(8676002)(16526019)(83380400001)(107886003)(316002)(54906003)(1076003)(6286002)(478600001)(426003)(186003)(7636003)(36906005)(82740400003)(36860700001)(70586007)(7696005)(2906002)(36756003)(47076005)(336012)(55016002)(82310400003)(2616005)(5660300002)(309714004); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 May 2021 06:43:09.1930 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: caa38769-ae17-4fc0-58b1-08d90f910be3 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: BN8NAM11FT039.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1548 Subject: [dpdk-dev] [PATCH v3 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