From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 89F3FC27C53 for ; Fri, 7 Jun 2024 13:47:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=j5CSnYXN8XK5U7+RCzWeC8efCP23PQ1wN/k8zd/Jaao=; b=hkMCtAiXA6aL9m ch6run5xt53jUQe61wLnFhsolgb+eJiOzF43nxBrwOBa4vFJEVyUGxUt/d5mAcxwfMUV9vWMiJ6EQ V1vwjzDdR6/SQkGWD/uE8FXvz3uWKThfg4wvVKW5hlBh34LYG5NOCjIE/ezIe6VXVkxNcKLLp8OsK f9I2aJemyaeN2rR4JE5mrktvbSlCGV42eLikyYG/Rzg6lnQkljnmJeLwBNLWToO2w0HFnFmmx2YAs rF1er0XSpGE+9NOjBwBAQ2jQwlx8g8xTNAHuKUt9BDX+gsAjxyExVQNi2eOW8ViHIzAULF/5Hzhnh xx/zyThaHMCObPo9cGQA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sFZwK-0000000EExi-2l72; Fri, 07 Jun 2024 13:47:32 +0000 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sFZwH-0000000EEwx-33hU for linux-arm-kernel@lists.infradead.org; Fri, 07 Jun 2024 13:47:31 +0000 Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-57c614c57e1so347912a12.3 for ; Fri, 07 Jun 2024 06:47:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717768046; x=1718372846; darn=lists.infradead.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=KmgBm9ThJPNKXmPz1Y3oHMiCl5cXiVptHJkrXtuToGI=; b=NgolgLHOI1Tb2J90TSwnAxKh72F3hJw2XfuEcrnQWIAj0mJ8WskhxyNmOlL+9Ohkue ln+QtZd7/98xbw3mzXEg6neXtKDzMD/VWxZW2KQYWE4I093SlzOPBve7h56qDns+Q7D0 3QIJ+Kh6PGuaW2TFyb4LkzIr3aa0G2oL232DP5xn72RWR7Av6tnV/wcQNbVzbjobJt9k QZsN0dG9V8Z8NTKdR+t3xaYtT35nJySgI8wWRBjDw+97oZWyeekLxOZLgjn8n0jfW/1j vl5/++fQtWQAMYiCHtTtg96sZMk7acSfDvVSkiOFjH5Tx8bXKqtKWpNfOa+Hfkiaty90 js0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717768046; x=1718372846; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=KmgBm9ThJPNKXmPz1Y3oHMiCl5cXiVptHJkrXtuToGI=; b=r8D+q3IaBBDwLMxutt5/OryZWw06C0HJa7Hq1dj8f1u5/+tiXvcMFeJGixVpWxvzUl 6YPLe3kKGrSA83kpZFiM4t7tnHRl1tm68vecJ14x4DeD6zETQOLbQmu1q4/eJYpwkDmG A+H23jeXxoERpY0B0vTwyB4GdjK/+d4t09a7JySdOLggi405YQfYXyY3wt0NEUFBld25 i6EniMwKsT+jme2CRvRG9hYxWaiWKvvYQUVXwfbAA77QmxDBVc830keOquFyjfGZsLYn mNWZPHDRhQDQ8M9kD6jJScpJu6Dofb/a3C0pAsGF8lPhMLVcPdxGY+QbmXe41p5FmpeU MXeA== X-Forwarded-Encrypted: i=1; AJvYcCXeqR7wo/D0bLmghP9tcfFk/mJsBwK1OpAEpg3P9HDC+YxOEy/lVZoVzU5wHjS4FbHPRS0FGbenuiS9yPDjMkcz3mqhgHfwiaWwypXvwdHrSTHL1Ww= X-Gm-Message-State: AOJu0YzcR5ktOYObNTuQS0dHqr2uImxBTipWyeoQI/pUz9vXTELRLLhf AwU5bAItSxCLX23kIH2OimT4dZ9zD+swN3hB2yWiS069EJP9I1Z/ X-Google-Smtp-Source: AGHT+IGxJly2Ygnl7BBvSpHo2MzTbd4GTMItTxW3Hu6qDDGLINsRJ6cxScLTVygUaG+CuvUghmikPg== X-Received: by 2002:a50:d799:0:b0:57a:2fc1:e838 with SMTP id 4fb4d7f45d1cf-57c50928dd9mr1603090a12.22.1717768045293; Fri, 07 Jun 2024 06:47:25 -0700 (PDT) Received: from skbuf ([188.25.55.166]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57aae1412a0sm2779581a12.56.2024.06.07.06.47.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 06:47:24 -0700 (PDT) Date: Fri, 7 Jun 2024 16:47:21 +0300 From: Vladimir Oltean To: Xiaolei Wang 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 Message-ID: <20240607134721.qxwyp63p5dlxw7ui@skbuf> References: <20240607103327.438455-1-xiaolei.wang@windriver.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240607103327.438455-1-xiaolei.wang@windriver.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240607_064729_952381_F6DDFF24 X-CRM114-Status: GOOD ( 23.27 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 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