From patchwork Thu Jan 6 16:06:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12705510 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 35ABFC433EF for ; Thu, 6 Jan 2022 16:07:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240971AbiAFQHR (ORCPT ); Thu, 6 Jan 2022 11:07:17 -0500 Received: from mail-mw2nam10on2087.outbound.protection.outlook.com ([40.107.94.87]:25601 "EHLO NAM10-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S240966AbiAFQHQ (ORCPT ); Thu, 6 Jan 2022 11:07:16 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T6UhvaMm0wdMbXju9GnKFBag80J2cd5eTC6FC18+S74/FTh3vcdktifNZ8GF8L3+nmL1SPvxDSUpUeBUteMhJ+tX3654RA2J+pSdl9Cf6fW2JaNdXFuEL873bDBvGmXL8nK730469JQy0toCwgfDGxWLYRFphAiCTnr49y7QpmsWGlAqsbJYRcySG87Pqpemkjn2T7DmkOD6k84ocGiStLzMG2viuCTN7VBqR7+z01HGq5yEFnl9l4RhiKom8Ky8juTONG+bPcMW0x+NtagJOk5e168HfivfckQTV/v3F2M07tr/9nI5IMtl9fjDKWGWBNdQGbDmw3mSEvspaNm14w== 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=QeVJ4b4pt0MTWMLMzrNRvFmCEf87r9E/+4ajucbZW9o=; b=LJh4Ktg+oG+l6+qbhcrkauAbgrwzqPd0VCo//YGrwQ+qBEhGaIlGwyj8h5ZIvZ2RaqmAWfwiz6zfoVupKosMVztDtOMQIutuqF6zIbFV5ttKx9R8aLUlxdDFsbo387YEPxnNPZvUu6wOiXrmTjX2bFlIU7toVygs+lz4iXjA49NXRlQUfFGvvBidw/MNNleJlWYJ35BLIbNGtt9FHgV+Y7XMN2XrNHefwd2ZmL9f2K14E1FX9FGlVVGBabj+vW+uK1jPPKJWKFvW79LaoQTBkyiMa7iSO7LAzfTb7yNas3HsMrKfP6fFC/gQLvwfD2O2QGjcOxddx8sgAmqfutFczA== 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=QeVJ4b4pt0MTWMLMzrNRvFmCEf87r9E/+4ajucbZW9o=; b=l9+l/OszVxGq2ENi/XDeryuMgbFqAbrN/EBagS7Z2O9dkmp5AUdDKQEYl0+OjRI3DetYBKSbf029kYR+MoaaODqIEpnLFpOhzu9pSRWT/Gr7T/SB2WcY76MIVrU96nIv8HBsCrc//aEtkICJfoMd+nL+wHMq6jhfGYMYuX6b7YbJ4PVE5wXRMp0uP41GpXYK9dyZHMpOp6kEU5laRxLq77XAQCLhsxc18JYVPaxz2Sbv9MYmENarnGV9NllMXa2aIogTTyjeSQBZo003fAOZoRZ77jm3GXcTsQIx9IjAfKSpWnJtNyuP2V1cutvVMR9su/iPc77nE5KsnRLNxdWRIA== 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:15 +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:15 +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 1/8] mlxsw: Rename virtual router flex key element Date: Thu, 6 Jan 2022 18:06:45 +0200 Message-Id: <20220106160652.821176-2-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: MRXP264CA0022.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:15::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: fa6829cf-29cc-40c2-caa3-08d9d12e9b5b X-MS-TrafficTypeDiagnostic: DM6PR12MB4058:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iFKWn3krzyinIL6PVsUBLMRqiZa1cS39Sp99e2vxr9DAkcYhQ/4UE4LNs2l5zgqmDtXrOKWxpDx5aX5cD8cdDeUr8TbINT+0Ux4IJLh8S6hNz2q5808gL0rQa4yDEjcqRKYpHPQRSPDh93UnKo5Zi8xu08ZPP1PoV4s8Jvcw/QMBd6GZcN99K/Ps9NRhMtfmTWCd88ua5QXgyehChRENFbtsKsG8p1N+w/BF0+BWjmGeWqlizBWJPagHGWyv1ozutvhKioJ+ehWdgf/sWcpB+9ID2OP9HngR6lP5C2RPY65buQLsX+gggmwYOQE8JklNcevvLc/pne6gSQi5eY0c6In/kS6O9yFfD4k1KoQGpsvoT88HXMjOEzafkl9mR4VBwM7TfNHPjGFPYosfqGOqy/SAlD+UJ0YdPybxvWBn2nXbk6QjDql1tqvHY6QR/rVd/l5N/WanUCnemBObyqS8R6KgINcgvieM5jiKRzpyHE6oe60Z4nYj9LIBNdSnHu8DR6SfKgm0WMxQq8YiQV/jAgfVcwkk8WxgpVe1zSlbTMNgFMwZwVmRjodrodawsvvho5Ye9x6dyg85Os6Z+XH8j2PxcFwXodcIItk14cdTCgVljLBX7xFfyyN9a597/sbxxNfIOkXB4SgnZJ/J3jh4IA== 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)(66574015)(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: dmz8t0G2IwSLsUIxveJcfrpVb71X0a7HQCLWGhg/26AdFK9a/mqqLPiROtjk4cjT3ZEnKNyAX78ow+LompbdXhCS33NvlApi0RlzndvvTfG8BAzGSQttZr8kGVqfJVG6KhRW0/hhpjwv9H+woD8sKfqxNyg9ZEawaiOz4Nufuv7xqrQuGkZgM7G27uhOj/2iFm5UW9+QE8YEH2dDoLksbK0KqDk+aE5+hV9sGRxP/3k3QLo5Gpx6lxNpcD1TGKF9p3DNLhCU5N7hZZP0wmj8I22U9J0OfyH9R/OYb5464GMiNFHHzqHszkcbf2z5bjHY4/HZgGSdFvoeXcNkkE50NmwWvElr7nisajxeKEzfi7Sz0zFQ5GFTV0ijmknnUKDKethGgIHWjWDLKSnKSFQb+tIuAkYwntOve5AjAXkJJPd6JRsXC40o1Rhvc4O2eiTsl+qJItRQBbUTOWLUYA3Vecuyit3MGwZf28ZKe5NZ9T4JlRsfCGnOhzjpkUOE07VSR3c9iCKoG/9iGcMfethLQP0kOtMa55uhlPtN7e3cp1zdAxCY3si6tEpd7c0j9Yh+YPIEKUYcLzGcmPcLvEjzfhdl5rvn8wsFi73rEYSLs4zM+b89O2EUWJCmpoehMVGxWGr7MjUSuJkuFXl9GAdHgD0eYJhffHtriKgvqVc6Wc1ILF1u5vnMYnBzFIzoxsbaQPSoF3SZU00hUrFA6WhYL+fiu+9wiNYkY2QRUJO5YaY1xwBAjL0g7ZlAFHZOzYDAJEbv9B91wKb/5FSjhjYNQ7H3TRlLWjXHOpoPoVoLb3mgUCWgCCDVzHMWrKiPO9f7zrc/2ThfWE2KXgoJj8BsNllfcygvTi+W8FxtG8LpKmwEYkOcGlmrdyyGGIYtyVmrO9mIk5NzuSpEno9aEAtFBI0kykNISpIZjs/OrOe1yfhVkd3+/uX9hcte/S+bFDjHcyAbgufZVvXEu2mR9TAIEYQJytjgZBK7/TPoPuw3Tbd5ADSH4jszPr1l3m8XpCkzziJzmhXiWsQUSgXnQEalo49onfUwJyjXxLjOpla+W2CfF+5FB2aOR+p23NO2wH2VZ98MiUUzxmx9DZ2wUpt+UgET+irTJIZbTjK1IIZEwW4MAZM/VjmzRntJungF7NG97Bji0x+7AXFomWezWv7ZyGKtYsdU7uTHWPJWVlq1jx/BkKDd8vUR4l7Wkc0BdgQhg9DaeCMLDg7w4/XkqmMR3LqVLAgTQPgTCgWgZYoP2pyw60M49sFuTfO+0WIFrCmxnxRCH/S3U2OQzLj41ht9EXbukrHF2RkjT68VgKEdg3M40v8ZpkeIORbFZhsSbKs5o8oQx+VBQQembogJRRCWP3+47BxreIwu52dsWhGh1KIRVwMloHq0jPOqHjacSnQMH0NxH4GCqp4Cuhn/pmz1qQRUJRuzaYVj0UaT1AUIYqOOYCOdUIIGEnhpIex665vCEh9uDL44JGmYOBkwrtFfDG+gQl2SIvfPzjJAM2/Suseckv3ykq4ZLT8/9KZQ73DXEC9chuVqn+qJSsrrIexQv40U+Lss8CEhNZYMBxnPRB4o0TozLbNeKHKhmBf0Yyr54yg3rXde/t4GwmB1AvHVWV6SSbvLyEwtmllBrNmJU9o= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: fa6829cf-29cc-40c2-caa3-08d9d12e9b5b 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:15.5601 (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: o9UNE2QkuVLH6QXJfJji1AavEonjVJlutMcTy0ZL5OoJ8H1sEXlCp6VCA1pvFkQJgOfEVXPEcNDHrbN3bO4Qyg== 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 In Spectrum-4, the size of the virtual router ACL key element increased from 11 bits to 12 bits. In order to reuse the existing virtual router ACL key element enumerators for Spectrum-4, rename 'VIRT_ROUTER_8_10' and 'VIRT_ROUTER_0_7' to 'VIRT_ROUTER_MSB' and 'VIRT_ROUTER_LSB', respectively. No functional changes intended. Signed-off-by: Amit Cohen Signed-off-by: Ido Schimmel --- .../net/ethernet/mellanox/mlxsw/core_acl_flex_keys.c | 4 ++-- .../net/ethernet/mellanox/mlxsw/core_acl_flex_keys.h | 4 ++-- .../net/ethernet/mellanox/mlxsw/spectrum2_mr_tcam.c | 12 ++++++------ .../ethernet/mellanox/mlxsw/spectrum_acl_flex_keys.c | 4 ++-- 4 files changed, 12 insertions(+), 12 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 f1b09c2f9eda..bd1a51a0a540 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.c @@ -32,8 +32,8 @@ static const struct mlxsw_afk_element_info mlxsw_afk_element_infos[] = { MLXSW_AFK_ELEMENT_INFO_U32(IP_TTL_, 0x18, 0, 8), MLXSW_AFK_ELEMENT_INFO_U32(IP_ECN, 0x18, 9, 2), MLXSW_AFK_ELEMENT_INFO_U32(IP_DSCP, 0x18, 11, 6), - MLXSW_AFK_ELEMENT_INFO_U32(VIRT_ROUTER_8_10, 0x18, 17, 3), - MLXSW_AFK_ELEMENT_INFO_U32(VIRT_ROUTER_0_7, 0x18, 20, 8), + MLXSW_AFK_ELEMENT_INFO_U32(VIRT_ROUTER_MSB, 0x18, 17, 3), + MLXSW_AFK_ELEMENT_INFO_U32(VIRT_ROUTER_LSB, 0x18, 20, 8), MLXSW_AFK_ELEMENT_INFO_BUF(SRC_IP_96_127, 0x20, 4), MLXSW_AFK_ELEMENT_INFO_BUF(SRC_IP_64_95, 0x24, 4), MLXSW_AFK_ELEMENT_INFO_BUF(SRC_IP_32_63, 0x28, 4), 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 a47a17c04c62..3a037fe47211 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.h +++ b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.h @@ -33,8 +33,8 @@ enum mlxsw_afk_element { MLXSW_AFK_ELEMENT_IP_TTL_, MLXSW_AFK_ELEMENT_IP_ECN, MLXSW_AFK_ELEMENT_IP_DSCP, - MLXSW_AFK_ELEMENT_VIRT_ROUTER_8_10, - MLXSW_AFK_ELEMENT_VIRT_ROUTER_0_7, + MLXSW_AFK_ELEMENT_VIRT_ROUTER_MSB, + MLXSW_AFK_ELEMENT_VIRT_ROUTER_LSB, MLXSW_AFK_ELEMENT_MAX, }; diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum2_mr_tcam.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum2_mr_tcam.c index a11d911302f1..e4f4cded2b6f 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum2_mr_tcam.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum2_mr_tcam.c @@ -45,8 +45,8 @@ static int mlxsw_sp2_mr_tcam_bind_group(struct mlxsw_sp *mlxsw_sp, } static const enum mlxsw_afk_element mlxsw_sp2_mr_tcam_usage_ipv4[] = { - MLXSW_AFK_ELEMENT_VIRT_ROUTER_8_10, - MLXSW_AFK_ELEMENT_VIRT_ROUTER_0_7, + MLXSW_AFK_ELEMENT_VIRT_ROUTER_MSB, + MLXSW_AFK_ELEMENT_VIRT_ROUTER_LSB, MLXSW_AFK_ELEMENT_SRC_IP_0_31, MLXSW_AFK_ELEMENT_DST_IP_0_31, }; @@ -89,8 +89,8 @@ static void mlxsw_sp2_mr_tcam_ipv4_fini(struct mlxsw_sp2_mr_tcam *mr_tcam) } static const enum mlxsw_afk_element mlxsw_sp2_mr_tcam_usage_ipv6[] = { - MLXSW_AFK_ELEMENT_VIRT_ROUTER_8_10, - MLXSW_AFK_ELEMENT_VIRT_ROUTER_0_7, + MLXSW_AFK_ELEMENT_VIRT_ROUTER_MSB, + MLXSW_AFK_ELEMENT_VIRT_ROUTER_LSB, MLXSW_AFK_ELEMENT_SRC_IP_96_127, MLXSW_AFK_ELEMENT_SRC_IP_64_95, MLXSW_AFK_ELEMENT_SRC_IP_32_63, @@ -189,10 +189,10 @@ mlxsw_sp2_mr_tcam_rule_parse(struct mlxsw_sp_acl_rule *rule, rulei = mlxsw_sp_acl_rule_rulei(rule); rulei->priority = priority; - mlxsw_sp_acl_rulei_keymask_u32(rulei, MLXSW_AFK_ELEMENT_VIRT_ROUTER_0_7, + mlxsw_sp_acl_rulei_keymask_u32(rulei, MLXSW_AFK_ELEMENT_VIRT_ROUTER_LSB, key->vrid, GENMASK(7, 0)); mlxsw_sp_acl_rulei_keymask_u32(rulei, - MLXSW_AFK_ELEMENT_VIRT_ROUTER_8_10, + MLXSW_AFK_ELEMENT_VIRT_ROUTER_MSB, key->vrid >> 8, GENMASK(2, 0)); switch (key->proto) { case MLXSW_SP_L3_PROTO_IPV4: 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 279c241f76f0..fa66316234c4 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_flex_keys.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_flex_keys.c @@ -168,8 +168,8 @@ static struct mlxsw_afk_element_inst mlxsw_sp_afk_element_info_ipv4_2[] = { }; static struct mlxsw_afk_element_inst mlxsw_sp_afk_element_info_ipv4_4[] = { - MLXSW_AFK_ELEMENT_INST_U32(VIRT_ROUTER_0_7, 0x04, 24, 8), - MLXSW_AFK_ELEMENT_INST_U32(VIRT_ROUTER_8_10, 0x00, 0, 3), + MLXSW_AFK_ELEMENT_INST_U32(VIRT_ROUTER_LSB, 0x04, 24, 8), + MLXSW_AFK_ELEMENT_INST_U32(VIRT_ROUTER_MSB, 0x00, 0, 3), }; static struct mlxsw_afk_element_inst mlxsw_sp_afk_element_info_ipv6_0[] = { From patchwork Thu Jan 6 16:06:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12705511 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 5FBE2C433EF for ; Thu, 6 Jan 2022 16:07:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240968AbiAFQH0 (ORCPT ); Thu, 6 Jan 2022 11:07:26 -0500 Received: from mail-mw2nam10on2086.outbound.protection.outlook.com ([40.107.94.86]:64913 "EHLO NAM10-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S240983AbiAFQHX (ORCPT ); Thu, 6 Jan 2022 11:07:23 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P8GfdlipHMdKVg9mJa3TQRkzOrqmj/IAIZuW0pX9R6eqkJaMirPSe+/BxMWknI1gLqNdx6pHmzlj4Of2KrzLgb4NU5rxB+ZO/HG2EMzjfP/cPJlA1CVJB/26lYLRI4HB/wN8D2HZPJR4vJnTXqu4jC7+Qy5Pl/v2l9NInFrZ0xJS8y36So+/nKvGWoZ924tvbWqYJpVGPiJJkKYsvxol4mzoIIsoehHcIptsK7GvaiiNozwIC8TpDc5Es8HCEy7RnYp5JuNAmPGe/Qup9QbFEicrGaugiz7zLSyvAwJe0rDyxQhGWYNa2WguSK2O1Y452vceJHkYlam2w0C2+sDwfA== 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=Rith8m0QzWQdXM0enrf3J2o+YUHSoCIKXS0QtRTQgx4=; b=MYvCoxQxK/jOfyFTZUncCRyHpKYStFrfX9weTG7WyIouaDOtq7DvDGkG32Tbg7miShfx+kJrB0mP6uaVTTSODpY3aW7WRyAnJMwxD0mlmTO4bhMMQNFKfSvHafLwTPJj2Bd4YAbNiN0B4z8Hs44ufVoP91AY14ILOK7LcsXIZ13Ho/D4ClscsiSRnRxJQ55hDvR5DSyZuYA3uAzfyjo44Xdx2g/D1d32AzzzWWKMX9x/I9oghXft10qt9gPAbCqKw2TwT8+1iXHQIiqe5wct5l/rJ47Ckwltoas/MHWVrvQ7bG5Bu8hCzpkqIQpKEK8zHkXbgUe8s0itaT+ecoUoUQ== 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=Rith8m0QzWQdXM0enrf3J2o+YUHSoCIKXS0QtRTQgx4=; b=ZR3fWwf3b7cjrgDEwM7epPWUZcJkE+Bqvo6P9cBL1eaGkiml4BjQloKmk7uffL0xsFYFg9ZjPT6JTkZ9xIYDJke4f+fa+mPfG9wkErfnDT4EN/A15SSvzsmgO5KZ3Y0ddgqYmixalFbOsbxzJSES0dyFTxmIMn7J4IPyfZi5Mf6TbJC/cN2x1+fx6T1NNoa3VcRm6ZPPdWxhXuzj11fxq++oCJmmrKVz07VGaxFH8L5AZPTT9m0rpLmsGTkGaKq0GdhLjlsNAAS1camZfB+wMX44GWHTnJn0oYBett/5TMresA47N/Pke9Q+ucyuMo4+3VNqP6W+14nBhioeMrsDKw== 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:21 +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:21 +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 2/8] mlxsw: Introduce flex key elements for Spectrum-4 Date: Thu, 6 Jan 2022 18:06:46 +0200 Message-Id: <20220106160652.821176-3-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: MR2P264CA0055.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:31::19) 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: 4d529031-8660-4369-b48a-08d9d12e9f04 X-MS-TrafficTypeDiagnostic: DM6PR12MB4058:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: coHwL+e/CkHekDA9JsTTniGciPuXFXfP+tC97ATRYl9OEUpZ6TOZLtgRJnH/GC9hki1QeUC3GZ7sBY7IPROYbAOuvcpc2HkBkESs1k8RiA1q1cepvk9EyVcxN65KkmF+BpTCEqvy4yXZEP9okUBmX8Ew6lJjAPUiRMaeJ+vq1oQWTWI+XpOYeecq+I9LqE1q36/0vG7XrB2OCSUbhbDOf7DuyW38WLD7OheNOyzzsq2NvlpSBbjnHbZJeeX1WwR84m4mAxYeNpvlVFIjfAQOpcxBKN8VRfHuUXP73tHOoVl/JofEFFdpkhiDAPDr3SnXyf4OHVQweJJ+gxejE6VExG33mXfTAb3pcTKgtLkA/jDcvtp+tRvk+5/fuqjzqPfDeXuDH9DZi9NCFyigCt346dK6J1pvopN2IZZZMgy0Y96XO7Gp5bWyhPjFVRDg1lkvvYTdswQ5vsQpv52jILEA+QDx1JYIXOLex1MMkBwKUFXwmpd8lnOSdckVLPAN7Uf/4FMr6rctnk2wU8/ZVBF1T0vc7q5Ad34An+RjQcVs7jJA85Wl0B/dRu9JfvTcZvRzxYacVxHlm0qPB5Ks97jDP5kbPShmY/AcxaaMiR/eDyf2y5IyI37R4lGZhf452KUOLKo5oBIjYCWxCTNWgvIvJg== 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)(66574015)(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: 8RXM0xJrkKoR0+NSiLEHEpP6sKLN+hco2oM0+/m8ll6W52+FwHSD2nunpBCVQsZTXZfw8lcyy9tO/ccPkZ3WdjeusIJYLNlJjV0gMNZceULLvuXnmCS4EDmcAEZblQOUvTVMYCG/qCdbtQ0RCaOmlYWQo+84n+v8VW0wN4Qow4duqMaQP1Ahm3p4Bk3TGwQEO5CLPTyKBmqWyzDpF38rXQhdgloveS7sAOU87kXwlwAC+2NCJy+iW8Dkwzuc5Lae83KshHvSN9v+ev6nB4reVPJYgB9K0yZimjH0ZDNgsxLBnVZHRdff/SuutvEpUYEm000f19rHNC85bhs9k85StUnRfsCbKBTnxpLuIKx4JGnJ2M349ZiisERVP9S6iTkgseHBKqaNCE+2yeT47Xkgfm8ehCKqpgRrVC/9Pf0/IEAIYhrmd9pEYHwY+8jKJQExsyVQzSRHx60WCTrN6IzQcL5AGRM9ddYFZmIZDt55QSYzkb5+tR4z5SWJCSO9auRYib9fubHxk7IeacR8FoQczKF2cS/gqS9M9/RfgpGGvlY6874//HFjeKGJx+hb2Xm8n4p7aipWKvR4UHQOSf1lmQI5oymm4km4T7EwD/DhGE4CFsWn76j4vzTMnlL0VFg5GnsHqgvBeZWGJaaPirIfu9+tTkdgxiJOG9oF7PFKZbQSgJRG7VilWcyjNrP8yLiDCYvhm6SrgSgeuSDbFpMRLFXWirZLX5Nrhmy3mhjQ2seWz3ZOU6x+CorKb1bMqxEFALjaUI0TGnIR0v4TJG/3yk995qBPLLEDAhHmCUpjfN3UowekXUnN/qene8sViHQZsXFI+pL01hDCO0oocYSinlRmkRXrurpnFEZXNhXmDOfn45S4gVKBqLmNAaYLTYNpCaX9Epnmj/9npWButsK7Rx9vJhOJXqLDXdg/q9JHj9lksFzKfo8a1muJrM70GsQ/EfbiKq408zVkp2Zmk2GlpvluKGm5IQfvL5KmZEn8z5XHpdYy1mmIR5a4N024pBE3Y+ZMjS7B+Hc9i7QuTbW7Wl8TG4Bm6kUzBMy38+/PFwCoyUjXW+IkG8HImaNGOYq5Ie6IWWYpPlAxB6iHSZmixKn0dunkyvSwpVIL3TfdH7ScSUe+G00pr3ILQw51evu5in7G/RWaCQeWHIjCz4RnZqvx4mmx6EYqljcXQMAN76VcHrvdsYxKhpHWbVZN2mrKuqFiKMpLsHnLMNBOo+2aaaJcvg6BczfSBcS4aW0VEzaDFucoC5AQ7qL5NGMOmZebA070H1INRI0O2tOrOz2fTHvOJKYhilEd4RV2bDXpld4TWy43Z5s9tqxByFP5hkuJwd+e1FQX3A7FMFeGkcsP2DdQ+HTRmqAAwnMryZY1cAZFBIjeGv/o5Z3kdAqAOs8DvcM3/iyyQT9Mak4CfG0AKXOea/Cc9q7Pe18cp+bML3LKUgw+PkBAFq/bUYcQhnnE35zCWyF0iuj145V51gak0Py9Vfxc2ljYO4TYCFGFAfhlPs1LQ/jIM693UfzLvgNhHTzXoGBb+9ikBPku7gDobwBWYVQiRUdlVc7fOGHF1rXIjRGGpl2P9R+LCIzIle0kzD892TVWxDM2HWLrjY3r/eRFqRNbjwV0N4mPPdsszzI= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4d529031-8660-4369-b48a-08d9d12e9f04 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:21.7316 (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: hWSJEPsQFjPVtFDX173d0dLOUEdu4DdUAiZqGhMTxmZqf2fHFVfI+mmeHB6uGI/KbXupfLkyn6BIjEafzkdFTQ== 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 ASIC will support more virtual routers and local ports compared to the existing ASICs. Therefore, the virtual router and local port ACL key elements need to be increased. Introduce new key elements for Spectrum-4 to be aligned with the elements used already for other Spectrum ASICs. The key blocks layout is the same for Spectrum-4, so use the existing code for encode_block() and clear_block(), just create separate blocks. Note that size of `VIRT_ROUTER_MSB` is 4 bits in Spectrum-4, therefore declare it using `MLXSW_AFK_ELEMENT_INST_U32()`, in order to be able to set `.avoid_size_check` to true. Otherwise, `mlxsw_afk_blocks_check()` will fail and warn. Signed-off-by: Amit Cohen Signed-off-by: Ido Schimmel --- .../net/ethernet/mellanox/mlxsw/spectrum.h | 1 + .../mellanox/mlxsw/spectrum_acl_flex_keys.c | 42 +++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h index 8445fc5c9ea3..a49316d0bd37 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h @@ -1106,6 +1106,7 @@ extern const struct mlxsw_afa_ops mlxsw_sp2_act_afa_ops; /* spectrum_acl_flex_keys.c */ 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_matchall.c */ struct mlxsw_sp_mall_ops { 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 fa66316234c4..00c32320f891 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_flex_keys.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_flex_keys.c @@ -311,3 +311,45 @@ const struct mlxsw_afk_ops mlxsw_sp2_afk_ops = { .encode_block = mlxsw_sp2_afk_encode_block, .clear_block = mlxsw_sp2_afk_clear_block, }; + +static struct mlxsw_afk_element_inst mlxsw_sp_afk_element_info_mac_5b[] = { + MLXSW_AFK_ELEMENT_INST_U32(VID, 0x04, 18, 12), + MLXSW_AFK_ELEMENT_INST_EXT_U32(SRC_SYS_PORT, 0x04, 0, 9, -1, true), /* RX_ACL_SYSTEM_PORT */ +}; + +static struct mlxsw_afk_element_inst mlxsw_sp_afk_element_info_ipv4_4b[] = { + MLXSW_AFK_ELEMENT_INST_U32(VIRT_ROUTER_LSB, 0x04, 13, 8), + MLXSW_AFK_ELEMENT_INST_EXT_U32(VIRT_ROUTER_MSB, 0x04, 21, 4, 0, true), +}; + +static struct mlxsw_afk_element_inst mlxsw_sp_afk_element_info_ipv6_2b[] = { + MLXSW_AFK_ELEMENT_INST_BUF(DST_IP_96_127, 0x04, 4), +}; + +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(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(0x3A, mlxsw_sp_afk_element_info_ipv4_2), + MLXSW_AFK_BLOCK(0x35, mlxsw_sp_afk_element_info_ipv4_4b), + MLXSW_AFK_BLOCK(0x40, mlxsw_sp_afk_element_info_ipv6_0), + MLXSW_AFK_BLOCK(0x41, mlxsw_sp_afk_element_info_ipv6_1), + MLXSW_AFK_BLOCK(0x47, mlxsw_sp_afk_element_info_ipv6_2b), + 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(0x92, mlxsw_sp_afk_element_info_l4_2), +}; + +const struct mlxsw_afk_ops mlxsw_sp4_afk_ops = { + .blocks = mlxsw_sp4_afk_blocks, + .blocks_count = ARRAY_SIZE(mlxsw_sp4_afk_blocks), + .encode_block = mlxsw_sp2_afk_encode_block, + .clear_block = mlxsw_sp2_afk_clear_block, +}; From patchwork Thu Jan 6 16:06:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12705512 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 68AF9C433F5 for ; Thu, 6 Jan 2022 16:07:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240969AbiAFQH3 (ORCPT ); Thu, 6 Jan 2022 11:07:29 -0500 Received: from mail-mw2nam10on2058.outbound.protection.outlook.com ([40.107.94.58]:12352 "EHLO NAM10-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S240966AbiAFQH2 (ORCPT ); Thu, 6 Jan 2022 11:07:28 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C2vmFs/rxACIdSvV/Ls3oo2nfHJF6nWGML7RSObQUfiGrpxKOSy5H3YDM79GR7AMoqmWvLOAwZThIWF7VDeYRxAdy54JOg5bNk3jpON7c7iZHT7/otI7Mc/u1MTmmaQCtrhMUsEx/A95v4UI6Ix/mt0Y8IQwdw3mNNWQnoSaa6keexQ5ySIDyPoD1RqagXEsUo6oDCXPR8sM7b4PmN89/90SNwwhKK/5VNKXWcoTPdz5KxGwrtTPNkH5/0oU8SniS2m8HOml4GsP3F/C4nBZVHaeRStHqrKZ6Tlc9UB4bLV3e+D5qtlvRFaJ/ZV+3lGXZeG7ZUZVDeb6H7tKwSIUOg== 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=tkJDIhuS/iCCNTR/zf5IbAFpdtEslz5lCN5y/ffu3fY=; b=AIcxRRWBqpHFzULR+EauogpUM9FqQYXKkMjSycdRdu3mj7KJx0GXrB40L9lOq27byDrfaU6SD1GLADvohAb+5AoaQlLiEMwncic35UflQEMb2uw4xShy3o95prZqWZoGKzoQ8S6fPUF22ELUmdGjg3JlDjDsdMeCRPPnQroUVCETUavGn3oAbMNCHmuJRrbwXxho2dilRjsicORD9GRHR7/JGpo8pFQgcEpVCb68BzzGHpxHoaIVAHm26iqdQHQqfFYWaug9jkTonCKa5IaXP9E8xUqKicQlQLLp103emmwu5ZtpFfmebqGI7NmECUhj2qyrZCgRa16md39FfN2JUA== 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=tkJDIhuS/iCCNTR/zf5IbAFpdtEslz5lCN5y/ffu3fY=; b=al5tuqln+fWmBRQL9y88+zUIgKk41LOHvqxuNFOcoORR3kfvRVYxVsv0TOb43h3nTuorJnok5sSuA8u9lVSKNeOiDHMlPwfuc/4e4SkMIYVjFP9VylnBCMRzXIGbu5HcSsu0myh6WLiN/0xnnYi9C/lgMvByk/X4PVAEjsZ3fU8Cz2nOq8SaxN92mJ5ViKCwZQBnuqfLFBjv3IeDzzHa2fbBee5CtM4ZHW8kLRBfshVKoUO3iBeJQgJ1I18Em1Z0aW1DQ558xuoS1pEOp2U3XIlSfzqAk6+R5Pzqw50XrMDArXeDeLuhVvV7OCmBKbvxNZYdO+tlaSLNRP+vcXjVcA== 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:27 +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:27 +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 3/8] mlxsw: spectrum_acl_bloom_filter: Reorder functions to make the code more aesthetic Date: Thu, 6 Jan 2022 18:06:47 +0200 Message-Id: <20220106160652.821176-4-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: MR2P264CA0021.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:1::33) 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: 1872f7c3-1a4d-403e-528d-08d9d12ea280 X-MS-TrafficTypeDiagnostic: DM6PR12MB4058:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3631; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4lJiXtNKRLtoIs147WFwOh4V6wJcquiROoHclauktj7cgDL0Dx+tfJiTJhGKVFeAWaKWMovoZ6i5a264CAW+xWjECYtwgjtu8qFCW7Ozg6eFXwGPIBWWeqmi/KAthsBSgyRS89/wADdeDRHqHkM00/DfQ4ZPASxs1Hq4ceImkFSBj9zztzFG0myarEkuozvkf74ffFGVEsxk2JDOgOreYXqADeVRyPizS2/Ns7TK1JrTPsxGIFOlAOGpAl+N9kxM/vQcZRIBDTuU3GYkEYv9HMR3C1Yg16prLyZsi4RurwZE0bEw9UdHvWrd0t3scYFDeNQ+/a6b2o+lG2KzEz6eXFbXGyGzYqGIoFT+YOYL8v8Isbb71ueTZNZg1W8WSsaxX/ntOEYT91dPEWLz3rCyJmd+OnmDf24yLyHJMFQI2xHDG4J0GNu89lBFylidqk0Ned/EoNRIFobZgyJByf9Lbo6rt55dIXWOzIKSRPvYPVI+RBQQ/F2+b9JwVV/DDcTFyOj6+XpGnSBc4v9Yuo4A7Hss0fZa8+QquWme788JArWUimJWOgesTb93+Uh836HPk7pE0C5aGpNI0c0lmDjyH5G0p9snWSydw26jG5ok+VynUtzgLLk6AaJwWLnCGyhBItAEpI44xWodaFa8ddTFtg== 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: CQGk7KhTBADbI2/CaC0atMHZtHPKmh5nv6+DFj+jWkMtIAa1K6iq5qPVCXd38tPdNeSCRbIrjWLQrxViWM7uXneI7p7xt3b5yqK8l13oeTQ4fm7xXDlxt9wcDEY6K9jeksM7eL4row55JUULjsNXq01xgesQrenJ2kXklQYtSgbep2h9qvCWetwsBzFEnGA98Ilh2qUHlKEY0sLUPYcxBHjOz2xEGM03rgig7w9nRC1XfGpFT5DvH2lAdRjKKqLt3EPc5QPHord+tUivq3v+l/ldiVIQ+ZFdhiFkb2WQ9HFvq44/sTSPPFT1MiNU1BPJqzrYSNkz3dmYCpm38zCTxGPBGmRc2Z0NNSqZQDRaChmjQmjPnnKHDi2EEysPJqsqmDmUA1y37JHinVa0Fd7Km/BlNcWxZrAiFFjuABugIfkDE5CBwDdLCRVysp24iR7FgLayfbs3KRn8d+X1hE38XQ+eWvPlgmIQASZJ9uGiNZ1zriNuHJnx4WjoeSBRE1h8ErNX1RHT/SR95t2lCHodGtPDAQG21+RRN8KC+GZz726ENeHuJA0vMdFrd4m2NIE51Rbt52N3tvN+Z3CXOIvyRwrCJpYEynJWsr5z6Z4deQLZOmiRIjeiX24zsE644gsMj3pdH1c8n+kVeG72Xut/0G8XLK0TNAtSn4SCDeqvOdFcMJkd2j54vJbdRONf8OZncDjYJWVNJ9tVJKO3KEJtX6rBuL7sXUq1yJ1ATFeXNN0DjQL/CPiAeynRXUjVDrDJNgXsHNtbquWUbG9qD7m+co2eJhR83r1tqVjyvB3M0tP+9xYx6vKp3Pm/tNlG5GMsJIsuxcX6WqTZE4UoHjpOO2kQGX4XFuviH6HbbYulfkx/MbJoBJCzR1Jzg7NSIARkY7yjnugsr6ObVkOToDyrdkK3ocbxLO0Scz7/4CbWIE95PWK04SlQizNz5QD9fhmruw7E2eIrhuG5iDqK9qxstPGEBPBElLrNGXN/uGDW60OmpBqQ4nLv8u5PlkEttUDlXUgpZ2qx7iIBS8yuTZTgfxPEM8h/0Vyjog6eXVg+0TrEAhymUMKxWkw8kudVl1WQrID7mSDoCRVSo1rPg0IOHG1OJ99F3H/gAQzfefi4C2QlIvmxD7wOF24XWEQy1HXFoj+wM/BkhfcQKTcLwUhkTly2CJLL2NDis2zx80hsTExoLcjn9NySD95MdqCdzTreDGHCL20DDOnayNfQwwjZDi6/2Tu4HZSe3IkuM4sIYNPqYY4NHKe63cI72pNbhs3lG16/M6XuHzVqx25Oh5ZYE40xagdy7zyVCKt/6J4ME2ljj2yoMX/B0w6ZtyLJ0DGuTkmSEitPGNEw6Jw7owrlF3T90eyeJVrB7la5BwnQpe/1/7at5nGATaK3o8BLb81a7Iuf2X1GK9s451p4vCJOp/W890oCxjlzojvvbKMITdVrsJS5U3jkPfi0lR52wTRm9XJh8Nk+EHHqJ6F1qllIq+NZzNKq50jkNuUN8srd22jEclsOuwsKRNAZGhnijQY54q7zWNrv4d+mTmK63xIPD5goT0zUn1lPy2lXLHoKmur6ckfs3LnfbrZwbsiU8wv+tfo0dFZa0JnmLWMht4dnTizktyUmuPr5e2v9gEtM9ns= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1872f7c3-1a4d-403e-528d-08d9d12ea280 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:27.5905 (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: vmt7p3cLJxG2VqYsWCcnAuFIm99Ldlcoootn3YgXRlfQ2KcyQ/fzXCp0W3zHpMTLF9nxTUx5haKvFp6R/2fJ5g== 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 Currently, mlxsw_sp_acl_bf_rule_count_index_get() is implemented before mlxsw_sp_acl_bf_index_get() but is used after it. Adding a new function for Spectrum-4 would make them further apart still. Fix by moving them around. Signed-off-by: Amit Cohen Reviewed-by: Petr Machata Signed-off-by: Ido Schimmel --- .../mellanox/mlxsw/spectrum_acl_bloom_filter.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 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 dbd3bebf11ec..732c261f83cf 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_bloom_filter.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_bloom_filter.c @@ -142,14 +142,6 @@ mlxsw_sp_acl_bf_key_encode(struct mlxsw_sp_acl_atcam_region *aregion, *len = chunk_count * MLXSW_BLOOM_KEY_CHUNK_BYTES; } -static unsigned int -mlxsw_sp_acl_bf_rule_count_index_get(struct mlxsw_sp_acl_bf *bf, - unsigned int erp_bank, - unsigned int bf_index) -{ - return erp_bank * bf->bank_size + bf_index; -} - static unsigned int mlxsw_sp_acl_bf_index_get(struct mlxsw_sp_acl_bf *bf, struct mlxsw_sp_acl_atcam_region *aregion, @@ -162,6 +154,14 @@ mlxsw_sp_acl_bf_index_get(struct mlxsw_sp_acl_bf *bf, return mlxsw_sp_acl_bf_crc(bf_key, bf_size); } +static unsigned int +mlxsw_sp_acl_bf_rule_count_index_get(struct mlxsw_sp_acl_bf *bf, + unsigned int erp_bank, + unsigned int bf_index) +{ + return erp_bank * bf->bank_size + bf_index; +} + int mlxsw_sp_acl_bf_entry_add(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_acl_bf *bf, 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/CibT5yoWsDnEsrzUPpupe3JcgH2h999WfqIFoWIVfWqkkvLPUbFb0q5CaUT5nBrQcbeuv3J6NqyTy01Yx2pthFlwlt4BUApQXWe8IIrBGKUoqBvUUZe8nX/CAVHrdBV6U+62pjrVCS/9T2JXxpOTkFWSsEATBq0qucXf/Xktr8RMWfOhiFXXx25ntAWBKTuBEHvZRP2xfc4Wca+EdfXOouG2MFpNHbV4mnlLHboILKck8q1bBbOA8u1A3/kOI56WaSJp1YKiquctW6RW6Q8hB4yyFlHCfwjypLXLCZsJk1bWKWYKZFbCQWJNat0a3+/CgwZ3OpKzy5W8X9f5Fe7drfZB+WhfkX9dAhTA3RkL4pr/H1QZaG1Nmayz20eIlR/p9UUsz2+PNKRKvTkmHMG3+6z2tXj8oT6qFpLATvqkZQky58LikPO9+D2zHL35f4MN6GiKO3TPWrG8mwD67//7CSXPFj/HcmToBnksQpI7hAF13U4XRdDz8hubcEaruC6R6zYN4hgn77L7tWkcjAwdmmutgGM5KyiBkdxDpjo4R5NWX3r4HVJ/7YYY9V9owZMHvpG0Omch7bKowwiIVedJO0SUgoVbyISS4vw7/oTWc+A3amysyvbBFabNGlG0WU6rDkBAGyx7RpDMTaoFhcoVGkYxs6KDJhcM4E1qhy+kB0rmqEAj429QjOk0u+OYSTr0YBRa7AQHPyPIziwLiQfv285ApJ1AT9JlgpogtTLmNfHzjBzZ/gJ38oWlU2Xn6FVLNLqMvREBrQjUIo+pQ9qDV23wRrMLrDAL0wbr6UeIZS8WZrFgrwE3qz2MYUZXi6USzsUevBWuYhhymU77v8zn6cp9s8bZU8t0Us5BCUss2nYBeMRvFo2Qa9xniuaDzaWJq4j0kc2qHl47B956qmNiT71//v9PP42QqQvo6BxZVo2qGSwCv/5pJaMSKyAxLWqjIYPFxobBOOV++R9c7jzTixWtwHHadQZVG4NwDTfTXqJ0xeEcdtcGxkyCHlZJGOavhzyPoIPX+G9nwVr5sz7BKCKtaj5LNSA9SQPBq3zPemL1J+4tBLF5xI2TNy3SmP7NCXDI/fo0hr4T2uDd7V6ZvdQ0iZ41QMn6Q6GeaC0pw6pcqnFzxsHMJNrS9YdarHVMFbNyomI+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 From patchwork Thu Jan 6 16:06:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12705514 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 8BD7CC433FE for ; Thu, 6 Jan 2022 16:07:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240980AbiAFQHm (ORCPT ); Thu, 6 Jan 2022 11:07:42 -0500 Received: from mail-bn8nam11on2044.outbound.protection.outlook.com ([40.107.236.44]:40092 "EHLO NAM11-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S240977AbiAFQHl (ORCPT ); Thu, 6 Jan 2022 11:07:41 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h+sIWTrW4FzRJplnW9YIgp3M95GP5VfTQrODo9r5t0tB5Jn1Py2O44bBEydjgS5MMdhYnQlNbmplmkDZUOArkjq5NaDALNL40vTz4aT4MZgOPgydpkP1bhB0mFW0lJz2pDg1REZZbO6h7FZH6TvwGZtiUjM3wxpzpKTGPqi/z1YD79t1NPjLytYZ2pHx+LnWWeg02gbnrGL6tAFP61+V7lRTAeKCDVtp/c1Y7kXATJ2CN0Lqk6cahzBxPkD0bLZB1yYYe4TfNtGY/F7L7XR4bdGL0/xAc/l/prMK5yGWgy7q4F/IOvik//n6v5UGmFbu7Lsf7PqMe4P1tTuWAYNR3g== 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=CF+rNNUbfO+3nGlpZCgoHWS97LW6WKHzW08HZKB5yCs=; b=Dw4Y+mUKDenu6/0vT49IJJIgbHmPUe0c/ofIdoHgEHtNWOjYnh4VuSoy6ETNiO7xt7/Rkk2zZVwH+2J17eGsUXCchy/SkyGXPo1S0bdn1yb5tichBSrPgIaBvB1Pehnhn/iI6Ov290Ac0mrolCpXLXtJHCse91zHIH6lPtM+otAMdztFN8Q3S8J2cR/RAsEwYdzSBMN3yoTiRS/ALMS4fHD4d/t2lAFRBJSW25weXKxUohIWFoWsSo7xDJLaE/Tf6MkTNyAa2yFg+FP1DQmbHHAbDn4rOh3nfxm/kBfNLtG7ATr0kuNs/tvshBzm7zCjFafopSgIZ0cRQYkPeq3mQw== 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=CF+rNNUbfO+3nGlpZCgoHWS97LW6WKHzW08HZKB5yCs=; b=VAHF85Fl3+qbgCzunV+m2BWS1rRi9rfxzrFFLvid3g2KwwbjDAAVGxhEdoUB6DG1gW/spgWMF6Jb/ALB6bGkp4+GksPL0N+1pNWLa5/pQ3JkMUojWPtkS0QTXUDhFYDYXSSsOyE28ygbRRBosJuRljjM20IwzzG2Ac1T7YUvXfDV0Qz1U5MWq1eEsciToc4A9bEwcaHAVPqQU52UapD5a5zXvTr41u9kK5hbbw/qf4795YrdiwLWszgBEIyCKYgQ+7L++/oKOLTydJSwSU0RU6CgGxwu/e8Ak/9jQjcxcduuv09AeT+O7mE2xEhKX423qMOEKhqzXGL6ip2xWQCm4Q== 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:40 +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:40 +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 5/8] mlxsw: spectrum_acl_bloom_filter: Rename Spectrum-2 specific objects for future use Date: Thu, 6 Jan 2022 18:06:49 +0200 Message-Id: <20220106160652.821176-6-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: MR2P264CA0076.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:32::16) 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: 06e76d9c-a501-4e3d-e8dc-08d9d12ea9f5 X-MS-TrafficTypeDiagnostic: DM6PR12MB4058:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SfWwjN1bTuVJgIJWghyOZF3/inq+eUPyDCUHnJp9Qr7ucG/9LSuXZ1d70CQT11Ye0F4Xukom8fi3wuJ1QHA1s83zb3LCcSXfS15ND7CCgs3kEwKYD1mNuTd35tDzwbRbbttV+9Dh8I5K3IfmBPS/CxA9jttMnW3P4lp/VSNU5YkMoEUWPoyWbByBD8yIf9Hyfj58SXlUrBP9p+isRqYLTpRsmH1a+JNJ6tKpkTeeIIr++efVFA2b5iN8vEPJ7b5DrBzJPz0k5MkjKY2pj+GyT3ICIKylddkQizTRWvTk9SJppgrjwHCS6z+U1pU/uXYAQ6RXu2pTsIDJ0E+rm2aNYsi557OoRsK1knYum0h3+BKTP+war9u9Lpty1XuPrxvXcv0T1MrcNPFZmtB1hQVFk5Lf72gXEjkaD0UZDDYM4uxxH52EZIIdm95VwlDgvvx6SXPe5EU+oj8V3Q0Ea8afQlRlVkNcc3btJvowok+DZ3EEdRvIjsuo8yDIGP7saL4dLmd/2Atpxk2s2SrtDXgXhygeeaCQvGGkQ0m4fPE9RhRplFTPDPenNPv17aImpgHhfSw7R7lxDKP+6sMaKT0ZJdyeW6xBptWuGL+SxciOM5HzO6Z+D2kdU8MVisG+QkqcC53G4uDjlY7D32Aow5Anvg== 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)(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: m+/9BVO3XiKHuwGXLxlvVhg7ZnfDWHy3lVNZQZQNfLvjKDNCrknYIelvHzeIxaogY6bAaXB0zHtLU+C6cBITz9Lrq89AzWSRr5XbXW0NOLfBd3hfgpr9V9JN76OBwJBeEa+UpR2DTOurNPWtWz9xR612/1C/3KtgrARnxwQdchAnSf9t3tOBy56Fruif/IYjzRHWf0qUwKHxwW5gM2JazE4CJE2B6PUjkoZnlP0cTH3kCUjxFBWn1Z9bWPtl8/s4I46lSoOu6y3kdy975bSEbLZLbNFb09knikAex2gkHmMF+/DcGiYdDA46E0jluM+7pfBIbjZUTp/5SKzwPj1Bh8/MMgW+bTS+lgfdcJp3n7+4OXCfWjPWh2cxFRY/G866JsZ9IO1hKU1JNUQu5zi0Q0Vp3q10hQiTbeW9UzwObJPd5sQZ/Wxu8E8k/2LygQXKLDh2YH5gUX0yvwoqds+SQFIq2UAmyBUDT2oWGJ5s4Ew6n+2tnsOFGhUrZkVuDwKiIrlcv1MeRA1XamR5E1r6xtPKATt9jwQiU4AljIWXoehqh1tNoR7ZDwTptb/K3JyPDFENvbWFZ7cVGpoXAae+ITQ/FBgVG84XqilJNNu91i/2NeKXg8KBXDzusvgTPqLl9rO3Nwhgn66ikEhWFoeyWhZRamP3NAkzrerFSt03CtiDKRz154yRQQCjAHC9GbN5RKDE1zc2OSeO7hDZjN1P7J9iHmcGUBeg2fSYYVY5XGbidmJ/C3tnQSqhHXo/I2b0hZDJGgUR+VdoObJldAHjjY9HkS3Xg7v/6qkVCKs3vOsI+tDYidSvdu1PCU2QYDMnoM8tN6+unPODGnGu5NYC7S5j9hYcZXqcDuWOHM9vIw5NT5nI73TOX0PzgJXEwiEDufW5ci2xPdM2SImHQZF3D5qTc1yvxXaPUZZdn7w1neCv0126bL4TXcS5n1nbFRSOXrK0t5em8o62bvy2+WLfuTz+V9DQwMEWq9Xh1JgLU+Srg6yRVEMjp/ZuJmlwCUlWejktfddiAVc3qw5lvH/pe5fcg019w39mowEd9Qi6MIZWu0NME+ycq7Mwkilj+jRgQroGZppVcE6rs0gsKfKEeLT4Cp46+yMLYGH4aSpP5P9OOOlmRA+goplJZuUirB2S2zyvB69OsF/alaDi/BSpIfxNRbt7/tdnC2w+XmTnqHteXPWTdoG5w23DZTSC2ZWmNuIQ6H7nCflIVEBc80cRKqPdAYR7S6/K6FAwKrGGyJ4D4E/xrk3XGmxEWmmSEPSkDpPN8RkbajOHjqZ6EaNip4wl/I5bvcLqmg4cWlduYZ5qnC1HeD9LyDtzwFAeNC4ig9aPoa0Q1daXnzWwYKOsVa3DsXVwBUfnqeChce8kDumYR41v2O8xyXgoEklvi0VaIegX4gvDzKCIhIuoikr7chb8Xd7c3WTYIW/l+W7BTYWfFGaONQi1bo+5Ph7p5QpAMysoES1DMBCgnLm0Ji+Ecmp+1eK3VqZWrvHH0+EAC6iVlZm25+/3FMZkr5TiHoJo8OuQfzWv9RlO6nAdYJ6FSE3veL/qy4V5zVRwr6sE8jExGWiMmzVLEK9uuqL15DyYbZsTCshI6mluK1iTuY3a+gBMtsEzkQEBSXC79V7cFV0= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 06e76d9c-a501-4e3d-e8dc-08d9d12ea9f5 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:40.1989 (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: 0e3WlDpsZ/ZIqERFOlGNHZAo2ZSX7NhFbzQogJZFv4Sj6jXM7OKUC18kKvIF7I04zh9e/k+fvbuQQU3W9p4lyA== 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, rename CRC table to include "sp2" prefix and "crc16", as next patch will add two additional tables. In addition, rename all the dedicated functions and defines for Spectrum-{2,3} to include "sp2" prefix. Signed-off-by: Amit Cohen Reviewed-by: Petr Machata Signed-off-by: Ido Schimmel --- .../mlxsw/spectrum_acl_bloom_filter.c | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 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 f0cd14a791df..3a3c7683b725 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_bloom_filter.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_bloom_filter.c @@ -27,7 +27,7 @@ struct mlxsw_sp_acl_bf { * +-------------------------+------------------------+------------------------+ */ #define MLXSW_BLOOM_KEY_CHUNKS 3 -#define MLXSW_BLOOM_KEY_LEN 69 +#define MLXSW_SP2_BLOOM_KEY_LEN 69 /* Each chunk size is 23 bytes. 18 bytes of it contain 4 key blocks, each is * 36 bits, 2 bytes which hold eRP ID and region ID, and 3 bytes of zero @@ -42,14 +42,14 @@ struct mlxsw_sp_acl_bf { * | 0 | region ID | eRP ID | 4 Key blocks (18 Bytes) | * +---------+-----------+----------+-----------------------------------+ */ -#define MLXSW_BLOOM_CHUNK_PAD_BYTES 3 -#define MLXSW_BLOOM_CHUNK_KEY_BYTES 18 -#define MLXSW_BLOOM_KEY_CHUNK_BYTES 23 +#define MLXSW_SP2_BLOOM_CHUNK_PAD_BYTES 3 +#define MLXSW_SP2_BLOOM_CHUNK_KEY_BYTES 18 +#define MLXSW_SP2_BLOOM_KEY_CHUNK_BYTES 23 /* The offset of the key block within a chunk is 5 bytes as it comes after * 3 bytes of zero padding and 16 bits of region ID and eRP ID. */ -#define MLXSW_BLOOM_CHUNK_KEY_OFFSET 5 +#define MLXSW_SP2_BLOOM_CHUNK_KEY_OFFSET 5 /* Each chunk contains 4 key blocks. Chunk 2 uses key blocks 11-8, * and we need to populate it with 4 key blocks copied from the entry encoded @@ -66,7 +66,7 @@ static const u8 chunk_key_offsets[MLXSW_BLOOM_KEY_CHUNKS] = {2, 20, 38}; * which is 0x8529 (1 + x^3 + x^5 + x^8 + x^10 + x^15 and * the implicit x^16). */ -static const u16 mlxsw_sp_acl_bf_crc_tab[256] = { +static const u16 mlxsw_sp2_acl_bf_crc16_tab[256] = { 0x0000, 0x8529, 0x8f7b, 0x0a52, 0x9bdf, 0x1ef6, 0x14a4, 0x918d, 0xb297, 0x37be, 0x3dec, 0xb8c5, 0x2948, 0xac61, 0xa633, 0x231a, 0xe007, 0x652e, 0x6f7c, 0xea55, 0x7bd8, 0xfef1, 0xf4a3, 0x718a, @@ -101,17 +101,17 @@ static const u16 mlxsw_sp_acl_bf_crc_tab[256] = { 0x0c4c, 0x8965, 0x8337, 0x061e, 0x9793, 0x12ba, 0x18e8, 0x9dc1, }; -static u16 mlxsw_sp_acl_bf_crc_byte(u16 crc, u8 c) +static u16 mlxsw_sp2_acl_bf_crc16_byte(u16 crc, u8 c) { - return (crc << 8) ^ mlxsw_sp_acl_bf_crc_tab[(crc >> 8) ^ c]; + return (crc << 8) ^ mlxsw_sp2_acl_bf_crc16_tab[(crc >> 8) ^ c]; } -static u16 mlxsw_sp_acl_bf_crc(const u8 *buffer, size_t len) +static u16 mlxsw_sp2_acl_bf_crc(const u8 *buffer, size_t len) { u16 crc = 0; while (len--) - crc = mlxsw_sp_acl_bf_crc_byte(crc, *buffer++); + crc = mlxsw_sp2_acl_bf_crc16_byte(crc, *buffer++); return crc; } @@ -144,28 +144,28 @@ __mlxsw_sp_acl_bf_key_encode(struct mlxsw_sp_acl_atcam_region *aregion, } 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_sp2_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); + MLXSW_SP2_BLOOM_CHUNK_PAD_BYTES, + MLXSW_SP2_BLOOM_CHUNK_KEY_OFFSET, + MLXSW_SP2_BLOOM_CHUNK_KEY_BYTES, + MLXSW_SP2_BLOOM_KEY_CHUNK_BYTES); } static unsigned int -mlxsw_sp_acl_bf_index_get(struct mlxsw_sp_acl_bf *bf, - struct mlxsw_sp_acl_atcam_region *aregion, - struct mlxsw_sp_acl_atcam_entry *aentry) +mlxsw_sp2_acl_bf_index_get(struct mlxsw_sp_acl_bf *bf, + struct mlxsw_sp_acl_atcam_region *aregion, + struct mlxsw_sp_acl_atcam_entry *aentry) { - char bf_key[MLXSW_BLOOM_KEY_LEN]; + char bf_key[MLXSW_SP2_BLOOM_KEY_LEN]; u8 bf_size; - mlxsw_sp_acl_bf_key_encode(aregion, aentry, bf_key, &bf_size); - return mlxsw_sp_acl_bf_crc(bf_key, bf_size); + mlxsw_sp2_acl_bf_key_encode(aregion, aentry, bf_key, &bf_size); + return mlxsw_sp2_acl_bf_crc(bf_key, bf_size); } static unsigned int @@ -190,7 +190,7 @@ mlxsw_sp_acl_bf_entry_add(struct mlxsw_sp *mlxsw_sp, mutex_lock(&bf->lock); - bf_index = mlxsw_sp_acl_bf_index_get(bf, aregion, aentry); + bf_index = mlxsw_sp2_acl_bf_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_sp_acl_bf_index_get(bf, aregion, aentry); + bf_index = mlxsw_sp2_acl_bf_index_get(bf, aregion, aentry); rule_index = mlxsw_sp_acl_bf_rule_count_index_get(bf, erp_bank, bf_index); 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/acYCd26JQYlkE5FdWCeuvE6ja5U4o97KY/xnuOEr6haErTirFjwPQUvNVjXB/i0wouFDoRsru26xjRM3a81FV5Ectw175OtvXPgAARavzuJN4niyYk6GGBP+891uvdRZiKUHwSJSCF6p7KGe7A8+E7O9r6hb26VAqaMB0C868u8VxS2BYJauxjZww+KQ6y8Bg3XdYiPOdJhzFNt/jbLG95cXHsiU/Lls2v1oOmR69FazEr7ayppTf5yntiS4n50bNcC7z95HimcrWL+X7OLFP6fA2rQ6Kg8oa1D1Xa9DnNi/A20fl5ZxPasA/JyLWMD9hltrp6jOlzxw23iJUyqsvdfdAeEKqRwMGO422ify/QdX3AICrxMBFTLhBLlf5JicaTsddr09jhDGpLsz4Mc20cJXXZFvXf5W8kPxdLElHYte7fyjWGxG0sNkLTQ3fbSPt2BAwUcDcLJGwlcu1wPo3TlFhIko+IXvGeuFyOiP9Lr4KhkQp9fRwapIUvurx+OEzr8QtiJ2kM9BnTkBlnsuGPgKH+pgaKbt4SO1WK639aRDCizKEb05QaTwkzAUjdczMtc/cDavd0lUFfVSZhSk1iQDZJKhm/XIQIljwXyi5xAIFn0NLR+kGfv2Snmjyvz7v8nNp0LIpfyG4z552z8Ob1ZEwih62mOjEIYvjINULtjj5CF1p6S0lSnUmIm/PUMIKA5oUqD+lxn//ZrY99LUWZXQR0aNcz5Gmscyz7Uw4m+x4XVtH+VwulbRBkYuv+djge8Y/QQTdrePGqV6HSfbqslJzyxSk/YDv5VR/Q8e+nbOIIghaoq80L2QNuL1Lzam2tW0j2S5nr2obE42Lbf8FuJ/s7nDvMNJN0Qec2cs0Uw6MCXR84256X0Q1Oc79Z+dnPe6jL+Md65IkWs9BeC5Hw7He9VktlMPZDE838RyaOsRtiFoNcmVOuOGU8uEVJufc2nDxmR7uGDPXx4hQ8hEovGw0MoflXRZNt7ZJoadc6i5YjE7kD0El1CFuEyw54eRJ7jRD6xunsXchBrFAaLH3S3dgfcVfpMQgZEJprUcu5mk4310eVQCcVZoM8avg/4J/9ccweTB+8mpRIB3b1uLbaw0rxTyINJ9uS8xMAadGgM0mSLXOGzgDySDMclQCsdjfKvVpEo4GlU7r1DiCOt+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, From patchwork Thu Jan 6 16:06:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12705516 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 0F545C433F5 for ; Thu, 6 Jan 2022 16:07:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240977AbiAFQH4 (ORCPT ); Thu, 6 Jan 2022 11:07:56 -0500 Received: from mail-bn8nam11on2044.outbound.protection.outlook.com ([40.107.236.44]:38124 "EHLO NAM11-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S240998AbiAFQHz (ORCPT ); Thu, 6 Jan 2022 11:07:55 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RwY3aB2jp3HX6pj667/SqPpUXM9qTLNfdLNzZJjgf4fe8HHFcaUlgG10i26IBb4042rxasAOPGPXTiapnKbmHoVnUzuvPUenVMKTemSVQVkTvrB7jH93v8ffqUzcYTJngU4YaJ6YUr0mttTt1qhFW28OBDnp5t0beMmvGkTisz1wHNhjdJXOn427rduNZxaPk25SkratKyUvdy7JI4RmFfCt1kfR1SbMda1ZVEnkW0LAyYpN15ak45199cy4F/kWGZ7D0sYZBLMqehZEEwUzGvXpeDB1fOuyjjvUXp3t7t373cNmS/OvBwr63B10bYsSD/tZJztz0tQZ/vNbNO18nA== 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=+QYjBjKBXpMWl+arQPoimfSzKNJ9SSVOHPouO7XqUpg=; b=V/nxhdCCOSaNSZImGXHjAYuGovShmfuaop6JuDrohpMufkSD/yzcI1WArDdJ/XJYK0JIJcVI1sD5HLTyShjdig0Wl5ByLkkovbz6G930SHMOnoNS/zlOajf/Z8UL7BSc7i/loDyqVHXyJUgsI4RKC8ZoTlNqrBUpb9oL4Ad6S23H5xrVrChMiIhW8tPQWHra3hBExrCCXPIAY8a1+yDQid0JH4mC4S8UBFy9kJ6yl5QI+7uxQFHs/Kx1SC8lJOfS9aO7UH5bpSgTshplGqOh0dwbK8fBkJP5/c9mTyLdhEYM/PSTolUSiUlyaR0ujBoZVoZW5Y/JgmXrh5MmzrrJRg== 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=+QYjBjKBXpMWl+arQPoimfSzKNJ9SSVOHPouO7XqUpg=; b=BBPHg+U1D0doig1kSYS0bhnHT9sz/XNpxlRzmvabLuBb33G5M+IIDL9mEa9XHSTIpKmRRlGCWGUjZJs6vW/dL9tfax8XnNEw9iwDXR4EEGLpxpYwctns+IIO/ID5GAjrLd2daKxXKqJbqqG+snUZsKn+zCBVNgHenAU2wWzu7mzqwc9zI4gk+hC1W3JRgyvIyThgnq19xWPvHhmbr91ctgxC9GFAD0BreAdchmEzak7GTfjmSXPcLGRdqM2gGgMFaeZxOtbio3zumXyEgb9Xek3fCmyp92axP8QK+bt6SUwSUc1KD+PT5+X4TSYVyoCJEhF8wgI4kU4Or0xVyM7eCw== 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:53 +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:53 +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 7/8] mlxsw: spectrum_acl_bloom_filter: Add support for Spectrum-4 calculation Date: Thu, 6 Jan 2022 18:06:51 +0200 Message-Id: <20220106160652.821176-8-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: MR2P264CA0097.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:33::13) 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: bededd2b-c7c0-435c-16d2-08d9d12eb1c6 X-MS-TrafficTypeDiagnostic: DM6PR12MB4058:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cKqSF4uylkW2CHoC2I6Yy04qrRDSiFQAyQpvjGZ40g6snwVOcdjU4YhcYUVcIT2LmdWX5Uh7ynMml2xE4JYDsJuaaHRUVAfztOLFNktH2LedJC6YcvV7GkImSf+Y/tJZUPV/tzGEdZQseoHIUY2OypMyj8GLHejQyr3QnbFZUyjX1crmWXxLac4cjl8/gsitTTjck/zyUGider9mm6wyk8g8aRYQ16JXaXgW76wUJ3vcv8DLdPgbrNjwdLYttvO/A57Nnbs1uxCBu8fr35L2C+q2miaF49Abfxln/qmPGaAuODHjSxAcm/R0RbcRkjnCiOGLhbjFBvcLUwFz9Slyx7KIoucD3gCoXxNYic5tXmMVC+RY278RStqBacKgxq7Fnktud9IsMnWlDd4A8kfECIag+AadK6dGkfGchkeO/mQwMIaLMKDEE8My/aQr+15kcs25YcNYUmDwIO7wcAS+G2ibKoycw7t9CLVKJL6gYZe5JCeZzWuBZxZBQ+czlBMnIyQ2dkMnM/y9GEgEG+fN34gxmZ39e3Uq5PazTX50xs68NurA3vXfE0JqA8JyoRsUlOt47O0q5xVRxNwRftsNismM43CNlywKv1KXIyZnnUW2tvB2y6QBZRzf4YAwjuuYLWZhLo4/KOos/Xj8AdnjDA== 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)(508600001)(66946007)(66476007)(5660300002)(36756003)(66556008)(6916009)(316002)(86362001)(4326008)(26005)(38100700002)(8676002)(2616005)(83380400001)(6512007)(6486002)(2906002)(1076003)(107886003)(30864003)(8936002)(6506007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: HGRgkDDaxGVnpwT0PjqeVhgTVCrskIoqCZFX04nUaHU/f8zSeJeKPP3u2YqUuNjvYXbyF7VJf1oQ7uerrqMBNW91AgktGjnAMGNXBhKafXu6cyU0YYFNNWd6p90zDhSbUDXZ9ufsW6EXEMElN5zMvS6YBEseBvV3EkbmhQPC6//l++gmMl5wOSbADGEInWKX+LWi102FzHA1SgFy50/WehL0FFoPQz2JWxNp+idGOn+1Y9GcmMil76UqxkpWFb8i2DuHg471c/4XEh7vY3ks+JfB6nHSo0GMdQ3uiTwh1IGRep8WhDNMNwiGi+DNXD87j7jeZ0wiMZ8LySfga3sWVXKfFj2BetLzRkQ47yYdad4Mj7Zabg3Bp70vbTaXmjELkGtNrV8514+1ExKjCq2Z4PfjcP2Kn3DAic5pe42/zKaOY99kM2UvdcrEcXC1flsC3mI9m4k02/1qlIMLoq03LvgSgAYepKaX6JCZmRCbIchJJ7tKy8cz1P2dY7RZFe9x1uDN2hq+Ik5bBL9f6pp4orCYSHVHaYu+rl0ews93jRWBAF+P7fP28HROZiz9kjO7++huva71BEuHdoQj8dL4Q8wEYPsYWX/3D2itNM1fsGaGO6rsgS0Lc2RJsSn0J+CNLmW7PhqpV7CeQYLcpH4jB+n7FsFL2V3ct6Eh6EkFWJJXXNv5f/fNRFzh2az49IaCgcbcjhKOkJr+Wzq9lseYHHRJ7VJWjYGs/bXUEEwkVh/azjIJghTw1VIeC4pdObAm8RNY23hJDAuuv9DfWxEbqxN+D/KUGT0L2NXBs0TIlurWsyi/hXgs5oKyMOXs1rmZ8FszaSDG1EaHHjdZh75eLMzcDe5SGkCE7JW0Z8ffZci7vNYNRBmnoSTpZhppVXcNCK+PktjpAOdZaBQRpnmvFYzCXtnIUBMZSyy0Zitf2qoKrR0I98EydsVa2iukYgVgx2medolo37Qcgb6AP7c5K53GtAMcTOfc8CCFK0MYp6tpXlD5DFsVBPFe3oMmmAXFWfyFc+tb46NWDsr+04RUdAR4wppXJhj88JUuYrLDotoOpzxiBh4PLOvzPXvICIFAQkPLQ4xkgPieZGrYqhFb+az/dhHo8EPx+zpKWdBp3pkU72t4NcF07dfwl7MyWVIuDm5Zmzc41sTtj3K9fZozS9pvfXfO04OrVOeOZcaOFp6aYXtuO6tBEcQKa91DpPCPPF3xKNKx9RkdtU0cTvmtPpr15jj8iLXB00hDQ38ZXC/UbGMaVmcpUECjsvXIqhpm8uv0S4iWQqrPmfjg7QXhY8Z5nNait+qOFA5D6zyglQq+MBUywZZl3fN2EnFUYDqoxVrGxHTEBWYwSGEqGxhiuwWKM4RPuRv1dQIs0YpxsMtvqxf5GYcg3CE5pbjYz8i0D49ilbvJsCqFkl81UA4jNtBuDP3fCLwOPzz6Gmd9/XxKtLh9WJ65cMKm3pf+9+sK60cKTLlpvWy44rELEJueIcJ0mSopz2WwYyzt52U/tJbl38z6i9/Kq/1IaTijgmkFKx/bkGWGM407ihj4V9n3NxfVVhx65Jk4sQa65zmHWE/8pKCPMouqoZJvHY0kEsKmFPoKsp5o9IF3Yn5WtQlxOrz6nhHgkJNS+Y5JVpzXTM0= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: bededd2b-c7c0-435c-16d2-08d9d12eb1c6 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:53.2916 (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: QQz7tyzFj/JNVOQyfvIUzLwjf/bO2iLHSIDNKk5fwfayxw1n3WqBnDN2HgRzJojoO+j5rIATVNzefbtXMdl1Bw== 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. First, two hash functions will be used to calculate 16 bits result. The final result will be combination of the two results - 6 bits which are result of CRC-6 will be used as MSB and 10 bits which are result of CRC-10 will be used as LSB. Second, while in Spectrum{2,3}, there is a padding in each chunk, so the chunks use a sequence of whole bytes, in Spectrum-4 there is no padding, so each chunk use 20 bytes minus 2 bits, so it is necessary to align the chunks to be without holes. Add dedicated 'mlxsw_sp_acl_bf_ops' for Spectrum-4 and add the required tables for CRC calculations. All the details are documented as part of the code for future use. Signed-off-by: Amit Cohen Reviewed-by: Petr Machata Signed-off-by: Ido Schimmel --- .../net/ethernet/mellanox/mlxsw/spectrum.h | 1 + .../mlxsw/spectrum_acl_bloom_filter.c | 267 ++++++++++++++++-- 2 files changed, 252 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h index e7da6c83c442..bb2442e1f705 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h @@ -1111,6 +1111,7 @@ 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; +extern const struct mlxsw_sp_acl_bf_ops mlxsw_sp4_acl_bf_ops; /* spectrum_matchall.c */ struct mlxsw_sp_mall_ops { 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 c6dab9615a0a..e2aced7ab454 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_bloom_filter.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_bloom_filter.c @@ -17,9 +17,9 @@ struct mlxsw_sp_acl_bf { }; /* Bloom filter uses a crc-16 hash over chunks of data which contain 4 key - * blocks, eRP ID and region ID. In Spectrum-2, region key is combined of up to - * 12 key blocks, so there can be up to 3 chunks in the Bloom filter key, - * depending on the actual number of key blocks used in the region. + * blocks, eRP ID and region ID. In Spectrum-2 and above, region key is combined + * of up to 12 key blocks, so there can be up to 3 chunks in the Bloom filter + * key, depending on the actual number of key blocks used in the region. * The layout of the Bloom filter key is as follows: * * +-------------------------+------------------------+------------------------+ @@ -27,6 +27,8 @@ struct mlxsw_sp_acl_bf { * +-------------------------+------------------------+------------------------+ */ #define MLXSW_BLOOM_KEY_CHUNKS 3 + +/* Spectrum-2 and Spectrum-3 chunks */ #define MLXSW_SP2_BLOOM_KEY_LEN 69 /* Each chunk size is 23 bytes. 18 bytes of it contain 4 key blocks, each is @@ -51,19 +53,9 @@ struct mlxsw_sp_acl_bf { */ #define MLXSW_SP2_BLOOM_CHUNK_KEY_OFFSET 5 -/* Each chunk contains 4 key blocks. Chunk 2 uses key blocks 11-8, - * and we need to populate it with 4 key blocks copied from the entry encoded - * key. Since the encoded key contains a padding, key block 11 starts at offset - * 2. block 7 that is used in chunk 1 starts at offset 20 as 4 key blocks take - * 18 bytes. - * This array defines key offsets for easy access when copying key blocks from - * entry key to Bloom filter chunk. - */ -static const u8 chunk_key_offsets[MLXSW_BLOOM_KEY_CHUNKS] = {2, 20, 38}; - -/* This table is just the CRC of each possible byte. It is - * computed, Msbit first, for the Bloom filter polynomial - * which is 0x8529 (1 + x^3 + x^5 + x^8 + x^10 + x^15 and +/* This table is just the CRC of each possible byte which is used for + * Spectrum-{2-3}. It is computed, Msbit first, for the Bloom filter + * polynomial which is 0x8529 (1 + x^3 + x^5 + x^8 + x^10 + x^15 and * the implicit x^16). */ static const u16 mlxsw_sp2_acl_bf_crc16_tab[256] = { @@ -101,6 +93,127 @@ static const u16 mlxsw_sp2_acl_bf_crc16_tab[256] = { 0x0c4c, 0x8965, 0x8337, 0x061e, 0x9793, 0x12ba, 0x18e8, 0x9dc1, }; +/* Spectrum-4 chunks */ +#define MLXSW_SP4_BLOOM_KEY_LEN 60 + +/* In Spectrum-4, there is no padding. Each chunk size is 20 bytes. + * 18 bytes of it contain 4 key blocks, each is 36 bits, and 2 bytes which hold + * eRP ID and region ID. + * The layout of each chunk is as follows: + * + * +----------------------+-----------------------------------+ + * | 2 bytes | 18 bytes | + * +-----------+----------+-----------------------------------+ + * | 157:148 | 147:144 | 143:0 | + * +---------+-----------+----------+-------------------------+ + * | region ID | eRP ID | 4 Key blocks (18 Bytes) | + * +-----------+----------+-----------------------------------+ + */ + +#define MLXSW_SP4_BLOOM_CHUNK_PAD_BYTES 0 +#define MLXSW_SP4_BLOOM_CHUNK_KEY_BYTES 18 +#define MLXSW_SP4_BLOOM_KEY_CHUNK_BYTES 20 + +/* The offset of the key block within a chunk is 2 bytes as it comes after + * 16 bits of region ID and eRP ID. + */ +#define MLXSW_SP4_BLOOM_CHUNK_KEY_OFFSET 2 + +/* For Spectrum-4, two hash functions are used, CRC-10 and CRC-6 based. + * The result is combination of the two calculations - + * 6 bit column are MSB (result of CRC-6), + * 10 bit row are LSB (result of CRC-10). + */ + +/* This table is just the CRC of each possible byte which is used for + * Spectrum-4. It is computed, Msbit first, for the Bloom filter + * polynomial which is 0x1b (1 + x^1 + x^3 + x^4 and the implicit x^10). + */ +static const u16 mlxsw_sp4_acl_bf_crc10_tab[256] = { +0x0000, 0x001b, 0x0036, 0x002d, 0x006c, 0x0077, 0x005a, 0x0041, +0x00d8, 0x00c3, 0x00ee, 0x00f5, 0x00b4, 0x00af, 0x0082, 0x0099, +0x01b0, 0x01ab, 0x0186, 0x019d, 0x01dc, 0x01c7, 0x01ea, 0x01f1, +0x0168, 0x0173, 0x015e, 0x0145, 0x0104, 0x011f, 0x0132, 0x0129, +0x0360, 0x037b, 0x0356, 0x034d, 0x030c, 0x0317, 0x033a, 0x0321, +0x03b8, 0x03a3, 0x038e, 0x0395, 0x03d4, 0x03cf, 0x03e2, 0x03f9, +0x02d0, 0x02cb, 0x02e6, 0x02fd, 0x02bc, 0x02a7, 0x028a, 0x0291, +0x0208, 0x0213, 0x023e, 0x0225, 0x0264, 0x027f, 0x0252, 0x0249, +0x02db, 0x02c0, 0x02ed, 0x02f6, 0x02b7, 0x02ac, 0x0281, 0x029a, +0x0203, 0x0218, 0x0235, 0x022e, 0x026f, 0x0274, 0x0259, 0x0242, +0x036b, 0x0370, 0x035d, 0x0346, 0x0307, 0x031c, 0x0331, 0x032a, +0x03b3, 0x03a8, 0x0385, 0x039e, 0x03df, 0x03c4, 0x03e9, 0x03f2, +0x01bb, 0x01a0, 0x018d, 0x0196, 0x01d7, 0x01cc, 0x01e1, 0x01fa, +0x0163, 0x0178, 0x0155, 0x014e, 0x010f, 0x0114, 0x0139, 0x0122, +0x000b, 0x0010, 0x003d, 0x0026, 0x0067, 0x007c, 0x0051, 0x004a, +0x00d3, 0x00c8, 0x00e5, 0x00fe, 0x00bf, 0x00a4, 0x0089, 0x0092, +0x01ad, 0x01b6, 0x019b, 0x0180, 0x01c1, 0x01da, 0x01f7, 0x01ec, +0x0175, 0x016e, 0x0143, 0x0158, 0x0119, 0x0102, 0x012f, 0x0134, +0x001d, 0x0006, 0x002b, 0x0030, 0x0071, 0x006a, 0x0047, 0x005c, +0x00c5, 0x00de, 0x00f3, 0x00e8, 0x00a9, 0x00b2, 0x009f, 0x0084, +0x02cd, 0x02d6, 0x02fb, 0x02e0, 0x02a1, 0x02ba, 0x0297, 0x028c, +0x0215, 0x020e, 0x0223, 0x0238, 0x0279, 0x0262, 0x024f, 0x0254, +0x037d, 0x0366, 0x034b, 0x0350, 0x0311, 0x030a, 0x0327, 0x033c, +0x03a5, 0x03be, 0x0393, 0x0388, 0x03c9, 0x03d2, 0x03ff, 0x03e4, +0x0376, 0x036d, 0x0340, 0x035b, 0x031a, 0x0301, 0x032c, 0x0337, +0x03ae, 0x03b5, 0x0398, 0x0383, 0x03c2, 0x03d9, 0x03f4, 0x03ef, +0x02c6, 0x02dd, 0x02f0, 0x02eb, 0x02aa, 0x02b1, 0x029c, 0x0287, +0x021e, 0x0205, 0x0228, 0x0233, 0x0272, 0x0269, 0x0244, 0x025f, +0x0016, 0x000d, 0x0020, 0x003b, 0x007a, 0x0061, 0x004c, 0x0057, +0x00ce, 0x00d5, 0x00f8, 0x00e3, 0x00a2, 0x00b9, 0x0094, 0x008f, +0x01a6, 0x01bd, 0x0190, 0x018b, 0x01ca, 0x01d1, 0x01fc, 0x01e7, +0x017e, 0x0165, 0x0148, 0x0153, 0x0112, 0x0109, 0x0124, 0x013f, +}; + +/* This table is just the CRC of each possible byte which is used for + * Spectrum-4. It is computed, Msbit first, for the Bloom filter + * polynomial which is 0x2d (1 + x^2+ x^3 + x^5 and the implicit x^6). + */ +static const u8 mlxsw_sp4_acl_bf_crc6_tab[256] = { +0x00, 0x2d, 0x37, 0x1a, 0x03, 0x2e, 0x34, 0x19, +0x06, 0x2b, 0x31, 0x1c, 0x05, 0x28, 0x32, 0x1f, +0x0c, 0x21, 0x3b, 0x16, 0x0f, 0x22, 0x38, 0x15, +0x0a, 0x27, 0x3d, 0x10, 0x09, 0x24, 0x3e, 0x13, +0x18, 0x35, 0x2f, 0x02, 0x1b, 0x36, 0x2c, 0x01, +0x1e, 0x33, 0x29, 0x04, 0x1d, 0x30, 0x2a, 0x07, +0x14, 0x39, 0x23, 0x0e, 0x17, 0x3a, 0x20, 0x0d, +0x12, 0x3f, 0x25, 0x08, 0x11, 0x3c, 0x26, 0x0b, +0x30, 0x1d, 0x07, 0x2a, 0x33, 0x1e, 0x04, 0x29, +0x36, 0x1b, 0x01, 0x2c, 0x35, 0x18, 0x02, 0x2f, +0x3c, 0x11, 0x0b, 0x26, 0x3f, 0x12, 0x08, 0x25, +0x3a, 0x17, 0x0d, 0x20, 0x39, 0x14, 0x0e, 0x23, +0x28, 0x05, 0x1f, 0x32, 0x2b, 0x06, 0x1c, 0x31, +0x2e, 0x03, 0x19, 0x34, 0x2d, 0x00, 0x1a, 0x37, +0x24, 0x09, 0x13, 0x3e, 0x27, 0x0a, 0x10, 0x3d, +0x22, 0x0f, 0x15, 0x38, 0x21, 0x0c, 0x16, 0x3b, +0x0d, 0x20, 0x3a, 0x17, 0x0e, 0x23, 0x39, 0x14, +0x0b, 0x26, 0x3c, 0x11, 0x08, 0x25, 0x3f, 0x12, +0x01, 0x2c, 0x36, 0x1b, 0x02, 0x2f, 0x35, 0x18, +0x07, 0x2a, 0x30, 0x1d, 0x04, 0x29, 0x33, 0x1e, +0x15, 0x38, 0x22, 0x0f, 0x16, 0x3b, 0x21, 0x0c, +0x13, 0x3e, 0x24, 0x09, 0x10, 0x3d, 0x27, 0x0a, +0x19, 0x34, 0x2e, 0x03, 0x1a, 0x37, 0x2d, 0x00, +0x1f, 0x32, 0x28, 0x05, 0x1c, 0x31, 0x2b, 0x06, +0x3d, 0x10, 0x0a, 0x27, 0x3e, 0x13, 0x09, 0x24, +0x3b, 0x16, 0x0c, 0x21, 0x38, 0x15, 0x0f, 0x22, +0x31, 0x1c, 0x06, 0x2b, 0x32, 0x1f, 0x05, 0x28, +0x37, 0x1a, 0x00, 0x2d, 0x34, 0x19, 0x03, 0x2e, +0x25, 0x08, 0x12, 0x3f, 0x26, 0x0b, 0x11, 0x3c, +0x23, 0x0e, 0x14, 0x39, 0x20, 0x0d, 0x17, 0x3a, +0x29, 0x04, 0x1e, 0x33, 0x2a, 0x07, 0x1d, 0x30, +0x2f, 0x02, 0x18, 0x35, 0x2c, 0x01, 0x1b, 0x36, +}; + +/* Each chunk contains 4 key blocks. Chunk 2 uses key blocks 11-8, + * and we need to populate it with 4 key blocks copied from the entry encoded + * key. The original keys layout is same for Spectrum-{2,3,4}. + * Since the encoded key contains a 2 bytes padding, key block 11 starts at + * offset 2. block 7 that is used in chunk 1 starts at offset 20 as 4 key blocks + * take 18 bytes. See 'MLXSW_SP2_AFK_BLOCK_LAYOUT' for more details. + * This array defines key offsets for easy access when copying key blocks from + * entry key to Bloom filter chunk. + */ +static const u8 chunk_key_offsets[MLXSW_BLOOM_KEY_CHUNKS] = {2, 20, 38}; + static u16 mlxsw_sp2_acl_bf_crc16_byte(u16 crc, u8 c) { return (crc << 8) ^ mlxsw_sp2_acl_bf_crc16_tab[(crc >> 8) ^ c]; @@ -168,6 +281,124 @@ mlxsw_sp2_acl_bf_index_get(struct mlxsw_sp_acl_bf *bf, return mlxsw_sp2_acl_bf_crc(bf_key, bf_size); } +static u16 mlxsw_sp4_acl_bf_crc10_byte(u16 crc, u8 c) +{ + u8 index = ((crc >> 2) ^ c) & 0xff; + + return ((crc << 8) ^ mlxsw_sp4_acl_bf_crc10_tab[index]) & 0x3ff; +} + +static u16 mlxsw_sp4_acl_bf_crc6_byte(u16 crc, u8 c) +{ + u8 index = (crc ^ c) & 0xff; + + return ((crc << 6) ^ (mlxsw_sp4_acl_bf_crc6_tab[index] << 2)) & 0xfc; +} + +static u16 mlxsw_sp4_acl_bf_crc(const u8 *buffer, size_t len) +{ + u16 crc_row = 0, crc_col = 0; + + while (len--) { + crc_row = mlxsw_sp4_acl_bf_crc10_byte(crc_row, *buffer); + crc_col = mlxsw_sp4_acl_bf_crc6_byte(crc_col, *buffer); + buffer++; + } + + crc_col >>= 2; + + /* 6 bit column are MSB, 10 bit row are LSB */ + return (crc_col << 10) | crc_row; +} + +static void right_shift_array(char *arr, u8 len, u8 shift_bits) +{ + u8 byte_mask = 0xff >> shift_bits; + int i; + + if (WARN_ON(!shift_bits || shift_bits >= 8)) + return; + + for (i = len - 1; i >= 0; i--) { + /* The first iteration looks like out-of-bounds access, + * but actually references a buffer that the array is shifted + * into. This move is legal as we never send the last chunk to + * this function. + */ + arr[i + 1] &= byte_mask; + arr[i + 1] |= arr[i] << (8 - shift_bits); + arr[i] = arr[i] >> shift_bits; + } +} + +static void mlxsw_sp4_bf_key_shift_chunks(u8 chunk_count, char *output) +{ + /* The chunks are suppoosed to be continuous, with no padding. + * Since region ID and eRP ID use 14 bits, and not fully 2 bytes, + * and in Spectrum-4 there is no padding, it is necessary to shift some + * chunks 2 bits right. + */ + switch (chunk_count) { + case 2: + /* The chunks are copied as follow: + * +-------------+-----------------+ + * | Chunk 0 | Chunk 1 | + * | IDs | keys |(**) IDs | keys | + * +-------------+-----------------+ + * In (**), there are two unused bits, therefore, chunk 0 needs + * to be shifted two bits right. + */ + right_shift_array(output, MLXSW_SP4_BLOOM_KEY_CHUNK_BYTES, 2); + break; + case 3: + /* The chunks are copied as follow: + * +-------------+-----------------+-----------------+ + * | Chunk 0 | Chunk 1 | Chunk 2 | + * | IDs | keys |(**) IDs | keys |(**) IDs | keys | + * +-------------+-----------------+-----------------+ + * In (**), there are two unused bits, therefore, chunk 1 needs + * to be shifted two bits right and chunk 0 needs to be shifted + * four bits right. + */ + right_shift_array(output + MLXSW_SP4_BLOOM_KEY_CHUNK_BYTES, + MLXSW_SP4_BLOOM_KEY_CHUNK_BYTES, 2); + right_shift_array(output, MLXSW_SP4_BLOOM_KEY_CHUNK_BYTES, 4); + break; + default: + WARN_ON(chunk_count > MLXSW_BLOOM_KEY_CHUNKS); + } +} + +static void +mlxsw_sp4_acl_bf_key_encode(struct mlxsw_sp_acl_atcam_region *aregion, + struct mlxsw_sp_acl_atcam_entry *aentry, + char *output, u8 *len) +{ + struct mlxsw_afk_key_info *key_info = aregion->region->key_info; + u8 block_count = mlxsw_afk_key_info_blocks_count_get(key_info); + u8 chunk_count = 1 + ((block_count - 1) >> 2); + + __mlxsw_sp_acl_bf_key_encode(aregion, aentry, output, len, + MLXSW_BLOOM_KEY_CHUNKS, + MLXSW_SP4_BLOOM_CHUNK_PAD_BYTES, + MLXSW_SP4_BLOOM_CHUNK_KEY_OFFSET, + MLXSW_SP4_BLOOM_CHUNK_KEY_BYTES, + MLXSW_SP4_BLOOM_KEY_CHUNK_BYTES); + mlxsw_sp4_bf_key_shift_chunks(chunk_count, output); +} + +static unsigned int +mlxsw_sp4_acl_bf_index_get(struct mlxsw_sp_acl_bf *bf, + struct mlxsw_sp_acl_atcam_region *aregion, + struct mlxsw_sp_acl_atcam_entry *aentry) +{ + char bf_key[MLXSW_SP4_BLOOM_KEY_LEN] = {}; + u8 bf_size; + + mlxsw_sp4_acl_bf_key_encode(aregion, aentry, bf_key, &bf_size); + return mlxsw_sp4_acl_bf_crc(bf_key, bf_size); +} + static unsigned int mlxsw_sp_acl_bf_rule_count_index_get(struct mlxsw_sp_acl_bf *bf, unsigned int erp_bank, @@ -285,3 +516,7 @@ void mlxsw_sp_acl_bf_fini(struct mlxsw_sp_acl_bf *bf) const struct mlxsw_sp_acl_bf_ops mlxsw_sp2_acl_bf_ops = { .index_get = mlxsw_sp2_acl_bf_index_get, }; + +const struct mlxsw_sp_acl_bf_ops mlxsw_sp4_acl_bf_ops = { + .index_get = mlxsw_sp4_acl_bf_index_get, +}; From patchwork Thu Jan 6 16:06:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12705517 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 19983C433EF for ; Thu, 6 Jan 2022 16:08:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241000AbiAFQIC (ORCPT ); Thu, 6 Jan 2022 11:08:02 -0500 Received: from mail-bn8nam11on2075.outbound.protection.outlook.com ([40.107.236.75]:24607 "EHLO NAM11-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S240990AbiAFQIB (ORCPT ); Thu, 6 Jan 2022 11:08:01 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HTPUKG6O8sQHQhqzB5TKLCPMmqNCTGqZINfcD/d8lpwKpUh2XiLISWouuxl0dXsNbji2DRH/6wrJm7thMMt5WtpSEi5MaVNDSbn9Zqpq5ZHUN8FLxmo+OQsFx+YZXq8PEbQmzyroDRKRvoPCL+vAxXzj2yhfA16ez7yr6Pah1zErqgeAwqrsQahnK65pj3HIdGz9bNdXELk1kTW36l/x45bO+MpZmO2WQZEDz6MCTjg1w3Qg4gZRxMkmHY3qTxb7BK4bN+MszCIY9sl25XZE38HcTObLTy6B3xhPtn7gcna9Avd4l7eRvzYaiANdSljrBJ9qIibnPbtQDjT3px9FIA== 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=4xTZWZp0gEhnons8tdSm8elF8yhVaWYK7athGArN8Lw=; b=iOi6a7ux45Ck+eUv3b5G9b4HO3wX++9/0CqOue0QdjanoNfPiu5ftzofd4VwZbOYPiS/d7m9DD8+A6xl0mJUFjrPZsqBcx4Y2B250LkuBZbt7N/HiKQxpUNy/Ndzf2sRJ6LBnPeQe9NPWQW2aFlSoFMLeSwB30GbigE7dX9QJuwhbtXkQ+2XF0lEnjdsLbdXaKSqej+LMGL+L12swr6KsvQxFnhisHUKvNKYd1g1EZ+4KqDLFEolf0i49xHoiF12y3awk9YIGc4KSW2Dgfe3+opTllyd33tL0wQEYUSqDAUrNzpfCe4LuewTLEzPfyuKQ7CCZpJRepnXQGAOGYMgnw== 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=4xTZWZp0gEhnons8tdSm8elF8yhVaWYK7athGArN8Lw=; b=JXtMjMzz/wfqqJ7LYC3G9M4eIbDuzZL+RhpLio7SlSMhFb9CFmrSgkihH+kqG3+3NHG2R4hpbLaxLiXfMHWyX2TIRkBIvmOoB1YLqiLC2cLPSyF8Vxlt1h6zSJiG+Fdb+KzijkEQIqC5dreXq0pRAQmaxgiDyL4J9Mt61w8CsJt+tNmrVAnzT8f5Cv5b5qdn8/FIMzls50HrKEGvbu1v2DQUK9mm3uKTVkBbj4w5DaQ0DMKtjPzbdRlN+nBvv+1BO5/Y77v6hYzaoVfL8MzaS5WW3VZc6rN6V/U84Pkss59QTrgvx4Cv8zQiAcpjK2dbDLSRoxGziNVdCXKS4meDHQ== 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:59 +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:59 +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 8/8] mlxsw: spectrum: Extend to support Spectrum-4 ASIC Date: Thu, 6 Jan 2022 18:06:52 +0200 Message-Id: <20220106160652.821176-9-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: MR1P264CA0058.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:3e::18) 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: a48490e8-dd42-4ef9-87e2-08d9d12eb597 X-MS-TrafficTypeDiagnostic: DM6PR12MB4058:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5516; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2TKvPoJ7p/A+oWZqpADqNH9G3kmQbz38XISb4JeK0q9YNGjPPj6PlVf3wE6z7qYrle4YYdLGT0crqlqNTigAY+fS3xJh2re559ANl/u0LI8ZiI8BXVWOqmDfGxYcCXV84haLjfYS5ikPtlcTw2uWgXxoyQFyfKX/ohYohsfC3yVwpoIo1cOaGnAnjQ6fiR4xOoHoDQ4C99WiJdflPYlSNZFI1QEWmDXDOxd94rtAHNtDWxsq9mTR0azw8dg/BxIUCkz2fDKCKVKLrde904knDVWWH0Afuvm7tqeF1BArPhF6bY2YmdjcsZMHJJ+N2f3PaID8lep8urDxoJ25SCfPYiqxtsuQXe1SNpvwcwNJV90k0/w02ACPi80/jiMInq9ZDmxjR5f3dUaQ6GdaBGWZk1kvdALXKcNYGqUx6Mauo0OsZXftKoCEJ+rAJBkmjui0HGk1D88f9B6qxbRcKLtQdJRplaz1UcXTx9yJeRO352hJaQWUWSr8fTod3J+cMlBprWpALYIIN0AOxwOkJairx3+UU5RVsZgUMg5+q+AyOhd5EKLURG8S/gcHD4uMJbE1WcZ+NitC0iP3coRMTvi6lak3RPj9gGONlCyIfCNTZjpDuPSIbY154RkibnVr8wbBLLmZVWFmyQNGWhl4thS2OA== 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)(66574015)(4326008)(26005)(38100700002)(8676002)(19627235002)(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: +0vjLCMPI5LC6B7FUm6/KOOG9O3foPC2E1mf12le7i3GeVctn9keVnvz6J1/EkqRJhuTz7RXJ7tzGugAB2HlaFUJvt8y8fANA3gDU1pnzRyC4dwTl0+i5VjkAMFrOf3hcsAs7EBM+0XYBJS0E0bP3o9KKVXMLTDBt7wdAMCTKNRRSz0NCD3S9HargrRr9LZQNxd6kQZJHOm5eZqkGnaEpVbnIjGatUEMfUEDDvd5QzE2kKpWr5jtoyFo35+Mp3HoeKnU45XUo9gclyQbT4l0cRG/ah5EZzCo5zDAolehgqNRY5JYHh8Uu9PbtE3R+LKjazi6a1woNVU01vWZW563X46TfkidRjPzeCpiQ6/CjsB9XimSE748CcS26FuXkjSQujKwTDFuJ5Oa6aPqHHhMk4XbK2Un0wCwqi+yLyVj/a60riHlxcB44Vaeft/NojJd4ozZB9b2TgGYQg/O8AXoHUZpgQ/F/1YCyauOVt3dFoc+Iy4wvwOldVgoT5a/XFY4zd2OZuE0zvwuj9CQzJ3RN6eS/LIX1OIWpUnNBRbsl60hMjqTV1OoJkF6HMflbh6cB2lx4/+goAyYSNGy03YU05mO65M84Fkk9zV8G5bYDxfiboUSAydHanqljhJYfx8Mh/DJNMHf1s47vNVo5n7+Q7NoVzMN1Hb25QeELkMRQ8XVtvgu+USNyNMuDmj7rKJt1dS8JhfZAVe4EZB4DcMHeQXpsQ35k5BziyCiqWRZAGG0ckBtkj45YtMzbYhHFQf2zMVDHznwZEcRznAb4NpLWLupQCryAA/a/z1PT8ouSDkmp5yEINonHOHeZ2QpJRCrQGsVJqljAr0QdsJSeETrgR7K1C8br4GVTrE+vxalbS2Q7+BhMal5sQotObSY7RFfVDbBTBtRIYxIe7/PVOszA26LdxCN8SyFgyHm3b51tvfabOB5QY//QmrB8frL73uPTE+em5s4f7/1vBfYgDv1vYQRivrltl5i+5puAyNLzzkeEJ0YLsBoeM1RAP9cPTHQJEbwAnKjLAQdbmL7/86kuPZbVvGXv79k5uZyMJLlg6PfRrPbkVYuGegsGiT0jlvOeunAnZZwE3dlhrrpknCS4FfrFfOrr0F4l9I7wNwH0mS6kwLBr2kFxoxMX7u8w1J4RoDwt8GBHkPV6aoS3AHWV1Oa7burGdIrtJSqfDqP6aixriIIm4ds7fsmSsRJUW16ps5QGjcbglUQ3QszpZdICft9eNhYBxljfqp04BDdTOp89H1lKpcPHRlxZc/s16kYE4qVlrhpT1asIwlgQ3nf+EF74W3/2mLjiQLrknbTTfMeJwrQsmxbs3Uk8PXg2PZzKNuEt5sqz33fyITtsTXnXjiTJkqGpAGSG1s6bMKGPIqDIO0I9pDuqUH33dwO6y2pSNrUc7uNkxHUfWnTnev184d4mKOZK/MaTF7XdlGgLiw7GcXI352MHCaiRdxQMtaExJP13FfIrxMy70StC9vgPK6GYqs+VRKSApLX8SGDNSI/Iywm/yJS47WAb4G0hsGHCCk9dyTgmOu4bNz5IM9mh9aPewfIsr8XRAHsVwjfdtkHSg4ZiMPcksKmwoQn0dVAQxSuGpfb/K9Q8MRsUO5A4bd7fDvApKYAwk9ddvrIRDs= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: a48490e8-dd42-4ef9-87e2-08d9d12eb597 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:59.6974 (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: d8xtrTbx5XvjlPu8SAXUxCaa3hiTN8YPyWdu3wP1RkoDtMvyIilNeCzvhUTGJy5PtkhGxdk6j56UwkVyG0DmZA== 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 Extend existing driver for Spectrum, Spectrum-2 and Spectrum-3 ASICs to support Spectrum-4 ASIC as well. Currently there is no released firmware version for Spectrum-4, so the driver is not enforcing a minimum version. Signed-off-by: Amit Cohen Signed-off-by: Ido Schimmel --- drivers/net/ethernet/mellanox/mlxsw/Kconfig | 2 +- drivers/net/ethernet/mellanox/mlxsw/pci.h | 1 + drivers/net/ethernet/mellanox/mlxsw/reg.h | 1 + .../net/ethernet/mellanox/mlxsw/spectrum.c | 95 +++++++++++++++++++ 4 files changed, 98 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/Kconfig b/drivers/net/ethernet/mellanox/mlxsw/Kconfig index d1ae248e125c..4683312861ac 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/Kconfig +++ b/drivers/net/ethernet/mellanox/mlxsw/Kconfig @@ -66,7 +66,7 @@ config MLXSW_SPECTRUM default m help This driver supports Mellanox Technologies - Spectrum/Spectrum-2/Spectrum-3 Ethernet Switch ASICs. + Spectrum/Spectrum-2/Spectrum-3/Spectrum-4 Ethernet Switch ASICs. To compile this driver as a module, choose M here: the module will be called mlxsw_spectrum. diff --git a/drivers/net/ethernet/mellanox/mlxsw/pci.h b/drivers/net/ethernet/mellanox/mlxsw/pci.h index 9899c1a2ea8f..cacc2f9fa1d4 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/pci.h +++ b/drivers/net/ethernet/mellanox/mlxsw/pci.h @@ -9,6 +9,7 @@ #define PCI_DEVICE_ID_MELLANOX_SPECTRUM 0xcb84 #define PCI_DEVICE_ID_MELLANOX_SPECTRUM2 0xcf6c #define PCI_DEVICE_ID_MELLANOX_SPECTRUM3 0xcf70 +#define PCI_DEVICE_ID_MELLANOX_SPECTRUM4 0xcf80 #if IS_ENABLED(CONFIG_MLXSW_PCI) diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h index c97d2c744725..24cc65018b41 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/reg.h +++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h @@ -3914,6 +3914,7 @@ MLXSW_ITEM32(reg, qeec, max_shaper_bs, 0x1C, 0, 6); #define MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP1 5 #define MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP2 11 #define MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP3 11 +#define MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP4 11 static inline void mlxsw_reg_qeec_pack(char *payload, u16 local_port, enum mlxsw_reg_qeec_hr hr, u8 index, diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c index 6e4265c86eb8..aa411dec62f0 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c @@ -95,6 +95,7 @@ static const struct mlxsw_fw_rev mlxsw_sp3_fw_rev = { static const char mlxsw_sp1_driver_name[] = "mlxsw_spectrum"; static const char mlxsw_sp2_driver_name[] = "mlxsw_spectrum2"; static const char mlxsw_sp3_driver_name[] = "mlxsw_spectrum3"; +static const char mlxsw_sp4_driver_name[] = "mlxsw_spectrum4"; static const unsigned char mlxsw_sp1_mac_mask[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00 @@ -3202,6 +3203,36 @@ static int mlxsw_sp3_init(struct mlxsw_core *mlxsw_core, return mlxsw_sp_init(mlxsw_core, mlxsw_bus_info, extack); } +static int mlxsw_sp4_init(struct mlxsw_core *mlxsw_core, + const struct mlxsw_bus_info *mlxsw_bus_info, + struct netlink_ext_ack *extack) +{ + struct mlxsw_sp *mlxsw_sp = mlxsw_core_driver_priv(mlxsw_core); + + mlxsw_sp->switchdev_ops = &mlxsw_sp2_switchdev_ops; + mlxsw_sp->kvdl_ops = &mlxsw_sp2_kvdl_ops; + mlxsw_sp->afa_ops = &mlxsw_sp2_act_afa_ops; + mlxsw_sp->afk_ops = &mlxsw_sp4_afk_ops; + 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_sp4_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; + mlxsw_sp->sb_ops = &mlxsw_sp3_sb_ops; + mlxsw_sp->port_type_speed_ops = &mlxsw_sp2_port_type_speed_ops; + mlxsw_sp->ptp_ops = &mlxsw_sp2_ptp_ops; + mlxsw_sp->span_ops = &mlxsw_sp3_span_ops; + mlxsw_sp->policer_core_ops = &mlxsw_sp2_policer_core_ops; + mlxsw_sp->trap_ops = &mlxsw_sp2_trap_ops; + mlxsw_sp->mall_ops = &mlxsw_sp2_mall_ops; + mlxsw_sp->router_ops = &mlxsw_sp2_router_ops; + mlxsw_sp->lowest_shaper_bs = MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP4; + + return mlxsw_sp_init(mlxsw_core, mlxsw_bus_info, extack); +} + static void mlxsw_sp_fini(struct mlxsw_core *mlxsw_core) { struct mlxsw_sp *mlxsw_sp = mlxsw_core_driver_priv(mlxsw_core); @@ -3761,6 +3792,45 @@ static struct mlxsw_driver mlxsw_sp3_driver = { .temp_warn_enabled = true, }; +static struct mlxsw_driver mlxsw_sp4_driver = { + .kind = mlxsw_sp4_driver_name, + .priv_size = sizeof(struct mlxsw_sp), + .init = mlxsw_sp4_init, + .fini = mlxsw_sp_fini, + .basic_trap_groups_set = mlxsw_sp_basic_trap_groups_set, + .port_split = mlxsw_sp_port_split, + .port_unsplit = mlxsw_sp_port_unsplit, + .sb_pool_get = mlxsw_sp_sb_pool_get, + .sb_pool_set = mlxsw_sp_sb_pool_set, + .sb_port_pool_get = mlxsw_sp_sb_port_pool_get, + .sb_port_pool_set = mlxsw_sp_sb_port_pool_set, + .sb_tc_pool_bind_get = mlxsw_sp_sb_tc_pool_bind_get, + .sb_tc_pool_bind_set = mlxsw_sp_sb_tc_pool_bind_set, + .sb_occ_snapshot = mlxsw_sp_sb_occ_snapshot, + .sb_occ_max_clear = mlxsw_sp_sb_occ_max_clear, + .sb_occ_port_pool_get = mlxsw_sp_sb_occ_port_pool_get, + .sb_occ_tc_port_bind_get = mlxsw_sp_sb_occ_tc_port_bind_get, + .trap_init = mlxsw_sp_trap_init, + .trap_fini = mlxsw_sp_trap_fini, + .trap_action_set = mlxsw_sp_trap_action_set, + .trap_group_init = mlxsw_sp_trap_group_init, + .trap_group_set = mlxsw_sp_trap_group_set, + .trap_policer_init = mlxsw_sp_trap_policer_init, + .trap_policer_fini = mlxsw_sp_trap_policer_fini, + .trap_policer_set = mlxsw_sp_trap_policer_set, + .trap_policer_counter_get = mlxsw_sp_trap_policer_counter_get, + .txhdr_construct = mlxsw_sp_txhdr_construct, + .resources_register = mlxsw_sp2_resources_register, + .params_register = mlxsw_sp2_params_register, + .params_unregister = mlxsw_sp2_params_unregister, + .ptp_transmitted = mlxsw_sp_ptp_transmitted, + .txhdr_len = MLXSW_TXHDR_LEN, + .profile = &mlxsw_sp2_config_profile, + .res_query_enabled = true, + .fw_fatal_enabled = true, + .temp_warn_enabled = true, +}; + bool mlxsw_sp_port_dev_check(const struct net_device *dev) { return dev->netdev_ops == &mlxsw_sp_port_netdev_ops; @@ -4928,6 +4998,16 @@ static struct pci_driver mlxsw_sp3_pci_driver = { .id_table = mlxsw_sp3_pci_id_table, }; +static const struct pci_device_id mlxsw_sp4_pci_id_table[] = { + {PCI_VDEVICE(MELLANOX, PCI_DEVICE_ID_MELLANOX_SPECTRUM4), 0}, + {0, }, +}; + +static struct pci_driver mlxsw_sp4_pci_driver = { + .name = mlxsw_sp4_driver_name, + .id_table = mlxsw_sp4_pci_id_table, +}; + static int __init mlxsw_sp_module_init(void) { int err; @@ -4947,6 +5027,10 @@ static int __init mlxsw_sp_module_init(void) if (err) goto err_sp3_core_driver_register; + err = mlxsw_core_driver_register(&mlxsw_sp4_driver); + if (err) + goto err_sp4_core_driver_register; + err = mlxsw_pci_driver_register(&mlxsw_sp1_pci_driver); if (err) goto err_sp1_pci_driver_register; @@ -4959,13 +5043,21 @@ static int __init mlxsw_sp_module_init(void) if (err) goto err_sp3_pci_driver_register; + err = mlxsw_pci_driver_register(&mlxsw_sp4_pci_driver); + if (err) + goto err_sp4_pci_driver_register; + return 0; +err_sp4_pci_driver_register: + mlxsw_pci_driver_unregister(&mlxsw_sp3_pci_driver); err_sp3_pci_driver_register: mlxsw_pci_driver_unregister(&mlxsw_sp2_pci_driver); err_sp2_pci_driver_register: mlxsw_pci_driver_unregister(&mlxsw_sp1_pci_driver); err_sp1_pci_driver_register: + mlxsw_core_driver_unregister(&mlxsw_sp4_driver); +err_sp4_core_driver_register: mlxsw_core_driver_unregister(&mlxsw_sp3_driver); err_sp3_core_driver_register: mlxsw_core_driver_unregister(&mlxsw_sp2_driver); @@ -4979,9 +5071,11 @@ static int __init mlxsw_sp_module_init(void) static void __exit mlxsw_sp_module_exit(void) { + mlxsw_pci_driver_unregister(&mlxsw_sp4_pci_driver); mlxsw_pci_driver_unregister(&mlxsw_sp3_pci_driver); mlxsw_pci_driver_unregister(&mlxsw_sp2_pci_driver); mlxsw_pci_driver_unregister(&mlxsw_sp1_pci_driver); + mlxsw_core_driver_unregister(&mlxsw_sp4_driver); mlxsw_core_driver_unregister(&mlxsw_sp3_driver); mlxsw_core_driver_unregister(&mlxsw_sp2_driver); mlxsw_core_driver_unregister(&mlxsw_sp1_driver); @@ -4998,6 +5092,7 @@ MODULE_DESCRIPTION("Mellanox Spectrum driver"); MODULE_DEVICE_TABLE(pci, mlxsw_sp1_pci_id_table); MODULE_DEVICE_TABLE(pci, mlxsw_sp2_pci_id_table); MODULE_DEVICE_TABLE(pci, mlxsw_sp3_pci_id_table); +MODULE_DEVICE_TABLE(pci, mlxsw_sp4_pci_id_table); MODULE_FIRMWARE(MLXSW_SP1_FW_FILENAME); MODULE_FIRMWARE(MLXSW_SP2_FW_FILENAME); MODULE_FIRMWARE(MLXSW_SP3_FW_FILENAME);