Skip to content

Commit bd691d5

Browse files
Russell King (Oracle)kuba-moo
authored andcommitted
net: lan743x: convert to phylink managed EEE
Convert lan743x to phylink managed EEE: - Set the lpi_capabilties. - Move the call to lan743x_mac_eee_enable() into the enable/disable tx_lpi functions. - Ensure that EEEEN is clear during probe. - Move the setting of the LPI timer into mac_enable_tx_lpi(). - Move reading of LPI timer to phylink initialisation to set the default timer value. Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> Reviewed-by: Jacob Keller <jacob.e.keller@intel.com> Link: https://patch.msgid.link/E1tYAEB-0014QB-4s@rmk-PC.armlinux.org.uk Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent a664479 commit bd691d5

File tree

3 files changed

+38
-28
lines changed

3 files changed

+38
-28
lines changed

drivers/net/ethernet/microchip/lan743x_ethtool.c

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,34 +1055,13 @@ static int lan743x_ethtool_get_eee(struct net_device *netdev,
10551055
{
10561056
struct lan743x_adapter *adapter = netdev_priv(netdev);
10571057

1058-
eee->tx_lpi_timer = lan743x_csr_read(adapter,
1059-
MAC_EEE_TX_LPI_REQ_DLY_CNT);
1060-
10611058
return phylink_ethtool_get_eee(adapter->phylink, eee);
10621059
}
10631060

10641061
static int lan743x_ethtool_set_eee(struct net_device *netdev,
10651062
struct ethtool_keee *eee)
10661063
{
10671064
struct lan743x_adapter *adapter = netdev_priv(netdev);
1068-
u32 tx_lpi_timer;
1069-
1070-
tx_lpi_timer = lan743x_csr_read(adapter, MAC_EEE_TX_LPI_REQ_DLY_CNT);
1071-
if (tx_lpi_timer != eee->tx_lpi_timer) {
1072-
u32 mac_cr = lan743x_csr_read(adapter, MAC_CR);
1073-
1074-
/* Software should only change this field when Energy Efficient
1075-
* Ethernet Enable (EEEEN) is cleared.
1076-
* This function will trigger an autonegotiation restart and
1077-
* eee will be reenabled during link up if eee was negotiated.
1078-
*/
1079-
lan743x_mac_eee_enable(adapter, false);
1080-
lan743x_csr_write(adapter, MAC_EEE_TX_LPI_REQ_DLY_CNT,
1081-
eee->tx_lpi_timer);
1082-
1083-
if (mac_cr & MAC_CR_EEE_EN_)
1084-
lan743x_mac_eee_enable(adapter, true);
1085-
}
10861065

10871066
return phylink_ethtool_set_eee(adapter->phylink, eee);
10881067
}

drivers/net/ethernet/microchip/lan743x_main.c

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2966,7 +2966,7 @@ static int lan743x_phylink_2500basex_config(struct lan743x_adapter *adapter)
29662966
return lan743x_pcs_power_reset(adapter);
29672967
}
29682968

2969-
void lan743x_mac_eee_enable(struct lan743x_adapter *adapter, bool enable)
2969+
static void lan743x_mac_eee_enable(struct lan743x_adapter *adapter, bool enable)
29702970
{
29712971
u32 mac_cr;
29722972

@@ -3027,10 +3027,8 @@ static void lan743x_phylink_mac_link_down(struct phylink_config *config,
30273027
phy_interface_t interface)
30283028
{
30293029
struct net_device *netdev = to_net_dev(config->dev);
3030-
struct lan743x_adapter *adapter = netdev_priv(netdev);
30313030

30323031
netif_tx_stop_all_queues(netdev);
3033-
lan743x_mac_eee_enable(adapter, false);
30343032
}
30353033

30363034
static void lan743x_phylink_mac_link_up(struct phylink_config *config,
@@ -3072,16 +3070,40 @@ static void lan743x_phylink_mac_link_up(struct phylink_config *config,
30723070
cap & FLOW_CTRL_TX,
30733071
cap & FLOW_CTRL_RX);
30743072

3075-
if (phydev)
3076-
lan743x_mac_eee_enable(adapter, phydev->enable_tx_lpi);
3077-
30783073
netif_tx_wake_all_queues(netdev);
30793074
}
30803075

3076+
static void lan743x_mac_disable_tx_lpi(struct phylink_config *config)
3077+
{
3078+
struct net_device *netdev = to_net_dev(config->dev);
3079+
struct lan743x_adapter *adapter = netdev_priv(netdev);
3080+
3081+
lan743x_mac_eee_enable(adapter, false);
3082+
}
3083+
3084+
static int lan743x_mac_enable_tx_lpi(struct phylink_config *config, u32 timer,
3085+
bool tx_clk_stop)
3086+
{
3087+
struct net_device *netdev = to_net_dev(config->dev);
3088+
struct lan743x_adapter *adapter = netdev_priv(netdev);
3089+
3090+
/* Software should only change this field when Energy Efficient
3091+
* Ethernet Enable (EEEEN) is cleared. We ensure that by clearing
3092+
* EEEEN during probe, and phylink itself guarantees that
3093+
* mac_disable_tx_lpi() will have been previously called.
3094+
*/
3095+
lan743x_csr_write(adapter, MAC_EEE_TX_LPI_REQ_DLY_CNT, timer);
3096+
lan743x_mac_eee_enable(adapter, true);
3097+
3098+
return 0;
3099+
}
3100+
30813101
static const struct phylink_mac_ops lan743x_phylink_mac_ops = {
30823102
.mac_config = lan743x_phylink_mac_config,
30833103
.mac_link_down = lan743x_phylink_mac_link_down,
30843104
.mac_link_up = lan743x_phylink_mac_link_up,
3105+
.mac_disable_tx_lpi = lan743x_mac_disable_tx_lpi,
3106+
.mac_enable_tx_lpi = lan743x_mac_enable_tx_lpi,
30853107
};
30863108

30873109
static int lan743x_phylink_create(struct lan743x_adapter *adapter)
@@ -3095,6 +3117,9 @@ static int lan743x_phylink_create(struct lan743x_adapter *adapter)
30953117

30963118
adapter->phylink_config.mac_capabilities = MAC_ASYM_PAUSE |
30973119
MAC_SYM_PAUSE | MAC_10 | MAC_100 | MAC_1000FD;
3120+
adapter->phylink_config.lpi_capabilities = MAC_100FD | MAC_1000FD;
3121+
adapter->phylink_config.lpi_timer_default =
3122+
lan743x_csr_read(adapter, MAC_EEE_TX_LPI_REQ_DLY_CNT);
30983123

30993124
lan743x_phy_interface_select(adapter);
31003125

@@ -3120,6 +3145,10 @@ static int lan743x_phylink_create(struct lan743x_adapter *adapter)
31203145
phy_interface_set_rgmii(adapter->phylink_config.supported_interfaces);
31213146
}
31223147

3148+
memcpy(adapter->phylink_config.lpi_interfaces,
3149+
adapter->phylink_config.supported_interfaces,
3150+
sizeof(adapter->phylink_config.lpi_interfaces));
3151+
31233152
pl = phylink_create(&adapter->phylink_config, NULL,
31243153
adapter->phy_interface, &lan743x_phylink_mac_ops);
31253154

@@ -3517,6 +3546,9 @@ static int lan743x_hardware_init(struct lan743x_adapter *adapter,
35173546
spin_lock_init(&tx->ring_lock);
35183547
}
35193548

3549+
/* Ensure EEEEN is clear */
3550+
lan743x_mac_eee_enable(adapter, false);
3551+
35203552
return 0;
35213553
}
35223554

drivers/net/ethernet/microchip/lan743x_main.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1206,6 +1206,5 @@ void lan743x_hs_syslock_release(struct lan743x_adapter *adapter);
12061206
void lan743x_mac_flow_ctrl_set_enables(struct lan743x_adapter *adapter,
12071207
bool tx_enable, bool rx_enable);
12081208
int lan743x_sgmii_read(struct lan743x_adapter *adapter, u8 mmd, u16 addr);
1209-
void lan743x_mac_eee_enable(struct lan743x_adapter *adapter, bool enable);
12101209

12111210
#endif /* _LAN743X_H */

0 commit comments

Comments
 (0)