From patchwork Fri Apr 12 18:03:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13628225 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6E8FAC4345F for ; Fri, 12 Apr 2024 18:04:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=kZavGZjCYN++j7nqgBorDOawLddgsA7STHb+3B0F5KE=; b=PKOTX8h/1ChRVm /xdaPTakk1yV1gYb4i/I1vU6jF1DoSaw4OsbFVNDldav9oo7ZOa4Gkq7Iu4QEkVBAqXtrxpSRmn7r 7zID+SwvkDUkGP2zJ0M3IIeydpaj2h4dt8WvLqWiCxwv733MfkELMVYgSX9k9duOjiTiPTqMkSQLC d1YY3Gg7Bq4O1pM0oE4fer8w1SdOEQpSlkO+5uNzaDkTsYJzLYPukNs+iaPuz41/MAsK+Y/6xWq4y GFYSh6CqaWCpCb5uRsQYjusj5qEGDBI0kZeI25J6pj0XXp9QQmfUtwNVbPx0NFqwcYJYL5rTvIbFQ TtYOuMoKvdRDPqwaLTEw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvLGJ-00000000mF5-2hXD; Fri, 12 Apr 2024 18:04:31 +0000 Received: from mail-lj1-x233.google.com ([2a00:1450:4864:20::233]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvLFz-00000000m4i-38wE for linux-arm-kernel@lists.infradead.org; Fri, 12 Apr 2024 18:04:13 +0000 Received: by mail-lj1-x233.google.com with SMTP id 38308e7fff4ca-2da0b3f7ad2so13591381fa.2 for ; Fri, 12 Apr 2024 11:04:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712945050; x=1713549850; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nVOumlgGtBlZ85ugSU3wCdejk77Ru/Jzabc/ZwR7GtA=; b=UZdAGMng+SFMpxC98KgABlelwl/rtGU7hSNAGQ/qBlmP4+mxeduabFnYC31j/M32tS Cwczc3Y97dbGR5fi7XqWO/Vr4kxobiadgPFDolvIi5CzKB7983vWuEK5mWVp4TDWQztS hacVUow8AANMdSpP/OpbHeJBaUlaeyOmxjwS7EqbaUxBOYgLPrYv01Um0VajCyUoWaXo JO4m8PpJoOK13OYr6XnHn9FBpCAQH93CLcd4ltRgTnNrjCNGwUo/9svYeF6VB2WA68z3 huxG4O9/swa/c9PcrSQA1z8ND0J9e8U2hHZh56qapsyRslfWPHbGsAgFktroYFI665YQ aAgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712945050; x=1713549850; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nVOumlgGtBlZ85ugSU3wCdejk77Ru/Jzabc/ZwR7GtA=; b=VV00qkYTI2Y72dkJ2CQEEokSrTn/FVbkf9VWG8sXxjF/1ytig+1X6e56ORHkXuxwp4 +mWcWkFC1yw+1WeRVWyRpG0gykuel4FKEHVWp3J7NIrlfA0aAIOz7YkMHsDGI8ReLv53 LcOlz0JChZBKOybYfSRlNRkD5Sa5VzJNOsasXeFsiEuWFY3EWHc789he7XFKe7SFc39C zEb62O+By2p/C7wYf6J6fcDm2DENlA22l5w6g2O6lz+qdesF5DCAubNEGTizzua5wPpW BGrCsE5Z37YNJAAK5rDiQNdwaioNJIAty3LUBYOl2QXsWGTPOpd9oZIajFiNIk5JF4s+ 8k3w== X-Forwarded-Encrypted: i=1; AJvYcCWDJkcmaZFBKTAe4hROslP4EEEoyeOcN0IckTpme8ZaNbX4NuXkTZCkRC5C1WqrFd+DQaMNuwfwHGLgD/lU9zdjRJwQAQU25kcXIZ211X3VkfU1H/8= X-Gm-Message-State: AOJu0Yxe4Q2cOB3qlUm4F0Z5BogP3NAzsc5JCCGnKgwerCYgWwxFp5jq ZzqtBl0gJIo0+G6MyK9Gp6PGm4jXclT9lIDIAgNTZRyl3VB3SWPo X-Google-Smtp-Source: AGHT+IErtp2nV7mcKdqRo+jq1OWZkiMk/4riy2CBgl5T4ICW2MsRDn+iJIiWgWyWac4RMpk9UBQ8Xg== X-Received: by 2002:a05:651c:33a:b0:2d8:6561:72ca with SMTP id b26-20020a05651c033a00b002d8656172camr2074103ljp.19.1712945049992; Fri, 12 Apr 2024 11:04:09 -0700 (PDT) Received: from localhost ([95.79.241.172]) by smtp.gmail.com with ESMTPSA id g20-20020a05651c079400b002d86998c8f6sm570047lje.88.2024.04.12.11.04.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 11:04:09 -0700 (PDT) From: Serge Semin To: Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Russell King , Yanteng Si , Maxime Coquelin Cc: Serge Semin , Simon Horman , Huacai Chen , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH net-next 4/4] net: stmmac: Move MAC caps init to phylink MAC caps getter Date: Fri, 12 Apr 2024 21:03:17 +0300 Message-ID: <20240412180340.7965-5-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240412180340.7965-1-fancer.lancer@gmail.com> References: <20240412180340.7965-1-fancer.lancer@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240412_110411_928361_0BDE995D X-CRM114-Status: GOOD ( 16.32 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org After a set of fixes the stmmac_phy_setup() and stmmac_reinit_queues() method have turned to having some duplicated code. Let's get rid from the duplication by moving the MAC-capabilities initialization to the PHYLINK MAC-capabilities getter. The getter is called during each network device interface open/close cycle. So the MAC-capabilities will be initialized in normal device functioning and in case of the Tx/Rx queues re-initialization as the original code semantics implies. Signed-off-by: Serge Semin --- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 36 +++++++++---------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 7c6fb14b5555..cb72dd93191e 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -936,6 +936,22 @@ static void stmmac_mac_flow_ctrl(struct stmmac_priv *priv, u32 duplex) priv->pause, tx_cnt); } +static unsigned long stmmac_mac_get_caps(struct phylink_config *config, + phy_interface_t interface) +{ + struct stmmac_priv *priv = netdev_priv(to_net_dev(config->dev)); + + /* Get the MAC-specific capabilities */ + stmmac_mac_phylink_get_caps(priv); + + config->mac_capabilities = priv->hw->link.caps; + + if (priv->plat->max_speed) + phylink_limit_mac_speed(config, priv->plat->max_speed); + + return config->mac_capabilities; +} + static struct phylink_pcs *stmmac_mac_select_pcs(struct phylink_config *config, phy_interface_t interface) { @@ -1105,6 +1121,7 @@ static void stmmac_mac_link_up(struct phylink_config *config, } static const struct phylink_mac_ops stmmac_phylink_mac_ops = { + .mac_get_caps = stmmac_mac_get_caps, .mac_select_pcs = stmmac_mac_select_pcs, .mac_config = stmmac_mac_config, .mac_link_down = stmmac_mac_link_down, @@ -1204,7 +1221,6 @@ static int stmmac_phy_setup(struct stmmac_priv *priv) int mode = priv->plat->phy_interface; struct fwnode_handle *fwnode; struct phylink *phylink; - int max_speed; priv->phylink_config.dev = &priv->dev->dev; priv->phylink_config.type = PHYLINK_NETDEV; @@ -1225,15 +1241,6 @@ static int stmmac_phy_setup(struct stmmac_priv *priv) xpcs_get_interfaces(priv->hw->xpcs, priv->phylink_config.supported_interfaces); - /* Get the MAC specific capabilities */ - stmmac_mac_phylink_get_caps(priv); - - priv->phylink_config.mac_capabilities = priv->hw->link.caps; - - max_speed = priv->plat->max_speed; - if (max_speed) - phylink_limit_mac_speed(&priv->phylink_config, max_speed); - fwnode = priv->plat->port_node; if (!fwnode) fwnode = dev_fwnode(priv->device); @@ -7327,7 +7334,6 @@ int stmmac_reinit_queues(struct net_device *dev, u32 rx_cnt, u32 tx_cnt) { struct stmmac_priv *priv = netdev_priv(dev); int ret = 0, i; - int max_speed; if (netif_running(dev)) stmmac_release(dev); @@ -7341,14 +7347,6 @@ 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_mac_phylink_get_caps(priv); - - priv->phylink_config.mac_capabilities = priv->hw->link.caps; - - max_speed = priv->plat->max_speed; - if (max_speed) - phylink_limit_mac_speed(&priv->phylink_config, max_speed); - stmmac_napi_add(dev); if (netif_running(dev))