Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1202843rwd; Tue, 16 May 2023 13:25:22 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7aPCJZU8VsP6QRPCLzKSqmfQHd1rtz03vxBkXY2AVffyTNxyTaKMba/PbQ6SV/bpYmL7xX X-Received: by 2002:a05:6a00:17a3:b0:636:f5f4:5308 with SMTP id s35-20020a056a0017a300b00636f5f45308mr53704908pfg.7.1684268722450; Tue, 16 May 2023 13:25:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684268722; cv=none; d=google.com; s=arc-20160816; b=tMCc+YxLxZOJuE/SYIVHjTRkWlhwmM5XaqqXmj7Ae5G+RoQulvw/FDWql9CIP/t22O en6eNNDKUjyoQzUXgnwyAHFqma6y21RPKyhASA1L+MSmyrUpn0ACOqteBNgcjv4TaVS0 lqDuzoTjvROg+1sOfewiXwhNlle+883JOPzLTmmZCpM9kDb+S2WZqIbffw+YDN2jY6L9 LPt6qvMhKW8Ly7gpwt0h1RDRD15BC4wl1NGid/FHkC5JWyRrK5J5MkRw+ukF6JkQr2yl N6EfiXgz5HfcLn4D8ib5CKekUKqBnCLtziNU4q4IyU2xdM6f+gf+YhTQgttlo1zSaU/B uF8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=lV3uaipPpzu/LBeQdTtAgRg9Q5Bbb8eo/GIk0X88rSc=; b=uu6fcUtFXwRDS1H/+hJdn5JUc7OA572yj/MJ/SM7mKO7mpBXZJHCWSdScZQVRyy4Ly VGdg7ip0wVuetlUcZ0ImUrw/c6hZ286osm7ricgoFuHfwm8oqsdIQw1LLMZN3X9aSBP6 gHJ2ulP1/KGfxNnXY1X49VREXsGgjchw19jWb3C0sjAFOPeh7B1gSSiUzj+ecqUFLQD8 diPqlNjFTQtQ+q5u3k6poI63SobQ1G4MwufmptvfwcNRcJxO8Zd9o/IgFFRmORGXGUJb TsPumivyX6sTobC7NfNCBVPWbEoRx2ClldojCmkeaGxaRZXDSP051Pp5NdJUOURt2nbn //2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b="DP6/4REF"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d206-20020a621dd7000000b0063b7c4435c0si20632102pfd.54.2023.05.16.13.25.07; Tue, 16 May 2023 13:25:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b="DP6/4REF"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230269AbjEPUOn (ORCPT + 99 others); Tue, 16 May 2023 16:14:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229491AbjEPUOf (ORCPT ); Tue, 16 May 2023 16:14:35 -0400 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0B917AA4; Tue, 16 May 2023 13:14:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1684268067; x=1715804067; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IJ41MGCIxf1x/RNusHwRU1NWoc/mmjmttYkLXaVv/6g=; b=DP6/4REFJZxdYHZ/3BeMq3zAfW6vijzwZKPA9Y/+4CEd/P+PEFgVVvQM Ilq+OMlX1rBwDbcLBOig5J51A1m8c8/byQ/isLXR6owpuDsYpoZHv32cK lzXe2PgM+pkZ0HVmm8iwxqUg1t0+17FaLa7un7c9pcgnkLD8ErTmbUeVV BmgadheaIWJUTfGlzD4J6Qh69p/N8WraAFfoW2WyNu+7m40ulTXQHKd8E gsxYKA3U88rIPFJlKCyKaQs1yAartUtMvj8AbG9rOSn4HaeBrC+gMXKyL 1NbIziiveEts3pqTg3sIQDu139G+CEzDhvs1uosXcUt9+FswKpC/PaSqD w==; X-IronPort-AV: E=Sophos;i="5.99,278,1677567600"; d="scan'208";a="152400229" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 16 May 2023 13:14:27 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Tue, 16 May 2023 13:14:25 -0700 Received: from soft-dev3-1.microsemi.net (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2507.21 via Frontend Transport; Tue, 16 May 2023 13:14:23 -0700 From: Horatiu Vultur To: , CC: , , , , , , , Horatiu Vultur Subject: [PATCH net-next v2 4/7] net: lan966x: Add support for offloading dscp table Date: Tue, 16 May 2023 22:14:05 +0200 Message-ID: <20230516201408.3172428-5-horatiu.vultur@microchip.com> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20230516201408.3172428-1-horatiu.vultur@microchip.com> References: <20230516201408.3172428-1-horatiu.vultur@microchip.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add support for offloading dscp app entries. The dscp values are global for all lan966x ports. Reviewed-by: Daniel Machon Signed-off-by: Horatiu Vultur --- .../ethernet/microchip/lan966x/lan966x_dcb.c | 59 +++++++++++++++++-- .../ethernet/microchip/lan966x/lan966x_main.h | 8 +++ .../ethernet/microchip/lan966x/lan966x_port.c | 26 ++++++++ 3 files changed, 89 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_dcb.c b/drivers/net/ethernet/microchip/lan966x/lan966x_dcb.c index d6210c70171e9..17cec9ec5ed25 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_dcb.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_dcb.c @@ -57,19 +57,62 @@ static void lan966x_dcb_app_update(struct net_device *dev) qos.pcp.map[i] = dcb_getapp(dev, &app_itr); } + /* Get dscp ingress mapping */ + for (int i = 0; i < ARRAY_SIZE(qos.dscp.map); i++) { + app_itr.selector = IEEE_8021QAZ_APP_SEL_DSCP; + app_itr.protocol = i; + qos.dscp.map[i] = dcb_getapp(dev, &app_itr); + } + /* Enable use of pcp for queue classification */ if (lan966x_dcb_apptrust_contains(port->chip_port, DCB_APP_SEL_PCP)) qos.pcp.enable = true; + /* Enable use of dscp for queue classification */ + if (lan966x_dcb_apptrust_contains(port->chip_port, IEEE_8021QAZ_APP_SEL_DSCP)) + qos.dscp.enable = true; + lan966x_port_qos_set(port, &qos); } +/* DSCP mapping is global for all ports, so set and delete app entries are + * replicated for each port. + */ +static int lan966x_dcb_ieee_dscp_setdel(struct net_device *dev, + struct dcb_app *app, + int (*setdel)(struct net_device *, + struct dcb_app *)) +{ + struct lan966x_port *port = netdev_priv(dev); + struct lan966x *lan966x = port->lan966x; + int err; + + for (int i = 0; i < NUM_PHYS_PORTS; i++) { + port = lan966x->ports[i]; + if (!port) + continue; + + err = setdel(port->dev, app); + if (err) + return err; + } + + return 0; +} + static int lan966x_dcb_app_validate(struct net_device *dev, const struct dcb_app *app) { int err = 0; switch (app->selector) { + /* Dscp checks */ + case IEEE_8021QAZ_APP_SEL_DSCP: + if (app->protocol >= LAN966X_PORT_QOS_DSCP_COUNT) + err = -EINVAL; + else if (app->priority >= NUM_PRIO_QUEUES) + err = -ERANGE; + break; /* Pcp checks */ case DCB_APP_SEL_PCP: if (app->protocol >= LAN966X_PORT_QOS_PCP_DEI_COUNT) @@ -93,8 +136,12 @@ static int lan966x_dcb_ieee_delapp(struct net_device *dev, struct dcb_app *app) { int err; - err = dcb_ieee_delapp(dev, app); - if (err < 0) + if (app->selector == IEEE_8021QAZ_APP_SEL_DSCP) + err = lan966x_dcb_ieee_dscp_setdel(dev, app, dcb_ieee_delapp); + else + err = dcb_ieee_delapp(dev, app); + + if (err) return err; lan966x_dcb_app_update(dev); @@ -117,10 +164,14 @@ static int lan966x_dcb_ieee_setapp(struct net_device *dev, struct dcb_app *app) if (prio) { app_itr = *app; app_itr.priority = prio; - dcb_ieee_delapp(dev, &app_itr); + lan966x_dcb_ieee_delapp(dev, &app_itr); } - err = dcb_ieee_setapp(dev, app); + if (app->selector == IEEE_8021QAZ_APP_SEL_DSCP) + err = lan966x_dcb_ieee_dscp_setdel(dev, app, dcb_ieee_setapp); + else + err = dcb_ieee_setapp(dev, app); + if (err) return err; diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.h b/drivers/net/ethernet/microchip/lan966x/lan966x_main.h index b9ca47ab6e8be..8213440e08672 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.h +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.h @@ -109,6 +109,8 @@ #define LAN966X_PORT_QOS_PCP_DEI_COUNT \ (LAN966X_PORT_QOS_PCP_COUNT + LAN966X_PORT_QOS_DEI_COUNT) +#define LAN966X_PORT_QOS_DSCP_COUNT 64 + /* MAC table entry types. * ENTRYTYPE_NORMAL is subject to aging. * ENTRYTYPE_LOCKED is not subject to aging. @@ -402,8 +404,14 @@ struct lan966x_port_qos_pcp { bool enable; }; +struct lan966x_port_qos_dscp { + u8 map[LAN966X_PORT_QOS_DSCP_COUNT]; + bool enable; +}; + struct lan966x_port_qos { struct lan966x_port_qos_pcp pcp; + struct lan966x_port_qos_dscp dscp; }; struct lan966x_port { diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_port.c b/drivers/net/ethernet/microchip/lan966x/lan966x_port.c index 0cee8127c48eb..11c552e87ee44 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_port.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_port.c @@ -418,10 +418,36 @@ static void lan966x_port_qos_pcp_set(struct lan966x_port *port, } } +static void lan966x_port_qos_dscp_set(struct lan966x_port *port, + struct lan966x_port_qos_dscp *qos) +{ + struct lan966x *lan966x = port->lan966x; + + /* Enable/disable dscp for qos classification. */ + lan_rmw(ANA_QOS_CFG_QOS_DSCP_ENA_SET(qos->enable), + ANA_QOS_CFG_QOS_DSCP_ENA, + lan966x, ANA_QOS_CFG(port->chip_port)); + + /* Map each dscp value to priority and dp */ + for (int i = 0; i < ARRAY_SIZE(qos->map); i++) + lan_rmw(ANA_DSCP_CFG_DP_DSCP_VAL_SET(0) | + ANA_DSCP_CFG_QOS_DSCP_VAL_SET(*(qos->map + i)), + ANA_DSCP_CFG_DP_DSCP_VAL | + ANA_DSCP_CFG_QOS_DSCP_VAL, + lan966x, ANA_DSCP_CFG(i)); + + /* Set per-dscp trust */ + for (int i = 0; i < ARRAY_SIZE(qos->map); i++) + lan_rmw(ANA_DSCP_CFG_DSCP_TRUST_ENA_SET(qos->enable), + ANA_DSCP_CFG_DSCP_TRUST_ENA, + lan966x, ANA_DSCP_CFG(i)); +} + void lan966x_port_qos_set(struct lan966x_port *port, struct lan966x_port_qos *qos) { lan966x_port_qos_pcp_set(port, &qos->pcp); + lan966x_port_qos_dscp_set(port, &qos->dscp); } void lan966x_port_init(struct lan966x_port *port) -- 2.38.0