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 98F3F4240D; Wed, 18 Jan 2023 13:57:03 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C32C442D81; Wed, 18 Jan 2023 13:56:36 +0100 (CET) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) by mails.dpdk.org (Postfix) with ESMTP id 688F842D59 for ; Wed, 18 Jan 2023 13:56:35 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V9aP36BjAVlGe2Luz5UQISH6dK3Q16wd28OzHppN+/Jt+iFBVlbOT5J5ThOcccGTMgGlQhe5uOvsPk7AmiA8A4HJUYzI6rIxOWLS8qv/jwTM41uF2ZKQpIVBes9UwWNCJMzLcvmHkb2OzTlHiVHKwtnSUNmfzu+GfuFzSrwOpKtR0GkJRQ+6oMXNwwV3EeVGqP7Yv2RSrPypvEDiMUkzN5rDdZvWfOP+WgosV1F7sAziLgd1V3owDBaC7btzQdT4lor2rFQVMc6bJVo4+NL9tUYpqKbv1NTs8cOCKaF8s5/meX9ueWWhCf7qXyxDaw9jZIvwbnOrgT8Rj1nmyG+xMg== 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=9T0r7iU7yL+SjKdWfHaDBkIYXtbWDQTIm1ObXc/80qg=; b=Oq/5EZgoxUhnWznjHRwSODkTxqazOUd+fWnRARkLB/XltA9dgWP16BxvwLJGlatD8Ct3LLkXIcqVzmK5rAnSCaFSe7wxI4/OmHX3t5PPc2eyV2KpYW80EDbRE9uNSLsKwvukmBhxkF+6EaLHdJJIFgoQ1gU2JHm53YZHtm62XXDmukOl0GSkPAt1r5avRWns+oS8XldcfY8XGuRs1ApCWGGyly6NL5WTl1qowMTpGnLRYdyHxtnLeS89HvI7exXKzti6t+UCr3nge1EjseU/T2D9UlFW63PNDb+WVNVLt5NqWQ00FUWmisHGo8sEBzY1p6y/ybp2B0Krri/mtiZGcg== 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=9T0r7iU7yL+SjKdWfHaDBkIYXtbWDQTIm1ObXc/80qg=; b=lXStW0XEqVzjyozfg0m4sMcaZGG14vh45OKjB0vj9i28ukFebkebIllemCVrmag8y8zf68lyQccbViClfzqgjdagNUSJjB/BTB4ovpIzUAQuyradXDDyDmPIF/R6zWfcNnu17DVnn8Vh4VkczHjiHMWscBk5qQzIA1Jq288s9/8Y9mFUHs/ewXWD4bIIr7aKOClU/7K+OYWcmZu95pcmDDA4UDlxPQP7BLm6cEXTVHz3A+6qbZNcZ5W7aDRnEJjvzq+fBgnyP6TkKC2uyo5cIpAdBFM98y/gjEbx0mGcSCPzRj8qFjtMnIBV0kSbszJoIHEzTXDoRbDX6AGJS7eSQA== Received: from DS7PR03CA0001.namprd03.prod.outlook.com (2603:10b6:5:3b8::6) by MW4PR12MB6949.namprd12.prod.outlook.com (2603:10b6:303:208::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.23; Wed, 18 Jan 2023 12:56:33 +0000 Received: from DS1PEPF0000B074.namprd05.prod.outlook.com (2603:10b6:5:3b8:cafe::c) by DS7PR03CA0001.outlook.office365.com (2603:10b6:5:3b8::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.19 via Frontend Transport; Wed, 18 Jan 2023 12:56:32 +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 DS1PEPF0000B074.mail.protection.outlook.com (10.167.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.11 via Frontend Transport; Wed, 18 Jan 2023 12:56:32 +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.36; Wed, 18 Jan 2023 04:56:24 -0800 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.36; Wed, 18 Jan 2023 04:56:22 -0800 From: Gregory Etelson To: CC: , , , Viacheslav Ovsiienko Subject: [PATCH 5/5] mlx5dr: Definer, translate RTE quota item Date: Wed, 18 Jan 2023 14:55:56 +0200 Message-ID: <20230118125556.23622-6-getelson@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230118125556.23622-1-getelson@nvidia.com> References: <20230118125556.23622-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: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0000B074:EE_|MW4PR12MB6949:EE_ X-MS-Office365-Filtering-Correlation-Id: 0f62c320-1d80-49fd-dd3c-08daf9536cb6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LQgAe+bhRQLSiO7gzrs7RHbD83wODcA0mlbe0nAzn/HBg1+QNfXnW7fY//oNWXjY0xSluj+TXKt23Wut1nLEo/X2N2BRAY8z+goVaQspZsiND2Q6d4v6SWRRSyXdFvnIG1FwyvpvjIyPs7wK3I9ltDYIB4RBLDsXc0Jx5SP0cQZMk0ouYqQ8eXyrlFhqmsJTlUjQnZN8V6uRUlwPDvlx4AFYJHVcnqC22aSmBu/DR4rkrDFpZ/g+DloZnwlZujAOzF16VFYRT18+Hw7MegGYUEJO1yrbJDBrtRShH3C3okmNPPQgK5KFfEWIcuy2ccCW6H5qsrAQQJDhF+VMRpKIYCj4Yb/meWKMp9OG37qGp4OwvApWx7qnzBvg1Xh4G3vYQHjFCGy2LN8IITKl9RLsug1UHAADrDvHhAcItee1mQ2QxjVy+2LAmI52T5D6lKDOy5RD44Tyu41Rcw3GWCzYwujUvKCQvvOzzvrl/u4MB0ZVakTb3As6rygxYyzFrn5JBvEinMg4cSbyqcMLESPUuZXxlKOuSDFEmNQ6BKubZf1RnDuRC9RcnImgfMd4aaz+gBg8L3NfKdST7aIH8NpPHikBRx/0fTQ3BemgmPoLxth3fMh4ttaoQmZOy31yxDwbcSSBk/XrR/Q6R0Ejtzg0AW5eZsBN2qmql/wHnMKgL47uPYkGzVHoMxMHbPdolyc9E4LNWnvAcsTIfsyhQzpICx77YrLZb96y+FisoVm/7f4= 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:(13230022)(4636009)(39860400002)(376002)(396003)(346002)(136003)(451199015)(36840700001)(40470700004)(46966006)(1076003)(54906003)(2616005)(186003)(8676002)(4326008)(336012)(6286002)(316002)(7696005)(70586007)(26005)(478600001)(70206006)(6916009)(41300700001)(8936002)(15650500001)(47076005)(426003)(5660300002)(6666004)(107886003)(2906002)(83380400001)(36860700001)(356005)(7636003)(82740400003)(16526019)(86362001)(55016003)(40480700001)(36756003)(40460700003)(82310400005)(32563001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2023 12:56:32.6465 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0f62c320-1d80-49fd-dd3c-08daf9536cb6 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: DS1PEPF0000B074.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB6949 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 --- drivers/net/mlx5/hws/mlx5dr_definer.c | 61 +++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/drivers/net/mlx5/hws/mlx5dr_definer.c b/drivers/net/mlx5/hws/mlx5dr_definer.c index 6b98eb8c96..40ffb02be0 100644 --- a/drivers/net/mlx5/hws/mlx5dr_definer.c +++ b/drivers/net/mlx5/hws/mlx5dr_definer.c @@ -19,6 +19,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 { \ @@ -1134,6 +1137,60 @@ 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) + return EINVAL; + + 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, @@ -1581,6 +1638,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; default: DR_LOG(ERR, "Unsupported item type %d", items->type); rte_errno = ENOTSUP; -- 2.34.1