Message ID | 20231027061114.3792619-1-yi.fang.gan@intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp393760vqb; Thu, 26 Oct 2023 23:16:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFeBg1jq55S2R7On3GiOVUsyda0NFj6upH1M7g9uBSzkGAJSLSTa7rNs+ltIl8ZinswfnHN X-Received: by 2002:a81:c64b:0:b0:578:5e60:dcc9 with SMTP id q11-20020a81c64b000000b005785e60dcc9mr1625460ywj.10.1698387372380; Thu, 26 Oct 2023 23:16:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698387372; cv=none; d=google.com; s=arc-20160816; b=GAnLDClK3GJ6gCdLhjWDrAYZYFmuJsUeLquGVSQxel7o0sYgi3jxV+6OTg1PnkUKae 31YX2s0vJLsmHEcaPmQwoWl6pNysMsuVkMYyut6v1GjWsN/FckRdUy4QuKvonPwGsl4o nNqCHjLdQL83aKrHPs2iCLgNr2ktkAPx5EJldScarBKGTwAnSfUsPwMp+AWFEBP8wZ4T hIRZ0882vPKSensu65qQ7E/GEY8UE3eTbrjZLRsOtTZlY65kLt66NxaKRXO5Wicy4di9 gDRu2N1EKUc8VZoResoY4Gd4p3Z2/mhcKlfZ5xNeEvWLqp7wnN6yBNvevSq0FxLg2iSN P2Gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=G9NHsVOvuWKmJst0zIsn13H9QesZAsTmgXU84eCalrU=; fh=EtSHjr0LVzFTVFr7/0EuT86GAwHEW/XgWOTDQnQ2zpQ=; b=Q6m1hjLk8KXAJratKQtz5VnTN9wo/N3sFKLyA3uxBZU8clZ30oDY1p7pVpgprW6XsB gkdItnICPDkxnMCtrrMk2MmvanHDgKetRi7chzr/2HGAG+QsnT93tbKEDaYKW+mRB37a Pc7aA3WRHOcvDPMsWNS1W1jyWtHNpwqHUZ45+bJ9Kyb00qd7waPUkvwFyZqvheWb36M7 09jUfSu3I1+KTUJA0C0lyJUo0avewMklj3Q6imaF+0/wXd8K/UC56qMbP0N6cgVBmLT9 60gM1b6eF5dNzbqFIZFUfyU16Y4tzokR7nviabISb8o07g5ladLDhRBxfF/uxH8pQLvv v+Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=cWfSHQFj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id r3-20020a818103000000b005afa2fe3f77si1509044ywf.188.2023.10.26.23.16.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 23:16:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=cWfSHQFj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 2E95C829C994; Thu, 26 Oct 2023 23:16:10 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230164AbjJ0GQA (ORCPT <rfc822;aposhian.dev@gmail.com> + 26 others); Fri, 27 Oct 2023 02:16:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229590AbjJ0GP6 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 27 Oct 2023 02:15:58 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2F4E1B1; Thu, 26 Oct 2023 23:15:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698387356; x=1729923356; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=RzxknOAHxhYQy517vTA+5JreFWE2tbMpxk8ZOQ6gyW0=; b=cWfSHQFj1f9YPlsrzzwgMWStoey8sg1NqQzcnoN6M4jUjdo6VZLStxZR BS51Z2zFqpWxs9FeOZd1Iwa5XuJt4V+txZM34UqjMwY9Xf+7DxC1gTmAU 1epKuWlkvZ96yGsNNVvzSQ7YCTQgQ9BKUc37PekkNeXXia1WRN74guJM2 m9XYNM5frPDRlbOazvm5WjRU/fxcHcbij3ZNdWLkb6ZXIWe8mMPPAafA3 wXmmP3AzFFyncRzAWAfmU50fsZapN/BVj7BkZk/yOaeeTNClv5i/NftBx /MH4V7klG9JYbajAj9qb3XbmU1GvbU00W3FYSk901TkJA3m1qcovhcbNe w==; X-IronPort-AV: E=McAfee;i="6600,9927,10875"; a="473958859" X-IronPort-AV: E=Sophos;i="6.03,255,1694761200"; d="scan'208";a="473958859" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2023 23:14:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10875"; a="735995360" X-IronPort-AV: E=Sophos;i="6.03,255,1694761200"; d="scan'208";a="735995360" Received: from ssid-ilbpg3-teeminta.png.intel.com ([10.88.227.74]) by orsmga006.jf.intel.com with ESMTP; 26 Oct 2023 23:14:21 -0700 From: Gan Yi Fang <yi.fang.gan@intel.com> To: Alexandre Torgue <alexandre.torgue@foss.st.com>, Jose Abreu <joabreu@synopsys.com>, "David S . Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Maxime Coquelin <mcoquelin.stm32@gmail.com>, netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Looi Hong Aun <hong.aun.looi@intel.com>, Voon Weifeng <weifeng.voon@intel.com>, Song Yoong Siang <yoong.siang.song@intel.com>, Michael Sit Wei Hong <michael.wei.hong.sit@intel.com>, Gan Yi Fang <yi.fang.gan@intel.com> Subject: [PATCH net-next 1/1] net: stmmac: check CBS input values before configuration Date: Fri, 27 Oct 2023 14:11:14 +0800 Message-Id: <20231027061114.3792619-1-yi.fang.gan@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 26 Oct 2023 23:16:10 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780888237304069677 X-GMAIL-MSGID: 1780888237304069677 |
Series |
[net-next,1/1] net: stmmac: check CBS input values before configuration
|
|
Commit Message
Gan, Yi Fang
Oct. 27, 2023, 6:11 a.m. UTC
From: Michael Sit Wei Hong <michael.wei.hong.sit@intel.com> Add check for below conditions before proceeding to configuration. A message will be prompted if the input value is invalid. Idleslope minus sendslope should equal speed_div. Idleslope is always a positive value. Sendslope is always a negative value. Hicredit is always a positive value. Locredit is always a negative value. Signed-off-by: Michael Sit Wei Hong <michael.wei.hong.sit@intel.com> Signed-off-by: Gan, Yi Fang <yi.fang.gan@intel.com> --- drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c | 5 +++++ 1 file changed, 5 insertions(+)
Comments
On 27.10.2023 08:11, Gan Yi Fang wrote: > From: Michael Sit Wei Hong <michael.wei.hong.sit@intel.com> > > Add check for below conditions before proceeding to configuration. > A message will be prompted if the input value is invalid. > > Idleslope minus sendslope should equal speed_div. > Idleslope is always a positive value. > Sendslope is always a negative value. > Hicredit is always a positive value. > Locredit is always a negative value. Can those values be equal to 0? The code allows it but the commit msg doesn't mention that. Some drivers does not allow 0, lan966x_cbs_add e.g. Would be good to double check that. > > Signed-off-by: Michael Sit Wei Hong <michael.wei.hong.sit@intel.com> > Signed-off-by: Gan, Yi Fang <yi.fang.gan@intel.com> > --- > drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c > index ac41ef4cbd2f..e8a079946f84 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c > @@ -381,6 +381,11 @@ static int tc_setup_cbs(struct stmmac_priv *priv, > return -EOPNOTSUPP; > } > > + if ((qopt->idleslope - qopt->sendslope != speed_div) || > + qopt->idleslope < 0 || qopt->sendslope > 0 || > + qopt->hicredit < 0 || qopt->locredit > 0) > + return -EINVAL; > + > mode_to_use = priv->plat->tx_queues_cfg[queue].mode_to_use; > if (mode_to_use == MTL_QUEUE_DCB && qopt->enable) { > ret = stmmac_dma_qmode(priv, priv->ioaddr, queue, MTL_QUEUE_AVB);
Hi, Value zero is allowed. I will update V2 with the commit msg updated. Best regards, Gan Yi Fang > -----Original Message----- > From: Drewek, Wojciech <wojciech.drewek@intel.com> > Sent: Friday, October 27, 2023 6:08 PM > To: Gan, Yi Fang <yi.fang.gan@intel.com>; Alexandre Torgue > <alexandre.torgue@foss.st.com>; Jose Abreu <joabreu@synopsys.com>; > David S . Miller <davem@davemloft.net>; Eric Dumazet > <edumazet@google.com>; Jakub Kicinski <kuba@kernel.org>; Paolo Abeni > <pabeni@redhat.com>; Maxime Coquelin <mcoquelin.stm32@gmail.com>; > netdev@vger.kernel.org; linux-stm32@st-md-mailman.stormreply.com; linux- > arm-kernel@lists.infradead.org; linux-kernel@vger.kernel.org > Cc: Looi, Hong Aun <hong.aun.looi@intel.com>; Voon, Weifeng > <weifeng.voon@intel.com>; Song, Yoong Siang > <yoong.siang.song@intel.com>; Sit, Michael Wei Hong > <michael.wei.hong.sit@intel.com> > Subject: Re: [PATCH net-next 1/1] net: stmmac: check CBS input values before > configuration > > > > On 27.10.2023 08:11, Gan Yi Fang wrote: > > From: Michael Sit Wei Hong <michael.wei.hong.sit@intel.com> > > > > Add check for below conditions before proceeding to configuration. > > A message will be prompted if the input value is invalid. > > > > Idleslope minus sendslope should equal speed_div. > > Idleslope is always a positive value. > > Sendslope is always a negative value. > > Hicredit is always a positive value. > > Locredit is always a negative value. > > Can those values be equal to 0? The code allows it but the commit msg > doesn't mention that. > Some drivers does not allow 0, lan966x_cbs_add e.g. Would be good to > double check that. > > > > > Signed-off-by: Michael Sit Wei Hong <michael.wei.hong.sit@intel.com> > > Signed-off-by: Gan, Yi Fang <yi.fang.gan@intel.com> > > --- > > drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c | 5 +++++ > > 1 file changed, 5 insertions(+) > > > > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c > b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c > > index ac41ef4cbd2f..e8a079946f84 100644 > > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c > > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c > > @@ -381,6 +381,11 @@ static int tc_setup_cbs(struct stmmac_priv *priv, > > return -EOPNOTSUPP; > > } > > > > + if ((qopt->idleslope - qopt->sendslope != speed_div) || > > + qopt->idleslope < 0 || qopt->sendslope > 0 || > > + qopt->hicredit < 0 || qopt->locredit > 0) > > + return -EINVAL; > > + > > mode_to_use = priv->plat->tx_queues_cfg[queue].mode_to_use; > > if (mode_to_use == MTL_QUEUE_DCB && qopt->enable) { > > ret = stmmac_dma_qmode(priv, priv->ioaddr, queue, > MTL_QUEUE_AVB);
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c index ac41ef4cbd2f..e8a079946f84 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c @@ -381,6 +381,11 @@ static int tc_setup_cbs(struct stmmac_priv *priv, return -EOPNOTSUPP; } + if ((qopt->idleslope - qopt->sendslope != speed_div) || + qopt->idleslope < 0 || qopt->sendslope > 0 || + qopt->hicredit < 0 || qopt->locredit > 0) + return -EINVAL; + mode_to_use = priv->plat->tx_queues_cfg[queue].mode_to_use; if (mode_to_use == MTL_QUEUE_DCB && qopt->enable) { ret = stmmac_dma_qmode(priv, priv->ioaddr, queue, MTL_QUEUE_AVB);