Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp944188rdh; Thu, 26 Oct 2023 23:16:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFgT1dVq2MAUo2TdEib7J0LlOY/Xvm1wiRPQEmTmmg74hHbs1lNo7TQlysATXQPYCnl99+F X-Received: by 2002:a25:f81b:0:b0:d9a:ce53:4942 with SMTP id u27-20020a25f81b000000b00d9ace534942mr1603944ybd.0.1698387374920; Thu, 26 Oct 2023 23:16:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698387374; cv=none; d=google.com; s=arc-20160816; b=yRhch6qNuauxpE2BgDdQ0g+2SEUZyE+RPtMIpVd4GDt8fHJ25gpMdbBsYgJuwan4JM NSv3avVnqllTghHf8yPuX/sDoDXKdm2kMDSbfrjpyDyu/x6mEFKTPyQeQ4S2CkfAtLd4 gk4V3fpIFJnINFU00MePkUVuPCvzTi/bWWLkEbprTa5QjFbuWEfo+f5m+LJg9De115VU afOdTqE+SltpFAolPHD4bzAoCklKs+QTLA/UcQvdvHx7MixVrkUPFmf5YhSNMnufiLLI e3LzyFRROoxNMOuP+YNqUnbkMtEvCTlYTgvr+V0a1Ms9fyXr5TtIDc6kaPJael5+zY38 YQYA== 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 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id 129-20020a250187000000b00d9ffbe11c19si1523018ybb.381.2023.10.26.23.16.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 23:16:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; 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 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id 0722082CFA49; Thu, 26 Oct 2023 23:16:12 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345144AbjJ0GQA (ORCPT + 99 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 ); 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 To: 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 Cc: Looi Hong Aun , Voon Weifeng , Song Yoong Siang , Michael Sit Wei Hong , Gan Yi Fang 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 howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Thu, 26 Oct 2023 23:16:12 -0700 (PDT) From: Michael Sit Wei Hong 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 Signed-off-by: Gan, Yi Fang --- 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); -- 2.34.1