From patchwork Tue Jul 24 12:25:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 10542041 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 0FA0F13BB for ; Tue, 24 Jul 2018 12:27:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F11CD2870F for ; Tue, 24 Jul 2018 12:27:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E5179287A1; Tue, 24 Jul 2018 12:27:01 +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 05D0528722 for ; Tue, 24 Jul 2018 12:27:00 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41Zd026nhqzDr11 for ; Tue, 24 Jul 2018 22:26:58 +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="C9TXvYyO"; 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.0.64; helo=eur02-am5-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="C9TXvYyO"; dkim-atps=neutral Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00064.outbound.protection.outlook.com [40.107.0.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41Zczw2MHCzDq6t for ; Tue, 24 Jul 2018 22:26:50 +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=vUDBYW3u4Q5VZ1nTkB9bUhULBgsWCiHWIfNi+JK91pI=; b=C9TXvYyOzdIZhKqGEt3OXwB9f0YMD/54XAvUStI13uOty4mIbWV9bdjZxMf7nwi0GcR3xKWFrL/3sYuFYgyhesinLszFxzFmwYODMZSK/WXECoPPilBB0WA/M1e1nr1cKxD7wd9HzFwEov3/bbbSiYT3EuWjhUayuWU8cKOHMTA= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=idosch@mellanox.com; Received: from splinter.mtl.com (193.47.165.251) by VI1PR0501MB2333.eurprd05.prod.outlook.com (2603:10a6:800:2c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.973.21; Tue, 24 Jul 2018 12:26:37 +0000 From: Ido Schimmel To: linux-internal@mellanox.com Subject: [PATCH net-next mlxsw v3 00/18] mlxsw: Introduce algorithmic TCAM support Date: Tue, 24 Jul 2018 15:25:53 +0300 Message-Id: <20180724122611.13150-1-idosch@mellanox.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [193.47.165.251] X-ClientProxiedBy: AM4PR0101CA0050.eurprd01.prod.exchangelabs.com (2603:10a6:200:41::18) To VI1PR0501MB2333.eurprd05.prod.outlook.com (2603:10a6:800:2c::22) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4d0ac792-688a-4606-6159-08d5f160b40d X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600073)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:VI1PR0501MB2333; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0501MB2333; 3:H9TEt0mI6v5NOBV2xjf4tejUZoDAf9COIEXkwysEFmNYFuQxgS+HUQ9xplzAeOXjYNXDR+5SNXeXTnwVWu5pGs5GP7IN064T3Q8uPI+B+FCbrP3Hr8QXqAvT6lTG0asV3K+mdRQNXbAOoZUugOtPxJ4fLdYW+oBkUh4IkPSDngXqn5CZBGZ4ZO8tXOP0hXXjmnOdyAN0Lj0kXjCEtf+xAwRzQNt5F3ECruxnk0YczTgNmRyLIMpGLSszzYGxqUM4; 25:2YnQ7hMRk5Kt3Kv3XFKdRx8HqekssnWFrndxcBV/Zzc25f7NaPLe977qiN/ORZP1CWSw3GKOVC5RWqB5bHahZW8G/IwN5uKMBmknGn4Zbpk3tMjlgD087Lqe8HJLFejoq4WyU8TJZh6YgSGw2M1auwB7uX2/MZC7sgc6Bkj7iF5hlm3wfRwGqZQWOroZClWMJGn5FyrRUY92s6ZRC6EuMJw11ayPzLSV8HvjHVl3bqMIkF10wXJCJMZUVRt84xvet0eoDPcoYIckt2k/ug/KqmpklN/ZDdBkVdVn4BWp5KnKXCEkmvHh+zIoq9wjeHlFdQJaaAYI827itbigiy9u/Q==; 31:K0Ft9GI8Vwd59VjNhTkCjYuqJZBaUKhhr13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VS: 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)(5005006)(8121501046)(10201501046)(3002001)(93006095)(93001095)(3231311)(944501410)(52105095)(6055026)(149027)(150027)(6041310)(20161123562045)(20161123560045)(20161123558120)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016); SRVR:VI1PR0501MB2333; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0501MB2333; X-Forefront-PRVS: 0743E8D0A6 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39860400002)(346002)(376002)(366004)(136003)(396003)(199004)(189003)(8936002)(6512007)(48376002)(81166006)(50466002)(97736004)(1076002)(47776003)(66066001)(2361001)(2351001)(50226002)(34206002)(16526019)(7736002)(107886003)(14444005)(6486002)(53936002)(5660300001)(6636002)(6666003)(305945005)(68736007)(53416004)(6506007)(386003)(6116002)(8676002)(81156014)(36756003)(105586002)(106356001)(956004)(486006)(3846002)(51416003)(2616005)(26005)(476003)(4326008)(478600001)(37006003)(86362001)(316002)(25786009)(16586007)(52116002)(2906002); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0501MB2333; 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; VI1PR0501MB2333; 23:j1GAxTkuT1BMMGorPa97ab1RghajSnbNTt4buim?= H7Y48lGFW/2nAqNAMrIbPlw/eI+fbOwi7jyGKoKLxU3BfYRr+ROVBPHtP8lXSK8RwhtXoo/krqFbGMzqN4kZ0LbPf5ZtgYjyM88l9DgNpdRm+MRX4p01hZptG3z8lQEzNEdA3KkbNQGxdI6qhqY0dJaYsZYjcTzWvxPbY1ttIHIOot0O9O8wfI5asIhpRF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doe5Tt4nR+O1A9Ts8wQ3Kb/2efy2maiyk1BtBgWbHIr9jdYU2ZGQmX+5tQujO5Ubln9vlrUQXyKi+VAgSpFhtDZWvoKru2UrbmKbDNO57f4FUOW2WZLI4uO9w8LgBct+DYEkngwxd+kclOrFAbwomurDnF3j2ZF4roIiMCms6fGVQrOsGpR/HIVTc40PUgkQLbJZQBP82immMM3lklXA SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2018 12:26:37.7489 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4d0ac792-688a-4606-6159-08d5f160b40d X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0501MB2333 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 Spectrum-2 ASIC uses an algorithmic TCAM (A-TCAM) where multiple exact matches lookups are performed instead of a single lookup as with standard circuit TCAM (C-TCAM) memory. This allows for higher scale and reduced power consumption. The lookups are performed by masking a packet using different masks (e.g., {dst_ip/24, ethtype}) defined for the region and looking for an exact match. Eventually, the rule with the highest priority will be picked. Since the number of masks per-region is limited, the ASIC includes a C-TCAM that can be used as a spill area for rules that do not fit into the A-TCAM. The driver currently uses a C-TCAM only mode which is similar to Spectrum-1. However, this mode severely limits both the number of supported ACL rules and the performance of the ACL lookup. This patch set introduces initial support for the A-TCAM mode where the C-TCAM is only used for rule spillage. The first five patches add the registers and ASIC resources needed in order to make use of the A-TCAM. Next three patches are the "meat" and add the eRP core which is used to manage the masks used by each ACL region. The individual commit messages are lengthy and aim to thoroughly explain the subject. The next seven patches perform small adjustments in the code and the related data structures and are meant to prepare the code base to the introduction of the A-TCAM in the last two patches. Last patch adds a selftests that verifies different scenarios, which are documented in the test itself. Various A-TCAM optimization will be the focus of follow-up patch sets: * Pruning - Used to reduce the number of lookups. Each rule will include a prune vector that indicates which masks should not be considered for further lookups as they cannot result in a higher priority match * Bloom filter - Used to reduce the number of lookups. Before performing a lookup with a given mask the ASIC will consult a bloom filter (managed by the driver) that indicates whether a match might exist using the considered mask * Masks aggregation - Used to increase scale and reduce lookups. Masks that only differ by up to eight consecutive bits (delta bits) can be aggregated into a single mask. The delta bits then become a part of the rule's key. For example, dst_ip/16 and dst_ip/17 can be represented as dst_ip/16 with a delta bit of one. Rules using the aggregated mask then specify whether the 17-th bit should be masked or not and its value v3: * Add forgotten error checking in mlxsw_sp_acl_atcam_region_init() * Remove redundant blank line * Insert rules into C-TCAM from A-TCAM code instead of Spectrum-2 code * Introduce 'achunk' that encapsulates 'cchunk' (like we already do with 'aentry' and 'aregion') * Spill to C-TCAM from A-TCAM code instead of Spectrum-2 code, that only calls mlxsw_sp_acl_atcam_entry_add() * Fix print in ctcam_one_atcam_mask_test() v2: * Fix typo in patch 6 * Implement mlxsw_sp_acl_erp_no_mask_destroy() as WARN_ON(1) * Do not cast to 'void *' * Do not break lines at 80 chars where cure is worse than the disease * Extend mlxsw_afk_encode() instead of creating a new function in patch 10 * Move C-TCAM region init to be part of A-TCAM region init in patch 12 Ido Schimmel (18): mlxsw: reg: Prepare PERERP register for A-TCAM usage mlxsw: reg: Add Policy-Engine TCAM Entry Register Version 3 mlxsw: reg: Add Policy-Engine eRP Table Register mlxsw: resources: Add Spectrum-2 maximum large key ID resource mlxsw: resources: Add Spectrum-2 eRP resources mlxsw: spectrum_acl: Implement common eRP core mlxsw: spectrum_acl: Enable C-TCAM only mode in eRP core mlxsw: spectrum_acl: Add support for C-TCAM eRPs mlxsw: spectrum_acl: Extend Spectrum-2 region struct mlxsw: spectrum_acl: Allow encoding a partial key mlxsw: spectrum_acl: Add A-TCAM initialization mlxsw: spectrum_acl: Encapsulate C-TCAM region in A-TCAM region mlxsw: spectrum_acl: Make global TCAM resources available to regions mlxsw: spectrum_acl: Add A-TCAM region initialization mlxsw: spectrum_acl: Pass C-TCAM region and entry to insert function mlxsw: spectrum_acl: Add A-TCAM rule insertion and deletion mlxsw: spectrum_acl: Start using A-TCAM selftests: mlxsw: Add TC flower test for Spectrum-2 drivers/net/ethernet/mellanox/mlxsw/Kconfig | 1 + drivers/net/ethernet/mellanox/mlxsw/Makefile | 2 +- .../mellanox/mlxsw/core_acl_flex_keys.c | 10 +- .../mellanox/mlxsw/core_acl_flex_keys.h | 2 +- drivers/net/ethernet/mellanox/mlxsw/reg.h | 301 ++++- .../net/ethernet/mellanox/mlxsw/resources.h | 14 + .../net/ethernet/mellanox/mlxsw/spectrum.h | 1 + .../mellanox/mlxsw/spectrum1_acl_tcam.c | 24 +- .../mellanox/mlxsw/spectrum2_acl_tcam.c | 82 +- .../mellanox/mlxsw/spectrum_acl_atcam.c | 509 ++++++- .../mellanox/mlxsw/spectrum_acl_ctcam.c | 40 +- .../mellanox/mlxsw/spectrum_acl_erp.c | 1199 +++++++++++++++++ .../mellanox/mlxsw/spectrum_acl_tcam.c | 2 +- .../mellanox/mlxsw/spectrum_acl_tcam.h | 117 +- .../drivers/net/mlxsw/spectrum-2/tc_flower.sh | 366 +++++ 15 files changed, 2601 insertions(+), 69 deletions(-) create mode 100644 drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_erp.c create mode 100755 tools/testing/selftests/drivers/net/mlxsw/spectrum-2/tc_flower.sh