From patchwork Wed Jan 18 21:08:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Machon X-Patchwork-Id: 13107093 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 40438C32793 for ; Wed, 18 Jan 2023 21:10:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=1WcMNkc6TZIg1z15DzFax/hRDTUtuJeI2BFNuaGSfv8=; b=KF4PcCl6+cC+Mi ldo7zS/kdDw9DQa9XBcjaueY5YBHKT75I028jDesgFEMbQ46r69r+yuoTXbmvmot2rD5CczWKLUE5 ALzYfGOjhnw5f4DIBQ+rRYt4X6JQ3FaTIhx5TIndI8V0uuCTG7VPPvm3GXk2CGTwNzjYfAOsul948 cI2qmLwNAOLfJmUuF7W+Pv9jblNQvR4QUpk4+96cZYVtovXnxGVAi0+Lp60bcVsASbvuUzUMFtB8n XuWO2X3538UL8BMVXDtPloiGGoFbBu6Z2+ZDy3xv8myhMdQ25DGS9Lu+m+TOmX+90SPoF1T5642Nu HdREOKaMSV8q+EtqZvvg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pIFgB-002enJ-Vy; Wed, 18 Jan 2023 21:09:08 +0000 Received: from esa.microchip.iphmx.com ([68.232.153.233]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pIFg0-002ej6-73 for linux-arm-kernel@lists.infradead.org; Wed, 18 Jan 2023 21:08:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1674076137; x=1705612137; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=W+zfF5/WByDU3V4Hotlsn4XZjcSRUBklqkwaaZxZT1g=; b=egt13snpysyAGSQ4Vr+P05BX/FQ9odwh2+VZ4rXCe0VwOQuVm8WRcU5i cRX3CqQoBYVxjVqNefZKXjfq17Szlr5ZvshQi6pHgNIEtLzrwXPVJRZ1C A5ufMIZVi/NWRyRy6+0wrUSSVDrwOM9uTzz1a8tnrzWYNqQ60+N5H8kQv zZnUf3H6Ij4i/EeJalhijnTF4WuzgNt3lBdwL6I8sd3HnVn3NCJYn5P7s 3/8r9FGpm7GGadN+pT1qo/aHg+sW/x7tKc8d67ozOBCHztP+MzEU6DF8x BY7nSalnj1fKHAwt/Z+EYQvNJIaz/faGIHm0QouB/Tnyix4RRPaGZZfDc g==; X-IronPort-AV: E=Sophos;i="5.97,226,1669100400"; d="scan'208";a="197370475" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 18 Jan 2023 14:08:51 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Wed, 18 Jan 2023 14:08:44 -0700 Received: from DEN-LT-70577.microchip.com (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Wed, 18 Jan 2023 14:08:40 -0700 From: Daniel Machon To: CC: , , , , , , , , , , , , , , , , Subject: [PATCH net-next v3 0/6] Introduce new DCB rewrite table Date: Wed, 18 Jan 2023 22:08:24 +0100 Message-ID: <20230118210830.2287069-1-daniel.machon@microchip.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230118_130856_342263_7DC40604 X-CRM114-Status: GOOD ( 18.30 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org There is currently no support for per-port egress mapping of priority to PCP and priority to DSCP. Some support for expressing egress mapping of PCP is supported through ip link, with the 'egress-qos-map', however this command only maps priority to PCP, and for vlan interfaces only. DCB APP already has support for per-port ingress mapping of PCP/DEI, DSCP and a bunch of other stuff. So why not take advantage of this fact, and add a new table that does the reverse. This patch series introduces the new DCB rewrite table. Whereas the DCB APP table deals with ingress mapping of PID (protocol identifier) to priority, the rewrite table deals with egress mapping of priority to PID. It is indeed possible to integrate rewrite in the existing APP table, by introducing new dedicated rewrite selectors, and altering existing functions to treat rewrite entries specially. However, I feel like this is not a good solution, and will pollute the APP namespace. APP is well-defined in IEEE, and some userspace relies of advertised entries - for this fact, separating APP and rewrite into to completely separate objects, seems to me the best solution. The new table shares much functionality with the APP table, and as such, much existing code is reused, or slightly modified, to work for both. ================================================================================ DCB rewrite table in a nutshell ================================================================================ The table is implemented as a simple linked list, and uses the same lock as the APP table. New functions for getting, setting and deleting entries have been added, and these are exported, so they can be used by the stack or drivers. Additionnaly, new dcbnl_setrewr and dcnl_delrewr hooks has been added, to support hardware offload of the entries. ================================================================================ Sparx5 per-port PCP rewrite support ================================================================================ Sparx5 supports PCP egress mapping through two eight-entry switch tables. One table maps QoS class 0-7 to PCP for DE0 (DP levels mapped to drop-eligibility 0) and the other for DE1. DCB does currently not have support for expressing DP/color, so instead, the tagged DEI bit will reflect the DP levels, for any rewrite entries> 7 ('de'). The driver will take apptrust (contributed earlier) into consideration, so that the mapping tables only be used, if PCP is trusted *and* the rewrite table has active mappings, otherwise classified PCP (same as frame PCP) will be used instead. ================================================================================ Sparx5 per-port DSCP rewrite support ================================================================================ Sparx5 support DSCP egress mapping through a single 32-entry table. This table maps classified QoS class and DP level to classified DSCP, and is consulted by the switch Analyzer Classifier at ingress. At egress, the frame DSCP can either be rewritten to classified DSCP to frame DSCP. The driver will take apptrust into consideration, so that the mapping tables only be used, if DSCP is trusted *and* the rewrite table has active mappings, otherwise frame DSCP will be used instead. ================================================================================ Patches ================================================================================ Patch #1 modifies dcb_app_add to work for both APP and rewrite Patch #2 adds dcbnl_app_table_setdel() for setting and deleting both APP and rewrite entries. Patch #3 adds the rewrite table and all required functions, offload hooks and bookkeeping for maintaining it. Patch #4 adds two new helper functions for getting a priority to PCP bitmask map, and a priority to DSCP bitmask map. Patch #5 adds support for PCP rewrite in the Sparx5 driver. Patch #6 adds support for DSCP rewrite in the Sparx5 driver. ================================================================================ v2 -> v3: in dcbnl_ieee_fill() use nla_nest_start() instead of the _noflag() version. Also, cancel the rewrite nest in case of an error (Petr Machata). v1 -> v2: In dcb_setrewr() change proto to u16 as it ought to be, and remove zero initialization of err. (Dan Carpenter). Change name of dcbnl_apprewr_setdel -> dcbnl_app_table_setdel and change the function signature to take a single function pointer. Update uses accordingly (Petr Machata). Daniel Machon (6): net: dcb: modify dcb_app_add to take list_head ptr as parameter net: dcb: add new common function for set/del of app/rewr entries net: dcb: add new rewrite table net: dcb: add helper functions to retrieve PCP and DSCP rewrite maps net: microchip: sparx5: add support for PCP rewrite net: microchip: sparx5: add support for DSCP rewrite .../ethernet/microchip/sparx5/sparx5_dcb.c | 121 +++++++- .../microchip/sparx5/sparx5_main_regs.h | 70 ++++- .../ethernet/microchip/sparx5/sparx5_port.c | 97 +++++++ .../ethernet/microchip/sparx5/sparx5_port.h | 41 +++ include/net/dcbnl.h | 18 ++ include/uapi/linux/dcbnl.h | 2 + net/dcb/dcbnl.c | 272 ++++++++++++++---- 7 files changed, 548 insertions(+), 73 deletions(-) --- 2.34.1