From patchwork Sun Jul 22 13:16:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 10539297 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 6CAF61805 for ; Sun, 22 Jul 2018 13:18:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4945928384 for ; Sun, 22 Jul 2018 13:18:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2811528385; Sun, 22 Jul 2018 13:18:23 +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 4F826281F9 for ; Sun, 22 Jul 2018 13:18:22 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41YQDB73kHzDr0d for ; Sun, 22 Jul 2018 23:18:18 +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="nQshe0UA"; 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.57; 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="nQshe0UA"; dkim-atps=neutral Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80057.outbound.protection.outlook.com [40.107.8.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41YQCx6NQCzDqmF for ; Sun, 22 Jul 2018 23:18:04 +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=4ZUuEK1iU7fjwa2HOR+9w6bwVTQ6yjjszT7lKOuD9Ug=; b=nQshe0UAz7hiYggfwUI7WFJ45eNNuSvGgNkIplnKbJ3XR18apM1930rGjPvLM8FDaNnZazW/s/91sI55YBTyGudxYrOHJGXpuAfkm/excL27mCzCtTsgLkcDvFmY6qN7y6olFyi7TL9iVqiU8xnPmGrBd5Pro//hFDm4yme6j5Y= 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:17:55 +0000 From: Ido Schimmel To: linux-internal@mellanox.com Subject: [PATCH net-next mlxsw 01/18] mlxsw: reg: Prepare PERERP register for A-TCAM usage Date: Sun, 22 Jul 2018 16:16:55 +0300 Message-Id: <20180722131712.30578-2-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: bfa3058a-405c-41ce-55b3-08d5efd589a0 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:SYVOAtV0RY61QD89L6wPKmmzgbB/JZOqprPNfP0h2NZWfM7OD05UzFeH7x6FJTXdk/O/gx1WJSkak819dNW+fQpoK0VLmHMViXNUfFiUT7++w71FdHBj+4k1N4SqeovzixvhqQD6l8CVbrnood8CzCFHPPrZ0p9bY8024VCXvUw53kbzM2pHthw23Rx04KBIN3EmHFUqrRkJe9gOfdMki8l3CvDqfO0kPs0cS4Ncj8acCQyZ7Oaa0GVPmztHnesN; 25:F9pbHfGNMgqznxEA7yWTJfeoJxejp9Lhi9QPyrAibg5pqyTYHmlh5np/0CVR+ZCVZ7PXF3WVnAxvVzX7yKPqlSYWPyWr22T+kQiqopZ9yH9e58yIo+epCq5Hf2tQZEv2Ty+VA9Zr2eykCLCR0V9SCUqc6PkjEKRFPevNLDtOM9fMQwnatMuAWBNmLEt/4gvuL3Tp4X7Fu72brqUkzT24+kUZ1NFFPEZ4qf6H/+maAxvQY6BBMVCXHYP9T4kGVGEgvI9BRUgHqXMplGoeETEzALFFb6G8iiBkkNPYhwnz5Nah0Z+VgXjE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vruNBdhDjmUjSJ52lKravPnC2lHYDZuJ+ym48Dc0kY6Kk7Vw4t5CRtjus0Ehw== 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)(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)(575784001)(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:7xMYjNiQcHZhln28/3XTrVYJjBuuYvpPNtXA5EP?= nGXX8+Q4/riHwdxbDbtSmmr6gQYqQbRYwr+6+EHOKgXmd0/JCC/AcXVX0Y9Mv1PGBEG/HBW5RtoCgF4krkyRQtfX8PdHr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slZ8jpG/aroAN9QhYj7GlQYk68GioB/2G3yteVLuC2eEiGq0ozwWmf2Ekwtj8JnU3kBaDG0DCL8x25UmA5HavE=; 7:2J1X6iO1P8Xryr58nLROPPTEuU/FXzQYxEVIHTWGe3hSfAQ4FqYl+q33pszMCO1u4H9m40K3I15ePy+D4gRg2ZEH3iB8mJRyPe8w0pauLwZgjU2sotsX4jFbl5J+sINT84kYOrjV+4mVDLza+gWJ+2GLUSWRG3Eqhywnd9aDtLHWkyJtxtMr8yzF5sPJVi4YPLeBgn8FZo8RR21LrSyFG/Qh+yRAzN9sY/rPJLzSxgjuTr+LCztt8sFGHl/palG/ SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2018 13:17:55.3070 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bfa3058a-405c-41ce-55b3-08d5efd589a0 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 introducing A-TCAM support we need to make sure all the necessary fields are configurable and not hard coded to values that worked for the C-TCAM only use case. This includes - for example - the ability to configure the eRP table used by the TCAM region. Signed-off-by: Ido Schimmel Reviewed-by: Jiri Pirko --- drivers/net/ethernet/mellanox/mlxsw/reg.h | 22 ++++++++++++++++--- .../mellanox/mlxsw/spectrum_acl_atcam.c | 2 +- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h index 596fddfb3850..f4e16ac20fea 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/reg.h +++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h @@ -2663,12 +2663,28 @@ MLXSW_ITEM_BIT_ARRAY(reg, pererp, erpt_vector, 0x14, 4, 1); */ MLXSW_ITEM32(reg, pererp, master_rp_id, 0x18, 0, 4); -static inline void mlxsw_reg_pererp_pack(char *payload, u16 region_id) +static inline void mlxsw_reg_pererp_erp_vector_pack(char *payload, + unsigned long *erp_vector, + unsigned long size) +{ + unsigned long bit; + + for_each_set_bit(bit, erp_vector, size) + mlxsw_reg_pererp_erpt_vector_set(payload, bit, true); +} + +static inline void mlxsw_reg_pererp_pack(char *payload, u16 region_id, + bool ctcam_le, bool erpt_pointer_valid, + u8 erpt_bank_pointer, u8 erpt_pointer, + u8 master_rp_id) { MLXSW_REG_ZERO(pererp, payload); mlxsw_reg_pererp_region_id_set(payload, region_id); - mlxsw_reg_pererp_ctcam_le_set(payload, true); - mlxsw_reg_pererp_erpt_pointer_valid_set(payload, true); + mlxsw_reg_pererp_ctcam_le_set(payload, ctcam_le); + mlxsw_reg_pererp_erpt_pointer_valid_set(payload, erpt_pointer_valid); + mlxsw_reg_pererp_erpt_bank_pointer_set(payload, erpt_bank_pointer); + mlxsw_reg_pererp_erpt_pointer_set(payload, erpt_pointer); + mlxsw_reg_pererp_master_rp_id_set(payload, master_rp_id); } /* IEDR - Infrastructure Entry Delete Register diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_atcam.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_atcam.c index b1b3b0e0c00e..a27d3b0f9fcb 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_atcam.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_atcam.c @@ -72,7 +72,7 @@ mlxsw_sp_acl_atcam_region_erp_init(struct mlxsw_sp *mlxsw_sp, { char pererp_pl[MLXSW_REG_PERERP_LEN]; - mlxsw_reg_pererp_pack(pererp_pl, region_id); + 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); } From patchwork Sun Jul 22 13:16:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 10539299 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 87D6A96FA for ; Sun, 22 Jul 2018 13:18:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 73785281F9 for ; Sun, 22 Jul 2018 13:18:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 67DB328385; Sun, 22 Jul 2018 13:18:23 +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 7305428372 for ; Sun, 22 Jul 2018 13:18:22 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41YQDD3SZhzDqrX for ; Sun, 22 Jul 2018 23:18:20 +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="VefUqCwv"; 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.57; 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="VefUqCwv"; dkim-atps=neutral Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80057.outbound.protection.outlook.com [40.107.8.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41YQD16RCJzDqmF for ; Sun, 22 Jul 2018 23:18:09 +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=AbADB4hQFOGorGwb91ClZNcXGFz/4smWsSXgkvwHzgc=; b=VefUqCwvQNy3Y9VrDKDkg90dnv1wuQZuBuQcCk42LmVd5ufG5yVNuzsXRvxAmkrFmqPbXPF7dOE3RBzeSX137/Q1rhID6D5g8S/reGvIGZlG67nYzbCXDMMjxtc14ymOFNv+UlhQEdlFv4+f0qoBhCcMpWJ3tSdiJQJU4e2y8GU= 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:17:56 +0000 From: Ido Schimmel To: linux-internal@mellanox.com Subject: [PATCH net-next mlxsw 02/18] mlxsw: reg: Add Policy-Engine TCAM Entry Register Version 3 Date: Sun, 22 Jul 2018 16:16:56 +0300 Message-Id: <20180722131712.30578-3-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: 10b6c2de-d3d9-44e8-ffc4-08d5efd58a2c 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:cWboV0C6hdpWlSHsacLtgcIim5HyCkCn9uHiu3VZIqTIoWYu4vNcqs28UA/EdW80mMOTiyA948wgmt0XkGYEwyH2/I3ZdMVdS0LckLhPh9GiI2Cy7vdcnmzjY39QVatWndTLt8ywUnFKIj0evueGeCkY+mzY1RDLg/lZJ18J02G6FoIgF/mhGUpvM65vyQ6JUMOcEGVvedqXEEPy22ji+J3ol/9GpCx2CIRfzlgwQe6oxTCPrMVF6sEXJ7TtIqIy; 25:6eM66b3I4HA2DLrfAJUImxqXdk6zUynM1KIgKRsU2wBPYEQkl9C+kvdnvoWSRxAfwfSag1KfYbgglJWwS9bEnsrW0x8rMrN5qEzb1HO5XWQLZBZfQ74BL5n6qFWfG5tncJQk6vP/wcZLnAG9bB13Bh8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W0X7v1w8jmu72KdSH3srJfCVuPG7OPHtfJFVuBp0XVgJOfituO7uwgzluf4RG5bIKGOKQxbNNsuG2wDpLGyDmZVK7up0Gx0n8IGSpQGfKyKkXujTkYVs2kr/UpWQFfNLZaBOrW2Ox2xSWPol+Jq9hMDR+Veslo1Vd1m0XqZgzyWrJ6X1nZ49HjztgmPjh6smmgFRNtlnjsQsWz+b4tUN1g1fzK6/Ag== 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)(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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o+Am0kJyhTd8wlmA+kOgPMzYOYrw1dqKxABJDipklss31pcYF7MbHS0Pfg==; 5:wYbFiLme8xPLf5a+2sbgkk7t5yRS8/M0DeFm6O92o7VyY10HhlrP6WSZ1kaljwxRpA57o9SK9NLzrwCE1K6/ef2oKhhBvfiPCFPrcqWHih2lEcWSSVSfY7EN8sYjVD8moer2MuSf2FVzTdfESfUr3p0UlgO4QTZbAlELfaL+DhE=; 7:D6DUhCONbtphMqvHOhbjhzWa7CO/52DaXYSWnxdozWU5QHdmqqUyzLZXzqapVfDe16wwZeqGICe8l3Pd9hsNWHMpbS4kMd37Tq9tHZ3rcF9M/6Mgfngk/XuKtM3Ksl3mqYq2gvN7dK6NEZnV3W9+u6kzshdNGmoKyYCrXetquFasTW3KU8NjwBAIY+P8vItgncmehQGhZUAq6Tw08WSrpST61DOZc9juCCkv0lO+y6Zyb5VDPWcfn+k8BCfQ46rb SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2018 13:17:56.2289 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 10b6c2de-d3d9-44e8-ffc4-08d5efd58a2c 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 The register is used to configure rules in the A-TCAM. Signed-off-by: Ido Schimmel Reviewed-by: Jiri Pirko --- drivers/net/ethernet/mellanox/mlxsw/reg.h | 165 +++++++++++++++++++++- 1 file changed, 162 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h index f4e16ac20fea..cf07436c911b 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/reg.h +++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h @@ -2466,14 +2466,14 @@ MLXSW_ITEM32(reg, ptce2, priority, 0x04, 0, 24); MLXSW_ITEM_BUF(reg, ptce2, tcam_region_info, 0x10, MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN); -#define MLXSW_REG_PTCE2_FLEX_KEY_BLOCKS_LEN 96 +#define MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN 96 /* reg_ptce2_flex_key_blocks * ACL Key. * Access: RW */ MLXSW_ITEM_BUF(reg, ptce2, flex_key_blocks, 0x20, - MLXSW_REG_PTCE2_FLEX_KEY_BLOCKS_LEN); + MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN); /* reg_ptce2_mask * mask- in the same size as key. A bit that is set directs the TCAM @@ -2482,7 +2482,7 @@ MLXSW_ITEM_BUF(reg, ptce2, flex_key_blocks, 0x20, * Access: RW */ MLXSW_ITEM_BUF(reg, ptce2, mask, 0x80, - MLXSW_REG_PTCE2_FLEX_KEY_BLOCKS_LEN); + MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN); /* reg_ptce2_flex_action_set * ACL action set. @@ -2545,6 +2545,164 @@ static inline void mlxsw_reg_perar_pack(char *payload, u16 region_id, mlxsw_reg_perar_hw_region_set(payload, hw_region); } +/* PTCE-V3 - Policy-Engine TCAM Entry Register Version 3 + * ----------------------------------------------------- + * This register is a new version of PTCE-V2 in order to support the + * A-TCAM. This register is not supported by SwitchX/-2 and Spectrum. + */ +#define MLXSW_REG_PTCE3_ID 0x3027 +#define MLXSW_REG_PTCE3_LEN 0xF0 + +MLXSW_REG_DEFINE(ptce3, MLXSW_REG_PTCE3_ID, MLXSW_REG_PTCE3_LEN); + +/* reg_ptce3_v + * Valid. + * Access: RW + */ +MLXSW_ITEM32(reg, ptce3, v, 0x00, 31, 1); + +enum mlxsw_reg_ptce3_op { + /* Write operation. Used to write a new entry to the table. + * All R/W fields are relevant for new entry. Activity bit is set + * for new entries. Write with v = 0 will delete the entry. Must + * not be used if an entry exists. + */ + MLXSW_REG_PTCE3_OP_WRITE_WRITE = 0, + /* Update operation */ + MLXSW_REG_PTCE3_OP_WRITE_UPDATE = 1, + /* Read operation */ + MLXSW_REG_PTCE3_OP_QUERY_READ = 0, +}; + +/* reg_ptce3_op + * Access: OP + */ +MLXSW_ITEM32(reg, ptce3, op, 0x00, 20, 3); + +/* reg_ptce3_priority + * Priority of the rule. Higher values win. + * For Spectrum-2 range is 1..cap_kvd_size - 1 + * Note: Priority does not have to be unique per rule. + * Access: RW + */ +MLXSW_ITEM32(reg, ptce3, priority, 0x04, 0, 24); + +/* reg_ptce3_tcam_region_info + * Opaque object that represents the TCAM region. + * Access: Index + */ +MLXSW_ITEM_BUF(reg, ptce3, tcam_region_info, 0x10, + MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN); + +/* reg_ptce3_flex2_key_blocks + * ACL key. The key must be masked according to eRP (if exists) or + * according to master mask. + * Access: Index + */ +MLXSW_ITEM_BUF(reg, ptce3, flex2_key_blocks, 0x20, + MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN); + +/* reg_ptce3_erp_id + * eRP ID. + * Access: Index + */ +MLXSW_ITEM32(reg, ptce3, erp_id, 0x80, 0, 4); + +/* reg_ptce3_delta_start + * Start point of delta_value and delta_mask, in bits. Must not exceed + * num_key_blocks * 36 - 8. Reserved when delta_mask = 0. + * Access: Index + */ +MLXSW_ITEM32(reg, ptce3, delta_start, 0x84, 0, 10); + +/* reg_ptce3_delta_mask + * Delta mask. + * 0 - Ignore relevant bit in delta_value + * 1 - Compare relevant bit in delta_value + * Delta mask must not be set for reserved fields in the key blocks. + * Note: No delta when no eRPs. Thus, for regions with + * PERERP.erpt_pointer_valid = 0 the delta mask must be 0. + * Access: Index + */ +MLXSW_ITEM32(reg, ptce3, delta_mask, 0x88, 16, 8); + +/* reg_ptce3_delta_value + * Delta value. + * Bits which are masked by delta_mask must be 0. + * Access: Index + */ +MLXSW_ITEM32(reg, ptce3, delta_value, 0x88, 0, 8); + +/* reg_ptce3_prune_vector + * Pruning vector relative to the PERPT.erp_id. + * Used for reducing lookups. + * 0 - NEED: Do a lookup using the eRP. + * 1 - PRUNE: Do not perform a lookup using the eRP. + * Maybe be modified by PEAPBL and PEAPBM. + * Note: In Spectrum-2, a region of 8 key blocks must be set to either + * all 1's or all 0's. + * Access: RW + */ +MLXSW_ITEM_BIT_ARRAY(reg, ptce3, prune_vector, 0x90, 4, 1); + +/* reg_ptce3_prune_ctcam + * Pruning on C-TCAM. Used for reducing lookups. + * 0 - NEED: Do a lookup in the C-TCAM. + * 1 - PRUNE: Do not perform a lookup in the C-TCAM. + * Access: RW + */ +MLXSW_ITEM32(reg, ptce3, prune_ctcam, 0x94, 31, 1); + +/* reg_ptce3_large_exists + * Large entry key ID exists. + * Within the region: + * 0 - SINGLE: The large_entry_key_id is not currently in use. + * For rule insert: The MSB of the key (blocks 6..11) will be added. + * For rule delete: The MSB of the key will be removed. + * 1 - NON_SINGLE: The large_entry_key_id is currently in use. + * For rule insert: The MSB of the key (blocks 6..11) will not be added. + * For rule delete: The MSB of the key will not be removed. + * Access: WO + */ +MLXSW_ITEM32(reg, ptce3, large_exists, 0x98, 31, 1); + +/* reg_ptce3_large_entry_key_id + * Large entry key ID. + * A key for 12 key blocks rules. Reserved when region has less than 12 key + * blocks. Must be different for different keys which have the same common + * 6 key blocks (MSB, blocks 6..11) key within a region. + * Range is 0..cap_max_pe_large_key_id - 1 + * Access: RW + */ +MLXSW_ITEM32(reg, ptce3, large_entry_key_id, 0x98, 0, 24); + +/* reg_ptce3_action_pointer + * Pointer to action. + * Range is 0..cap_max_kvd_action_sets - 1 + * Access: RW + */ +MLXSW_ITEM32(reg, ptce3, action_pointer, 0xA0, 0, 24); + +static inline void mlxsw_reg_ptce3_pack(char *payload, bool valid, + enum mlxsw_reg_ptce3_op op, + u32 priority, + const char *tcam_region_info, + const char *key, u8 erp_id, + bool large_exists, u32 lkey_id, + u32 action_pointer) +{ + MLXSW_REG_ZERO(ptce3, payload); + mlxsw_reg_ptce3_v_set(payload, valid); + mlxsw_reg_ptce3_op_set(payload, op); + mlxsw_reg_ptce3_priority_set(payload, priority); + mlxsw_reg_ptce3_tcam_region_info_memcpy_to(payload, tcam_region_info); + mlxsw_reg_ptce3_flex2_key_blocks_memcpy_to(payload, key); + mlxsw_reg_ptce3_erp_id_set(payload, erp_id); + mlxsw_reg_ptce3_large_exists_set(payload, large_exists); + mlxsw_reg_ptce3_large_entry_key_id_set(payload, lkey_id); + mlxsw_reg_ptce3_action_pointer_set(payload, action_pointer); +} + /* PERCR - Policy-Engine Region Configuration Register * --------------------------------------------------- * This register configures the region parameters. The region_id must be @@ -8265,6 +8423,7 @@ static const struct mlxsw_reg_info *mlxsw_reg_infos[] = { MLXSW_REG(pefa), MLXSW_REG(ptce2), MLXSW_REG(perar), + MLXSW_REG(ptce3), MLXSW_REG(percr), MLXSW_REG(pererp), MLXSW_REG(iedr), From patchwork Sun Jul 22 13:16:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 10539303 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 8807996FA for ; Sun, 22 Jul 2018 13:18:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7344C281F9 for ; Sun, 22 Jul 2018 13:18:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6744128372; Sun, 22 Jul 2018 13:18:32 +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 9A71228384 for ; Sun, 22 Jul 2018 13:18:31 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41YQDP3z2yzDr0y for ; Sun, 22 Jul 2018 23:18:29 +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="nwvWD4f9"; 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.57; 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="nwvWD4f9"; dkim-atps=neutral Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80057.outbound.protection.outlook.com [40.107.8.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41YQD32Nr1zDqmF for ; Sun, 22 Jul 2018 23:18:11 +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=ddQT6Qqly85meXTRjTKwYGUT9i7+o3SWqDGDreew1mE=; b=nwvWD4f9IR5lnHNO66gdgXXe6Tqyw1WT2fOiv7St/E9lajwbgyNAwTK7VnsoW2WwQ48IiBSzKlubg5RFueWK5zRU/HudZ1om1nVmsd6+TaJpA17JnyZ8FRXFyT6rP4SufntNvWEOLe6LvCwmKVgLQad8J0CaeqJL7A41FCqgwO8= 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:17:57 +0000 From: Ido Schimmel To: linux-internal@mellanox.com Subject: [PATCH net-next mlxsw 03/18] mlxsw: reg: Add Policy-Engine eRP Table Register Date: Sun, 22 Jul 2018 16:16:57 +0300 Message-Id: <20180722131712.30578-4-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: b2f59a35-435f-4862-f7ce-08d5efd58ac7 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:eEoJ4nbyTJRIrfM6wAydA53W/ezjTyrkdxsYR7l/H9tIkdFS05f0UJqifLCWU7RTIS8K38cEZ3JmJuauu5WxvaFVoTw7nxPPXeft9J2oxn2FQaiDSyz7xupgQloWJtnJItxt0+7xEJJkYiZ7MVj6lflB92RA1uuElpqTSdP56lYh7M+ES+K9vOiEZjH9an4KrCuD/Cev4iPLFgLw10ErMMTgNni5mWplb60qzoZpm6KUHg/3/YJJ1NbAr4+iCsw+; 25:U/QcTHGeUqtJn+4LR4RT1y6wopUZYBWiKRiYsO/7E4EQLlJ+nPeRG0JLH3hxA58Z/uthpfqBvV4DzA3ZX+zL5w0rp/MoNHAobSZknQ4cuW20il5EXP3EaI++DpRYvAXyU5Q9ye1VVIeSiFIdRFT6RtiDehpW4zyvK2gYgDbNwJTgCtkkMGyFYcCUcDQA5RGrzZBrWJzlzXjcYA/8QCerb70cMqrsEIDE/GS/56PLQuMp+9SQ/pVgdhP+yREP2s1sFIk5fm0JQ0LSqJNO8+cdLyqSS+EJQOZdNr9rjhJ5/46f4q+a4n0Rm1b3+HXlSDaE+Nfe5u6zAqKFzWVHKcsP5g==; 31:LSoera/fL71s6MWih+F6nUGoSP2ASzWY4ZOMVaeQJ+nSvNoCVEfiiKWbmBnFR1qqMUHHAM2Mz84GsLqMRcoed9cGxs9zK+6hRrTkIQYBGoELOgyhuRR1q6AUoK/v07/Km6blHtkHeGX3wlbbV7v4bXKQWao0mMxODyfC1fOHj4hsRiw+azpSnNMKVwTJQc4csrZfcW0uIkjfaD8HbTjFNuFuB10lCvQQ1JloCMuu+fE= X-MS-TrafficTypeDiagnostic: HE1PR0501MB2331: X-Microsoft-Exchange-Diagnostics: 1; HE1PR0501MB2331; 20:cKxztn3rmM2HYiMbVThvNeTdatglddCT8sdpJC9bKlgL7jbZtvYnmfEjmnvqjZG6Lb5s8SrVDQ9Y+PuTtuRyqFlcrRtw2TTEhAMDuZlwyg7kHGt+ObjMScoJC2yP4lrmKVKZt+ySI5DDrVPbNC9FyaHR9nl7nbUt85/7xrdMDnDT5KVd95bsA8IGteUqcEuOz6K9JuQqSkelIFiR2J0kXTs+I4hBGkxpzwTx9XHIdBuHV9T0ggvtZMMmcefKOD77WJxKoEJXRirWQ0sB33KCmKZSB6p5W9Tddo1pQo9RKgWKBMsg2dlUpukyfw+kr+F5O6dPI4oJQ5JR71koGLEObAx3xqDPBa4gCU3MZFMxToiUUc3Ejx/B/vNanIUrqahmDxtb71+Hp3s16EpK0T8v7Q7kLpJLmeb6JhlJRn9i0kcgjvoS0yyUVuitm/LIQsRNgOSuPjm7rQaMf7sQiLcmu43sS3YY+dIv/DawvVEfe27r5EAs21UpbcrDegCEOEWe; 4:cd68I7/oNS/WUkkm19lakbO5zbjE/kZXim9ABoADXDB46SRnaPY7V2ofyZWDroVWlLOfleJx9z5aG7m0oaD11OjW+06XfvPWyTFlZrE+AF1QjYFQ11MCiAsCWPU1OFQSvYCZ1cwJB8gqdBhnYon0d6kDZ6Psfj+kuXKAB3Jxvsr6pMnO3KSgQ1mElnFYARgHw8txtbwlbQEG3KuwYF87FkM/0Vp1jJDGsSGDPP6/98FdlRxrjjkDb05XwW2PCLVo4lDHoftSiqcwRpnDv/W2BA== 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)(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)(575784001)(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:ycglzIruSbKKvZdrfBhNg2a5knQmkwCfhlH5nWs?= xnAtxwwklutSuGnQEzuGZTwDig6ywf424lDMBELJ2/bDCOyzrSKDSpOO0WHYpGD6oZnZy9BTlrkrodF+l9ijCwiB/7zFyXxx3SEOHwEFkWCbFJ6bTdBqt9avKJZpgFTWYs0DGVLC3ezo+K+63jJCqAODEQB41XVdkP5GN1/EZmry/ope38K0vcHFg2MBNUGDPtXsPGJFSB4sQVrZzPnHNbXepYqHNMxz/yYQmGARfzxq6YlkgI9P/2Kjmv3tMOdpkiLTN/4R0V8GfnDzzsie6ZR55q2PsBCHH8bMNherCj5yHAmIRXutLgoaNKUwdk/iwcoJxkLOmzctTghw2RhTh1/bJZiudYo7VqIB416tnq9OTgPMN6DnXM1VyeP5aw146aR0hAyqS64i6PYG0JD24Yq9Ijg9IUWfyBuLCo+wTka/jqD88rVJvUO91QfXNE7Sk1jHk3xBfcPZfF3cuOeJhS/5SbZdgf4yrGIwNNtWu+hxRoL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ginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2018 13:17:57.2445 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b2f59a35-435f-4862-f7ce-08d5efd58ac7 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 The register is used to add and delete eRPs from the eRP table. Signed-off-by: Ido Schimmel Reviewed-by: Jiri Pirko --- drivers/net/ethernet/mellanox/mlxsw/reg.h | 113 ++++++++++++++++++++++ 1 file changed, 113 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h index cf07436c911b..5acef249e776 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/reg.h +++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h @@ -2504,6 +2504,118 @@ static inline void mlxsw_reg_ptce2_pack(char *payload, bool valid, mlxsw_reg_ptce2_tcam_region_info_memcpy_to(payload, tcam_region_info); } +/* PERPT - Policy-Engine ERP Table Register + * ---------------------------------------- + * This register adds and removes eRPs from the eRP table. + */ +#define MLXSW_REG_PERPT_ID 0x3021 +#define MLXSW_REG_PERPT_LEN 0x80 + +MLXSW_REG_DEFINE(perpt, MLXSW_REG_PERPT_ID, MLXSW_REG_PERPT_LEN); + +/* reg_perpt_erpt_bank + * eRP table bank. + * Range 0 .. cap_max_erp_table_banks - 1 + * Access: Index + */ +MLXSW_ITEM32(reg, perpt, erpt_bank, 0x00, 16, 4); + +/* reg_perpt_erpt_index + * Index to eRP table within the eRP bank. + * Range is 0 .. cap_max_erp_table_bank_size - 1 + * Access: Index + */ +MLXSW_ITEM32(reg, perpt, erpt_index, 0x00, 0, 8); + +enum mlxsw_reg_perpt_key_size { + MLXSW_REG_PERPT_KEY_SIZE_2KB, + MLXSW_REG_PERPT_KEY_SIZE_4KB, + MLXSW_REG_PERPT_KEY_SIZE_8KB, + MLXSW_REG_PERPT_KEY_SIZE_12KB, +}; + +/* reg_perpt_key_size + * Access: OP + */ +MLXSW_ITEM32(reg, perpt, key_size, 0x04, 0, 4); + +/* reg_perpt_bf_bypass + * 0 - The eRP is used only if bloom filter state is set for the given + * rule. + * 1 - The eRP is used regardless of bloom filter state. + * The bypass is an OR condition of region_id or eRP. See PERCR.bf_bypass + * Access: RW + */ +MLXSW_ITEM32(reg, perpt, bf_bypass, 0x08, 8, 1); + +/* reg_perpt_erp_id + * eRP ID for use by the rules. + * Access: RW + */ +MLXSW_ITEM32(reg, perpt, erp_id, 0x08, 0, 4); + +/* reg_perpt_erpt_base_bank + * Base eRP table bank, points to head of erp_vector + * Range is 0 .. cap_max_erp_table_banks - 1 + * Access: OP + */ +MLXSW_ITEM32(reg, perpt, erpt_base_bank, 0x0C, 16, 4); + +/* reg_perpt_erpt_base_index + * Base index to eRP table within the eRP bank + * Range is 0 .. cap_max_erp_table_bank_size - 1 + * Access: OP + */ +MLXSW_ITEM32(reg, perpt, erpt_base_index, 0x0C, 0, 8); + +/* reg_perpt_erp_index_in_vector + * eRP index in the vector. + * Access: OP + */ +MLXSW_ITEM32(reg, perpt, erp_index_in_vector, 0x10, 0, 4); + +/* reg_perpt_erp_vector + * eRP vector. + * Access: OP + */ +MLXSW_ITEM_BIT_ARRAY(reg, perpt, erp_vector, 0x14, 4, 1); + +/* reg_perpt_mask + * Mask + * 0 - A-TCAM will ignore the bit in key + * 1 - A-TCAM will compare the bit in key + * Access: RW + */ +MLXSW_ITEM_BUF(reg, perpt, mask, 0x20, MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN); + +static inline void mlxsw_reg_perpt_erp_vector_pack(char *payload, + unsigned long *erp_vector, + unsigned long size) +{ + unsigned long bit; + + for_each_set_bit(bit, erp_vector, size) + mlxsw_reg_perpt_erp_vector_set(payload, bit, true); +} + +static inline void +mlxsw_reg_perpt_pack(char *payload, u8 erpt_bank, u8 erpt_index, + enum mlxsw_reg_perpt_key_size key_size, u8 erp_id, + u8 erpt_base_bank, u8 erpt_base_index, u8 erp_index, + char *mask) +{ + MLXSW_REG_ZERO(perpt, payload); + mlxsw_reg_perpt_erpt_bank_set(payload, erpt_bank); + mlxsw_reg_perpt_erpt_index_set(payload, erpt_index); + mlxsw_reg_perpt_key_size_set(payload, key_size); + mlxsw_reg_perpt_bf_bypass_set(payload, true); + mlxsw_reg_perpt_erp_id_set(payload, erp_id); + mlxsw_reg_perpt_erpt_base_bank_set(payload, erpt_base_bank); + mlxsw_reg_perpt_erpt_base_index_set(payload, erpt_base_index); + mlxsw_reg_perpt_erp_index_in_vector_set(payload, erp_index); + mlxsw_reg_perpt_mask_memcpy_to(payload, mask); +} + /* PERAR - Policy-Engine Region Association Register * ------------------------------------------------- * This register associates a hw region for region_id's. Changing on the fly @@ -8422,6 +8534,7 @@ static const struct mlxsw_reg_info *mlxsw_reg_infos[] = { MLXSW_REG(prcr), MLXSW_REG(pefa), MLXSW_REG(ptce2), + MLXSW_REG(perpt), MLXSW_REG(perar), MLXSW_REG(ptce3), MLXSW_REG(percr), From patchwork Sun Jul 22 13:16:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 10539313 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 43B011823 for ; Sun, 22 Jul 2018 13:18:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 30D02281F9 for ; Sun, 22 Jul 2018 13:18:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2532B28385; Sun, 22 Jul 2018 13:18:55 +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 70D12281F9 for ; Sun, 22 Jul 2018 13:18:54 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41YQDr5Cw5zDrM8 for ; Sun, 22 Jul 2018 23:18:52 +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="xE1EFcr2"; 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="xE1EFcr2"; 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 41YQD70FhYzDqmj for ; Sun, 22 Jul 2018 23:18:14 +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=bE+8KZAkRrXL/IbW3DTdYTUFyQ8xnS9XO34ZXOQeeRI=; b=xE1EFcr2J4ym5YefYjdOjRfYUNE8PnMG+QI2V581BWlEVyGnR3KpNV4DD3X80VzL/EFtbmY2fJjlqh/rVS9meF+l3Fh5q0LgPXZG3qjylmaq7L7GVOfi4vRZYp/Ok8UDD4OUTY/9yqfIllFJK3oMuv+YgPdoLaNrw45jPo/z5vg= 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:17:58 +0000 From: Ido Schimmel To: linux-internal@mellanox.com Subject: [PATCH net-next mlxsw 04/18] mlxsw: resources: Add Spectrum-2 maximum large key ID resource Date: Sun, 22 Jul 2018 16:16:58 +0300 Message-Id: <20180722131712.30578-5-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: 125cc654-0cab-4aa4-b492-08d5efd58b67 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:KDYCJyfAabdo5gSFzpkC6Epuu8AdFuFRvace0UzWnoQZ3K6G0yDfJ4rVrCaEvrBjt4mUV5SNtaoBZMnNcSRRPUrvUaOIcCUdhMqq/ranoPyOZzcwYz2pTvyIDA+sl5Py0wKUDyvmP4lMs9SAREG8ahjY5ifBcEM4XgEPz+ZsU7T0zcEP8xrrmWW5Tq1Mc8hC2Pn6DITcEFwur8pQ/BoQQyPFtKk5lh/cBZE+AU67iIvDzY620uYgyLlNM87f8jAE; 25:jgT51X2vq33JTBP94HV/Txp1HXr0v7Bdb6wflq+ZEt+IhLOsKCHjZcedOfK7/w2flBxW9qShif4YVSSZENKziGNCoNGilS8jMV6KgpLL7GjCYnC6kqVftBynp0w3PjUh0NV9XhVueCt+aSRvknwQn5a9Z9ZRS0H3dLoV7SmZk/Ieg15c18CQkm9vL5g0+OAL289isCXG16SuGQliFma0VEWsaT4IdaTk0DJqFH4kGsRkK3k5Aw8FnLgEiR94Lq42KRs6iwTPnioplAqwTqxM7Y0NJarUZ2qWUu0AaVAkhukpg3KIrKnKTOfjgG11TYouu6vEDBlnuGKny02+8YcJWg==; 31:ASQ2T7Y+wnHc0axfEI1MsnlvIjUpHJtxwgE1gPGuIbuRQkQR4eRPjOPVfO+L+3ifdQl2Og2RG4FcjyQ4FG4S3c8u89UOn2SeKDZcCKAq2Kebp6NNXMynL8/Xe/gGQ50NrxaXj+DGCf0v2kQBtjgRQjVJzPIl0IPKaHg8JDp1HByARCKLPPYBs6c74tMCY/cJY8GDPRd2sk+BGG1zRjuSmv8Lvh3+s2PO40/PqR9hlXY= X-MS-TrafficTypeDiagnostic: HE1PR0501MB2331: X-Microsoft-Exchange-Diagnostics: 1; HE1PR0501MB2331; 20:RJHgwnCSaJE/Jp+8WpiWMsh4EwFc4J2YAzjUMSRiYzVaY8fxfAKP0S6nrG61My7d+BVctN+S8hcUAmx++UKR7B6fHIKz8+xAQQARRc6qQdrCnwBk06ntuCG9pMzbtk6yUEelYztUBsdOZOSKfUUy7oSHwP6N1lMV47ymeUCD4Wcc3Vu423YL3iprTDtZz8JYDVidISre3otDbUZK+g6JE5jeOn03sxTK5w2GnkPGa6lauFzzs5xJ8O8Lr8URMZmyn17+45XgpK7AsR+RxO+1moEEmuTYJdLT5yTlvPpBHClVxbfz3q8Viq2Q4JImusU59gKuspKrqKgZLWlC4r9Lv83PYOtyWGfZtgS9ebGynjEWSrMpW/qFNr+0wqIDuKZMWPjRyn9cSGToqaHj91YILCyPZUnXIXWv5K9dnEd1hocp+LWFDD5IpqUPdr3dSkEK1zVOGr8vxDvNmvoaQdJ1+pdvUp7wjnoDnPecppEbtYTpVEn/wwwiuwi3R3LXah95; 4:JSQBYurPm014XkCD0fLXA9NkY9fJkbTotroO4EUBuK1qBGa9ykbIjRW7mzTavyCcte3BOHN8OhkA9g5jt8fWas2GylCaz8PCw8f64cMHMJpG7+p11Ks7lPzXfXb6zPGlS3oGgOAQW36MqInVfm5GbiZGHgcEiUzm8dO7UDfiTQ4QpFhccUTcwQov7PS4cCZcH+AbZ396l8fY/SN95b+Q5XMSJULAS5rgq3u8Zad2BBn6Vqoz/ba5p47dzZlXlS6j415G7jxlzqxwVMsxlfP9tw== 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)(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:cYU8zh0m0gCQJLWaKSr/kyvFnvWUywgChLtPC5+?= x4oLOGSWZwhljfu7FkrBvOSkwp2zYVtKib9B7oAlt/1bUKSCMajPtxBOXeIHSqbfaDY81j/2wiWT3PJvxIliWm0ymelne4IFU0nYBS9ULsuEsADCYyL5ZFS11wIv4vzQ6x6MpUamcvlxffzifkaz0kIRgVmc7gL57xZCkur/ga12ivlgIZA6lKo8n2uuob64AvGQWEZkhqqDEnb3ouq7CZaYGH59lgurPgrh+EMNlxvBa7Xxj8bvszAJYGUnfp2/sd+Gjf0+pBLzC3vRI1R/4DF3ZWUlJX3BwxpHdZnAS3QM1AapQP5oglziHr2vhc5I8HVnTsl6ox2cE9ZgDUV1qSxecsQLjW0I2/dAeKbK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7hvXtXyCNf1U0olhkGc8Ri941RP2Z02xk9MRSwy+bZp1jDtG9ijUY4bxXgWrRNOJEhhzYEc6/6C9 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2018 13:17:58.2601 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 125cc654-0cab-4aa4-b492-08d5efd58b67 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 Add a resource to make sure we do not exceed the maximum number of supported large key IDs in a region. Signed-off-by: Ido Schimmel Reviewed-by: Jiri Pirko --- drivers/net/ethernet/mellanox/mlxsw/resources.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlxsw/resources.h b/drivers/net/ethernet/mellanox/mlxsw/resources.h index f672a7b71de7..4f84c7c8117b 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/resources.h +++ b/drivers/net/ethernet/mellanox/mlxsw/resources.h @@ -65,6 +65,7 @@ enum mlxsw_res_id { MLXSW_RES_ID_ACL_FLEX_KEYS, MLXSW_RES_ID_ACL_MAX_ACTION_PER_RULE, MLXSW_RES_ID_ACL_ACTIONS_PER_SET, + MLXSW_RES_ID_ACL_MAX_LARGE_KEY_ID, MLXSW_RES_ID_MAX_CPU_POLICERS, MLXSW_RES_ID_MAX_VRS, MLXSW_RES_ID_MAX_RIFS, @@ -108,6 +109,7 @@ static u16 mlxsw_res_ids[] = { [MLXSW_RES_ID_ACL_FLEX_KEYS] = 0x2910, [MLXSW_RES_ID_ACL_MAX_ACTION_PER_RULE] = 0x2911, [MLXSW_RES_ID_ACL_ACTIONS_PER_SET] = 0x2912, + [MLXSW_RES_ID_ACL_MAX_LARGE_KEY_ID] = 0x2942, [MLXSW_RES_ID_MAX_CPU_POLICERS] = 0x2A13, [MLXSW_RES_ID_MAX_VRS] = 0x2C01, [MLXSW_RES_ID_MAX_RIFS] = 0x2C02, From patchwork Sun Jul 22 13:16:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 10539305 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 0173E1823 for ; Sun, 22 Jul 2018 13:18:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E2F40281F9 for ; Sun, 22 Jul 2018 13:18:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D5F5E28385; Sun, 22 Jul 2018 13:18:39 +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 2D2D9281F9 for ; Sun, 22 Jul 2018 13:18:39 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41YQDY2ntNzDqnc for ; Sun, 22 Jul 2018 23:18:37 +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="i3N0ZF5c"; 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.57; 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="i3N0ZF5c"; dkim-atps=neutral Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80057.outbound.protection.outlook.com [40.107.8.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41YQD542N5zDqmf for ; Sun, 22 Jul 2018 23:18:13 +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=9FlZH9V35VVWYSdew7X57DmJFVcpO4wcI7O6tBgjktY=; b=i3N0ZF5c5kg2gHQpZdnwS6FBmTIw9dYn9w9qvWNvUTLm+2anfxW5X9/KBsF8CnT2aMCsjmDoDBh/K9ZJc3cd8KIrVqQNlHGDcLveroEtbFxsHJCURwSNFMnt7Sdsh0Szi7akojbS5Vg0Qs4iiw0syxAZPAh2VUbZn7mmy6D2mOc= 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:17:59 +0000 From: Ido Schimmel To: linux-internal@mellanox.com Subject: [PATCH net-next mlxsw 05/18] mlxsw: resources: Add Spectrum-2 eRP resources Date: Sun, 22 Jul 2018 16:16:59 +0300 Message-Id: <20180722131712.30578-6-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: 5d4ab917-3924-48ad-8274-08d5efd58c39 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:dhVvcZzSkckGopxK/lICIb8E9QCSBnY2s0d4xWMMpp3HLiFscS3CN00p7+uJSFTBgrMRMHYQEP0VeO9Sf9qW4Elltov5Qd9a6LxKDxohlWNA6zyzfmLCqo9MrF/dgilh2CeuAp8Q7lwuWfc27jaTWzd/mXkOYUhJIuBe24OhtBK3U/+Q+b0oQL5+dvMoX7hZ8w4+efoOlGvJ8VB6rGK3tz08Ngzr/G+c/BCKZD6RF9+OjkRsoLxQdlo/rSp5/Eka; 25:BouLuSGgKYQckPnd7hvaiV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wbZzbVY6v/dXQPXPrHm/VfUu0EcrSqNb7od4gfG1FaId5S1l9RdJ1JLyEfyE; 4:raon6Zq/nqMnDDeRrW3TciZDgBMBCd7Tt5DbPAXA5VqtbUsAgRXrl6Oy6PUmKVC2J5FLV0+X2gH85HfjFn5Wah30s04VipfPctOpATP0SHMQlhX9G9M1ltm71eaMzYOJwUp3jA+awVGHm32qGbT/AQYGcphARaxAkDCfk1vRbAfW+kmsJQ+Li3WFzHwCwonDAHWmluzKCDi3XVJzzHLJmrAOrc8uS1hg0AFYZR1D3SPCEbIw6Em1fVNemhIFYkEDRqV6/adrON1p59QLLOsZdg== 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)(376002)(366004)(136003)(346002)(396003)(39860400002)(199004)(189003)(47776003)(956004)(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:LLkYhOGLNhUc8LX67n8TxG4i4fdVX8hQeMVig9p?= zMpGL378X/Naa3GI2q3C4tB7RK/GN47lrdA/bmbaqMGtte9ol6UUD+79F/JI8fcWyjbVu224+IaT6yrQXY2AChJUYJs5A29pyyurhlPYG19LMm8Q4xDYihHYy6taRpVVf+JdcwPBaLESLxuNT6C+1STR1vu66ZHPyaRYFUFUsuNRjP4/VjLfaWwz0C1Dy/8JI9C6MlBh5El1ZigDnn+9fo/5LncgLpm8e04nnfIoLjgpm8QuF4GJko8Ww6KO5CPGiYPWgNPBWmyjZ5AdleYFijt/9S6QxK/eVrqHffyH8MrGbv8Mb9TiSgkiJRaQT+v7wpQ1U2P+oHwaG320RGnSWXS8OzplNP99jojHw9BNUVN31AWXsMG7vR4mcolTpZjr7BTggrZWgz+jrpNzctnPKPu4DXOWvNlKsKts2KUEVrAyuisXE6px3f5kEuOj6NeJESJfzNF//Vjp47Q4BMVUzDdmyCG2YuTVAF7mE47qXDQJG+jAkCxcwd8j6Cd6RpPUc28K9eOAav2TfwXIMuGAvW/QS1W869jhRdSIUEm82xye8NpUfqveLJGNZpWV0TfKZtd5a4MVPGSqTYNPRksJfwMjQQs4dbX/8MMVsNPYS/PlXtCVaRMO1DditiiwIDFxjOneG7OFuUrqesxRp65uwR9T++YqKZF6WBTN1v2rlvCZnpHjqp3AJ2S65NY2Y/Gu4hHvbQGatelMlwX5MvvDR9avszeSyd76XlattOL70f6RX9q8697eT+J04ti+Mf9FiwGmLsPY3RtzWVkq6vwac2KAvZWUrlhhc+VAbKq2/c0vNvWHuiGTz2aJRaENwsRr6nHQ6VbXm5ONXbkR4/Fto3hG+hVlR3Wp8GP+LhH0SeYYSzPuWXmLsueCkKp1Ndl0g2vm8mAc60slbkcz9b/MK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BkS6bME594+r1MNrFq1HszwdT/vqplMStmpzJiG8iVlzPt51aijS8YH7gBbEHAiAvKbvYVyDZ+BEyvx7ydkoSRTugq1fCFgFWcTSCoc/hOp2l1/DRVhNYZ8f4GFYurW5vQuVGLCNHW8/fa/Bew==; 5:zEaWmajv7px4725r0dI6MmjxY7PCxPxVDFm8VoZCsQu7lpEwgeWOVXU0TxbnZdgiU8jKO1i72MHXKqPqyXYZpMPyMcYVdzOhMSrhWsdEGiRcLUmZ4EAOLL3SBP/HH4WntbEfLXqXKHxwpxq3UNvyPs9APhXvf04Nr1aychlnh9M=; 7:cMx5ieHo6kMNjODT6onFx0RbWI5CCSz1iu7/btdd2Ri/82VPsdWqi8G6Ez+Nf+NsQLqtREwanlAsASQwlwt4of3yjdV2nvLjZ9yyGesbhyMV0KvljWNt5RdW+z3LxqnMgxW8M0gcFXFYbsOX3gKqdM1JhB4dhwUDVKy7tjMXfbNNtiYxsV/lUh8TrD4VuXe2xdD+98X20GOzzCrFE8RjJ4KCpIAkWfo5Bmz283hOwYD5phn4gOJ+pPuO8YxYZq2/ SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2018 13:17:59.6663 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5d4ab917-3924-48ad-8274-08d5efd58c39 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 Add the following resources to be used by A-TCAM code: * Maximum number of eRP banks * Maximum size of eRP bank * Number of eRP entries required for a 2/4/8/12 key blocks mask Signed-off-by: Ido Schimmel Reviewed-by: Jiri Pirko --- drivers/net/ethernet/mellanox/mlxsw/resources.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlxsw/resources.h b/drivers/net/ethernet/mellanox/mlxsw/resources.h index 4f84c7c8117b..bf650f2cd5af 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/resources.h +++ b/drivers/net/ethernet/mellanox/mlxsw/resources.h @@ -65,7 +65,13 @@ enum mlxsw_res_id { MLXSW_RES_ID_ACL_FLEX_KEYS, MLXSW_RES_ID_ACL_MAX_ACTION_PER_RULE, MLXSW_RES_ID_ACL_ACTIONS_PER_SET, + MLXSW_RES_ID_ACL_MAX_ERPT_BANKS, + MLXSW_RES_ID_ACL_MAX_ERPT_BANK_SIZE, MLXSW_RES_ID_ACL_MAX_LARGE_KEY_ID, + MLXSW_RES_ID_ACL_ERPT_ENTRIES_2KB, + MLXSW_RES_ID_ACL_ERPT_ENTRIES_4KB, + MLXSW_RES_ID_ACL_ERPT_ENTRIES_8KB, + MLXSW_RES_ID_ACL_ERPT_ENTRIES_12KB, MLXSW_RES_ID_MAX_CPU_POLICERS, MLXSW_RES_ID_MAX_VRS, MLXSW_RES_ID_MAX_RIFS, @@ -109,7 +115,13 @@ static u16 mlxsw_res_ids[] = { [MLXSW_RES_ID_ACL_FLEX_KEYS] = 0x2910, [MLXSW_RES_ID_ACL_MAX_ACTION_PER_RULE] = 0x2911, [MLXSW_RES_ID_ACL_ACTIONS_PER_SET] = 0x2912, + [MLXSW_RES_ID_ACL_MAX_ERPT_BANKS] = 0x2940, + [MLXSW_RES_ID_ACL_MAX_ERPT_BANK_SIZE] = 0x2941, [MLXSW_RES_ID_ACL_MAX_LARGE_KEY_ID] = 0x2942, + [MLXSW_RES_ID_ACL_ERPT_ENTRIES_2KB] = 0x2950, + [MLXSW_RES_ID_ACL_ERPT_ENTRIES_4KB] = 0x2951, + [MLXSW_RES_ID_ACL_ERPT_ENTRIES_8KB] = 0x2952, + [MLXSW_RES_ID_ACL_ERPT_ENTRIES_12KB] = 0x2953, [MLXSW_RES_ID_MAX_CPU_POLICERS] = 0x2A13, [MLXSW_RES_ID_MAX_VRS] = 0x2C01, [MLXSW_RES_ID_MAX_RIFS] = 0x2C02, From patchwork Sun Jul 22 13:17:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 10539311 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 4B07F1805 for ; Sun, 22 Jul 2018 13:18:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3291D281F9 for ; Sun, 22 Jul 2018 13:18:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 26AB628384; Sun, 22 Jul 2018 13:18:51 +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 C6F5228372 for ; Sun, 22 Jul 2018 13:18:48 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41YQDk5LXvzDqyG for ; Sun, 22 Jul 2018 23:18:46 +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="lwqK3453"; 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.57; 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="lwqK3453"; dkim-atps=neutral Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80057.outbound.protection.outlook.com [40.107.8.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41YQD66Wx1zDqmf for ; Sun, 22 Jul 2018 23:18:14 +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=HF2MUUOrheRPBXA1gckOu7i5crYh8ZMSaMJ+nxilUZc=; b=lwqK3453jSDl6hRQmjXkyc61aRF64gJL5Eew4c5c4CNS9Kg3GIwQl+HOWFJl8NuhOOC5uKcCPIIormdGgR/OgRHaAsm8INVfEGhM4qXWPRinR46gk4/2sulqkLb93I2a0Q8/csbgQkF1MerdSxwYUtB6wFecreaOPRcAxeXRZ3w= 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:00 +0000 From: Ido Schimmel To: linux-internal@mellanox.com Subject: [PATCH net-next mlxsw 06/18] mlxsw: spectrum_acl: Implement common eRP core Date: Sun, 22 Jul 2018 16:17:00 +0300 Message-Id: <20180722131712.30578-7-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: 0e0ceb8d-49fe-4809-182c-08d5efd58cd2 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:Zv+ot0SaYX40E5kV/un7LWUi4SHPBhJx6Hwdg/V2TR7avfn/8hZaF4K2zbX7wYPShcN65BFQYC4mAhZYyNKc/psFbUzNRq+C26Oc+t4Y6d1eb+G8t83GHwWvYzCCLRP7F92KqBBNyUsKPEjJ9Hfr4kH9q2uQV5HcDODhHH3E8QTHvTb0Xa89KEN0y32uvMZy9GWx0Lh+uxtleKrdjX85233m0+c+il2TJmHXoSZfh3KOXq2ufXUfdq4SUPtqwRYi; 25:TGsIIV2z4ayJ0kku/wwlZknXglQyvKogSXlVmUuw33i1HX5tQP0ECpq+VQYx79t5v/RwHziyLHicph5US39CEUrJtA7KxVHUZlNs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ivGGW4RFVolttXJBqQQHJXnTCN69suT8Ze1MnHsUnh95tUQHpTg4QXtbaw4l6/rJupyBpcVqK6N+GRaXkSgCzyBWXrtscfgW1fCYOuxV+rQVzDfMeIbYYrLnT22fPotqVKhoRpaX9kzuzdUPot/Db+XQ9YfVjsg9yBI03JoiSawkR6xPVlxRT3uwIajNM3+lypIdpX5vT66EeuCMUohNAm5rZ2W/QBKejEZEUlr0tkrtHKKq5yJApsWSc5aPr3WAe8gdee7RIlTKfaTjg== 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)(53946003)(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:JiMdzyVFgiA2rsdQ3NXgJj/xdYTwikX1hnLY6ea?= VPwNR9VBsUoEkyt8c67wBX5/ucg/dsfFgG2hLmwwUBsgS3pINQJsTOw/ul+GzC12NJwcVCsLhQLwmR0qp0/gMOkAhXFseKhPPCRlPqOw5qdrR1FfyogJiAJcvdnovnaZ2h/xnUbwXTSDjOLldkURIF/7MqQFVnNrqcJ6OkL+6N7w42LXIxDEqGKdgBF/3PbM6qzIa/hpqeASlm4K5di6QdHxWCVedYMI6fATyHJY2qOOFQbX1Cv6Xbwx5fSGD8jm08EoGW85wv85Do43sdatjgq5nOIPnfjn6uUMderpUVYwdfMIDFMVEIUqGDE/nRNqHCiEWUuoq3G9QUMn4ErxPTv9/KLALkHknu+4N4qWb5es3Ff6UWd2r/T9Wv594ygE74axljG39KPJTZ9IyLeKrX8w4rDa0+JYrQ2EA61uKfJ/HENgVhTZXVDssoJ9hPLBBLok5Fh0kFLzzc21fVFxxTcIqDOFat7todFo9tUGDBBH3GSBQX7GE2ioqG+lyef8BG9P8GOkMmRj+tIqb/YpczT91KQKInGcMEA2Cn8UT5ioYWzKZ9eOxtZEDlG2AXQ0wvh67otBs2EDQIXLrNYoktXH+P7VRIHFVQonRzeEm6ST6XTHViWxk6Hbpn8toUMXS+IP5X/tba6j0lldrJ7Lu4LHV1Zc6lywooWavjDDY/ladFoZazqqKdrevQBwr6xjjwCqeSuDGQFnExusPCVZ2nQB8V25DmJpNMx6hls4P5IzmxR8UqMU50qwovR/YqUSN3MDGtKhk2gksN3xAQpLwVylds9enxq9pGpsP7CSDsPKFK5WCbt6Tc414E3/oSkOs1ZsgtmwfvYgFbebLxRaSFmcc1WOcvLb0o2glUIlUWyKHOu76TZBmpLoFdXruHKRZ/Ei2fUOCk5KNZuQg4YA15YniDazBDCQp2Ys7vDr5Zz69LJYik4+xNN8yB9PIU9a96FH1iMX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vL8gXIiBzMbRj+z8U4CQUVV5usCzgMi5gm5X2+DgWQdQ5Q5EBSNp+NvDzQZnqUHzEQtuwGm18hYG0IFLUeK9foNzTEL8l0dDjLlyfr1TEP78uSZia+6w+3XJq8U6+oLkO04Ib3q86QVcbPZHwMvZ2GMd7kDBVZQ==; 5:AoRzUw9ePHqDlJ+FvJucN6l+LjgFydWBhp56gSHDfZrymBP1/vn79s+tqhyCYXnab75Wz1JC4HYI1YSvvsQiILCrZL+EuAaOufpM1F590d980LwRMNvgd5cukHj79Z5EzDSNQef1IkLd1eC2q66gQl80OUoje27LenEWXgSxqXA=; 7:1nKvHAosEOM0j8WTUQ3ubhQbi+UsTb6L4mA4lTKCAbd9VG24ev4j9kOdu0aCNvb+bMTO5LgId9mGjldT84/M6ZMbVr0bcRYZ/l9r1+bGHm9TxVWvP+oQQRYN1u+WmKjugs3iIOtOzI99O2mZ/Q6v9CNXJfHogAMUUyC8RZ+i5mOSOdSzpKFfuFl5HTS0WRoShNmjMZozl2BtkvHecLb68WSbK9C/zXh2mzOItssqhZ2cPEECzDy9vY5n8BnR37Yi SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2018 13:18:00.6819 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0e0ceb8d-49fe-4809-182c-08d5efd58cd2 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 When rules are inserted into the A-TCAM they are associated with a mask, which is part of the lookup key: { masked key, mask ID, region ID }. These masks are called rule patterns (RP) and the aggregation of several masks into one (to be introduced in follow-up patch sets) is called an extended RP (eRP). When a packet undergoes a lookup in an ACL region it is masked by the current set of eRPs used by the region, looking for an exact match. Eventually, the rule with the highest priority is picked. These eRPs are stored in several global banks to allow for lookup to occur using several eRPs simultaneously. At first, an ACL region will only require a single mask - upon the insertion of the first rule. In this case, the region can use the "master RP" which is composed by OR-ing all the masks used by the region. This mask is a property of the region and thus there is no need to use the above mentioned banks. At some point, a second mask will be needed. In this case, the region will need to allocate an eRP table from the above mentioned banks and insert its masks there. From now on, upon lookup, the eRP table used by the region will be fetched from the eRP banks - using {eRP bank, Index within the bank} - and the eRPs present in the table will be used to mask the packet. Note that masks with consecutive indexes are inserted into consecutive banks. When rules are deleted and a region only needs a single mask once again it can free its eRP table and use the master RP. The above logic is implemented in the eRP core and represented using the following state machine: +------------+ create mask - as master RP +---------------+ | +--------------------------------> | | no masks | | single mask | | <--------------------------------+ | +------------+ delete mask +-----+--^------+ | | | | create mask - | | delete mask - create mask transition to use eRP | | transition to +--------+ table | | use master RP | | | | | | | | +----v--------+----+ create mask +----v--+-----+ | <-------------------------------+ | | multiple masks | | two masks | | +-------------------------------> | +------------------+ delete mask - if two +-------------+ remaining The code that actually configures rules in the A-TCAM will interface with the eRP core by getting or putting an eRP based on the required mask used by the rule. Signed-off-by: Ido Schimmel --- Notes: v2: * Fix typo in commit message s/exact/exact match/ * Implement mlxsw_sp_acl_erp_no_mask_destroy() as WARN_ON(1) * Cast to 'u32 *' instead of 'void *' * Do not break lines at 80 chars where cure is worse than the disease drivers/net/ethernet/mellanox/mlxsw/Kconfig | 1 + drivers/net/ethernet/mellanox/mlxsw/Makefile | 2 +- .../mellanox/mlxsw/spectrum_acl_erp.c | 1019 +++++++++++++++++ .../mellanox/mlxsw/spectrum_acl_tcam.h | 40 + 4 files changed, 1061 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_erp.c diff --git a/drivers/net/ethernet/mellanox/mlxsw/Kconfig b/drivers/net/ethernet/mellanox/mlxsw/Kconfig index 82827a8d3d67..8a291eb36c64 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/Kconfig +++ b/drivers/net/ethernet/mellanox/mlxsw/Kconfig @@ -78,6 +78,7 @@ config MLXSW_SPECTRUM depends on IPV6 || IPV6=n depends on NET_IPGRE || NET_IPGRE=n depends on IPV6_GRE || IPV6_GRE=n + select GENERIC_ALLOCATOR select PARMAN select MLXFW default m diff --git a/drivers/net/ethernet/mellanox/mlxsw/Makefile b/drivers/net/ethernet/mellanox/mlxsw/Makefile index 4a1069166119..68fa44a41485 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/Makefile +++ b/drivers/net/ethernet/mellanox/mlxsw/Makefile @@ -18,7 +18,7 @@ mlxsw_spectrum-objs := spectrum.o spectrum_buffers.o \ spectrum1_kvdl.o spectrum2_kvdl.o \ spectrum_kvdl.o \ spectrum_acl_tcam.o spectrum_acl_ctcam.o \ - spectrum_acl_atcam.o \ + spectrum_acl_atcam.o spectrum_acl_erp.o \ spectrum1_acl_tcam.o spectrum2_acl_tcam.o \ spectrum_acl.o \ spectrum_flower.o spectrum_cnt.o \ diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_erp.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_erp.c new file mode 100644 index 000000000000..960f29140b43 --- /dev/null +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_erp.c @@ -0,0 +1,1019 @@ +/* + * drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_erp.c + * Copyright (c) 2018 Mellanox Technologies. All rights reserved. + * Copyright (c) 2018 Ido Schimmel + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "core.h" +#include "reg.h" +#include "spectrum.h" +#include "spectrum_acl_tcam.h" + +/* gen_pool_alloc() returns 0 when allocation fails, so use an offset */ +#define MLXSW_SP_ACL_ERP_GENALLOC_OFFSET 0x100 +#define MLXSW_SP_ACL_ERP_MAX_PER_REGION 16 + +struct mlxsw_sp_acl_erp_core { + unsigned int erpt_entries_size[MLXSW_SP_ACL_ATCAM_REGION_TYPE_MAX + 1]; + struct gen_pool *erp_tables; + struct mlxsw_sp *mlxsw_sp; + unsigned int num_erp_banks; +}; + +struct mlxsw_sp_acl_erp_key { + char mask[MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN]; +}; + +struct mlxsw_sp_acl_erp { + struct mlxsw_sp_acl_erp_key key; + u8 id; + u8 index; + refcount_t refcnt; + DECLARE_BITMAP(mask_bitmap, MLXSW_SP_ACL_TCAM_MASK_LEN); + struct list_head list; + struct rhash_head ht_node; + struct mlxsw_sp_acl_erp_table *erp_table; +}; + +struct mlxsw_sp_acl_erp_master_mask { + DECLARE_BITMAP(bitmap, MLXSW_SP_ACL_TCAM_MASK_LEN); + unsigned int count[MLXSW_SP_ACL_TCAM_MASK_LEN]; +}; + +struct mlxsw_sp_acl_erp_table { + struct mlxsw_sp_acl_erp_master_mask master_mask; + DECLARE_BITMAP(erp_id_bitmap, MLXSW_SP_ACL_ERP_MAX_PER_REGION); + DECLARE_BITMAP(erp_index_bitmap, MLXSW_SP_ACL_ERP_MAX_PER_REGION); + struct list_head atcam_erps_list; + struct rhashtable erp_ht; + struct mlxsw_sp_acl_erp_core *erp_core; + struct mlxsw_sp_acl_atcam_region *aregion; + const struct mlxsw_sp_acl_erp_table_ops *ops; + unsigned long base_index; + unsigned int num_atcam_erps; + unsigned int num_max_atcam_erps; +}; + +static const struct rhashtable_params mlxsw_sp_acl_erp_ht_params = { + .key_len = sizeof(struct mlxsw_sp_acl_erp_key), + .key_offset = offsetof(struct mlxsw_sp_acl_erp, key), + .head_offset = offsetof(struct mlxsw_sp_acl_erp, ht_node), +}; + +struct mlxsw_sp_acl_erp_table_ops { + struct mlxsw_sp_acl_erp * + (*erp_create)(struct mlxsw_sp_acl_erp_table *erp_table, + struct mlxsw_sp_acl_erp_key *key); + void (*erp_destroy)(struct mlxsw_sp_acl_erp_table *erp_table, + struct mlxsw_sp_acl_erp *erp); +}; + +static struct mlxsw_sp_acl_erp * +mlxsw_sp_acl_erp_mask_create(struct mlxsw_sp_acl_erp_table *erp_table, + struct mlxsw_sp_acl_erp_key *key); +static void +mlxsw_sp_acl_erp_mask_destroy(struct mlxsw_sp_acl_erp_table *erp_table, + struct mlxsw_sp_acl_erp *erp); +static struct mlxsw_sp_acl_erp * +mlxsw_sp_acl_erp_second_mask_create(struct mlxsw_sp_acl_erp_table *erp_table, + struct mlxsw_sp_acl_erp_key *key); +static void +mlxsw_sp_acl_erp_second_mask_destroy(struct mlxsw_sp_acl_erp_table *erp_table, + struct mlxsw_sp_acl_erp *erp); +static struct mlxsw_sp_acl_erp * +mlxsw_sp_acl_erp_first_mask_create(struct mlxsw_sp_acl_erp_table *erp_table, + struct mlxsw_sp_acl_erp_key *key); +static void +mlxsw_sp_acl_erp_first_mask_destroy(struct mlxsw_sp_acl_erp_table *erp_table, + struct mlxsw_sp_acl_erp *erp); +static void +mlxsw_sp_acl_erp_no_mask_destroy(struct mlxsw_sp_acl_erp_table *erp_table, + struct mlxsw_sp_acl_erp *erp); + +static const struct mlxsw_sp_acl_erp_table_ops erp_multiple_masks_ops = { + .erp_create = mlxsw_sp_acl_erp_mask_create, + .erp_destroy = mlxsw_sp_acl_erp_mask_destroy, +}; + +static const struct mlxsw_sp_acl_erp_table_ops erp_two_masks_ops = { + .erp_create = mlxsw_sp_acl_erp_mask_create, + .erp_destroy = mlxsw_sp_acl_erp_second_mask_destroy, +}; + +static const struct mlxsw_sp_acl_erp_table_ops erp_single_mask_ops = { + .erp_create = mlxsw_sp_acl_erp_second_mask_create, + .erp_destroy = mlxsw_sp_acl_erp_first_mask_destroy, +}; + +static const struct mlxsw_sp_acl_erp_table_ops erp_no_mask_ops = { + .erp_create = mlxsw_sp_acl_erp_first_mask_create, + .erp_destroy = mlxsw_sp_acl_erp_no_mask_destroy, +}; + +u8 mlxsw_sp_acl_erp_id(const struct mlxsw_sp_acl_erp *erp) +{ + return erp->id; +} + +static unsigned int +mlxsw_sp_acl_erp_table_entry_size(const struct mlxsw_sp_acl_erp_table *erp_table) +{ + struct mlxsw_sp_acl_atcam_region *aregion = erp_table->aregion; + struct mlxsw_sp_acl_erp_core *erp_core = erp_table->erp_core; + + return erp_core->erpt_entries_size[aregion->type]; +} + +static int mlxsw_sp_acl_erp_id_get(struct mlxsw_sp_acl_erp_table *erp_table, + u8 *p_id) +{ + u8 id; + + id = find_first_zero_bit(erp_table->erp_id_bitmap, + MLXSW_SP_ACL_ERP_MAX_PER_REGION); + if (id < MLXSW_SP_ACL_ERP_MAX_PER_REGION) { + __set_bit(id, erp_table->erp_id_bitmap); + *p_id = id; + return 0; + } + + return -ENOBUFS; +} + +static void mlxsw_sp_acl_erp_id_put(struct mlxsw_sp_acl_erp_table *erp_table, + u8 id) +{ + __clear_bit(id, erp_table->erp_id_bitmap); +} + +static void +mlxsw_sp_acl_erp_master_mask_bit_set(unsigned long bit, + struct mlxsw_sp_acl_erp_master_mask *mask) +{ + if (mask->count[bit]++ == 0) + __set_bit(bit, mask->bitmap); +} + +static void +mlxsw_sp_acl_erp_master_mask_bit_clear(unsigned long bit, + struct mlxsw_sp_acl_erp_master_mask *mask) +{ + if (--mask->count[bit] == 0) + __clear_bit(bit, mask->bitmap); +} + +static int +mlxsw_sp_acl_erp_master_mask_update(struct mlxsw_sp_acl_erp_table *erp_table) +{ + struct mlxsw_sp_acl_tcam_region *region = erp_table->aregion->region; + struct mlxsw_sp *mlxsw_sp = region->mlxsw_sp; + char percr_pl[MLXSW_REG_PERCR_LEN]; + char *master_mask; + + mlxsw_reg_percr_pack(percr_pl, region->id); + master_mask = mlxsw_reg_percr_master_mask_data(percr_pl); + bitmap_to_arr32((u32 *) master_mask, erp_table->master_mask.bitmap, + MLXSW_SP_ACL_TCAM_MASK_LEN); + + return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(percr), percr_pl); +} + +static int +mlxsw_sp_acl_erp_master_mask_set(struct mlxsw_sp_acl_erp_table *erp_table, + const struct mlxsw_sp_acl_erp *erp) +{ + unsigned long bit; + int err; + + for_each_set_bit(bit, erp->mask_bitmap, MLXSW_SP_ACL_TCAM_MASK_LEN) + mlxsw_sp_acl_erp_master_mask_bit_set(bit, + &erp_table->master_mask); + + err = mlxsw_sp_acl_erp_master_mask_update(erp_table); + if (err) + goto err_master_mask_update; + + return 0; + +err_master_mask_update: + for_each_set_bit(bit, erp->mask_bitmap, MLXSW_SP_ACL_TCAM_MASK_LEN) + mlxsw_sp_acl_erp_master_mask_bit_clear(bit, + &erp_table->master_mask); + return err; +} + +static int +mlxsw_sp_acl_erp_master_mask_clear(struct mlxsw_sp_acl_erp_table *erp_table, + const struct mlxsw_sp_acl_erp *erp) +{ + unsigned long bit; + int err; + + for_each_set_bit(bit, erp->mask_bitmap, MLXSW_SP_ACL_TCAM_MASK_LEN) + mlxsw_sp_acl_erp_master_mask_bit_clear(bit, + &erp_table->master_mask); + + err = mlxsw_sp_acl_erp_master_mask_update(erp_table); + if (err) + goto err_master_mask_update; + + return 0; + +err_master_mask_update: + for_each_set_bit(bit, erp->mask_bitmap, MLXSW_SP_ACL_TCAM_MASK_LEN) + mlxsw_sp_acl_erp_master_mask_bit_set(bit, + &erp_table->master_mask); + return err; +} + +static struct mlxsw_sp_acl_erp * +mlxsw_sp_acl_erp_generic_create(struct mlxsw_sp_acl_erp_table *erp_table, + struct mlxsw_sp_acl_erp_key *key) +{ + struct mlxsw_sp_acl_erp *erp; + int err; + + erp = kzalloc(sizeof(*erp), GFP_KERNEL); + if (!erp) + return ERR_PTR(-ENOMEM); + + err = mlxsw_sp_acl_erp_id_get(erp_table, &erp->id); + if (err) + goto err_erp_id_get; + + memcpy(&erp->key, key, sizeof(*key)); + bitmap_from_arr32(erp->mask_bitmap, (u32 *) key->mask, + MLXSW_SP_ACL_TCAM_MASK_LEN); + list_add(&erp->list, &erp_table->atcam_erps_list); + refcount_set(&erp->refcnt, 1); + erp_table->num_atcam_erps++; + erp->erp_table = erp_table; + + err = mlxsw_sp_acl_erp_master_mask_set(erp_table, erp); + if (err) + goto err_master_mask_set; + + err = rhashtable_insert_fast(&erp_table->erp_ht, &erp->ht_node, + mlxsw_sp_acl_erp_ht_params); + if (err) + goto err_rhashtable_insert; + + return erp; + +err_rhashtable_insert: + mlxsw_sp_acl_erp_master_mask_clear(erp_table, erp); +err_master_mask_set: + erp_table->num_atcam_erps--; + list_del(&erp->list); + mlxsw_sp_acl_erp_id_put(erp_table, erp->id); +err_erp_id_get: + kfree(erp); + return ERR_PTR(err); +} + +static void +mlxsw_sp_acl_erp_generic_destroy(struct mlxsw_sp_acl_erp *erp) +{ + struct mlxsw_sp_acl_erp_table *erp_table = erp->erp_table; + + rhashtable_remove_fast(&erp_table->erp_ht, &erp->ht_node, + mlxsw_sp_acl_erp_ht_params); + mlxsw_sp_acl_erp_master_mask_clear(erp_table, erp); + erp_table->num_atcam_erps--; + list_del(&erp->list); + mlxsw_sp_acl_erp_id_put(erp_table, erp->id); + kfree(erp); +} + +static int +mlxsw_sp_acl_erp_table_alloc(struct mlxsw_sp_acl_erp_core *erp_core, + unsigned int num_erps, + enum mlxsw_sp_acl_atcam_region_type region_type, + unsigned long *p_index) +{ + unsigned int num_rows, entry_size; + + /* We only allow allocations of entire rows */ + if (num_erps % erp_core->num_erp_banks != 0) + return -EINVAL; + + entry_size = erp_core->erpt_entries_size[region_type]; + num_rows = num_erps / erp_core->num_erp_banks; + + *p_index = gen_pool_alloc(erp_core->erp_tables, num_rows * entry_size); + if (*p_index == 0) + return -ENOBUFS; + *p_index -= MLXSW_SP_ACL_ERP_GENALLOC_OFFSET; + + return 0; +} + +static void +mlxsw_sp_acl_erp_table_free(struct mlxsw_sp_acl_erp_core *erp_core, + unsigned int num_erps, + enum mlxsw_sp_acl_atcam_region_type region_type, + unsigned long index) +{ + unsigned long base_index; + unsigned int entry_size; + size_t size; + + entry_size = erp_core->erpt_entries_size[region_type]; + base_index = index + MLXSW_SP_ACL_ERP_GENALLOC_OFFSET; + size = num_erps / erp_core->num_erp_banks * entry_size; + gen_pool_free(erp_core->erp_tables, base_index, size); +} + +static struct mlxsw_sp_acl_erp * +mlxsw_sp_acl_erp_table_master_rp(struct mlxsw_sp_acl_erp_table *erp_table) +{ + if (!list_is_singular(&erp_table->atcam_erps_list)) + return NULL; + + return list_first_entry(&erp_table->atcam_erps_list, + struct mlxsw_sp_acl_erp, list); +} + +static int mlxsw_sp_acl_erp_index_get(struct mlxsw_sp_acl_erp_table *erp_table, + u8 *p_index) +{ + u8 index; + + index = find_first_zero_bit(erp_table->erp_index_bitmap, + erp_table->num_max_atcam_erps); + if (index < erp_table->num_max_atcam_erps) { + __set_bit(index, erp_table->erp_index_bitmap); + *p_index = index; + return 0; + } + + return -ENOBUFS; +} + +static void mlxsw_sp_acl_erp_index_put(struct mlxsw_sp_acl_erp_table *erp_table, + u8 index) +{ + __clear_bit(index, erp_table->erp_index_bitmap); +} + +static void +mlxsw_sp_acl_erp_table_locate(const struct mlxsw_sp_acl_erp_table *erp_table, + const struct mlxsw_sp_acl_erp *erp, + u8 *p_erpt_bank, u8 *p_erpt_index) +{ + unsigned int entry_size = mlxsw_sp_acl_erp_table_entry_size(erp_table); + struct mlxsw_sp_acl_erp_core *erp_core = erp_table->erp_core; + unsigned int row; + + *p_erpt_bank = erp->index % erp_core->num_erp_banks; + row = erp->index / erp_core->num_erp_banks; + *p_erpt_index = erp_table->base_index + row * entry_size; +} + +static int +mlxsw_sp_acl_erp_table_erp_add(struct mlxsw_sp_acl_erp_table *erp_table, + struct mlxsw_sp_acl_erp *erp) +{ + struct mlxsw_sp *mlxsw_sp = erp_table->erp_core->mlxsw_sp; + enum mlxsw_reg_perpt_key_size key_size; + char perpt_pl[MLXSW_REG_PERPT_LEN]; + u8 erpt_bank, erpt_index; + + mlxsw_sp_acl_erp_table_locate(erp_table, erp, &erpt_bank, &erpt_index); + key_size = (enum mlxsw_reg_perpt_key_size) erp_table->aregion->type; + mlxsw_reg_perpt_pack(perpt_pl, erpt_bank, erpt_index, key_size, erp->id, + 0, erp_table->base_index, erp->index, + erp->key.mask); + mlxsw_reg_perpt_erp_vector_pack(perpt_pl, erp_table->erp_index_bitmap, + MLXSW_SP_ACL_ERP_MAX_PER_REGION); + mlxsw_reg_perpt_erp_vector_set(perpt_pl, erp->index, true); + return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(perpt), perpt_pl); +} + +static void mlxsw_sp_acl_erp_table_erp_del(struct mlxsw_sp_acl_erp *erp) +{ + char empty_mask[MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN] = { 0 }; + struct mlxsw_sp_acl_erp_table *erp_table = erp->erp_table; + struct mlxsw_sp *mlxsw_sp = erp_table->erp_core->mlxsw_sp; + enum mlxsw_reg_perpt_key_size key_size; + char perpt_pl[MLXSW_REG_PERPT_LEN]; + u8 erpt_bank, erpt_index; + + mlxsw_sp_acl_erp_table_locate(erp_table, erp, &erpt_bank, &erpt_index); + key_size = (enum mlxsw_reg_perpt_key_size) erp_table->aregion->type; + mlxsw_reg_perpt_pack(perpt_pl, erpt_bank, erpt_index, key_size, erp->id, + 0, erp_table->base_index, erp->index, empty_mask); + mlxsw_reg_perpt_erp_vector_pack(perpt_pl, erp_table->erp_index_bitmap, + MLXSW_SP_ACL_ERP_MAX_PER_REGION); + mlxsw_reg_perpt_erp_vector_set(perpt_pl, erp->index, false); + mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(perpt), perpt_pl); +} + +static int +mlxsw_sp_acl_erp_table_enable(struct mlxsw_sp_acl_erp_table *erp_table) +{ + struct mlxsw_sp_acl_tcam_region *region = erp_table->aregion->region; + struct mlxsw_sp *mlxsw_sp = erp_table->erp_core->mlxsw_sp; + char pererp_pl[MLXSW_REG_PERERP_LEN]; + + mlxsw_reg_pererp_pack(pererp_pl, region->id, false, true, 0, + erp_table->base_index, 0); + mlxsw_reg_pererp_erp_vector_pack(pererp_pl, erp_table->erp_index_bitmap, + MLXSW_SP_ACL_ERP_MAX_PER_REGION); + + return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pererp), pererp_pl); +} + +static void +mlxsw_sp_acl_erp_table_disable(struct mlxsw_sp_acl_erp_table *erp_table) +{ + struct mlxsw_sp_acl_tcam_region *region = erp_table->aregion->region; + struct mlxsw_sp *mlxsw_sp = erp_table->erp_core->mlxsw_sp; + char pererp_pl[MLXSW_REG_PERERP_LEN]; + struct mlxsw_sp_acl_erp *master_rp; + + master_rp = mlxsw_sp_acl_erp_table_master_rp(erp_table); + if (!master_rp) + return; + + mlxsw_reg_pererp_pack(pererp_pl, region->id, false, false, 0, 0, + master_rp->id); + mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pererp), pererp_pl); +} + +static int +mlxsw_sp_acl_erp_table_relocate(struct mlxsw_sp_acl_erp_table *erp_table) +{ + struct mlxsw_sp_acl_erp *erp; + int err; + + list_for_each_entry(erp, &erp_table->atcam_erps_list, list) { + err = mlxsw_sp_acl_erp_table_erp_add(erp_table, erp); + if (err) + goto err_table_erp_add; + } + + return 0; + +err_table_erp_add: + list_for_each_entry_continue_reverse(erp, &erp_table->atcam_erps_list, + list) + mlxsw_sp_acl_erp_table_erp_del(erp); + return err; +} + +static int +mlxsw_sp_acl_erp_table_expand(struct mlxsw_sp_acl_erp_table *erp_table) +{ + unsigned int num_erps, old_num_erps = erp_table->num_max_atcam_erps; + struct mlxsw_sp_acl_erp_core *erp_core = erp_table->erp_core; + unsigned long old_base_index = erp_table->base_index; + int err; + + if (erp_table->num_atcam_erps < erp_table->num_max_atcam_erps) + return 0; + + if (erp_table->num_max_atcam_erps == MLXSW_SP_ACL_ERP_MAX_PER_REGION) + return -ENOBUFS; + + num_erps = old_num_erps + erp_core->num_erp_banks; + err = mlxsw_sp_acl_erp_table_alloc(erp_core, num_erps, + erp_table->aregion->type, + &erp_table->base_index); + if (err) + return err; + erp_table->num_max_atcam_erps = num_erps; + + err = mlxsw_sp_acl_erp_table_relocate(erp_table); + if (err) + goto err_table_relocate; + + err = mlxsw_sp_acl_erp_table_enable(erp_table); + if (err) + goto err_table_enable; + + mlxsw_sp_acl_erp_table_free(erp_core, old_num_erps, + erp_table->aregion->type, old_base_index); + + return 0; + +err_table_enable: +err_table_relocate: + erp_table->num_max_atcam_erps = old_num_erps; + mlxsw_sp_acl_erp_table_free(erp_core, num_erps, + erp_table->aregion->type, + erp_table->base_index); + erp_table->base_index = old_base_index; + return err; +} + +static int +mlxsw_sp_acl_erp_region_table_trans(struct mlxsw_sp_acl_erp_table *erp_table) +{ + struct mlxsw_sp_acl_erp_core *erp_core = erp_table->erp_core; + struct mlxsw_sp_acl_erp *master_rp; + int err; + + /* Initially, allocate a single eRP row. Expand later as needed */ + err = mlxsw_sp_acl_erp_table_alloc(erp_core, erp_core->num_erp_banks, + erp_table->aregion->type, + &erp_table->base_index); + if (err) + return err; + erp_table->num_max_atcam_erps = erp_core->num_erp_banks; + + /* Transition the sole RP currently configured (the master RP) + * to the eRP table + */ + master_rp = mlxsw_sp_acl_erp_table_master_rp(erp_table); + if (!master_rp) { + err = -EINVAL; + goto err_table_master_rp; + } + + /* Maintain the same eRP bank for the master RP, so that we + * wouldn't need to update the bloom filter + */ + master_rp->index = master_rp->index % erp_core->num_erp_banks; + __set_bit(master_rp->index, erp_table->erp_index_bitmap); + + err = mlxsw_sp_acl_erp_table_erp_add(erp_table, master_rp); + if (err) + goto err_table_master_rp_add; + + err = mlxsw_sp_acl_erp_table_enable(erp_table); + if (err) + goto err_table_enable; + + return 0; + +err_table_enable: + mlxsw_sp_acl_erp_table_erp_del(master_rp); +err_table_master_rp_add: + __clear_bit(master_rp->index, erp_table->erp_index_bitmap); +err_table_master_rp: + mlxsw_sp_acl_erp_table_free(erp_core, erp_table->num_max_atcam_erps, + erp_table->aregion->type, + erp_table->base_index); + return err; +} + +static void +mlxsw_sp_acl_erp_region_master_mask_trans(struct mlxsw_sp_acl_erp_table *erp_table) +{ + struct mlxsw_sp_acl_erp_core *erp_core = erp_table->erp_core; + struct mlxsw_sp_acl_erp *master_rp; + + mlxsw_sp_acl_erp_table_disable(erp_table); + master_rp = mlxsw_sp_acl_erp_table_master_rp(erp_table); + if (!master_rp) + return; + mlxsw_sp_acl_erp_table_erp_del(master_rp); + __clear_bit(master_rp->index, erp_table->erp_index_bitmap); + mlxsw_sp_acl_erp_table_free(erp_core, erp_table->num_max_atcam_erps, + erp_table->aregion->type, + erp_table->base_index); +} + +static int +mlxsw_sp_acl_erp_region_erp_add(struct mlxsw_sp_acl_erp_table *erp_table, + struct mlxsw_sp_acl_erp *erp) +{ + struct mlxsw_sp_acl_tcam_region *region = erp_table->aregion->region; + struct mlxsw_sp *mlxsw_sp = erp_table->erp_core->mlxsw_sp; + char pererp_pl[MLXSW_REG_PERERP_LEN]; + + mlxsw_reg_pererp_pack(pererp_pl, region->id, false, true, 0, + erp_table->base_index, 0); + mlxsw_reg_pererp_erp_vector_pack(pererp_pl, erp_table->erp_index_bitmap, + MLXSW_SP_ACL_ERP_MAX_PER_REGION); + mlxsw_reg_pererp_erpt_vector_set(pererp_pl, erp->index, true); + + return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pererp), pererp_pl); +} + +static void mlxsw_sp_acl_erp_region_erp_del(struct mlxsw_sp_acl_erp *erp) +{ + struct mlxsw_sp_acl_erp_table *erp_table = erp->erp_table; + struct mlxsw_sp_acl_tcam_region *region = erp_table->aregion->region; + struct mlxsw_sp *mlxsw_sp = erp_table->erp_core->mlxsw_sp; + char pererp_pl[MLXSW_REG_PERERP_LEN]; + + mlxsw_reg_pererp_pack(pererp_pl, region->id, false, true, 0, + erp_table->base_index, 0); + mlxsw_reg_pererp_erp_vector_pack(pererp_pl, erp_table->erp_index_bitmap, + MLXSW_SP_ACL_ERP_MAX_PER_REGION); + mlxsw_reg_pererp_erpt_vector_set(pererp_pl, erp->index, false); + + mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pererp), pererp_pl); +} + +static struct mlxsw_sp_acl_erp * +mlxsw_sp_acl_erp_mask_create(struct mlxsw_sp_acl_erp_table *erp_table, + struct mlxsw_sp_acl_erp_key *key) +{ + struct mlxsw_sp_acl_erp *erp; + int err; + + /* Expand the eRP table for the new eRP, if needed */ + err = mlxsw_sp_acl_erp_table_expand(erp_table); + if (err) + return ERR_PTR(err); + + erp = mlxsw_sp_acl_erp_generic_create(erp_table, key); + if (IS_ERR(erp)) + return erp; + + err = mlxsw_sp_acl_erp_index_get(erp_table, &erp->index); + if (err) + goto err_erp_index_get; + + err = mlxsw_sp_acl_erp_table_erp_add(erp_table, erp); + if (err) + goto err_table_erp_add; + + err = mlxsw_sp_acl_erp_region_erp_add(erp_table, erp); + if (err) + goto err_region_erp_add; + + erp_table->ops = &erp_multiple_masks_ops; + + return erp; + +err_region_erp_add: + mlxsw_sp_acl_erp_table_erp_del(erp); +err_table_erp_add: + mlxsw_sp_acl_erp_index_put(erp_table, erp->index); +err_erp_index_get: + mlxsw_sp_acl_erp_generic_destroy(erp); + return ERR_PTR(err); +} + +static void +mlxsw_sp_acl_erp_mask_destroy(struct mlxsw_sp_acl_erp_table *erp_table, + struct mlxsw_sp_acl_erp *erp) +{ + mlxsw_sp_acl_erp_region_erp_del(erp); + mlxsw_sp_acl_erp_table_erp_del(erp); + mlxsw_sp_acl_erp_index_put(erp_table, erp->index); + mlxsw_sp_acl_erp_generic_destroy(erp); + + if (erp_table->num_atcam_erps == 2) + erp_table->ops = &erp_two_masks_ops; +} + +static struct mlxsw_sp_acl_erp * +mlxsw_sp_acl_erp_second_mask_create(struct mlxsw_sp_acl_erp_table *erp_table, + struct mlxsw_sp_acl_erp_key *key) +{ + struct mlxsw_sp_acl_erp *erp; + int err; + + /* Transition to use eRP table instead of master mask */ + err = mlxsw_sp_acl_erp_region_table_trans(erp_table); + if (err) + return ERR_PTR(err); + + erp = mlxsw_sp_acl_erp_generic_create(erp_table, key); + if (IS_ERR(erp)) { + err = PTR_ERR(erp); + goto err_erp_create; + } + + err = mlxsw_sp_acl_erp_index_get(erp_table, &erp->index); + if (err) + goto err_erp_index_get; + + err = mlxsw_sp_acl_erp_table_erp_add(erp_table, erp); + if (err) + goto err_table_erp_add; + + err = mlxsw_sp_acl_erp_region_erp_add(erp_table, erp); + if (err) + goto err_region_erp_add; + + erp_table->ops = &erp_two_masks_ops; + + return erp; + +err_region_erp_add: + mlxsw_sp_acl_erp_table_erp_del(erp); +err_table_erp_add: + mlxsw_sp_acl_erp_index_put(erp_table, erp->index); +err_erp_index_get: + mlxsw_sp_acl_erp_generic_destroy(erp); +err_erp_create: + mlxsw_sp_acl_erp_region_master_mask_trans(erp_table); + return ERR_PTR(err); +} + +static void +mlxsw_sp_acl_erp_second_mask_destroy(struct mlxsw_sp_acl_erp_table *erp_table, + struct mlxsw_sp_acl_erp *erp) +{ + mlxsw_sp_acl_erp_region_erp_del(erp); + mlxsw_sp_acl_erp_table_erp_del(erp); + mlxsw_sp_acl_erp_index_put(erp_table, erp->index); + mlxsw_sp_acl_erp_generic_destroy(erp); + /* Transition to use master mask instead of eRP table */ + mlxsw_sp_acl_erp_region_master_mask_trans(erp_table); + + erp_table->ops = &erp_single_mask_ops; +} + +static struct mlxsw_sp_acl_erp * +mlxsw_sp_acl_erp_first_mask_create(struct mlxsw_sp_acl_erp_table *erp_table, + struct mlxsw_sp_acl_erp_key *key) +{ + struct mlxsw_sp_acl_erp *erp; + + erp = mlxsw_sp_acl_erp_generic_create(erp_table, key); + if (IS_ERR(erp)) + return erp; + + erp_table->ops = &erp_single_mask_ops; + + return erp; +} + +static void +mlxsw_sp_acl_erp_first_mask_destroy(struct mlxsw_sp_acl_erp_table *erp_table, + struct mlxsw_sp_acl_erp *erp) +{ + mlxsw_sp_acl_erp_generic_destroy(erp); + erp_table->ops = &erp_no_mask_ops; +} + +static void +mlxsw_sp_acl_erp_no_mask_destroy(struct mlxsw_sp_acl_erp_table *erp_table, + struct mlxsw_sp_acl_erp *erp) +{ + WARN_ON(1); +} + +struct mlxsw_sp_acl_erp * +mlxsw_sp_acl_erp_get(struct mlxsw_sp_acl_atcam_region *aregion, + const char *mask) +{ + struct mlxsw_sp_acl_erp_table *erp_table = aregion->erp_table; + struct mlxsw_sp_acl_erp_key key; + struct mlxsw_sp_acl_erp *erp; + + /* eRPs are allocated from a shared resource, but currently all + * allocations are done under RTNL. + */ + ASSERT_RTNL(); + + memcpy(key.mask, mask, MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN); + erp = rhashtable_lookup_fast(&erp_table->erp_ht, &key, + mlxsw_sp_acl_erp_ht_params); + if (erp) { + refcount_inc(&erp->refcnt); + return erp; + } + + return erp_table->ops->erp_create(erp_table, &key); +} + +void mlxsw_sp_acl_erp_put(struct mlxsw_sp_acl_atcam_region *aregion, + struct mlxsw_sp_acl_erp *erp) +{ + struct mlxsw_sp_acl_erp_table *erp_table = aregion->erp_table; + + ASSERT_RTNL(); + + if (!refcount_dec_and_test(&erp->refcnt)) + return; + + erp_table->ops->erp_destroy(erp_table, erp); +} + +static struct mlxsw_sp_acl_erp_table * +mlxsw_sp_acl_erp_table_create(struct mlxsw_sp_acl_atcam_region *aregion) +{ + struct mlxsw_sp_acl_erp_table *erp_table; + int err; + + erp_table = kzalloc(sizeof(*erp_table), GFP_KERNEL); + if (!erp_table) + return ERR_PTR(-ENOMEM); + + err = rhashtable_init(&erp_table->erp_ht, &mlxsw_sp_acl_erp_ht_params); + if (err) + goto err_rhashtable_init; + + erp_table->erp_core = aregion->atcam->erp_core; + erp_table->ops = &erp_no_mask_ops; + INIT_LIST_HEAD(&erp_table->atcam_erps_list); + erp_table->aregion = aregion; + + return erp_table; + +err_rhashtable_init: + kfree(erp_table); + return ERR_PTR(err); +} + +static void +mlxsw_sp_acl_erp_table_destroy(struct mlxsw_sp_acl_erp_table *erp_table) +{ + WARN_ON(!list_empty(&erp_table->atcam_erps_list)); + rhashtable_destroy(&erp_table->erp_ht); + kfree(erp_table); +} + +static int +mlxsw_sp_acl_erp_master_mask_init(struct mlxsw_sp_acl_atcam_region *aregion) +{ + struct mlxsw_sp *mlxsw_sp = aregion->region->mlxsw_sp; + char percr_pl[MLXSW_REG_PERCR_LEN]; + char *master_mask; + + mlxsw_reg_percr_pack(percr_pl, aregion->region->id); + master_mask = mlxsw_reg_percr_master_mask_data(percr_pl); + memset(master_mask, 0, MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN); + return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(percr), percr_pl); +} + +static int +mlxsw_sp_acl_erp_region_param_init(struct mlxsw_sp_acl_atcam_region *aregion) +{ + struct mlxsw_sp *mlxsw_sp = aregion->region->mlxsw_sp; + char pererp_pl[MLXSW_REG_PERERP_LEN]; + + mlxsw_reg_pererp_pack(pererp_pl, aregion->region->id, false, false, 0, + 0, 0); + return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pererp), pererp_pl); +} + +int mlxsw_sp_acl_erp_region_init(struct mlxsw_sp_acl_atcam_region *aregion) +{ + struct mlxsw_sp_acl_erp_table *erp_table; + int err; + + erp_table = mlxsw_sp_acl_erp_table_create(aregion); + if (IS_ERR(erp_table)) + return PTR_ERR(erp_table); + aregion->erp_table = erp_table; + + /* Initialize the region's master mask to all zeroes */ + err = mlxsw_sp_acl_erp_master_mask_init(aregion); + if (err) + goto err_erp_master_mask_init; + + /* Initialize the region to not use the eRP table */ + err = mlxsw_sp_acl_erp_region_param_init(aregion); + if (err) + goto err_erp_region_param_init; + + return 0; + +err_erp_region_param_init: +err_erp_master_mask_init: + mlxsw_sp_acl_erp_table_destroy(erp_table); + return err; +} + +void mlxsw_sp_acl_erp_region_fini(struct mlxsw_sp_acl_atcam_region *aregion) +{ + mlxsw_sp_acl_erp_table_destroy(aregion->erp_table); +} + +static int +mlxsw_sp_acl_erp_tables_sizes_query(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_acl_erp_core *erp_core) +{ + unsigned int size; + + if (!MLXSW_CORE_RES_VALID(mlxsw_sp->core, ACL_ERPT_ENTRIES_2KB) || + !MLXSW_CORE_RES_VALID(mlxsw_sp->core, ACL_ERPT_ENTRIES_4KB) || + !MLXSW_CORE_RES_VALID(mlxsw_sp->core, ACL_ERPT_ENTRIES_8KB) || + !MLXSW_CORE_RES_VALID(mlxsw_sp->core, ACL_ERPT_ENTRIES_12KB)) + return -EIO; + + size = MLXSW_CORE_RES_GET(mlxsw_sp->core, ACL_ERPT_ENTRIES_2KB); + erp_core->erpt_entries_size[MLXSW_SP_ACL_ATCAM_REGION_TYPE_2KB] = size; + + size = MLXSW_CORE_RES_GET(mlxsw_sp->core, ACL_ERPT_ENTRIES_4KB); + erp_core->erpt_entries_size[MLXSW_SP_ACL_ATCAM_REGION_TYPE_4KB] = size; + + size = MLXSW_CORE_RES_GET(mlxsw_sp->core, ACL_ERPT_ENTRIES_8KB); + erp_core->erpt_entries_size[MLXSW_SP_ACL_ATCAM_REGION_TYPE_8KB] = size; + + size = MLXSW_CORE_RES_GET(mlxsw_sp->core, ACL_ERPT_ENTRIES_12KB); + erp_core->erpt_entries_size[MLXSW_SP_ACL_ATCAM_REGION_TYPE_12KB] = size; + + return 0; +} + +static int mlxsw_sp_acl_erp_tables_init(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_acl_erp_core *erp_core) +{ + unsigned int erpt_bank_size; + int err; + + if (!MLXSW_CORE_RES_VALID(mlxsw_sp->core, ACL_MAX_ERPT_BANK_SIZE) || + !MLXSW_CORE_RES_VALID(mlxsw_sp->core, ACL_MAX_ERPT_BANKS)) + return -EIO; + erpt_bank_size = MLXSW_CORE_RES_GET(mlxsw_sp->core, + ACL_MAX_ERPT_BANK_SIZE); + erp_core->num_erp_banks = MLXSW_CORE_RES_GET(mlxsw_sp->core, + ACL_MAX_ERPT_BANKS); + + erp_core->erp_tables = gen_pool_create(0, -1); + if (!erp_core->erp_tables) + return -ENOMEM; + gen_pool_set_algo(erp_core->erp_tables, gen_pool_best_fit, NULL); + + err = gen_pool_add(erp_core->erp_tables, + MLXSW_SP_ACL_ERP_GENALLOC_OFFSET, erpt_bank_size, + -1); + if (err) + goto err_gen_pool_add; + + /* Different regions require masks of different sizes */ + err = mlxsw_sp_acl_erp_tables_sizes_query(mlxsw_sp, erp_core); + if (err) + goto err_erp_tables_sizes_query; + + return 0; + +err_erp_tables_sizes_query: +err_gen_pool_add: + gen_pool_destroy(erp_core->erp_tables); + return err; +} + +static void mlxsw_sp_acl_erp_tables_fini(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_acl_erp_core *erp_core) +{ + gen_pool_destroy(erp_core->erp_tables); +} + +int mlxsw_sp_acl_erps_init(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_acl_atcam *atcam) +{ + struct mlxsw_sp_acl_erp_core *erp_core; + int err; + + erp_core = kzalloc(sizeof(*erp_core), GFP_KERNEL); + if (!erp_core) + return -ENOMEM; + erp_core->mlxsw_sp = mlxsw_sp; + atcam->erp_core = erp_core; + + err = mlxsw_sp_acl_erp_tables_init(mlxsw_sp, erp_core); + if (err) + goto err_erp_tables_init; + + return 0; + +err_erp_tables_init: + kfree(erp_core); + return err; +} + +void mlxsw_sp_acl_erps_fini(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_acl_atcam *atcam) +{ + mlxsw_sp_acl_erp_tables_fini(mlxsw_sp, atcam->erp_core); + kfree(atcam->erp_core); +} diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h index 68551da2221d..5c9a479ece25 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h @@ -91,6 +91,9 @@ mlxsw_sp_acl_tcam_profile_ops(struct mlxsw_sp *mlxsw_sp, #define MLXSW_SP_ACL_TCAM_CATCHALL_PRIO (~0U) +#define MLXSW_SP_ACL_TCAM_MASK_LEN \ + (MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN * BITS_PER_BYTE) + struct mlxsw_sp_acl_tcam_group; struct mlxsw_sp_acl_tcam_region { @@ -143,9 +146,46 @@ mlxsw_sp_acl_ctcam_entry_offset(struct mlxsw_sp_acl_ctcam_entry *centry) return centry->parman_item.index; } +enum mlxsw_sp_acl_atcam_region_type { + MLXSW_SP_ACL_ATCAM_REGION_TYPE_2KB, + MLXSW_SP_ACL_ATCAM_REGION_TYPE_4KB, + MLXSW_SP_ACL_ATCAM_REGION_TYPE_8KB, + MLXSW_SP_ACL_ATCAM_REGION_TYPE_12KB, + __MLXSW_SP_ACL_ATCAM_REGION_TYPE_MAX, +}; + +#define MLXSW_SP_ACL_ATCAM_REGION_TYPE_MAX \ + (__MLXSW_SP_ACL_ATCAM_REGION_TYPE_MAX - 1) + +struct mlxsw_sp_acl_atcam { + struct mlxsw_sp_acl_erp_core *erp_core; +}; + +struct mlxsw_sp_acl_atcam_region { + struct mlxsw_sp_acl_tcam_region *region; + struct mlxsw_sp_acl_atcam *atcam; + enum mlxsw_sp_acl_atcam_region_type type; + struct mlxsw_sp_acl_erp_table *erp_table; +}; + int mlxsw_sp_acl_atcam_region_associate(struct mlxsw_sp *mlxsw_sp, u16 region_id); int mlxsw_sp_acl_atcam_region_init(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_acl_tcam_region *region); +struct mlxsw_sp_acl_erp; + +u8 mlxsw_sp_acl_erp_id(const struct mlxsw_sp_acl_erp *erp); +struct mlxsw_sp_acl_erp * +mlxsw_sp_acl_erp_get(struct mlxsw_sp_acl_atcam_region *aregion, + const char *mask); +void mlxsw_sp_acl_erp_put(struct mlxsw_sp_acl_atcam_region *aregion, + struct mlxsw_sp_acl_erp *erp); +int mlxsw_sp_acl_erp_region_init(struct mlxsw_sp_acl_atcam_region *aregion); +void mlxsw_sp_acl_erp_region_fini(struct mlxsw_sp_acl_atcam_region *aregion); +int mlxsw_sp_acl_erps_init(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_acl_atcam *atcam); +void mlxsw_sp_acl_erps_fini(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_acl_atcam *atcam); + #endif From patchwork Sun Jul 22 13:17:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 10539307 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 35F8F96FA for ; Sun, 22 Jul 2018 13:18:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 20F6A281F9 for ; Sun, 22 Jul 2018 13:18:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1560928384; Sun, 22 Jul 2018 13:18:40 +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 5F66128372 for ; Sun, 22 Jul 2018 13:18:39 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41YQDY5XnbzDrG3 for ; Sun, 22 Jul 2018 23:18:37 +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="UvCwR3rR"; 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="UvCwR3rR"; 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 41YQD542LGzDqmF for ; Sun, 22 Jul 2018 23:18:13 +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=O8hxm/lP/NRf/HYfVg8+X7VREZMskmoeilcXgNkSOFo=; b=UvCwR3rRiZ/orf1KiNLPNqxIGXuZ6HQ/kGLdVa5offNX4ozbiTc8DHtvsUHcWnFusNxi38Go5UAlcBbfFAykwH7uZ/B9XLiZH0ws0A4oyQGl3jwjyGyI6o1m6pDxR/urnteKZf1HfMMlBBBgfm9QP4kMOEZkVkXfUShYLFT7aiA= 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:01 +0000 From: Ido Schimmel To: linux-internal@mellanox.com Subject: [PATCH net-next mlxsw 07/18] mlxsw: spectrum_acl: Enable C-TCAM only mode in eRP core Date: Sun, 22 Jul 2018 16:17:01 +0300 Message-Id: <20180722131712.30578-8-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: 4e8c76de-2b1a-434c-999e-08d5efd58d76 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:R6EJ02rCMduyDWKSbQ9NHN4wfRRDIS0l0gGIzCYqMmhME7rfAhyKNdRssf2Qk0vQX9e+zyECAYWHg8XDfoj02g/jqb9aekSu2JElTDf67fRjU2TKj8RHEQCg7SRSyWNXZ5Y1992veAO9/TYLsA1qjH8vyA3nKKP0EbTeb+XUlU+mZJx4oxkMSI0L8SV/B+ILK9lkDA8zfrk9khwBXm95IXZ04c2BY0UQBP45aZNB1EgFlmNjvNiwjx/ZMMij40IN; 25:DIsPxYq/Ny6RwFFlKPEVlU9mB7vqcDtSt4XsHeDGi4eirHuUmQmK9XBkxvaqztmw14c0726xbZQWE6MU/mN/Nlit+OxDXPll1PSJtPNEybBXQgcIsVEVfezVH56Vs/8y3Zv3zJTzNInTcJHIxozKs+dVUj6tv4gGPLhM2vqNAn8I15hDDPp1MIBPZhxh18mZrKwm4zjBqVWKSg49TnaJTy6TJY8L8CW9FkseGGTrA6fddKo8+XZ0UGhgjBX3nZzAb+6H+sdvtPpSY3FMgq015WYjDFJOYhDFwwBZy+NBzcRmjBdpVP2r1idZQREwNiZ6Z/OJW0AfVz1jHKLlSBWUMw==; 31:ZJuXe3/9Vr8eCcQ1iV168uGNoGrk8o1wBHGu8MZurA3J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am-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)(979002)(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)(969003)(989001)(999001)(1009001)(1019001); 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:h9JvAvxWnfXKgeXA20tJCYUtp0HD99oTpO28HXc?= dQVviq6pc+da/WSU4vkt4xHQirr7ANQmVpRGK1vu1xNLD9hRgUg6Wi0BNU/Cgou1CHd41RF72KZdUe1ZmFgIiTQeNjDDcnVSg8YKtiUx/fgfBl+drFkhw9L3hb3m7s4uHagpvVQPICxynUIj1b1B87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aOFL1sMHGylfLi5E1t0k63mH/x2iuTk+QHzwJLiLn1WbBFSKgpLxUYDsM4MZVYt/s0Sb8XAqNlSZI1QcfbdhG2JSJP6pwDuZ5Cp7w9FKT5SXDC9FDMehhSNNkmj8vva1JqEWfVPjFJpk=; 7:IZRFx5m9I6viWA67yQHc8obs9B4nDVhoHOQufF4cwiuq/MXdflkD8JvNxKQttNrY9jr3D/mEfH8LLxCZ/xinPbELtAq4UlmYjgMSxLKw/x+n5n6eGLtPi4yVE72Zewt+Jl+HPu/h2+iPxX0q3sF/VT5gkN/pCr6cE5Ahj1KiotxuYyyP7ihM1EOAx/4gU8QEMzqJstGVLmS6trSDEfZ5o9lD+gXRz6ZK3uYA6OnZJu/8OrnJ1+QWFj4WAk3D+uSs SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2018 13:18:01.7600 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4e8c76de-2b1a-434c-999e-08d5efd58d76 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 Currently, no calls are performed into the eRP core, but in order to make review easier we would like to gradually add these calls. Have the eRP core initialize a region's master mask to all ones and allow it to use an empty eRP table. This directs the lookup to the C-TCAM and allows the C-TCAM only mode to continue working. Signed-off-by: Ido Schimmel Reviewed-by: Jiri Pirko --- drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_erp.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_erp.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_erp.c index 960f29140b43..86600c780c95 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_erp.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_erp.c @@ -879,7 +879,7 @@ mlxsw_sp_acl_erp_region_param_init(struct mlxsw_sp_acl_atcam_region *aregion) struct mlxsw_sp *mlxsw_sp = aregion->region->mlxsw_sp; char pererp_pl[MLXSW_REG_PERERP_LEN]; - mlxsw_reg_pererp_pack(pererp_pl, aregion->region->id, false, false, 0, + mlxsw_reg_pererp_pack(pererp_pl, aregion->region->id, true, true, 0, 0, 0); return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pererp), pererp_pl); } @@ -894,12 +894,16 @@ int mlxsw_sp_acl_erp_region_init(struct mlxsw_sp_acl_atcam_region *aregion) return PTR_ERR(erp_table); aregion->erp_table = erp_table; - /* Initialize the region's master mask to all zeroes */ + /* Initialize the region's master mask to all ones for C-TCAM + * only mode + */ err = mlxsw_sp_acl_erp_master_mask_init(aregion); if (err) goto err_erp_master_mask_init; - /* Initialize the region to not use the eRP table */ + /* Initialize the region to use the eRP table and enable C-TCAM + * lookup + */ err = mlxsw_sp_acl_erp_region_param_init(aregion); if (err) goto err_erp_region_param_init; From patchwork Sun Jul 22 13:17:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 10539309 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 EC6381805 for ; Sun, 22 Jul 2018 13:18:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D7575281F9 for ; Sun, 22 Jul 2018 13:18:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CBB4B28385; Sun, 22 Jul 2018 13:18:48 +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 9F6D9281F9 for ; Sun, 22 Jul 2018 13:18:47 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41YQDj6Z83zDrC5 for ; Sun, 22 Jul 2018 23:18:45 +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="ddI5aNIh"; 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="ddI5aNIh"; 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 41YQD66KWlzDqmF for ; Sun, 22 Jul 2018 23:18:14 +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=kdZhbsZz7e75MOl1fi5IXl763dZvM9B54VkcnWums9w=; b=ddI5aNIhvjyYV1hI0A9RNG7cdoA4elCSzF7FlaGBQB2fG0vWTnC5Leclvfd7OCM4McadbauMftO1zBoluCIoA+arKRU9xTAgGmFU12tGmjqVJYoAtpRCt+87235U2Q+G6mb0i+xVD+vwuPpnOja484sPZJdPR1B1qTidYUU2Zf4= 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:02 +0000 From: Ido Schimmel To: linux-internal@mellanox.com Subject: [PATCH net-next mlxsw 08/18] mlxsw: spectrum_acl: Add support for C-TCAM eRPs Date: Sun, 22 Jul 2018 16:17:02 +0300 Message-Id: <20180722131712.30578-9-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: a1e4589f-1b83-47b0-6aa3-08d5efd58e0a 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:ihwLqPTdLc+snFMNSAjZHJFcW3CLHEWXObGL8nC9dYAYkDsx39UrkYJQE4jyPnKVLDLk7YufK84AYtGA+eUZoXomnTabHAGio9c9W4Ge7AXH3EBkP7YdXQH2T2K/9o/cxWVH+RNnCGCbZZsjyNancbVR1bTTm8TTJh8LXqKivz8e9tLcK+YJGoSCloCQEcLw3eeT8eECSQFQ85nx/nDjWGj937YQKA/0/h/EnguYH/arSgOyJpUmY2BR4dKQAV02; 25:G1l0fAWOQPNh9iK8wFxebpycLYLoL4XCQ/kSRKdT3BIJYsrkvRWtYNVfsrckmNx0nOf/TxobEqvVXT2xKbzgaVC2IoxtAiOuG+uOjZiiyevDCeNFE40OKE85oBu3Mu9/kLjKCivRHRSKpnydwsear00nB1XtFnCfivt0skpoJCoB3DYMYtq21oHC71anamqbV0HeAcLz3VeeIMHiG3ezWQKx9MLkwoJsxDeVBbyetNxFPqcbvUQiUdD+9XX0GRkkBVXURjNQSP/2vgI2AGtse3UrjgqrXT1tn30naYZklNWV9eaDUvR3mkW4Hd/yB9mN4rAeuQl+/23HYXlS8KW8/g==; 31:tU7IP0DTEEPUa473y9H6MPWjyPfte82l/nNAj2deTnPZHJDKEF4mDpjhvaD3ob4YtOLQHfGr/sulaDLzlRbjMmViCxUnpbZF9vPBocX49Br3mIkB6Oj36PxNONc1gg9C1cEb1tgy9A9NsVewV/OObcrsN5Mx5m9Jswnx44dNMv0yjbWeeCh+P8YuRmqbpdVBWx0K83FhKktMvSgNrQP/2jkmay9dbJ0BqC2xLVEga7w= X-MS-TrafficTypeDiagnostic: HE1PR0501MB2331: X-Microsoft-Exchange-Diagnostics: 1; HE1PR0501MB2331; 20:ohpdTbecgmAQ3o7GBMzrk3U5YU2wzWzn1Cq3k7dFfZYFHuRFsKwnxdU5Lw4ChKap05K/cx3Aoqx9S9l8Eq3zJw+pFsukv67xnAHRhaHCyEYrlLiRT/+AhZfdtu/HT7cnGyY69qzeMDdC4TU68hUfeOB6DbcELgyUYarJhtYaQNtC3L0O5Fzmpk0JJkM4i1Sh+zLQDqT6pE0nQnfX4XNP0BlMNLdvr1u4JAH+Bj68t+cXzkKk/4YzZX6u1AutbDC7909qASNci/9mKX+7WSkOAdxzmMEB3teNVMqu6gx+uCxWhi7yHIeRiuXfRiFcuSD/gO7WhR3682pQY+y6PI50+KDt0jA3Or6TVOEmqKsSE42lYEepV9I4SdoYUxnm7xLFPdHhSttsQaVQPuCTZomd6uQbSo6S4/2Gbvh7vYJxEW9iUAMw1t/cqEtXmsv3bRUbukCCVwPY9r+eiJADeNu2dXQ77WdhCIy1bwciJnE/CNmu3dWAY/PRyTz0jEb7umwv; 4:b6he9PFb9HJs8NihXN99bXPmuqZAjKohrT0kXzR5J5cmMwaUOdRBhb0Sje17eQNfPl4N0TWT5L3B2ofzyQaahzDqxBolr9J3HDlESVbB84qAnlOoKuAst0p7As5T5TwrxuOnJxjtwgtCX4HirCojxZknusS1A8hgqB1BY1x5DeDSF5BreEi8Q7nuaUZoxVuqNlZK2SJodHRRqtSChD/h4vxNXXUkk192OX1mM5Ctn+GsHpvgY+W6LE8xehIQd1zjML2M2054GqLTZzDA11Xqxg== 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:2P4E/Dw+4jzAg4EIN/XX9M3jkLaWrQH8M6etCP6?= H0eV0XJVhC/7vHIOtfZsBUMkAUynLO6nHemSIB1tq1N2n6cqCVsjQTBQFIi5qfat/R3x30ma4AeCsLrBEQtsvCT6FkJk8HkF0PjwkHiAEsmatr/UeFNzoWg3udG/fRRxjidmSfMN8TQPsVkWKfGlwUdQ/rwRjwS03KqbeYYzyak9sLnp8/+gYXAUtAn8+WjeWhihPJdIIvqGdSqNXwCgIp5aY8gVmicpyQiauYXkN/06sdJ9PZljwjsvWxrxfwjTZDAtOTz83LK+UMB1pAZh53zDRiHFnXSFScn4RphOd6VAtJfcSBQailJiyNaS1FaMSMOmVN5v/WOp6JZxikXZbARZBlSZKuY+bdSkIXOp1MC+pruyihHJTtdw0WUnUbzL7GClHyksk580TWLyvU04f+IlnmDz+q9Z7VMs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8qGLT65JXb1F00Grb+mzATDLHh+sk6rYSmdQ7/kTcYUa52vXKhzI/sJQtGQVJoXv0 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2018 13:18:02.7131 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a1e4589f-1b83-47b0-6aa3-08d5efd58e0a 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 The number of eRPs that can be used by a single A-TCAM region is limited to 16. When more eRPs are needed, an ordinary circuit TCAM (C-TCAM) can be used to hold the extra eRPs. Unlike the A-TCAM, only a single (last) lookup is performed in the C-TCAM and not a lookup per-eRP. However, modeling the C-TCAM as extra eRPs will allow us to easily introduce support for pruning in a follow-up patch set and is also logically correct. The following diagram depicts the relation between both TCAMs: C-TCAM +-------------------+ +--------------------+ +-----------+ | | | | | | | eRP #1 (A-TCAM) +----> ... +----+ eRP #16 (A-TCAM) +----+ eRP #17 | | | | | | ... | +-------------------+ +--------------------+ | eRP #N | | | +-----------+ Lookup order is from left to right. Extend the eRP core APIs with a C-TCAM parameter which indicates whether the requested eRP is to be used with the C-TCAM or not. Since the C-TCAM is only meant to absorb rules that can't fit in the A-TCAM due to exceeded number of eRPs or key collision, an error is returned when a C-TCAM eRP needs to be created when the eRP state machine is in its initial state (i.e., 'no masks'). This should only happen in the face of very unlikely errors when trying to push rules into the A-TCAM. In order not to perform unnecessary lookups, the eRP core will only enable a C-TCAM lookup for a given region if it knows there are C-TCAM eRPs present. Signed-off-by: Ido Schimmel Reviewed-by: Jiri Pirko --- Notes: v2: * Cast to 'u32 *' instead of 'void *' .../mellanox/mlxsw/spectrum_acl_erp.c | 202 ++++++++++++++++-- .../mellanox/mlxsw/spectrum_acl_tcam.h | 2 +- 2 files changed, 191 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_erp.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_erp.c index 86600c780c95..e26efa451d4a 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_erp.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_erp.c @@ -60,6 +60,7 @@ struct mlxsw_sp_acl_erp_core { struct mlxsw_sp_acl_erp_key { char mask[MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN]; + bool ctcam; }; struct mlxsw_sp_acl_erp { @@ -90,6 +91,7 @@ struct mlxsw_sp_acl_erp_table { unsigned long base_index; unsigned int num_atcam_erps; unsigned int num_max_atcam_erps; + unsigned int num_ctcam_erps; }; static const struct rhashtable_params mlxsw_sp_acl_erp_ht_params = { @@ -448,13 +450,14 @@ static void mlxsw_sp_acl_erp_table_erp_del(struct mlxsw_sp_acl_erp *erp) } static int -mlxsw_sp_acl_erp_table_enable(struct mlxsw_sp_acl_erp_table *erp_table) +mlxsw_sp_acl_erp_table_enable(struct mlxsw_sp_acl_erp_table *erp_table, + bool ctcam_le) { struct mlxsw_sp_acl_tcam_region *region = erp_table->aregion->region; struct mlxsw_sp *mlxsw_sp = erp_table->erp_core->mlxsw_sp; char pererp_pl[MLXSW_REG_PERERP_LEN]; - mlxsw_reg_pererp_pack(pererp_pl, region->id, false, true, 0, + mlxsw_reg_pererp_pack(pererp_pl, region->id, ctcam_le, true, 0, erp_table->base_index, 0); mlxsw_reg_pererp_erp_vector_pack(pererp_pl, erp_table->erp_index_bitmap, MLXSW_SP_ACL_ERP_MAX_PER_REGION); @@ -471,11 +474,12 @@ mlxsw_sp_acl_erp_table_disable(struct mlxsw_sp_acl_erp_table *erp_table) struct mlxsw_sp_acl_erp *master_rp; master_rp = mlxsw_sp_acl_erp_table_master_rp(erp_table); - if (!master_rp) - return; - + /* It is possible we do not have a master RP when we disable the + * table when there are no rules in the A-TCAM and the last C-TCAM + * rule is deleted + */ mlxsw_reg_pererp_pack(pererp_pl, region->id, false, false, 0, 0, - master_rp->id); + master_rp ? master_rp->id : 0); mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pererp), pererp_pl); } @@ -506,6 +510,7 @@ mlxsw_sp_acl_erp_table_expand(struct mlxsw_sp_acl_erp_table *erp_table) unsigned int num_erps, old_num_erps = erp_table->num_max_atcam_erps; struct mlxsw_sp_acl_erp_core *erp_core = erp_table->erp_core; unsigned long old_base_index = erp_table->base_index; + bool ctcam_le = erp_table->num_ctcam_erps > 0; int err; if (erp_table->num_atcam_erps < erp_table->num_max_atcam_erps) @@ -526,7 +531,7 @@ mlxsw_sp_acl_erp_table_expand(struct mlxsw_sp_acl_erp_table *erp_table) if (err) goto err_table_relocate; - err = mlxsw_sp_acl_erp_table_enable(erp_table); + err = mlxsw_sp_acl_erp_table_enable(erp_table, ctcam_le); if (err) goto err_table_enable; @@ -579,7 +584,7 @@ mlxsw_sp_acl_erp_region_table_trans(struct mlxsw_sp_acl_erp_table *erp_table) if (err) goto err_table_master_rp_add; - err = mlxsw_sp_acl_erp_table_enable(erp_table); + err = mlxsw_sp_acl_erp_table_enable(erp_table, false); if (err) goto err_table_enable; @@ -619,9 +624,10 @@ mlxsw_sp_acl_erp_region_erp_add(struct mlxsw_sp_acl_erp_table *erp_table, { struct mlxsw_sp_acl_tcam_region *region = erp_table->aregion->region; struct mlxsw_sp *mlxsw_sp = erp_table->erp_core->mlxsw_sp; + bool ctcam_le = erp_table->num_ctcam_erps > 0; char pererp_pl[MLXSW_REG_PERERP_LEN]; - mlxsw_reg_pererp_pack(pererp_pl, region->id, false, true, 0, + mlxsw_reg_pererp_pack(pererp_pl, region->id, ctcam_le, true, 0, erp_table->base_index, 0); mlxsw_reg_pererp_erp_vector_pack(pererp_pl, erp_table->erp_index_bitmap, MLXSW_SP_ACL_ERP_MAX_PER_REGION); @@ -635,9 +641,10 @@ static void mlxsw_sp_acl_erp_region_erp_del(struct mlxsw_sp_acl_erp *erp) struct mlxsw_sp_acl_erp_table *erp_table = erp->erp_table; struct mlxsw_sp_acl_tcam_region *region = erp_table->aregion->region; struct mlxsw_sp *mlxsw_sp = erp_table->erp_core->mlxsw_sp; + bool ctcam_le = erp_table->num_ctcam_erps > 0; char pererp_pl[MLXSW_REG_PERERP_LEN]; - mlxsw_reg_pererp_pack(pererp_pl, region->id, false, true, 0, + mlxsw_reg_pererp_pack(pererp_pl, region->id, ctcam_le, true, 0, erp_table->base_index, 0); mlxsw_reg_pererp_erp_vector_pack(pererp_pl, erp_table->erp_index_bitmap, MLXSW_SP_ACL_ERP_MAX_PER_REGION); @@ -646,6 +653,161 @@ static void mlxsw_sp_acl_erp_region_erp_del(struct mlxsw_sp_acl_erp *erp) mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pererp), pererp_pl); } +static int +mlxsw_sp_acl_erp_region_ctcam_enable(struct mlxsw_sp_acl_erp_table *erp_table) +{ + /* No need to re-enable lookup in the C-TCAM */ + if (erp_table->num_ctcam_erps > 1) + return 0; + + return mlxsw_sp_acl_erp_table_enable(erp_table, true); +} + +static void +mlxsw_sp_acl_erp_region_ctcam_disable(struct mlxsw_sp_acl_erp_table *erp_table) +{ + /* Only disable C-TCAM lookup when last C-TCAM eRP is deleted */ + if (erp_table->num_ctcam_erps > 1) + return; + + mlxsw_sp_acl_erp_table_enable(erp_table, false); +} + +static void +mlxsw_sp_acl_erp_ctcam_table_ops_set(struct mlxsw_sp_acl_erp_table *erp_table) +{ + switch (erp_table->num_atcam_erps) { + case 2: + /* Keep using the eRP table, but correctly set the + * operations pointer so that when an A-TCAM eRP is + * deleted we will transition to use the master mask + */ + erp_table->ops = &erp_two_masks_ops; + break; + case 1: + /* We only kept the eRP table because we had C-TCAM + * eRPs in use. Now that the last C-TCAM eRP is gone we + * can stop using the table and transition to use the + * master mask + */ + mlxsw_sp_acl_erp_region_master_mask_trans(erp_table); + erp_table->ops = &erp_single_mask_ops; + break; + case 0: + /* There are no more eRPs of any kind used by the region + * so free its eRP table and transition to initial state + */ + mlxsw_sp_acl_erp_table_disable(erp_table); + mlxsw_sp_acl_erp_table_free(erp_table->erp_core, + erp_table->num_max_atcam_erps, + erp_table->aregion->type, + erp_table->base_index); + erp_table->ops = &erp_no_mask_ops; + break; + default: + break; + } +} + +static struct mlxsw_sp_acl_erp * +__mlxsw_sp_acl_erp_ctcam_mask_create(struct mlxsw_sp_acl_erp_table *erp_table, + struct mlxsw_sp_acl_erp_key *key) +{ + struct mlxsw_sp_acl_erp *erp; + int err; + + erp = kzalloc(sizeof(*erp), GFP_KERNEL); + if (!erp) + return ERR_PTR(-ENOMEM); + + memcpy(&erp->key, key, sizeof(*key)); + bitmap_from_arr32(erp->mask_bitmap, (u32 *) key->mask, + MLXSW_SP_ACL_TCAM_MASK_LEN); + refcount_set(&erp->refcnt, 1); + erp_table->num_ctcam_erps++; + erp->erp_table = erp_table; + + err = mlxsw_sp_acl_erp_master_mask_set(erp_table, erp); + if (err) + goto err_master_mask_set; + + err = rhashtable_insert_fast(&erp_table->erp_ht, &erp->ht_node, + mlxsw_sp_acl_erp_ht_params); + if (err) + goto err_rhashtable_insert; + + err = mlxsw_sp_acl_erp_region_ctcam_enable(erp_table); + if (err) + goto err_erp_region_ctcam_enable; + + /* When C-TCAM is used, the eRP table must be used */ + erp_table->ops = &erp_multiple_masks_ops; + + return erp; + +err_erp_region_ctcam_enable: + rhashtable_remove_fast(&erp_table->erp_ht, &erp->ht_node, + mlxsw_sp_acl_erp_ht_params); +err_rhashtable_insert: + mlxsw_sp_acl_erp_master_mask_clear(erp_table, erp); +err_master_mask_set: + erp_table->num_ctcam_erps--; + kfree(erp); + return ERR_PTR(err); +} + +static struct mlxsw_sp_acl_erp * +mlxsw_sp_acl_erp_ctcam_mask_create(struct mlxsw_sp_acl_erp_table *erp_table, + struct mlxsw_sp_acl_erp_key *key) +{ + struct mlxsw_sp_acl_erp *erp; + int err; + + /* There is a special situation where we need to spill rules + * into the C-TCAM, yet the region is still using a master + * mask and thus not performing a lookup in the C-TCAM. This + * can happen when two rules that only differ in priority - and + * thus sharing the same key - are programmed. In this case + * we transition the region to use an eRP table + */ + err = mlxsw_sp_acl_erp_region_table_trans(erp_table); + if (err) + return ERR_PTR(err); + + erp = __mlxsw_sp_acl_erp_ctcam_mask_create(erp_table, key); + if (IS_ERR(erp)) { + err = PTR_ERR(erp); + goto err_erp_create; + } + + return erp; + +err_erp_create: + mlxsw_sp_acl_erp_region_master_mask_trans(erp_table); + return ERR_PTR(err); +} + +static void +mlxsw_sp_acl_erp_ctcam_mask_destroy(struct mlxsw_sp_acl_erp *erp) +{ + struct mlxsw_sp_acl_erp_table *erp_table = erp->erp_table; + + mlxsw_sp_acl_erp_region_ctcam_disable(erp_table); + rhashtable_remove_fast(&erp_table->erp_ht, &erp->ht_node, + mlxsw_sp_acl_erp_ht_params); + mlxsw_sp_acl_erp_master_mask_clear(erp_table, erp); + erp_table->num_ctcam_erps--; + kfree(erp); + + /* Once the last C-TCAM eRP was destroyed, the state we + * transition to depends on the number of A-TCAM eRPs currently + * in use + */ + if (erp_table->num_ctcam_erps > 0) + return; + mlxsw_sp_acl_erp_ctcam_table_ops_set(erp_table); +} + static struct mlxsw_sp_acl_erp * mlxsw_sp_acl_erp_mask_create(struct mlxsw_sp_acl_erp_table *erp_table, struct mlxsw_sp_acl_erp_key *key) @@ -653,6 +815,9 @@ mlxsw_sp_acl_erp_mask_create(struct mlxsw_sp_acl_erp_table *erp_table, struct mlxsw_sp_acl_erp *erp; int err; + if (key->ctcam) + return __mlxsw_sp_acl_erp_ctcam_mask_create(erp_table, key); + /* Expand the eRP table for the new eRP, if needed */ err = mlxsw_sp_acl_erp_table_expand(erp_table); if (err) @@ -691,12 +856,15 @@ static void mlxsw_sp_acl_erp_mask_destroy(struct mlxsw_sp_acl_erp_table *erp_table, struct mlxsw_sp_acl_erp *erp) { + if (erp->key.ctcam) + return mlxsw_sp_acl_erp_ctcam_mask_destroy(erp); + mlxsw_sp_acl_erp_region_erp_del(erp); mlxsw_sp_acl_erp_table_erp_del(erp); mlxsw_sp_acl_erp_index_put(erp_table, erp->index); mlxsw_sp_acl_erp_generic_destroy(erp); - if (erp_table->num_atcam_erps == 2) + if (erp_table->num_atcam_erps == 2 && erp_table->num_ctcam_erps == 0) erp_table->ops = &erp_two_masks_ops; } @@ -707,6 +875,9 @@ mlxsw_sp_acl_erp_second_mask_create(struct mlxsw_sp_acl_erp_table *erp_table, struct mlxsw_sp_acl_erp *erp; int err; + if (key->ctcam) + return mlxsw_sp_acl_erp_ctcam_mask_create(erp_table, key); + /* Transition to use eRP table instead of master mask */ err = mlxsw_sp_acl_erp_region_table_trans(erp_table); if (err) @@ -749,6 +920,9 @@ static void mlxsw_sp_acl_erp_second_mask_destroy(struct mlxsw_sp_acl_erp_table *erp_table, struct mlxsw_sp_acl_erp *erp) { + if (erp->key.ctcam) + return mlxsw_sp_acl_erp_ctcam_mask_destroy(erp); + mlxsw_sp_acl_erp_region_erp_del(erp); mlxsw_sp_acl_erp_table_erp_del(erp); mlxsw_sp_acl_erp_index_put(erp_table, erp->index); @@ -765,6 +939,9 @@ mlxsw_sp_acl_erp_first_mask_create(struct mlxsw_sp_acl_erp_table *erp_table, { struct mlxsw_sp_acl_erp *erp; + if (key->ctcam) + return ERR_PTR(-EINVAL); + erp = mlxsw_sp_acl_erp_generic_create(erp_table, key); if (IS_ERR(erp)) return erp; @@ -791,7 +968,7 @@ mlxsw_sp_acl_erp_no_mask_destroy(struct mlxsw_sp_acl_erp_table *erp_table, struct mlxsw_sp_acl_erp * mlxsw_sp_acl_erp_get(struct mlxsw_sp_acl_atcam_region *aregion, - const char *mask) + const char *mask, bool ctcam) { struct mlxsw_sp_acl_erp_table *erp_table = aregion->erp_table; struct mlxsw_sp_acl_erp_key key; @@ -803,6 +980,7 @@ mlxsw_sp_acl_erp_get(struct mlxsw_sp_acl_atcam_region *aregion, ASSERT_RTNL(); memcpy(key.mask, mask, MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN); + key.ctcam = ctcam; erp = rhashtable_lookup_fast(&erp_table->erp_ht, &key, mlxsw_sp_acl_erp_ht_params); if (erp) { diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h index 5c9a479ece25..d6af9920a930 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h @@ -178,7 +178,7 @@ struct mlxsw_sp_acl_erp; u8 mlxsw_sp_acl_erp_id(const struct mlxsw_sp_acl_erp *erp); struct mlxsw_sp_acl_erp * mlxsw_sp_acl_erp_get(struct mlxsw_sp_acl_atcam_region *aregion, - const char *mask); + const char *mask, bool ctcam); void mlxsw_sp_acl_erp_put(struct mlxsw_sp_acl_atcam_region *aregion, struct mlxsw_sp_acl_erp *erp); int mlxsw_sp_acl_erp_region_init(struct mlxsw_sp_acl_atcam_region *aregion); From patchwork Sun Jul 22 13:17:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 10539315 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 AA27196FA for ; Sun, 22 Jul 2018 13:18:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 97C8B281F9 for ; Sun, 22 Jul 2018 13:18:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C3E528384; Sun, 22 Jul 2018 13:18:55 +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 DF78828372 for ; Sun, 22 Jul 2018 13:18:54 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41YQDs0ljkzDqyG for ; Sun, 22 Jul 2018 23:18:53 +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="t3Y+A3yV"; 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="t3Y+A3yV"; 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 41YQD823YKzDqnc for ; Sun, 22 Jul 2018 23:18:16 +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=cJCnhKpUZOHgIqq9DXKZ/orlrkLNlxuJ9/cCLOUP42U=; b=t3Y+A3yVgzKbp0b1qYIUpzUetMqWJ7+kh5btb8WXuGiFLKl+opSJipXEF69fW13E7IfaPqB7WG3uvIjIkJG4X701n2bHOlCSoOkxIKn0jU1tribqTStlMOdxNbu0TqBU+TQngVnT7lh5eqhhTOCj8xSN2p8bYRzSeWOvc/icWsU= 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:03 +0000 From: Ido Schimmel To: linux-internal@mellanox.com Subject: [PATCH net-next mlxsw 09/18] mlxsw: spectrum_acl: Extend Spectrum-2 region struct Date: Sun, 22 Jul 2018 16:17:03 +0300 Message-Id: <20180722131712.30578-10-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: a585fd38-73d1-4061-d95e-08d5efd58e9b 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:aGviech3EeArbsRyhnS+VVkSxJHwJEwr3C9JoGrBAWZ7k4JUvYCZYV9YvaxEl1O+UGp7MwcEPuM22WPKd2+2wRSZTezbi6JxMvN6pCr+9vEEm9Fn9iPuDeUDD4ZIRiiqY0IGPpAVnFd6w49UATG98EEb3oCuFGx8nNTdfy626qYU8EuUiSgx51wOc2o8pJQx+d7TIeVQr35/C4fF4/anrwoISn9Zd4TbLyrdlvuUIPfQUlKYPHme89MYKDToJrdQ; 25:JESJa4/t9C00IxBHrOL9Yft34o00kuEwgh2aM/r8prbmIWZ0gCeZFgK6Pmckqky96WRys9Dx9vKAU+eqQOWevfEVzgh6bTm+tMX1lg52pOM767F7DXD+zKXGtJRWjzdKDdNcQCXomHLq6qg+3MlXTPVqJgDT8AI0aYfAjQ1n1RrztDfBerjdP0C6CbaWcWhdBPct0u2CCo6GiXPRrmoEjAOgTjqqm3Df9HaNw/w3cPGxDnkoOVFbEXCad+/DrFLpkTBdlnWD3wl1l0nQooFKNMaH5oOiCN7x55Xpo6n5ITn+H3yHU9agV9jRrcCgoe8HXiBqU/Oz1QKHQ7C+sXKAsA==; 31:vUhmlIvz5j+tWo+vp2fPvY6ytbhTpJf7K+jT1ehtMvWjfSlwWexq4eCNFOBbiOVbjo6iBiinIkv99opc0q8ruzAEmeDut1Hy4rofxkyWU+n+DNdzlcSKz5Cjtf+Q+r+rnXVN1A4BduS8FgMf1jO9qr2pxVspAvKY7b/N5PIm6Eb4lJGp7ClWlidr6DBcFWrLW/aR0qV1ngixqeiqYAw+KlcpSXDd3n6fAY32KVhVJ/c= X-MS-TrafficTypeDiagnostic: HE1PR0501MB2331: X-Microsoft-Exchange-Diagnostics: 1; HE1PR0501MB2331; 20:mSRpfG5q0qbCGP+dDu879WbOzF97EprLr3uPYHkB3F5QAgQYUMuCgP6f184jeURZPc2j99RxU+CjO3InP+p23tuPNQ0JZEdtOLe8Ug4SbrYZ1uSd5qlKCakkhymyUQa4vEF8bph7x2/iLa4jRSrjNO/KGYovPExUle1BCzKbHyncfQL5gCLDy+pYu1Rur1D4nGK5ZRyFhK80uxIyryCcneLBVzeIBgdbURU5QYkAfajWfNKxTszFw+aZU3ChTqJEH2wz2dOxFhiueQAj6f0arWnw2G8zzMgtea4vRg6x7OVT9mFLt5yNrjACG6rkdytwebdJpTZ/RVYLGs1L4qRt7UIVYFBmTjl4DVnBATMxqVsxMQX1r5Xkvq6FiWGzZj1nmcK9VXxNJYlevMEHqq2O4GnwHOIXdz8By4no4AbRV4diHfrUIOPoVWq5izSX/D4fvrkNNhnfBVFaCXf9kJsAIGj85xE48VD5eZNqSn1wbAZ8749RULgjZVXkw4Wy7DGK; 4:CFJ3n2VjFfZ0XDm3xWgrl7/N3hEPpB/PWPso+xhxUZUfnb/RpKa8N2qCSokLuC1A6tXjE5yAEsQ/qCCB239oDy/iO4GBPEKwey6tnZtdHENkcAWWZBr253qdumtRxOzES5xJBNKNgGbSXlrWba9eWOVmvr7n535hzVVst+gzQiJOVwyLbbFuISYgxs8oE9lVOqPIjDYLW/z/CtBa2MsaHDpWo/Y9qFCbmAyXuvwUD0NOU/tLx5OgrLu2cK4tXRio22oFQQn7utnti7tQ77Enew== 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:zoG4LMEd14Lfc28cLtgCYZth9pC3TXLdmH07ti8?= s05Kkf5etajrk7iVEGC5jDzyhH67zG3Wgt23zQPNxGyTc6TSe2PAgmzx3ZZtbar7C3o951wf+IfkNPmBdAHYBMNweOQkT4wkalNqISeZ92AQrsZb7LwClGP5i9ODAkeVnsE1jO+Ry6LLMij8umCTrK7XfTJsOG1KUtPfir8DdTzA+bx6MD1lM7gCGYfcV2EryTo89KZpTear+W7IX5rgO2yRdik9uGzD9kQCmOtlRnHKoZcsxd3cwoDCjVlWIx0bgmySCOuH5oeGr26qisdxBozJOhoICPvJI33t9JtCBI340do7pl8PTnJH3JKaFOMU8I/k0eAHdoH7UrD8I7Y1g1DizCWWE1va5Ha/CmfPmTo0Eu3p9/ryB2o7gxZEKFnApqfg3wQLR8R3sBIgToo0wxJDrHULUigH0TVf3VNZetO9iVJfk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pRPE4MWn9GRemu2iVzrnrHytP SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2018 13:18:03.6194 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a585fd38-73d1-4061-d95e-08d5efd58e9b 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 In a similar fashion to Spectrum-1's region struct, Spectrum-2's struct needs to store a pointer to the common region struct. The pointer will be used in follow-up patches that implement rules insertion and deletion. Signed-off-by: Ido Schimmel --- drivers/net/ethernet/mellanox/mlxsw/spectrum2_acl_tcam.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum2_acl_tcam.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum2_acl_tcam.c index d7f1fb35ea2a..33787b154e74 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum2_acl_tcam.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum2_acl_tcam.c @@ -45,6 +45,7 @@ struct mlxsw_sp2_acl_tcam { struct mlxsw_sp2_acl_tcam_region { struct mlxsw_sp_acl_ctcam_region cregion; + struct mlxsw_sp_acl_tcam_region *region; }; struct mlxsw_sp2_acl_tcam_chunk { @@ -127,6 +128,8 @@ mlxsw_sp2_acl_tcam_region_init(struct mlxsw_sp *mlxsw_sp, void *region_priv, struct mlxsw_sp2_acl_tcam_region *region = region_priv; int err; + region->region = _region; + err = mlxsw_sp_acl_atcam_region_init(mlxsw_sp, _region); if (err) return err; From patchwork Sun Jul 22 13:17:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 10539319 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 EF0B31823 for ; Sun, 22 Jul 2018 13:19:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DC365281F9 for ; Sun, 22 Jul 2018 13:19:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CF66C28372; Sun, 22 Jul 2018 13:19:03 +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 EF6F828384 for ; Sun, 22 Jul 2018 13:19:02 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41YQF10DGczDrM8 for ; Sun, 22 Jul 2018 23:19:00 +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="wcoYSbTP"; 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.57; 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="wcoYSbTP"; dkim-atps=neutral Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80057.outbound.protection.outlook.com [40.107.8.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41YQD82L3gzDqrX for ; Sun, 22 Jul 2018 23:18:16 +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=bTs63eI02UJ7HIcvdK2FarDK8gFOh9ySq+55Ses/XqY=; b=wcoYSbTPtwgSSZT1MuZ4p70ODonypVHt/O1cvnlVRmMvzX4h9hU8nn6bAn98gVzd+s8T6ZJsjUsJrm8xslRZT+TaJ+DgLbYbE9Yy/TfdTOvJV57MHVLArETSAJ4nLSjlYthcBYKH0Z3nAEaRNa88h3CuxxJMzgbdls4WWpV3268= 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:06 +0000 From: Ido Schimmel To: linux-internal@mellanox.com Subject: [PATCH net-next mlxsw 10/18] mlxsw: spectrum_acl: Allow encoding a partial key Date: Sun, 22 Jul 2018 16:17:04 +0300 Message-Id: <20180722131712.30578-11-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: f84d6abb-4efb-48c5-0013-08d5efd5902a 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:aEFDBNrBnIZHadZNepbaEHTK4Jq1JPmdKyjrt1HgNDu6RYIwMcOKJsQ2ipvJR2xmKgC8tcArniVBQp59cYwSD1nMeL5V90SjJ4ZvlK6HIugXd0pF0MOvO6qWv0z7EV8yj/hfAQflZSVtChSR90CYYzyaG78U06DPgS5H424jWxXybPxd1dIzz7jrBNkkmoQMYPuPl6aYPqAwCaSCF7PH8SvzOG44ip03BXpy8VAZYzdu2HTltajgXevdVlDMMYCi; 25:fB6OXxeOGsBf38TBMYJLgtdRJYS8CN1uRZfE/CwmioXfhBLBKFRJCzSXbbyuJlXkebHE3jX+THoRX5sL1Z1lRSOL+UUgsslr4ajRRAVv+MAXDsU0tfAzmSPidyXGOOoIy+ZZC6pq3ZQs0QYB+Hm7IrfP36iD/UpDwo17XOjylkTlKPiupK0/AkfKeuwYVnuL8GMKAT/B0q2G26e95KzBATIA1a6YX7m6tY44fv65SxayodQEdKZWwZAf4VyszEZU+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AcUvU3jlfwxWtc2BGbvSf4i4SB9VjFfRMs1Pg/eHTnMt4t+DvBI7KZwp0tig9pkkdoB+138O89D08juD7FFolbBq5u5a6I3F4noovExUWVTEsOSZ6kQSCYI6ZrQ== 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)(575784001)(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:m2cIF0tY3x0PjFuhd91svWmMPwSzWZ4EOoUuMSC?= 374IIT55oieWJvtxDiI1oALAU2qE2X+OnoFs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5:wkCcyb+/xMMi0gwJ8OE4R6a3Og170XflnVp1k6uykz6V4NBlMjHlhcMbTnNEIgdGIzzPLTf4aaC2Hqhb+eAyE2tvEPbZlfAqyyB5UiHAVepcSK1nrlDldc8gf9Rnn/hGjhscRb7+zZV6dkleWPTRkkER8XkW6hQSXvQzP4ihwi0=; 7:j2FwvYWQ2/HyqPW3VnYVb83x/IyCjDiSLLYIh0sjv7BLXPaozhF1K+PSBHYoJRUtlSn7eCcC3Jb6XjK9yyNz97qMY725Wt9oILulWFK9ChSBxCh8Nu7iVDCt92BcqhmvzJcM5kTy3jPRrhQ902JI4pGOSRvREn5QH4Oxiks5C4dI6EJJUzNP3jTtIGHKoAJQt4QnQgrBqPTuDrZNOKYvtwX2YT6bUKRr/gpjH7dz24L3GtjteVgHRCELbt0fGnzG SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2018 13:18:06.2912 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f84d6abb-4efb-48c5-0013-08d5efd5902a 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 When working with 12 key blocks in the A-TCAM, rules are split into two records, which constitute two lookups. The two records are linked using a "large entry key ID". The ID is assigned to key blocks 6 to 11 and resolved during the first lookup. The second lookup is performed using the ID and the remaining key blocks. Allow encoding a partial key so that it can be later used to check if an ID can be reused. This is done by adding two arguments to the existing encode function that specify the range of the block indexes we would like to encode. The key and mask arguments become optional, as we will not need to encode both of them all the time. Signed-off-by: Ido Schimmel --- Notes: v2: * Extend mlxsw_afk_encode() instead of creating a new function .../net/ethernet/mellanox/mlxsw/core_acl_flex_keys.c | 10 ++++++---- .../net/ethernet/mellanox/mlxsw/core_acl_flex_keys.h | 2 +- .../net/ethernet/mellanox/mlxsw/spectrum_acl_ctcam.c | 5 ++++- 3 files changed, 11 insertions(+), 6 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 5f8485c7640e..9649b4d9349a 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.c @@ -457,7 +457,7 @@ mlxsw_sp_afk_encode_one(const struct mlxsw_afk_element_inst *elinst, void mlxsw_afk_encode(struct mlxsw_afk *mlxsw_afk, struct mlxsw_afk_key_info *key_info, struct mlxsw_afk_element_values *values, - char *key, char *mask) + char *key, char *mask, int block_start, int block_end) { char block_mask[MLXSW_SP_AFK_KEY_BLOCK_MAX_SIZE]; char block_key[MLXSW_SP_AFK_KEY_BLOCK_MAX_SIZE]; @@ -465,7 +465,7 @@ void mlxsw_afk_encode(struct mlxsw_afk *mlxsw_afk, enum mlxsw_afk_element element; int block_index, i; - for (i = 0; i < key_info->blocks_count; i++) { + for (i = block_start; i <= block_end; i++) { memset(block_key, 0, MLXSW_SP_AFK_KEY_BLOCK_MAX_SIZE); memset(block_mask, 0, MLXSW_SP_AFK_KEY_BLOCK_MAX_SIZE); @@ -482,8 +482,10 @@ void mlxsw_afk_encode(struct mlxsw_afk *mlxsw_afk, values->storage.mask); } - mlxsw_afk->ops->encode_block(block_key, i, key); - mlxsw_afk->ops->encode_block(block_mask, i, mask); + if (key) + mlxsw_afk->ops->encode_block(block_key, i, key); + if (mask) + mlxsw_afk->ops->encode_block(block_mask, i, mask); } } EXPORT_SYMBOL(mlxsw_afk_encode); 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 2ffde915349b..18d9bfed6001 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.h +++ b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.h @@ -259,6 +259,6 @@ void mlxsw_afk_values_add_buf(struct mlxsw_afk_element_values *values, void mlxsw_afk_encode(struct mlxsw_afk *mlxsw_afk, struct mlxsw_afk_key_info *key_info, struct mlxsw_afk_element_values *values, - char *key, char *mask); + char *key, char *mask, int block_start, int block_end); #endif diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_ctcam.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_ctcam.c index ef0d4c0a5a1f..11b19272ab13 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_ctcam.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_ctcam.c @@ -76,6 +76,7 @@ mlxsw_sp_acl_ctcam_region_entry_insert(struct mlxsw_sp *mlxsw_sp, { struct mlxsw_afk *afk = mlxsw_sp_acl_afk(mlxsw_sp->acl); char ptce2_pl[MLXSW_REG_PTCE2_LEN]; + unsigned int blocks_count; char *act_set; u32 priority; char *mask; @@ -91,7 +92,9 @@ mlxsw_sp_acl_ctcam_region_entry_insert(struct mlxsw_sp *mlxsw_sp, region->tcam_region_info, offset, priority); key = mlxsw_reg_ptce2_flex_key_blocks_data(ptce2_pl); mask = mlxsw_reg_ptce2_mask_data(ptce2_pl); - mlxsw_afk_encode(afk, region->key_info, &rulei->values, key, mask); + blocks_count = mlxsw_afk_key_info_blocks_count_get(region->key_info); + mlxsw_afk_encode(afk, region->key_info, &rulei->values, key, mask, 0, + blocks_count - 1); /* Only the first action set belongs here, the rest is in KVD */ act_set = mlxsw_afa_block_first_set(rulei->act_block); From patchwork Sun Jul 22 13:17:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 10539317 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 2F6DC1805 for ; Sun, 22 Jul 2018 13:19:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B19128372 for ; Sun, 22 Jul 2018 13:19:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0E4E528385; Sun, 22 Jul 2018 13:19:03 +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 37075281F9 for ; Sun, 22 Jul 2018 13:19:02 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41YQF03fNszDqnG for ; Sun, 22 Jul 2018 23:19:00 +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="Gh7Y0B3N"; 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="Gh7Y0B3N"; 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 41YQD84RxrzDqtW for ; Sun, 22 Jul 2018 23:18:16 +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=53oASw8eBJjbXXCcI1UOlm8xqVNgRn+rJ4nuHrIvuTI=; b=Gh7Y0B3NGMprlFyp7TC4pghPnGtsjasvnMKDxRqYT1F8dKMs7xcv9KKdC2qd/g53Xt/2CGp8UN8IdW468h5usmjcaKzhlYm8coJTYLGfaGm70S1JS9M02F13uOuaNsi61AIzVLOb78OFB2gQxd3JmSav0gMqOij2ajNZZ8of/8c= 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:07 +0000 From: Ido Schimmel To: linux-internal@mellanox.com Subject: [PATCH net-next mlxsw 11/18] mlxsw: spectrum_acl: Add A-TCAM initialization Date: Sun, 22 Jul 2018 16:17:05 +0300 Message-Id: <20180722131712.30578-12-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: d1e12acd-6f96-4f0c-d121-08d5efd590bd 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:yIVbSl7nDcPXAUcGYRS73hkdOIcnl1ud3P2NZMHo0EHBlGeCJ8ZQR+zcjd9s0DR4OCufZIhno5KmUbc/N8Im73+DAomFKR8EkMZDazlC3IBBLSbSf5pFobdzNPvwsX7vOj0FVYr3Jq2M2S69w6aqdDQnl3e7iVWbgYTaLmDEt1TtUx59A4/vxxWFmYlHDEP3tCQF4aBY9bZEi8OD6pwwNiGxdDUIcE6HEVgL7cor9FBJssJmLp+IivVbb/Z5W/bR; 25:CVjrpHww2OOvsN7y99orh/amL8sXp+gfoPTg2A+3XYcCr/+UHxbvOY9SsFKETf/uWSOxwBZ8zk6ah1e2EyYTaG+kEc7Lo/zvjqzz/E/35/nBNu7xJrdno/Eo/m57QMuw79//p50MY0mhLTRoPegrZZianWvASqNxyOI8el39Pr+qxMZtUzT3caOVjP4pZ6xdId3T22t0/O4vTHpzIOOZfUD5bBkEyHFTmfGm6gVQjM/tCShxhTcagSS3iigC93K+vRK+KCgUg3KVBfluuNJXmsQKktB0cUn9UZst4qk5mEO9m+ENdyq8oXy3/81pG9bhRaPtR8Wh7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6R0svuBbWSdifw9XH75e+ZtIl4Tr1Iw== 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)(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)(575784001)(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:+E66etCLk9Q8kfpqD+B+L1+OwnjyV6hxTk7gHSR?= jL3KnLrWYMydV5ZLd+oOSwYghs0YQCrZpTMAb6QB07etoDNZhRtScu1+/plu8/RjWzI7ggjRY2uvW+01nUdt0Dy8z+54/xm5hHQ/Al50uTuqoLBJ1uoq9aCU0itzdsRpG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5RKo6qrvs9BBg4xNPhhRXjailgLwMgnyG4hHUr1F9s12HzCOmDKBk76wXz2CXRDguPAPNwA3FA=; 7:LW9hO1ZlJTgwOBGfjlR81t9wwp+NhfUEDHTF00+uvu3xsrH2XlS+X26mFqJ9F/9ehCaUc71ctfgJf2+bRjruRBsPqU1pC7OhkpBsM4ycf/45LGRM87FJlfv7Gdlh0XBQps5/PJ48lI8fOH4bVNMAEUWQClHunEKKksjufSO6L6KlwQGe4oEjhVc4UJaVd3vnMT7EGyIzBVMwCJvLc89AdfSWldfROEjEa6YPpmLT3NiE8q1odBuvaYSX1vGrco24 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2018 13:18:07.2599 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d1e12acd-6f96-4f0c-d121-08d5efd590bd 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 Initialize the A-TCAM as part of the driver's initialization routine. Specifically, initialize the eRP tables so that A-TCAM regions will be able to perform allocations of eRP tables upon rule insertion in subsequent patches. Signed-off-by: Ido Schimmel Reviewed-by: Jiri Pirko --- .../net/ethernet/mellanox/mlxsw/spectrum2_acl_tcam.c | 7 +++++++ .../net/ethernet/mellanox/mlxsw/spectrum_acl_atcam.c | 12 ++++++++++++ .../net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h | 4 ++++ 3 files changed, 23 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum2_acl_tcam.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum2_acl_tcam.c index 33787b154e74..2442decd0652 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum2_acl_tcam.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum2_acl_tcam.c @@ -39,6 +39,7 @@ #include "core_acl_flex_actions.h" struct mlxsw_sp2_acl_tcam { + struct mlxsw_sp_acl_atcam atcam; u32 kvdl_index; unsigned int kvdl_count; }; @@ -100,9 +101,14 @@ static int mlxsw_sp2_acl_tcam_init(struct mlxsw_sp *mlxsw_sp, void *priv, if (err) goto err_pgcr_write; + err = mlxsw_sp_acl_atcam_init(mlxsw_sp, &tcam->atcam); + if (err) + goto err_atcam_init; + mlxsw_afa_block_destroy(afa_block); return 0; +err_atcam_init: err_pgcr_write: err_pefa_write: err_afa_block_continue: @@ -117,6 +123,7 @@ static void mlxsw_sp2_acl_tcam_fini(struct mlxsw_sp *mlxsw_sp, void *priv) { struct mlxsw_sp2_acl_tcam *tcam = priv; + mlxsw_sp_acl_atcam_fini(mlxsw_sp, &tcam->atcam); mlxsw_sp_kvdl_free(mlxsw_sp, MLXSW_SP_KVDL_ENTRY_TYPE_ACTSET, tcam->kvdl_count, tcam->kvdl_index); } diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_atcam.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_atcam.c index a27d3b0f9fcb..89c78c62e7e5 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_atcam.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_atcam.c @@ -93,3 +93,15 @@ int mlxsw_sp_acl_atcam_region_init(struct mlxsw_sp *mlxsw_sp, return 0; } + +int mlxsw_sp_acl_atcam_init(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_acl_atcam *atcam) +{ + return mlxsw_sp_acl_erps_init(mlxsw_sp, atcam); +} + +void mlxsw_sp_acl_atcam_fini(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_acl_atcam *atcam) +{ + mlxsw_sp_acl_erps_fini(mlxsw_sp, atcam); +} diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h index d6af9920a930..0f242afdf5fe 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h @@ -172,6 +172,10 @@ int mlxsw_sp_acl_atcam_region_associate(struct mlxsw_sp *mlxsw_sp, u16 region_id); int mlxsw_sp_acl_atcam_region_init(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_acl_tcam_region *region); +int mlxsw_sp_acl_atcam_init(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_acl_atcam *atcam); +void mlxsw_sp_acl_atcam_fini(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_acl_atcam *atcam); struct mlxsw_sp_acl_erp; From patchwork Sun Jul 22 13:17:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 10539321 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 F04C11823 for ; Sun, 22 Jul 2018 13:19:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DCF13281F9 for ; Sun, 22 Jul 2018 13:19:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D14F028385; Sun, 22 Jul 2018 13:19:09 +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 02140281F9 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 41YQF71T6tzDqmj 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="mwLL2afX"; 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="mwLL2afX"; 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 41YQD94yP6zDqyG for ; Sun, 22 Jul 2018 23:18:17 +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=9nck4N5fvv+VWqoLneOYZSn/+LYV0Tt4/GXmLChIxI8=; b=mwLL2afXh7CmufPEtyV2aR9o9H278AaBdkyOMgBuB5xDGclQTTVW8PBzqVQi0+M+Dl4hZgGlKSUA6FJ2I/JYIrhqRF1R0GOEiSqbr9bL8P204POpOeVirbbVrSoZpu+XFnsWaFKXYD+I1elbjx/VOqbLfPuRxj9P81IvXpjYIzk= 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:08 +0000 From: Ido Schimmel To: linux-internal@mellanox.com Subject: [PATCH net-next mlxsw 12/18] mlxsw: spectrum_acl: Encapsulate C-TCAM region in A-TCAM region Date: Sun, 22 Jul 2018 16:17:06 +0300 Message-Id: <20180722131712.30578-13-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: 61a75ec4-d2b4-47f4-a22a-08d5efd59151 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-Diagnost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OYsug1pPgYryJbUFuCor225twDV5ccKXkw70FNKwaZbQBVg3CRzu0GTvRtK6bNUImt2rcxcsWhCWj70Zu4x0edzi3kNdd21U2QMdI/xoCokQPuT9WhhD0S3rhqLBbNAUs39SPEMdqNZBK7YGzogq6EHpWpcozMkHFxOLssNCAar/1wjKrlcFQt9Gg+ImQz1Ko1Gc0zbEYG/3kA2v6pel5xwSWo8W3+HUTv+WwHwcDY/MacJw/HgSnY1vp9nucIyNlCz9/evPm6O9TLl+UgDBIuJjrB26Y84ya3GzlNFJutMVk2iE1B16GQCfzK75I7Ex1zYEuThMSTykqmXlMLq0cniakd8NXoenT+tZ18Tb0q/DjcjeNbljL+/2; 4:EyustyocMTxUwmRI+3IjToQXdX+VM1Q/lGgPAnUNIGsrD8qosmCz4m3paL0SdGgXgJvDh3eotgF442VOPIitV1rcrIJoWn0hFql1AJE/ipap2fQF9FOA7jWfLgJsih+n3Tw1v8SM749a4IWqOiRdAH/5vCPHaqU3IPz2LSVe78spQIvLUKxlVB/3ASamNuMnwNvvO9BB87PRzvPXZ3AuBlp5watPc7W0iWwdNu3khwlin9kzoe+nRdvRXHcafKDZ6/w27agQhH85Mzhq+VNzXQ== 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)(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:rB/idNYJ2qrf1NCBo70ZSXOJjKSTZg1cSqeaiuY?= W/PqikTASgRWNXYpDk0u8cxapb8+anS12W5OHjCaCon15/b57t76V8tKF5rfekqoDUlyqTKDiCVCuoSWQGBXoxizvEe8E5oRWhqXMX8J5s03eSqABdZmN4ujQKn/AVQZry10Tnb7T7tKF4QrA7sAyAb4dEWnOngdBbzG6yTxRzSumOQ9saaqJULucl3JeeFT7fieGK8Xd3Pn3qAVS8578v+AXLfcVoNEy3FYd8VtIjgYEuC3NujpmstF0phDJHNnI4jmLsQEWi/C9HWlhFyZOJ96Nn+eS9VkZ2vodC1wgRZgsibaDTLW2XCCzstRSfwRPh3EUTD5AI4UibmaxSO7tANqHt9+LwXsKbe6W+fSLfOXTSe+pdnpVhRZfYN3sOyLcLjK6zM271m3NCSmJQbwhcBo40rGz+QPbf0Z63/VhURT4pMEEZI4u34pecjXLN+dZFRKaYBHnAydGJkM1vtWJ4VT5sbRfq6n35CUhOYehtYnSvzDbTuVOsIPadp16qHb9/EcZwPnYDGC+bbk/jhWLjRkrIajvw7OCrg/n6FyyMc0lDDMBB5oJVtNYsRzi05lFLXBf7gcD6Fk3bKwO1BN6Fnsl4/NY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OeKbCcEbD37mzX0yecaoCo5pRgBHfxbRiBtLYYzS6Dgb2U+9CyoWZ5MDWFiKhXPvJ6KIHQgNrVA5gLQFCgxa25Dt751iybYFnxPgmHsuMEO4xSTXxLAcXQX/c9Yr4h58nhr44xcZWzjAY4gohoUfwFAVEo6ILktpvb90+Rz9wy3+YJXWJwbX8996bUiOYtIJYQU5xbGJp+ybbk9sG+PexVSs1OUjWwD1QljJywYLbptm7ST2l94kVtfTGpmLMaeKFRrK4tmGxwwI4+rW/iYP6HI/oTFaInMl4s9PYdjdQat7KJvtsVNFLpzESrHlR5x29FpPPuSM7qv0twU3b+onclZasieFcFs1g7Icow4mImMaEa7QWyrvkg+apVorwv+BjKDkb2gMHphu6p0LqPKT8NxtlyFjtr32lVeJ2e5Qk5qEzwURvYLOSGkeU988qLA0PRj6BVVppKO0b2w==; 5:lVEZEAJFH+JETlaNPHXLbofUIEGUyKDpo2spS86mRy/w1DwexHLGwEzn0yeadU+o7GgSW1l83dqynrkL4FUz033rtPktZ3lOFHQJVnSVqIvSArVVoAGen3kimz6GRm+ZF0NYvFgrZrcUruLpgPoLizK7L9BkjOnFApL+x6FaXf8=; 7:Qvb+OAwiIkS/OOa1noLOPuzkTrsPDsM9SgM4Pw96mEASAtLjhjyhOBZv+UHUy0RMWiph1x/9tpjRgjWbJyff84Z42KfCM1pTH1194Y4mucrgBIYijvigVlfqjyeb4Wfb3WlsuPjbVz2r384FaDK9zgMOAyE/ucSYPVgt6d3hd6AjZNOiYKC6YotUUXYt3gXbW6TmsrkG1u90szvqJGdys6F0SbdE4l8VWPGexWOGddlD/LAibV0eofHObbO2ciGe SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2018 13:18:08.1974 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 61a75ec4-d2b4-47f4-a22a-08d5efd59151 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 In Spectrum-2 the C-TCAM is only used for rules that can't fit in the A-TCAM due to a limited number of masks per A-TCAM region. In addition, rules inserted into the C-TCAM may affect rules residing in the A-TCAM, by clearing their C-TCAM prune bit. The two regions are thus closely related and can be thought of as if the C-TCAM region is encapsulated in the A-TCAM one. Change the data structures to reflect that before introducing A-TCAM support and make C-TCAM region initialization part of the A-TCAM region initialization sequence. Signed-off-by: Ido Schimmel --- Notes: v2: * Move C-TCAM region init to be part of A-TCAM region init .../ethernet/mellanox/mlxsw/spectrum2_acl_tcam.c | 16 ++++++---------- .../ethernet/mellanox/mlxsw/spectrum_acl_atcam.c | 8 ++++++++ .../ethernet/mellanox/mlxsw/spectrum_acl_tcam.h | 3 +++ 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum2_acl_tcam.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum2_acl_tcam.c index 2442decd0652..7e392529a896 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum2_acl_tcam.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum2_acl_tcam.c @@ -45,7 +45,7 @@ struct mlxsw_sp2_acl_tcam { }; struct mlxsw_sp2_acl_tcam_region { - struct mlxsw_sp_acl_ctcam_region cregion; + struct mlxsw_sp_acl_atcam_region aregion; struct mlxsw_sp_acl_tcam_region *region; }; @@ -133,14 +133,10 @@ mlxsw_sp2_acl_tcam_region_init(struct mlxsw_sp *mlxsw_sp, void *region_priv, struct mlxsw_sp_acl_tcam_region *_region) { struct mlxsw_sp2_acl_tcam_region *region = region_priv; - int err; region->region = _region; - err = mlxsw_sp_acl_atcam_region_init(mlxsw_sp, _region); - if (err) - return err; - return mlxsw_sp_acl_ctcam_region_init(mlxsw_sp, ®ion->cregion, + return mlxsw_sp_acl_atcam_region_init(mlxsw_sp, ®ion->aregion, _region); } @@ -149,7 +145,7 @@ mlxsw_sp2_acl_tcam_region_fini(struct mlxsw_sp *mlxsw_sp, void *region_priv) { struct mlxsw_sp2_acl_tcam_region *region = region_priv; - mlxsw_sp_acl_ctcam_region_fini(®ion->cregion); + mlxsw_sp_acl_atcam_region_fini(®ion->aregion); } static int @@ -165,7 +161,7 @@ static void mlxsw_sp2_acl_tcam_chunk_init(void *region_priv, void *chunk_priv, struct mlxsw_sp2_acl_tcam_region *region = region_priv; struct mlxsw_sp2_acl_tcam_chunk *chunk = chunk_priv; - mlxsw_sp_acl_ctcam_chunk_init(®ion->cregion, &chunk->cchunk, + mlxsw_sp_acl_ctcam_chunk_init(®ion->aregion.cregion, &chunk->cchunk, priority); } @@ -186,7 +182,7 @@ static int mlxsw_sp2_acl_tcam_entry_add(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp2_acl_tcam_entry *entry = entry_priv; entry->act_block = rulei->act_block; - return mlxsw_sp_acl_ctcam_entry_add(mlxsw_sp, ®ion->cregion, + return mlxsw_sp_acl_ctcam_entry_add(mlxsw_sp, ®ion->aregion.cregion, &chunk->cchunk, &entry->centry, rulei, true); } @@ -199,7 +195,7 @@ static void mlxsw_sp2_acl_tcam_entry_del(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp2_acl_tcam_chunk *chunk = chunk_priv; struct mlxsw_sp2_acl_tcam_entry *entry = entry_priv; - mlxsw_sp_acl_ctcam_entry_del(mlxsw_sp, ®ion->cregion, + mlxsw_sp_acl_ctcam_entry_del(mlxsw_sp, ®ion->aregion.cregion, &chunk->cchunk, &entry->centry); } diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_atcam.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_atcam.c index 89c78c62e7e5..93401f08d987 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_atcam.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_atcam.c @@ -77,6 +77,7 @@ mlxsw_sp_acl_atcam_region_erp_init(struct mlxsw_sp *mlxsw_sp, } int mlxsw_sp_acl_atcam_region_init(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_acl_atcam_region *aregion, struct mlxsw_sp_acl_tcam_region *region) { int err; @@ -90,10 +91,17 @@ int mlxsw_sp_acl_atcam_region_init(struct mlxsw_sp *mlxsw_sp, err = mlxsw_sp_acl_atcam_region_erp_init(mlxsw_sp, region->id); if (err) return err; + err = mlxsw_sp_acl_ctcam_region_init(mlxsw_sp, &aregion->cregion, + region); return 0; } +void mlxsw_sp_acl_atcam_region_fini(struct mlxsw_sp_acl_atcam_region *aregion) +{ + mlxsw_sp_acl_ctcam_region_fini(&aregion->cregion); +} + int mlxsw_sp_acl_atcam_init(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_acl_atcam *atcam) { diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h index 0f242afdf5fe..a982df31cc47 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h @@ -162,6 +162,7 @@ struct mlxsw_sp_acl_atcam { }; struct mlxsw_sp_acl_atcam_region { + struct mlxsw_sp_acl_ctcam_region cregion; struct mlxsw_sp_acl_tcam_region *region; struct mlxsw_sp_acl_atcam *atcam; enum mlxsw_sp_acl_atcam_region_type type; @@ -171,7 +172,9 @@ struct mlxsw_sp_acl_atcam_region { int mlxsw_sp_acl_atcam_region_associate(struct mlxsw_sp *mlxsw_sp, u16 region_id); int mlxsw_sp_acl_atcam_region_init(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_acl_atcam_region *aregion, struct mlxsw_sp_acl_tcam_region *region); +void mlxsw_sp_acl_atcam_region_fini(struct mlxsw_sp_acl_atcam_region *aregion); int mlxsw_sp_acl_atcam_init(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_acl_atcam *atcam); void mlxsw_sp_acl_atcam_fini(struct mlxsw_sp *mlxsw_sp, From patchwork Sun Jul 22 13:17:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 10539325 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 E19271823 for ; Sun, 22 Jul 2018 13:19:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF086281F9 for ; Sun, 22 Jul 2018 13:19:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C333728385; Sun, 22 Jul 2018 13:19:15 +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 F22D0281F9 for ; Sun, 22 Jul 2018 13:19:14 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41YQFF1bHQzDrTJ for ; Sun, 22 Jul 2018 23:19:13 +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="LSp+17O8"; 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.57; 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="LSp+17O8"; dkim-atps=neutral Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80057.outbound.protection.outlook.com [40.107.8.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41YQDB4Jk6zDqrX 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=ytRIAdV1elDY1orj6HcIikwpwKorkwVXomeoLhvnFi0=; b=LSp+17O84ZmqNaIQbxYQ7bDB3Y2BcGjzojXw5zb92OJX9xNytg9RAjllqYzyNUGtuShGKvJXsRL3/VwXTrfYn3UMA/0EEqc5Z/bKnFQ1WU4rfI14zpDwxphKn40Hk+kcjMMyhGNUW8UDiKLbESVxdm3zAK18XZxUebLL79q4Ufo= 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:09 +0000 From: Ido Schimmel To: linux-internal@mellanox.com Subject: [PATCH net-next mlxsw 13/18] mlxsw: spectrum_acl: Make global TCAM resources available to regions Date: Sun, 22 Jul 2018 16:17:07 +0300 Message-Id: <20180722131712.30578-14-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: 7ed6c449-fde4-42db-4c33-08d5efd591de 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:pek3mPqZ9E7YOKBxIlbgC8aBVZjYAqmmjglaTAdmXM/W/uWUCI0vdEZdqbC1p0sYNGuuR81y+RhcdIhc1zr9EsiBjTA2SiWYSbxuacm8A7ZzbzKZuOtBrBPQI5vKtTo/GLfqEE/I8eVm25S1XfqvxOv7GuQHWByReR4/oO5RlPPJqksg8YYXVjRdEJ1ji+vCzE980iV7eQQbVWaZP9mxNwYMuwEffX45D/FSmsExC5IxtC8aqwtOvEjAT2L+GpdR; 25:25KLP93uAWZJgLYRn9+DJG0lmQmfjJfuUYUZhDokDxIP6gpv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2GCDCUcQywNBfCimvWIgBYuGaDVLUOKT8FIawi4VJBIsi8fZ1wpkYHe8; 4:yg/knRvQgj/sUQR5rE4mgieVZ9bhwcxmqNkDvl4Ga+x+K2zWtaXdTc8yms9amlVBLksEB3ZKGVU+ZE2K2VdMnxCdLbW0SuM3AAWaLk3p3lGX6BD36JqSE8HRYqw1oMsFcOE4gDadYLTP+o3dMAxcxKy1KDp3GwJuBaFWfa5p7KbSIoaJIWQX8BItQrCRQ1RWHR+tlmU2MrL9qE+IsizY25yFk33pYsoAaXZsLY/zv1pR8hSwpoBHeJkqwvnxW3Vl0JDWxvreS/ej4nUu1yQ0ow== 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)(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:RfcA7SUzjqYIykT+2YIMsYB5dEJWOuYBjB8c5+5?= uiSmXgVag2vDYhXJvtK7BEUNKdh/bJ7tGAHaIXu7r5gTEknGcbOh/v4o4uIXeE46VKMPGKPFS00OF1H+7eVjIiNekW0CrllD9KamtQvy2gdqJkIscQGx390ECQUssAQ+MbNlcR0GB41Cd9KNAMhLclUbzx2AgQ67bge093eIqvBwKRhgC/pDPSXxHxDWhIRIMlNeYPLojyOMf9Zh5uF12iPSMrwCAK/S5sZBXXIvODLh3ACXgHDZhSY0sWefvaXbGdgnaquIwl3U72xNFSKWCL15jYGbek0bTvf686bCftYOfi2oiZOw/CIWfvuI17dU1aabaaqKGOKjU7yocr1TQYkzyR6AkzoYJUjsmXRYYvchb5B/QbuGuVaUHxry0rdjx+Z36N05hDHtgJf1dQOJL34r/tj49DvrWGyKywFQJykfBr0BNpI+HMj/W//fojyHhpws9J4U7bTSU7kGn/4FjPLV71Kn22pJRT3x6eIw8ik8SP8OsHw4XHmK7ZsMSV9vbRHyT89Wsd9Dbbhte0gNSQpgXdJT5RQMyP0U2qS3OoPqW07Fs1IVZV3IrLQBiOVORmTt213bCSYYpmyI9ki4eaxA8/VI2nhRDNrS+XJOEzNG2h22Wuelp1i/c062kdzWahtTV2YjW97XzuwWopNpbwWJxVLZg8855DMIattlHaBBO0gl6hvW8DPch4PEz2Ho3UcZwXUtXOrWxZ6fRNHIBguY7HPF4UZAYxpSwfwsQ6N1hl74QnsErTN66V1Zp5zyJJ6hpaC7tKh770uOncbXq4svFBcuo8RbeVtGPvlmY86BEqJXJx6CGovOtSm+LJ37qKulHcBme2JfZsziO4EdU5cH6p503ikEbBfSrdajX9X0feFoc7/MmHYt+NIludY37QSJ78nxoUk68XMAftkDiL9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UXY8aWKHaXeCNd1isCbqjgJIMIwZnEBtmcOjMtxyHqmyrujqnxAo2sVaf/6gWdKLQloP+bh92yty7Q9L9FHeGiuLXODZZPK3jaZEJAJD9xeQDWVhOZJbP7U2jtDQHj7jH17FKn7Qy9fbFxhiT6ryJtjEjPwUDx+zg==; 5:pSn8TyOlSFedwvNpx1XzPtUD7zFJ273H8S+s52YdHbv2BOsrRYnp2FrcFnfDGhvahvo37n7KCb8RPD4CkOmbpY8Cv12llfQgzyVdD/DvXVuCFUxpVwtfVO9Ht8xBVd/bX3VTMOEDd2W+0icY1YP2U7Pbs02wfMp/Um2IveunsDM=; 7:KuCYQxNZ+q3oaAS2Y9n4Qkx/ykDT0JuDJcW5XzpWAe6KXY9qYQpnGFm0uB9q9v5jfH+gngXYeJjYeJLjKI8Qs2KKg7Zx+oCwGnLmcNmwV8C2mwAfeAQOAj4oObpdNIsSV3GCENGawyKqTJK21spSu9eBRTb4elE9wCMvFIS71K2EaH22qf+MIAUyyyZ8Fkrx0c8f4g2EYXeSOY4Zj/KzirhjQjajCntGLZUcipAL5U+LHKoQaTII1EnezwJXMrBj SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2018 13:18:09.1349 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7ed6c449-fde4-42db-4c33-08d5efd591de 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 Each TCAM region currently uses its own resources and there is no sharing between the different regions. This is going to change with A-TCAM as each region will need to allocate an eRP table from the global eRP tables array. Make the global TCAM resources available to each region by passing the TCAM private data to the region initialization routine. Signed-off-by: Ido Schimmel Reviewed-by: Jiri Pirko --- drivers/net/ethernet/mellanox/mlxsw/spectrum.h | 1 + drivers/net/ethernet/mellanox/mlxsw/spectrum1_acl_tcam.c | 1 + drivers/net/ethernet/mellanox/mlxsw/spectrum2_acl_tcam.c | 6 ++++-- drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_atcam.c | 1 + drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c | 2 +- drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h | 1 + 6 files changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h index 016058961542..e86ac922aa41 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h @@ -622,6 +622,7 @@ struct mlxsw_sp_acl_tcam_ops { void (*fini)(struct mlxsw_sp *mlxsw_sp, void *priv); size_t region_priv_size; int (*region_init)(struct mlxsw_sp *mlxsw_sp, void *region_priv, + void *tcam_priv, struct mlxsw_sp_acl_tcam_region *region); void (*region_fini)(struct mlxsw_sp *mlxsw_sp, void *region_priv); int (*region_associate)(struct mlxsw_sp *mlxsw_sp, diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum1_acl_tcam.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum1_acl_tcam.c index d339ec43d79c..926483434e99 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum1_acl_tcam.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum1_acl_tcam.c @@ -122,6 +122,7 @@ mlxsw_sp1_acl_ctcam_region_catchall_del(struct mlxsw_sp *mlxsw_sp, static int mlxsw_sp1_acl_tcam_region_init(struct mlxsw_sp *mlxsw_sp, void *region_priv, + void *tcam_priv, struct mlxsw_sp_acl_tcam_region *_region) { struct mlxsw_sp1_acl_tcam_region *region = region_priv; diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum2_acl_tcam.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum2_acl_tcam.c index 7e392529a896..bef2329bb233 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum2_acl_tcam.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum2_acl_tcam.c @@ -130,14 +130,16 @@ static void mlxsw_sp2_acl_tcam_fini(struct mlxsw_sp *mlxsw_sp, void *priv) static int mlxsw_sp2_acl_tcam_region_init(struct mlxsw_sp *mlxsw_sp, void *region_priv, + void *tcam_priv, struct mlxsw_sp_acl_tcam_region *_region) { struct mlxsw_sp2_acl_tcam_region *region = region_priv; + struct mlxsw_sp2_acl_tcam *tcam = tcam_priv; region->region = _region; - return mlxsw_sp_acl_atcam_region_init(mlxsw_sp, ®ion->aregion, - _region); + return mlxsw_sp_acl_atcam_region_init(mlxsw_sp, &tcam->atcam, + ®ion->aregion, _region); } static void diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_atcam.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_atcam.c index 93401f08d987..f030da8b9c31 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_atcam.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_atcam.c @@ -77,6 +77,7 @@ mlxsw_sp_acl_atcam_region_erp_init(struct mlxsw_sp *mlxsw_sp, } int mlxsw_sp_acl_atcam_region_init(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_acl_atcam *atcam, struct mlxsw_sp_acl_atcam_region *aregion, struct mlxsw_sp_acl_tcam_region *region) { diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c index e06d7d9e5b7f..9fff3fe189c8 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c @@ -560,7 +560,7 @@ mlxsw_sp_acl_tcam_region_create(struct mlxsw_sp *mlxsw_sp, if (err) goto err_tcam_region_enable; - err = ops->region_init(mlxsw_sp, region->priv, region); + err = ops->region_init(mlxsw_sp, region->priv, tcam->priv, region); if (err) goto err_tcam_region_init; diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h index a982df31cc47..51f7e2327603 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h @@ -172,6 +172,7 @@ struct mlxsw_sp_acl_atcam_region { int mlxsw_sp_acl_atcam_region_associate(struct mlxsw_sp *mlxsw_sp, u16 region_id); int mlxsw_sp_acl_atcam_region_init(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_acl_atcam *atcam, struct mlxsw_sp_acl_atcam_region *aregion, struct mlxsw_sp_acl_tcam_region *region); void mlxsw_sp_acl_atcam_region_fini(struct mlxsw_sp_acl_atcam_region *aregion); 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/fpWEC4YPJo5Pl6dAlCJJpBi9UiBBCSGDY3wdBvjNM10RZVFexsQuDSCKsHo37Jpgzok51ItCEoE/ZcQH0J8BCBpUXse8BQ==; 31:Hd56YXxZEBGvIlJ8UKEZJmR+bTS6P/qRsWVOLdV+HHttNGdyhTcKPkvuMgeZc+fqq5gUiQZrgcbsF9A3swzEP61e8yNSLehG2LT1grJqd93JxoVQMniCZbV+O+3kpwo7bgc5oIkZIaoXOtt+1/1m4rKd85yPBEYk29ZtGZz+No6wDkgs18GGwYWLxa/ubI3hjLIQA154/PmFtErE3lm4/tZhmmoXePCo241/Wxr1gxc= X-MS-TrafficTypeDiagnostic: HE1PR0501MB2331: X-Microsoft-Exchange-Diagnostics: 1; HE1PR0501MB2331; 20:jwFG2cmwqxwpOlOViii4ZPSSgplvVvJVwMKxxWYwF/BdXYTKmE4CaQuVB+KIpJtK0xzV/hXBjJxmLj6Bu2U0FV76E2lire1ajuirTsg0I4xrJV5l7sxNJhL8UtIE2lFBQpEL3HRw6yJtwTRT3xfTJurNaa5J91HS8TC5nofvlPwd49oVCK83lcRNDjvQwye54QVG8cYX9eCurdt1YmhCbFgJXyRUaUyDjyWqU6SzcvB1Q8UWwLG4D+iGKsaxm0RLAru+P9EZql+wNmGaHGsiHZqMNjwQumwLDE8rtbdeNn1XGrFFh56vIwvE+++Hd1E6Hxn4SmHyPKol4BM9uRmVQ2oHz6dk9Iq1ecB8uGK7UTNxnFjpeFvG0tLHQ8Uy2yo2s1zVhIgGzD/VYh353o08Z/LhRw3oveLtGOQD1JhtHH8lL51ObfKuHmk2oDHuCFJ/SMaBCA62ZzyQ9c7TcBvK3fegbGS7ezOOiGbtR86WjX3qT1i6OBcbdu8HtobwxDBp; 4:UD1fXlCAD3zgiWjNnRVQsY4ec9DhsBcHcn2LCzOZDhL884cV63W6pK7K+qLU1/1vng3p7u1aLOdd5R0uNHHBZqSffx2K2yLAIsIE2YTbe1ZofDIAyC33n2bmk0Udya0ZfQ3W98ibNJWKTPtgbpbhtTyi61C+sSyZr9Pw/Cpqh7fV0CSe+8EWH5NMrjbeT3v/GTE0x3wZG5QZyCma+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+dkqn24xmTFv8Lb5Xs2NfSzeTjz1Z4vQ8cme7T4j65Dvb0TlkGoqZ6dYUHz2JBoF2e8UQEANuX1jgWPwIHFwycuZbKOognM04TpDLgSBSWqxeVXx/iM6a8/64H7oz/mnVy0YjF1lYs9nxD+v8/hnbBBneX2wdwhpYaWoYBGqiG8gnkXjykHlUuL4E9PuLOP/nX0iJ8S5NiKFv37YfrBU+TE/JvQLwVMCYeysbRjdVBPdArfvJwq2AcLyQaxTJPyxWGwHqLMt3xg0WybxeD8uBZTPOJH3GpK2MggwJxa3gS7BKfCeP9IKlrankWcEp5L2ZgCe2H2yc2TCcT8MscR7zaby902i98rJ9gKOEL8aG0Vt/gJ5+j6K41BJN1gJlWHK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pamDiagnosticOutput: 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, From patchwork Sun Jul 22 13:17:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 10539327 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 5A02496FA for ; Sun, 22 Jul 2018 13:19:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 47509281F9 for ; Sun, 22 Jul 2018 13:19:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3B98028384; Sun, 22 Jul 2018 13:19:16 +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 7692E28372 for ; Sun, 22 Jul 2018 13:19:15 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41YQFF4kcpzDrvG for ; Sun, 22 Jul 2018 23:19:13 +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="ObXg9IPH"; 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="ObXg9IPH"; 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 41YQDC3YPjzDqyG for ; Sun, 22 Jul 2018 23:18:19 +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=fY3G9aOVnvL1LZGgK2yvRfI2y/Vk5oeNo5wuj9vd2eo=; b=ObXg9IPHXRet9nPtnTrHfGyZgZgrkVnB3NWp8tn89aeYP4D6hAFFDoGbCRwBqGD6PQpzXo02/opTiDmPOMETuUw+RG1NWmgnEf/WMjd2QILdEtzjF0BzJ+CUNZJL3PoNJSKmj9SBbW7zVVxzRIskiZVJ253Quwb/QqGYQENvLOs= 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 15/18] mlxsw: spectrum_acl: Pass C-TCAM region and entry to insert function Date: Sun, 22 Jul 2018 16:17:09 +0300 Message-Id: <20180722131712.30578-16-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: 6b7626fc-a69f-4d9d-a049-08d5efd592f7 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:VnT5vTfJ9yV3arsZ7wF+V6730qFO56cr7iuBElC0S0tv44K4/8jbKAet7Z7TYkoUEwzdxePfMWrByvix2khoc84a1rV7eXBVvzl5e/YwHnDnlZNh6BTkMqIKsgt9cdxGwS6glDGdImpzQbOEY4SW+qTs5IS/BdBCk3VO7kguwA6JaZxmJ7NSMKsbbE/RwXPaAyIB2ZYIF2OWrCBXNW5+JMA66rVw9GILZEEQR02eMA9iFRmXLM5eZ1LKISAJVI5G; 25:IRlZqM1LwZ6yCSFNTaaeXD4x5sGjjJnjkgzqR9uzHchVRC6oO3XyLrh2FXEsjrKDaaWZMiTXQjw/ngxN0zb9qJUyqbwWvTxjVxzK8SL1dUBKViYg/l2DEtylinuzVA5UDZ6AdQl5+kFW1Ym8z5U39b+v0OhZ0vuJmXPWtfw27GJabx9Kz+JoP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V5LKPAj2ydn6tvT4zhu69yavhMbVlK4EWRb0lkE//0Do6DPTED1+bhCON7RiGoGcG+yPKY6QTZMcy1vFN4fQTnfxZVvc2WAyOtKkko6juKP9qVirICTNto9MEyv+243TitYfSydG6seoOzaY7NnJjSjIKr298ck6n2pJq6dogjjxfKxPSJkQblA7FqJsEuCS73epuS98ZVzczCuhVQ== 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:PhXBaz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WzF/NAirONVI8Hl1fvBGNjjtDXaAe0w/iefrqq/dD7ilf6N4g2zlIKNzFzw==; 5:0bzZqtuP6RHqiDFJ/D6G3fMPnWlZ7CmFj589gBoaN8JEo0tykNwTSXKMFMwd+iMHsFI3PVJCsuM0xPXlf1oIbjgfL2WMVs05K2jv9xbV3bhym05NZ3B5MPtIS89gtGYzQHlSUb2DhUyyrFMm7acS9+8sF9glBoMuxKXpZc0R3qs=; 7:VdODmguMEgRFOIM5ZesJofthTy3xZOoSBB65HUVYeNe3d41bUWkxN5LnFFRR15G23qhcjkJaT8H+YrIIKa5//ixh3Zg7T6L6Wc9+AWdhBhOgz9wKmhy7YL3K7w9ZhFpqX6fYq4yoZzr0PwhI3ON1sLsNPGdQQAKS0HfXQyHj/IYs7xGDRd60e1aas0DTusNBcSpGqHTF+kyWeMoh0G/bVSUa+oOthXF0/r0QDU0k0LavhqRjB/wgBVDZ6agm7TZ4 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2018 13:18:10.9942 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6b7626fc-a69f-4d9d-a049-08d5efd592f7 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 When A-TCAM will be used together with C-TCAM, the C-TCAM code will need to call into the eRP core in order to get an eRP for an inserted entry. The eRP core takes an A-TCAM region as one of its arguments, so pass the C-TCAM region to the insertion function which will later allow us to derive the A-TCAM region, given it contains the C-TCAM one. Signed-off-by: Ido Schimmel Reviewed-by: Jiri Pirko --- .../mellanox/mlxsw/spectrum_acl_ctcam.c | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_ctcam.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_ctcam.c index 11b19272ab13..7ff31247cac7 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_ctcam.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_ctcam.c @@ -69,11 +69,12 @@ mlxsw_sp_acl_ctcam_region_move(struct mlxsw_sp *mlxsw_sp, static int mlxsw_sp_acl_ctcam_region_entry_insert(struct mlxsw_sp *mlxsw_sp, - struct mlxsw_sp_acl_tcam_region *region, - unsigned int offset, + struct mlxsw_sp_acl_ctcam_region *cregion, + struct mlxsw_sp_acl_ctcam_entry *centry, struct mlxsw_sp_acl_rule_info *rulei, bool fillup_priority) { + struct mlxsw_sp_acl_tcam_region *region = cregion->region; struct mlxsw_afk *afk = mlxsw_sp_acl_afk(mlxsw_sp->acl); char ptce2_pl[MLXSW_REG_PTCE2_LEN]; unsigned int blocks_count; @@ -89,7 +90,8 @@ mlxsw_sp_acl_ctcam_region_entry_insert(struct mlxsw_sp *mlxsw_sp, return err; mlxsw_reg_ptce2_pack(ptce2_pl, true, MLXSW_REG_PTCE2_OP_WRITE_WRITE, - region->tcam_region_info, offset, priority); + region->tcam_region_info, + centry->parman_item.index, priority); key = mlxsw_reg_ptce2_flex_key_blocks_data(ptce2_pl); mask = mlxsw_reg_ptce2_mask_data(ptce2_pl); blocks_count = mlxsw_afk_key_info_blocks_count_get(region->key_info); @@ -105,13 +107,14 @@ mlxsw_sp_acl_ctcam_region_entry_insert(struct mlxsw_sp *mlxsw_sp, static void mlxsw_sp_acl_ctcam_region_entry_remove(struct mlxsw_sp *mlxsw_sp, - struct mlxsw_sp_acl_tcam_region *region, - unsigned int offset) + struct mlxsw_sp_acl_ctcam_region *cregion, + struct mlxsw_sp_acl_ctcam_entry *centry) { char ptce2_pl[MLXSW_REG_PTCE2_LEN]; mlxsw_reg_ptce2_pack(ptce2_pl, false, MLXSW_REG_PTCE2_OP_WRITE_WRITE, - region->tcam_region_info, offset, 0); + cregion->region->tcam_region_info, + centry->parman_item.index, 0); mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ptce2), ptce2_pl); } @@ -193,8 +196,7 @@ int mlxsw_sp_acl_ctcam_entry_add(struct mlxsw_sp *mlxsw_sp, if (err) return err; - err = mlxsw_sp_acl_ctcam_region_entry_insert(mlxsw_sp, cregion->region, - centry->parman_item.index, + err = mlxsw_sp_acl_ctcam_region_entry_insert(mlxsw_sp, cregion, centry, rulei, fillup_priority); if (err) goto err_rule_insert; @@ -211,8 +213,7 @@ void mlxsw_sp_acl_ctcam_entry_del(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_acl_ctcam_chunk *cchunk, struct mlxsw_sp_acl_ctcam_entry *centry) { - mlxsw_sp_acl_ctcam_region_entry_remove(mlxsw_sp, cregion->region, - centry->parman_item.index); + mlxsw_sp_acl_ctcam_region_entry_remove(mlxsw_sp, cregion, centry); parman_item_remove(cregion->parman, &cchunk->parman_prio, ¢ry->parman_item); } From patchwork Sun Jul 22 13:17:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 10539331 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 7B5DB96FA for ; Sun, 22 Jul 2018 13:19:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 66580281F9 for ; Sun, 22 Jul 2018 13:19:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5A4F928384; Sun, 22 Jul 2018 13:19:21 +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 1081B28372 for ; Sun, 22 Jul 2018 13:19:20 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41YQFL2bMjzDqtW for ; Sun, 22 Jul 2018 23:19:18 +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="EjAs+zyC"; 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.57; 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="EjAs+zyC"; dkim-atps=neutral Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80057.outbound.protection.outlook.com [40.107.8.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41YQDD6SpTzDr0q for ; Sun, 22 Jul 2018 23:18:20 +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=zPo/03O2c5PoAwPEcNlKU6FqLE47ug6WUT2+zKCcA80=; b=EjAs+zyC1b/f15TbpVfiwqGxIEhMzA7+HoAQVlPdXhbwaDWkFqkp1ccdGmKyGzQoNgANJyNVpADyMQwZepruPHdbOid6nBV9VI3zSF9MIeql3Tk5Y8MkFH7S2dyD26ZzHvaKCfj8eXzQOjHBZRDFpD7gHtwmM33uMRtLeo6B6Cg= 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:11 +0000 From: Ido Schimmel To: linux-internal@mellanox.com Subject: [PATCH net-next mlxsw 16/18] mlxsw: spectrum_acl: Add A-TCAM rule insertion and deletion Date: Sun, 22 Jul 2018 16:17:10 +0300 Message-Id: <20180722131712.30578-17-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: 20a1d460-fa3f-4957-aca9-08d5efd59386 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:55N9sWS50Lzkhhqt6k5c4Ja8p4knTcJc35kaXL41okfODEY7tdNzGmT+UF+UvI0glnQ+s46gI5OsAwRVirnlTgZLC2IdRK3B53164BBXaXGw1NNwiy2Kz9PzXOP9K2k7NVxH58r5fT2G2CBVWKbbuULd1oTia9A5cY1Tdfrm6/B6E6WHNxv5A4SPrQzm11uZ5tC3xguSfaiByNkhShqoBYuZBbrBCdbR1CCMS+W+co2UsR4fMV9Gu5yIkdzqq0wx; 25:LXuI5Pw1u8dZ5D3DQ+id87/RUYJv+39rRRVgh7YyQed3XSzZE9CYnb50/UgsoTJS4aj3OLtwEz4Ml3z8Wn4JxmN/0n/QKKffcKrXfE9cYrqd62AhhRcIMjOVUJsWD7HV0dKg1sSPBBO8sH50qPJwTa9ADww8HMXWSt445AYQr4iF+jhQ7gnhIrFxcm/Xj9V6i2m9SWAKoC0htZz2Ttb2J/+Sme9/HbDlGJnomYBzvniCu2ei9Lbd1Z+JLGNVUU0JQED1/aZmRR5jvqnHEDo8pHq4SZWwmjca8w9bpBYWkR0ZmKnMXS0MhQXLKeJAOib9TDSpe5rL6qaPFCR285KYHA==; 31:32Y0DPOhZLA/fdkCKBG62TigxGIBC3d4UEzIBeWyJE4RQbbleXVPlhHRq7f+p8QAo6ymSQobZJcBzawJyTSyIOYQJEpz7DX6pHjMqkfxywrhLpSss92i+M/ey1LDxQhI4utgZdAac5sbv1qlZqp5Avnf02279MT50cDuvY1Opnt8RtIeW809/GJa93xxCIiAJRP++bVflJZz1t6fYEhiwLPOj363owU78uBM7vq2H3s= X-MS-TrafficTypeDiagnostic: HE1PR0501MB2331: X-Microsoft-Exchange-Diagnostics: 1; HE1PR0501MB2331; 20:1vD1h1F4byWlXY9upEUQtuFiVlBMmgpzGfgwMBjxpduAeH9xkY5pBghhoaGXZjXBo20N7m/+KZBOmC2GDJOItuYJNl93+fRFOu7jmyQEQ9WOBD1D5XqHEo2bLMyPtQykof0lPRAfzPqiRKlXyfTabE6DvUghOcz6U8CeT7JgKEC6MGGPhXs9BxWKNq1ptw2Xq9Fo/ur6mpebf2yNx6h1yeMzEy3TUxTxaZHPD2p2yhh3g0uyY8crxRmHj1BJauWlhBqiDoddXlvZIepZBSUizGMR4EJiYvyUhgizXHHGWPm52/f/fgKwxoThFAhEqBGpUzhIL9I1F4sLykuF/BAQvLXckA+ACQziEcebblZkuCe7Vh2Et9C5oM0zfmmZYMGZ3EjniLvQYdi+8kGogqMN/i0PxdTUakTPXTyquZb7b5opBPxcYi8L5KwvW0qNAmm3Grlxwj+WkQRpYPxQpEcyKWAll0fe1cuNq8d+g24X7sxobTj27ZkQJvImGlLgPmpl; 4:hec4yXILR2Sjka55c+6pWCN87jeeLnKCxGjgcPIDlPS3gL8mmSSZ6tVE+4vXw1gBe59OvA38rp+Jui2N6mQGifprPCl8rNYLPz8NY2j74KL2JZlxI4v6oSBPsYzV/fT/YjfIqGwg7I2o6utg0Z/8hOLm0p8WxVRvcuxNnDHXOG5T0c2lMKN/HTPHQ0DPwi7dO5+kBfttZDWEgJG64eqTeLvBE1T0JOlZBfpDgQQNZySX4u9dqKzNI72Nap/J6C+brN3l4NRhmqB32hdzHWhxIg== 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:+URvLPJEF3GeP0BiSaF5Aj+izri8JDE4YtA9/BP?= 54lIasGudku2yXMo02bXPV+Y0A9P8z5+j9ERHZFDUjGsgtpLaT0ORuaF7kxMvqoeDGmw9gesvvfa2ZsCd+DeG70TX6mGezjD6ISA0bY7EG4Da+Ph6wAholzAtER/R6O1sBsEwGGJtLfsFqY7VoZ+3r8ttLnHO6O2l3Lb8v7+/JGpavl+37YXqOWiNzuJ6MXJjVF5vrJbCs24iG7VV/63IBQmI9/WtjEhjat8Nu2MBgJmqS1jcBadZMmLgZWtbnJwXytBS0fQ33nBuOEzEfE1RzpJJX1R2XRkmTMssO3ttHJPqmJfdfXrJOrpmodcED06lMzTInD9RmSJ0UtZrWg6p/snXE9pSqeKVOTEY0hbEN4Ik0opv4E+cuvH33v6DUiAkB16w6GzsDIdE2lcpVnOKi1F4dmUbikWBdYqJsApO3sG/d7ycH6KTjIaNGDDCytl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DJ SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2018 13:18:11.9317 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 20a1d460-fa3f-4957-aca9-08d5efd59386 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 Implement rule insertion and deletion into the A-TCAM before we flip the driver to start using the A-TCAM. Rule insertion into the A-TCAM is very similar to C-TCAM, but there are subtle differences between regions of different sizes (i.e., different number of key blocks). Specifically, as explained in "mlxsw: spectrum_acl: Allow encoding a partial key", in 12 key blocks regions a rule is split into two and the two halves of the rule are linked using a "large entry key ID". Such differences are abstracted away by using different region operations per region type. Signed-off-by: Ido Schimmel Reviewed-by: Jiri Pirko --- Notes: v2: * Do not break lines at 80 chars where cure is worse than the disease .../mellanox/mlxsw/spectrum_acl_atcam.c | 388 +++++++++++++++++- .../mellanox/mlxsw/spectrum_acl_tcam.h | 22 + 2 files changed, 409 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_atcam.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_atcam.c index c13f08e9e907..9d2791a6d1a9 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_atcam.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_atcam.c @@ -34,12 +34,269 @@ */ #include +#include #include +#include +#include +#include #include "reg.h" #include "core.h" #include "spectrum.h" #include "spectrum_acl_tcam.h" +#include "core_acl_flex_keys.h" + +#define MLXSW_SP_ACL_ATCAM_LKEY_ID_BLOCK_START 6 +#define MLXSW_SP_ACL_ATCAM_LKEY_ID_BLOCK_END 11 + +struct mlxsw_sp_acl_atcam_lkey_id_ht_key { + char enc_key[MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN]; /* MSB blocks */ + u8 erp_id; +}; + +struct mlxsw_sp_acl_atcam_lkey_id { + struct rhash_head ht_node; + struct mlxsw_sp_acl_atcam_lkey_id_ht_key ht_key; + refcount_t refcnt; + u32 id; +}; + +struct mlxsw_sp_acl_atcam_region_ops { + int (*init)(struct mlxsw_sp_acl_atcam_region *aregion); + void (*fini)(struct mlxsw_sp_acl_atcam_region *aregion); + struct mlxsw_sp_acl_atcam_lkey_id * + (*lkey_id_get)(struct mlxsw_sp_acl_atcam_region *aregion, + struct mlxsw_sp_acl_rule_info *rulei, u8 erp_id); + void (*lkey_id_put)(struct mlxsw_sp_acl_atcam_region *aregion, + struct mlxsw_sp_acl_atcam_lkey_id *lkey_id); +}; + +struct mlxsw_sp_acl_atcam_region_generic { + struct mlxsw_sp_acl_atcam_lkey_id dummy_lkey_id; +}; + +struct mlxsw_sp_acl_atcam_region_12kb { + struct rhashtable lkey_ht; + unsigned int max_lkey_id; + unsigned long *used_lkey_id; +}; + +static const struct rhashtable_params mlxsw_sp_acl_atcam_lkey_id_ht_params = { + .key_len = sizeof(struct mlxsw_sp_acl_atcam_lkey_id_ht_key), + .key_offset = offsetof(struct mlxsw_sp_acl_atcam_lkey_id, ht_key), + .head_offset = offsetof(struct mlxsw_sp_acl_atcam_lkey_id, ht_node), +}; + +static const struct rhashtable_params mlxsw_sp_acl_atcam_entries_ht_params = { + .key_len = sizeof(struct mlxsw_sp_acl_atcam_entry_ht_key), + .key_offset = offsetof(struct mlxsw_sp_acl_atcam_entry, ht_key), + .head_offset = offsetof(struct mlxsw_sp_acl_atcam_entry, ht_node), +}; + +static int +mlxsw_sp_acl_atcam_region_generic_init(struct mlxsw_sp_acl_atcam_region *aregion) +{ + struct mlxsw_sp_acl_atcam_region_generic *region_generic; + + region_generic = kzalloc(sizeof(*region_generic), GFP_KERNEL); + if (!region_generic) + return -ENOMEM; + + refcount_set(®ion_generic->dummy_lkey_id.refcnt, 1); + aregion->priv = region_generic; + + return 0; +} + +static void +mlxsw_sp_acl_atcam_region_generic_fini(struct mlxsw_sp_acl_atcam_region *aregion) +{ + kfree(aregion->priv); +} + +static struct mlxsw_sp_acl_atcam_lkey_id * +mlxsw_sp_acl_atcam_generic_lkey_id_get(struct mlxsw_sp_acl_atcam_region *aregion, + struct mlxsw_sp_acl_rule_info *rulei, + u8 erp_id) +{ + struct mlxsw_sp_acl_atcam_region_generic *region_generic; + + region_generic = aregion->priv; + return ®ion_generic->dummy_lkey_id; +} + +static void +mlxsw_sp_acl_atcam_generic_lkey_id_put(struct mlxsw_sp_acl_atcam_region *aregion, + struct mlxsw_sp_acl_atcam_lkey_id *lkey_id) +{ +} + +static const struct mlxsw_sp_acl_atcam_region_ops +mlxsw_sp_acl_atcam_region_generic_ops = { + .init = mlxsw_sp_acl_atcam_region_generic_init, + .fini = mlxsw_sp_acl_atcam_region_generic_fini, + .lkey_id_get = mlxsw_sp_acl_atcam_generic_lkey_id_get, + .lkey_id_put = mlxsw_sp_acl_atcam_generic_lkey_id_put, +}; + +static int +mlxsw_sp_acl_atcam_region_12kb_init(struct mlxsw_sp_acl_atcam_region *aregion) +{ + struct mlxsw_sp *mlxsw_sp = aregion->region->mlxsw_sp; + struct mlxsw_sp_acl_atcam_region_12kb *region_12kb; + size_t alloc_size; + u64 max_lkey_id; + int err; + + if (!MLXSW_CORE_RES_VALID(mlxsw_sp->core, ACL_MAX_LARGE_KEY_ID)) + return -EIO; + + max_lkey_id = MLXSW_CORE_RES_GET(mlxsw_sp->core, ACL_MAX_LARGE_KEY_ID); + region_12kb = kzalloc(sizeof(*region_12kb), GFP_KERNEL); + if (!region_12kb) + return -ENOMEM; + + alloc_size = BITS_TO_LONGS(max_lkey_id) * sizeof(unsigned long); + region_12kb->used_lkey_id = kzalloc(alloc_size, GFP_KERNEL); + if (!region_12kb->used_lkey_id) { + err = -ENOMEM; + goto err_used_lkey_id_alloc; + } + + err = rhashtable_init(®ion_12kb->lkey_ht, + &mlxsw_sp_acl_atcam_lkey_id_ht_params); + if (err) + goto err_rhashtable_init; + + region_12kb->max_lkey_id = max_lkey_id; + aregion->priv = region_12kb; + + return 0; + +err_rhashtable_init: + kfree(region_12kb->used_lkey_id); +err_used_lkey_id_alloc: + kfree(region_12kb); + return err; +} + +static void +mlxsw_sp_acl_atcam_region_12kb_fini(struct mlxsw_sp_acl_atcam_region *aregion) +{ + struct mlxsw_sp_acl_atcam_region_12kb *region_12kb = aregion->priv; + + rhashtable_destroy(®ion_12kb->lkey_ht); + kfree(region_12kb->used_lkey_id); + kfree(region_12kb); +} + +static struct mlxsw_sp_acl_atcam_lkey_id * +mlxsw_sp_acl_atcam_lkey_id_create(struct mlxsw_sp_acl_atcam_region *aregion, + struct mlxsw_sp_acl_atcam_lkey_id_ht_key *ht_key) +{ + struct mlxsw_sp_acl_atcam_region_12kb *region_12kb = aregion->priv; + struct mlxsw_sp_acl_atcam_lkey_id *lkey_id; + u32 id; + int err; + + id = find_first_zero_bit(region_12kb->used_lkey_id, + region_12kb->max_lkey_id); + if (id < region_12kb->max_lkey_id) + __set_bit(id, region_12kb->used_lkey_id); + else + return ERR_PTR(-ENOBUFS); + + lkey_id = kzalloc(sizeof(*lkey_id), GFP_KERNEL); + if (!lkey_id) { + err = -ENOMEM; + goto err_lkey_id_alloc; + } + + lkey_id->id = id; + memcpy(&lkey_id->ht_key, ht_key, sizeof(*ht_key)); + refcount_set(&lkey_id->refcnt, 1); + + err = rhashtable_insert_fast(®ion_12kb->lkey_ht, + &lkey_id->ht_node, + mlxsw_sp_acl_atcam_lkey_id_ht_params); + if (err) + goto err_rhashtable_insert; + + return lkey_id; + +err_rhashtable_insert: + kfree(lkey_id); +err_lkey_id_alloc: + __clear_bit(id, region_12kb->used_lkey_id); + return ERR_PTR(err); +} + +static void +mlxsw_sp_acl_atcam_lkey_id_destroy(struct mlxsw_sp_acl_atcam_region *aregion, + struct mlxsw_sp_acl_atcam_lkey_id *lkey_id) +{ + struct mlxsw_sp_acl_atcam_region_12kb *region_12kb = aregion->priv; + u32 id = lkey_id->id; + + rhashtable_remove_fast(®ion_12kb->lkey_ht, &lkey_id->ht_node, + mlxsw_sp_acl_atcam_lkey_id_ht_params); + kfree(lkey_id); + __clear_bit(id, region_12kb->used_lkey_id); +} + +static struct mlxsw_sp_acl_atcam_lkey_id * +mlxsw_sp_acl_atcam_12kb_lkey_id_get(struct mlxsw_sp_acl_atcam_region *aregion, + struct mlxsw_sp_acl_rule_info *rulei, + u8 erp_id) +{ + struct mlxsw_sp_acl_atcam_region_12kb *region_12kb = aregion->priv; + struct mlxsw_sp_acl_tcam_region *region = aregion->region; + struct mlxsw_sp_acl_atcam_lkey_id_ht_key ht_key = {{ 0 } }; + struct mlxsw_sp *mlxsw_sp = region->mlxsw_sp; + struct mlxsw_afk *afk = mlxsw_sp_acl_afk(mlxsw_sp->acl); + struct mlxsw_sp_acl_atcam_lkey_id *lkey_id; + + mlxsw_afk_encode(afk, region->key_info, &rulei->values, ht_key.enc_key, + NULL, MLXSW_SP_ACL_ATCAM_LKEY_ID_BLOCK_START, + MLXSW_SP_ACL_ATCAM_LKEY_ID_BLOCK_END); + ht_key.erp_id = erp_id; + lkey_id = rhashtable_lookup_fast(®ion_12kb->lkey_ht, &ht_key, + mlxsw_sp_acl_atcam_lkey_id_ht_params); + if (lkey_id) { + refcount_inc(&lkey_id->refcnt); + return lkey_id; + } + + return mlxsw_sp_acl_atcam_lkey_id_create(aregion, &ht_key); +} + +static void +mlxsw_sp_acl_atcam_12kb_lkey_id_put(struct mlxsw_sp_acl_atcam_region *aregion, + struct mlxsw_sp_acl_atcam_lkey_id *lkey_id) +{ + if (refcount_dec_and_test(&lkey_id->refcnt)) + mlxsw_sp_acl_atcam_lkey_id_destroy(aregion, lkey_id); +} + +static const struct mlxsw_sp_acl_atcam_region_ops +mlxsw_sp_acl_atcam_region_12kb_ops = { + .init = mlxsw_sp_acl_atcam_region_12kb_init, + .fini = mlxsw_sp_acl_atcam_region_12kb_fini, + .lkey_id_get = mlxsw_sp_acl_atcam_12kb_lkey_id_get, + .lkey_id_put = mlxsw_sp_acl_atcam_12kb_lkey_id_put, +}; + +static const struct mlxsw_sp_acl_atcam_region_ops * +mlxsw_sp_acl_atcam_region_ops_arr[] = { + [MLXSW_SP_ACL_ATCAM_REGION_TYPE_2KB] = + &mlxsw_sp_acl_atcam_region_generic_ops, + [MLXSW_SP_ACL_ATCAM_REGION_TYPE_4KB] = + &mlxsw_sp_acl_atcam_region_generic_ops, + [MLXSW_SP_ACL_ATCAM_REGION_TYPE_8KB] = + &mlxsw_sp_acl_atcam_region_generic_ops, + [MLXSW_SP_ACL_ATCAM_REGION_TYPE_12KB] = + &mlxsw_sp_acl_atcam_region_12kb_ops, +}; int mlxsw_sp_acl_atcam_region_associate(struct mlxsw_sp *mlxsw_sp, u16 region_id) @@ -78,6 +335,7 @@ mlxsw_sp_acl_atcam_region_type_init(struct mlxsw_sp_acl_atcam_region *aregion) region_type = MLXSW_SP_ACL_ATCAM_REGION_TYPE_12KB; aregion->type = region_type; + aregion->ops = mlxsw_sp_acl_atcam_region_ops_arr[region_type]; } int mlxsw_sp_acl_atcam_region_init(struct mlxsw_sp *mlxsw_sp, @@ -91,10 +349,19 @@ int mlxsw_sp_acl_atcam_region_init(struct mlxsw_sp *mlxsw_sp, aregion->atcam = atcam; mlxsw_sp_acl_atcam_region_type_init(aregion); - err = mlxsw_sp_acl_erp_region_init(aregion); + err = rhashtable_init(&aregion->entries_ht, + &mlxsw_sp_acl_atcam_entries_ht_params); if (err) return err; + err = aregion->ops->init(aregion); + if (err) + goto err_ops_init; + + err = mlxsw_sp_acl_erp_region_init(aregion); + if (err) + goto err_erp_region_init; + err = mlxsw_sp_acl_ctcam_region_init(mlxsw_sp, &aregion->cregion, region); if (err) @@ -104,6 +371,10 @@ int mlxsw_sp_acl_atcam_region_init(struct mlxsw_sp *mlxsw_sp, err_ctcam_region_init: mlxsw_sp_acl_erp_region_fini(aregion); +err_erp_region_init: + aregion->ops->fini(aregion); +err_ops_init: + rhashtable_destroy(&aregion->entries_ht); return err; } @@ -111,6 +382,121 @@ 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); + aregion->ops->fini(aregion); + rhashtable_destroy(&aregion->entries_ht); +} + +static int +mlxsw_sp_acl_atcam_region_entry_insert(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_acl_atcam_region *aregion, + struct mlxsw_sp_acl_atcam_entry *aentry, + struct mlxsw_sp_acl_rule_info *rulei) +{ + struct mlxsw_sp_acl_tcam_region *region = aregion->region; + u8 erp_id = mlxsw_sp_acl_erp_id(aentry->erp); + struct mlxsw_sp_acl_atcam_lkey_id *lkey_id; + char ptce3_pl[MLXSW_REG_PTCE3_LEN]; + u32 kvdl_index, priority; + int err; + + err = mlxsw_sp_acl_tcam_priority_get(mlxsw_sp, rulei, &priority, true); + if (err) + return err; + + lkey_id = aregion->ops->lkey_id_get(aregion, rulei, erp_id); + if (IS_ERR(lkey_id)) + return PTR_ERR(lkey_id); + aentry->lkey_id = lkey_id; + + kvdl_index = mlxsw_afa_block_first_kvdl_index(rulei->act_block); + mlxsw_reg_ptce3_pack(ptce3_pl, true, MLXSW_REG_PTCE3_OP_WRITE_WRITE, + priority, region->tcam_region_info, + aentry->ht_key.enc_key, erp_id, + refcount_read(&lkey_id->refcnt) != 1, lkey_id->id, + kvdl_index); + err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ptce3), ptce3_pl); + if (err) + goto err_ptce3_write; + + return 0; + +err_ptce3_write: + aregion->ops->lkey_id_put(aregion, lkey_id); + return err; +} + +static void +mlxsw_sp_acl_atcam_region_entry_remove(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_acl_atcam_region *aregion, + struct mlxsw_sp_acl_atcam_entry *aentry) +{ + struct mlxsw_sp_acl_atcam_lkey_id *lkey_id = aentry->lkey_id; + struct mlxsw_sp_acl_tcam_region *region = aregion->region; + u8 erp_id = mlxsw_sp_acl_erp_id(aentry->erp); + char ptce3_pl[MLXSW_REG_PTCE3_LEN]; + + mlxsw_reg_ptce3_pack(ptce3_pl, false, MLXSW_REG_PTCE3_OP_WRITE_WRITE, 0, + region->tcam_region_info, aentry->ht_key.enc_key, + erp_id, refcount_read(&lkey_id->refcnt) != 1, + lkey_id->id, 0); + mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ptce3), ptce3_pl); + aregion->ops->lkey_id_put(aregion, lkey_id); +} + +int mlxsw_sp_acl_atcam_entry_add(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_acl_atcam_region *aregion, + struct mlxsw_sp_acl_atcam_entry *aentry, + struct mlxsw_sp_acl_rule_info *rulei) +{ + struct mlxsw_sp_acl_tcam_region *region = aregion->region; + char mask[MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN] = { 0 }; + struct mlxsw_afk *afk = mlxsw_sp_acl_afk(mlxsw_sp->acl); + struct mlxsw_sp_acl_erp *erp; + unsigned int blocks_count; + int err; + + blocks_count = mlxsw_afk_key_info_blocks_count_get(region->key_info); + mlxsw_afk_encode(afk, region->key_info, &rulei->values, + aentry->ht_key.enc_key, mask, 0, blocks_count - 1); + + erp = mlxsw_sp_acl_erp_get(aregion, mask, false); + if (IS_ERR(erp)) + return PTR_ERR(erp); + aentry->erp = erp; + aentry->ht_key.erp_id = mlxsw_sp_acl_erp_id(erp); + + /* We can't insert identical rules into the A-TCAM, so fail and + * let the rule spill into C-TCAM + */ + err = rhashtable_lookup_insert_fast(&aregion->entries_ht, + &aentry->ht_node, + mlxsw_sp_acl_atcam_entries_ht_params); + if (err) + goto err_rhashtable_insert; + + err = mlxsw_sp_acl_atcam_region_entry_insert(mlxsw_sp, aregion, aentry, + rulei); + if (err) + goto err_rule_insert; + + return 0; + +err_rule_insert: + rhashtable_remove_fast(&aregion->entries_ht, &aentry->ht_node, + mlxsw_sp_acl_atcam_entries_ht_params); +err_rhashtable_insert: + mlxsw_sp_acl_erp_put(aregion, erp); + return err; +} + +void mlxsw_sp_acl_atcam_entry_del(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_acl_atcam_region *aregion, + struct mlxsw_sp_acl_atcam_entry *aentry) +{ + mlxsw_sp_acl_atcam_region_entry_remove(mlxsw_sp, aregion, aentry); + rhashtable_remove_fast(&aregion->entries_ht, &aentry->ht_node, + mlxsw_sp_acl_atcam_entries_ht_params); + mlxsw_sp_acl_erp_put(aregion, aentry->erp); } int mlxsw_sp_acl_atcam_init(struct mlxsw_sp *mlxsw_sp, diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h index 51f7e2327603..6d904c1dbdc2 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h @@ -162,11 +162,26 @@ struct mlxsw_sp_acl_atcam { }; struct mlxsw_sp_acl_atcam_region { + struct rhashtable entries_ht; /* A-TCAM only */ struct mlxsw_sp_acl_ctcam_region cregion; + const struct mlxsw_sp_acl_atcam_region_ops *ops; struct mlxsw_sp_acl_tcam_region *region; struct mlxsw_sp_acl_atcam *atcam; enum mlxsw_sp_acl_atcam_region_type type; struct mlxsw_sp_acl_erp_table *erp_table; + void *priv; +}; + +struct mlxsw_sp_acl_atcam_entry_ht_key { + char enc_key[MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN]; /* Encoded key */ + u8 erp_id; +}; + +struct mlxsw_sp_acl_atcam_entry { + struct rhash_head ht_node; + struct mlxsw_sp_acl_atcam_entry_ht_key ht_key; + struct mlxsw_sp_acl_atcam_lkey_id *lkey_id; + struct mlxsw_sp_acl_erp *erp; }; int mlxsw_sp_acl_atcam_region_associate(struct mlxsw_sp *mlxsw_sp, @@ -176,6 +191,13 @@ int mlxsw_sp_acl_atcam_region_init(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_acl_atcam_region *aregion, struct mlxsw_sp_acl_tcam_region *region); void mlxsw_sp_acl_atcam_region_fini(struct mlxsw_sp_acl_atcam_region *aregion); +int mlxsw_sp_acl_atcam_entry_add(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_acl_atcam_region *aregion, + struct mlxsw_sp_acl_atcam_entry *aentry, + struct mlxsw_sp_acl_rule_info *rulei); +void mlxsw_sp_acl_atcam_entry_del(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_acl_atcam_region *aregion, + struct mlxsw_sp_acl_atcam_entry *aentry); int mlxsw_sp_acl_atcam_init(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_acl_atcam *atcam); void mlxsw_sp_acl_atcam_fini(struct mlxsw_sp *mlxsw_sp, From patchwork Sun Jul 22 13:17:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 10539329 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 1178C1805 for ; Sun, 22 Jul 2018 13:19:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F106C28384 for ; Sun, 22 Jul 2018 13:19:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E3372281F9; Sun, 22 Jul 2018 13:19:20 +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 A4FB3281F9 for ; Sun, 22 Jul 2018 13:19:19 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41YQFK73LCzDsGJ for ; Sun, 22 Jul 2018 23:19:17 +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="qm5pOnL8"; 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="qm5pOnL8"; 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 41YQDD6T8NzDr0y for ; Sun, 22 Jul 2018 23:18:20 +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=9zZzitGG/89FLkHTniOgVZgKe3oQ//CH+TafmMXYECc=; b=qm5pOnL8Jdk4dryGSOpaR6XspnU4DYKnYvu3MGsLibSHwQ5K7OWRGO2vBSNy4kjNJzZBtOsZxsgXtDQ75ben5Vd6bHIO4WF/6ayhmPun+ToFdVWkAbWHhJo2AnF6kofzxcL2Vr9gY6qgpMuHAucfcVVauGraXBnnwuWxI1ZeL4s= 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:12 +0000 From: Ido Schimmel To: linux-internal@mellanox.com Subject: [PATCH net-next mlxsw 17/18] mlxsw: spectrum_acl: Start using A-TCAM Date: Sun, 22 Jul 2018 16:17:11 +0300 Message-Id: <20180722131712.30578-18-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: 6029c34d-bc5e-4aba-1b5c-08d5efd59418 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:+g+xvJqh2sKd5G/fkaYNzwsvbWMEFN2wiv239/trIeyo2I7KzT+mcLoo5BRKmMZ/junr2EKHScizoawA6tkCRMqktr6MLDV868Auy/fkaW8eAnbwVmHEFlGar7LIS/qI9VylUYrbO7pDGOdy19jqcaAFcgyv9clkHQTQis88hxASpLf+hVX15397Oyts6OPigsA+/qZrW+wxSBVfBXz8s87UVdz/rAfJ8m5zwJC8Gn3/iQiilpPTF2fyFH/81VVf; 25:iFGqWY0gn/wJ3bLsvmpxczZSByTKDHseXAVqqmT/XiaMrjh1tkV5uOPDKIA7feapNFpquwbIxDHEmnOum3vg2DaWIvKaB118p4p4UxbZC6yFlBr3A7gZXx6pO3Uuc49+zXCPQ3sGmB3/Xl9w1BpBShpv3iXy4654FZR/2JFaeJ8RqN1fRRhvRK9PLnYnh8puDTY3hR4ZBduBHOwLcCOGYMbpC83gjE3uS4UM/r7QgyzxGTL1/e6RjA+WOisutSexaWGwkx2PmilBnljkoutmijIZsvN6/EA9Quc4Cp1K0QdND/9qzIeZAd8lmpVtn0X+pPM9W2rXqbQtZbcdFjCCtA==; 31:DUmnpdE051+s43RcRXfcYEj6bszunKAgwJ/tB0ZAfgNaN/Z4SmtubggzMlUTPVk25l02DvOC3FPSo7fE/7aB8SXs15N1mJzFJNlvgeot51hNqG20pZXO/c6s9Di+2JPXVN/YnQVC+3Gr/CtZpuE/tdibhoyKjrh2eDQ6y/bAnov8VdoKEIvrL1Aap3qIvKateW3BP2eBlgQrjHJj0g4n/+uig9Ym8bYthH+ViSGlFlI= X-MS-TrafficTypeDiagnostic: HE1PR0501MB2331: X-Microsoft-Exchange-Diagnostics: 1; HE1PR0501MB2331; 20:Ub+ye0Yc7iepNLbORZavs6F21/sbyS7iSI0h2fjsPOK+w5Fo3j24RwvBqTOAwAA1fie8uskDHTtKObIa2MdZerMiOyfec/dG0BhximKspZMK7qkSVtniO1qpKgSVb5t1AGZftWFq896leY5ZgRxmCyLE83RZJeOFGxhQAP7xO9MIv2TfKTbGSYWSzN+8p/xpuER/J1aHlQSxYk4vAfQpvlq6NzamMapiHvRKk+yuWyoc6y3Dy7r4HKw3IlITy5b36SlDSLXiTrQI0B2yoTJvVthz744meDU8HlQvCpOKZ6V2CPmh4NCa/1ZOyieB4gHLsb9siUctDMTfqk0EoRIUVQDPJUNMKaByYeNpCCswD6LnPzyLJxFoKKiRqsmMh3WCMyIuLwJcZs+YshevE+QgrhakJf6r3aBv/7Avq2TiKC+x/dW+6wSw2HY2B8W5LuHMuOmYLEmYC2CVk7C3PwkwIMenso2BD3QTlSxXzWzEcYp7CtKKHzAjmgwKGUiblIED; 4:aclhIed76RBaifSgghmR/am+2Twb4BuHapYpqxEHeQKVJmPGPpZv0K0SzkQwzlo2DsZ8TNRmYi77jmZm8Soyvp1HdWqKu3/ELPNJD4rvny2meUW74yqZvBOIpZL+chfghf0oYA6UAac3vmz1Td54EBgrEQJF0GZ4PdkdQi7S0ub+ZotLem2fAOmTaqtoAX3H6br0J52WnPKz6amDC1YVLVtipiKsNmPzyXFxDdYQ+klaxzT5GpgUzrYAN2J1IG/L31zZbGAaFsgKndojIw35lw== 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)(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:KrcF66KtQQBj3i+4lQbCTRGXiP404IjJ8SOjtd4?= b8l8XpBYbe2R1icZq7RdD0REPwyrcWfhHGSXyEojJ9AC4UWRd+p8azhK18i6Yz4ZoINt5YuTgROT5h5JcSjgCIcX77xDyMC6rYk0OJK0kPNKIlNQDE86v6zPsNt6dMESgYX2ul3hrZF5M4IgxNBZKJl2fLh/eiKOQ1pnyte3AouJtBg3stfvx11k8YQqe3wIZE50cuU/3ycZiQIVgevN0efhmy0ufyaSrK716fyfpaDtYo8gMdE9botB5bjdJwZNmIkfmmbuDq0NOlrhq3o7mBW32AZj6kFJ+uO+E/MvpYdjg0HJPxu/tQZqLccCogMIJGNP8dYoyR252EqoaINdxGmRwLKd4l3D1BCLc9fe/urUQol8z//U4SRnBCwStN+cbi49z06GqxXe/cMWNW0nidabOOJY/1PBMru/U+Tz1kRiJOEogqRcJRgIQ3CZR+awrzrOBq7/hBA81mBZw82F4yLsjc7SevdKXDVfO2CCSczHQDdmZZNPfRqdDUQkXtIWCzKnNkK+mTJ/xbjJjQFoqYGs9UUo3EltAEB5r2M7ovxoAB1FibBI3q6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Cb+cQ= X-Microsoft-Exchange-Diagnostics: 1; HE1PR0501MB2331; 6:XfBsilWgaipE+iZLaMGOvuI1aQtnPIKoZq3D2w1g4cke6qlUIEL7sbOmsEFtMGgrzSfe/nWZXAXE0hKMv1CGy0qCVhDXtR185e7PqXo8aEY62vu4v9vwp/JJbrOhRH/JJrRapwBkyR/21Hu8j/EHie7yTFUPJeRcdxQdQkgSakAiUKZFqhrTR4A/9fD2pJw6AQ2zLbz044u7hQykT8PURD5sQrnKzDLyFled6rkEEffhZvyMSqByuyQUhyHVGCgyfzddlOXTxEtL5tDnnmYy0g+RjB99yilqULXHDc9RhnyMLVPGu+Di+IAs/H5cZJO2cfMIBvMUwiJkm0DiKcO4Nt6PyUfqP9PK4RUDeTxMJYHAF4KyW5MeWds45y8DDoh3s4XbxWSYGbf9f84+PlozVHCpgAFvUtkBxIwIAQUONAnw0LAN6B8R64UID70dqbQ26biSlKh1Qa7Si19rslBLHw==; 5:IDr37UBIHBrfbfu8im13TBHahw0N74Yk6WBxXEZ4GGbHPPHPFlOjP9mtbeD5bgnq3qTJc6KSXzRu0ONOInXlYgqdrbvGHvo/wxxrtcS8V7AdBk0zb2NeXLcgj5JpO6sIA1oZFKF6jlS4vTgcgWfh73YehmQn0akX5K8c92fOzFo=; 7:n2BNpVy3t08jelhCPQz5cFQ/Rc9LE56n+kJQH2kncezEN90JcxZ9Qkuc+cMDrkFA9h4XfOmlX/UTlk3tegNctWp34qcnP2vGakR3ZvQRou4MKFtaK5fkygLagFB4xiTYNySa9YXzWzPUSDL2/ATS/UUHKEKg7d0KKaMhrVi2LJXlm9DPWf1EOwQAeFbX+4kTLIdRNlabGNEvb7x2PQyq0d+C3qmV/4Oq+WSRSuD8lxNN8Gy77v5g/T7aMG71BJj1 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2018 13:18:12.8692 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6029c34d-bc5e-4aba-1b5c-08d5efd59418 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 Now that all the pieces are in place we can start using the A-TCAM instead of only using the C-TCAM. This allows for much higher scale and better performance (to be improved further by follow-up patch sets). Perform the integration with the A-TCAM and the eRP core by reverting the changes introduced by "mlxsw: spectrum_acl: Enable C-TCAM only mode in eRP core" and add calls from the C-TCAM code into the eRP core. Signed-off-by: Ido Schimmel --- Notes: v2: * Do not break lines at 80 chars where cure is worse than the disease drivers/net/ethernet/mellanox/mlxsw/reg.h | 1 - .../mellanox/mlxsw/spectrum1_acl_tcam.c | 23 ++++- .../mellanox/mlxsw/spectrum2_acl_tcam.c | 98 +++++++++++++++++-- .../mellanox/mlxsw/spectrum_acl_atcam.c | 12 ++- .../mellanox/mlxsw/spectrum_acl_ctcam.c | 14 ++- .../mellanox/mlxsw/spectrum_acl_erp.c | 13 +-- .../mellanox/mlxsw/spectrum_acl_tcam.h | 40 ++++++-- 7 files changed, 167 insertions(+), 34 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h index 5acef249e776..fd2e3dd166d2 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/reg.h +++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h @@ -2868,7 +2868,6 @@ static inline void mlxsw_reg_percr_pack(char *payload, u16 region_id) mlxsw_reg_percr_atcam_ignore_prune_set(payload, false); mlxsw_reg_percr_ctcam_ignore_prune_set(payload, false); mlxsw_reg_percr_bf_bypass_set(payload, true); - memset(payload + 0x20, 0xff, 96); } /* PERERP - Policy-Engine Region eRP Register diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum1_acl_tcam.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum1_acl_tcam.c index 926483434e99..5c8956573632 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum1_acl_tcam.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum1_acl_tcam.c @@ -58,6 +58,26 @@ struct mlxsw_sp1_acl_tcam_entry { struct mlxsw_sp_acl_ctcam_entry centry; }; +static int +mlxsw_sp1_acl_ctcam_region_entry_insert(struct mlxsw_sp_acl_ctcam_region *cregion, + struct mlxsw_sp_acl_ctcam_entry *centry, + const char *mask) +{ + return 0; +} + +static void +mlxsw_sp1_acl_ctcam_region_entry_remove(struct mlxsw_sp_acl_ctcam_region *cregion, + struct mlxsw_sp_acl_ctcam_entry *centry) +{ +} + +static const struct mlxsw_sp_acl_ctcam_region_ops +mlxsw_sp1_acl_ctcam_region_ops = { + .entry_insert = mlxsw_sp1_acl_ctcam_region_entry_insert, + .entry_remove = mlxsw_sp1_acl_ctcam_region_entry_remove, +}; + static int mlxsw_sp1_acl_tcam_init(struct mlxsw_sp *mlxsw_sp, void *priv, struct mlxsw_sp_acl_tcam *tcam) { @@ -129,7 +149,8 @@ mlxsw_sp1_acl_tcam_region_init(struct mlxsw_sp *mlxsw_sp, void *region_priv, int err; err = mlxsw_sp_acl_ctcam_region_init(mlxsw_sp, ®ion->cregion, - _region); + _region, + &mlxsw_sp1_acl_ctcam_region_ops); if (err) return err; err = mlxsw_sp1_acl_ctcam_region_catchall_add(mlxsw_sp, region); diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum2_acl_tcam.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum2_acl_tcam.c index bef2329bb233..5ee993a733b4 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum2_acl_tcam.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum2_acl_tcam.c @@ -54,8 +54,50 @@ struct mlxsw_sp2_acl_tcam_chunk { }; struct mlxsw_sp2_acl_tcam_entry { - struct mlxsw_sp_acl_ctcam_entry centry; + struct mlxsw_sp_acl_atcam_entry aentry; struct mlxsw_afa_block *act_block; + void (*destructor)(struct mlxsw_sp2_acl_tcam_entry *entry, + struct mlxsw_sp2_acl_tcam_region *region, + struct mlxsw_sp2_acl_tcam_chunk *chunk); +}; + +static int +mlxsw_sp2_acl_ctcam_region_entry_insert(struct mlxsw_sp_acl_ctcam_region *cregion, + struct mlxsw_sp_acl_ctcam_entry *centry, + const char *mask) +{ + struct mlxsw_sp_acl_atcam_region *aregion; + struct mlxsw_sp_acl_atcam_entry *aentry; + struct mlxsw_sp_acl_erp *erp; + + aregion = mlxsw_sp_acl_tcam_cregion_aregion(cregion); + aentry = mlxsw_sp_acl_tcam_centry_aentry(centry); + + erp = mlxsw_sp_acl_erp_get(aregion, mask, true); + if (IS_ERR(erp)) + return PTR_ERR(erp); + aentry->erp = erp; + + return 0; +} + +static void +mlxsw_sp2_acl_ctcam_region_entry_remove(struct mlxsw_sp_acl_ctcam_region *cregion, + struct mlxsw_sp_acl_ctcam_entry *centry) +{ + struct mlxsw_sp_acl_atcam_region *aregion; + struct mlxsw_sp_acl_atcam_entry *aentry; + + aregion = mlxsw_sp_acl_tcam_cregion_aregion(cregion); + aentry = mlxsw_sp_acl_tcam_centry_aentry(centry); + + mlxsw_sp_acl_erp_put(aregion, aentry->erp); +} + +static const struct mlxsw_sp_acl_ctcam_region_ops +mlxsw_sp2_acl_ctcam_region_ops = { + .entry_insert = mlxsw_sp2_acl_ctcam_region_entry_insert, + .entry_remove = mlxsw_sp2_acl_ctcam_region_entry_remove, }; static int mlxsw_sp2_acl_tcam_init(struct mlxsw_sp *mlxsw_sp, void *priv, @@ -139,7 +181,8 @@ mlxsw_sp2_acl_tcam_region_init(struct mlxsw_sp *mlxsw_sp, void *region_priv, region->region = _region; return mlxsw_sp_acl_atcam_region_init(mlxsw_sp, &tcam->atcam, - ®ion->aregion, _region); + ®ion->aregion, _region, + &mlxsw_sp2_acl_ctcam_region_ops); } static void @@ -174,6 +217,30 @@ static void mlxsw_sp2_acl_tcam_chunk_fini(void *chunk_priv) mlxsw_sp_acl_ctcam_chunk_fini(&chunk->cchunk); } +static void +mlxsw_sp2_acl_atcam_entry_del(struct mlxsw_sp2_acl_tcam_entry *entry, + struct mlxsw_sp2_acl_tcam_region *region, + struct mlxsw_sp2_acl_tcam_chunk *chunk) +{ + struct mlxsw_sp_acl_tcam_region *_region = region->region; + struct mlxsw_sp *mlxsw_sp = _region->mlxsw_sp; + + mlxsw_sp_acl_atcam_entry_del(mlxsw_sp, ®ion->aregion, + &entry->aentry); +} + +static void +mlxsw_sp2_acl_ctcam_entry_del(struct mlxsw_sp2_acl_tcam_entry *entry, + struct mlxsw_sp2_acl_tcam_region *region, + struct mlxsw_sp2_acl_tcam_chunk *chunk) +{ + struct mlxsw_sp_acl_tcam_region *_region = region->region; + struct mlxsw_sp *mlxsw_sp = _region->mlxsw_sp; + + mlxsw_sp_acl_ctcam_entry_del(mlxsw_sp, ®ion->aregion.cregion, + &chunk->cchunk, &entry->aentry.centry); +} + static int mlxsw_sp2_acl_tcam_entry_add(struct mlxsw_sp *mlxsw_sp, void *region_priv, void *chunk_priv, void *entry_priv, @@ -182,11 +249,29 @@ static int mlxsw_sp2_acl_tcam_entry_add(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp2_acl_tcam_region *region = region_priv; struct mlxsw_sp2_acl_tcam_chunk *chunk = chunk_priv; struct mlxsw_sp2_acl_tcam_entry *entry = entry_priv; + int err; entry->act_block = rulei->act_block; - return mlxsw_sp_acl_ctcam_entry_add(mlxsw_sp, ®ion->aregion.cregion, - &chunk->cchunk, &entry->centry, - rulei, true); + + err = mlxsw_sp_acl_atcam_entry_add(mlxsw_sp, ®ion->aregion, + &entry->aentry, rulei); + if (!err) { + entry->destructor = mlxsw_sp2_acl_atcam_entry_del; + return 0; + } + + /* It is possible we failed to add the rule to the A-TCAM due to + * exceeded number of masks. Try to spill into C-TCAM. + */ + err = mlxsw_sp_acl_ctcam_entry_add(mlxsw_sp, ®ion->aregion.cregion, + &chunk->cchunk, + &entry->aentry.centry, rulei, true); + if (!err) { + entry->destructor = mlxsw_sp2_acl_ctcam_entry_del; + return 0; + } + + return err; } static void mlxsw_sp2_acl_tcam_entry_del(struct mlxsw_sp *mlxsw_sp, @@ -197,8 +282,7 @@ static void mlxsw_sp2_acl_tcam_entry_del(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp2_acl_tcam_chunk *chunk = chunk_priv; struct mlxsw_sp2_acl_tcam_entry *entry = entry_priv; - mlxsw_sp_acl_ctcam_entry_del(mlxsw_sp, ®ion->aregion.cregion, - &chunk->cchunk, &entry->centry); + entry->destructor(entry, region, chunk); } static int diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_atcam.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_atcam.c index 9d2791a6d1a9..4fc2f86b3315 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_atcam.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_atcam.c @@ -338,10 +338,12 @@ mlxsw_sp_acl_atcam_region_type_init(struct mlxsw_sp_acl_atcam_region *aregion) aregion->ops = mlxsw_sp_acl_atcam_region_ops_arr[region_type]; } -int mlxsw_sp_acl_atcam_region_init(struct mlxsw_sp *mlxsw_sp, - struct mlxsw_sp_acl_atcam *atcam, - struct mlxsw_sp_acl_atcam_region *aregion, - struct mlxsw_sp_acl_tcam_region *region) +int +mlxsw_sp_acl_atcam_region_init(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_acl_atcam *atcam, + struct mlxsw_sp_acl_atcam_region *aregion, + struct mlxsw_sp_acl_tcam_region *region, + const struct mlxsw_sp_acl_ctcam_region_ops *ops) { int err; @@ -363,7 +365,7 @@ int mlxsw_sp_acl_atcam_region_init(struct mlxsw_sp *mlxsw_sp, goto err_erp_region_init; err = mlxsw_sp_acl_ctcam_region_init(mlxsw_sp, &aregion->cregion, - region); + region, ops); if (err) goto err_ctcam_region_init; diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_ctcam.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_ctcam.c index 7ff31247cac7..7440a1189250 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_ctcam.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_ctcam.c @@ -98,6 +98,10 @@ mlxsw_sp_acl_ctcam_region_entry_insert(struct mlxsw_sp *mlxsw_sp, mlxsw_afk_encode(afk, region->key_info, &rulei->values, key, mask, 0, blocks_count - 1); + err = cregion->ops->entry_insert(cregion, centry, mask); + if (err) + return err; + /* Only the first action set belongs here, the rest is in KVD */ act_set = mlxsw_afa_block_first_set(rulei->act_block); mlxsw_reg_ptce2_flex_action_set_memcpy_to(ptce2_pl, act_set); @@ -116,6 +120,7 @@ mlxsw_sp_acl_ctcam_region_entry_remove(struct mlxsw_sp *mlxsw_sp, cregion->region->tcam_region_info, centry->parman_item.index, 0); mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ptce2), ptce2_pl); + cregion->ops->entry_remove(cregion, centry); } static int mlxsw_sp_acl_ctcam_region_parman_resize(void *priv, @@ -153,11 +158,14 @@ static const struct parman_ops mlxsw_sp_acl_ctcam_region_parman_ops = { .algo = PARMAN_ALGO_TYPE_LSORT, }; -int mlxsw_sp_acl_ctcam_region_init(struct mlxsw_sp *mlxsw_sp, - struct mlxsw_sp_acl_ctcam_region *cregion, - struct mlxsw_sp_acl_tcam_region *region) +int +mlxsw_sp_acl_ctcam_region_init(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_acl_ctcam_region *cregion, + struct mlxsw_sp_acl_tcam_region *region, + const struct mlxsw_sp_acl_ctcam_region_ops *ops) { cregion->region = region; + cregion->ops = ops; cregion->parman = parman_create(&mlxsw_sp_acl_ctcam_region_parman_ops, cregion); if (!cregion->parman) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_erp.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_erp.c index e26efa451d4a..787d928cae66 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_erp.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_erp.c @@ -1043,11 +1043,8 @@ mlxsw_sp_acl_erp_master_mask_init(struct mlxsw_sp_acl_atcam_region *aregion) { struct mlxsw_sp *mlxsw_sp = aregion->region->mlxsw_sp; char percr_pl[MLXSW_REG_PERCR_LEN]; - char *master_mask; mlxsw_reg_percr_pack(percr_pl, aregion->region->id); - master_mask = mlxsw_reg_percr_master_mask_data(percr_pl); - memset(master_mask, 0, MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN); return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(percr), percr_pl); } @@ -1057,7 +1054,7 @@ mlxsw_sp_acl_erp_region_param_init(struct mlxsw_sp_acl_atcam_region *aregion) struct mlxsw_sp *mlxsw_sp = aregion->region->mlxsw_sp; char pererp_pl[MLXSW_REG_PERERP_LEN]; - mlxsw_reg_pererp_pack(pererp_pl, aregion->region->id, true, true, 0, + mlxsw_reg_pererp_pack(pererp_pl, aregion->region->id, false, false, 0, 0, 0); return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pererp), pererp_pl); } @@ -1072,16 +1069,12 @@ int mlxsw_sp_acl_erp_region_init(struct mlxsw_sp_acl_atcam_region *aregion) return PTR_ERR(erp_table); aregion->erp_table = erp_table; - /* Initialize the region's master mask to all ones for C-TCAM - * only mode - */ + /* Initialize the region's master mask to all zeroes */ err = mlxsw_sp_acl_erp_master_mask_init(aregion); if (err) goto err_erp_master_mask_init; - /* Initialize the region to use the eRP table and enable C-TCAM - * lookup - */ + /* Initialize the region to not use the eRP table */ err = mlxsw_sp_acl_erp_region_param_init(aregion); if (err) goto err_erp_region_param_init; diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h index 6d904c1dbdc2..b7355a4d71ce 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h @@ -111,6 +111,7 @@ struct mlxsw_sp_acl_tcam_region { struct mlxsw_sp_acl_ctcam_region { struct parman *parman; + const struct mlxsw_sp_acl_ctcam_region_ops *ops; struct mlxsw_sp_acl_tcam_region *region; }; @@ -122,9 +123,19 @@ struct mlxsw_sp_acl_ctcam_entry { struct parman_item parman_item; }; -int mlxsw_sp_acl_ctcam_region_init(struct mlxsw_sp *mlxsw_sp, - struct mlxsw_sp_acl_ctcam_region *cregion, - struct mlxsw_sp_acl_tcam_region *region); +struct mlxsw_sp_acl_ctcam_region_ops { + int (*entry_insert)(struct mlxsw_sp_acl_ctcam_region *cregion, + struct mlxsw_sp_acl_ctcam_entry *centry, + const char *mask); + void (*entry_remove)(struct mlxsw_sp_acl_ctcam_region *cregion, + struct mlxsw_sp_acl_ctcam_entry *centry); +}; + +int +mlxsw_sp_acl_ctcam_region_init(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_acl_ctcam_region *cregion, + struct mlxsw_sp_acl_tcam_region *region, + const struct mlxsw_sp_acl_ctcam_region_ops *ops); void mlxsw_sp_acl_ctcam_region_fini(struct mlxsw_sp_acl_ctcam_region *cregion); void mlxsw_sp_acl_ctcam_chunk_init(struct mlxsw_sp_acl_ctcam_region *cregion, struct mlxsw_sp_acl_ctcam_chunk *cchunk, @@ -180,16 +191,31 @@ struct mlxsw_sp_acl_atcam_entry_ht_key { struct mlxsw_sp_acl_atcam_entry { struct rhash_head ht_node; struct mlxsw_sp_acl_atcam_entry_ht_key ht_key; + struct mlxsw_sp_acl_ctcam_entry centry; struct mlxsw_sp_acl_atcam_lkey_id *lkey_id; struct mlxsw_sp_acl_erp *erp; }; +static inline struct mlxsw_sp_acl_atcam_region * +mlxsw_sp_acl_tcam_cregion_aregion(struct mlxsw_sp_acl_ctcam_region *cregion) +{ + return container_of(cregion, struct mlxsw_sp_acl_atcam_region, cregion); +} + +static inline struct mlxsw_sp_acl_atcam_entry * +mlxsw_sp_acl_tcam_centry_aentry(struct mlxsw_sp_acl_ctcam_entry *centry) +{ + return container_of(centry, struct mlxsw_sp_acl_atcam_entry, centry); +} + int mlxsw_sp_acl_atcam_region_associate(struct mlxsw_sp *mlxsw_sp, u16 region_id); -int mlxsw_sp_acl_atcam_region_init(struct mlxsw_sp *mlxsw_sp, - struct mlxsw_sp_acl_atcam *atcam, - struct mlxsw_sp_acl_atcam_region *aregion, - struct mlxsw_sp_acl_tcam_region *region); +int +mlxsw_sp_acl_atcam_region_init(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_acl_atcam *atcam, + struct mlxsw_sp_acl_atcam_region *aregion, + struct mlxsw_sp_acl_tcam_region *region, + const struct mlxsw_sp_acl_ctcam_region_ops *ops); void mlxsw_sp_acl_atcam_region_fini(struct mlxsw_sp_acl_atcam_region *aregion); int mlxsw_sp_acl_atcam_entry_add(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_acl_atcam_region *aregion, From patchwork Sun Jul 22 13:17:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 10539333 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 9DF3696FA for ; Sun, 22 Jul 2018 13:19:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 88C55281F9 for ; Sun, 22 Jul 2018 13:19:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7D1A128384; Sun, 22 Jul 2018 13:19:27 +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 1127C281F9 for ; Sun, 22 Jul 2018 13:19:26 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41YQFS1mnbzDrdf for ; Sun, 22 Jul 2018 23:19:24 +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="R/mDisbG"; 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="R/mDisbG"; 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 41YQDF1QqGzDqnM for ; Sun, 22 Jul 2018 23:18:21 +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=u7LZVB7e/2gZiElCDWb5imPk8bfX2pH8rzt+iAZJWmA=; b=R/mDisbGil+HgAAXsfoHMDUJ6UOy4+WRSe7tTX12lpT0AOQ5A/yUJS7qUxrty6KASo/Z4m3av1tGArkP4rM1u0bD/eV20Y8plmFzVC9JlqHecV84wDRUXbsiAPf5mNG8DqqqnVM7t1GDCGBIcmRuJWJFgQN9a/94vrixvS11tnc= 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:13 +0000 From: Ido Schimmel To: linux-internal@mellanox.com Subject: [PATCH net-next mlxsw 18/18] selftests: mlxsw: Add TC flower test for Spectrum-2 Date: Sun, 22 Jul 2018 16:17:12 +0300 Message-Id: <20180722131712.30578-19-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: 2768398f-e6b7-43d3-27bb-08d5efd594a7 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:7Dd69JFWUN7O0gHNkNsodGVxxZz5Ub/s4wvkaUlphh6xmo2Zq8FJU1OwX/a/UIfsU9uXkS3AL4gt0hu99vULKo/3dSA2aNjP+Kk4OChy414Xswc7uctsqqXOPAnrUaGA83UTvQ5TGideHZ/JxTBC0uZ60HvWD5ZeNmltH6gmm5+uxuDAY5xX6XPWb8EJqHg6ARqZIdq8npieNUrYW1smVWqolJHZ3PELpLeBNj6Q1SJ94W04gjWXzOmiXACfn7ms; 25:/b/5O5UVfGpJhEEqZ+0/42iwkPfhHfBvW5jGIYeuAwt130E3ECa2pdvOIhbwnwV6yjW+GeIN8Z7ZAhzSXuSG67nXRzSe5I9OZhSXH6c5eb3OSpvui7xcUBn4/ikvO6+CM8jYkghu7XgMoDp6CaaxfD5pEs2KU2e74eJDFxOe0NjBCHjwRTQ9ColH4TKp/U+/X9prOFbD+T0xrvn6IdidIAaWOdfpUGnCwLJZZ3mwILn0rAkhbBvkHdeiz7gfDtMKCOQlBJ0MdpAanXcZ0chOqcq2B+WNDybr0AiwYyGoh2fTveiL4FpPbvcZ3mZqOAlqVykevM3pT3liTmQgi9Ga9w==; 31:CHbhdIxKu7o8vqUJb701gq4bBgTUMRJBr3z0uWUfYzAsUnLmKvpUZR78WliGXVMYzYGqk5vtqAqVnSeto4in80pMBxp6/n7oUt8m7b+wcwnxFxxdchBPA6CjnTdXLkHilASlKkEsb/cfjxs98gt25Mi0dVOUiylWhRvG/62eqNEXX0IF25yjU3J6+++b32wqHjtWbfRFQcWakIKoe/RGCEEu716z89S6TKWOJ1e1VVs= X-MS-TrafficTypeDiagnostic: HE1PR0501MB2331: X-Microsoft-Exchange-Diagnostics: 1; HE1PR0501MB2331; 20:xHXsk/i1C0ITvPWSOwBu78Q1tsajK0ZcYcmlY5B/OAN1rRn/tMQ+2l3jllQHyA+1Hxv3qiaEZiUbW89dYelA15LVb7kgGtZSaI4xm0EIJcGFvPMOOOzrGABn8yDC+tQsnSD4hSvGDwxNSo8SVqiPunk8go7feScwjsxDlPuZcG2kyzRjrTUHywA7ATmebqe8PjG6p6hfp1tjwGVY3WK+qMi62aTxSVT6MagorsWAHN3hyrLa+1DqL6eFgPu8AJj4K1AJhf/9PKCzx3ROZr6I9LcLJ+4a0dHe6/gLM8uZQOxpzqA4W9IUGXzhX8eZsio3EkNVeWEbQ4peH5haoLPCt13IT9WS+QANYEv71J2MVyNQ8R9/lEpIKbURqcD5zfTIfmZa1t6fXMoMYlzm/dXgd4h8g03ECxTqyaxChjeOacIvE+j1p7tBWLmNpOTvFiGU/dfZc99FlRPMR1zx2LtFQ9lTyU/gNOooaMVRK/PB+4dc3UlH8DY5774xXkLXfUkN; 4:WxDuuA4WM9rZI74cO2gauMqzsV9eDU+9GZqCots7uEzHI+4aOblDmH3qS83tFi/KZgxRAo0tQVTVrajB+yANL8CzKp1bNt6q5nOxgMwii1psyu3TqI2CO7dT4Kk7OrJ7Ol3oDqK09svC3UT+M4rYZn/mSVfTveAB82iBBrOveIluvys9QCrwOx2rbu9JyIKYy/noKN4wnYj0j1ah/5HLmSGHIhUdhAOFDJ0GL2MD0+zlF2I14vsDOHijRD4h7+HHx0BTWhl7zRUSQuxnjseeFQ== 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)(473944003); 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:vpaEV7BYb473rmH2ZOr/LsyEdRt/9iECLYU+d8r?= IYurDVObiJJ6gM7R4vEDs6Qzi8Yh4dZpiF8RpT83d8x4ez2jmPDq2Mdyc0RrQhV/6ew0novZd7dE+v0wUblZ5oKRbC3PNv3Avp0cSZrVZCKKBTNDL8dmLtKaZZ2ZXja/G5dz9RDq5ZJ43n7x8i5dUwl6WKUdyTISov/qb2pnWo+MkclJqO7kTgpkdPrqP3A6Yl4U5qzCXIx8vX4jDVJClEon+6wFu9YBB8vsbdBw+OhLvPafdq9D6gvL7vXzeSuMX+KAbRlnHZVTZnO8ge1zPfoOm9CG8KI8xA6iwOgLz/quJsfe0D8ikrkDD6vviU56t5YdmdSLBn75kJxGSz7OJgfAt9/mJUAA9aA0l3a3QQ6xjXo6gmaZVhOKY59ahbDhXOSSzPUMg8DMmPkgioEhw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ew8TY08yv+R72n952S1LYoOikxj0RMCY1uiVHWKaYS2WRdk02saTjo5jxMNKGmaF0MNzw+UYyjBpmD29+m9LXs7nhyix8fN SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2018 13:18:13.8223 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2768398f-e6b7-43d3-27bb-08d5efd594a7 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 Signed-off-by: Ido Schimmel Reviewed-by: Jiri Pirko --- .../drivers/net/mlxsw/spectrum-2/tc_flower.sh | 366 ++++++++++++++++++ 1 file changed, 366 insertions(+) create mode 100755 tools/testing/selftests/drivers/net/mlxsw/spectrum-2/tc_flower.sh diff --git a/tools/testing/selftests/drivers/net/mlxsw/spectrum-2/tc_flower.sh b/tools/testing/selftests/drivers/net/mlxsw/spectrum-2/tc_flower.sh new file mode 100755 index 000000000000..a57d2278c3ef --- /dev/null +++ b/tools/testing/selftests/drivers/net/mlxsw/spectrum-2/tc_flower.sh @@ -0,0 +1,366 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +# This test is for checking the A-TCAM and C-TCAM operation in Spectrum-2. +# It tries to exercise as many code paths in the eRP state machine as +# possible. + +lib_dir=$(dirname $0)/../../../../net/forwarding + +ALL_TESTS="single_mask_test identical_filters_test two_masks_test \ + multiple_masks_test ctcam_edge_cases_test" +NUM_NETIFS=2 +source $lib_dir/tc_common.sh +source $lib_dir/lib.sh + +tcflags="skip_hw" + +h1_create() +{ + simple_if_init $h1 192.0.2.1/24 198.51.100.1/24 +} + +h1_destroy() +{ + simple_if_fini $h1 192.0.2.1/24 198.51.100.1/24 +} + +h2_create() +{ + simple_if_init $h2 192.0.2.2/24 198.51.100.2/24 + tc qdisc add dev $h2 clsact +} + +h2_destroy() +{ + tc qdisc del dev $h2 clsact + simple_if_fini $h2 192.0.2.2/24 198.51.100.2/24 +} + +single_mask_test() +{ + # When only a single mask is required, the device uses the master + # mask and not the eRP table. Verify that under this mode the right + # filter is matched + + RET=0 + + tc filter add dev $h2 ingress protocol ip pref 1 handle 101 flower \ + $tcflags dst_ip 192.0.2.2 action drop + + $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \ + -t ip -q + + tc_check_packets "dev $h2 ingress" 101 1 + check_err $? "Single filter - did not match" + + tc filter add dev $h2 ingress protocol ip pref 2 handle 102 flower \ + $tcflags dst_ip 198.51.100.2 action drop + + $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \ + -t ip -q + + tc_check_packets "dev $h2 ingress" 101 2 + check_err $? "Two filters - did not match highest priority" + + $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 198.51.100.1 -B 198.51.100.2 \ + -t ip -q + + tc_check_packets "dev $h2 ingress" 102 1 + check_err $? "Two filters - did not match lowest priority" + + tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower + + $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 198.51.100.1 -B 198.51.100.2 \ + -t ip -q + + tc_check_packets "dev $h2 ingress" 102 2 + check_err $? "Single filter - did not match after delete" + + tc filter del dev $h2 ingress protocol ip pref 2 handle 102 flower + + log_test "single mask test ($tcflags)" +} + +identical_filters_test() +{ + # When two filters that only differ in their priority are used, + # one needs to be inserted into the C-TCAM. This test verifies + # that filters are correctly spilled to C-TCAM and that the right + # filter is matched + + RET=0 + + tc filter add dev $h2 ingress protocol ip pref 1 handle 101 flower \ + $tcflags dst_ip 192.0.2.2 action drop + tc filter add dev $h2 ingress protocol ip pref 2 handle 102 flower \ + $tcflags dst_ip 192.0.2.2 action drop + + $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \ + -t ip -q + + tc_check_packets "dev $h2 ingress" 101 1 + check_err $? "Did not match A-TCAM filter" + + tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower + + $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \ + -t ip -q + + tc_check_packets "dev $h2 ingress" 102 1 + check_err $? "Did not match C-TCAM filter after A-TCAM delete" + + tc filter add dev $h2 ingress protocol ip pref 3 handle 103 flower \ + $tcflags dst_ip 192.0.2.2 action drop + + $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \ + -t ip -q + + tc_check_packets "dev $h2 ingress" 102 2 + check_err $? "Did not match C-TCAM filter after A-TCAM add" + + tc filter del dev $h2 ingress protocol ip pref 2 handle 102 flower + + $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \ + -t ip -q + + tc_check_packets "dev $h2 ingress" 103 1 + check_err $? "Did not match A-TCAM filter after C-TCAM delete" + + tc filter del dev $h2 ingress protocol ip pref 3 handle 103 flower + + log_test "identical filters test ($tcflags)" +} + +two_masks_test() +{ + # When more than one mask is required, the eRP table is used. This + # test verifies that the eRP table is correctly allocated and used + + RET=0 + + tc filter add dev $h2 ingress protocol ip pref 1 handle 101 flower \ + $tcflags dst_ip 192.0.2.2 action drop + tc filter add dev $h2 ingress protocol ip pref 3 handle 103 flower \ + $tcflags dst_ip 192.0.0.0/16 action drop + + $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \ + -t ip -q + + tc_check_packets "dev $h2 ingress" 101 1 + check_err $? "Two filters - did not match highest priority" + + tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower + + $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \ + -t ip -q + + tc_check_packets "dev $h2 ingress" 103 1 + check_err $? "Single filter - did not match" + + tc filter add dev $h2 ingress protocol ip pref 2 handle 102 flower \ + $tcflags dst_ip 192.0.2.0/24 action drop + + $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \ + -t ip -q + + tc_check_packets "dev $h2 ingress" 102 1 + check_err $? "Two filters - did not match highest priority after add" + + tc filter del dev $h2 ingress protocol ip pref 3 handle 103 flower + tc filter del dev $h2 ingress protocol ip pref 2 handle 102 flower + + log_test "two masks test ($tcflags)" +} + +multiple_masks_test() +{ + # The number of masks in a region is limited. Once the maximum + # number of masks has been reached filters that require new + # masks are spilled to the C-TCAM. This test verifies that + # spillage is performed correctly and that the right filter is + # matched + + local index + + RET=0 + + NUM_MASKS=32 + BASE_INDEX=100 + + for i in $(eval echo {1..$NUM_MASKS}); do + index=$((BASE_INDEX - i)) + + tc filter add dev $h2 ingress protocol ip pref $index \ + handle $index \ + flower $tcflags dst_ip 192.0.2.2/${i} src_ip 192.0.2.1 \ + action drop + + $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 \ + -B 192.0.2.2 -t ip -q + + tc_check_packets "dev $h2 ingress" $index 1 + check_err $? "$i filters - did not match highest priority (add)" + done + + for i in $(eval echo {$NUM_MASKS..1}); do + index=$((BASE_INDEX - i)) + + $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 \ + -B 192.0.2.2 -t ip -q + + tc_check_packets "dev $h2 ingress" $index 2 + check_err $? "$i filters - did not match highest priority (del)" + + tc filter del dev $h2 ingress protocol ip pref $index \ + handle $index flower + done + + log_test "multiple masks test ($tcflags)" +} + +ctcam_two_atcam_masks_test() +{ + RET=0 + + # First case: C-TCAM is disabled when there are two A-TCAM masks. + # We push a filter into the C-TCAM by using two identical filters + # as in identical_filters_test() + + # Filter goes into A-TCAM + tc filter add dev $h2 ingress protocol ip pref 1 handle 101 flower \ + $tcflags dst_ip 192.0.2.2 action drop + # Filter goes into C-TCAM + tc filter add dev $h2 ingress protocol ip pref 2 handle 102 flower \ + $tcflags dst_ip 192.0.2.2 action drop + # Filter goes into A-TCAM + tc filter add dev $h2 ingress protocol ip pref 3 handle 103 flower \ + $tcflags dst_ip 192.0.2.0/24 action drop + + $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \ + -t ip -q + + tc_check_packets "dev $h2 ingress" 101 1 + check_err $? "Did not match A-TCAM filter" + + # Delete both A-TCAM and C-TCAM filters and make sure the remaining + # A-TCAM filter still works + tc filter del dev $h2 ingress protocol ip pref 2 handle 102 flower + tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower + + $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \ + -t ip -q + + tc_check_packets "dev $h2 ingress" 103 1 + check_err $? "Did not match A-TCAM filter" + + tc filter del dev $h2 ingress protocol ip pref 3 handle 103 flower + + log_test "ctcam with two atcam masks test ($tcflags)" +} + +ctcam_one_atcam_mask_test() +{ + RET=0 + + # Second case: C-TCAM is disabled when there is one A-TCAM mask. + # The test is similar to identical_filters_test() + + # Filter goes into A-TCAM + tc filter add dev $h2 ingress protocol ip pref 2 handle 102 flower \ + $tcflags dst_ip 192.0.2.2 action drop + # Filter goes into C-TCAM + tc filter add dev $h2 ingress protocol ip pref 1 handle 101 flower \ + $tcflags dst_ip 192.0.2.2 action drop + + $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \ + -t ip -q + + tc_check_packets "dev $h2 ingress" 101 1 + check_err $? "Did not match C-TCAM filter" + + tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower + + $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \ + -t ip -q + + tc_check_packets "dev $h2 ingress" 102 1 + check_err $? "Did not match A-TCAM filter" + + tc filter del dev $h2 ingress protocol ip pref 2 handle 102 flower + + log_test "ctcam with two atcam masks test ($tcflags)" +} + +ctcam_no_atcam_masks_test() +{ + RET=0 + + # Third case: C-TCAM is disabled when there are no A-TCAM masks + # This test exercises the code path that transitions the eRP table + # to its initial state after deleting the last C-TCAM mask + + # Filter goes into A-TCAM + tc filter add dev $h2 ingress protocol ip pref 1 handle 101 flower \ + $tcflags dst_ip 192.0.2.2 action drop + # Filter goes into C-TCAM + tc filter add dev $h2 ingress protocol ip pref 2 handle 102 flower \ + $tcflags dst_ip 192.0.2.2 action drop + + tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower + tc filter del dev $h2 ingress protocol ip pref 2 handle 102 flower + + log_test "ctcam with no atcam masks test ($tcflags)" +} + +ctcam_edge_cases_test() +{ + # When the C-TCAM is disabled after deleting the last C-TCAM + # mask, we want to make sure the eRP state machine is put in + # the correct state + + ctcam_two_atcam_masks_test + ctcam_one_atcam_mask_test + ctcam_no_atcam_masks_test +} + +setup_prepare() +{ + h1=${NETIFS[p1]} + h2=${NETIFS[p2]} + h1mac=$(mac_get $h1) + h2mac=$(mac_get $h2) + + vrf_prepare + + h1_create + h2_create +} + +cleanup() +{ + pre_cleanup + + h2_destroy + h1_destroy + + vrf_cleanup +} + +trap cleanup EXIT + +setup_prepare +setup_wait + +tests_run + +if ! tc_offload_check; then + check_err 1 "Could not test offloaded functionality" + log_test "mlxsw-specific tests for tc flower" + exit +else + tcflags="skip_sw" + tests_run +fi + +exit $EXIT_STATUS