Add support to PHYLINK and SFP for PCI11x1x chips
Subsystems (3)
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. Mellanox DAC10G SFP (MC3309130-001) at 2.5 Gbps speed (interface 2500Base-X) and 1Gpbs speed (interface 1000Base-X)
3. Axcen's 1G SFP (AXGT-R1T4-05I1) at 1G/100M/10M bps speed (interface SGMII)
4. Fiber 1G SFP (AXGE-1354-0531) at 1Gpbs speed (interface 1000Base-X)
Change Log:
===========
V0 -> V1:
- Integrate with Synopsys DesignWare XPCS drivers
- Based on external review comments,
- Changes made to SGMII interface support only 1G/100M/10M bps speed
- Changes made to 2500Base-X interface support only 2.5Gbps speed
- Add check for not is_sgmii_en with is_sfp_support_en support
- Change the "pci11x1x_strap_get_status" function return type from void to int
- Add ethtool phylink wol, eee, pause get/set functions
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: Register the platform device for sfp pluggable module
net: lan743x: Add support to the phylink framework
net: lan743x: Add support to ethtool phylink get and set settings
drivers/net/ethernet/microchip/Kconfig | 9 +- .../net/ethernet/microchip/lan743x_ethtool.c | 85 +- drivers/net/ethernet/microchip/lan743x_main.c | 1090 ++++++++++++----- drivers/net/ethernet/microchip/lan743x_main.h | 49 + 4 files changed, 868 insertions(+), 365 deletions(-)
Signature · 1 line
2.34.1
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 | 55 ++++++++++--------- 1 file changed, 29 insertions(+), 26 deletions(-)
drivers/net/ethernet/microchip/lan743x_main.c +29 -26
@@ -1145,12 +1145,39 @@ 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;struct phy_device *phydev = netdev->phydev;enum lan743x_sgmii_lsd lsd =POWER_DOWN ; -int mii_ctl;bool status;int ret;
@@ -1207,31 +1234,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.34.1
PATCH 2/7 net: lan743x: Create separate Link Speed Duplex state function
In reply to Raju LakkarajuCreate separate Link Speed Duplex (LSD) update state function from lan743x_sgmii_config () to use as subroutine.
--- drivers/net/ethernet/microchip/lan743x_main.c | 75 +++++++++++-------- 1 file changed, 45 insertions(+), 30 deletions(-)
drivers/net/ethernet/microchip/lan743x_main.c +45 -30
@@ -990,6 +990,42 @@ static int lan743x_sgmii_write(struct lan743x_adapter *adapter,return ret; } +static int lan743x_get_lsd (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,42 +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 ;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_get_lsd (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,
Signature · 1 line
2.34.1
PATCH 3/7 net: lan743x: Add SFP support check flag
In reply to Raju LakkarajuPCI11x1x 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 | 27 ++++++++++++++++--- drivers/net/ethernet/microchip/lan743x_main.h | 3 +++ 2 files changed, 27 insertions(+), 3 deletions(-)
drivers/net/ethernet/microchip/lan743x_main.c +24 -3
@@ -25,7 +25,7 @@#define PCS_POWER_STATE_DOWN 0x6#define PCS_POWER_STATE_UP 0x4 -static void pci11x1x_strap_get_status (struct lan743x_adapter *adapter) +static int pci11x1x_strap_get_status (struct lan743x_adapter *adapter) {u32 chip_rev;u32 cfg_load;
@@ -38,7 +38,7 @@ static void pci11x1x_strap_get_status(struct lan743x_adapter *adapter)if (ret <0 ) {netif_err (adapter, drv, adapter->netdev,"Sys Lock acquire failed ret:%d\n" , ret); -return ; +return ret; } cfg_load =lan743x_csr_read (adapter,ETH_SYS_CONFIG_LOAD_STARTED_REG );
@@ -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,21 @@ static void pci11x1x_strap_get_status(struct lan743x_adapter *adapter) adapter->is_sgmii_en = false; } } + +if (adapter->is_pci11x1x && !adapter->is_sgmii_en && + adapter->is_sfp_support_en) { +netif_err (adapter, drv, adapter->netdev, +"Invalid eeprom sgmii support configuration\n" ); +return -EINVAL ; + } +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" ); + +return 0 ; }static bool is_pci11x1x_chip (struct lan743x_adapter *adapter)
@@ -3259,7 +3277,9 @@ static int lan743x_hardware_init(struct lan743x_adapter *adapter, adapter->max_tx_channels =PCI11X1X_MAX_TX_CHANNELS ; adapter->used_tx_channels =PCI11X1X_USED_TX_CHANNELS ; adapter->max_vector_count =PCI11X1X_MAX_VECTOR_COUNT ; -pci11x1x_strap_get_status (adapter); + ret =pci11x1x_strap_get_status (adapter); +if (ret <0 ) +return ret;spin_lock_init (&adapter->eth_syslock_spinlock);mutex_init (&adapter->sgmii_rw_lock); }else {
@@ -3414,6 +3434,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
@@ -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.34.1
PATCH 4/7 net: lan743x: Add support to software-nodes for sfp and phylink
In reply to Raju LakkarajuRegister software nodes and define the device properties. software-node contains following properties.
- gpio pin details
- i2c bus information
- sfp signals
- phylink mode
--- drivers/net/ethernet/microchip/Kconfig | 5 +- drivers/net/ethernet/microchip/lan743x_main.c | 235 +++++++++++++++++- drivers/net/ethernet/microchip/lan743x_main.h | 36 +++ 3 files changed, 272 insertions(+), 4 deletions(-)
drivers/net/ethernet/microchip/Kconfig +4 -1
@@ -50,8 +50,11 @@ 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 + Support for the Microchip LAN743x and PCI11x1x families of PCI + Express Ethernet devices To compile this driver as a module, choose M here. The module will be called lan743x.
drivers/net/ethernet/microchip/lan743x_main.c +232 -3
271 lines not on this page · raw message
drivers/net/ethernet/microchip/lan743x_main.h +36 -0
@@ -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,39 @@ enum lan743x_sgmii_lsd {LINK_2500_SLAVE }; +enum lan743x_swnodes { +SWNODE_GPIO =0 , +SWNODE_I2C , +SWNODE_SFP , +SWNODE_PHYLINK , +SWNODE_MAX +}; + +#define I2C_DRV_NAME 48 +#define GPIO_DRV_NAME 32 +#define SFP_NODE_NAME 32 +#define PHYLINK_NODE_NAME 32 + +struct lan743x_sw_nodes { +char gpio_name[GPIO_DRV_NAME ]; +char i2c_name[I2C_DRV_NAME ]; +char sfp_name[SFP_NODE_NAME ]; +char phylink_name[PHYLINK_NODE_NAME ]; +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_sel0_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 +1080,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.34.1
PATCH 5/7 net: lan743x: Register the platform device for sfp pluggable module
In reply to Raju LakkarajuAdd 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/Kconfig | 2 +- drivers/net/ethernet/microchip/lan743x_main.c | 41 +++++++++++++++++++ drivers/net/ethernet/microchip/lan743x_main.h | 1 + 3 files changed, 43 insertions(+), 1 deletion(-)
drivers/net/ethernet/microchip/Kconfig +1 -1
@@ -46,12 +46,12 @@ config LAN743X tristate "LAN743x support" depends on PCI depends on PTP_1588_CLOCK_OPTIONAL - select PHYLIB select FIXED_PHY select CRC16 select CRC32 select I2C_PCI1XXXX select GP_PCI1XXXX + select SFP help Support for the Microchip LAN743x and PCI11x1x families of PCI Express Ethernet devices
drivers/net/ethernet/microchip/lan743x_main.c +41 -0
65 lines not on this page · raw message
drivers/net/ethernet/microchip/lan743x_main.h +1 -0
@@ -1082,6 +1082,7 @@ struct lan743x_adapter {phy_interface_t phy_interface;struct lan743x_sw_nodes *nodes;struct i2c_adapter *i2c_adap; +struct platform_device *sfp_dev; };#define LAN743X_COMPONENT_FLAG_RX (channel) BIT(20 + (channel))
Signature · 1 line
2.34.1
PATCH 6/7 net: lan743x: Add support to the phylink framework
In reply to Raju LakkarajuPhylink framework is added since it is required for sfp support of PCI11x1x boards with sfp cages
---
Change Log:
===========
V0 -> V1:
- Remove the phylib functions and support the phylink fully
drivers/net/ethernet/microchip/Kconfig | 2 + drivers/net/ethernet/microchip/lan743x_main.c | 741 +++++++++++------- drivers/net/ethernet/microchip/lan743x_main.h | 9 + 3 files changed, 460 insertions(+), 292 deletions(-)
drivers/net/ethernet/microchip/Kconfig +2 -0
@@ -52,6 +52,8 @@ config LAN743X select I2C_PCI1XXXX select GP_PCI1XXXX select SFP + select PCS_XPCS + select PHYLINK help Support for the Microchip LAN743x and PCI11x1x families of PCI Express Ethernet devices
drivers/net/ethernet/microchip/lan743x_main.c +449 -292
880 lines not on this page · raw message
drivers/net/ethernet/microchip/lan743x_main.h +9 -0
@@ -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
@@ -1083,6 +1087,9 @@ struct lan743x_adapter {struct lan743x_sw_nodes *nodes;struct i2c_adapter *i2c_adap;struct platform_device *sfp_dev; +struct dw_xpcs *xpcs; +struct phylink *phylink; +struct phylink_config phylink_config; };#define LAN743X_COMPONENT_FLAG_RX (channel) BIT(20 + (channel))
@@ -1203,5 +1210,7 @@ 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); +void lan743x_mac_cfg_update (struct lan743x_adapter *adapter,bool link, +int speed,const unsigned long *advertise);#endif /* _LAN743X_H */
Signature · 1 line
2.34.1
Re: [PATCH net-next V1 6/7] net: lan743x: Add support to the phylink framework
drivers/net/ethernet/microchip/lan743x_main.c static int lan743x_sfp_register(struct lan743x_adapter *adapter) · line 3183
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);
Another case of not reading the phylink documentation... :( I *really* don't see why we bother to write documentation, from my experience, it seems to be totally a write-only thing... no one seems to bother reading it.
/**
* mac_config() - configure the MAC for the selected mode and state
* @config: a pointer to a &struct phylink_config.
* @mode: one of %MLO_AN_FIXED, %MLO_AN_PHY, %MLO_AN_INBAND.
* @state: a pointer to a &struct phylink_link_state.
*
* Note - not all members of @state are valid. In particular,
* @state->lp_advertising, @state->link, @state->an_complete are never
* guaranteed to be correct, and so any mac_config() implementation must
* never reference these fields.
...
* The action performed depends on the currently selected mode:
*
* %MLO_AN_FIXED, %MLO_AN_PHY:
...
* Valid state members: interface, advertising.
* Deprecated state members: speed, duplex, pause.
...
* %MLO_AN_INBAND:
...
* Valid state members: interface, an_enabled, pause, advertising.
So "link" and "speed" are not valid. They're certainly not valid now that the pre-March 2020 legacy support has been removed.
The only time that you get to know what speed the link is operating at is after the link has been negotiated and is up - and you will be told via the mac_link_up() function (or in the case of a PCS, via the pcs_link_up() function.) You can't know before that point what speed the link will be operating at because its dependent on the results of link negotiation.
I haven't bothered to look more deeply at this patch, because I regard any patch that gets this wrong to be utter trash (sorry that's a bit hard, but I see people not bothering to read documentation all too often and it pisses me off that I've gone to the bother of writing it and it just gets ignored.)
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!
PATCH 7/7 net: lan743x: Add support to ethtool phylink get and set settings
In reply to Raju LakkarajuAdd support to ethtool phylink functions:
- get/set settings like speed, duplex etc.
- get/set the wake-on-lan (WOL)
- get/set the energy-efficient ethernet (EEE)
- get/set the pause
---
Change Log:
===========
V0 -> V1:
- Remove the phylib ethtool functions and support the phylink ethtool
.../net/ethernet/microchip/lan743x_ethtool.c | 85 ++++++++----------- 1 file changed, 34 insertions(+), 51 deletions(-)
drivers/net/ethernet/microchip/lan743x_ethtool.c +34 -51
@@ -1055,19 +1055,10 @@ static int lan743x_ethtool_get_eee(struct net_device *netdev, struct ethtool_eee *eee) {struct lan743x_adapter *adapter =netdev_priv (netdev); -struct phy_device *phydev = netdev->phydev;u32 buf;int ret; -if (!phydev) -return -EIO ; -if (!phydev->drv) { -netif_err (adapter, drv, adapter->netdev, -"Missing PHY Driver\n" ); -return -EIO ; - } - - ret =phy_ethtool_get_eee (phydev, eee); + ret =phylink_ethtool_get_eee (adapter->phylink, eee);if (ret <0 )return ret;
@@ -1093,32 +1084,15 @@ static int lan743x_ethtool_set_eee(struct net_device *netdev, struct ethtool_eee *eee) {struct lan743x_adapter *adapter; -struct phy_device *phydev;u32 buf =0 ; -int ret =0 ;if (!netdev)return -EINVAL ; adapter =netdev_priv (netdev);if (!adapter)return -EINVAL ; - phydev = netdev->phydev; -if (!phydev) -return -EIO ; -if (!phydev->drv) { -netif_err (adapter, drv, adapter->netdev, -"Missing PHY Driver\n" ); -return -EIO ; - }if (eee->eee_enabled) { - ret =phy_init_eee (phydev, false); -if (ret) { -netif_err (adapter, drv, adapter->netdev, -"EEE initialization failed\n" ); -return ret; - } - buf = (u32 )eee->tx_lpi_timer;lan743x_csr_write (adapter,MAC_EEE_TX_LPI_REQ_DLY_CNT , buf);
@@ -1131,7 +1105,23 @@ static int lan743x_ethtool_set_eee(struct net_device *netdev,lan743x_csr_write (adapter,MAC_CR , buf); } -return phy_ethtool_set_eee (phydev, eee); +return phylink_ethtool_set_eee (adapter->phylink, 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); + +return phylink_ethtool_ksettings_set (adapter->phylink, cmd); +} + +static int lan743x_ethtool_get_link_ksettings (struct net_device *netdev, +struct ethtool_link_ksettings *cmd) +{ +struct lan743x_adapter *adapter =netdev_priv (netdev); + +return phylink_ethtool_ksettings_get (adapter->phylink, cmd); }#ifdef CONFIG_PM
@@ -1143,8 +1133,7 @@ static void lan743x_ethtool_get_wol(struct net_device *netdev, wol->supported =0 ; wol->wolopts =0 ; -if (netdev->phydev) -phy_ethtool_get_wol (netdev->phydev, wol); +phylink_ethtool_get_wol (adapter->phylink, wol); wol->supported |=WAKE_BCAST |WAKE_UCAST |WAKE_MCAST |WAKE_MAGIC |WAKE_PHY |WAKE_ARP ;
@@ -1161,8 +1150,18 @@ static int lan743x_ethtool_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) {struct lan743x_adapter *adapter =netdev_priv (netdev); +int ret; adapter->wolopts =0 ; + +/* Pass the order to phylink layer */ + ret =phylink_ethtool_set_wol (adapter->phylink, wol); +/* Don't manage WoL on MAC if handled by the PHY +* or if there's a failure in talking to the PHY +*/ +if (!ret || ret != -EOPNOTSUPP ) +return ret; +if (wol->wolopts &WAKE_UCAST ) adapter->wolopts |=WAKE_UCAST ;if (wol->wolopts &WAKE_MCAST )
@@ -1185,8 +1184,7 @@ static int lan743x_ethtool_set_wol(struct net_device *netdev,device_set_wakeup_enable (&adapter->pdev->dev, (bool )wol->wolopts); -return netdev->phydev ?phy_ethtool_set_wol (netdev->phydev, wol) - : -ENETDOWN; + return 0; }#endif /* CONFIG_PM */
@@ -1342,28 +1340,16 @@ static void lan743x_get_pauseparam(struct net_device *dev, struct ethtool_pauseparam *pause) {struct lan743x_adapter *adapter =netdev_priv (dev); -struct lan743x_phy *phy = &adapter->phy; -if (phy->fc_request_control &FLOW_CTRL_TX ) - pause->tx_pause =1 ; -if (phy->fc_request_control &FLOW_CTRL_RX ) - pause->rx_pause =1 ; - pause->autoneg = phy->fc_autoneg; +phylink_ethtool_get_pauseparam (adapter->phylink, pause); }static int lan743x_set_pauseparam (struct net_device *dev,struct ethtool_pauseparam *pause) {struct lan743x_adapter *adapter =netdev_priv (dev); -struct phy_device *phydev = dev->phydev;struct lan743x_phy *phy = &adapter->phy; -if (!phydev) -return -ENODEV ; - -if (!phy_validate_pause (phydev, pause)) -return -EINVAL ; - phy->fc_request_control =0 ;if (pause->rx_pause) phy->fc_request_control |=FLOW_CTRL_RX ;
@@ -1376,10 +1362,7 @@ static int lan743x_set_pauseparam(struct net_device *dev,if (pause->autoneg ==AUTONEG_DISABLE )lan743x_mac_flow_ctrl_set_enables (adapter, pause->tx_pause, pause->rx_pause); -else -phy_set_asym_pause (phydev, pause->rx_pause, pause->tx_pause); - -return 0 ; +return phylink_ethtool_set_pauseparam (adapter->phylink, pause); }const struct ethtool_ops lan743x_ethtool_ops = {
@@ -1404,8 +1387,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.34.1