Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1205095rbb; Mon, 26 Feb 2024 02:00:41 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVy5EuchB9bOjEB36yToVAxIgxDx2tPhLcU2Rax61fzr+3oAM8T0dRIkSX50kyujCxFw7MgcIjs4/8DSSGes7I8LCFenZY33bntiHdG+w== X-Google-Smtp-Source: AGHT+IEyRgIxawDbh/9OPthJf+mrUUEhGw3G1gWHomkaAq3j2VVXZRYgy43EruvT7Gau9cfzxwEe X-Received: by 2002:a17:906:5044:b0:a43:5c1c:70f4 with SMTP id e4-20020a170906504400b00a435c1c70f4mr1263016ejk.38.1708941641156; Mon, 26 Feb 2024 02:00:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708941641; cv=pass; d=google.com; s=arc-20160816; b=PLvoReMugvClQ722FkJEpFSRseGgw1UHiOi6eRemH5c1cFoNPWZHeFKdHB6LEXng0+ yD4UPyXfXlqEQFaukH0SffvDpzrSO3WlGQHQcYLZDGEMwwg2g2p3jH0TGdzgooktnNIx 0nnvb/I/N01W0m6ZTZtXZutc9xdMt4AQpy7ItfOUL5GF7KYYPYnPd0b8GdynASUy22VP HYiRxa6A/q4V6QPb/nWQFPUaaMhwwyRxw8M9xV7z4t9tPEq5ZTNsdD66bL2xnBUnNNo2 PYZCR6myK+8uKMkn6ekXFFrkn4Ot/L0mV72xNDMjpKBbCKdbE3POiMrl5h8BvO6y6zIK Ilhg== 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=yLtF7BizwZvfZN5GuZUignuLCSNDd+sax5JxYiM+LhA=; fh=LK+ZEdA6UrLYKi2XkEW75YxIlkFDCDgHfGjIC21b4xY=; b=JHT4kXpqlYmwJC5xYszcoy7GfWo8Bels0dHBLCdpSTGWSnuFS2c1k8XxJApNP6teHI MQ1aupEPbJNEYicwadkJQEU3Pxjpgnr1aipKNUFI6LmEaGhGByCUvoKY45KoceJICGzt 2U5xuAkjWbTvvPNU779spidRRo6ApagipbmSvtIk8JINxDSZ5tMWQ0MjEWp3E3w4lM4c DoI3FzUqWy3SxMo8XikHNWe3RAh/L1F1quD8OTbasXO8DgLUa2i0JUjW0T8UKM45pc8Q suCZyXtp9Ab2HByULE1uuL22LSYnGRcb4wy2qsqYLiseexq6HIAj6MBfq2L6gxKZbo26 soYQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=U661mhYt; 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-81061-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81061-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 h25-20020a1709066d9900b00a3e1067746csi1910481ejt.177.2024.02.26.02.00.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 02:00:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81061-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=U661mhYt; 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-81061-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81061-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 BB0221F26740 for ; Mon, 26 Feb 2024 10:00:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BC6545A116; Mon, 26 Feb 2024 09:34:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="U661mhYt" 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 EC3D658AA6; Mon, 26 Feb 2024 09:34:09 +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=1708940051; cv=none; b=GSEu4V0rFWRpRCY6VoXIhIR9cM5x7WMQ3ARQNYX0plagjpRkLHpFA48ZOsCEbOKNGgYM0z5pI7PO6eOFtw2fI4kVaH9SjFcg6rLlyYMeaSgvlMzwmsGTf04MRGFVGSTCuNqj6X5s6NWua/ioetFPhiACixDzVYImKl4i66E9nl4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708940051; c=relaxed/simple; bh=B5XmgnTQfmniREvPObTq626oj49TOQPaFFKPyJV8MWE=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=oMy1Etxwxi8W4DHEJAU9cTGFIuBrt5NjSA3JJCfds6TQ6oVxLjw+6yngxwN1bdOGZhRjePG/0gZIE5I2jMmKoR42YOrROzofyRE2WdYMpJG/oNBg3MuhvEd4uTEfTbDweV59QzWW9hAuW4OgJfAh6XN8Tp7ALEy2FhpEN4S+wuc= 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=U661mhYt; 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-33d90dfe73cso1891569f8f.0; Mon, 26 Feb 2024 01:34:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708940048; x=1709544848; 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=yLtF7BizwZvfZN5GuZUignuLCSNDd+sax5JxYiM+LhA=; b=U661mhYt+yxbagFzdkYhPwkALZo7ch3nZaO3fiYpVkrDq5hRg6A0pCKK09PlzXstqs iHMFzz3RNrj8jWFvw/o91mP7+pQGIraH3dGxUrJxs92D4Ko8l+N8WcmcipWAAAfyBjWU ULF+uBBDtFqrIJgv1cpNL2tHQCdCzEprBFrLujju5I2+x0c+g9Ba++cQ5tGlJQbrfE5Y 116EYtLuCWA/kKg522xXt40OGbCKi/n2h1Kw3Yw5FP0sTgtob6hWpoXO81i/T2+ie/dK L2ZT4hC4U1v113QfetHCMXlmSR6jqKHItkf+d89acnpkDOoiv9N8F5h6K3XY3Lag6G1q x+ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708940048; x=1709544848; 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=yLtF7BizwZvfZN5GuZUignuLCSNDd+sax5JxYiM+LhA=; b=MWkuyShDuU/1Pym/vaMFtZN2hQ3o0VyjTosqnef5Kv1jS5f7sjKJzJ1N11+dB2KxwY X7BcuBBeFkND2UAZZMXE2CiLnDeoDuGY2AeGHjtZk0AJzdsohdngzVvXKXGFzo4+LB53 Qn0kbCqLAZGjtG1LhDfe9aYW36R5FeCk2dpJrQ+rLr9Iy6oqRgX/TujFLJAWVZJ6mXXV 8fbkCDu0K6dC3+Vhg7QECHdJbdHslCJie6Uinv1q/UKpZoxqfglG6kc2q+Fe2DdPxRdq AzbAH4a+suQ5E4N18WxkRmUR1wGuW+JpGvfrRiTqScIfmEli0GKuJLF3+oMSHo3Chqy/ IvVA== X-Forwarded-Encrypted: i=1; AJvYcCWStX0ILebTPF2klBWwFD/C2oYbPdyIcBf9yj3wpLMGh5DDQyy1dCJdQ5jn4rmmzcJ++GOgq0dXwUuQzbI2NNGhhpLOALpnSumL9GNfTD8spq0FlrsRRFfSN2pbPC9PKUorT/aC X-Gm-Message-State: AOJu0Yw0UHvCiCPOFuN8O5LjWTBROx2VZYaMyaa8vms08287KAr1jK+Q FVw15+KLDyIzhFa1S37pQGq1msLlUGAwXCj7LRiL9ZncrKv59ah3 X-Received: by 2002:a05:6000:1752:b0:33d:3cd3:5ffd with SMTP id m18-20020a056000175200b0033d3cd35ffdmr5624541wrf.22.1708940047938; Mon, 26 Feb 2024 01:34:07 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:a92:c660:e2e4:db7a:f447:614]) by smtp.gmail.com with ESMTPSA id bj20-20020a0560001e1400b0033db0c866f7sm7749527wrb.11.2024.02.26.01.34.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 01:34:07 -0800 (PST) From: Piotr Wejman To: Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , 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 v2] net: stmmac: fix rx queue priority assignment Date: Mon, 26 Feb 2024 10:31:44 +0100 Message-Id: <20240226093144.31965-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. Currently rx_queue_priority() function is adding priorities for a queue without clearing them from others. 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[...]" After this patch, rx_queue_priority() function will: - assign desired priorities to a queue - remove those priorities from all other queues The write sequence of CTRL2 and CTRL3 registers is done in the way to ensure this order. 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 .../net/ethernet/stmicro/stmmac/dwmac4_core.c | 42 +++++++++++++++---- .../ethernet/stmicro/stmmac/dwxgmac2_core.c | 40 ++++++++++++++---- 2 files changed, 66 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..76ec0c1da250 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c @@ -92,19 +92,43 @@ 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); + + /* 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)); - value = readl(ioaddr + base_register); + ctrl2 &= ~clear_mask; + ctrl3 &= ~clear_mask; - value &= ~GMAC_RXQCTRL_PSRQX_MASK(queue); - value |= (prio << GMAC_RXQCTRL_PSRQX_SHIFT(queue)) & + /* Assign new priorities to a queue and + * clear them from others queues. + * The CTRL2 and CTRL3 registers write sequence is done + * in the way to ensure this order. + */ + if (queue < 4) { + ctrl2 |= (prio << GMAC_RXQCTRL_PSRQX_SHIFT(queue)) & GMAC_RXQCTRL_PSRQX_MASK(queue); - writel(value, ioaddr + base_register); + + 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(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..7ad73e1d353e 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c @@ -105,17 +105,43 @@ 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; + + /* Assign new priorities to a queue and + * clear them from others queues. + * The CTRL2 and CTRL3 registers write sequence is done + * in the way to ensure this order. + */ + 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