lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20240608124306.nh2olzpybffitw6w@skbuf>
Date: Sat, 8 Jun 2024 15:43:06 +0300
From: Vladimir Oltean <olteanv@...il.com>
To: Xiaolei Wang <xiaolei.wang@...driver.com>
Cc: linux@...linux.org.uk, andrew@...n.ch, alexandre.torgue@...s.st.com,
	joabreu@...opsys.com, davem@...emloft.net, edumazet@...gle.com,
	kuba@...nel.org, pabeni@...hat.com, mcoquelin.stm32@...il.com,
	wojciech.drewek@...el.com, netdev@...r.kernel.org,
	linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [net v4 PATCH] net: stmmac: replace priv->speed with the
 portTransmitRate from the tc-cbs parameters

On Sat, Jun 08, 2024 at 12:45:57PM +0800, Xiaolei Wang wrote:
> The current cbs parameter depends on speed after uplinking,
> which is not needed and will report a configuration error
> if the port is not initially connected. The UAPI exposed by
> tc-cbs requires userspace to recalculate the send slope anyway,
> because the formula depends on port_transmit_rate (see man tc-cbs),
> which is not an invariant from tc's perspective. Therefore, we
> use offload->sendslope and offload->idleslope to derive the
> original port_transmit_rate from the CBS formula.
> 
> Fixes: 1f705bc61aee ("net: stmmac: Add support for CBS QDISC")
> Signed-off-by: Xiaolei Wang <xiaolei.wang@...driver.com>
> Reviewed-by: Wojciech Drewek <wojciech.drewek@...el.com>
> ---
> 
> Change log:
> 
> v1:
>     https://patchwork.kernel.org/project/linux-arm-kernel/patch/20240528092010.439089-1-xiaolei.wang@windriver.com/
> v2:
>     Update CBS parameters when speed changes after linking up
>     https://patchwork.kernel.org/project/linux-arm-kernel/patch/20240530061453.561708-1-xiaolei.wang@windriver.com/
> v3:
>     replace priv->speed with the  portTransmitRate from the tc-cbs parameters suggested by Vladimir Oltean
>     link: https://patchwork.kernel.org/project/linux-arm-kernel/patch/20240607103327.438455-1-xiaolei.wang@windriver.com/
> v4:
>     Delete speed_div variable, delete redundant port_transmit_rate_kbps = qopt->idleslope - qopt->sendslope; and update commit log
> 
>  .../net/ethernet/stmicro/stmmac/stmmac_tc.c   | 20 +++++++------------
>  1 file changed, 7 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c
> index 222540b55480..87af129a6a1d 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c
> @@ -344,10 +344,11 @@ static int tc_setup_cbs(struct stmmac_priv *priv,
>  {
>  	u32 tx_queues_count = priv->plat->tx_queues_to_use;
>  	u32 queue = qopt->queue;
> -	u32 ptr, speed_div;
> +	u32 ptr;
>  	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,20 @@ 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;

I have one more request.

It is very discouraging for a user to give invalid parameters and
receive -EOPNOTSUPP, because this is indicative of other "usual
suspects": "did I enable CONFIG_NET_SCH_CBS?"

It is unfortunate that struct tc_cbs_qopt_offload does not carry a
netlink extack, but I'm also not requesting you to add one here.
Instead, please at least change the return code to something like
-EINVAL, and print something to the console along the lines of:
"Invalid portTransmitRate %lld (idleSlope - sendSlope)\n".

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ