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 93F0142A81; Sun, 7 May 2023 09:41:10 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4901042D3C; Sun, 7 May 2023 09:40:49 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2072.outbound.protection.outlook.com [40.107.93.72]) by mails.dpdk.org (Postfix) with ESMTP id E2FC542D4B for ; Sun, 7 May 2023 09:40:47 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Oojs0FMqfe1/HUPUqrhzAQXZGNL3Cf+7sV0W4cZpEr4ivPTV9bMMnM6zDRzXnNCcwIF5Q3w2ApJRKm9af/43EM7wR9oj6ZK3X11ghuTJviJuHUu/luy7ytsui4iCGxW1nA69pT1d0IeicSw0DHv9xeIb1UOdq0cx+1stSaWP5Kz7Z0iZ84qW/+w6Q+el0eqo2C2KMS95rWa4pziopScG5aSJsnSlVzqdxbDCpqBR7B+70kFdCtfF8yJW6GAr/2Y1jWDKnOJiQm6G8/SMCy9Qs6c/xkWH26a7hCWsv448mcI9qakkiCgJuD3qIRhk1M1lP1rJsrBp6AjXsdhAnoxcaw== 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=K9vDvCV8HDV4YIzR7KmkHYavTKH1zSJYNXHrDQLrtYw=; b=HzA7dwneiWfUyqOsXQCpepOsjxXCAH5qkcXTqZ5T+iCNJIhePrBu9MLl42TFUMRa83UTBXkOsIci+CVs4SFdmauVomzLFjK79ofmWMcZZ89LCFZUSn5J/K0NaTBJ6Qo/TtRSQ2UQCIJ5YHl+KUmw9d8+mTzCgo++Qzd6z3qzQm6Z5ea+yWotVlSNtc3Oja8N3ruxhu6VJwAOe7qnebHjofpjOX1am+7lEki7j5dA1Pj1tnkSlbiePdl4qwGDEdglr6gZheFwGV77SjaUJl7kWNUP6rKkwyYphAkGCHA8GO9MU5z3Us6pMgqPAT1qiyD+j8d8tJltjqZ10JzwCP6ZEA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject 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=K9vDvCV8HDV4YIzR7KmkHYavTKH1zSJYNXHrDQLrtYw=; b=M32i7ZUeNqh0MQdSUFd7Zz5ywQ1WfQgzI5B5QcP9Y4HHPgUxjGlBJqFRmwvLQJcR0UnkDlAYfeiwEDTQYj0oKvwdwu0iN6b9VxR6bXp0apuEP2W0zG7bUO0iZ/XG918HqlGV6zwwVgnSnLi9qPOmMaOhZolJpZYfCZMKBTz6w14yucWB3z4X3QU1THps+N7d1JwEEq4hGv4clFt8SZ4GL5mrUpKzBrAcN3lHrc+Qj/4LKqlZi5m2a07saiTGeLkKBY7TrE57Rp4fY4UQb4ToUQIEcF7BUka9EJm5ZfzW0MhqLUA3N3ooT3kH3WwLan5bW1zRv8qB/6ByB5pN6uF+Sg== Received: from BN8PR07CA0003.namprd07.prod.outlook.com (2603:10b6:408:ac::16) by BY5PR12MB4130.namprd12.prod.outlook.com (2603:10b6:a03:20b::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.30; Sun, 7 May 2023 07:40:43 +0000 Received: from BN8NAM11FT113.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ac:cafe::59) by BN8PR07CA0003.outlook.office365.com (2603:10b6:408:ac::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.32 via Frontend Transport; Sun, 7 May 2023 07:40:43 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by BN8NAM11FT113.mail.protection.outlook.com (10.13.176.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.31 via Frontend Transport; Sun, 7 May 2023 07:40:42 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Sun, 7 May 2023 00:40:25 -0700 Received: from nvidia.com (10.126.231.37) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Sun, 7 May 2023 00:40:22 -0700 From: Gregory Etelson To: CC: , , , Viacheslav Ovsiienko , Matan Azrad Subject: [PATCH v3 5/5] mlx5dr: Definer, translate RTE quota item Date: Sun, 7 May 2023 10:39:52 +0300 Message-ID: <20230507073952.4061-6-getelson@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230507073952.4061-1-getelson@nvidia.com> References: <20230118125556.23622-1-getelson@nvidia.com> <20230507073952.4061-1-getelson@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.231.37] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT113:EE_|BY5PR12MB4130:EE_ X-MS-Office365-Filtering-Correlation-Id: cb28fe00-3bdc-484a-2e10-08db4ece5cb0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cpSXC5kBR7hDWnhjSnUvR6N7P0LZAgT5dgO+kiSwI5GsW7XNDh/YfaSfxUjj8ZnQWcJu1KZklJ2G/aK16muY+nuZ1eT7nn63E4OrLEjMGfC404Fl02Idxoea00vWkI6OfoYhGG/DB0/cQudjRviUmvGy9px/ccfxJtfTSWL/b919I97+z8sM0F/m4bwNzC54NtwEbSTPoh1DKfzYUzgKv0rdpMWmiUVoA1KLn4cIslYQfdbbdmfBkDespDXUfpYYFChSZdcwT5/NknhNwM9H05l37CjPpiK2xQaJEA1GdDbGabnkFsO42wvBAtBQRVsxfvhd9b4Q4qvWo/olgFpbz9D30/2hE66mffQ9CRoe3BMUuKmAeQoxTMry/rmvLO1GGx/T4W2jisHvCtq9ol+rXiE4rMnJ1/jcART0eR6tfUv+rSZpVQTRsrT5BVTjd/9HaM7XwlTXyr0pVFiYUT3eBUVp4aMUbpq4ZrccfNOaaSWgeZ7Y0mnw+VlEH3BtdackKdh5ghSHyXLqY1IiNVr2csJCkD48aOMya1zxLVpm7pcXLCLCeTHzD74dJgCX6qAVrnF6L1E8itgbNp+3mVD5ynlSBo1AKzIvAT42IFD6O2EQsL10B/I09VK3AoFGPRP7yBXPmRF2vsEGUCnrDJ0OPwo9W3EcgNajYIZF0Jmj/EpCu19puRa9+1YxASHHsdav X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(396003)(136003)(376002)(39850400004)(346002)(451199021)(46966006)(36840700001)(7696005)(478600001)(70206006)(6916009)(4326008)(70586007)(6666004)(316002)(54906003)(36756003)(86362001)(47076005)(336012)(426003)(83380400001)(1076003)(26005)(107886003)(2616005)(36860700001)(8676002)(8936002)(15650500001)(2906002)(5660300002)(82310400005)(41300700001)(55016003)(40480700001)(186003)(6286002)(16526019)(7636003)(82740400003)(356005)(32563001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2023 07:40:42.6461 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cb28fe00-3bdc-484a-2e10-08db4ece5cb0 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT113.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4130 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 MLX5 PMD implements QUOTA with Meter object. PMD Quota action translation implicitly increments Meter register value after HW assigns it. Meter register values are: HW QUOTA(HW+1) QUOTA state RED 0 1 (01b) BLOCK YELLOW 1 2 (10b) PASS GREEN 2 3 (11b) PASS Quota item checks Meter register bit 1 value to determine state: SPEC MASK PASS 2 (10b) 2 (10b) BLOCK 0 (00b) 2 (10b) Signed-off-by: Gregory Etelson Acked-by: Viacheslav Ovsiienko --- drivers/net/mlx5/hws/mlx5dr_definer.c | 63 +++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/drivers/net/mlx5/hws/mlx5dr_definer.c b/drivers/net/mlx5/hws/mlx5dr_definer.c index f92d3e8e1f..2d505f1908 100644 --- a/drivers/net/mlx5/hws/mlx5dr_definer.c +++ b/drivers/net/mlx5/hws/mlx5dr_definer.c @@ -21,6 +21,9 @@ #define STE_UDP 0x2 #define STE_ICMP 0x3 +#define MLX5DR_DEFINER_QUOTA_BLOCK 0 +#define MLX5DR_DEFINER_QUOTA_PASS 2 + /* Setter function based on bit offset and mask, for 32bit DW*/ #define _DR_SET_32(p, v, byte_off, bit_off, mask) \ do { \ @@ -1447,6 +1450,62 @@ mlx5dr_definer_conv_item_tag(struct mlx5dr_definer_conv_data *cd, return 0; } +static void +mlx5dr_definer_quota_set(struct mlx5dr_definer_fc *fc, + const void *item_data, uint8_t *tag) +{ + /** + * MLX5 PMD implements QUOTA with Meter object. + * PMD Quota action translation implicitly increments + * Meter register value after HW assigns it. + * Meter register values are: + * HW QUOTA(HW+1) QUOTA state + * RED 0 1 (01b) BLOCK + * YELLOW 1 2 (10b) PASS + * GREEN 2 3 (11b) PASS + * + * Quota item checks Meter register bit 1 value to determine state: + * SPEC MASK + * PASS 2 (10b) 2 (10b) + * BLOCK 0 (00b) 2 (10b) + * + * item_data is NULL when template quota item is non-masked: + * .. / quota / .. + */ + + const struct rte_flow_item_quota *quota = item_data; + uint32_t val; + + if (quota && quota->state == RTE_FLOW_QUOTA_STATE_BLOCK) + val = MLX5DR_DEFINER_QUOTA_BLOCK; + else + val = MLX5DR_DEFINER_QUOTA_PASS; + + DR_SET(tag, val, fc->byte_off, fc->bit_off, fc->bit_mask); +} + +static int +mlx5dr_definer_conv_item_quota(struct mlx5dr_definer_conv_data *cd, + __rte_unused struct rte_flow_item *item, + int item_idx) +{ + int mtr_reg = flow_hw_get_reg_id(RTE_FLOW_ITEM_TYPE_METER_COLOR, 0); + struct mlx5dr_definer_fc *fc; + + if (mtr_reg < 0) { + rte_errno = EINVAL; + return rte_errno; + } + + fc = mlx5dr_definer_get_register_fc(cd, mtr_reg); + if (!fc) + return rte_errno; + + fc->tag_set = &mlx5dr_definer_quota_set; + fc->item_idx = item_idx; + return 0; +} + static int mlx5dr_definer_conv_item_metadata(struct mlx5dr_definer_conv_data *cd, struct rte_flow_item *item, @@ -2163,6 +2222,10 @@ mlx5dr_definer_conv_items_to_hl(struct mlx5dr_context *ctx, ret = mlx5dr_definer_conv_item_meter_color(&cd, items, i); item_flags |= MLX5_FLOW_ITEM_METER_COLOR; break; + case RTE_FLOW_ITEM_TYPE_QUOTA: + ret = mlx5dr_definer_conv_item_quota(&cd, items, i); + item_flags |= MLX5_FLOW_ITEM_QUOTA; + break; case RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT: ret = mlx5dr_definer_conv_item_ipv6_routing_ext(&cd, items, i); item_flags |= cd.tunnel ? MLX5_FLOW_ITEM_INNER_IPV6_ROUTING_EXT : -- 2.34.1