From patchwork Sun Jul 22 13:17:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 10539323 X-Patchwork-Delegate: jiri@resnulli.us Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E26E21805 for ; Sun, 22 Jul 2018 13:19:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF865281F9 for ; Sun, 22 Jul 2018 13:19:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C426E28384; Sun, 22 Jul 2018 13:19:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,MAILING_LIST_MULTI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9D91F28372 for ; Sun, 22 Jul 2018 13:19:09 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41YQF75ZBfzDrC5 for ; Sun, 22 Jul 2018 23:19:07 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=mellanox.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=Mellanox.com header.i=@Mellanox.com header.b="c1cyjjZG"; dkim-atps=neutral X-Original-To: linux-mlxsw@lists.ozlabs.org Delivered-To: linux-mlxsw@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=mellanox.com (client-ip=40.107.8.51; helo=eur04-vi1-obe.outbound.protection.outlook.com; envelope-from=idosch@mellanox.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=mellanox.com Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=Mellanox.com header.i=@Mellanox.com header.b="c1cyjjZG"; dkim-atps=neutral Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80051.outbound.protection.outlook.com [40.107.8.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41YQDB4Jl7zDqtW for ; Sun, 22 Jul 2018 23:18:18 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xnMg9ES8ga2UoVLLHqfxp1PM3mRb2h1Hwr6keI7UHfM=; b=c1cyjjZGkIUdXAlTNI8QSW3rIiOSEQz60QXUO1ji3x8ADofRDg4XFgRgHaWxQxi5eLErNANR4zHnXLE8ENudWY5KYUqcWR/ogXQl8btxQNUAgMZzfsOXc/Hag3pBki49rqFMvBjIkRqZHP9XhZvL/BOZCaPNCbXTMmQAE30y/3Y= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=idosch@mellanox.com; Received: from splinter.mtl.com (193.47.165.251) by HE1PR0501MB2331.eurprd05.prod.outlook.com (2603:10a6:3:27::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.973.20; Sun, 22 Jul 2018 13:18:10 +0000 From: Ido Schimmel To: linux-internal@mellanox.com Subject: [PATCH net-next mlxsw 14/18] mlxsw: spectrum_acl: Add A-TCAM region initialization Date: Sun, 22 Jul 2018 16:17:08 +0300 Message-Id: <20180722131712.30578-15-idosch@mellanox.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180722131712.30578-1-idosch@mellanox.com> References: <20180722131712.30578-1-idosch@mellanox.com> MIME-Version: 1.0 X-Originating-IP: [193.47.165.251] X-ClientProxiedBy: AM0PR01CA0036.eurprd01.prod.exchangelabs.com (2603:10a6:208:69::49) To HE1PR0501MB2331.eurprd05.prod.outlook.com (2603:10a6:3:27::24) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: aa730c23-8234-4f6e-f640-08d5efd5926a X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600073)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:HE1PR0501MB2331; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0501MB2331; 3:IImjBFf0R+fJ+x4+jgGsDIxyub72BVH18xNvtrUTtxCsP+6TZiCwukjaCkDl9lQuVEbD4qy6tnITER4hCAVPb0r2LiaD78zddkqY6o42zcCrilVmMlWaG25p0WPcOoQ0oiVyPlwQFr1IVhYQq7w9naXXU0UNvWP4o0aZMD2KTDtoN/A6C5Kqv96uLpb8jAIZPjHm9dIjaEAE4nBFfO4CvrDdZcZeKpw2fR4Xgot8dvGAdsffGofo0sWSy4FYhr5q; 25:/GRh2wF47bbwIme3QFvI3otQPQ9oinYVaKTG5A5aSWbA54vIhcFaTqAld7PA5Ojvi05fiMIjDiDvOqe4W9cnjOjCf3OJa8i7juf77n1KtJkjn5Ov+oaxaQL5DpuzsKYVqS84E1+fbjIxtWy7bqVQix/hbe9RDKENK4WUymlFv6tWX9dIZuUYoa4Mzkk7BrdYPfupqRoFLZmlB4HpT8gvUcbM2A48sD3UqoAOdm0RDsZi8Bp8YD6nwCa/fpWEC4YPJo5Pl6dAlCJJpBi9UiBBCSGDY3wdBvjNM10RZVFexsQuD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E0x3wZG5QZyCma+x1F4igDMFrUejV798SSjxGDmLHgka7xQUawfH32Q2O7KrTs0DrQcRL+5bROTrDAkavZUg== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231311)(944501410)(52105095)(3002001)(93006095)(93001095)(10201501046)(6055026)(149027)(150027)(6041310)(20161123564045)(20161123562045)(20161123558120)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016); SRVR:HE1PR0501MB2331; BCL:0; PCL:0; RULEID:; SRVR:HE1PR0501MB2331; X-Forefront-PRVS: 0741C77572 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(1496009)(376002)(366004)(136003)(346002)(396003)(39860400002)(199004)(189003)(47776003)(956004)(14444005)(81156014)(106356001)(66066001)(3846002)(6116002)(2361001)(486006)(97736004)(68736007)(81166006)(1076002)(36756003)(4326008)(2906002)(86362001)(16526019)(11346002)(26005)(105586002)(6636002)(386003)(6506007)(478600001)(446003)(8676002)(8936002)(5660300001)(53936002)(48376002)(34206002)(107886003)(50226002)(76176011)(316002)(53416004)(305945005)(476003)(6512007)(25786009)(2616005)(2351001)(37006003)(7736002)(51416003)(16586007)(50466002)(52116002)(6486002); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR0501MB2331; H:splinter.mtl.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HE1PR0501MB2331; 23:k1tKpJy4v4oVfqF2Fc0dFKP9NAF+HwrBbKF87Zm?= Kq7NwM0qQxGivUUf5OkF0mSbD9W03633tqvsKUxTWJuC2jz+WMewAdVIG4f/hIOYvHvcaU6zVmEk+dkqn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Z2zJMtcepPgw52g9PhrrIyQ+wqLwYqcq03VLNe/muvmmdXUf1PofSn5AsmB5Nkkt/DFk50IEETNh8o/6NsTmvSMqOR5RaTm3mXBqmya/VYq1hpR2CRJR0c91IBou03tFFvh722Z8=; 7:d7x//nZAfhDYe+K5AaO0opr5dWb622fc2W2TEZzxcjFlq59hH83FBD+y4xHHeoE90R9hulR66cofIuJBaTIj6xFE1boDLP88QAufbO+oGetnwMwf98hD7DczxmdRy+8GIi2So6tAvI9DWE7CauKVX9B9h6alttleaJxvt8gaJKyjdeOxT2+TSWmBhcGxMEgO8GCw6A/7cYZ2rNhG3DcerXTyekLFQUr125F0S2Nnh1nPmVQKRUZhglDHK1c/F+W3 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2018 13:18:10.0724 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: aa730c23-8234-4f6e-f640-08d5efd5926a X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0501MB2331 X-BeenThere: linux-mlxsw@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: mlxsw driver development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-mlxsw-bounces+patchwork-linux-mlxsw=patchwork.kernel.org@lists.ozlabs.org X-Virus-Scanned: ClamAV using ClamSMTP Before we start using the A-TCAM we need to make sure the region is properly initialized. This includes the setting of its type (which affects the size of its eRP table, for example) and its registration with the eRP core. Signed-off-by: Ido Schimmel --- .../mellanox/mlxsw/spectrum_acl_atcam.c | 52 +++++++++++-------- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_atcam.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_atcam.c index f030da8b9c31..c13f08e9e907 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_atcam.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_atcam.c @@ -57,23 +57,27 @@ int mlxsw_sp_acl_atcam_region_associate(struct mlxsw_sp *mlxsw_sp, return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(perar), perar_pl); } -static int mlxsw_sp_acl_atcam_region_param_init(struct mlxsw_sp *mlxsw_sp, - u16 region_id) +static void +mlxsw_sp_acl_atcam_region_type_init(struct mlxsw_sp_acl_atcam_region *aregion) { - char percr_pl[MLXSW_REG_PERCR_LEN]; + struct mlxsw_sp_acl_tcam_region *region = aregion->region; + enum mlxsw_sp_acl_atcam_region_type region_type; + unsigned int blocks_count; - mlxsw_reg_percr_pack(percr_pl, region_id); - return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(percr), percr_pl); -} - -static int -mlxsw_sp_acl_atcam_region_erp_init(struct mlxsw_sp *mlxsw_sp, - u16 region_id) -{ - char pererp_pl[MLXSW_REG_PERERP_LEN]; + /* We already know the blocks count can not exceed the maximum + * blocks count. + */ + blocks_count = mlxsw_afk_key_info_blocks_count_get(region->key_info); + if (blocks_count <= 2) + region_type = MLXSW_SP_ACL_ATCAM_REGION_TYPE_2KB; + else if (blocks_count <= 4) + region_type = MLXSW_SP_ACL_ATCAM_REGION_TYPE_4KB; + else if (blocks_count <= 8) + region_type = MLXSW_SP_ACL_ATCAM_REGION_TYPE_8KB; + else + region_type = MLXSW_SP_ACL_ATCAM_REGION_TYPE_12KB; - mlxsw_reg_pererp_pack(pererp_pl, region_id, true, true, 0, 0, 0); - return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pererp), pererp_pl); + aregion->type = region_type; } int mlxsw_sp_acl_atcam_region_init(struct mlxsw_sp *mlxsw_sp, @@ -83,24 +87,30 @@ int mlxsw_sp_acl_atcam_region_init(struct mlxsw_sp *mlxsw_sp, { int err; - err = mlxsw_sp_acl_atcam_region_associate(mlxsw_sp, region->id); - if (err) - return err; - err = mlxsw_sp_acl_atcam_region_param_init(mlxsw_sp, region->id); - if (err) - return err; - err = mlxsw_sp_acl_atcam_region_erp_init(mlxsw_sp, region->id); + aregion->region = region; + aregion->atcam = atcam; + mlxsw_sp_acl_atcam_region_type_init(aregion); + + err = mlxsw_sp_acl_erp_region_init(aregion); if (err) return err; + err = mlxsw_sp_acl_ctcam_region_init(mlxsw_sp, &aregion->cregion, region); + if (err) + goto err_ctcam_region_init; return 0; + +err_ctcam_region_init: + mlxsw_sp_acl_erp_region_fini(aregion); + return err; } void mlxsw_sp_acl_atcam_region_fini(struct mlxsw_sp_acl_atcam_region *aregion) { mlxsw_sp_acl_ctcam_region_fini(&aregion->cregion); + mlxsw_sp_acl_erp_region_fini(aregion); } int mlxsw_sp_acl_atcam_init(struct mlxsw_sp *mlxsw_sp,