Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Oltean <olteanv@gmail.com>
To: Xiaolei Wang <xiaolei.wang@windriver.com>
Cc: linux@armlinux.org.uk, andrew@lunn.ch,
	alexandre.torgue@foss.st.com, joabreu@synopsys.com,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, mcoquelin.stm32@gmail.com,
	netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [net PATCH] net: stmmac: replace priv->speed with the portTransmitRate from the tc-cbs parameters
Date: Fri, 7 Jun 2024 16:47:21 +0300	[thread overview]
Message-ID: <20240607134721.qxwyp63p5dlxw7ui@skbuf> (raw)
In-Reply-To: <20240607103327.438455-1-xiaolei.wang@windriver.com>

On Fri, Jun 07, 2024 at 06:33:27PM +0800, Xiaolei Wang wrote:
> Since the given offload->sendslope only applies to the
> current link speed, and userspace may reprogram it when
> the link speed changes, don't even bother tracking the
> port's link speed, and deduce the port transmit rate
> from idleslope - sentslope instead.
> 
> Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>

Patches to the "net" tree usually need a Fixes: tag pointing to the
first commit introducing an issue. They also need an explanation of the
problem being addressed and how it can negatively affect an user.

Still on the process topic, please increment the patch version from the
previous submissions, and post a change log under the "---" sign below,
as well as links on patchwork or lore to previous versions.

> ---
>  drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c
> index 222540b55480..48500864017b 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c
> @@ -348,6 +348,7 @@ static int tc_setup_cbs(struct stmmac_priv *priv,
>  	u32 mode_to_use;
>  	u64 value;
>  	int ret;
> +	s64 port_transmit_rate_kbps;
>  
>  	/* Queue 0 is not AVB capable */
>  	if (queue <= 0 || queue >= tx_queues_count)
> @@ -355,27 +356,24 @@ static int tc_setup_cbs(struct stmmac_priv *priv,
>  	if (!priv->dma_cap.av)
>  		return -EOPNOTSUPP;
>  
> +	port_transmit_rate_kbps = qopt->idleslope - qopt->sendslope;
> +
>  	/* Port Transmit Rate and Speed Divider */
> -	switch (priv->speed) {
> +	switch (div_s64(port_transmit_rate_kbps, 1000)) {
>  	case SPEED_10000:
>  		ptr = 32;
> -		speed_div = 10000000;
>  		break;
>  	case SPEED_5000:
>  		ptr = 32;
> -		speed_div = 5000000;
>  		break;
>  	case SPEED_2500:
>  		ptr = 8;
> -		speed_div = 2500000;
>  		break;
>  	case SPEED_1000:
>  		ptr = 8;
> -		speed_div = 1000000;
>  		break;
>  	case SPEED_100:
>  		ptr = 4;
> -		speed_div = 100000;
>  		break;
>  	default:
>  		return -EOPNOTSUPP;

This can be further compressed after the elimination of speed_div:

	switch (div_s64(port_transmit_rate_kbps, 1000)) {
	case SPEED_10000:
	case SPEED_5000:
		ptr = 32;
	case SPEED_2500:
	case SPEED_1000:
		ptr = 8;
		break;
	case SPEED_100:
		ptr = 4;
		break;
	default:
		return -EOPNOTSUPP;
	}

> @@ -397,11 +395,13 @@ static int tc_setup_cbs(struct stmmac_priv *priv,
>  		priv->plat->tx_queues_cfg[queue].mode_to_use = MTL_QUEUE_DCB;
>  	}
>  
> +	port_transmit_rate_kbps = qopt->idleslope - qopt->sendslope;
> +

You don't need to calculate it twice in the same function.

>  	/* Final adjustments for HW */
> -	value = div_s64(qopt->idleslope * 1024ll * ptr, speed_div);
> +	value = div_s64(qopt->idleslope * 1024ll * ptr, port_transmit_rate_kbps);
>  	priv->plat->tx_queues_cfg[queue].idle_slope = value & GENMASK(31, 0);
>  
> -	value = div_s64(-qopt->sendslope * 1024ll * ptr, speed_div);
> +	value = div_s64(-qopt->sendslope * 1024ll * ptr, port_transmit_rate_kbps);
>  	priv->plat->tx_queues_cfg[queue].send_slope = value & GENMASK(31, 0);
>  
>  	value = qopt->hicredit * 1024ll * 8;
> -- 
> 2.25.1
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2024-06-07 13:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-07 10:33 [net PATCH] net: stmmac: replace priv->speed with the portTransmitRate from the tc-cbs parameters Xiaolei Wang
2024-06-07 10:51 ` Wojciech Drewek
2024-06-07 13:47 ` Vladimir Oltean [this message]
2024-06-07 14:52 ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240607134721.qxwyp63p5dlxw7ui@skbuf \
    --to=olteanv@gmail.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=joabreu@synopsys.com \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=xiaolei.wang@windriver.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox