From patchwork Mon Apr 1 19:22:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Piotr Wejman X-Patchwork-Id: 13612979 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 E965ACD1288 for ; Mon, 1 Apr 2024 19:25:55 +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=msi3RA8t+WFMp5C0ZBGMArKYaJWPsvtlnLw7RkcJzww=; b=mYfh7/H5dWleku p6MRUnisDGHyLaWSarV6WKvK3a6JVCkt0uRffrwkL1tuHqo9vPqEwX3wUgZCa0VkN47ysQV7DEUWR MoRvdK2C3NNbNRKE6ScmAFjjYHmPXDdUVD8Qf1/6JQFXzR3g/kXcHnHyv+A3EAQkr2gfrcAnOlHJA aCpnOsjwsJS3AIffa8CjYy6cBgxi2nMdaS2ppXs87PPAnYhOTnte4ckAI0NbZ2k5dGBbqWluj+QH8 iOJMgzplN4bess4JVwtOR/ZHdqwWge+w6oEMMHqkopjftm/C5Fk9raKneBmnYf3wXueoWM1+pdpIO eJg8MmoqWPhNMup6LIVA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rrNHj-00000008fk7-1fG1; Mon, 01 Apr 2024 19:25:35 +0000 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rrNHd-00000008fj1-361r for linux-arm-kernel@lists.infradead.org; Mon, 01 Apr 2024 19:25:31 +0000 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-33ddd1624beso2699633f8f.1 for ; Mon, 01 Apr 2024 12:25:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711999521; x=1712604321; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=lbATZVSwtVFCc38UdteT0WxrSxfowo8TkRKmuWEvy1c=; b=RD0ELG3gl65zhPkzo65hN4I4lUB+9/I09qGYWmdeTD2aq8UiSZlP+DknvJdAZmybte a8pO6UKIHjjbiyc6ozPjyKWt6Feksp+oLhJfrKqzB3G1Zf0EaSZZs0LRkd60oAo6Epy6 hldt8sC7ZszwPBBpqKOgmnNl6ht7yLPpCdQBwCvVukcRkd+HH9rhveWrjJgK2wUh4DIw 6AgFczdPhoD/VPwBjIBfyBU+rYRu7xYqLMlv3YGKtPJU8z0Q632jxkKLx7yrAX8tf7R+ T2+NDqBm69C5cTUCEkeSiKylxdcGDMTvfznQSj+hs/E5f4bs1Ds9Xxtel+zOIV3yB//c 3w0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711999521; x=1712604321; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=lbATZVSwtVFCc38UdteT0WxrSxfowo8TkRKmuWEvy1c=; b=hDrmLSVnPji8NBU92PSme6sA7dxfg1dsajUPtN8Ch4fYyWqAv5GJp9/XZfLUW21HTc /EnB1XG+oDjLZVPxQLPxvZGvnMkWz6D+jRzztJ1Cq1govJ8+jTW6X+kSuHk2vXiUjfx3 HQ45elM9OOU8zwpi0Bw8/xYeSOs864yoIOg7vGYeMUrOTAVgiFhqzTM3U0sYpoBxXlTo huE0qHIwwxezh8Z/fsewC1IQwzQ7/uEiEazUUrEA3vcjdRIyuOzawpEgJNRhekKNRsbe FeBlu4tjDDL4tdU6h7EZMAEyLfL3X2/AIiVTWswvlSZWvjycJ31TkBLUsHcb5CceTqgX KzFQ== X-Forwarded-Encrypted: i=1; AJvYcCXDaQTGB0P5Ll2EOyXdMFPq5qYZAIPVHfDztd8TGnrxU/ARd+u8FWnadohjS81FGBJkKDjAIrhFh8ByPSmxcIFhhbwMDs+yfsFEF6PYKH3BVKM0z8E= X-Gm-Message-State: AOJu0Yz/zcFJzKDIp0vfOC9gcuWHO8TsnZTbleL0xNOpViEA9KX90fSS CinuCmIcphIBEQSJ6qFAoZVoG73F44c3ktCjociYY4y9TcRXHgAT X-Google-Smtp-Source: AGHT+IFKo0GgVDkY7Zy7nJekIuEkhWVnxNxEK6NrznEjLdMqIaCn/ECvU1iVX2nGEqSYcSNB4vTQvA== X-Received: by 2002:a5d:47c4:0:b0:343:44cd:7d1e with SMTP id o4-20020a5d47c4000000b0034344cd7d1emr5650181wrc.17.1711999520491; Mon, 01 Apr 2024 12:25:20 -0700 (PDT) Received: from localhost.localdomain ([2a01:e0a:a92:c660:38e3:78b9:48eb:4246]) by smtp.gmail.com with ESMTPSA id n2-20020a056000170200b0034335e47102sm10319848wrc.113.2024.04.01.12.25.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Apr 2024 12:25:19 -0700 (PDT) From: Piotr Wejman To: Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Joao Pinto , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Piotr Wejman Subject: [PATCH v4] net: stmmac: fix rx queue priority assignment Date: Mon, 1 Apr 2024 21:22:39 +0200 Message-Id: <20240401192239.33942-1-piotrwejman90@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240401_122530_020809_0C6F0164 X-CRM114-Status: GOOD ( 17.23 ) 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 The driver should ensure that same priority is not mapped to multiple rx queues. From DesignWare Cores Ethernet Quality-of-Service Databook, section 17.1.29 MAC_RxQ_Ctrl2: "[...]The software must ensure that the content of this field is mutually exclusive to the PSRQ fields for other queues, that is, the same priority is not mapped to multiple Rx queues[...]" Previously rx_queue_priority() function was: - clearing all priorities from a queue - adding new priorities to that queue After this patch it will: - first assign new priorities to a queue - then remove those priorities from all other queues - keep other priorities previously assigned to that queue Fixes: a8f5102af2a7 ("net: stmmac: TX and RX queue priority configuration") Fixes: 2142754f8b9c ("net: stmmac: Add MAC related callbacks for XGMAC2") Signed-off-by: Piotr Wejman --- Changes in v2: - Add some comments - Apply same changes to dwxgmac2_rx_queue_prio() - Revert "Rename prio argument to prio_mask" - Link to v1: https://lore.kernel.org/netdev/20240219102405.32015-1-piotrwejman90@gmail.com/T/#u Changes in v3: - Fix trailing whitespace - Link to v2: https://lore.kernel.org/netdev/20240226093144.31965-1-piotrwejman90@gmail.com/ Changes in v4: - amend comment and commit message - Link to v3: https://lore.kernel.org/netdev/20240303190339.52496-1-piotrwejman90@gmail.com/ .../net/ethernet/stmicro/stmmac/dwmac4_core.c | 40 ++++++++++++++----- .../ethernet/stmicro/stmmac/dwxgmac2_core.c | 38 ++++++++++++++---- 2 files changed, 62 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c index 6b6d0de09619..eb2d0976d010 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c @@ -92,19 +92,41 @@ static void dwmac4_rx_queue_priority(struct mac_device_info *hw, u32 prio, u32 queue) { void __iomem *ioaddr = hw->pcsr; - u32 base_register; - u32 value; + u32 clear_mask = 0; + u32 ctrl2, ctrl3; + int i; - base_register = (queue < 4) ? GMAC_RXQ_CTRL2 : GMAC_RXQ_CTRL3; - if (queue >= 4) - queue -= 4; + ctrl2 = readl(ioaddr + GMAC_RXQ_CTRL2); + ctrl3 = readl(ioaddr + GMAC_RXQ_CTRL3); - value = readl(ioaddr + base_register); + /* The software must ensure that the same priority + * is not mapped to multiple Rx queues + */ + for (i = 0; i < 4; i++) + clear_mask |= ((prio << GMAC_RXQCTRL_PSRQX_SHIFT(i)) & + GMAC_RXQCTRL_PSRQX_MASK(i)); + + ctrl2 &= ~clear_mask; + ctrl3 &= ~clear_mask; + + /* First assign new priorities to a queue, then + * clear them from others queues + */ + if (queue < 4) { + ctrl2 |= (prio << GMAC_RXQCTRL_PSRQX_SHIFT(queue)) & + GMAC_RXQCTRL_PSRQX_MASK(queue); - value &= ~GMAC_RXQCTRL_PSRQX_MASK(queue); - value |= (prio << GMAC_RXQCTRL_PSRQX_SHIFT(queue)) & + writel(ctrl2, ioaddr + GMAC_RXQ_CTRL2); + writel(ctrl3, ioaddr + GMAC_RXQ_CTRL3); + } else { + queue -= 4; + + ctrl3 |= (prio << GMAC_RXQCTRL_PSRQX_SHIFT(queue)) & GMAC_RXQCTRL_PSRQX_MASK(queue); - writel(value, ioaddr + base_register); + + writel(ctrl3, ioaddr + GMAC_RXQ_CTRL3); + writel(ctrl2, ioaddr + GMAC_RXQ_CTRL2); + } } static void dwmac4_tx_queue_priority(struct mac_device_info *hw, diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c index 1af2f89a0504..2bc05173884e 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c @@ -105,17 +105,41 @@ static void dwxgmac2_rx_queue_prio(struct mac_device_info *hw, u32 prio, u32 queue) { void __iomem *ioaddr = hw->pcsr; - u32 value, reg; + u32 clear_mask = 0; + u32 ctrl2, ctrl3; + int i; - reg = (queue < 4) ? XGMAC_RXQ_CTRL2 : XGMAC_RXQ_CTRL3; - if (queue >= 4) + ctrl2 = readl(ioaddr + XGMAC_RXQ_CTRL2); + ctrl3 = readl(ioaddr + XGMAC_RXQ_CTRL3); + + /* The software must ensure that the same priority + * is not mapped to multiple Rx queues + */ + for (i = 0; i < 4; i++) + clear_mask |= ((prio << XGMAC_PSRQ_SHIFT(i)) & + XGMAC_PSRQ(i)); + + ctrl2 &= ~clear_mask; + ctrl3 &= ~clear_mask; + + /* First assign new priorities to a queue, then + * clear them from others queues + */ + if (queue < 4) { + ctrl2 |= (prio << XGMAC_PSRQ_SHIFT(queue)) & + XGMAC_PSRQ(queue); + + writel(ctrl2, ioaddr + XGMAC_RXQ_CTRL2); + writel(ctrl3, ioaddr + XGMAC_RXQ_CTRL3); + } else { queue -= 4; - value = readl(ioaddr + reg); - value &= ~XGMAC_PSRQ(queue); - value |= (prio << XGMAC_PSRQ_SHIFT(queue)) & XGMAC_PSRQ(queue); + ctrl3 |= (prio << XGMAC_PSRQ_SHIFT(queue)) & + XGMAC_PSRQ(queue); - writel(value, ioaddr + reg); + writel(ctrl3, ioaddr + XGMAC_RXQ_CTRL3); + writel(ctrl2, ioaddr + XGMAC_RXQ_CTRL2); + } } static void dwxgmac2_tx_queue_prio(struct mac_device_info *hw, u32 prio,