Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp1643617lqz; Mon, 1 Apr 2024 12:25:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUbgwFj4MSVePsKUDfi64picuP1LupqOITH+vrFuTbPE/3mndzmcr11rYwkGrsGtlASEkuR6rZukeWHeo6l3tM0Vc+nTbAb/StRFd92Ow== X-Google-Smtp-Source: AGHT+IG4Of9pxYlp6cNeEY2EGLkLP2FzU9iLei2z4gcGV7IdSZWJgk6swIv9E/DoF+X68qGV9+MD X-Received: by 2002:a05:6402:13cb:b0:56d:c70e:d7e0 with SMTP id a11-20020a05640213cb00b0056dc70ed7e0mr6388769edx.19.1711999536897; Mon, 01 Apr 2024 12:25:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711999536; cv=pass; d=google.com; s=arc-20160816; b=ZPQ+Ud+Wv9oDWrxclUFu4MNVMyuexEgSTMki+mFk1o89Nb0HYAalM5TMLJF0gIVOYA lalSmBOiwFiw8QxuPr09Z8fVK2yiqr5bZE7UMqs9MRfR67CcD7nZSg6YiToBhJ8sTTZ+ QaErKIaKicG/ofA/7ukGee3EzLhrs54/IpHRAnOgguOTIhEsE+HKvLP5Q49MAJvHDCnp 763pOOwCR3J12Dvcp+D/0yb3YztC5J1jbstA9mgLL3XQYwWS4/ap1mlpW5xA/yN/Pwhh srkkC09ojSa5Ei6yw80hLTWPFZiLsMK+PeEn7qjWjPCx2qnZXTT169mnS/N5NtWfgWPj cmKw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=lbATZVSwtVFCc38UdteT0WxrSxfowo8TkRKmuWEvy1c=; fh=SqWmfGOsU0g9odGHNsGO9SV5joS27UzIZutVXcV3ewg=; b=EhW9VJg8M2GHJQa8wDYdm+86awB5+raSRok5LKdyHCn5H7oHz9v0TrfJlMlkWwDXPL VDDEaOksn9SADT2GCC9MQWmZA2FzpH6829s/r3JBvr4EmIcW85G8e8DSnQNhS3Djjwh0 heXI7X1U5eWq1PL/LSLcixgqzeYePBO8uM2tPTJmErXqUGFJOrBgvgUfF+gTxEzCbDXP ppNrLkOBYdW8xq2IpgtdGCl1bFejBxyqBBKVYRyhkxnQGgClmVpvm8itTQzX0Wm8ErUV dRypTlROKamWO8x3FF2FpHpqE7LlECbP+/dIC+/RjCSUnHEhptaPf6iOdWLFeEI4JQ0J mpzw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=CGnFGP4j; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-126987-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-126987-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 19-20020a508753000000b0056c0cc477ecsi4660678edv.146.2024.04.01.12.25.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Apr 2024 12:25:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-126987-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=CGnFGP4j; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-126987-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-126987-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 4C3E61F21E94 for ; Mon, 1 Apr 2024 19:25:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F004B5337E; Mon, 1 Apr 2024 19:25:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CGnFGP4j" Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4596C47A76; Mon, 1 Apr 2024 19:25:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711999524; cv=none; b=sO54G1wPXJIJPdv6yK+OFupa5Vhq+rMpQx2uo0YdBi1AWOEVhImI+L7gDKPdJpwr9vTaybguvxlSrVjWdrCPw0NMpD2kKTStf2VwfDjEOejClv97ACfaoXyGj+i3sHyaLx2+sA8JFZjK8ccUM63RHfP34RBNENyiEiytclhUS5I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711999524; c=relaxed/simple; bh=o6eDuCSXAK7lFo/qKkEQQj36soVQbPoLui5kgXGipeQ=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=B5Tvv81fP0C0QoUr9ewB/oXb2Y35mNX2xNblRqvLRiCaz8SHmGOryHKoVU0/1wy9O2yatNh4kunQCHXz0sOeT/VfwVMe2Ud8CnofFHvCrbB0/rv0ZKrCKmfw6j7O2VTZnyZi7SVF+rn5gaZXfPvgZFyC59RKnahoJuvrEE+6Uo4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=CGnFGP4j; arc=none smtp.client-ip=209.85.221.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-33ed4dd8659so3251414f8f.0; Mon, 01 Apr 2024 12:25:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711999521; x=1712604321; darn=vger.kernel.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=CGnFGP4jDlOuHf26HFmLsbqRcSrb82Wocpj7qmXN7xZZ6SpHu0Bg0rVBlDDqK8p7gU Vke8vfsQlNNoMQ0Jn4eSDkkOktjS3HUMevizgH9lHeJFG2PZoShKpha8zl3SfMpogowD m1gPDRtpDAGImKiuXllUYULHwwTtw53C3BaZ6njOokkns2EpkjEdKyzxeD2J78G/eCJq NECmbLeOzQl8whf5O2XD3lvNHXmjhjAUOPwllbCjwuX65x1WdefqIcf0+Cs2n4uLQyA7 +U7Oe1mkkDKsGAxG3omzwP2tClH0VeNOTOtrcVSlAzgAZURGhdccRahXgyEv3ZfzfsIZ F6hA== 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=o7hU+3wbXA9m/UA0QsQTOEdCSOZswaite3yBu6PTZRHKHXJCY2w+DLPBihcMpxToRF OBflGN/yRQaYvTE2v6osMpvPAsSAQaMuXlhVzPy20T6aiGGNOLUV9+fP2Ao4sTrMKHAC DT2lFCYcSE6H1BkXr3u+8GVcTOydrvl3F1UK5dCz7XNTpW4dEZTlI0n1FHfRXn4GFBNU f9MedaH2r39xQZ3sWHcJ6yd1uepWrKFN38GnQPsOMSbah0MWCci2sTFa6XpAyRHbL5aE 76YhADyCmnLSfaiCUTyOZQtT/mWHDYfgIxQBtLzmSbb0eDWmWUqSViO4W8Cq9LME/VaT 9J+g== X-Forwarded-Encrypted: i=1; AJvYcCUhhGgVuglJWjKliQL6/dImvOLggUfwBQuVFcwugyL9ud3qzO1ZlzuO8IDI8tLjbih+/6Dub9U8LM5Ra7tVyZJtHlPFC87N4wREcrKRzYkki4F0TFrXFksh5ktsIC2JgBH2KOMg X-Gm-Message-State: AOJu0YxMk9fVMX8j75VDlCT9V8zl9DZdeS5PnAZZ1Wqu6qLlzjxIHY0A F1xMZ0LAVf/qOSxhFxGAjqgMzfRoMoDK9ZeVO0EySeAkbc23dpUf 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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, -- 2.25.1