From patchwork Tue Jul 24 14:29: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: 10542273 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 9597F1805 for ; Tue, 24 Jul 2018 14:42:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 83B3428C63 for ; Tue, 24 Jul 2018 14:42:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 77DD428C7F; Tue, 24 Jul 2018 14:42:36 +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 F166228C63 for ; Tue, 24 Jul 2018 14:42:34 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41Zh0S52FnzDq6t for ; Wed, 25 Jul 2018 00:42:32 +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="WVMkg0bA"; 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=104.47.0.88; helo=eur01-he1-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="WVMkg0bA"; dkim-atps=neutral Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on0088.outbound.protection.outlook.com [104.47.0.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41Zgk54b7pzF0Pl for ; Wed, 25 Jul 2018 00:30: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=no4x2pnktNEiluOr/RcT2Gaz1/834OBGklioVWTaXH0=; b=WVMkg0bAlRbPu8VOOQvjND+N72qabs8wH1gbSYqg6cJBIG7Bh1xd8wAoCmYYU8c2wmKp7FG4cbHgYoaX4z6vkwwZi9cb0s+ibjseuGE9dW9AbzcWViWHIv2UIcHGeT/QUGRB11x3FQAgfjMo6YNX/3j/P2oaP2Su9VbvP9DhxLg= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=idosch@mellanox.com; Received: from splinter.mtl.com (193.47.165.251) by AM4PR0501MB2322.eurprd05.prod.outlook.com (2603:10a6:200:53::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.973.16; Tue, 24 Jul 2018 14:29:53 +0000 From: Ido Schimmel To: linux-internal@mellanox.com Subject: [PATCH net-next mlxsw v4 00/18] mlxsw: Introduce algorithmic TCAM support Date: Tue, 24 Jul 2018 17:29:08 +0300 Message-Id: <20180724142926.13033-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: VI1P189CA0018.EURP189.PROD.OUTLOOK.COM (2603:10a6:802:2a::31) To AM4PR0501MB2322.eurprd05.prod.outlook.com (2603:10a6:200:53::23) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e1e66c93-8dbc-4fb4-c81e-08d5f171ec28 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600073)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:AM4PR0501MB2322; X-Microsoft-Exchange-Diagnostics: 1; AM4PR0501MB2322; 3:cbQuhZt6VOBjVtnIw4rcR4P2lgs0XWUYJ+9LpS+P4Fx3XRt6lNy1tUrY+vf/QkKY+fJL4PcgsVrezHSthP0dvMI089+6+rY4qwCAsPUIzOPuk32HoiW9gUOsQpR4dJHx+NLB5W1cymRiAlfBgqAg4EpKhXsppbBwQAO+g0yMgv1ZCwY4xCdBVHrzu9yWl79XGA38sNCTB1Xq8UMem8Z7JAtKhSb8jSvrG4bplEi0bvyzs0x8VT8Ce9UplrB03RWn; 25:mFY7uT2+prcH3267N2/JsSs151HmB0QgvsBmptPuLJgqyRafuRpj4IbyCPCnA/hhWIqoHzjGiT4iZbtufHMeikHO8BVn839cGg4BTLCjL8v1mnG0sRBaMz0RV/5I6N138H3H5Whs1QIpknhx/vr7vG1z0tH5lHYiKrqYUvKV9eJ+om8uoS/Bq6regv0Nv9X/MaEJ5N2EqLlz8V6C66MGacoIDFsH4FoiJT9KNEQFLqGYAaEpqYI4Vms8NkpXEtqRhmJRCzGDtIjCYFd04LKw44hm35uGXCVnAgMf/9/O2LqyvqCfUu5r4ECNLkhvlEjw/hpMa+9s8fqjG2QCXkCXAw==; 31:dEkiA8ua60Rgqy2NQJW8CuH5R/gMl3bG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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)(5005006)(8121501046)(10201501046)(3002001)(93006095)(93001095)(3231311)(944501410)(52105095)(6055026)(149027)(150027)(6041310)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016); SRVR:AM4PR0501MB2322; BCL:0; PCL:0; RULEID:; SRVR:AM4PR0501MB2322; X-Forefront-PRVS: 0743E8D0A6 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(346002)(396003)(376002)(39860400002)(366004)(136003)(199004)(189003)(53936002)(97736004)(7736002)(305945005)(34206002)(107886003)(6512007)(486006)(4326008)(25786009)(26005)(478600001)(6486002)(16526019)(6116002)(105586002)(2616005)(956004)(16586007)(53416004)(316002)(3846002)(66066001)(1076002)(47776003)(2361001)(5660300001)(68736007)(51416003)(50226002)(2906002)(8936002)(37006003)(106356001)(81156014)(86362001)(8676002)(386003)(36756003)(81166006)(6636002)(48376002)(2351001)(52116002)(6666003)(14444005)(476003)(50466002)(6506007); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR0501MB2322; 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; AM4PR0501MB2322; 23:/dIDarLnuODYs8DTuThksUCfPsUny5FAmPHiNxq?= mxxY94NKiaz0ES43JEXmqfwsSFGpsZVJm41GYHkcqvJXfb+mYryj/4jnIjuXYcJIPKTuNOzAkckBCMHN1rp3a7fZ1f/eYiF1B2jag5JOkSHPRXfFM0vd1r0Sf84RR7/9ECczqGhLLvouL0ylcB4o5/NHPqy2fhEC1e9M3Ad6WSnH2fzQCr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ZXBr4Tnf2FI5DBuiKYKA6iKBp0Bw+pxStVkKbptLzrG26nzDGmjYgSQEMLuxv1oiTR6bP1m0e1kB2X5u/1gPfKLvEehQfG+MytFEpVfW1n8Jo3vK8aoB1kiEKSIiYRc69ZtYA9YRN0XNg01UeGslCnWPvTbpfhJzdAP8Kz71N9thEo9S1FfUXs89dGXQK66iLMoE/NydvHglKhsnzJLVZFT3ICrYj1cgWmMVzD+XT SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2018 14:29:53.2393 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e1e66c93-8dbc-4fb4-c81e-08d5f171ec28 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR0501MB2322 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 v4: * In patch 12, directly return in mlxsw_sp_acl_atcam_region_init() instead of returning 'err' 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