Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2670263rdh; Wed, 27 Sep 2023 09:12:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHjwP91CH2JCy49esVpr7kdILJyfvN6b00HaGSYMcxwYVaXBYWg5DkCQ0d0eU24wWGGtZwi X-Received: by 2002:a05:6a00:847:b0:68f:dfe2:9f03 with SMTP id q7-20020a056a00084700b0068fdfe29f03mr2409888pfk.11.1695831129186; Wed, 27 Sep 2023 09:12:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695831129; cv=none; d=google.com; s=arc-20160816; b=bS9YkG1SpPFUB4pB1NTraQZmexnnTaEOlc7kVhT5G9cyO7ub6ObJltLr5J+BH5aGbq j9TEoJubv+uo0AY6343g+hCzrFije/mnToHsC0IR3GYVMEr5p5oINOkrbkITzKF+pb5O 15GUsBEfKlCuXUrwvmoBaDUI6mdCEnirBlEKA/O86dF+P8yFfMFWXdYZ0o++cgnvD9eF ZJ4o+kj4L94vvvW0zF3m9iPwpxCM+E1RYarFkUH/04b7CiclosSIzoQaWB410YSZY6w3 ohcx4xIItHOieiCtYtYv/HW1WPyjHNcpwybuMWtP641W0Ghh8eKtzP1Xoz+c+uY09DY/ GBNg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Q4WxNyTq1nkzNWRvFx0BRNFlwuaJgnNtfXvM/DpCDZM=; fh=PdKB5H0uUHWsGiUZAfKXwBgfRduyYCTj6vVGcrsTRlY=; b=rVoLhHfPHHIG1KKccif9SZ6hJUlC7SzAhlXFFRTPUpxGYxIwVi81E1HQNYWJzB664P EVtGvo8VFFdMXKQ3ASvYBllo4JsBHbaouvrHRrmXfjQC6qoDjHWmC738hzZYwHCI232C wy+sJPE9PbO2NRrC6LkAr+CgMEv3nkHqOwMX+KOPpcZGH47IFo7JgCCTxIXl3E52ZEUj ydiLj0PsrYulHX3Zg3xwMjjDoTo1prCTFEAppafCH0H4T1y/c1Bv8+c9OAa+zGkD8MKa 9aPpFko6he1+Qz+bgJ7zr6njPPr8GzyH4st3JRKdsc/KN00KRi6tttuNZzOUFdsOqzQx alrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=gVLZqqb+; 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 Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id ck12-20020a056a00328c00b0069026a3de0asi15709088pfb.138.2023.09.27.09.12.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 09:12:09 -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=gVLZqqb+; 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 6E29582A049B; Wed, 27 Sep 2023 06:34:14 -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 S231849AbjI0Ndq (ORCPT + 99 others); Wed, 27 Sep 2023 09:33:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231848AbjI0Ndm (ORCPT ); Wed, 27 Sep 2023 09:33:42 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DF3B11D; Wed, 27 Sep 2023 06:33:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695821620; x=1727357620; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dtL29E/BwrOaZOSvMgF27vlanWODXVxmTDllXA3PIbI=; b=gVLZqqb+mxIppnp7WIKIssI8LG+2KPE1BPhGVGouTinIVtd9TGXFdOus gseFM7SfbvST70aKlPY1mJ/D6yJJD5x8cQBz4vf2nRHfPBmKdC6D2PPYk z1spuDvuDHPEeQtgVzQaDxKaEWFwDkLI4uNxWf2JJexIVktrvc3piKHRH cdEnmZjA21UViRdemlSHhB97CX4LTDXgxgtM1lZACZohGyTk68mPPaKGi b/f8a8fyO5fVrgo7RAmmeUQbiThwosiPRo0iC7Hv1scXCjcHLnefpF0AE KyZoDIFuVcpDrE4uTgPrSX4v2fSsj/lbF7FP8PlQda38qMf3XP7sQp/Gu w==; X-IronPort-AV: E=McAfee;i="6600,9927,10846"; a="380700777" X-IronPort-AV: E=Sophos;i="6.03,181,1694761200"; d="scan'208";a="380700777" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Sep 2023 06:09:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10846"; a="698867015" X-IronPort-AV: E=Sophos;i="6.03,181,1694761200"; d="scan'208";a="698867015" Received: from pglc00352.png.intel.com ([10.221.235.155]) by orsmga003.jf.intel.com with ESMTP; 27 Sep 2023 06:09:38 -0700 From: Rohan G Thomas To: "David S . Miller" , Alexandre Torgue , Jose Abreu , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Giuseppe Cavallaro , Serge Semin Cc: netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Rohan G Thomas Subject: [PATCH net-next 2/2] net: stmmac: TBS support for platform driver Date: Wed, 27 Sep 2023 21:09:19 +0800 Message-Id: <20230927130919.25683-3-rohan.g.thomas@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20230927130919.25683-1-rohan.g.thomas@intel.com> References: <20230927130919.25683-1-rohan.g.thomas@intel.com> 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: 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]); Wed, 27 Sep 2023 06:34:14 -0700 (PDT) Enable Time Based Scheduling(TBS) support for Tx queues through the stmmac platform driver. For this a new per-queue tx-config property, tbs-enabled is added to the devicetree. Commit 7eadf57290ec ("net: stmmac: pci: Enable TBS on GMAC5 IPK PCI entry") enables similar support for the stmmac pci driver. Also add check whether TBS support is available for a Tx DMA channel before enabling TBS support for that Tx DMA channel. Signed-off-by: Rohan G Thomas --- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 25 +++++++++++++++---- .../ethernet/stmicro/stmmac/stmmac_platform.c | 4 +++ 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 81b6f3ecdf92..7333f0640b3d 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -3773,12 +3773,18 @@ stmmac_setup_dma_desc(struct stmmac_priv *priv, unsigned int mtu) dma_conf->dma_rx_size = DMA_DEFAULT_RX_SIZE; /* Earlier check for TBS */ - for (chan = 0; chan < priv->plat->tx_queues_to_use; chan++) { - struct stmmac_tx_queue *tx_q = &dma_conf->tx_queue[chan]; - int tbs_en = priv->plat->tx_queues_cfg[chan].tbs_en; + if (priv->dma_cap.tbssel) { + /* TBS is available only for tbs_ch_num of Tx DMA channels, + * starting from the highest Tx DMA channel. + */ + chan = priv->dma_cap.number_tx_channel - priv->dma_cap.tbs_ch_num; + for (; chan < priv->plat->tx_queues_to_use; chan++) { + struct stmmac_tx_queue *tx_q = &dma_conf->tx_queue[chan]; + int tbs_en = priv->plat->tx_queues_cfg[chan].tbs_en; - /* Setup per-TXQ tbs flag before TX descriptor alloc */ - tx_q->tbs |= tbs_en ? STMMAC_TBS_AVAIL : 0; + /* Setup per-TXQ tbs flag before TX descriptor alloc */ + tx_q->tbs |= tbs_en ? STMMAC_TBS_AVAIL : 0; + } } ret = alloc_dma_desc_resources(priv, dma_conf); @@ -7505,6 +7511,15 @@ int stmmac_dvr_probe(struct device *device, } } + /* If TBS feature is supported(i.e. tbssel is true), then at least 1 Tx + * DMA channel supports TBS. So if tbs_ch_num is 0 and tbssel is true, + * assume all Tx DMA channels support TBS. TBS_CH field, which gives + * number of Tx DMA channels with TBS support is only available only for + * DW xGMAC IP. For other DWMAC IPs all Tx DMA channels can support TBS. + */ + if (priv->dma_cap.tbssel && !priv->dma_cap.tbs_ch_num) + priv->dma_cap.tbs_ch_num = priv->dma_cap.number_tx_channel; + ndev->features |= ndev->hw_features | NETIF_F_HIGHDMA; ndev->watchdog_timeo = msecs_to_jiffies(watchdog); #ifdef STMMAC_VLAN_TAG_USED diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c index 843bd8804bfa..6c0191c84071 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c @@ -279,6 +279,10 @@ static int stmmac_mtl_setup(struct platform_device *pdev, plat->tx_queues_cfg[queue].coe_unsupported = of_property_read_bool(q_node, "snps,coe-unsupported"); + /* Select TBS for supported queues */ + plat->tx_queues_cfg[queue].tbs_en = + of_property_read_bool(q_node, "snps,tbs-enabled"); + queue++; } if (queue != plat->tx_queues_to_use) { -- 2.26.2