From patchwork Wed Jul 25 13:53:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 10544035 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 3BFBD139A for ; Wed, 25 Jul 2018 13:53:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 299B42A020 for ; Wed, 25 Jul 2018 13:53:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1DF092A07B; Wed, 25 Jul 2018 13:53: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 2C8342A020 for ; Wed, 25 Jul 2018 13:53: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 41bGsS35nFzDrSg for ; Wed, 25 Jul 2018 23:53: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="Mq0iX2vY"; 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.82; helo=eur04-vi1-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="Mq0iX2vY"; dkim-atps=neutral Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80082.outbound.protection.outlook.com [40.107.8.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41bGsG4nz9zDrHF for ; Wed, 25 Jul 2018 23:53: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=iaCtJDWtY9KsazvRnvZYymf9ynJVLd6Gt7eVNRuRu54=; b=Mq0iX2vY2nOQ/KAUhanR3rBwanrHEzj0OLNhRn8qqzHwpNOdWv+vEOfvcX6FgKXC2xARqIk3PsLjiJoJ6Go08aWz/gB2dfkXo+ECOVMx78xDLlByb+Unbkw+NHQPqKX6lzQpBxHkL7i9m/0rIyWNIr6NjY7td2SDvXLGC7UjEdI= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=petrm@mellanox.com; Received: from t540p (78.45.160.211) by DB7PR05MB4186.eurprd05.prod.outlook.com (2603:10a6:5:18::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.973.21; Wed, 25 Jul 2018 13:53:12 +0000 From: Petr Machata To: Subject: [PATCH net-next mlxsw v2 0/8] mlxsw: Support DSCP prioritization and rewrite Message-Id: Date: Wed, 25 Jul 2018 15:53:07 +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: AM5PR0701CA0013.eurprd07.prod.outlook.com (2603:10a6:203:51::23) To DB7PR05MB4186.eurprd05.prod.outlook.com (2603:10a6:5:18::27) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0a43e64d-0639-418f-e7e9-08d5f235f67d X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600073)(711020)(4618075)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)(7193020); SRVR:DB7PR05MB4186; X-Microsoft-Exchange-Diagnostics: 1; DB7PR05MB4186; 3:aRMN05YpFP1ZWEyy/Ha4WKQwP3lBphMmJ1TwplrphFzDbmVOExLlQm/nkd4ZhUlfgRMWFe0aIUmmHdxypxMWNDWYtUnF8dVw3KyqAbZ1XxS1lfFTHm4Za6N+uf+wrUN85QqiIDLHCJv2hZlM+SISEQyep2KLOXrLgQSO0PhGZEGMeapjNCcUhlKlcS5cQ3lcrf59qIMI9kDs18AXKkEf7m1qhqF4F6kEZWJ8mH3OzBfQo0B5h6m8m9Qwv3XwL2jX; 25:wOonWdF300diICpdgTpt/hwoeDtc7DqjX5cKkD5QgrIUH4Xzqmbq3PhxDmj5gHkcDVTCYpin0NzFaCmu47PPRQeQUkraMvM1srjtulzFrlInMIrbn2eDdUV7gakCtkSYY0msqR0VsG0cKh0YUaq1z9pKl+u/IQT0+871kEZCa69fL3kODYtPFNInhWysBbviUcslttLcD+WhkO2qu78AaWXoQS8LMx8jHwrBg3AVFWz1EUXJ5LeG3uZxs6AwxPRVEKieuKgK4iNzhhR9YQ21jFktQt8SHMCGcTvTNJUyPQvOmjVm0+3B3VAm2ipVh5+V2YJYBcp/LMT5BRBIjyitsQ==; 31:zgSRFxrWMsnKmSmTqNEC1vCXpA0BPn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/9w== 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)(5005006)(8121501046)(10201501046)(93006095)(93001095)(3231311)(944501410)(52105095)(3002001)(6055026)(149027)(150027)(6041310)(20161123562045)(20161123560045)(20161123564045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016); SRVR:DB7PR05MB4186; BCL:0; PCL:0; RULEID:; SRVR:DB7PR05MB4186; X-Forefront-PRVS: 0744CFB5E8 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39860400002)(136003)(376002)(396003)(346002)(366004)(189003)(199004)(53936002)(6666003)(36756003)(6486002)(478600001)(50466002)(48376002)(97736004)(6862004)(8936002)(81166006)(81156014)(25786009)(7736002)(305945005)(8676002)(6496006)(2351001)(106356001)(6636002)(386003)(476003)(956004)(2616005)(486006)(6116002)(3846002)(105586002)(66066001)(186003)(16526019)(47776003)(26005)(51416003)(52116002)(68736007)(2906002)(16586007)(58126008)(5660300001)(316002)(14444005)(37006003)(86362001); DIR:OUT; SFP:1101; SCL:1; SRVR:DB7PR05MB4186; 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; DB7PR05MB4186; 23:HWVeTPIMM9P5FEZalCFqFk9HY2EkVghNRUXyI70j0?= u8IVUzchUKR2vgJr/Y064aHY451gU0An/cbp01S2/U2kruaQPpbf/VQ3szFHNY3Kcev9fWNmAvsF2UaRKGSD5YjGqZk+EiIL3IFAtl6p/wdo2dUQTomqTnWeEO7WtyapwPeaWy8FBrXF7eNAAneSDhEFYKdNd7hpgiAFhVv3rGScmmblWdPTiaG6/Umbmr2pl9Jy9j/9K2CcnY1tzt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lbLW/b3z23S+Wfj102WpXh6ogWXK2xbzHjnddXLSiE32l9ZOBfQq7zwbM+brBjgdM7ItNAOkIij2OSZWmQLqmOPpGs48nXHo SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2018 13:53:12.2928 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0a43e64d-0639-418f-e7e9-08d5f235f67d X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR05MB4186 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 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. - Patch #8 adds a 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 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 (8): 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: 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 | 248 +++++++++++++++++++ 6 files changed, 844 insertions(+), 6 deletions(-) create mode 100755 tools/testing/selftests/drivers/net/mlxsw/qos_dscp_bridge.sh