From patchwork Sun Jul 22 13:16:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 10539301 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 D21C71805 for ; Sun, 22 Jul 2018 13:18:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BDBC3281F9 for ; Sun, 22 Jul 2018 13:18:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AFBDE28385; Sun, 22 Jul 2018 13:18:31 +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 D4BF4281F9 for ; Sun, 22 Jul 2018 13:18:30 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41YQDN6qKzzDqyZ for ; Sun, 22 Jul 2018 23:18:28 +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="bIvIr5Hf"; 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="bIvIr5Hf"; 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 41YQD33djjzDqmf for ; Sun, 22 Jul 2018 23:18:10 +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=9ZG/ZfcGlPJ7SQLAp7znbo8o+QjKdWmZZ2q5aKSgIyE=; b=bIvIr5HfOUkbiPInboOfPaitDt6JekK3sGZvxaQg1eHR3TWxYw47VyP46n6uQ3vAcZG7DNeT8wLo5rZY0b3WNPJxrhbFcex+Agl6PhhqnhuZbADEVs9UUP+DcRx2YXHJn8FhTL2Hjwd1r/WMGALO8oFRLHxe1m9W8P+qCmdxAbI= 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:54 +0000 From: Ido Schimmel To: linux-internal@mellanox.com Subject: [PATCH net-next mlxsw 00/18] mlxsw: Introduce algorithmic TCAM support Date: Sun, 22 Jul 2018 16:16:54 +0300 Message-Id: <20180722131712.30578-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: 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: 37fc7554-e702-42dd-bff7-08d5efd58907 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:YZz9uZdzpxHy4sNLXiJfwhZg2vIfDbgdUcvBWZIhjYdn65zAK0cH8xnJFhMsefj2GPSkQIlRZ/TiBASb1sHc9RnebPx+mpCxrzQzp352caotyFhUUceMShy4BFU+HK8piiCIYIMzOJNrBlGMGaB3ObAzLf5U5x4Qjy7GPAxjSrM5Sd56ty+xd61yivPuURxSIRZK3CbShynzY143Csen7qst9WzmXzntzq0qyiA/y8KgwmARdCCEoX4D3+iIVyc4; 25:4tgkeYD+q8w0NU5o40aXFP3ywFjuaV2KZUvccLde+vhklzB9nTx5yAEsCBJRYOTiSKmyHb1fOb9OTV5suhfYXzrU1U5YeSvdZvd4+PN4hnPg/dbuUY7s/rTpNCqlX3pU0QVLyt2t+jfYZlUKdebLvlM0TgjnFC0JteIFyxie90Uwx6Di1RcwT1dtJGdWv4ox46kwbDF2Xch9hnpAXlqcBShQCL55BcpYNOePX4jX1hBsNduES2iXne8/IjE+bAL/5CqkCkm7uYYNJHl334Nf5n16YLLYIIiMz5R+rYm5HZ1Dz8qy6J9O7MC6PlAPHkPqDFH/cRG5VquSDfuiSE6zOQ==; 31:k7qiLOj9qZzWPgsPo7UoOonk+U+OlFFmJxZR/4ub19M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soft-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)(26005)(105586002)(6636002)(386003)(6506007)(478600001)(8676002)(8936002)(5660300001)(53936002)(48376002)(34206002)(107886003)(50226002)(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:F+LNxJIC/fxyGvgR7PRslqIJGke/nEELb2Dm1sJ?= 27nqNRACXy6OYEYegy3dtMf7S6t6/ut/fbsA5jw4uIaoF1Goxbq8ZuQDHPYwzkuoXN3n+sGkiW/9m4JUtoJoEN0WSaWsCCdMan1ZjTQp0OcVjSJU0qQ3HnJk6CGjlAQ5oJW/uCXRu5Q9MYoJjSNpYLVzk21NGFhwqIBG74YG+ItutYyLq7l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i9gAECoidJ2zHfYUycjitjIHocGHiui7rQuclgootWdPgkkD6fw6TfdUwhNauXEKx1gvf53H0Fv7I4P/MvHDKLMxoO9X1eGYCMlrexqm0tr9AY0bJ0MnaHAv2Y7BdUhGeugx1Cjop0/R4DcB+EiTTvhfKUM3fzI5/UBUE8tenwRk3SzOCzMag+yFk945Ay/0I2YHg+Z3 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2018 13:17:54.3227 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 37fc7554-e702-42dd-bff7-08d5efd58907 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 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 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 | 122 +- .../mellanox/mlxsw/spectrum_acl_atcam.c | 455 ++++++- .../mellanox/mlxsw/spectrum_acl_ctcam.c | 40 +- .../mellanox/mlxsw/spectrum_acl_erp.c | 1194 +++++++++++++++++ .../mellanox/mlxsw/spectrum_acl_tcam.c | 2 +- .../mellanox/mlxsw/spectrum_acl_tcam.h | 106 +- .../drivers/net/mlxsw/spectrum-2/tc_flower.sh | 366 +++++ 15 files changed, 2573 insertions(+), 67 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