Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2172106rbb; Tue, 27 Feb 2024 13:02:39 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXsel5zn8tvOne/ATS0mzU31DhCiFvcG4wotSM1srgJ12kgvUGso/5OZnCX7R9DdlFuYVJ6SnL5nQ5iQ++kzUjhEGNigLesQyHizSKqKw== X-Google-Smtp-Source: AGHT+IFeTZKCK+w6p+Rb2pIGaSyL9GbZHBNiyPjWssDfsB3OTjDH4P3etkr+ONlqGMVvHnlQ3TTc X-Received: by 2002:a2e:a9a5:0:b0:2d2:3b6b:2d11 with SMTP id x37-20020a2ea9a5000000b002d23b6b2d11mr8352093ljq.8.1709067759138; Tue, 27 Feb 2024 13:02:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709067759; cv=pass; d=google.com; s=arc-20160816; b=XX3HbY4E3n5z7lH+ByLLR1osoJ1jG2LcWKbyySp0Y2zms763O5qLwzrOcCzzV9SGdz nOQQaUTRccayHLPqGC8UOcUn4h1953f8YSRc71Y/kxJ/cfKwe1Ru8OdUq4DbGhgKbD5X oisZUIPtApQC4rqHiPfisagzpcoJPeVDo8IrKA1PRvbwxEhkzpqZ3WcDorVPHtuRDBSN BWxwwXRRzNc/zBoE5yI34FXDZIvHr4cvguNw7lx072AgsVBGCol15PeYu/MaO6IL+a7i tDlNmk4O5t9laubScETdEZ+sjt82FplCK6LfBiK5rA2HPcXZqE5FY1TVRHzkbcuPb6Hc SPnA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=TCvOzH3AgQHUF89o253QmqxH7/ZY+b6gaeKdj4UuoVM=; fh=QogVtoCkf678NDn98dgF/QnJc5eNxLaC5Jz0lrvyGhg=; b=WQkf9w/TC+rDAXU27qLU3x7GLQrcfI8tTX0rbC43WMWZaOWUVoVx1Joe7aV2nxWhh8 Y/tRKiiJnBpV68JrtiFg0Bwn4LONR2U2WHrNZqj2p08Ng4ufTlFeyG+E05qDYMA/BbIg Kjj4usOKV/bY2sNtruas7jGPsmHLTfVI24Dq/ulxBwbe9lZxkQ8ZBB5ApIx2DgK1Vc1X dANP0D7AY9LTZVq9YuXd8+XsTOv55e9ykY75ZWmHzFwQzYLndqYJxoVTU+jch9oBZB9h 4KWEm7XtHLhjGsL7Z6DVUOitqc3Pl9nzFq+ql6xArr+SE2a+gcD37Ge1c/lnaYrZOOZH xLqg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=u+JynnRf; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-84012-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84012-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id v2-20020aa7d802000000b00565e0c707fasi977129edq.339.2024.02.27.13.02.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 13:02:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-84012-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=@kernel.org header.s=k20201202 header.b=u+JynnRf; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-84012-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84012-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 AC7761F2123B for ; Tue, 27 Feb 2024 21:02:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6D15614F9FB; Tue, 27 Feb 2024 21:01:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="u+JynnRf" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8084C14F991; Tue, 27 Feb 2024 21:01:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709067705; cv=none; b=VjJC0Mr3RzA8XZsoX/2H+Dll2kB521ewsZn494RpNC//ztb04oQHGwBjtE5VnC6RaOWb0zrlYvYEsVbLtKHg2KTrc+l+OK/GKjvBp8dyd58FVNMd3nTtZjvSNagzLhPUouY2P9BX03lGayE6Cx3PvzyFMRSm3u15IRQHyYfzBtw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709067705; c=relaxed/simple; bh=9RZq2R9Frymd/w3S8HzXoEU6qYzChWirDv0zqoRbLTk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=m/vewCHhg2aWpa/t8AhPxQCayPqMMzXIHQ4yHowm/QkUCWu80M8/atUdC+iTN78NLkVpwlSepOWU1GM3Qt5LEmoYO/om8ZTWYaHpCMmKYgCnHAIdrIgZnF6EgDdijDvTLcyG//hwrDvjaLAj+pI5ioz5WQV0XFigykywfap2ejo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=u+JynnRf; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86FD3C433C7; Tue, 27 Feb 2024 21:01:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709067705; bh=9RZq2R9Frymd/w3S8HzXoEU6qYzChWirDv0zqoRbLTk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=u+JynnRfHU57qm/IfI2DmAMzW+Z+HURn/wRIswI2yK8NtC0raFRdTiOy4qlbPax3w JiI6oLi82m4D1BQ7uuvvvouZa77iboiNlYx7dHAA7iAu6uBn9DQlZtepRQTo6mIIuw 3bu9ckYS/wr4aBGPpBKZGyzLUGRFuIuOl/Fa5JeE6Q+uILukCpgGZxZAIZRpGTSfVP wsGp6WhCOBdTRian9eSDB5y1gxI+ChqHkbQhsarVwzUWmWm1X+laByAiGFtC+Fo+2r 76GHln3XjVUrCOOJDjj8orK0KjQAK8Uzm4VHZp38d3cFG9irPXxNSBbQe50E2DPb5O zGFPMDzAym6lw== Date: Tue, 27 Feb 2024 21:01:40 +0000 From: Simon Horman To: Piotr Wejman Cc: 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 Subject: Re: [PATCH v2] net: stmmac: fix rx queue priority assignment Message-ID: <20240227210140.GP277116@kernel.org> References: <20240226093144.31965-1-piotrwejman90@gmail.com> <20240227170012.GC277116@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240227170012.GC277116@kernel.org> On Tue, Feb 27, 2024 at 05:00:12PM +0000, Simon Horman wrote: > On Mon, Feb 26, 2024 at 10:31:44AM +0100, Piotr Wejman wrote: > > 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); > > + } > > } > > Hi Piotr, > > Sorry if I am on the wrong track here, but this seems a little odd to me. > > My reading is that each byte of GMAC_RXQ_CTRL2 and GMAC_RXQ_CTRL3 > hold the priority value - an integer in the range of 0-255 - for > each of 8 queues. Thinking about this some more, and checking the code some more, I realise I am wrong here. I now see that the priority values are bit-fields not integers. So I think what you have is fine. Sorry about the noise.