From patchwork Fri Oct 27 06:11:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gan, Yi Fang" X-Patchwork-Id: 158768 Return-Path: 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 + 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 ); 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 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: 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 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);