[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240215030500.3067426-4-yong.liang.choong@linux.intel.com>
Date: Thu, 15 Feb 2024 11:04:53 +0800
From: Choong Yong Liang <yong.liang.choong@...ux.intel.com>
To: Rajneesh Bhardwaj <irenic.rajneesh@...il.com>,
David E Box <david.e.box@...ux.intel.com>,
Hans de Goede <hdegoede@...hat.com>,
Mark Gross <markgross@...nel.org>,
Alexandre Torgue <alexandre.torgue@...s.st.com>,
Jose Abreu <Jose.Abreu@...opsys.com>,
"David S . Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Maxime Coquelin <mcoquelin.stm32@...il.com>,
Richard Cochran <richardcochran@...il.com>,
Russell King <linux@...linux.org.uk>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Jesper Dangaard Brouer <hawk@...nel.org>,
John Fastabend <john.fastabend@...il.com>,
Andrew Lunn <andrew@...n.ch>,
Heiner Kallweit <hkallweit1@...il.com>,
Philipp Zabel <p.zabel@...gutronix.de>
Cc: Andrew Halaney <ahalaney@...hat.com>,
Serge Semin <fancer.lancer@...il.com>,
netdev@...r.kernel.org,
linux-kernel@...r.kernel.org,
linux-stm32@...md-mailman.stormreply.com,
linux-arm-kernel@...ts.infradead.org,
platform-driver-x86@...r.kernel.org,
linux-hwmon@...r.kernel.org,
bpf@...r.kernel.org,
Voon Wei Feng <weifeng.voon@...el.com>,
Michael Sit Wei Hong <michael.wei.hong.sit@...el.com>,
Lai Peter Jun Ann <jun.ann.lai@...el.com>,
Abdul Rahim Faizal <faizal.abdul.rahim@...el.com>
Subject: [PATCH net-next v5 3/9] net: stmmac: select PCS negotiation mode according to the interface mode
The 'stmmac_get_pcs_neg_mode' is invoked during link initialization or
interface mode changes.
In cases where 'priv->plat->get_pcs_neg_mode' is absent, the default
'phylink_pcs_neg_mode' function is utilized.
Additionally, the 'intel_get_pcs_neg_mode' function is available to
determine the PCS negotiation mode based on the provided interface mode.
Signed-off-by: Choong Yong Liang <yong.liang.choong@...ux.intel.com>
---
.../net/ethernet/stmicro/stmmac/dwmac-intel.c | 48 +++++++++++++++----
.../net/ethernet/stmicro/stmmac/stmmac_main.c | 17 +++++++
include/linux/stmmac.h | 2 +
3 files changed, 57 insertions(+), 10 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c
index 60283543ffc8..6f12e80b8a05 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c
@@ -414,6 +414,39 @@ static void intel_mgbe_pse_crossts_adj(struct intel_priv_data *intel_priv,
}
}
+static bool is_fixed_link(struct pci_dev *pdev)
+{
+ struct fwnode_handle *fwnode = dev_fwnode(&pdev->dev);
+ bool is_fixed_link = false;
+
+ if (fwnode) {
+ struct fwnode_handle *fixed_node;
+
+ fixed_node = fwnode_get_named_child_node(fwnode, "fixed-link");
+ if (fixed_node)
+ is_fixed_link = true;
+
+ fwnode_handle_put(fixed_node);
+ }
+
+ return is_fixed_link;
+}
+
+static unsigned int intel_get_pcs_neg_mode(phy_interface_t interface,
+ struct pci_dev *pdev)
+{
+ unsigned int neg_mode;
+
+ if ((interface == PHY_INTERFACE_MODE_SGMII ||
+ interface == PHY_INTERFACE_MODE_1000BASEX) &&
+ !is_fixed_link(pdev))
+ neg_mode = PHYLINK_PCS_NEG_INBAND_ENABLED;
+ else
+ neg_mode = PHYLINK_PCS_NEG_OUTBAND;
+
+ return neg_mode;
+}
+
static void common_default_data(struct plat_stmmacenet_data *plat)
{
plat->clk_csr = 2; /* clk_csr_i = 20-35MHz & MDC = clk_csr_i/16 */
@@ -590,15 +623,8 @@ static int intel_mgbe_common_data(struct pci_dev *pdev,
}
/* For fixed-link setup, we clear xpcs_an_inband */
- if (fwnode) {
- struct fwnode_handle *fixed_node;
-
- fixed_node = fwnode_get_named_child_node(fwnode, "fixed-link");
- if (fixed_node)
- plat->mdio_bus_data->xpcs_an_inband = false;
-
- fwnode_handle_put(fixed_node);
- }
+ if (is_fixed_link(pdev))
+ plat->mdio_bus_data->xpcs_an_inband = false;
/* Ensure mdio bus scan skips intel serdes and pcs-xpcs */
plat->mdio_bus_data->phy_mask = 1 << INTEL_MGBE_ADHOC_ADDR;
@@ -649,7 +675,7 @@ static int ehl_sgmii_data(struct pci_dev *pdev,
plat->speed_mode_2500 = intel_speed_mode_2500;
plat->serdes_powerup = intel_serdes_powerup;
plat->serdes_powerdown = intel_serdes_powerdown;
-
+ plat->get_pcs_neg_mode = intel_get_pcs_neg_mode;
plat->clk_ptp_rate = 204800000;
return ehl_common_data(pdev, plat);
@@ -708,6 +734,7 @@ static int ehl_pse0_sgmii1g_data(struct pci_dev *pdev,
plat->speed_mode_2500 = intel_speed_mode_2500;
plat->serdes_powerup = intel_serdes_powerup;
plat->serdes_powerdown = intel_serdes_powerdown;
+ plat->get_pcs_neg_mode = intel_get_pcs_neg_mode;
return ehl_pse0_common_data(pdev, plat);
}
@@ -749,6 +776,7 @@ static int ehl_pse1_sgmii1g_data(struct pci_dev *pdev,
plat->speed_mode_2500 = intel_speed_mode_2500;
plat->serdes_powerup = intel_serdes_powerup;
plat->serdes_powerdown = intel_serdes_powerdown;
+ plat->get_pcs_neg_mode = intel_get_pcs_neg_mode;
return ehl_pse1_common_data(pdev, plat);
}
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index ae2ffa9595d6..dbd16fc38888 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1104,11 +1104,28 @@ static void stmmac_mac_link_up(struct phylink_config *config,
stmmac_hwtstamp_correct_latency(priv, priv);
}
+static unsigned int stmmac_get_pcs_neg_mode(struct phylink_config *config,
+ unsigned int mode,
+ phy_interface_t interface,
+ const unsigned long *advertising)
+{
+ struct stmmac_priv *priv = netdev_priv(to_net_dev(config->dev));
+ unsigned int neg_mode;
+
+ if (priv->plat->get_pcs_neg_mode)
+ neg_mode = priv->plat->get_pcs_neg_mode(interface, priv->plat->pdev);
+ else
+ neg_mode = phylink_pcs_neg_mode(mode, interface, advertising);
+
+ return neg_mode;
+}
+
static const struct phylink_mac_ops stmmac_phylink_mac_ops = {
.mac_select_pcs = stmmac_mac_select_pcs,
.mac_config = stmmac_mac_config,
.mac_link_down = stmmac_mac_link_down,
.mac_link_up = stmmac_mac_link_up,
+ .mac_get_pcs_neg_mode = stmmac_get_pcs_neg_mode,
};
/**
diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
index dfa1828cd756..ffd66722eeda 100644
--- a/include/linux/stmmac.h
+++ b/include/linux/stmmac.h
@@ -277,6 +277,8 @@ struct plat_stmmacenet_data {
int (*serdes_powerup)(struct net_device *ndev, void *priv);
void (*serdes_powerdown)(struct net_device *ndev, void *priv);
void (*speed_mode_2500)(struct net_device *ndev, void *priv);
+ unsigned int (*get_pcs_neg_mode)(phy_interface_t interface,
+ struct pci_dev *pdev);
void (*ptp_clk_freq_config)(struct stmmac_priv *priv);
int (*init)(struct platform_device *pdev, void *priv);
void (*exit)(struct platform_device *pdev, void *priv);
--
2.34.1
Powered by blists - more mailing lists