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 EF786A0C57; Mon, 1 Nov 2021 10:16:38 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 038F341148; Mon, 1 Nov 2021 10:16:08 +0100 (CET) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2056.outbound.protection.outlook.com [40.107.92.56]) by mails.dpdk.org (Postfix) with ESMTP id 0EC6341150 for ; Mon, 1 Nov 2021 10:16:07 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FEysnz5rHKYYyL3ocNvTeQWLGc4UC/A6VdK7RCBND8yr9hxrNcQyooz54HOe97NwGZdFfXQeKAbj1Dkqt4/J+TEj7rjjCRog0ZuCHG4Qjv1CxUKPuC29RAptlWZqrdNeFN9OD4C+A0ECsK6Hdo/NlkfkdfGZAElb59b/cHEhnm+34okHA4JQGZSRNRe4pQK0I/t7bbDlaslYLiu3qYwWmDeACyYfuTb4vzL784KRBuT+S9Tsdslf9NiHjiuMKW+3yiRNw6Xfs7A+J2KbCTIr7Yt+5ThSxsVvX38iLD/bkW7wFV2JX0/q5+qTjoV1nLqIGkoPgqz9mxo1oJ5oY3oqqg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=eEqADj1gvHULokwfaZvdtLZHRm68JqUA0Zj7t9/JFI8=; b=lrTtT+2zezk0DPcgyn33eo0knyzoDzG0C0WjdjMu+/5unhy8lM6CKT4vKsstDalmhu6CvyRiqQKkapxKS+6N3vatFxmRew2FWOIuBfa82H73XsdqXiajo7SHeypa4QWmVVyPZFWTtkWGLpTxrHD1gPc0EvHglUMbu1tmd2XJu8VHJLnU6hcEyAxi6832AKVBBqEwkdl4TBgYfg5biOe9TKoRdQ5qyek/pJH6rKmWmrJkx2AKNPv8RNUMKPZmTsOY8v4lSTBkiGp9KjDfq0ELokzpxLBaynftpP5C7NE+gBq+GjiIHcW2hzx1/V4mWRz9wSHN8tQ9gSnTGADVeZUp2Q== 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=quarantine sp=quarantine 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=eEqADj1gvHULokwfaZvdtLZHRm68JqUA0Zj7t9/JFI8=; b=YQl7aHQk/pw2UK8bg+Pe1uhAuMD03zUUqWYQ9lWNKH4voBbN0kG3n/8/tR+31od35KBn/7velIyr8i2iRmlex8gMlNcegBLngRYe63fVRGqO6FtXUXM8UcJTG4E/ofW6kEOYejjcvOydV+SisSrqL9TKSvSASanxcL+wr4EDjWB4fyFL3sYsyx8VqXE6MxJN3D3URMkmHP7SMZeuzMo+GExGv5w/+eG47JkN/UfMOKSzSTC0qarkp7jFCV8I+bTuMFtTdepcjj/dXyILcmqvZEawG2YCuqpS6p+nKw2Clnn8ggTK8pqSLk6pbkpVdowY2EFp5gf/KUoHQKAgyB26ZQ== Received: from BN9PR03CA0273.namprd03.prod.outlook.com (2603:10b6:408:f5::8) by DM5PR12MB1434.namprd12.prod.outlook.com (2603:10b6:3:77::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.15; Mon, 1 Nov 2021 09:16:05 +0000 Received: from BN8NAM11FT029.eop-nam11.prod.protection.outlook.com (2603:10b6:408:f5:cafe::9f) by BN9PR03CA0273.outlook.office365.com (2603:10b6:408:f5::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.15 via Frontend Transport; Mon, 1 Nov 2021 09:16:05 +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 BN8NAM11FT029.mail.protection.outlook.com (10.13.177.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4649.14 via Frontend Transport; Mon, 1 Nov 2021 09:16:03 +0000 Received: from nvidia.com (172.20.187.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 1 Nov 2021 09:15:53 +0000 From: Gregory Etelson To: , , CC: Date: Mon, 1 Nov 2021 11:15:14 +0200 Message-ID: <20211101091514.3891-10-getelson@nvidia.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211101091514.3891-1-getelson@nvidia.com> References: <20211101091514.3891-1-getelson@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL111.nvidia.com (172.20.187.18) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 036ca1c7-3a74-41f3-3d21-08d99d183b38 X-MS-TrafficTypeDiagnostic: DM5PR12MB1434: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1227; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: R/0mm+CZj2xypy9DfKHe0gnn92Y9feD9stNjCS9UEN2IUC6gwU23wqaXpcRE0bJvKlsrzIa6afp3gV6lz7oWpmmeHFEieTjQN300fNAfPPrd05eFwGwMo8MO+Ub7j7pyDJoJV9m3Fw9jRgm908f5lndagSbQgQ1JJbxytZRxbNyL1vOCAoEQktOCCQnXOaZ1EVqiZn3GUjredvk1DvpbaT0VIKqLdNUe3xdC0xxbpfW4MJFh8V4aYZppQQiTiipgh2O0cfY0Uwn3JXu1kMhcVcWCEBCUay7hHNN9ZpKfp5MCj3XcznrQs76rrZYLm9A1wVpym+VcpPDfUF9B+4CPiZoZxmLEDZpKW40sKC2H4qfWGpdXNGR6wZ+12aJZF8lQTQJCAXgAyMcY1CPjMvs3yHqilg2NAuzP7XJ/R38/H6/vaWhwGMhtUAFAF8rjZK/ymSsb/ftBH2Uu+jnLJEXe0fMqeY8xxRvrglGXeFGtDnGGpungfro7+DQN7h3kakVNsj2yeWkP3bXG36fzsYjXavJCfvcowNKi5xK0mFS3tanp5RDgRFf3JD4+6darpr3YC/onLCfi1KC942Nw4vXHFnPURge6HHi2dGQ+rNzyxoJDXZ1kbJ5MZA2TI6ow56AzE8cPNWgKgrTOyTg+OCzIna0gY/JCQFZCSaJ4zvXsbkIAD1Jy5IlFYA1wRRajnXDNv0aZ1oIvT31EXxQIoX0i1Q== 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)(36840700001)(46966006)(336012)(4326008)(107886003)(6636002)(82310400003)(8676002)(426003)(508600001)(6666004)(110136005)(86362001)(316002)(36756003)(8936002)(70206006)(5660300002)(2616005)(83380400001)(16526019)(70586007)(1076003)(186003)(26005)(6286002)(7696005)(36860700001)(55016002)(7636003)(47076005)(2906002)(356005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Nov 2021 09:16:03.4721 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 036ca1c7-3a74-41f3-3d21-08d99d183b38 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: BN8NAM11FT029.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1434 Subject: [dpdk-dev] [PATCH 9/9] net/mlx5: handle flex item in flows 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" Provide flex item recognition, validation and translation in flow patterns. Track the flex item referencing. Signed-off-by: Gregory Etelson Reviewed-by: Viacheslav Ovsiienko --- drivers/net/mlx5/mlx5_flow.h | 9 ++- drivers/net/mlx5/mlx5_flow_dv.c | 124 ++++++++++++++++++++++++++++++++ 2 files changed, 132 insertions(+), 1 deletion(-) diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index c1b6198adf..046516efd0 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -176,6 +176,11 @@ enum mlx5_feature_name { /* Conntrack item. */ #define MLX5_FLOW_LAYER_ASO_CT (UINT64_C(1) << 35) +/* Flex item */ +#define MLX5_FLOW_ITEM_OUTER_FLEX (UINT64_C(1) << 36) +#define MLX5_FLOW_ITEM_INNER_FLEX (UINT64_C(1) << 37) +#define MLX5_FLOW_ITEM_FLEX_TUNNEL (UINT64_C(1) << 38) + /* Outer Masks. */ #define MLX5_FLOW_LAYER_OUTER_L3 \ (MLX5_FLOW_LAYER_OUTER_L3_IPV4 | MLX5_FLOW_LAYER_OUTER_L3_IPV6) @@ -190,7 +195,8 @@ enum mlx5_feature_name { (MLX5_FLOW_LAYER_VXLAN | MLX5_FLOW_LAYER_VXLAN_GPE | \ MLX5_FLOW_LAYER_GRE | MLX5_FLOW_LAYER_NVGRE | MLX5_FLOW_LAYER_MPLS | \ MLX5_FLOW_LAYER_IPIP | MLX5_FLOW_LAYER_IPV6_ENCAP | \ - MLX5_FLOW_LAYER_GENEVE | MLX5_FLOW_LAYER_GTP) + MLX5_FLOW_LAYER_GENEVE | MLX5_FLOW_LAYER_GTP | \ + MLX5_FLOW_ITEM_FLEX_TUNNEL) /* Inner Masks. */ #define MLX5_FLOW_LAYER_INNER_L3 \ @@ -689,6 +695,7 @@ struct mlx5_flow_handle { uint32_t is_meter_flow_id:1; /**< Indate if flow_id is for meter. */ uint32_t mark:1; /**< Metadate rxq mark flag. */ uint32_t fate_action:3; /**< Fate action type. */ + uint32_t flex_item; /**< referenced Flex Item bitmask. */ union { uint32_t rix_hrxq; /**< Hash Rx queue object index. */ uint32_t rix_jump; /**< Index to the jump action resource. */ diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 1b92dd75ff..c12a7a986d 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -6733,6 +6733,88 @@ flow_dv_validate_item_integrity(struct rte_eth_dev *dev, return 0; } +static int +flow_dv_validate_item_flex(struct rte_eth_dev *dev, + const struct rte_flow_item *item, + uint64_t item_flags, + uint64_t *last_item, + bool is_inner, + struct rte_flow_error *error) +{ + const struct rte_flow_item_flex *flow_spec = item->spec; + const struct rte_flow_item_flex *flow_mask = item->mask; + struct mlx5_flex_item *flex; + + if (!flow_spec) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, NULL, + "flex flow item spec cannot be NULL"); + if (!flow_mask) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, NULL, + "flex flow item mask cannot be NULL"); + if (item->last) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ITEM, NULL, + "flex flow item last not supported"); + if (mlx5_flex_acquire_index(dev, flow_spec->handle, false) < 0) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, NULL, + "invalid flex flow item handle"); + flex = (struct mlx5_flex_item *)flow_spec->handle; + switch (flex->tunnel_mode) { + case FLEX_TUNNEL_MODE_SINGLE: + if (item_flags & + (MLX5_FLOW_ITEM_OUTER_FLEX | MLX5_FLOW_ITEM_INNER_FLEX)) + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + NULL, "multiple flex items not supported"); + break; + case FLEX_TUNNEL_MODE_OUTER: + if (is_inner) + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + NULL, "inner flex item was not configured"); + if (item_flags & MLX5_FLOW_ITEM_OUTER_FLEX) + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ITEM, + NULL, "multiple flex items not supported"); + break; + case FLEX_TUNNEL_MODE_INNER: + if (!is_inner) + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + NULL, "outer flex item was not configured"); + if (item_flags & MLX5_FLOW_ITEM_INNER_FLEX) + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + NULL, "multiple flex items not supported"); + break; + case FLEX_TUNNEL_MODE_MULTI: + if ((is_inner && (item_flags & MLX5_FLOW_ITEM_INNER_FLEX)) || + (!is_inner && (item_flags & MLX5_FLOW_ITEM_OUTER_FLEX))) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + NULL, "multiple flex items not supported"); + } + break; + case FLEX_TUNNEL_MODE_TUNNEL: + if (is_inner || (item_flags & MLX5_FLOW_ITEM_FLEX_TUNNEL)) + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + NULL, "multiple flex tunnel items not supported"); + break; + default: + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + NULL, "invalid flex item configuration"); + } + *last_item = flex->tunnel_mode == FLEX_TUNNEL_MODE_TUNNEL ? + MLX5_FLOW_ITEM_FLEX_TUNNEL : is_inner ? + MLX5_FLOW_ITEM_INNER_FLEX : MLX5_FLOW_ITEM_OUTER_FLEX; + return 0; +} + /** * Internal validation function. For validating both actions and items. * @@ -7174,6 +7256,13 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, * list it here as a supported type */ break; + case RTE_FLOW_ITEM_TYPE_FLEX: + ret = flow_dv_validate_item_flex(dev, items, item_flags, + &last_item, + tunnel != 0, error); + if (ret < 0) + return ret; + break; default: return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ITEM, @@ -10038,6 +10127,27 @@ flow_dv_translate_item_aso_ct(struct rte_eth_dev *dev, reg_value, reg_mask); } +static void +flow_dv_translate_item_flex(struct rte_eth_dev *dev, void *matcher, void *key, + const struct rte_flow_item *item, + struct mlx5_flow *dev_flow, bool is_inner) +{ + const struct rte_flow_item_flex *spec = + (const struct rte_flow_item_flex *)item->spec; + int index = mlx5_flex_acquire_index(dev, spec->handle, false); + + MLX5_ASSERT(index >= 0 && index <= (int)(sizeof(uint32_t) * CHAR_BIT)); + if (index < 0) + return; + if (!(dev_flow->handle->flex_item & RTE_BIT32(index))) { + /* Don't count both inner and outer flex items in one rule. */ + if (mlx5_flex_acquire_index(dev, spec->handle, true) != index) + MLX5_ASSERT(false); + dev_flow->handle->flex_item |= RTE_BIT32(index); + } + mlx5_flex_flow_translate_item(dev, matcher, key, item, is_inner); +} + static uint32_t matcher_zero[MLX5_ST_SZ_DW(fte_match_param)] = { 0 }; #define HEADER_IS_ZERO(match_criteria, headers) \ @@ -13455,6 +13565,13 @@ flow_dv_translate(struct rte_eth_dev *dev, flow_dv_translate_item_aso_ct(dev, match_mask, match_value, items); break; + case RTE_FLOW_ITEM_TYPE_FLEX: + flow_dv_translate_item_flex(dev, match_mask, + match_value, items, + dev_flow, tunnel != 0); + last_item = tunnel ? MLX5_FLOW_ITEM_INNER_FLEX : + MLX5_FLOW_ITEM_OUTER_FLEX; + break; default: break; } @@ -14329,6 +14446,12 @@ flow_dv_destroy(struct rte_eth_dev *dev, struct rte_flow *flow) if (!dev_handle) return; flow->dev_handles = dev_handle->next.next; + while (dev_handle->flex_item) { + int index = rte_bsf32(dev_handle->flex_item); + + mlx5_flex_release_index(dev, index); + dev_handle->flex_item &= ~RTE_BIT32(index); + } if (dev_handle->dvh.matcher) flow_dv_matcher_release(dev, dev_handle); if (dev_handle->dvh.rix_sample) @@ -17945,5 +18068,6 @@ const struct mlx5_flow_driver_ops mlx5_flow_dv_drv_ops = { .item_create = flow_dv_item_create, .item_release = flow_dv_item_release, }; + #endif /* HAVE_IBV_FLOW_DV_SUPPORT */ -- 2.33.1