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 99991A0032; Fri, 1 Oct 2021 21:36:25 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5CA124126F; Fri, 1 Oct 2021 21:35:21 +0200 (CEST) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2082.outbound.protection.outlook.com [40.107.92.82]) by mails.dpdk.org (Postfix) with ESMTP id ECCF84126F for ; Fri, 1 Oct 2021 21:35:19 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MMap1QPzJ4POprknN7TfURybKRtYtbRymYDnuAS5hRTpYaZnNA7lOnvAxd9Lk8eeRqiQiwglYHeqHloIa88F+dJYqhV+zIZ3slaN/WStXWHp72G7RXu6idk/NPZGOC6TfWJPc4oWullIugAZ20Lk4QcKAtxyV3hO0Cyf6m4XdpqAOUWbqaNXD7AfGe8Z7iHJaAbfeJpP8Z5j0D3Fl40jVxhQ3S69A+Ups1Xzhx5ROBt7RVbeho7eHsRjvXwfo9EdQi+GiRo19li87hcX18lC9c5ecLHm8P0kp/6y0g1m1E8cWV7shwlv3gtkP9OQMBP1cjcLldANjGdHr6dMg0Bwqg== 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=HSdPbzorOW5irY8nXGiBwjQDMyULT42/2l5B7zooHFQ=; b=OY4W/n7PNACzBsYeLK8rk3YJ30dhQHWNurXZOCb3AiUrc1DuPeYk1xjQm0/QyKkR6JI7fXO9b03DZbf/n4B00Jiuy9AjkxrDKg8dvqx04hhmOVcte4lE1reARrtWS+QD0cPZImt3QTXPhVrZBtKAuv7+1pRPv5zQsy/Z45zZ/f/WYDphQstupMAqU+cPln1J5vN2236XwFXwWSl/9dENJiVFhNtlThtFvKsLECjvgrc9nlM5D/Hl/x6gQ2PT5K/lg3Gxoozgv09hpXLRYi4WDMGIFWKBjcIoI6kD+Op52hUsEp7fwS9uzg49yhq9X1OXZCBK4zu1IxvixvGYLM6ZXA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=monjalon.net smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine 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=HSdPbzorOW5irY8nXGiBwjQDMyULT42/2l5B7zooHFQ=; b=CLzJZrwGEVGoAeNM9AH0zHnZKMjRiCALErYNYOLymEl1jPS0EhHSMkixHaY9+CNR255B5SwlpNihkak3z6M3jWoWL3eAFEhgiMU3GDfsbTar+dP6dePfqJI88J7HbsvRb9Bhc8ARt6G99+45Lyo/jNfatyxs8IGqfKxeTaWyXm4T4ue//8GKGVV8T5ZpSl8gKevriRsHHF5xoFqUQYLYtm5qK9KiHHNJN6KGk+RBlVIGonTYCCuuveXoqoBKXc1rTqZGFyEqmMd9F+f0Bww9IEj5U0CO/dNl3s9WsypdYZxmvrxVX/pzTa76t3HQJxW6pjE/F/cjogKb8fHA2TRyHA== Received: from BN9PR03CA0046.namprd03.prod.outlook.com (2603:10b6:408:fb::21) by CH2PR12MB4103.namprd12.prod.outlook.com (2603:10b6:610:7e::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.19; Fri, 1 Oct 2021 19:35:15 +0000 Received: from BN8NAM11FT057.eop-nam11.prod.protection.outlook.com (2603:10b6:408:fb:cafe::7) by BN9PR03CA0046.outlook.office365.com (2603:10b6:408:fb::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14 via Frontend Transport; Fri, 1 Oct 2021 19:35:15 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; monjalon.net; dkim=none (message not signed) header.d=none;monjalon.net; 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 BN8NAM11FT057.mail.protection.outlook.com (10.13.177.49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4566.14 via Frontend Transport; Fri, 1 Oct 2021 19:35:15 +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; Fri, 1 Oct 2021 19:35:09 +0000 From: Viacheslav Ovsiienko To: CC: , , , , , Date: Fri, 1 Oct 2021 22:34:15 +0300 Message-ID: <20211001193415.23288-15-viacheslavo@nvidia.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20211001193415.23288-1-viacheslavo@nvidia.com> References: <20210922180418.20663-1-viacheslavo@nvidia.com> <20211001193415.23288-1-viacheslavo@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.20.187.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: 70fb55b9-fa93-47e2-0dbb-08d9851297dd X-MS-TrafficTypeDiagnostic: CH2PR12MB4103: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1051; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: T+JLsK4ZcvWN3Lu9+N4TdSSMKqi8MGc5dA9JdHE4Y9yOPm9A8tMRgClgBcu94VN0ROSc9CYw82Ns4lVIJzDFYZjjxvyZr5UfJQtMScnMilJOIWiKoJ+mOG3q4qw9u0RQMh/zYMtTRMStWxivLXjOrSvCsjPXBpCHtai5SHlFWOQ5KKnYPgxOQIS6efSj1PMn9tKZQ5+iNWldL+lj27qH5d4vb6uWAgvD/QHIuPJuL6jSvEtYCw4RtbfuhLhgwd1dAXAs53qBoF49aSwgNOKyyoXZiKdoWAcHcYqXbjAIn5da0tpf0QlG2LpBzpp3SAoy0MIERlP8IxPTm0w6JTUow+rN6b9PLbqEa4bwTvTAVAO/jiYVXs+dSdn6QkQdDnRSES2I+h6IlU3mAeS/nfyFhEyozyti/YeaeKkP3TVeOLZyuU3HaQkX2dlYPspfhk3Z5C7v+eW9KupAp5MBpmjELEzGLrWXWsM436WUusUgdWZnwYhNWB7V3j4R8CUsGkygyfl1Py6AwI1wuv+LxmsXOntUaIq+hgPMW4wy6Oy4X6d1xsDQBybgDpiXbLZb2TuIgU7b7jDchZILY9c1FU7AiQS/Qc1F4wo5JwurE4dBWLw18z9ROb5pK5KnNEOpgFRaNDSQ6iDVEQ48CYBS2BvZPC7qDjy500sXMdhMbHRJTcxbmNh8lWrK7LcWs01rk2xFz8+Odl/GlFkykRRzpJ0nrQ== 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)(36756003)(6286002)(55016002)(316002)(7636003)(8936002)(36860700001)(4326008)(47076005)(54906003)(8676002)(356005)(426003)(1076003)(508600001)(70586007)(336012)(26005)(70206006)(2616005)(2906002)(83380400001)(86362001)(6916009)(7696005)(5660300002)(16526019)(82310400003)(6666004)(186003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Oct 2021 19:35:15.1651 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 70fb55b9-fa93-47e2-0dbb-08d9851297dd 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: BN8NAM11FT057.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4103 Subject: [dpdk-dev] [PATCH v2 14/14] 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" From: Gregory Etelson Provide flex item recognition, validation and trabslation in flow patterns. Track the flex item referencing. Signed-off-by: Gregory Etelson --- drivers/net/mlx5/mlx5_flow.h | 8 +++- drivers/net/mlx5/mlx5_flow_dv.c | 70 +++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_flow_flex.c | 4 +- 3 files changed, 79 insertions(+), 3 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index a8f8c49dd2..c87d8e3168 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -173,6 +173,10 @@ enum mlx5_feature_name { /* Conntrack item. */ #define MLX5_FLOW_LAYER_ASO_CT (UINT64_C(1) << 35) +/* Flex item */ +#define MLX5_FLOW_ITEM_FLEX (UINT64_C(1) << 36) +#define MLX5_FLOW_ITEM_FLEX_TUNNEL (UINT64_C(1) << 37) + /* Outer Masks. */ #define MLX5_FLOW_LAYER_OUTER_L3 \ (MLX5_FLOW_LAYER_OUTER_L3_IPV4 | MLX5_FLOW_LAYER_OUTER_L3_IPV6) @@ -187,7 +191,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 \ @@ -686,6 +691,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 a3c35a5edf..3a785e7925 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -6825,6 +6825,38 @@ 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 *last_item, + 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; + *last_item = flex->tunnel ? MLX5_FLOW_ITEM_FLEX_TUNNEL : + MLX5_FLOW_ITEM_FLEX; + return 0; +} + /** * Internal validation function. For validating both actions and items. * @@ -7266,6 +7298,14 @@ 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: + if (item_flags & MLX5_FLOW_ITEM_FLEX) + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ITEM, + NULL, "multiple flex items not supported"); + ret = flow_dv_validate_item_flex(dev, items, + &last_item, error); + break; default: return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ITEM, @@ -10123,6 +10163,25 @@ 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) +{ + 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 (!(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); +} + static uint32_t matcher_zero[MLX5_ST_SZ_DW(fte_match_param)] = { 0 }; #define HEADER_IS_ZERO(match_criteria, headers) \ @@ -13520,6 +13579,10 @@ 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); default: break; } @@ -14393,6 +14456,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) @@ -18014,5 +18083,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 */ diff --git a/drivers/net/mlx5/mlx5_flow_flex.c b/drivers/net/mlx5/mlx5_flow_flex.c index f695198833..f1567ddfdd 100644 --- a/drivers/net/mlx5/mlx5_flow_flex.c +++ b/drivers/net/mlx5/mlx5_flow_flex.c @@ -1164,8 +1164,8 @@ flow_dv_item_release(struct rte_eth_dev *dev, &flex->devx_fp->entry); flex->devx_fp = NULL; mlx5_flex_free(priv, flex); - if (rc) - return rte_flow_error_set(error, rc, + if (rc < 0) + return rte_flow_error_set(error, EBUSY, RTE_FLOW_ERROR_TYPE_ITEM, NULL, "flex item release failure"); return 0; -- 2.18.1