From patchwork Thu Jan 6 16:06:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12705515 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 2D31BC433F5 for ; Thu, 6 Jan 2022 16:07:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240974AbiAFQHt (ORCPT ); Thu, 6 Jan 2022 11:07:49 -0500 Received: from mail-bn8nam11on2058.outbound.protection.outlook.com ([40.107.236.58]:31232 "EHLO NAM11-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S240914AbiAFQHs (ORCPT ); Thu, 6 Jan 2022 11:07:48 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BeWJKTaxgAIKN6SOFsLNFJ4TuXbxHMs4yczMAzOqoT64ZD7tdTJh1cUGWcdMWImlmN6kDJGLKjAab+ACKvlLSSdx8+WdUREoMtEj+CBideus9SvgMbSvGn64tfxSzDBL/DaWren5XTFn6TK4gZlvzNUke1tbK6FpnkwZILyifcJesAo43XlcWE85wAscIhQ/AC+6kMbBBWQ4A0Idw5Ue/c5zmnCYQQRNgXqvd17Mqd7gAk9k6qHnmhmpPwyaS9HHrQB5JCJbfsZ6JEaodNe+5V2SiQNQx6uHd1Nj3PQ/qv9QSiTwRrsuWyYK+KRlt06wn4/QRpXwJygsrK8+BcJd8g== 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=qSMKX0JAqZN8er7iphqSvq58JTv9+OzAotKphdplC0s=; b=dA+UkDEBfrKL4Hga/1h5knSH+StA2/t19sC2x0ylyNET8c2BSck9bwkvTKVhJrcLz8e/Q8z6MDxBJJwyTkf+omQt2nSSPlDKGJr55CADSiLR5AvaZz+P64kWaignfZVY3csl0EJ5bwfR8b3s94+GZIm3PGxipnwrmWXO2XJd3UJ64u1gkqMdepERHj+TZE0oVMx1to799pO+/U22QExfnLk12WHlxnKACVSddTEjalr7HkVXTqhO1RQzFLdHw2YFYc/ykz2tozA3SCsmjSBLH1DyrCJmdu2DqsNyYzV0b+1OMvwFKfenRDVDjb7lu9wlJleiTduW2MXPL4txbBChVw== 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=qSMKX0JAqZN8er7iphqSvq58JTv9+OzAotKphdplC0s=; b=M6hjXhH09hnR782axdMzYqK7dqhSbItgc1P1i3V/O74GafdvuCuaDSVeZoPlNxGeqZohvgOYvc55FlkeiL62MFe9pqbdV2cmyOhnyX3V4tX1WVMGo591SIylXVgqcbksreSCj0TtvkYzqwmexn5BUkhJX3GeFuDqD71u0LdZGqvhFn7qSSGRL7DHwkKDUsdgDy5u52gu/FV+Kqj+IY+VxNeP2ySfKgI4FxH9kF8ydXhdsQ8L3QPthIzUmpWdkM/hh6ztuBaPYKMvpPZ9AlPUojDlmA+V618Eh1hFN2durRYT21O89oV+3TTF1DiDND5TPmhE6IL7vM1A6bVN1M9g9A== 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:47 +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:47 +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 6/8] mlxsw: Add operations structure for bloom filter calculation Date: Thu, 6 Jan 2022 18:06:50 +0200 Message-Id: <20220106160652.821176-7-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: MR2P264CA0033.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500::21) 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: bc172523-bad1-4839-7cc8-08d9d12eae0c X-MS-TrafficTypeDiagnostic: DM6PR12MB4058:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1923; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: j7amcUMm0T4IQDk5/ObqjQTMqWWpf5K37hntrv3GSLEnJvYsyM7P44pdVLMEdyJYK2ftp9xNhbInFAeT52u26tx3Vc/zWxzGlLyS0tvWzAFe5jj3c5i/6uP7FkDk5sZ405TvB1xKOE2MgQ7IYAJcomvmddD4x2u8Oickz61dN+gkluxg2TUcUJBFGVPSOMdFdwd6JjxZ95JGYDuw4UoCaAyqR+sHMV0+Ui3JtDsPoKCGopdKFwBAFhx2/o/JjOQEVNa+fZ+6BzsoBQFyzN1y22BexeTRXh43M/HuysxhlJtY6dlg1m7NcjlYSBdXUAhzvjnJ7B/y4Z3zGgaJiohZYhGkM59y8sEM489rvpLrpqzr5jrOl8DCrALfjCJvVHDmOF0aQUhgTujYBe9dojQ/6wdOICkk2jF05xVp5Bs/UNWyIqdQRqbZCBxEFaovGthSq6EEEYaPcMRT47F3XrzgH5bs0JTfp/WwkPUciiSJz1Dxh/gI9IOHaIbmw+ULuugwwDhgQW+aWh+MmXUSiyze5cwkkpgIOPQInQBzQnisA7JJoG98gQsDjO7I82E3zIg7KTTFy+3Lf4GgQu6QF9yCZOxxCon0TkRssttQjv4kD5L+YduvdiYLQs2wiU9w51kMBQRl8wtLcT83oWI4k/LNLw== 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: OxqhsifK/liWd4sop74ntXSDP0sN90tpJRkgNLnyywHwHhObxeYhYn3F8fgFRqoQzeg/LUUbPCzUMIfEH3yolmB/VRkor/f44L1Bf4c150bEWL6SLthzKFVN+k2IaYy9ZFhIkoa0T6Bee4rLZyID+KiONidV5gDoICC+F1b8Q34ChFM3F1DbYc7MkQRPsnyQzqQNbB+4W+z7jo8TJQzKeZT/acYCd26JQYlkE5FdWCeuv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w0rxTyINJ9uS8xMAadGgM0mSLXOGzgDySDMclQCsdjfKvVpEo4GlU7r1DiCOt+wsfrDZa9j7aVivZdOzY3ljK+nISg6hChuHAm0wUJ4X6iP23ZB0EF35n83rPIUtw/rxdVrSG8b+tcb9yiLJbNz2bDSJ96upgTdzvJu328EF/L93wAE9TyL98fPnFWl9BmAFeB/POjmzFPYkolLv2mFrB/0wvl/7aV8MrTFEe7IAGcf4V1Jf5HQsDpO+yxaFn8VWJPy0HHTXjdqbhe+41dahPyx0RS6TSsojlcWM/mlwtGvGufVK4/P9TE6kENwIg= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: bc172523-bad1-4839-7cc8-08d9d12eae0c 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:47.0265 (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: kkbhE+yGoX6I02FTahQS5eNPTxNk9DTByUBJNcCjORyCPFiIyLTQL2/KTr3nVaMeS1yjs6nPW/fo7Ian4m3dFA== 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. There are two changes: 1. Instead of using one hash function to calculate 16 bits output (CRC-16), two functions will be used. 2. The chunks will be built differently, without padding. As preparation for support of Spectrum-4 bloom filter, add 'ops' structure to allow handling different calculation for different ASICs. Signed-off-by: Amit Cohen Reviewed-by: Petr Machata Signed-off-by: Ido Schimmel --- drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 2 ++ drivers/net/ethernet/mellanox/mlxsw/spectrum.h | 4 ++++ .../ethernet/mellanox/mlxsw/spectrum_acl_bloom_filter.c | 8 ++++++-- drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h | 6 ++++++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c index 5251f33af0fb..6e4265c86eb8 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c @@ -3155,6 +3155,7 @@ static int mlxsw_sp2_init(struct mlxsw_core *mlxsw_core, mlxsw_sp->mr_tcam_ops = &mlxsw_sp2_mr_tcam_ops; mlxsw_sp->acl_rulei_ops = &mlxsw_sp2_acl_rulei_ops; mlxsw_sp->acl_tcam_ops = &mlxsw_sp2_acl_tcam_ops; + mlxsw_sp->acl_bf_ops = &mlxsw_sp2_acl_bf_ops; mlxsw_sp->nve_ops_arr = mlxsw_sp2_nve_ops_arr; mlxsw_sp->mac_mask = mlxsw_sp2_mac_mask; mlxsw_sp->sb_vals = &mlxsw_sp2_sb_vals; @@ -3184,6 +3185,7 @@ static int mlxsw_sp3_init(struct mlxsw_core *mlxsw_core, mlxsw_sp->mr_tcam_ops = &mlxsw_sp2_mr_tcam_ops; mlxsw_sp->acl_rulei_ops = &mlxsw_sp2_acl_rulei_ops; mlxsw_sp->acl_tcam_ops = &mlxsw_sp2_acl_tcam_ops; + mlxsw_sp->acl_bf_ops = &mlxsw_sp2_acl_bf_ops; mlxsw_sp->nve_ops_arr = mlxsw_sp2_nve_ops_arr; mlxsw_sp->mac_mask = mlxsw_sp2_mac_mask; mlxsw_sp->sb_vals = &mlxsw_sp2_sb_vals; diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h index a49316d0bd37..e7da6c83c442 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h @@ -190,6 +190,7 @@ struct mlxsw_sp { const struct mlxsw_sp_mr_tcam_ops *mr_tcam_ops; const struct mlxsw_sp_acl_rulei_ops *acl_rulei_ops; const struct mlxsw_sp_acl_tcam_ops *acl_tcam_ops; + const struct mlxsw_sp_acl_bf_ops *acl_bf_ops; const struct mlxsw_sp_nve_ops **nve_ops_arr; const struct mlxsw_sp_sb_vals *sb_vals; const struct mlxsw_sp_sb_ops *sb_ops; @@ -1108,6 +1109,9 @@ extern const struct mlxsw_afk_ops mlxsw_sp1_afk_ops; extern const struct mlxsw_afk_ops mlxsw_sp2_afk_ops; extern const struct mlxsw_afk_ops mlxsw_sp4_afk_ops; +/* spectrum_acl_bloom_filter.c */ +extern const struct mlxsw_sp_acl_bf_ops mlxsw_sp2_acl_bf_ops; + /* spectrum_matchall.c */ struct mlxsw_sp_mall_ops { int (*sample_add)(struct mlxsw_sp *mlxsw_sp, 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 3a3c7683b725..c6dab9615a0a 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_bloom_filter.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_bloom_filter.c @@ -190,7 +190,7 @@ mlxsw_sp_acl_bf_entry_add(struct mlxsw_sp *mlxsw_sp, mutex_lock(&bf->lock); - bf_index = mlxsw_sp2_acl_bf_index_get(bf, aregion, aentry); + bf_index = mlxsw_sp->acl_bf_ops->index_get(bf, aregion, aentry); rule_index = mlxsw_sp_acl_bf_rule_count_index_get(bf, erp_bank, bf_index); @@ -233,7 +233,7 @@ mlxsw_sp_acl_bf_entry_del(struct mlxsw_sp *mlxsw_sp, mutex_lock(&bf->lock); - bf_index = mlxsw_sp2_acl_bf_index_get(bf, aregion, aentry); + bf_index = mlxsw_sp->acl_bf_ops->index_get(bf, aregion, aentry); rule_index = mlxsw_sp_acl_bf_rule_count_index_get(bf, erp_bank, bf_index); @@ -281,3 +281,7 @@ void mlxsw_sp_acl_bf_fini(struct mlxsw_sp_acl_bf *bf) mutex_destroy(&bf->lock); kfree(bf); } + +const struct mlxsw_sp_acl_bf_ops mlxsw_sp2_acl_bf_ops = { + .index_get = mlxsw_sp2_acl_bf_index_get, +}; diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h index a41df10ade9b..edbbc89e7a71 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h @@ -287,6 +287,12 @@ void mlxsw_sp_acl_erps_fini(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_acl_bf; +struct mlxsw_sp_acl_bf_ops { + unsigned int (*index_get)(struct mlxsw_sp_acl_bf *bf, + struct mlxsw_sp_acl_atcam_region *aregion, + struct mlxsw_sp_acl_atcam_entry *aentry); +}; + int mlxsw_sp_acl_bf_entry_add(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_acl_bf *bf,