Skip to contentSkip to conversation

Add support to PHYLINK and SFP for PCI11x1x chips

PATCH In review Raju Lakkaraju 3 participants 15 messages Jul 21, 2023 – Aug 1, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover Add support to PHYLINK and SFP for PCI11x1x chips

This patch series adds support to PHYLINK and SFP pluggable module. Add software-nodes to hold the network interface phylink, sfp, i2c and GPIO configuration and integrates the PCI1x1x chip I2C driver and GPIO driver to access the SFP module EEPROM data.

Tested on chip PCI11010 Rev-B with Bridgeport Evaluation board Rev-1 with following SFP modules:

1. FS's 2.5G SFP (SFP-2.5G-T) with 2.5 Gbps speed (interface 2500Base-X)

2. FS's DAC10G SFP (SFPP-PC01) with 2.5 Gbps speed (interface 2500Base-X)

3. FS's 1G SFP (SFP-GB-GE-TL) with 1G/100M/10M bps speed (interface SGMII)

4. Axcen's 1G SFP (AXGT-R1T4-05I1) with 1G/100M/10M bps speed (interface SGMII)

5. Excom's 1G SFP (SFP-T) with 1G/100M/10M bps speed (interface SGMII)

Raju Lakkaraju (7):
net: lan743x: Create separate PCS power reset function
net: lan743x: Create separate Link Speed Duplex state function
net: lan743x: Add SFP support check flag
net: lan743x: Add support to software-nodes for SFP and PHYLINK
net: lan743x: Add support to the Phylink framework
net: lan743x: Add support to ethtool phylink get and set settings
net: lan743x: Register the platform device for sfp pluggable module

 drivers/net/ethernet/microchip/Kconfig        |   4 +-
 .../net/ethernet/microchip/lan743x_ethtool.c  |  34 +-
 drivers/net/ethernet/microchip/lan743x_main.c | 707 ++++++++++++++++--
 drivers/net/ethernet/microchip/lan743x_main.h |  42 ++
 4 files changed, 718 insertions(+), 69 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/7 net: lan743x: Create separate PCS power reset function

Create separate PCS power reset function from lan743x_sgmii_config () to use as subroutine.

---
 drivers/net/ethernet/microchip/lan743x_main.c | 54 ++++++++++---------
 1 file changed, 29 insertions(+), 25 deletions(-)
drivers/net/ethernet/microchip/lan743x_main.c +29 -25
index a36f6369f132..dba5576a933b 100644
@@ -1145,6 +1145,34 @@ static int lan743x_pcs_seq_state(struct lan743x_adapter *adapter, u8 state)
 	return 0;
 }
 
+static int lan743x_pcs_power_reset(struct lan743x_adapter *adapter)
+{
+	int mii_ctl;
+	int ret;
+
+	/* SGMII/1000/2500BASE-X PCS power down */
+	mii_ctl = lan743x_sgmii_read(adapter, MDIO_MMD_VEND2, MII_BMCR);
+	if (mii_ctl < 0)
+		return mii_ctl;
+
+	mii_ctl |= BMCR_PDOWN;
+	ret = lan743x_sgmii_write(adapter, MDIO_MMD_VEND2, MII_BMCR, mii_ctl);
+	if (ret < 0)
+		return ret;
+
+	ret = lan743x_pcs_seq_state(adapter, PCS_POWER_STATE_DOWN);
+	if (ret < 0)
+		return ret;
+
+	/* SGMII/1000/2500BASE-X PCS power up */
+	mii_ctl &= ~BMCR_PDOWN;
+	ret = lan743x_sgmii_write(adapter, MDIO_MMD_VEND2, MII_BMCR, mii_ctl);
+	if (ret < 0)
+		return ret;
+
+	return lan743x_pcs_seq_state(adapter, PCS_POWER_STATE_UP);
+}
+
 static int lan743x_sgmii_config(struct lan743x_adapter *adapter)
 {
 	struct net_device *netdev = adapter->netdev;
@@ -1207,31 +1235,7 @@ static int lan743x_sgmii_config(struct lan743x_adapter *adapter)
 		netif_dbg(adapter, drv, adapter->netdev,
 			  "SGMII 1G mode enable\n");
 
-	/* SGMII/1000/2500BASE-X PCS power down */
-	mii_ctl = lan743x_sgmii_read(adapter, MDIO_MMD_VEND2, MII_BMCR);
-	if (mii_ctl < 0)
-		return mii_ctl;
-
-	mii_ctl |= BMCR_PDOWN;
-	ret = lan743x_sgmii_write(adapter, MDIO_MMD_VEND2, MII_BMCR, mii_ctl);
-	if (ret < 0)
-		return ret;
-
-	ret = lan743x_pcs_seq_state(adapter, PCS_POWER_STATE_DOWN);
-	if (ret < 0)
-		return ret;
-
-	/* SGMII/1000/2500BASE-X PCS power up */
-	mii_ctl &= ~BMCR_PDOWN;
-	ret = lan743x_sgmii_write(adapter, MDIO_MMD_VEND2, MII_BMCR, mii_ctl);
-	if (ret < 0)
-		return ret;
-
-	ret = lan743x_pcs_seq_state(adapter, PCS_POWER_STATE_UP);
-	if (ret < 0)
-		return ret;
-
-	return 0;
+	return lan743x_pcs_power_reset(adapter);
 }
 
 static void lan743x_mac_set_address(struct lan743x_adapter *adapter,
Signature · 1 line
2.25.1
#3 lore raw

PATCH 2/7 net: lan743x: Create separate Link Speed Duplex state function

In reply to Raju Lakkaraju

Create separate Link Speed Duplex (LSD) update state function from lan743x_sgmii_config () to use as subroutine.

---
 drivers/net/ethernet/microchip/lan743x_main.c | 76 +++++++++++--------
 drivers/net/ethernet/microchip/lan743x_main.h |  1 +
 2 files changed, 46 insertions(+), 31 deletions(-)
drivers/net/ethernet/microchip/lan743x_main.c +45 -31
index dba5576a933b..e8dd272a591a 100644
@@ -990,6 +990,42 @@ static int lan743x_sgmii_write(struct lan743x_adapter *adapter,
 	return ret;
 }
 
+int lan743x_lsd_update(int speed, int duplex, u8 mss)
+{
+	enum lan743x_sgmii_lsd lsd = POWER_DOWN;
+
+	switch (speed) {
+	case SPEED_2500:
+		if (mss == MASTER_SLAVE_STATE_SLAVE)
+			lsd = LINK_2500_SLAVE;
+		else
+			lsd = LINK_2500_MASTER;
+		break;
+	case SPEED_1000:
+		if (mss == MASTER_SLAVE_STATE_SLAVE)
+			lsd = LINK_1000_SLAVE;
+		else
+			lsd = LINK_1000_MASTER;
+		break;
+	case SPEED_100:
+		if (duplex == DUPLEX_FULL)
+			lsd = LINK_100FD;
+		else
+			lsd = LINK_100HD;
+		break;
+	case SPEED_10:
+		if (duplex == DUPLEX_FULL)
+			lsd = LINK_10FD;
+		else
+			lsd = LINK_10HD;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	return lsd;
+}
+
 static int lan743x_sgmii_mpll_set(struct lan743x_adapter *adapter,
 				  u16 baud)
 {
@@ -1177,43 +1213,21 @@ static int lan743x_sgmii_config(struct lan743x_adapter *adapter)
 {
 	struct net_device *netdev = adapter->netdev;
 	struct phy_device *phydev = netdev->phydev;
-	enum lan743x_sgmii_lsd lsd = POWER_DOWN;
-	int mii_ctl;
 	bool status;
 	int ret;
 
-	switch (phydev->speed) {
-	case SPEED_2500:
-		if (phydev->master_slave_state == MASTER_SLAVE_STATE_MASTER)
-			lsd = LINK_2500_MASTER;
-		else
-			lsd = LINK_2500_SLAVE;
-		break;
-	case SPEED_1000:
-		if (phydev->master_slave_state == MASTER_SLAVE_STATE_MASTER)
-			lsd = LINK_1000_MASTER;
-		else
-			lsd = LINK_1000_SLAVE;
-		break;
-	case SPEED_100:
-		if (phydev->duplex)
-			lsd = LINK_100FD;
-		else
-			lsd = LINK_100HD;
-		break;
-	case SPEED_10:
-		if (phydev->duplex)
-			lsd = LINK_10FD;
-		else
-			lsd = LINK_10HD;
-		break;
-	default:
+	ret = lan743x_lsd_update(phydev->speed, phydev->duplex,
+				 phydev->master_slave_state);
+	if (ret < 0) {
 		netif_err(adapter, drv, adapter->netdev,
-			  "Invalid speed %d\n", phydev->speed);
-		return -EINVAL;
+			  "error %d link-speed-duplex(LSD) invalid\n", ret);
+		return ret;
 	}
 
-	adapter->sgmii_lsd = lsd;
+	adapter->sgmii_lsd = ret;
+	netif_dbg(adapter, drv, adapter->netdev,
+		  "Link Speed Duplex (lsd) : 0x%X\n", adapter->sgmii_lsd);
+
 	ret = lan743x_sgmii_aneg_update(adapter);
 	if (ret < 0) {
 		netif_err(adapter, drv, adapter->netdev,
drivers/net/ethernet/microchip/lan743x_main.h +1 -0
index 52609fc13ad9..0cd3fe71dfad 100644
@@ -1163,5 +1163,6 @@ void lan743x_hs_syslock_release(struct lan743x_adapter *adapter);
 void lan743x_mac_flow_ctrl_set_enables(struct lan743x_adapter *adapter,
 				       bool tx_enable, bool rx_enable);
 int lan743x_sgmii_read(struct lan743x_adapter *adapter, u8 mmd, u16 addr);
+int lan743x_lsd_update(int speed, int duplex, u8 mss);
 
 #endif /* _LAN743X_H */
Signature · 1 line
2.25.1
#4 lore raw

PATCH 3/7 net: lan743x: Add SFP support check flag

In reply to Raju Lakkaraju

PCI11x1x chip support the Pluggable module (SFP) depend on Board requirement. SFP support information programmed in EEPROM.
Flag "is_sfp_support_en" update on "STRAP" register.

---
 drivers/net/ethernet/microchip/lan743x_main.c | 10 ++++++++++
 drivers/net/ethernet/microchip/lan743x_main.h |  3 +++
 2 files changed, 13 insertions(+)
drivers/net/ethernet/microchip/lan743x_main.c +10 -0
index e8dd272a591a..822576b088a9 100644
@@ -52,6 +52,11 @@ static void pci11x1x_strap_get_status(struct lan743x_adapter *adapter)
 			adapter->is_sgmii_en = true;
 		else
 			adapter->is_sgmii_en = false;
+
+		if ((strap & STRAP_SFP_USE_EN_) && (strap & STRAP_SFP_EN_))
+			adapter->is_sfp_support_en = true;
+		else
+			adapter->is_sfp_support_en = false;
 	} else {
 		chip_rev = lan743x_csr_read(adapter, FPGA_REV);
 		if (chip_rev) {
@@ -63,8 +68,12 @@ static void pci11x1x_strap_get_status(struct lan743x_adapter *adapter)
 			adapter->is_sgmii_en = false;
 		}
 	}
+
 	netif_dbg(adapter, drv, adapter->netdev,
 		  "SGMII I/F %sable\n", adapter->is_sgmii_en ? "En" : "Dis");
+	netif_dbg(adapter, drv, adapter->netdev,
+		  "SFP support %sable\n", adapter->is_sfp_support_en ?
+		  "En" : "Dis");
 }
 
 static bool is_pci11x1x_chip(struct lan743x_adapter *adapter)
@@ -3408,6 +3417,7 @@ static int lan743x_pcidev_probe(struct pci_dev *pdev,
 			      NETIF_MSG_LINK | NETIF_MSG_IFUP |
 			      NETIF_MSG_IFDOWN | NETIF_MSG_TX_QUEUED;
 	netdev->max_mtu = LAN743X_MAX_FRAME_SIZE;
+	adapter->is_sfp_support_en = false;
 
 	of_get_mac_address(pdev->dev.of_node, adapter->mac_address);
 
drivers/net/ethernet/microchip/lan743x_main.h +3 -0
index 0cd3fe71dfad..3889bb20a524 100644
@@ -34,6 +34,8 @@
 
 #define STRAP_READ			(0x0C)
 #define STRAP_READ_USE_SGMII_EN_	BIT(22)
+#define STRAP_SFP_USE_EN_		BIT(31)
+#define STRAP_SFP_EN_			BIT(15)
 #define STRAP_READ_SGMII_EN_		BIT(6)
 #define STRAP_READ_SGMII_REFCLK_	BIT(5)
 #define STRAP_READ_SGMII_2_5G_		BIT(4)
@@ -1038,6 +1040,7 @@ struct lan743x_adapter {
 	u8			max_tx_channels;
 	u8			used_tx_channels;
 	u8			max_vector_count;
+	bool			is_sfp_support_en;
 
 #define LAN743X_ADAPTER_FLAG_OTP		BIT(0)
 	u32			flags;
Signature · 1 line
2.25.1
#5 lore raw

PATCH 4/7 net: lan743x: Add support to software-nodes for SFP and PHYLINK

In reply to Raju Lakkaraju

Register software nodes and define the device properties. software-node contains following properties.
- GPIO pin details
- I2C bus information
- SFP signals
- phylink modes

---
 drivers/net/ethernet/microchip/Kconfig        |   2 +
 drivers/net/ethernet/microchip/lan743x_main.c | 214 +++++++++++++++++-
 drivers/net/ethernet/microchip/lan743x_main.h |  31 +++
 3 files changed, 244 insertions(+), 3 deletions(-)
drivers/net/ethernet/microchip/Kconfig +2 -0
index 329e374b9539..b1d361b412d1 100644
@@ -49,6 +49,8 @@ config LAN743X
 	select FIXED_PHY
 	select CRC16
 	select CRC32
+	select I2C_PCI1XXXX
+	select GP_PCI1XXXX
 	help
 	  Support for the Microchip LAN743x PCI Express Gigabit Ethernet chip
 
drivers/net/ethernet/microchip/lan743x_main.c +211 -3

250 lines not on this page · raw message

drivers/net/ethernet/microchip/lan743x_main.h +31 -0
index 3889bb20a524..7f1c5673bc61 100644
@@ -5,6 +5,7 @@
 #define _LAN743X_H
 
 #include <linux/phy.h>
+#include <linux/property.h>
 #include "lan743x_ptp.h"
 
 #define DRIVER_AUTHOR   "Bryan Whitehead <[email protected]>"
@@ -1008,6 +1009,34 @@ enum lan743x_sgmii_lsd {
 	LINK_2500_SLAVE
 };
 
+enum lan743x_swnodes {
+	SWNODE_GPIO = 0,
+	SWNODE_I2C,
+	SWNODE_SFP,
+	SWNODE_PHYLINK,
+	SWNODE_MAX
+};
+
+struct lan743x_sw_nodes {
+	char gpio_name[32];
+	char i2c_name[48];
+	char sfp_name[32];
+	char phylink_name[32];
+	struct property_entry gpio_props[1];
+	struct property_entry i2c_props[1];
+	struct property_entry sfp_props[8];
+	struct property_entry phylink_props[2];
+	struct software_node_ref_args i2c_ref[1];
+	struct software_node_ref_args tx_fault_ref[1];
+	struct software_node_ref_args tx_disable_ref[1];
+	struct software_node_ref_args mod_def0_ref[1];
+	struct software_node_ref_args los_ref[1];
+	struct software_node_ref_args rate_select0_ref[1];
+	struct software_node_ref_args sfp_ref[1];
+	struct software_node swnodes[SWNODE_MAX];
+	const struct software_node *group[SWNODE_MAX + 1];
+};
+
 struct lan743x_adapter {
 	struct net_device       *netdev;
 	struct mii_bus		*mdiobus;
@@ -1046,6 +1075,8 @@ struct lan743x_adapter {
 	u32			flags;
 	u32			hw_cfg;
 	phy_interface_t		phy_interface;
+	struct lan743x_sw_nodes	*nodes;
+	struct i2c_adapter	*i2c_adap;
 };
 
 #define LAN743X_COMPONENT_FLAG_RX(channel)  BIT(20 + (channel))
Signature · 1 line
2.25.1
#12 lore raw

PATCH 6/7 net: lan743x: Add support to ethtool phylink get and set settings

In reply to Raju Lakkaraju

Add support to ethtool phylink get/set settings for the network interface via ethtool like speed, duplex etc.

---
 .../net/ethernet/microchip/lan743x_ethtool.c  | 34 +++++++++++++++++--
 1 file changed, 32 insertions(+), 2 deletions(-)
drivers/net/ethernet/microchip/lan743x_ethtool.c +32 -2
index 2db5949b4c7e..3004863bebf8 100644
@@ -1134,6 +1134,36 @@ static int lan743x_ethtool_set_eee(struct net_device *netdev,
 	return phy_ethtool_set_eee(phydev, eee);
 }
 
+static int lan743x_ethtool_set_link_ksettings(struct net_device *netdev,
+					      const struct ethtool_link_ksettings *cmd)
+{
+	struct lan743x_adapter *adapter = netdev_priv(netdev);
+	int ret;
+
+	if (adapter->phylink) {
+		ret = lan743x_lsd_update(cmd->base.speed, cmd->base.duplex,
+					 cmd->base.master_slave_state);
+		if (ret < 0)
+			return ret;
+
+		adapter->sgmii_lsd = ret;
+		return phylink_ethtool_ksettings_set(adapter->phylink, cmd);
+	}
+
+	return phy_ethtool_set_link_ksettings(netdev, cmd);
+}
+
+static int lan743x_ethtool_get_link_ksettings(struct net_device *netdev,
+					      struct ethtool_link_ksettings *cmd)
+{
+	struct lan743x_adapter *adapter = netdev_priv(netdev);
+
+	if (adapter->phylink)
+		return phylink_ethtool_ksettings_get(adapter->phylink, cmd);
+
+	return phy_ethtool_get_link_ksettings(netdev, cmd);
+}
+
 #ifdef CONFIG_PM
 static void lan743x_ethtool_get_wol(struct net_device *netdev,
 				    struct ethtool_wolinfo *wol)
@@ -1400,8 +1430,8 @@ const struct ethtool_ops lan743x_ethtool_ops = {
 	.get_ts_info = lan743x_ethtool_get_ts_info,
 	.get_eee = lan743x_ethtool_get_eee,
 	.set_eee = lan743x_ethtool_set_eee,
-	.get_link_ksettings = phy_ethtool_get_link_ksettings,
-	.set_link_ksettings = phy_ethtool_set_link_ksettings,
+	.get_link_ksettings = lan743x_ethtool_get_link_ksettings,
+	.set_link_ksettings = lan743x_ethtool_set_link_ksettings,
 	.get_regs_len = lan743x_get_regs_len,
 	.get_regs = lan743x_get_regs,
 	.get_pauseparam = lan743x_get_pauseparam,
Signature · 1 line
2.25.1
#6 lore raw

PATCH 5/7 net: lan743x: Add support to the Phylink framework

In reply to Raju Lakkaraju

The phylink framework will be helpful in the future for boards using this controller with SFP cages.

---
 drivers/net/ethernet/microchip/Kconfig        |   2 +-
 drivers/net/ethernet/microchip/lan743x_main.c | 314 +++++++++++++++++-
 drivers/net/ethernet/microchip/lan743x_main.h |   6 +
 3 files changed, 314 insertions(+), 8 deletions(-)
drivers/net/ethernet/microchip/Kconfig +1 -1
index b1d361b412d1..1c947e3437b7 100644
@@ -46,7 +46,7 @@ config LAN743X
 	tristate "LAN743x support"
 	depends on PCI
 	depends on PTP_1588_CLOCK_OPTIONAL
-	select FIXED_PHY
+	select PHYLINK
 	select CRC16
 	select CRC32
 	select I2C_PCI1XXXX
drivers/net/ethernet/microchip/lan743x_main.c +307 -7

374 lines not on this page · raw message

drivers/net/ethernet/microchip/lan743x_main.h +6 -0
index 7f1c5673bc61..6b94d0e93cbb 100644
@@ -6,6 +6,7 @@
 
 #include <linux/phy.h>
 #include <linux/property.h>
+#include <linux/phylink.h>
 #include "lan743x_ptp.h"
 
 #define DRIVER_AUTHOR   "Bryan Whitehead <[email protected]>"
@@ -317,6 +318,9 @@
 /* Vendor Specific SGMII MMD details */
 #define SR_VSMMD_PCS_ID1		0x0004
 #define SR_VSMMD_PCS_ID2		0x0005
+#define SR_MII_CTRL			MII_BMCR
+#define SR_MII_STS			MII_BMSR
+#define SR_MII_STS_LINK_STS_		BIT(2)
 #define SR_VSMMD_STS			0x0008
 #define SR_VSMMD_CTRL			0x0009
 
@@ -1077,6 +1081,8 @@ struct lan743x_adapter {
 	phy_interface_t		phy_interface;
 	struct lan743x_sw_nodes	*nodes;
 	struct i2c_adapter	*i2c_adap;
+	struct phylink		*phylink;
+	struct phylink_config	phylink_config;
 };
 
 #define LAN743X_COMPONENT_FLAG_RX(channel)  BIT(20 + (channel))
Signature · 1 line
2.25.1
#14 lore raw

PATCH 7/7 net: lan743x: Register the platform device for sfp pluggable module

In reply to Raju Lakkaraju

Add support for SFP pluggable module as platform device handle the GPIO input and output signals and i2c bus access the SFP EEPROM data.

---
 drivers/net/ethernet/microchip/lan743x_main.c | 39 +++++++++++++++++++
 drivers/net/ethernet/microchip/lan743x_main.h |  1 +
 2 files changed, 40 insertions(+)
drivers/net/ethernet/microchip/lan743x_main.c +39 -0
index 9b6326d035a8..2dd0965982fb 100644
@@ -17,6 +17,7 @@
 #include <linux/crc16.h>
 #include <linux/gpio/machine.h>
 #include <linux/i2c.h>
+#include <linux/platform_device.h>
 #include "../../../misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.h"
 #include "lan743x_main.h"
 #include "lan743x_ethtool.h"
@@ -3228,6 +3229,31 @@ static int lan743x_swnodes_register(struct lan743x_adapter *adapter)
 	return software_node_register_node_group(nodes->group);
 }
 
+static int lan743x_sfp_register(struct lan743x_adapter *adapter)
+{
+	struct pci_dev *pdev = adapter->pdev;
+	struct platform_device_info sfp_info;
+	struct platform_device *sfp_dev;
+
+	memset(&sfp_info, 0, sizeof(sfp_info));
+	sfp_info.parent = &adapter->pdev->dev;
+	sfp_info.fwnode = software_node_fwnode(adapter->nodes->group[SWNODE_SFP]);
+	sfp_info.name = "sfp";
+	sfp_info.id = (pdev->bus->number << 8) | pdev->devfn;
+	sfp_dev = platform_device_register_full(&sfp_info);
+	if (IS_ERR(sfp_dev)) {
+		netif_err(adapter, drv, adapter->netdev,
+			  "Failed to register SFP device\n");
+		return PTR_ERR(sfp_dev);
+	}
+
+	adapter->sfp_dev = sfp_dev;
+	netif_dbg(adapter, drv, adapter->netdev,
+		  "SFP platform device registered");
+
+	return 0;
+}
+
 static void lan743x_mac_cfg_update(struct lan743x_adapter *adapter, bool link,
 				   int speed, const unsigned long *advertise)
 {
@@ -3715,6 +3741,9 @@ static void lan743x_hardware_cleanup(struct lan743x_adapter *adapter)
 	if (adapter->phylink)
 		phylink_destroy(adapter->phylink);
 
+	if (adapter->sfp_dev)
+		platform_device_unregister(adapter->sfp_dev);
+
 	if (adapter->nodes)
 		software_node_unregister_node_group(adapter->nodes->group);
 
@@ -3942,6 +3971,16 @@ static int lan743x_pcidev_probe(struct pci_dev *pdev,
 	adapter->sgmii_lsd = LINK_2500_MASTER;
 
 	if (adapter->is_sfp_support_en) {
+		adapter->i2c_adap->dev.fwnode =
+			software_node_fwnode(adapter->nodes->group[SWNODE_I2C]);
+
+		ret = lan743x_sfp_register(adapter);
+		if (ret < 0) {
+			netif_err(adapter, probe, netdev,
+				  "failed to sfp register (%d)\n", ret);
+			goto cleanup_hardware;
+		}
+
 		ret = lan743x_phylink_create(adapter->netdev);
 		if (ret) {
 			netif_err(adapter, probe, netdev,
drivers/net/ethernet/microchip/lan743x_main.h +1 -0
index 6b94d0e93cbb..d23cf1ca888c 100644
@@ -1083,6 +1083,7 @@ struct lan743x_adapter {
 	struct i2c_adapter	*i2c_adap;
 	struct phylink		*phylink;
 	struct phylink_config	phylink_config;
+	struct platform_device	*sfp_dev;
 };
 
 #define LAN743X_COMPONENT_FLAG_RX(channel)  BIT(20 + (channel))
Signature · 1 line
2.25.1
#7 lore raw

Re: [PATCH net-next 5/7] net: lan743x: Add support to the Phylink framework

In reply to Raju Lakkaraju

drivers/net/ethernet/microchip/lan743x_main.c static int lan743x_swnodes_register(struct lan743x_adapter *adapter) · line 3276

Quoted 11 lines · Raju Lakkaraju
drivers/net/ethernet/microchip/lan743x_main.c +11 -0
+static void lan743x_phylink_mac_config(struct phylink_config *config,
+				       unsigned int link_an_mode,
+				       const struct phylink_link_state *state)
+{
+	struct net_device *netdev = to_net_dev(config->dev);
+	struct lan743x_adapter *adapter = netdev_priv(netdev);
+	bool status;
+	int ret;
+
+	lan743x_mac_cfg_update(adapter, state->link, state->speed,
+			       state->advertising);

Please, no new state->speed users in mac_config().

Quoted 21 lines
drivers/net/ethernet/microchip/lan743x_main.c +21 -0
+
+	if (!state->link && adapter->is_sgmii_en) {
+		ret = lan743x_sgmii_aneg_update(adapter);
+		if (ret < 0) {
+			netif_err(adapter, drv, adapter->netdev,
+				  "error %d SGMII cfg failed\n", ret);
+			return;
+		}
+
+		ret = lan743x_is_sgmii_2_5G_mode(adapter, &status);
+		if (ret < 0) {
+			netif_err(adapter, drv, adapter->netdev,
+				  "erro %d SGMII get mode failed\n", ret);
+			return;
+		}
+
+		if (status)
+			netif_dbg(adapter, drv, adapter->netdev,
+				  "SGMII 2.5G mode enable\n");
+		else
+			netif_dbg(adapter, drv, adapter->netdev,

drivers/net/ethernet/microchip/lan743x_main.c static int lan743x_swnodes_register(struct lan743x_adapter *adapter) · line 3307

Quoted 10 lines
drivers/net/ethernet/microchip/lan743x_main.c +10 -0
+				  "SGMII 1G mode enable\n");
+
+		ret = lan743x_pcs_power_reset(adapter);
+		if (ret < 0) {
+			netif_err(adapter, drv, adapter->netdev,
+				  "error %d pcs power reset failed\n", ret);
+			return;
+		}
+
+		phylink_mac_change(adapter->phylink, state->link);

Sorry but no, this is not what the function is for.

Quoted 8 lines
drivers/net/ethernet/microchip/lan743x_main.c +8 -0
+	}
+}
+
+static void lan743x_phylink_mac_link_down(struct phylink_config *config,
+					  unsigned int link_an_mode,
+					  phy_interface_t interface)
+{
+	netif_tx_stop_all_queues(to_net_dev(config->dev));

drivers/net/ethernet/microchip/lan743x_main.c static int lan743x_swnodes_register(struct lan743x_adapter *adapter) · line 3325

Quoted 10 lines
drivers/net/ethernet/microchip/lan743x_main.c +10 -0
+}
+
+static void lan743x_phylink_mac_link_up(struct phylink_config *config,
+					struct phy_device *phydev,
+					unsigned int link_an_mode,
+					phy_interface_t interface,
+					int speed, int duplex,
+					bool tx_pause, bool rx_pause)
+{
+	netif_tx_wake_all_queues(to_net_dev(config->dev));

Also rubbish. This is where you're supposed to be configuring the hardware for the results of negotiation. It seems to me to be a complete waste of time writing phylink documentation when rubbish like this gets submitted.

Quoted 84 lines
drivers/net/ethernet/microchip/lan743x_main.c +84 -0
+}
+
+static void lan743x_phylink_mac_pcs_get_state(struct phylink_config *config,
+					      struct phylink_link_state *state)
+{
+	struct net_device *netdev = to_net_dev(config->dev);
+	struct lan743x_adapter *adapter = netdev_priv(netdev);
+	int intr_sts;
+	int wait_cnt;
+	bool status;
+	int mii_sts;
+	bool link;
+	int ret;
+
+	wait_cnt = 0;
+	link = false;
+	while (wait_cnt++ < 10) {
+		mii_sts = lan743x_sgmii_read(adapter, MDIO_MMD_VEND2, MII_BMSR);
+		if (mii_sts < 0) {
+			netif_err(adapter, drv, adapter->netdev,
+				  "erro %d MMD VEND2 MII BMSR read failed\n",
+				   mii_sts);
+			return;
+		}
+
+		mii_sts = lan743x_sgmii_read(adapter, MDIO_MMD_VEND2, MII_BMSR);
+		if (mii_sts < 0) {
+			netif_err(adapter, drv, adapter->netdev,
+				  "erro %d MMD VEND2 MII BMSR read failed\n",
+				   mii_sts);
+			return;
+		}
+
+		if (mii_sts & SR_MII_STS_LINK_STS_) {
+			link = true;
+			break;
+		}
+
+		usleep_range(1000, 2000);
+	}
+
+	state->speed = SPEED_UNKNOWN;
+	state->duplex = DUPLEX_UNKNOWN;
+	if (link) {
+		int speed = SPEED_UNKNOWN;
+		int duplex = DUPLEX_UNKNOWN;
+
+		intr_sts = lan743x_sgmii_read(adapter, MDIO_MMD_VEND2,
+					      VR_MII_AN_INTR_STS);
+		if (intr_sts < 0) {
+			netif_err(adapter, drv, adapter->netdev,
+				  "erro %d VR_MII_AN_INTR_STS read failed\n",
+				  intr_sts);
+			return;
+		}
+
+		if ((intr_sts & VR_MII_AN_INTR_STS_SPEED_MASK_) !=
+		    VR_MII_AN_INTR_STS_SPEED_MASK_) {
+			if (intr_sts & VR_MII_AN_INTR_STS_1000_MBPS_)
+				speed = SPEED_1000;
+			else if (intr_sts & VR_MII_AN_INTR_STS_100_MBPS_)
+				speed = SPEED_100;
+			else
+				speed = SPEED_10;
+		}
+
+		if (intr_sts & VR_MII_AN_INTR_STS_FDX_)
+			duplex = DUPLEX_FULL;
+		else
+			duplex = DUPLEX_HALF;
+
+		ret = lan743x_is_sgmii_2_5G_mode(adapter, &status);
+		if (ret < 0) {
+			netif_err(adapter, drv, adapter->netdev,
+				  "erro %d SGMII get mode failed\n", ret);
+			return;
+		}
+
+		if (adapter->is_sgmii_en && status) {
+			state->speed = SPEED_2500;
+			state->duplex = DUPLEX_FULL;
+		} else if (adapter->is_sgmii_en) {
+			state->speed = speed;
+			state->duplex = duplex;

drivers/net/ethernet/microchip/lan743x_main.c static int lan743x_swnodes_register(struct lan743x_adapter *adapter) · line 3419

Quoted 10 lines
drivers/net/ethernet/microchip/lan743x_main.c +10 -0
+		}
+	}
+
+	state->link = link;
+
+	netif_dbg(adapter, drv, adapter->netdev,
+		  "Link: %s, Speed:%d, %s Duplex\n",
+		  state->link ? "Up" : "Down",
+		  state->speed, (state->duplex == DUPLEX_FULL ? "Full" :
+		  (state->duplex == DUPLEX_HALF ? "Half" : "Unknown")));

Please port to phylink_pcs.

Quoted 12 lines
drivers/net/ethernet/microchip/lan743x_main.c +12 -0
+}
+
+static const struct phylink_mac_ops lan743x_phylink_mac_ops = {
+	.validate = phylink_generic_validate,
+	.mac_config = lan743x_phylink_mac_config,
+	.mac_link_down = lan743x_phylink_mac_link_down,
+	.mac_link_up = lan743x_phylink_mac_link_up,
+	.mac_pcs_get_state = lan743x_phylink_mac_pcs_get_state,
+};
+
+static int lan743x_phylink_create(struct net_device *netdev)
+{

drivers/net/ethernet/microchip/lan743x_main.c static int lan743x_swnodes_register(struct lan743x_adapter *adapter) · line 3441

Quoted 10 lines
drivers/net/ethernet/microchip/lan743x_main.c +10 -0
+	struct lan743x_adapter *adapter = netdev_priv(netdev);
+	struct fwnode_handle *fwnode;
+	struct phylink *phylink;
+	int ret;
+
+	adapter->phylink_config.dev = &netdev->dev;
+	adapter->phylink_config.type = PHYLINK_NETDEV;
+	adapter->phylink_config.mac_managed_pm = true;
+	/* This driver makes use of state->speed in mac_config */
+	adapter->phylink_config.legacy_pre_march2020 = true;

Sorry, but no new users of legacy features.

Quoted 53 lines
drivers/net/ethernet/microchip/lan743x_main.c +49 -0
+
+	adapter->phylink_config.mac_capabilities = MAC_ASYM_PAUSE |
+		MAC_SYM_PAUSE | MAC_10 | MAC_100 | MAC_1000FD | MAC_2500FD;
+
+	/* Config serdes Interface */
+	lan743x_phy_interface_select(adapter);
+
+	if (adapter->is_sgmii_en) {
+		__set_bit(PHY_INTERFACE_MODE_SGMII,
+			  adapter->phylink_config.supported_interfaces);
+		__set_bit(PHY_INTERFACE_MODE_1000BASEX,
+			  adapter->phylink_config.supported_interfaces);
+		__set_bit(PHY_INTERFACE_MODE_2500BASEX,
+			  adapter->phylink_config.supported_interfaces);
+	}
+
+	fwnode = software_node_fwnode(adapter->nodes->group[SWNODE_PHYLINK]);
+	if (!fwnode)
+		return -ENODEV;
+
+	phylink = phylink_create(&adapter->phylink_config,
+				 fwnode,
+				 adapter->phy_interface,
+				 &lan743x_phylink_mac_ops);
+
+	if (IS_ERR(phylink)) {
+		ret = PTR_ERR(phylink);
+		netdev_err(netdev, "Could not create phylink (%pe)\n", phylink);
+		return ret;
+	}
+
+	adapter->phylink = phylink;
+	netdev_dbg(netdev, "lan743x phylink created");
+
+	return 0;
+}
+
+static int lan743x_phylink_connect(struct lan743x_adapter *adapter)
+{
+	phylink_start(adapter->phylink);
+
+	return 0;
+}
+
+static void lan743x_phylink_close(struct lan743x_adapter *adapter)
+{
+	phylink_stop(adapter->phylink);
+}
+
 static int lan743x_netdev_close(struct net_device *netdev)
 {
 	struct lan743x_adapter *adapter = netdev_priv(netdev);

drivers/net/ethernet/microchip/lan743x_main.c static int lan743x_netdev_close(struct net_device *netdev) · line 3507

Quoted 8 lines
drivers/net/ethernet/microchip/lan743x_main.c +4 -1
@@ -3234,7 +3501,10 @@ static int lan743x_netdev_close(struct net_device *netdev)
 
 	lan743x_ptp_close(adapter);
 
-	lan743x_phy_close(adapter);
+	if (adapter->phylink)
+		lan743x_phylink_close(adapter);
+	else
+		lan743x_phy_close(adapter);

Why this conditional? Why not go the full distance and do the conversion detailed in the phylink documentation from phylib to phylink?

Quoted 119 lines
drivers/net/ethernet/microchip/lan743x_main.c +35 -5
 	lan743x_mac_close(adapter);
 
@@ -3257,9 +3527,15 @@ static int lan743x_netdev_open(struct net_device *netdev)
 	if (ret)
 		goto close_intr;
 
-	ret = lan743x_phy_open(adapter);
-	if (ret)
-		goto close_mac;
+	if (adapter->phylink) {
+		ret = lan743x_phylink_connect(adapter);
+		if (ret)
+			goto close_mac;
+	} else {
+		ret = lan743x_phy_open(adapter);
+		if (ret)
+			goto close_mac;
+	}
 
 	ret = lan743x_ptp_open(adapter);
 	if (ret)
@@ -3294,7 +3570,10 @@ static int lan743x_netdev_open(struct net_device *netdev)
 	lan743x_ptp_close(adapter);
 
 close_phy:
-	lan743x_phy_close(adapter);
+	if (adapter->phylink)
+		lan743x_phylink_close(adapter);
+	else
+		lan743x_phy_close(adapter);
 
 close_mac:
 	lan743x_mac_close(adapter);
@@ -3323,10 +3602,16 @@ static netdev_tx_t lan743x_netdev_xmit_frame(struct sk_buff *skb,
 static int lan743x_netdev_ioctl(struct net_device *netdev,
 				struct ifreq *ifr, int cmd)
 {
+	struct lan743x_adapter *adapter = netdev_priv(netdev);
+
 	if (!netif_running(netdev))
 		return -EINVAL;
 	if (cmd == SIOCSHWTSTAMP)
 		return lan743x_ptp_ioctl(netdev, ifr, cmd);
+
+	if (adapter->phylink)
+		return phylink_mii_ioctl(adapter->phylink, ifr, cmd);
+
 	return phy_mii_ioctl(netdev->phydev, ifr, cmd);
 }
 
@@ -3427,6 +3712,9 @@ static void lan743x_hardware_cleanup(struct lan743x_adapter *adapter)
 	if (adapter->i2c_adap)
 		adapter->i2c_adap = NULL;
 
+	if (adapter->phylink)
+		phylink_destroy(adapter->phylink);
+
 	if (adapter->nodes)
 		software_node_unregister_node_group(adapter->nodes->group);
 
@@ -3650,9 +3938,21 @@ static int lan743x_pcidev_probe(struct pci_dev *pdev,
 	adapter->netdev->features = NETIF_F_SG | NETIF_F_TSO |
 				    NETIF_F_HW_CSUM | NETIF_F_RXCSUM;
 	adapter->netdev->hw_features = adapter->netdev->features;
+	/* Default Link-Speed-Duplex (LSD) state */
+	adapter->sgmii_lsd = LINK_2500_MASTER;
+
+	if (adapter->is_sfp_support_en) {
+		ret = lan743x_phylink_create(adapter->netdev);
+		if (ret) {
+			netif_err(adapter, probe, netdev,
+				  "failed to setup phylink (%d)\n", ret);
+			goto cleanup_hardware;
+		}
+	}
 
 	/* carrier off reporting is important to ethtool even BEFORE open */
-	netif_carrier_off(netdev);
+	if (!adapter->phylink)
+		netif_carrier_off(netdev);
 
 	ret = register_netdev(adapter->netdev);
 	if (ret < 0)
drivers/net/ethernet/microchip/lan743x_main.h +6 -0
index 7f1c5673bc61..6b94d0e93cbb 100644
@@ -6,6 +6,7 @@
 
 #include <linux/phy.h>
 #include <linux/property.h>
+#include <linux/phylink.h>
 #include "lan743x_ptp.h"
 
 #define DRIVER_AUTHOR   "Bryan Whitehead <[email protected]>"
@@ -317,6 +318,9 @@
 /* Vendor Specific SGMII MMD details */
 #define SR_VSMMD_PCS_ID1		0x0004
 #define SR_VSMMD_PCS_ID2		0x0005
+#define SR_MII_CTRL			MII_BMCR
+#define SR_MII_STS			MII_BMSR
+#define SR_MII_STS_LINK_STS_		BIT(2)
 #define SR_VSMMD_STS			0x0008
 #define SR_VSMMD_CTRL			0x0009
 
@@ -1077,6 +1081,8 @@ struct lan743x_adapter {
 	phy_interface_t		phy_interface;
 	struct lan743x_sw_nodes	*nodes;
 	struct i2c_adapter	*i2c_adap;
+	struct phylink		*phylink;
+	struct phylink_config	phylink_config;
 };
 
 #define LAN743X_COMPONENT_FLAG_RX(channel)  BIT(20 + (channel))
Signature · 1 line
2.25.1
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
#13 lore raw

Re: [PATCH net-next 6/7] net: lan743x: Add support to ethtool phylink get and set settings

In reply to Raju Lakkaraju
Quoted 19 lines · Raju Lakkaraju

Add support to ethtool phylink get/set settings for the network interface via ethtool like speed, duplex etc.

---
 .../net/ethernet/microchip/lan743x_ethtool.c  | 34 +++++++++++++++++--
 1 file changed, 32 insertions(+), 2 deletions(-)
drivers/net/ethernet/microchip/lan743x_ethtool.c +3 -0
index 2db5949b4c7e..3004863bebf8 100644
@@ -1134,6 +1134,36 @@ static int lan743x_ethtool_set_eee(struct net_device *netdev,
 	return phy_ethtool_set_eee(phydev, eee);
 }
 
+static int lan743x_ethtool_set_link_ksettings(struct net_device *netdev,
+					      const struct ethtool_link_ksettings *cmd)
+{

drivers/net/ethernet/microchip/lan743x_ethtool.c static int lan743x_ethtool_set_eee(struct net_device *netdev, · line 1149

Quoted 10 lines
drivers/net/ethernet/microchip/lan743x_ethtool.c +10 -0
+	struct lan743x_adapter *adapter = netdev_priv(netdev);
+	int ret;
+
+	if (adapter->phylink) {
+		ret = lan743x_lsd_update(cmd->base.speed, cmd->base.duplex,
+					 cmd->base.master_slave_state);
+		if (ret < 0)
+			return ret;
+
+		adapter->sgmii_lsd = ret;

I guess this is how you are hacking SGMII to do what you want - using the ethtool master_slave_state to control whether SGMII is operating as a "host" or a "PHY", and I would say it's a hack to make stuff work the way you want it to, so you can run SGMII over a DAC cable at speeds such as 100M. I really don't see what the point of that is.

In any case, doing this is buggy. You update state, and then call into phylink. What if phylink returns an error? You've updated the state which may take effect if the link goes up/down but maybe the settings were rejected by phylink.

Sorry, but no, this to me is a gross hack.

Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
#8 lore raw

Re: [PATCH net-next 5/7] net: lan743x: Add support to the Phylink framework

In reply to Russell King (Oracle)
Quoted 14 lines · Russell King (Oracle)

drivers/net/ethernet/microchip/lan743x_main.c static int lan743x_swnodes_register(struct lan743x_adapter *adapter) · line 3276

Quoted 11 lines · Raju Lakkaraju
drivers/net/ethernet/microchip/lan743x_main.c +11 -0
+static void lan743x_phylink_mac_config(struct phylink_config *config,
+				       unsigned int link_an_mode,
+				       const struct phylink_link_state *state)
+{
+	struct net_device *netdev = to_net_dev(config->dev);
+	struct lan743x_adapter *adapter = netdev_priv(netdev);
+	bool status;
+	int ret;
+
+	lan743x_mac_cfg_update(adapter, state->link, state->speed,
+			       state->advertising);

Please, no new state->speed users in mac_config().

I have just submitted a patch series that results in state->speed always being set to SPEED_UNKNOWN when this function is called to prevent future uses of this struct member.

Quoted 7 lines

drivers/net/ethernet/microchip/lan743x_main.c static int lan743x_swnodes_register(struct lan743x_adapter *adapter) · line 3441

Quoted 5 lines
drivers/net/ethernet/microchip/lan743x_main.c +5 -0
+	adapter->phylink_config.dev = &netdev->dev;
+	adapter->phylink_config.type = PHYLINK_NETDEV;
+	adapter->phylink_config.mac_managed_pm = true;
+	/* This driver makes use of state->speed in mac_config */
+	adapter->phylink_config.legacy_pre_march2020 = true;

Sorry, but no new users of legacy features.

... and which totally strips out the legacy phylink code, which I've been wanting to remove for the last three years.

Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
#2 lore raw

Re: [PATCH net-next 1/7] net: lan743x: Create separate PCS power reset function

In reply to Raju Lakkaraju
Quoted 12 lines · Raju Lakkaraju

Create separate PCS power reset function from lan743x_sgmii_config () to use as subroutine.

---
 drivers/net/ethernet/microchip/lan743x_main.c | 54 ++++++++++---------
 1 file changed, 29 insertions(+), 25 deletions(-)
drivers/net/ethernet/microchip/lan743x_main.c +0 -0
index a36f6369f132..dba5576a933b 100644

...

Quoted 23 lines

static int lan743x_sgmii_config(struct lan743x_adapter *adapter) {

drivers/net/ethernet/microchip/lan743x_main.c +0 -16
 	struct net_device *netdev = adapter->netdev;
@@ -1207,31 +1235,7 @@ static int lan743x_sgmii_config(struct lan743x_adapter *adapter)
 		netif_dbg(adapter, drv, adapter->netdev,
 			  "SGMII 1G mode enable\n");
 
-	/* SGMII/1000/2500BASE-X PCS power down */
-	mii_ctl = lan743x_sgmii_read(adapter, MDIO_MMD_VEND2, MII_BMCR);
-	if (mii_ctl < 0)
-		return mii_ctl;
-
-	mii_ctl |= BMCR_PDOWN;
-	ret = lan743x_sgmii_write(adapter, MDIO_MMD_VEND2, MII_BMCR, mii_ctl);
-	if (ret < 0)
-		return ret;
-
-	ret = lan743x_pcs_seq_state(adapter, PCS_POWER_STATE_DOWN);
-	if (ret < 0)
-		return ret;
-
-	/* SGMII/1000/2500BASE-X PCS power up */
-	mii_ctl &= ~BMCR_PDOWN;

drivers/net/ethernet/microchip/lan743x_main.c static int lan743x_sgmii_config(struct lan743x_adapter *adapter) · line 1238

Quoted 10 lines
drivers/net/ethernet/microchip/lan743x_main.c +1 -9
-	ret = lan743x_sgmii_write(adapter, MDIO_MMD_VEND2, MII_BMCR, mii_ctl);
-	if (ret < 0)
-		return ret;
-
-	ret = lan743x_pcs_seq_state(adapter, PCS_POWER_STATE_UP);
-	if (ret < 0)
-		return ret;
-
-	return 0;
+	return lan743x_pcs_power_reset(adapter);

Hi Raju,

It appears that the local variable mii_ctl is now unused in lan743x_sgmii_config() and can be removed.

Quoted 7 lines
drivers/net/ethernet/microchip/lan743x_main.c +0 -0
 }
 
 static void lan743x_mac_set_address(struct lan743x_adapter *adapter,
Signature · 1 line
2.25.1
#11 lore raw

Re: [PATCH net-next 5/7] net: lan743x: Add support to the Phylink framework

In reply to Raju Lakkaraju

On Fri, Jul 21, 2023 at 11:30:17AM +0530, Raju Lakkaraju wrote:

...

Quoted 7 lines
drivers/net/ethernet/microchip/lan743x_main.c +7 -0
+static void lan743x_phylink_mac_config(struct phylink_config *config,
+				       unsigned int link_an_mode,
+				       const struct phylink_link_state *state)
+{
+	struct net_device *netdev = to_net_dev(config->dev);
+	struct lan743x_adapter *adapter = netdev_priv(netdev);
+	bool status;

drivers/net/ethernet/microchip/lan743x_main.c static int lan743x_swnodes_register(struct lan743x_adapter *adapter) · line 3282

Quoted 10 lines
drivers/net/ethernet/microchip/lan743x_main.c +10 -0
+	int ret;
+
+	lan743x_mac_cfg_update(adapter, state->link, state->speed,
+			       state->advertising);
+
+	if (!state->link && adapter->is_sgmii_en) {
+		ret = lan743x_sgmii_aneg_update(adapter);
+		if (ret < 0) {
+			netif_err(adapter, drv, adapter->netdev,
+				  "error %d SGMII cfg failed\n", ret);

Hi Raju,

Maybe "error" is appropriate here and in other similar error messages in this patch.

Quoted 2 lines
(quoted diff) +2 -0
+			return;
+		}

...

#9 lore raw

Re: [PATCH net-next 5/7] net: lan743x: Add support to the Phylink framework

In reply to Russell King (Oracle)

Hi Russell King,

Thank you for review comments.

Quoted 18 lines · Russell King (Oracle)

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Quoted 14 lines · Russell King (Oracle)

drivers/net/ethernet/microchip/lan743x_main.c static int lan743x_swnodes_register(struct lan743x_adapter *adapter) · line 3276

Quoted 11 lines · Raju Lakkaraju
drivers/net/ethernet/microchip/lan743x_main.c +11 -0
+static void lan743x_phylink_mac_config(struct phylink_config *config,
+                                  unsigned int link_an_mode,
+                                  const struct phylink_link_state *state)
+{
+   struct net_device *netdev = to_net_dev(config->dev);
+   struct lan743x_adapter *adapter = netdev_priv(netdev);
+   bool status;
+   int ret;
+
+   lan743x_mac_cfg_update(adapter, state->link, state->speed,
+                          state->advertising);

Please, no new state->speed users in mac_config().

Quoted 3 lines

I have just submitted a patch series that results in state->speed always being set to SPEED_UNKNOWN when this function is called to prevent future uses of this struct member.

Still, these changes are not available in "net-next" branch. I will check and fix.

Quoted 15 lines
Quoted 8 lines

drivers/net/ethernet/microchip/lan743x_main.c static int lan743x_swnodes_register(struct lan743x_adapter *adapter) · line 3441

Quoted 6 lines
drivers/net/ethernet/microchip/lan743x_main.c +5 -0
+   adapter->phylink_config.dev = &netdev->dev;
+   adapter->phylink_config.type = PHYLINK_NETDEV;
+   adapter->phylink_config.mac_managed_pm = true;
+   /* This driver makes use of state->speed in mac_config */
+   adapter->phylink_config.legacy_pre_march2020 = true;

Sorry, but no new users of legacy features.

... and which totally strips out the legacy phylink code, which I've been wanting to remove for the last three years.

--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

Signature · 2 lines
Thanks,
Raju
#10 lore raw

Re: [PATCH net-next 5/7] net: lan743x: Add support to the Phylink framework

Quoted 8 lines · Raju Lakkaraju
Quoted 7 lines · Russell King (Oracle)

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Quoted 4 lines · Russell King (Oracle)
Quoted 2 lines · Raju Lakkaraju
drivers/net/ethernet/microchip/lan743x_main.c +2 -0
+   lan743x_mac_cfg_update(adapter, state->link, state->speed,
+                          state->advertising);
Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Please, no new state->speed users in mac_config().

I have just submitted a patch series that results in state->speed always being set to SPEED_UNKNOWN when this function is called to prevent future uses of this struct member.

Still, these changes are not available in "net-next" branch. I will check and fix.

The changes went in last week, which means phylink no longer supports the legacy mode stuff, nor use of the above.

Please respin your changes to use the modern approach.

Thanks.

Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!