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 F391DA0524; Wed, 5 May 2021 09:21:02 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4AAE3410FF; Wed, 5 May 2021 09:20:02 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2069.outbound.protection.outlook.com [40.107.220.69]) by mails.dpdk.org (Postfix) with ESMTP id DBCFE410FB for ; Wed, 5 May 2021 09:20:00 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ak0Pi2+kIWxpfUbQjGzKaC6YrzUDBkRn6ESabEmX/wb0nSFG2IjXJPDJUGmxlczARqPH6qZWyx0/igHNPw/HzOUyV2gYSbRx8wXOKRYtvBTHtxyDdrG0enPtxtfLs8Dvts+l1ngrQB0Ic0/MH5q39IJ1U6M+QS38K/tsw1eLj/tbyDQdRpEEYcWv8M4eR8XBB5WxGwwFheghugiA/eiI4sPg+ft1pDtVUQFhkwmhUsDrCkqMtv9IQ6FYVlPonb79Tot7VJeFOZiWO5ghXhwYH5oo591CcNr4iQZE8x6cZ9MUhQrEMspvFw284tpMKtvUGLsjniwjohMVVjDqFiy+1w== 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=fE2pRAjf4ySJh5RT1BadgB3oxf/Yg1+1WJdLbw7rFmY=; b=C4fvekLwps2DItPZY6jsPIisdVInrvBmpMOHeXpfLf0z2k8/PXDu9zPVw1j2V7L9t0lRrEC2EbTnVNJZzhaNtz79KBykOhwILKhnKS4dNE7Acd0v5QXOQdN6NfmSuaFzzBCUy3gJhGn33lD2xdv5EkOCvq53FMbOslOZECRv4Yv+Rnvr7UAk7kwMyC8bWzzQBCYnRMH8QF0ghUqM+ZoiJbe0bxaG9uJsoDdQiZuoX8UR81VMg0mj2WFYVAQFgzifI0mmTLLISjHoEWTB0Q0Ew8AThUTQ/tHzfk4YbqWvCwJtMnTCLXvH5YSUoMHx4HduWd8r0301LuVh2EqMQOxalw== 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=fE2pRAjf4ySJh5RT1BadgB3oxf/Yg1+1WJdLbw7rFmY=; b=jalcKmpc4eXT5AfKqZubPpMoUgYHMKP5KTgGx1Awu4AesjhrYXxjSrHmnb/TIla90S9YI9EangtBKA21n9h//Lg5jKlgqPsJbXzp5/Ql8EWmmF1p77/oDK5nynfeiS1ROLilNviToRfEI2q2zbX3ZY9c0Z11OILqNmnLyZB2zkE5PjpY0VGIs7eeE4MF6C0EL7sizWjrbueqRzUvnp+rOFabeHmjFWRtzJrg1G/KVtMbdWU5PBfg1qyIbx8tJz5Ww1eUMoj4qaLtXDPpmDyIgmTdOUNATqmLmUidrMQWuzd7zJyTMA/a2KMSAbPCuqtY+iUE1m/MQNFjusSEfM9y5g== Received: from DM5PR10CA0018.namprd10.prod.outlook.com (2603:10b6:4:2::28) by DM6PR12MB3561.namprd12.prod.outlook.com (2603:10b6:5:3e::26) 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 07:19:59 +0000 Received: from DM6NAM11FT005.eop-nam11.prod.protection.outlook.com (2603:10b6:4:2:cafe::2c) by DM5PR10CA0018.outlook.office365.com (2603:10b6:4:2::28) 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 07:19:59 +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 DM6NAM11FT005.mail.protection.outlook.com (10.13.172.238) 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:19:59 +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:19:56 +0000 From: Bing Zhao To: , , CC: , , Date: Wed, 5 May 2021 10:19:12 +0300 Message-ID: <20210505071917.31802-13-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: 7bad735c-6f5b-4629-5f7f-08d90f963101 X-MS-TrafficTypeDiagnostic: DM6PR12MB3561: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jTgeIgQrkMS3qgaRCf1no7mYyUXw9JpMERwtpjKXtObBQVqvYmawUy65Xav+gwdYwrK7Yu3Lqmp+K5QFyfRdX+JfH54MIP01inceZyd8fOk6M6WlJhz9gPr35+zVzopyBWZp8zfraLqiaM+uMn1HZsKnl+sJNcaDAFy3KZP/C7CjjgR2q9LOw248AGesJNgoPxziVw8i+alFZZuqy6qd4IBau7yvEcctRHeHqk+YzorUV8Yzya9Jkv1EPprXIzDEHnnG4Q+rqLvOqPxzyVJ6qYw5IuQ7sSWuQMwoTgtuLKbYNVyXZbMAPYYcvIF2Gkcjt45ncYhqgLpHGfv0tahPbpwJTH7cGpYxBaQlMl2pjeAARSw1mKWf7vRpKZxBDmkVeZlGXbQdvH6y3R2iBivEfd2ACkisbmxeslI9TgNeN+Mp58Ccq9/9HAy2v9SBV9OS1x+/NRC8OSmK5scNWq+gANOfLDYq1gQjlnHHI7hYYaLVAu56NKUm29NxIBBckzZllvE+VaqVvID+LM/IIKK9zT4y+AYBgCBVocQcYP8I7XsO/pxvtXalsRyWtzPmTfGkZ9DI6edd1JVeo4Vv+7kbqXAiT6TpTtpUVbCdKeLOaqQl4Axjbp2YAC6VvNIzJS+PtHbQ95FfzUCddOx2aSC3+Q== 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)(376002)(396003)(346002)(39860400002)(136003)(36840700001)(46966006)(4326008)(36756003)(70586007)(5660300002)(426003)(2906002)(70206006)(2616005)(316002)(82740400003)(7696005)(26005)(82310400003)(336012)(54906003)(55016002)(16526019)(83380400001)(110136005)(186003)(6286002)(47076005)(8676002)(1076003)(6666004)(36906005)(107886003)(86362001)(478600001)(36860700001)(356005)(8936002)(7636003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 May 2021 07:19:59.0131 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7bad735c-6f5b-4629-5f7f-08d90f963101 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: DM6NAM11FT005.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3561 Subject: [dpdk-dev] [PATCH v4 12/17] net/mlx5: add translation of CT item 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 return register of the DR action will be used for matching. After the ASO CT checking of a TCP packet, the syndrome is filled in the register. Only the 8 LSB should be used. A converting from RTE_FLOW_CONNTRACK_FLAG* to the syndrome should be done after checing the spec and mask fields. Signed-off-by: Bing Zhao --- drivers/net/mlx5/mlx5_flow.h | 7 ++++ drivers/net/mlx5/mlx5_flow_dv.c | 62 +++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 286e3fb6a4..eb0bb42161 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -405,6 +405,13 @@ enum mlx5_feature_name { /* Maximum number of fields to modify in MODIFY_FIELD */ #define MLX5_ACT_MAX_MOD_FIELDS 5 +/* Syndrome bits definition for connection tracking. */ +#define MLX5_CT_SYNDROME_VALID (0x0 << 6) +#define MLX5_CT_SYNDROME_INVALID (0x1 << 6) +#define MLX5_CT_SYNDROME_TRAP (0x2 << 6) +#define MLX5_CT_SYNDROME_STATE_CHANGE (0x1 << 1) +#define MLX5_CT_SYNDROME_BAD_PACKET (0x1 << 0) + enum mlx5_flow_drv_type { MLX5_FLOW_TYPE_MIN, MLX5_FLOW_TYPE_DV, diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 14af900267..b0858e3df8 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -9379,6 +9379,64 @@ flow_dv_translate_item_ecpri(struct rte_eth_dev *dev, void *matcher, } } +/* + * Add connection tracking status item to matcher + * + * @param[in] dev + * The devich to configure through. + * @param[in, out] matcher + * Flow matcher. + * @param[in, out] key + * Flow matcher value. + * @param[in] item + * Flow pattern to translate. + */ +static void +flow_dv_translate_item_aso_ct(struct rte_eth_dev *dev, + void *matcher, void *key, + const struct rte_flow_item *item) +{ + uint32_t reg_value = 0; + int reg_id; + /* 8LSB 0b 11/0000/11, middle 4 bits are reserved. */ + uint32_t reg_mask = 0; + const struct rte_flow_item_conntrack *spec = item->spec; + const struct rte_flow_item_conntrack *mask = item->mask; + uint32_t flags; + struct rte_flow_error error; + + if (!mask) + mask = &rte_flow_item_conntrack_mask; + if (!spec || !mask->flags) + return; + flags = spec->flags & mask->flags; + /* The conflict should be checked in the validation. */ + if (flags & RTE_FLOW_CONNTRACK_PKT_STATE_VALID) + reg_value |= MLX5_CT_SYNDROME_VALID; + if (flags & RTE_FLOW_CONNTRACK_PKT_STATE_CHANGED) + reg_value |= MLX5_CT_SYNDROME_STATE_CHANGE; + if (flags & RTE_FLOW_CONNTRACK_PKT_STATE_INVALID) + reg_value |= MLX5_CT_SYNDROME_INVALID; + if (flags & RTE_FLOW_CONNTRACK_PKT_STATE_DISABLED) + reg_value |= MLX5_CT_SYNDROME_TRAP; + if (flags & RTE_FLOW_CONNTRACK_PKT_STATE_BAD) + reg_value |= MLX5_CT_SYNDROME_BAD_PACKET; + if (mask->flags & (RTE_FLOW_CONNTRACK_PKT_STATE_VALID | + RTE_FLOW_CONNTRACK_PKT_STATE_INVALID | + RTE_FLOW_CONNTRACK_PKT_STATE_DISABLED)) + reg_mask |= 0xc0; + if (mask->flags & RTE_FLOW_CONNTRACK_PKT_STATE_CHANGED) + reg_mask |= MLX5_CT_SYNDROME_STATE_CHANGE; + if (mask->flags & RTE_FLOW_CONNTRACK_PKT_STATE_BAD) + reg_mask |= MLX5_CT_SYNDROME_BAD_PACKET; + /* The REG_C_x value could be saved during startup. */ + reg_id = mlx5_flow_get_reg_id(dev, MLX5_ASO_CONNTRACK, 0, &error); + if (reg_id == REG_NON) + return; + flow_dv_match_meta_reg(matcher, key, (enum modify_reg)reg_id, + reg_value, reg_mask); +} + static uint32_t matcher_zero[MLX5_ST_SZ_DW(fte_match_param)] = { 0 }; #define HEADER_IS_ZERO(match_criteria, headers) \ @@ -12322,6 +12380,10 @@ flow_dv_translate(struct rte_eth_dev *dev, /* No other protocol should follow eCPRI layer. */ last_item = MLX5_FLOW_LAYER_ECPRI; break; + case RTE_FLOW_ITEM_TYPE_CONNTRACK: + flow_dv_translate_item_aso_ct(dev, match_mask, + match_value, items); + break; default: break; } -- 2.27.0