From patchwork Fri Oct 20 03:25:35 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: 155776 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp798895vqb; Thu, 19 Oct 2023 20:29:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEaF4fkbF+bVYGZ7g+ulYkd670JlXiTI/1UdyESSAd9CMrZWC/unnFqldkiXusf6WVy0kni X-Received: by 2002:aa7:88ce:0:b0:6b6:e147:717 with SMTP id k14-20020aa788ce000000b006b6e1470717mr642144pff.23.1697772543142; Thu, 19 Oct 2023 20:29:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697772543; cv=none; d=google.com; s=arc-20160816; b=dapl6eCDpfFcjUa/6ISMMNP5qe1fsbEpqVDZuKA1FVm0IjfI7Cuycu4uXr0fomlaLl iwncM0acfnsIhiGyplgvx0K89z6Ny++H4iHv6kfqsqwZakfGsW9KSjD5sXih9zEjy//0 KbgM93lDlI1OsTYn0ndO7/1XyNZ/n4zosrHJ5ur5IQID4jqYzcAkbCEfbPauW6FDu3IF e6N7vZtd4wbzDZiTpqGRuH5B1b3IjQdR4hZI2fi/7y9oML2F5iPBwTjCoS/WZmw5fuwc RoBhU39YGn4UIazM61NQ3Vz/e6ukPAmvfx0wYcxblmBisqJFhthkPqGXU4PB8w+2PzCo 567g== 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=xLweuhMJCqmHEdjm09kabumCAIwkO+0yw6SsiK8gudQ=; fh=ZE8jK/KICYibp5zdxwGwN/ZEfzER6EKdGYOrha7OOvs=; b=zcKwPWty/VDn3Qh8ynlURyaN9AATisYjK7WIUm5G3RmnoAdRSPuxTMeFu0zSTNMWMs UVIAKoGyB3B618J8MHaMPCrWZvcwJhGXRjRbYVQKwqgerjltSZfx7PaeD47/Xy5h2NKi tvnhqjhlo5ssakMwN/vmCvF/uNNxmF5LjZ0sDcWnvMj/OP639ZFZiUtCz7f80Ifu2tHS Zu45UGCJ1SiDnvk6cVjwr46n4+JH8xfsgQxTSxffuomoTNkb6NxCZbO65Uxki3khYirT E+BCW+OY9MIj8ZkoJuScVn0Xxkb/VRqUCO1Qs090999J6TQLhpEUv+Xt92o/KM8X6ePH LC+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=SZ5pGjCx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id b6-20020a6567c6000000b00578a43e3b0bsi986825pgs.655.2023.10.19.20.29.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 20:29:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=SZ5pGjCx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 6A5CA82958BD; Thu, 19 Oct 2023 20:29:02 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346886AbjJTD2z (ORCPT + 25 others); Thu, 19 Oct 2023 23:28:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235594AbjJTD2v (ORCPT ); Thu, 19 Oct 2023 23:28:51 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 245B3D4C; Thu, 19 Oct 2023 20:28:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697772530; x=1729308530; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=96Gky6mpZZHpzgNi964Tps4EK4L+Pft4fZHmTBB7PZs=; b=SZ5pGjCx+5SdJ/o0PCwaYnm8gfySxrz1JJNucTi/XSx7Q7L8Li+9ByK8 bL/+tCdVU/JYrJ0Hwi77jDyHwYqrCgpKgDoJoZJT4ftxZh7sgJYZmZbjg ecIHF5aWZyP0KoS4SpkVZ8kIYoQwIbFXoa3rHig4LErYH5BgYNCiV40e0 Bvr/TGa6t//NmZlCAVOqgWzbqA5OqJcwpGoH+RY/UNC2jVgUopVQrDL9R SaqJgQX+P7+45khGHwHnLIMcENTJU5BQgzxpDlhGuvAVW3NO4IWg8Bz76 9pW95xj36WGtZoOY3QSzpX0A6NRmG37tu/zYmKzQGaNcM0yqL4Kht0bXH A==; X-IronPort-AV: E=McAfee;i="6600,9927,10868"; a="472645905" X-IronPort-AV: E=Sophos;i="6.03,238,1694761200"; d="scan'208";a="472645905" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Oct 2023 20:28:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10868"; a="827592040" X-IronPort-AV: E=Sophos;i="6.03,238,1694761200"; d="scan'208";a="827592040" Received: from ssid-ilbpg3-teeminta.png.intel.com ([10.88.227.74]) by fmsmga004.fm.intel.com with ESMTP; 19 Oct 2023 20:28:45 -0700 From: Gan Yi Fang To: Alexandre Torgue , Jose Abreu , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Russell King , Ong Boon Leong , 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 , Gan Yi Fang Subject: [PATCH net v2 1/1] net: stmmac: update MAC capabilities when tx queues are updated Date: Fri, 20 Oct 2023 11:25:35 +0800 Message-Id: <20231020032535.1777746-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=AC_FROM_MANY_DOTS,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Thu, 19 Oct 2023 20:29:02 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780243542139147418 X-GMAIL-MSGID: 1780243542139147418 From: Michael Sit Wei Hong Upon boot up, the driver will configure the MAC capabilities based on the maximum number of tx and rx queues. When the user changes the tx queues to single queue, the MAC should be capable of supporting Half Duplex, but the driver does not update the MAC capabilities when it is configured so. Using the stmmac_reinit_queues() to check the number of tx queues and set the MAC capabilities accordingly. Fixes: 0366f7e06a6b ("net: stmmac: add ethtool support for get/set channels") Cc: # 5.17+ Signed-off-by: Michael Sit Wei Hong Signed-off-by: Gan, Yi Fang --- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index ed1a5a31a491..5801f4d50f95 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -1197,6 +1197,17 @@ static int stmmac_init_phy(struct net_device *dev) return ret; } +static void stmmac_set_half_duplex(struct stmmac_priv *priv) +{ + /* Half-Duplex can only work with single tx queue */ + if (priv->plat->tx_queues_to_use > 1) + priv->phylink_config.mac_capabilities &= + ~(MAC_10HD | MAC_100HD | MAC_1000HD); + else + priv->phylink_config.mac_capabilities |= + (MAC_10HD | MAC_100HD | MAC_1000HD); +} + static int stmmac_phy_setup(struct stmmac_priv *priv) { struct stmmac_mdio_bus_data *mdio_bus_data; @@ -1228,10 +1239,7 @@ static int stmmac_phy_setup(struct stmmac_priv *priv) MAC_10FD | MAC_100FD | MAC_1000FD; - /* Half-Duplex can only work with single queue */ - if (priv->plat->tx_queues_to_use <= 1) - priv->phylink_config.mac_capabilities |= MAC_10HD | MAC_100HD | - MAC_1000HD; + stmmac_set_half_duplex(priv); /* Get the MAC specific capabilities */ stmmac_mac_phylink_get_caps(priv); @@ -7172,6 +7180,7 @@ int stmmac_reinit_queues(struct net_device *dev, u32 rx_cnt, u32 tx_cnt) priv->rss.table[i] = ethtool_rxfh_indir_default(i, rx_cnt); + stmmac_set_half_duplex(priv); stmmac_napi_add(dev); if (netif_running(dev))