From patchwork Fri Jul 27 19:09:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 10547615 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 1A6CF112E for ; Fri, 27 Jul 2018 19:10:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 079F52C453 for ; Fri, 27 Jul 2018 19:10:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EFE952C440; Fri, 27 Jul 2018 19:10: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 AF7252C44C for ; Fri, 27 Jul 2018 19:10:12 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41cdnt4V4HzF0x7 for ; Sat, 28 Jul 2018 05:10:10 +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="q4ku1/5b"; 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.6.61; helo=eur04-db3-obe.outbound.protection.outlook.com; envelope-from=petrm@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="q4ku1/5b"; dkim-atps=neutral Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60061.outbound.protection.outlook.com [40.107.6.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41cdnc1QbJzF0jD for ; Sat, 28 Jul 2018 05:09:55 +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=XKDlCoeo9ibDdA1A0Izh/hlYtL53jsYQXxpq/w5Z/R4=; b=q4ku1/5b9ScQOpXA3Vkz2ty7JrAChX5e9Vwbwf18nMEzl0cBHjT7ReKbVVPmbdLv5CL72+DEVNplLR+T/3vcKAdoHhcVfpgn9XxqJ+oLoeszbY2/TmUOOh7nsuxK7Lel7H+JSQQONZDayBvWEPYCXd7sdjuj623DAv50k4DnV6I= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=petrm@mellanox.com; Received: from t540p (78.45.160.211) by VI1PR05MB4192.eurprd05.prod.outlook.com (2603:10a6:803:4e::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.973.21; Fri, 27 Jul 2018 19:09:47 +0000 From: Petr Machata To: Subject: [PATCH net-next mlxsw v3 00/10] mlxsw: Support DSCP prioritization and rewrite Message-Id: Date: Fri, 27 Jul 2018 21:09:41 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 X-Originating-IP: [78.45.160.211] X-ClientProxiedBy: VI1PR04CA0110.eurprd04.prod.outlook.com (2603:10a6:803:64::45) To VI1PR05MB4192.eurprd05.prod.outlook.com (2603:10a6:803:4e::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 27167e11-1c42-4f34-e819-08d5f3f48507 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:VI1PR05MB4192; X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB4192; 3:8MaQirEDS/8DSmIWKTo3nFN2ttRCqR9O13kP6nxkp9Wcj8oIpV2ln2eKEprMkw+uTLPJzi/GhCn0T4CYRAg75FVDJGIOo54OuNMJWz4qc/EPKOOl7zamjPpLqQfkHL747ILWvv8kNTJ06EqqoEPvOWdFuA1q5HnwNogdKZouQi3BJxADN8nUFPMhdIXbvyySrV5spFZyW2JQph2YkdSI0sl0tDeN6GQirABjuL6M6pQQHKAqpc9JTREvr3kFJtvm; 25:wjnJZegAWBx3vPdkY8wOTuT1oZVELrAIkyaiAPG/ovtArAN+bVvJQe8n0Eq8E49hSrWeVBcWBiPlFHpcQWcqZB6PKBOZo7OwCCra+bQF4UBZoR5g/lpnDcZ14Te1NtTtEMMFtr4ZfLIK9+UimquhYn836/nfOeICgn/oFGkTRmjf2Bo+gqFF8m5ZCUgLYI8x0zU2TfmWnHujsR4jtTUDR4L2mqjVBLvgP5poJ7Fgp4lYbpzOQkyFdeYjaZEmBKPiAMNHMUfaVPvQJtEFbjN3dhNc+opIzCHskS18GYlzFcE9KlNygyS+uOJLElG4oXfPhQqZUuOH8wuIi0u4iz1o7A==; 31:YfONOFMCQ3a0R7fJYlyOJ8r/W0TFDIx61W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XCw== 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)(93006095)(93001095)(3002001)(3231311)(944501410)(52105095)(10201501046)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123560045)(20161123562045)(6072148)(201708071742011)(7699016); SRVR:VI1PR05MB4192; BCL:0; PCL:0; RULEID:; SRVR:VI1PR05MB4192; X-Forefront-PRVS: 07467C4D33 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(396003)(346002)(136003)(366004)(376002)(39860400002)(189003)(199004)(6862004)(105586002)(316002)(66066001)(2616005)(14444005)(52116002)(106356001)(47776003)(2351001)(51416003)(478600001)(186003)(486006)(956004)(476003)(386003)(53936002)(25786009)(16526019)(97736004)(6666003)(8936002)(6496006)(81166006)(6486002)(81156014)(6636002)(8676002)(48376002)(37006003)(50466002)(36756003)(16586007)(86362001)(58126008)(575784001)(68736007)(26005)(305945005)(6116002)(5660300001)(3846002)(7736002)(2906002); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR05MB4192; H:t540p; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR05MB4192; 23:1JqOYPvLmpgQl7xmiWWk/oAXJm21U2qOh797VY+lf?= BICLzXHg9q77W9X5B4ROIYBhU7/u+PeNZ8XnCw0f+eCafxo5W3qfTZKbPuCpDJj0tT9yM331Caf1JrugnSIP8uBZiy93gUSeUufCYY+FNM/XguxF1W/GINnsEciNXTataVyV9NDsvk4qu28Di3BF0jTEI+nvkZ5oeAZfRTkQeUVbjvmQEgaaipJUaL4k1XRg6+2FAUsGFlPqfJ+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qFjHh4uyzLAzI/P3cGritIKy8dv8sWrM5pO577LH8W9ewQHAIap0bKy122GaQ2Viz82XivCC5suulR017qSRa8sMAfGYm3 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jul 2018 19:09:47.1313 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 27167e11-1c42-4f34-e819-08d5f3f48507 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB4192 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 **Note:** The SPDX patch landed in combined queue since v2. I don't want to rebase this v3 on top of that, because that would cause useless back-and-forth as we update each other's patches to apply cleanly. The changes in this version v3 are however only in tests and thus won't conflict. So when applying this, just unroll the v2, apply v3, and reapply whatever was on top that, there won't be any conflicts. On ingress, a network device such as a switch assigns to packets priority based on various criteria. Common options include interpreting PCP and DSCP fields according to user configuration. When a packet egresses the switch, a reverse process may rewrite PCP and/or DSCP headers according to packet priority. So far, mlxsw has supported prioritization based on PCP (802.1p priority tag). This patch set introduces support for prioritization based on DSCP, and DSCP rewrite. To configure the DSCP-to-priority maps, the user is expected to invoke ieee_setapp and ieee_delapp DCBNL ops, e.g. by using lldptool: # lldptool -T -i sw1p6 -V APP app=3,5,24 # (priority 3, DSCP, 24) To decide whether or not to pay attention to DSCP values, the Spectrum switch recognize a per-port configuration of trust level. Until the first APP rule is added for a given port, this port's trust level stays at PCP, meaning that PCP is used for packet prioritization. With the first DSCP APP rule, the port is configured to trust DSCP instead, and it stays there until all DSCP APP rules are removed again. Besides the DSCP (value 5) selector, another selector that plays into packet prioritization is Ethernet type (value 1) with PID of 0. Such APP entries denote default priority[1]: # lldptool -T -i sw1p6 -V APP app=3,1,0 # (default priority 3) With this patch set, mlxsw uses these values to configure priority for DSCP values not explicitly specified in DSCP APP map. In the future we expect to also use this to configure default port priority for untagged packets. Access to DSCP-to-priority map, priority-to-DSCP map, and default priority for a port is exposed through three new DCB helpers. Like the already-existing dcb_ieee_getapp_mask() helper, these helpers operate in terms of bitmaps, to support the arbitrary M:N mapping that the APP rules allow. Such interface presents all the relevant information from the APP database without necessitating exposition of iterators, locking or other complex primitives. It is up to the driver to then digest the mapping in a way that the device supports. In this patch set, mlxsw resolves conflicts by favoring higher-numbered DSCP values and priorities. In this patchset: - Patch #1 fixes a bug in DCB APP database management. - Patch #2 adds the getters described above. - Patches #3-#6 add Spectrum configuration registers. - Patch #7 adds the mlxsw logic that configures the device according to APP rules. - Patches #8-#10 add a library support and self-test. The test is added to the subdirectory drivers/net/mlxsw. Even though it's not particularly specific to mlxsw, it's not suitable for running on soft devices (which don't support the ieee_getapp et.al.), and thus isn't a good fit for the general net/forwarding directory. [1] 802.1Q-2014, Table D-9 Changes from v2 to v3: - Split patch #8 into patches #8-#10. - In patch #10, fix two bugs: when indexing in bash associative array, the subscript is interpreted as string, not as a variable name to be expanded. And the key stored to t0s and t1s is not DSCP value, but key+base. Any one of these bugs would be noticed, but in combination they conspired to make the test just work, except it didn't really test anything. - Add lldpad_wait_del even though it just sleeps. It will serve as a placeholder for the explanatory comment (which tweak to make it more understandable) and as a source code marker in case we'll come up with a better way to handle this. - Support DSCP of 0 for dscp_capture_install et.al. Changes from v1 to v2: - In patches #2 and #7, use IEEE_8021QAZ_MAX_TCS instead of literal 8. - In patch #2, check values of ifindex, selector, protocol, priority consistently in all helpers, and in this order. - In patch #6, update commit message to describe when the rewrite is done. - In patch #7, in mlxsw_sp_port_dcb_app_update(): - Don't unnecessarily initialize have_dscp - Rewrite if(have_dscp){Y} if(!have_dscp){Z} to if(have_dscp){return Y} Z - In patch #8: - Fix asymmetry between h1_create and h1_destroy, likewise for h2 - Don't tolerate a couple stray extra packets. - Rename to qos_dscp_bridge.sh to recognize that this is the likely less common scenario that doesn't involve router. Petr Machata (10): net: dcb: For wild-card lookups, use priority -1, not 0 net: dcb: Add priority-to-DSCP map getters mlxsw: reg: Add QoS Port DSCP to Priority Mapping Register mlxsw: reg: Add QoS Priority Trust State Register mlxsw: reg: Add QoS ReWrite Enable Register mlxsw: reg: Add QoS Priority to DSCP Mapping Register mlxsw: spectrum: Support ieee_setapp, ieee_delapp selftests: forwarding: lib: Add DSCP capture selftests: forwarding: lib: Add lldpad waiting functions selftests: mlxsw: Add test for trust-DSCP drivers/net/ethernet/mellanox/mlxsw/reg.h | 219 +++++++++++++++++ drivers/net/ethernet/mellanox/mlxsw/spectrum.h | 4 +- drivers/net/ethernet/mellanox/mlxsw/spectrum_dcb.c | 269 ++++++++++++++++++++- include/net/dcbnl.h | 13 + net/dcb/dcbnl.c | 97 +++++++- .../selftests/drivers/net/mlxsw/qos_dscp_bridge.sh | 189 +++++++++++++++ tools/testing/selftests/net/forwarding/lib.sh | 63 +++++ 7 files changed, 848 insertions(+), 6 deletions(-) create mode 100755 tools/testing/selftests/drivers/net/mlxsw/qos_dscp_bridge.sh