From patchwork Thu Jan 6 16:06:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12705513 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5E8BCC433F5 for ; Thu, 6 Jan 2022 16:07:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240981AbiAFQHf (ORCPT ); Thu, 6 Jan 2022 11:07:35 -0500 Received: from mail-mw2nam10on2070.outbound.protection.outlook.com ([40.107.94.70]:31745 "EHLO NAM10-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S240980AbiAFQHf (ORCPT ); Thu, 6 Jan 2022 11:07:35 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O+P8GABFI73wkW5Tug7UJqTEMMgoR6oBsz/2darTVg67DGDQWKsiFfg2zAW+QU/KBUQaAf2ZHUYdTIzHdMDTG0Q/o5Y6H0J2fu/XzjnPu6g09Gto9l3y+mRHaheYoaSAtAzeO7SBVMzK6qMqu2dFybSeFAKmJLPfJqNMYPjBB4PG5N4lGIEdyuX4BZWte6GPp0aVLu73lIHe05N79o4lARC1HJ16qxXxGFqVpJw6UpBpfLYC03kliH5wPZQhVZeerXYNMhu7pc4DDoQxfDh+azLRD4PW5hViOUNefbz3jNMpp4EA9X0Go12ekGNkSPa8uu3qwU0nNV5+IvTXQPzGLg== 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=FXADXkk5sSj22FWkYO177+uXKBzhvIa77eGTjMsb8/c=; b=AIJCALXzK5Cg1DAUFHc1liUJLJW1RcEpqmV6LKInUQPoTboiNUEEVKCtlCayBjVhFkUNugUIycHEJPYiMu27JaSRZ7oYkkKetP/pB350aigP3xu7eJJxfMsPJiyFKvMT2RjvqxAjgoV/lOju7yaaWOLgqPt4YZIfnvwwCN+LJ5QBP27w25huyn2fNiON+M+Y1jYiJjmu3EWDLPZzBBkIn4MHep4rhLWfPK2j9eMnwbID+RczOfqk3jyC568DCHp/SYfVPlssQz1+1Y372r3qvltXHfb0wT0gRZhmS6uDhOJ5WK9k6Lw5TgaBEzi6C2OeDIJ4gEmjN2AZfS5YwbPsvw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; 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=FXADXkk5sSj22FWkYO177+uXKBzhvIa77eGTjMsb8/c=; b=NRy88Da8Axg/+F4OCN/q8cphzQwUiiTSb0Sg8alcN5LgXoSD5rSh9mOGyYo60MdTpgCdqMZsABWdiYV5gULzgiYcvoKlzC7LUEh0GqYIhW5CF/Tn8TwPX7dQxJZ6R0joryG7H0u+HLDUV4ANrn8uurX3d9RypG2LLhDYwg+xo75nHiNNbSjJuaL6OX2jmAX8qQpWpgL8QbZjro0YwIcQiFDcnQDFJquuVKsicDFerkjjn8ggCGA3JCI+U8OgG/A+1s9bJwLxh/jw8k2IbGeFHfkv8363UfoOPPBxLZLfNBwjsGqu9+D+V8aem944Atdh3ig9hgw4hlx5QXquOhFiaw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM5PR12MB1641.namprd12.prod.outlook.com (2603:10b6:4:10::23) by DM6PR12MB4058.namprd12.prod.outlook.com (2603:10b6:5:21d::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4867.7; Thu, 6 Jan 2022 16:07:33 +0000 Received: from DM5PR12MB1641.namprd12.prod.outlook.com ([fe80::41f2:c3c7:f19:7dfa]) by DM5PR12MB1641.namprd12.prod.outlook.com ([fe80::41f2:c3c7:f19:7dfa%11]) with mapi id 15.20.4844.016; Thu, 6 Jan 2022 16:07:33 +0000 From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, petrm@nvidia.com, amcohen@nvidia.com, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 4/8] mlxsw: spectrum_acl_bloom_filter: Make mlxsw_sp_acl_bf_key_encode() more flexible Date: Thu, 6 Jan 2022 18:06:48 +0200 Message-Id: <20220106160652.821176-5-idosch@nvidia.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220106160652.821176-1-idosch@nvidia.com> References: <20220106160652.821176-1-idosch@nvidia.com> X-ClientProxiedBy: MR1P264CA0037.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:3e::34) To DM5PR12MB1641.namprd12.prod.outlook.com (2603:10b6:4:10::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 385b3372-93a0-41d7-8c50-08d9d12ea618 X-MS-TrafficTypeDiagnostic: DM6PR12MB4058:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3zbsAHASdUA4hIBSvful+8fVXYnCh2H5b0ZXg7ASdYu/AE0DWTu27xviVBJIuPw/jGtIkd80H49FAe+66eCYoIwchPDKjp+VYIQTE52ED+KNkymDzncrTgj8rYMDbGdVewq9avKV8HOElb5QXVcRH79AcUhzgT7tTaOXksYZJUBo4L1xjErmebBL02pMuYto3Up7xI3NRWr42MfbgFnOtr/cb/c/eCOSeCOZnTK4SvHzpGLIpm/2A19nJgBRdhG/iod4j43SCSo21cn4mWSmjYQuBhvTDG9lq0QM238k5MQ+/t2wBkw/H3MDSPoiqrvDiudpMxv1gjas/pdtI+MI/Yr5smc2Qu6bnh5oYyc1VTcBuimg/rxn8lP8lbyRPMfRseKe6t/iGrOBDwpHVyr2971jSbEbflLZJRi35ijKjm9fSigKWfPzQCxqalteSoL+wVxIuSCiX/mnAbtr90qcoDGIHSqvJkrCyQYDVRPuHF3xRs4+RraCkse0ID0aFVCz0ze3sGQdGXCvntWzJnyK3lBhlafUHaNFCbB6PRBXPcb0MYnFpVlv9LbMJKqSu7ze2mqNZtmTHtyhyJv59pEXQhewvdYV86JmNlJ5ibhFK5jdlUIYH7R10m5gr/2WBAeF3MFFHklLpdWD9Syu4JentA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM5PR12MB1641.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(186003)(6666004)(508600001)(66946007)(66476007)(5660300002)(36756003)(66556008)(6916009)(316002)(86362001)(4326008)(26005)(38100700002)(8676002)(2616005)(83380400001)(6512007)(6486002)(2906002)(1076003)(107886003)(8936002)(6506007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Z7M+LXImj4Y+ibIkiOMm91wERGLC4prZM2qpglZfQKBGqQW229t+KfhGrkc6hSe3jSLiVYkGPcMBSAZlteVloXt+RKkBZBuYwh/qZtFMk/G9GN4yOetWCMM8+fxjR5Wqy4wB8u3vnLo3bvbrrbYJ7u0VRS2ullAHBuA/6r0VffgPPR1UDCNeuM6/CibT5yoWsDnEs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0hr4T2uDd7V6ZvdQ0iZ41QMn6Q6GeaC0pw6pcqnFzxsHMJNrS9YdarHVMFbNyomI+gVN7ubhAIZa0Y3DmZSpBoeRA3BFcg2iBLPJB77A/ArMXsUX8WGQh3dveiu0ByGFrOPspMj2FmEmHMsbU5+kpBKLSN2pEqYAkzDI4ZAmtZSIlM8KDniPp8q4igpIszQtjtjkD1G5NWWPpmPpIV7H9JekoxgChCqZ4R4qV7eF4PzrxjLiUgRb48/VjsrYNtJI3PLeG29HSzgd/X6GUqz/zLvj80+BeqCd7Ms6amuhxiN7B+IaMq5uWUyQvoUunBXo9l6TritwGviEVcdyz8l7tyHZv6KMqrQSbwy2Qzc+LTSE= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 385b3372-93a0-41d7-8c50-08d9d12ea618 X-MS-Exchange-CrossTenant-AuthSource: DM5PR12MB1641.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jan 2022 16:07:33.6213 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: P/NwChT57HfXsQ4JoE67U/VTEI5zpRAAETbKkv1inR3Ua6UAbBNedsrsmnWtFCZxjffpgag8JnJjxyGqKN3UZw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4058 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Amit Cohen Spectrum-4 will calculate hash function for bloom filter differently from the existing ASICs. One of the changes is related to the way that the chunks will be build - without padding. As preparation for support of Spectrum-4 bloom filter, make mlxsw_sp_acl_bf_key_encode() more flexible, so it will be able to use it for Spectrum-4 as well. Signed-off-by: Amit Cohen Reviewed-by: Petr Machata Signed-off-by: Ido Schimmel --- .../mlxsw/spectrum_acl_bloom_filter.c | 36 +++++++++++++------ 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_bloom_filter.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_bloom_filter.c index 732c261f83cf..f0cd14a791df 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_bloom_filter.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_bloom_filter.c @@ -116,9 +116,10 @@ static u16 mlxsw_sp_acl_bf_crc(const u8 *buffer, size_t len) } static void -mlxsw_sp_acl_bf_key_encode(struct mlxsw_sp_acl_atcam_region *aregion, - struct mlxsw_sp_acl_atcam_entry *aentry, - char *output, u8 *len) +__mlxsw_sp_acl_bf_key_encode(struct mlxsw_sp_acl_atcam_region *aregion, + struct mlxsw_sp_acl_atcam_entry *aentry, + char *output, u8 *len, u8 max_chunks, u8 pad_bytes, + u8 key_offset, u8 chunk_key_len, u8 chunk_len) { struct mlxsw_afk_key_info *key_info = aregion->region->key_info; u8 chunk_index, chunk_count, block_count; @@ -129,17 +130,30 @@ mlxsw_sp_acl_bf_key_encode(struct mlxsw_sp_acl_atcam_region *aregion, chunk_count = 1 + ((block_count - 1) >> 2); erp_region_id = cpu_to_be16(aentry->ht_key.erp_id | (aregion->region->id << 4)); - for (chunk_index = MLXSW_BLOOM_KEY_CHUNKS - chunk_count; - chunk_index < MLXSW_BLOOM_KEY_CHUNKS; chunk_index++) { - memset(chunk, 0, MLXSW_BLOOM_CHUNK_PAD_BYTES); - memcpy(chunk + MLXSW_BLOOM_CHUNK_PAD_BYTES, &erp_region_id, + for (chunk_index = max_chunks - chunk_count; chunk_index < max_chunks; + chunk_index++) { + memset(chunk, 0, pad_bytes); + memcpy(chunk + pad_bytes, &erp_region_id, sizeof(erp_region_id)); - memcpy(chunk + MLXSW_BLOOM_CHUNK_KEY_OFFSET, + memcpy(chunk + key_offset, &aentry->enc_key[chunk_key_offsets[chunk_index]], - MLXSW_BLOOM_CHUNK_KEY_BYTES); - chunk += MLXSW_BLOOM_KEY_CHUNK_BYTES; + chunk_key_len); + chunk += chunk_len; } - *len = chunk_count * MLXSW_BLOOM_KEY_CHUNK_BYTES; + *len = chunk_count * chunk_len; +} + +static void +mlxsw_sp_acl_bf_key_encode(struct mlxsw_sp_acl_atcam_region *aregion, + struct mlxsw_sp_acl_atcam_entry *aentry, + char *output, u8 *len) +{ + __mlxsw_sp_acl_bf_key_encode(aregion, aentry, output, len, + MLXSW_BLOOM_KEY_CHUNKS, + MLXSW_BLOOM_CHUNK_PAD_BYTES, + MLXSW_BLOOM_CHUNK_KEY_OFFSET, + MLXSW_BLOOM_CHUNK_KEY_BYTES, + MLXSW_BLOOM_KEY_CHUNK_BYTES); } static unsigned int