From patchwork Tue Oct 3 11:25:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13407493 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F39F7210F8 for ; Tue, 3 Oct 2023 11:26:08 +0000 (UTC) Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2048.outbound.protection.outlook.com [40.107.100.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B723BA7 for ; Tue, 3 Oct 2023 04:26:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Zuo/4WgFRikvRexyyFlikaRFpp+mnLUNneFXtpfx7weoPGgR/J2TrCd+y39DqQ6KuAbzTwAKjB5F9RZzYQVpxrhCjLKs1HBeB/IgDOwnykrryq1R2arszy02+aVIYAhT4iRG3j26mmWH5suwEXIhqlNg2hqZQiMXmXQaFUaRAqL2bhiAy58H76vdV6myWAD2QoRcEIR6aNtWTzjJgPjHqmrN7GkTA+0lg/BRB66jzS3t/6VWexwpVRDCDQqbz2JW7ZZdlK8ma204864/JqnqGE/jkwtozRRqRaoJQ6Gj9uztRYsTLCCFSqiQXGUWMy6cibeWJdjJ2FNCEi/cTaXvYQ== 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=SWNMBLL4C63PG5Kf5m6oAwmoxSFxWITjxnRLI3e7Rys=; b=mbzzRNoAaMUDIzl6Xvy6S4ImbJUEnRU9qAnDlK+ULYB+sS8eWvn+0dDmQr2mUvb4+QsHIMR7Gg2cMxNTcQg2vFIpmSs8HAsz/du10ZYkpEkF3mRUzkBjkAH6CdkIZ1kJf7VD+B6CjTGh6JfCtPkfR1r5Z7g5xXkCnCIAn3s12lDqgJ4C59kUaYdEEk76/lkalAAXDZPoIgTFG48ngbk6GbpYQ54UnaZYotkv6VG5Mqni8tfVmr6O9Vf1j6yuLrEz/ogdX9yGs5BpL2dGxSb8+rhxeiU9Bs3NoNkHNTSmuk2ZhwW5tmYL6GB6kqeJydbF47b0gvgDeEB8AvYcS8Mrew== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=davemloft.net 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=SWNMBLL4C63PG5Kf5m6oAwmoxSFxWITjxnRLI3e7Rys=; b=b4y06c31QRj9CwN6zAXx1tTn4n4LlB4uXpUOKKJmSZhHCXWFyBvESjOWPIwd1ag4NF/IIStRS4Q2CnKFzOv2u5Sdy3I2+34mGMjuaWpq1I64np7UwJBWXQNtHyhMokrmLYrpbimxge0FuYBBO9nIpLHfFAejMy9sczS2fDKIoB2i8FzRxWeH1QMZRcExqWQm1Uc8ssbNsfuei62t8We0pxWQ9H0I1ZEaR/JbilEmOpoPLmbkbn/1E+aHlRdvb+gCPMgnGW+jEvARM4x6K5g656B8UzAgu8o4cSmIDA9fUB2HVVtUmQeHYUHNKCv10HXWMQJnmB65gnDMxQCL+chz6Q== Received: from SN4PR0501CA0026.namprd05.prod.outlook.com (2603:10b6:803:40::39) by PH0PR12MB7469.namprd12.prod.outlook.com (2603:10b6:510:1e9::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.29; Tue, 3 Oct 2023 11:26:02 +0000 Received: from SA2PEPF00001508.namprd04.prod.outlook.com (2603:10b6:803:40:cafe::3a) by SN4PR0501CA0026.outlook.office365.com (2603:10b6:803:40::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.24 via Frontend Transport; Tue, 3 Oct 2023 11:26:02 +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 SA2PEPF00001508.mail.protection.outlook.com (10.167.242.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.14 via Frontend Transport; Tue, 3 Oct 2023 11:26:02 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) 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.41; Tue, 3 Oct 2023 04:25:49 -0700 Received: from yaviefel.vdiclient.nvidia.com (10.126.231.35) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Tue, 3 Oct 2023 04:25:46 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , "Amit Cohen" , Subject: [PATCH net-next 1/5] mlxsw: Mark high entropy key blocks Date: Tue, 3 Oct 2023 13:25:26 +0200 Message-ID: <7bd964e525278b1d0b7af0cd2edf380a71202bf9.1696330098.git.petrm@nvidia.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail202.nvidia.com (10.129.68.7) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00001508:EE_|PH0PR12MB7469:EE_ X-MS-Office365-Filtering-Correlation-Id: dad54d74-6e6d-43ee-9cc8-08dbc403867b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8+UK86JNuFc507RVdeXvAIdX6sFJChOjid8tOTaj1/Zwm/6RuelXtFCYVgk0fkIGvIxhmMv2baAkEMNKYw0JXB/1+tEbbKfx2o/ohwLkNcGCS0yUWqyrHu1KjF+PtyTZzXCFuij76QF6D/EXDhEcr3mNoIqB61AWTvFvlMrwiV95lfQAL63nFZp0lPdFH3Y2numHsuiJK9tf2s9OKYA7M8QkbcqoVbctSEjqBgjLWxREn5KUsh0l0WfWfqORbSskugR1ZgyH8PLAj6vpTPngUWKf7tDiAS05ieHWm62GL3iz8StnCt7OWU0duNhPiduRPS5OOiLAhkOSWWyoP2EhXI6bl1W7pGocGoqiZw4rq9sHOpD/hfN7E84h4bZKkvpw3WSHVD4HIGPBIkdFRYEbkcKJNQBIJXCL1wnlWxwkmXIBNqs8FHkx+5DkR3hBvUS7Nsf4NbeD9bffiRse4+IMJ7X5JnQO7f9aOcK1haalHuAjMPIE21IUlYKqpcCnFhv8De09UVvyyH7zm2igZaI/2QB+/3yd0o706Y/3IXgIs9X5KwyelFT1luEDXfJSjMY19JUSr6BhTEAzKfx0FoN9OU7GExUf4t5jXbrOSGZLL/rgs10yYPZsKJOGDCuK3XwJyXt7YBCCcIp3rTjRIkCO3Qn45Cf2xrP2HrVRXQXX5C6zzUOj9zqFg9MdMlMWU+BGIwpOygmKicHuqGmQ74gDcOXGdQUYajbSgYMZPFcXYAfCgw6B9AudVcciuHCVejpD 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:(13230031)(4636009)(396003)(346002)(39860400002)(376002)(136003)(230922051799003)(82310400011)(186009)(64100799003)(1800799009)(451199024)(46966006)(36840700001)(40470700004)(316002)(110136005)(70586007)(5660300002)(70206006)(54906003)(6666004)(8936002)(4326008)(26005)(478600001)(7696005)(8676002)(16526019)(2906002)(336012)(426003)(2616005)(107886003)(47076005)(83380400001)(41300700001)(36860700001)(356005)(7636003)(82740400003)(86362001)(36756003)(40460700003)(40480700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2023 11:26:02.1688 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dad54d74-6e6d-43ee-9cc8-08dbc403867b 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: SA2PEPF00001508.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7469 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org From: Amit Cohen For 12 key blocks in the A-TCAM, rules are split into two records, which constitute two lookups. The two records are linked using a "large entry key ID". Due to a Spectrum-4 hardware issue, KVD entries that correspond to key blocks 0 to 5 of 12 key blocks A-TCAM entries will be placed in the same KVD pipe if they only differ in their "large entry key ID", as it is ignored. This results in a reduced scale. To reduce the probability of this issue, we can place key blocks with high entropy in blocks 0 to 5. The idea is to place blocks that are changed often in blocks 0 to 5, for example, key blocks that match on IPv4 addresses or the LSBs of IPv6 addresses. Such placement will reduce the probability of these blocks to be same. Mark several blocks with 'high_entropy' flag, so later we will take into account this flag and place them in blocks 0 to 5. Signed-off-by: Amit Cohen Reviewed-by: Ido Schimmel Signed-off-by: Petr Machata --- .../net/ethernet/mellanox/mlxsw/core_acl_flex_keys.h | 9 +++++++++ .../ethernet/mellanox/mlxsw/spectrum_acl_flex_keys.c | 12 ++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.h b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.h index 1c76aa3ffab7..98a05598178b 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.h +++ b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.h @@ -119,6 +119,7 @@ struct mlxsw_afk_block { u16 encoding; /* block ID */ struct mlxsw_afk_element_inst *instances; unsigned int instances_count; + bool high_entropy; }; #define MLXSW_AFK_BLOCK(_encoding, _instances) \ @@ -128,6 +129,14 @@ struct mlxsw_afk_block { .instances_count = ARRAY_SIZE(_instances), \ } +#define MLXSW_AFK_BLOCK_HIGH_ENTROPY(_encoding, _instances) \ + { \ + .encoding = _encoding, \ + .instances = _instances, \ + .instances_count = ARRAY_SIZE(_instances), \ + .high_entropy = true, \ + } + struct mlxsw_afk_element_usage { DECLARE_BITMAP(usage, MLXSW_AFK_ELEMENT_MAX); }; diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_flex_keys.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_flex_keys.c index 4b3564f5fd65..eaad78605602 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_flex_keys.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_flex_keys.c @@ -334,14 +334,14 @@ static struct mlxsw_afk_element_inst mlxsw_sp_afk_element_info_ipv6_2b[] = { }; static const struct mlxsw_afk_block mlxsw_sp4_afk_blocks[] = { - MLXSW_AFK_BLOCK(0x10, mlxsw_sp_afk_element_info_mac_0), - MLXSW_AFK_BLOCK(0x11, mlxsw_sp_afk_element_info_mac_1), + MLXSW_AFK_BLOCK_HIGH_ENTROPY(0x10, mlxsw_sp_afk_element_info_mac_0), + MLXSW_AFK_BLOCK_HIGH_ENTROPY(0x11, mlxsw_sp_afk_element_info_mac_1), MLXSW_AFK_BLOCK(0x12, mlxsw_sp_afk_element_info_mac_2), MLXSW_AFK_BLOCK(0x13, mlxsw_sp_afk_element_info_mac_3), MLXSW_AFK_BLOCK(0x14, mlxsw_sp_afk_element_info_mac_4), - MLXSW_AFK_BLOCK(0x1A, mlxsw_sp_afk_element_info_mac_5b), - MLXSW_AFK_BLOCK(0x38, mlxsw_sp_afk_element_info_ipv4_0), - MLXSW_AFK_BLOCK(0x39, mlxsw_sp_afk_element_info_ipv4_1), + MLXSW_AFK_BLOCK_HIGH_ENTROPY(0x1A, mlxsw_sp_afk_element_info_mac_5b), + MLXSW_AFK_BLOCK_HIGH_ENTROPY(0x38, mlxsw_sp_afk_element_info_ipv4_0), + MLXSW_AFK_BLOCK_HIGH_ENTROPY(0x39, mlxsw_sp_afk_element_info_ipv4_1), MLXSW_AFK_BLOCK(0x3A, mlxsw_sp_afk_element_info_ipv4_2), MLXSW_AFK_BLOCK(0x36, mlxsw_sp_afk_element_info_ipv4_5b), MLXSW_AFK_BLOCK(0x40, mlxsw_sp_afk_element_info_ipv6_0), @@ -350,7 +350,7 @@ static const struct mlxsw_afk_block mlxsw_sp4_afk_blocks[] = { MLXSW_AFK_BLOCK(0x43, mlxsw_sp_afk_element_info_ipv6_3), MLXSW_AFK_BLOCK(0x44, mlxsw_sp_afk_element_info_ipv6_4), MLXSW_AFK_BLOCK(0x45, mlxsw_sp_afk_element_info_ipv6_5), - MLXSW_AFK_BLOCK(0x90, mlxsw_sp_afk_element_info_l4_0), + MLXSW_AFK_BLOCK_HIGH_ENTROPY(0x90, mlxsw_sp_afk_element_info_l4_0), MLXSW_AFK_BLOCK(0x92, mlxsw_sp_afk_element_info_l4_2), }; From patchwork Tue Oct 3 11:25:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13407494 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2B7A521352 for ; Tue, 3 Oct 2023 11:26:08 +0000 (UTC) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2043.outbound.protection.outlook.com [40.107.223.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B012AAC for ; Tue, 3 Oct 2023 04:26:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ABST8MEbH02MHLLcY8MSkswic30Vdax53Zay1PWf7/DgPy9LLqTyaOpqeA5TOOpnQ+tE+EQ7LwUnidnLaE6RrwLSjr7gfgFaOytGx96bUfdLkW5A9HE/qg+dJf1Bl+1Ks4S85afIDSfKtyrBLrWTbGGpV9dai7xvotnqgDMqhsSBZSfjQS/DB/C1hojIi1epLUtQhtLkmf95NnBg0LOtRPenxXuDNpeyIGX5fx4wtfFNT98dbD4r8mf7s8OA3GHfsZrGxXoS8yPv5Af41pvC+PWG4uajrvv/M9TXpCz/lgsFLIbZkD18dJ+R+i3LdZOWWxGehbNQLCnz66wesE358A== 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=nwkxeg5lmz3PowmoapNWdScvBdop7AcSWOXm4UXsLdU=; b=IpGh6UsHz4dMcdvK8ei2w30TlnhDCYOseOkY3jAZmjfBRLV1FLlJGky1f+ICfghkZOEyz0XhJorT6+kCT6gYwtmU86c4DXfEjLA56O4BnC2CoA6HxkS2CA8sqsm8KTrrQ4WxYPS6sNDYldqRZBneuyTAVBacf9qhztSFpsC7plqyvbmjwa5Q12xYh8+Bi/H6PhUGhzoNYnyGvbuU6g96qNWTmctkoNx5yLf2P9jblO36rq3WtfQ2QN1nCCzLXTwvCwVbWBu9NBRqzABBI5R/CoVRm6Dnmj6vLMrnimjg8arEgkq9IJI7kTihbsGIWeuPQCBJ8uOPadQc3PgePsIrYg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=davemloft.net 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=nwkxeg5lmz3PowmoapNWdScvBdop7AcSWOXm4UXsLdU=; b=seg5aGsa/M0l2NSCMmxjapWWfM/auCAgcCGyDGUyG/L0GGreVQF9ZU8TgcmYjp/poCpEfiDkCydX0HU3HQ3rlTBAlQQVHuOjytznhMlp/Vr8DzJTYaBZ13x1RZEaqY4zkvbsJaeBZre2wq6Tl/47pUzMD4A6QRiVAlcGuBTzlj1HBPYXi/KuxhJEVDEZKgBQEJdOyqnhMUE0vz351yOeS8sgUuAXIyxSXQrTyIRPB18ER3RxQzHPyoPoeHdg05bZjmSBBEwY8CSG1O6aRBZ0enlRL3N5NeZTFS4XEGYxhedKDLfQ6quHowAgf1Hi+E+dGSW+vP5akJWofS0VyiRwJw== Received: from SN6PR08CA0023.namprd08.prod.outlook.com (2603:10b6:805:66::36) by MW6PR12MB8951.namprd12.prod.outlook.com (2603:10b6:303:244::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.32; Tue, 3 Oct 2023 11:26:05 +0000 Received: from SA2PEPF00001505.namprd04.prod.outlook.com (2603:10b6:805:66:cafe::49) by SN6PR08CA0023.outlook.office365.com (2603:10b6:805:66::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.31 via Frontend Transport; Tue, 3 Oct 2023 11:26:04 +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 SA2PEPF00001505.mail.protection.outlook.com (10.167.242.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.14 via Frontend Transport; Tue, 3 Oct 2023 11:26:04 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) 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.41; Tue, 3 Oct 2023 04:25:51 -0700 Received: from yaviefel.vdiclient.nvidia.com (10.126.231.35) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Tue, 3 Oct 2023 04:25:49 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , "Amit Cohen" , Subject: [PATCH net-next 2/5] mlxsw: core_acl_flex_keys: Add a bitmap to save which blocks are chosen Date: Tue, 3 Oct 2023 13:25:27 +0200 Message-ID: <8f118572e0f2fe4f800303977bcc4c6606c78642.1696330098.git.petrm@nvidia.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail202.nvidia.com (10.129.68.7) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00001505:EE_|MW6PR12MB8951:EE_ X-MS-Office365-Filtering-Correlation-Id: ec72f841-1442-4d95-8a54-08dbc403879d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pF8UjiX2jBc6KkzjUtIs7sHZ3f+MTGF6grsQZy22u0ZGRL0R7XtaiGnUu/Iau4gLp9ywFhtTYXMfSxxt1fqARkWXtjPbXngZXiyfU/pZP3w1I1F/YZCI7cP4tILQhGVio9gu4nwvFkCcv21csRVw9+DsPrJZaRLF6H3WAvgCmeptwyHxToRTrySRksz2y3FtxkEtcLjlDnMWl7eGNb1VLaqbSewqA/GeU7tp6o2tYezlxdbQjydPw9U8Fh7g7kKrcx6pjvBOH+0JmiHBkp67b0ltf52ZWp11jWGj943hoTmSjMZwRP80GCBimO8a67xRt9mObeInVWaAB62lfRw6jZN27mOR889BxX2lsxacr3L6aai4QV7ljjn1WMFZ63Vo6WtqAgbA33cuzGZMUc9hy1uf1x0BJIASOPla0wHxBvkSyJVzspwZW2Flmb7toDg/dalvxi32YO+kI54afBr2sSlRJAQUBwEFh0IgXFw4gQByT5vDCynJQnh15etDfcw1vD0LeU0r9yOxClkf0HMaE1vUZ/twfUU65OpfbmAAOfUrPkyrgpXoWUy1eo2ArNievFq6AzuVIoI1rAZsdd2XiZzV5Q0Ptafl/VZS0Jxt5MgqnFT/4HIFUZnJUTfymc2yMUu2e6ZcppUz/6ubbq836BDPhwC8dfzinX0nGxAmzVOw0iWVacN7zu5jVQle8iZSuNuk4fCqthn1RcPEWqWL3nNQ2mH5kWhyDSkXAlM49qHg4NDkQ2yY6CdSBGcph+3L 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:(13230031)(4636009)(396003)(376002)(346002)(39860400002)(136003)(230922051799003)(186009)(451199024)(64100799003)(1800799009)(82310400011)(40470700004)(36840700001)(46966006)(40460700003)(40480700001)(7696005)(478600001)(6666004)(107886003)(7636003)(47076005)(356005)(86362001)(82740400003)(41300700001)(426003)(16526019)(336012)(83380400001)(110136005)(2616005)(26005)(36860700001)(36756003)(2906002)(70206006)(54906003)(70586007)(5660300002)(8676002)(316002)(4326008)(8936002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2023 11:26:04.0845 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ec72f841-1442-4d95-8a54-08dbc403879d 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: SA2PEPF00001505.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW6PR12MB8951 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org From: Amit Cohen Currently, mlxsw_afk_picker() chooses which blocks will be used for a given list of elements, and fills the blocks during the searching - when a key block is found with most hits, it adds it and removes the elements from the count of hits. This should be changed as we want to be able to choose which blocks will be placed in blocks 0 to 5. To separate between choosing blocks and filling blocks, several pre-changes are required. The indexes of the chosen blocks should be saved, so then the relevant blocks will be filled at the end of search. Allocate a bitmap for chosen blocks, when a block is found with most hits, set the relevant bit in the bitmap. This bitmap will be used in a following patch. Signed-off-by: Amit Cohen Reviewed-by: Ido Schimmel Signed-off-by: Petr Machata --- .../net/ethernet/mellanox/mlxsw/core_acl_flex_keys.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.c b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.c index 745438d8ae10..e0b4834700dd 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.c @@ -225,6 +225,7 @@ static int mlxsw_afk_picker(struct mlxsw_afk *mlxsw_afk, struct mlxsw_afk_element_usage *elusage) { struct mlxsw_afk_picker *picker; + unsigned long *chosen_blocks_bm; enum mlxsw_afk_element element; int err; @@ -232,6 +233,12 @@ static int mlxsw_afk_picker(struct mlxsw_afk *mlxsw_afk, if (!picker) return -ENOMEM; + chosen_blocks_bm = bitmap_zalloc(mlxsw_afk->blocks_count, GFP_KERNEL); + if (!chosen_blocks_bm) { + err = -ENOMEM; + goto err_bitmap_alloc; + } + /* Since the same elements could be present in multiple blocks, * we must find out optimal block list in order to make the * block count as low as possible. @@ -256,6 +263,9 @@ static int mlxsw_afk_picker(struct mlxsw_afk *mlxsw_afk, err = block_index; goto out; } + + __set_bit(block_index, chosen_blocks_bm); + err = mlxsw_afk_picker_key_info_add(mlxsw_afk, picker, block_index, key_info); if (err) @@ -265,6 +275,8 @@ static int mlxsw_afk_picker(struct mlxsw_afk *mlxsw_afk, err = 0; out: + bitmap_free(chosen_blocks_bm); +err_bitmap_alloc: kfree(picker); return err; } From patchwork Tue Oct 3 11:25:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13407495 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 755E021379 for ; Tue, 3 Oct 2023 11:26:10 +0000 (UTC) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2073.outbound.protection.outlook.com [40.107.243.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 402C18E for ; Tue, 3 Oct 2023 04:26:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eSZfkA3vmBfGL55mZJx+fBZ2Via4FrjmLhwW6fplgBEaOqkqiT9SNxx6qRFVRowwB+WXTub4HtHWTSvYyIp7arQ5Phmh2TUazCmirhHp1AxtO9QBd3v8LzD9wJ8FkTLm294LADaDZEe3PESFQmHExsXTySjyPRcejhHkTk5d6h/V8tANyaDR70IveX2k5srq9wuU1stVFfnacqWPQQ437P8Js56QiFuOwpYWCYMhtnisgU/EgN/AHMZYbboQWziVgLahL3Ct08zPcDkLYy69GSpSiz6cE19w6DAN0i1bGq+u/4E31q4kaYx8cDVnMnfRHWgOVWYNj4RZVD8Swgjx2g== 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=9M4ox8m9jR5VIDBXrBS96hjWZK2rX2hJQPvfkLeafLU=; b=UNE7LlFR9UuHLR6YvCNN9JDoDJ1m+WgXIivrQFBH3i2z1eGJsaw0WfpN7RwQFek8sXv2mzYuJ+pBm7yupPVk2HtGgkBg2h0WD9arahLtLQgPhuuf83l91M+7BYbLOWTha6WOBWPi066m4iz09LVvkjZWmYjiGG5t8Ab0Nsbsbf91Vi9ziy63Ckd/ZuuMdr4QEtPE1ZOp2N91hFI5k5ukS83rP2LsSuaHAwpPJhHzOyvYscnWBKfMf/nRKlJegOXtDEa4ObLmJJnSUsqweH75cswS/MCx7IT6Z15rBjR3ko4wEaIowGJRXu3Uj3ODDKZ1oYkMH9j2jomeAzuzddW0oA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=davemloft.net 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=9M4ox8m9jR5VIDBXrBS96hjWZK2rX2hJQPvfkLeafLU=; b=izjCi8emp1atFZNqjxLp+ByALU8ZLDDRYdZ4cMBaH6Fmc/bj2QcguylqcEp7JHMggnxbmppszPCZlTi5gvn92Ic/b2d0Qr6Wpk+ADE//yEFUKGWjnmFNNrHss3ILeUKljVUH48tKb80q5weTTICKx3d7jN0CU6V4Y26SIXBsZkfl/rVj0h2RkX12Mz4sUrZQI8q7IXqw1QmtuzmX0dYNW8QDBqmGdL5pNkvWW3ELzz030Rx2W+0dcYRbccLNFkqhl7j6VNZGUnK+n2aS5KN/EqqjL+0yVGIob4DZ3TzwxZYppoZgpOgg/NWoVjw3WFQDOeZ4asC4mtribdNmC0MbYg== Received: from SN4PR0501CA0013.namprd05.prod.outlook.com (2603:10b6:803:40::26) by SA3PR12MB9089.namprd12.prod.outlook.com (2603:10b6:806:39f::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.30; Tue, 3 Oct 2023 11:26:07 +0000 Received: from SA2PEPF00001508.namprd04.prod.outlook.com (2603:10b6:803:40:cafe::83) by SN4PR0501CA0013.outlook.office365.com (2603:10b6:803:40::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.24 via Frontend Transport; Tue, 3 Oct 2023 11:26:07 +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 SA2PEPF00001508.mail.protection.outlook.com (10.167.242.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.14 via Frontend Transport; Tue, 3 Oct 2023 11:26:07 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) 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.41; Tue, 3 Oct 2023 04:25:54 -0700 Received: from yaviefel.vdiclient.nvidia.com (10.126.231.35) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Tue, 3 Oct 2023 04:25:51 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , "Amit Cohen" , Subject: [PATCH net-next 3/5] mlxsw: core_acl_flex_keys: Save chosen elements per block Date: Tue, 3 Oct 2023 13:25:28 +0200 Message-ID: X-Mailer: git-send-email 2.41.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail202.nvidia.com (10.129.68.7) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00001508:EE_|SA3PR12MB9089:EE_ X-MS-Office365-Filtering-Correlation-Id: c2a3849d-9623-4e1c-a651-08dbc403896a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ydg4n8in3DOBFxhbuFbfavSGf2OmobGXYocK9gqdi4LkeySY5qMzoS1bdEodVKGHS/80WmaeBJO8HKxF0GWiveZ2d6H4S3mjVlQ4uvrMy08syJBEs/jbCurkQBXoaBcUQfJUA4P16KUiu6/v+yYoHRD0XpxAC5DQ5du7Pj1g172oF1AzWZp6ZALZ1SqmLcAKjdnmlUPFYl3TNYHHM4slnronmPF6i1EXtV3oWsCw2Fxwl5UedpOMr17XZmLQZ7+C8Hv9Xrr/vttPw9SgEbbHPOLaSNt24/I+DpDvA3UIFbNbECaFxbhXPp7vJWLtHMyLpDiF4atmo2/3vL6q24fRiFjXs4bLENUE74TAniaVlUPo8AUTTerVwSqrrujaYcjDjSyf3PsacRLX4Zxhd5Ay4VGGGPyzINFZ1QRWIIZckvPeS1ANuK8yP1nKraovzGg2ayKNeXD3bR5LHgPoZ8fuZgefFz2D5qnVCmpcvw8QcXAhK0ADGIKgE12oZP7E0BM4SEFpEtA0d5GnUWFin/sGnOxHQn0iVRiSGDZ9RsHKXcLvNIXUzoEilhewja2j0FF+G4D539ca3sigPIKavwkwQPXmm860t5fju7wSgSnk6ENZZ4AuYiMiiq2L5hV7zC/uAr5YFaOTTcRiEhj7wm2S/UeUWr48LTni9FpCq3+7thUmr5vqenzNuo5v8ZsndYBknkbbgpCMaO3MvCv0SLTt0iKaQ4bmTAaWnAx4a9wDA2o98IplzJVN4PBhzZxzFNvyvl1IXC/CSdWY7rLCPsDv/g== 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:(13230031)(4636009)(136003)(396003)(346002)(376002)(39860400002)(230922051799003)(451199024)(186009)(1800799009)(64100799003)(82310400011)(46966006)(36840700001)(40470700004)(7696005)(2616005)(107886003)(40480700001)(40460700003)(82740400003)(36756003)(356005)(86362001)(7636003)(36860700001)(16526019)(6666004)(2906002)(47076005)(5660300002)(26005)(83380400001)(8936002)(316002)(41300700001)(426003)(478600001)(336012)(70206006)(70586007)(54906003)(8676002)(4326008)(110136005)(60793003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2023 11:26:07.1063 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c2a3849d-9623-4e1c-a651-08dbc403896a 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: SA2PEPF00001508.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB9089 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org From: Amit Cohen Currently, mlxsw_afk_picker() chooses which blocks will be used for a given list of elements, and fills the blocks during the searching - when a key block is found with most hits, it adds it and removes the elements from the count of hits. This should be changed as we want to be able to choose which blocks will be placed in blocks 0 to 5. To separate between choosing blocks and filling blocks, several pre-changes are required. During the search, the structure 'mlxsw_afk_picker' is used per block, it contains how many elements from the required list appear in the block. When a block is chosen and filled, this bitmap of elements is cleaned. To be able to fill the blocks at the end, add a bitmap called 'chosen_element' as part of picker. When a block is chosen, copy the 'element' bitmap to it. Use the new bitmap as part of mlxsw_afk_picker_key_info_add(). So later, when filling the block will be done at the end of the searching, we will use the copied bitmap that contains the elements that should be used in the block. Signed-off-by: Amit Cohen Reviewed-by: Ido Schimmel Signed-off-by: Petr Machata --- drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.c b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.c index e0b4834700dd..7679df860a74 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.c @@ -138,6 +138,7 @@ mlxsw_afk_key_info_find(struct mlxsw_afk *mlxsw_afk, struct mlxsw_afk_picker { DECLARE_BITMAP(element, MLXSW_AFK_ELEMENT_MAX); + DECLARE_BITMAP(chosen_element, MLXSW_AFK_ELEMENT_MAX); unsigned int total; }; @@ -208,7 +209,7 @@ static int mlxsw_afk_picker_key_info_add(struct mlxsw_afk *mlxsw_afk, if (key_info->blocks_count == mlxsw_afk->max_blocks) return -EINVAL; - for_each_set_bit(element, picker[block_index].element, + for_each_set_bit(element, picker[block_index].chosen_element, MLXSW_AFK_ELEMENT_MAX) { key_info->element_to_block[element] = key_info->blocks_count; mlxsw_afk_element_usage_add(&key_info->elusage, element); @@ -266,6 +267,9 @@ static int mlxsw_afk_picker(struct mlxsw_afk *mlxsw_afk, __set_bit(block_index, chosen_blocks_bm); + bitmap_copy(picker[block_index].chosen_element, + picker[block_index].element, MLXSW_AFK_ELEMENT_MAX); + err = mlxsw_afk_picker_key_info_add(mlxsw_afk, picker, block_index, key_info); if (err) From patchwork Tue Oct 3 11:25:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13407496 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9A881219F4 for ; Tue, 3 Oct 2023 11:26:13 +0000 (UTC) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2074.outbound.protection.outlook.com [40.107.243.74]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CCDA9B for ; Tue, 3 Oct 2023 04:26:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E8+RXzDUvWeP+TEmeEN+rnvmoNkJ0usY6WV4waCbADOTxPFAVIlVEZY6hBs+1UnGdYDt/lcdTh0A+CHrzgoZA2q07VoI4Hht6x3Fuf6kB+jG8vGLNr0hnLOZ284Cc+dal6FD2UiPJXYS2WsiNY80uZQhWyD3WKz5MYA2RRBdJVFwkZNXUEHzZa9q4yTYhh7e50O0T+en3vJ87isaY3san2stJ+GnGKthk0tQC8xFOKLlTXNeT2KmCMHhdDmNRqAG9yFZTyxbcxtpb5aTAMtmcb17GFMEnwKjwB8RnaTv49gjIgOb5ysCBqYk9wAUwVCFbgsSryMS17lxjfcCuEWy1Q== 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=KoYEqe6RfPUIqrSXHOWsWfFQRvZvxNd91p0ZS5yhqTg=; b=WbIemvIEtlQhnyeBU3h8TY5qs+BlOrw8EC7qgWjzGPem/fBjYZNmwO4Ovjnkee8JXyvM8xzjZFuf4y8pqr/sEwq3pwvS3QAmYgiLQY+jsotFdQY7u51HxDDvmPt9JJ1UXOzdX+RMHSDYeKTYTsTujH+5mVowk1WufgArrqxywEM9MSGj0uslHD+G/TQ+wVCbUdRYEmFHU00GrKD0CbYx9GTWhEp/wDTSmBPbOC4RELOZUR0nGNCbjHhPtFcqVG85SUSI0RvA9rPNAiHkzbD3x1NsxluZxfbElwmUREUvymi19jc+hNezRlyr1QC0jIkAmoq+IiRjst+PvnssvaG8yQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=davemloft.net 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=KoYEqe6RfPUIqrSXHOWsWfFQRvZvxNd91p0ZS5yhqTg=; b=cT8HuDTUWs+lj+/9nw4HsDBGK/A9Ue2PufZ3Qmr+a+tL2LZKhnTGUQoyRB8l/vRKsNhn6mBFJVAL2X5oO/h540tjW1MoSZulzK9p65TYgARnuBIAgDG6EgLypBIDWx7GX66VOTl7V0v9brxG2cipsDFlQXsOfLfX/J3xl4rWeBJSdu5+0hxXk/6eTxSXX4Q6g+3Ii1gVL/Xl4i6hi+HMxo7T39RxHXA120yUeHGYO6aS1yJK5Wfo++8teoXkTo58WUd468mi+1c/9+mk7lMbCybqRCMrPoYTTyYzcM3I6W73rCPomPsIj5IUKwpMOD29v9DlcXTk5q3BzNO/oDFJbA== Received: from SA0PR11CA0037.namprd11.prod.outlook.com (2603:10b6:806:d0::12) by SA1PR12MB6752.namprd12.prod.outlook.com (2603:10b6:806:259::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.25; Tue, 3 Oct 2023 11:26:09 +0000 Received: from DS3PEPF000099D5.namprd04.prod.outlook.com (2603:10b6:806:d0:cafe::6a) by SA0PR11CA0037.outlook.office365.com (2603:10b6:806:d0::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.33 via Frontend Transport; Tue, 3 Oct 2023 11:26:09 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) 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.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by DS3PEPF000099D5.mail.protection.outlook.com (10.167.17.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.14 via Frontend Transport; Tue, 3 Oct 2023 11:26:09 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Tue, 3 Oct 2023 04:25:56 -0700 Received: from yaviefel.vdiclient.nvidia.com (10.126.231.35) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Tue, 3 Oct 2023 04:25:54 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , "Amit Cohen" , Subject: [PATCH net-next 4/5] mlxsw: core_acl_flex_keys: Save chosen elements in all blocks per search Date: Tue, 3 Oct 2023 13:25:29 +0200 Message-ID: <918cc4da16bf2ad38ccc11c6041ba89377bd9107.1696330098.git.petrm@nvidia.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail202.nvidia.com (10.129.68.7) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099D5:EE_|SA1PR12MB6752:EE_ X-MS-Office365-Filtering-Correlation-Id: a7c8cb5f-85f4-4e46-8781-08dbc4038abf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Vz/WoIKynv3FvSt4vmpc198dB7ZPdGYY71bsmIJxNS1IxE7wAUxrJTOzhyupBGtSK/RTfHRsW+GyUbdIkGanFZubpd/Xm1u65USyacDagfxNPPowtwqNrATUP+Q/ak2t4WNbSsfPYVuxcqoDdY9QlxA6dIEfG24MRFJkORi5KdPAUjYTv3UjASobKUFXG+0wERk3rwyYNH6or5wl2yRu34pocGWOFMXNNFKkLSmu7BQax32udF/vbmByWFTL5RWw42WCLgWW7Me166jTQMPQ6nGW6J+MCFCg815gUwtUKts3LuB5BuUGh6U81/tZWmAnBOkkbCEgrQdov9CMj6lDT2Ma2DUDRKQl+gr/ZQ5rG8IYvkIA5gSXZWLlvYjs7jYXZMjvnFBqNVWt5P4DGEq9TK0bgLCgZFyFg7iTIqLjG2g03b56+Ju3dfMJY8YTpCVbEmG4j7+bCstwi4jYx6wyBs/FQLR8w69tMNRAwZ0uIBAErBb3AWu+/IWDgjwRUu0nwYb4HlS+SlgS+/F3ZTls3JdhwQY6Kb0VxbfUbNov4d7sbOFaX+KTAoaYYopHDC0VbgwX7yd/kWmR6E8Bweas2U4NaSF97d7/qHNNGNww7DwRJfPXPPU/RRkvpJmr5a+B7O4F0QeXb8l8tUobiwHcFyCyWKDsF3pJI7hGMhmwqrkhD134HmJReYxr2wz2wrYO/fHvgv3evisyU9vW6iksewH018KvfbUbg7WCg00SxL00T7o05hht2L6Vpy/ywLo8/PrrGQA/o2GsGa33nV7T4g== X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230031)(4636009)(136003)(376002)(39860400002)(396003)(346002)(230922051799003)(186009)(1800799009)(82310400011)(64100799003)(451199024)(36840700001)(40470700004)(46966006)(40460700003)(2906002)(426003)(2616005)(107886003)(356005)(110136005)(70586007)(41300700001)(86362001)(6666004)(82740400003)(54906003)(36860700001)(7636003)(16526019)(478600001)(336012)(83380400001)(26005)(47076005)(40480700001)(70206006)(4326008)(8676002)(5660300002)(316002)(36756003)(8936002)(7696005)(60793003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2023 11:26:09.3248 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a7c8cb5f-85f4-4e46-8781-08dbc4038abf 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.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF000099D5.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6752 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org From: Amit Cohen Currently, mlxsw_afk_picker() chooses which blocks will be used for a given list of elements, and fills the blocks during the searching - when a key block is found with most hits, it adds it and removes the elements from the count of hits. This should be changed as we want to be able to choose which blocks will be placed in blocks 0 to 5. To separate between choosing blocks and filling blocks, several pre-changes are required. Currently, the indication of whether all elements were found in the chosen blocks is by the structure 'key_info->elusage'. This structure is updated when block is filled as part of mlxsw_afk_picker_key_info_add(). A following patch will call this function only after choosing all the blocks. Add a bitmap called 'elusage_chosen' to store which elements were chosen in the chosen blocks. Change the condition in the loop to check elements that were chosen, not elements that were already filled in the blocks. Signed-off-by: Amit Cohen Reviewed-by: Ido Schimmel Signed-off-by: Petr Machata --- drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.c b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.c index 7679df860a74..c0e0493f67b2 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.c @@ -225,6 +225,7 @@ static int mlxsw_afk_picker(struct mlxsw_afk *mlxsw_afk, struct mlxsw_afk_key_info *key_info, struct mlxsw_afk_element_usage *elusage) { + DECLARE_BITMAP(elusage_chosen, MLXSW_AFK_ELEMENT_MAX) = {0}; struct mlxsw_afk_picker *picker; unsigned long *chosen_blocks_bm; enum mlxsw_afk_element element; @@ -270,12 +271,18 @@ static int mlxsw_afk_picker(struct mlxsw_afk *mlxsw_afk, bitmap_copy(picker[block_index].chosen_element, picker[block_index].element, MLXSW_AFK_ELEMENT_MAX); + bitmap_or(elusage_chosen, elusage_chosen, + picker[block_index].chosen_element, + MLXSW_AFK_ELEMENT_MAX); + err = mlxsw_afk_picker_key_info_add(mlxsw_afk, picker, block_index, key_info); if (err) goto out; mlxsw_afk_picker_subtract_hits(mlxsw_afk, picker, block_index); - } while (!mlxsw_afk_key_info_elements_eq(key_info, elusage)); + + } while (!bitmap_equal(elusage_chosen, elusage->usage, + MLXSW_AFK_ELEMENT_MAX)); err = 0; out: From patchwork Tue Oct 3 11:25:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13407497 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD64E21369 for ; Tue, 3 Oct 2023 11:26:15 +0000 (UTC) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2050.outbound.protection.outlook.com [40.107.220.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84AB08E for ; Tue, 3 Oct 2023 04:26:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZSajf58tDfxn9///k8qOjAbvH5/YL50PwD1FoepLBe8y4Dz78JdUGL9TOw/gCC9kbHqru4H4/trcuJjF6vWyY9ipxB+iNboKbyiYIFArN/nyppiYqpGt3iywLcYMUKmtMrwqnj30oLjibFzG/sokUCv5oLYjBVuaWksjP+aj8P7zn1I4JYJFjlDE1/Cmpha3gJHCl2bHXqvMuRpC+8j5KRDEZntqifnHXkt7ABHqStndb9U1mdr6OtFjzaghxvBRhYVKS9UI0stl1sPg96rEarAwzgRqR4/3lb8Jo6S4zmV8vDSqEJPReCijeTmlX8hXRqLhoaouqdjbLgv+gay0Qg== 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=2fb3C0kYfhVlls6q5GctX0Hvfh8w8K8IxO9xwM8px3g=; b=e01OPQCXLzGi7zV/Jtw2e7dyTZIyH2pK4YyXf901C1VP6+DdpGtz3g8reaut2lr2buEs/Co9EKOzyA57gRYUdaMcX73yknqgtj46kt8SABn0R/ZRMwh86dCIfyEAsTa9HCNZQiaMXJhMPnZyHYwBD1SAb6jJxe1+Sq3HyYGanZvPzOFmmTH+gpI3kQ9wIlXcpyuBL94i6r4xpUWVhTZ6Qn0u074faIwhSuEplEmD9b/5s7brcdabwElAw+EYAcBds1W8awzdSU2v1JG+c054gXsrTcBqknYJD8puYN2iFvlS+xt2okAvjwnTBFHsAFGFlUdLyOrTlfeKazvQ32VP6g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=davemloft.net 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=2fb3C0kYfhVlls6q5GctX0Hvfh8w8K8IxO9xwM8px3g=; b=QJc7zH/+CgpmpDWtxNhOKt5YUrKaeCUG2G2+xIEehSD/j1BviGQzFtcxal/gv0CPGVTgZEnM8wsqeH7aM6NdGS9XVgZLzB33ZpD1sLTZKuWBGtTTxsXolAyE8Fixw6+Cb87VPP2kIY/SUmZOaCdHkr90plDmzPJJHgBjQF56sFRFbITk0UueQz5TAVWYblegyQoEk44W2hd6C5xsu8mSv7Jt9WYPmrnxlSswX61V5w+Ef+krDQOg/gVkSjtjwuKQfx9gNGdQRepejE4IcZ6DMYXve033FEON6wWlGN0cZaNz1Y+NeZQ3UZE/CydrE9ZPe05yvJwr6BIX0lKki4pJAA== Received: from SN6PR08CA0033.namprd08.prod.outlook.com (2603:10b6:805:66::46) by MN2PR12MB4469.namprd12.prod.outlook.com (2603:10b6:208:268::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.33; Tue, 3 Oct 2023 11:26:11 +0000 Received: from SA2PEPF00001505.namprd04.prod.outlook.com (2603:10b6:805:66:cafe::56) by SN6PR08CA0033.outlook.office365.com (2603:10b6:805:66::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.31 via Frontend Transport; Tue, 3 Oct 2023 11:26:11 +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 SA2PEPF00001505.mail.protection.outlook.com (10.167.242.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.14 via Frontend Transport; Tue, 3 Oct 2023 11:26:11 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) 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.41; Tue, 3 Oct 2023 04:25:59 -0700 Received: from yaviefel.vdiclient.nvidia.com (10.126.231.35) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Tue, 3 Oct 2023 04:25:57 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , "Amit Cohen" , Subject: [PATCH net-next 5/5] mlxsw: core_acl_flex_keys: Fill blocks with high entropy first Date: Tue, 3 Oct 2023 13:25:30 +0200 Message-ID: X-Mailer: git-send-email 2.41.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail202.nvidia.com (10.129.68.7) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00001505:EE_|MN2PR12MB4469:EE_ X-MS-Office365-Filtering-Correlation-Id: 13cab653-2ab9-4707-cee5-08dbc4038bef X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: r4X3sc6R7c8Rr4VMdj7LLMxniUnsTMVcZSncfG8IuSfZ5gcbI4ShXLNgx7GirHfV4lNOpZaJEGZBxmgtLsUItE9+c3wWGUi/MjdbHFpAroo9HzncyQdq/RkDXylJMLAodln/KVFv3ksW9xCRZLCZJiKe6u63re3zcWQX0dDqCqhKRNNpEpTRyjVLq+X6gB9WWo/6BJDN+i9uk+AR0MQgawp2fWPjdVPbrxFY3C7tsGRkYlXHXxWQck7GSVjjYg1gIiXcDWNZiy6QpQ4kRNINdJoTfcTSMn38FHh2NXwcNEJBxzgekuq7aGA5V+UtF8184943Xng3jkxlDHN2iJzhDNUB0kN0eSFKpliP0pBXbmZKr67aC8iUWJkd2Jg3RashHrWXHFKDqEA9zyVOj2D3RMnK1NMJ+y/BZMDAN7339PdliNNBqkrqkLHKKZob99gOZCC1zJuKqm/+lPg+GiK0FesIHWpfIIPgtVNY9fAC8IR64110/liupYPQDn9+k4gjFE8kf3YeOVssqRfKTU35nBbt4rM1dfA455r/gyhHFgPGroWQYrjMnZj2LyTROhpUcdFsENU6btVbURJcFC4JUfFRYhh64u2NMjuLILGx3ug6hYyASmKWlPtqqCA9XFp6uFGF+Sx2Z3dozJaMN0n6W3Zh5unvKJsIf4B0A3VV6TTnlkaDYaHkg2TfwrQFAjlEU79Ih3YrcIiEaC2Rja4tbymUUIJ5KbN8+MVQ95Gta4OQCy0j4MbaoedBkNsBvthY 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:(13230031)(4636009)(136003)(396003)(346002)(39860400002)(376002)(230922051799003)(82310400011)(1800799009)(451199024)(64100799003)(186009)(36840700001)(40470700004)(46966006)(6666004)(7696005)(478600001)(426003)(83380400001)(336012)(2616005)(16526019)(26005)(107886003)(2906002)(41300700001)(70586007)(70206006)(54906003)(316002)(110136005)(5660300002)(8676002)(8936002)(4326008)(36756003)(36860700001)(47076005)(86362001)(82740400003)(7636003)(356005)(40480700001)(40460700003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2023 11:26:11.3033 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 13cab653-2ab9-4707-cee5-08dbc4038bef 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: SA2PEPF00001505.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4469 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org From: Amit Cohen The previous patches prepared the code to allow separating between choosing blocks and filling blocks. Do not add blocks as part of the loop that chooses them. When all the required blocks are set in the bitmap 'chosen_blocks_bm', start filling blocks. Iterate over the bitmap twice - first add only blocks that are marked with 'high_entropy' flag. Then, fill the rest of the blocks. The idea is to place key blocks with high entropy in blocks 0 to 5. See more details in previous patches. Signed-off-by: Amit Cohen Reviewed-by: Ido Schimmel Signed-off-by: Petr Machata --- .../mellanox/mlxsw/core_acl_flex_keys.c | 37 ++++++++++++++++--- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.c b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.c index c0e0493f67b2..0d5e6f9b466e 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.c @@ -221,6 +221,36 @@ static int mlxsw_afk_picker_key_info_add(struct mlxsw_afk *mlxsw_afk, return 0; } +static int mlxsw_afk_keys_fill(struct mlxsw_afk *mlxsw_afk, + unsigned long *chosen_blocks_bm, + struct mlxsw_afk_picker *picker, + struct mlxsw_afk_key_info *key_info) +{ + int i, err; + + /* First fill only key blocks with high_entropy. */ + for_each_set_bit(i, chosen_blocks_bm, mlxsw_afk->blocks_count) { + if (!mlxsw_afk->blocks[i].high_entropy) + continue; + + err = mlxsw_afk_picker_key_info_add(mlxsw_afk, picker, i, + key_info); + if (err) + return err; + __clear_bit(i, chosen_blocks_bm); + } + + /* Fill the rest of key blocks. */ + for_each_set_bit(i, chosen_blocks_bm, mlxsw_afk->blocks_count) { + err = mlxsw_afk_picker_key_info_add(mlxsw_afk, picker, i, + key_info); + if (err) + return err; + } + + return 0; +} + static int mlxsw_afk_picker(struct mlxsw_afk *mlxsw_afk, struct mlxsw_afk_key_info *key_info, struct mlxsw_afk_element_usage *elusage) @@ -275,16 +305,13 @@ static int mlxsw_afk_picker(struct mlxsw_afk *mlxsw_afk, picker[block_index].chosen_element, MLXSW_AFK_ELEMENT_MAX); - err = mlxsw_afk_picker_key_info_add(mlxsw_afk, picker, - block_index, key_info); - if (err) - goto out; mlxsw_afk_picker_subtract_hits(mlxsw_afk, picker, block_index); } while (!bitmap_equal(elusage_chosen, elusage->usage, MLXSW_AFK_ELEMENT_MAX)); - err = 0; + err = mlxsw_afk_keys_fill(mlxsw_afk, chosen_blocks_bm, picker, + key_info); out: bitmap_free(chosen_blocks_bm); err_bitmap_alloc: