igc: Add initial EEE support
Subsystems (2)
PATCH v2 1/1 igc: Add initial EEE support
IEEE802.3az-2010 Energy Efficient Ethernet has been approved as standard (September 2010) and the driver can enable and disable it via ethtool.
Disable the feature by default on parts which support it. Add enable/disable eee options.
tx-lpi, tx-timer and advertise not supported yet.
v1-v2:
Rid of inverted logic and replace eee_disable boolean with eee_enable in device specification.
Address community comments.
--- drivers/net/ethernet/intel/igc/igc.h | 4 ++ drivers/net/ethernet/intel/igc/igc_defines.h | 10 +++ drivers/net/ethernet/intel/igc/igc_ethtool.c | 100 +++++++++++++++++++++++++++ drivers/net/ethernet/intel/igc/igc_hw.h | 1 + drivers/net/ethernet/intel/igc/igc_i225.c | 57 +++++++++++++++ drivers/net/ethernet/intel/igc/igc_i225.h | 2 + drivers/net/ethernet/intel/igc/igc_main.c | 16 +++++ drivers/net/ethernet/intel/igc/igc_regs.h | 5 ++ 8 files changed, 195 insertions(+)
drivers/net/ethernet/intel/igc/igc.h +4 -0
@@ -117,6 +117,9 @@ struct igc_ring {struct igc_adapter {struct net_device *netdev; +struct ethtool_eee eee; +u16 eee_advert; +unsigned long state;unsigned int flags;unsigned int num_q_vectors;
@@ -256,6 +259,7 @@ extern char igc_driver_version[];#define IGC_FLAG_MEDIA_RESET BIT(10)#define IGC_FLAG_MAS_ENABLE BIT(12)#define IGC_FLAG_HAS_MSIX BIT(13) +#define IGC_FLAG_EEE BIT(14)#define IGC_FLAG_VLAN_PROMISC BIT(15)#define IGC_FLAG_RX_LEGACY BIT(16)#define IGC_FLAG_TSN_QBV_ENABLED BIT(17)
drivers/net/ethernet/intel/igc/igc_defines.h +10 -0
@@ -512,4 +512,14 @@/* Maximum size of the MTA register table in all supported adapters */ #define MAX_MTA_REG 128 +/* EEE defines */ +#define IGC_IPCNFG_EEE_2_5G_AN 0x00000010/* IPCNFG EEE Ena 2.5G AN */ +#define IGC_IPCNFG_EEE_1G_AN 0x00000008/* IPCNFG EEE Ena 1G AN */ +#define IGC_IPCNFG_EEE_100M_AN 0x00000004/* IPCNFG EEE Ena 100M AN */ +#define IGC_EEER_EEE_NEG 0x20000000/* EEE capability nego */ +#define IGC_EEER_TX_LPI_EN 0x00010000/* EEER Tx LPI Enable */ +#define IGC_EEER_RX_LPI_EN 0x00020000/* EEER Rx LPI Enable */ +#define IGC_EEER_LPI_FC 0x00040000/* EEER Ena on Flow Cntrl */ +#define IGC_EEE_SU_LPI_CLK_STP 0x00800000/* EEE LPI Clock Stop */ +#endif /* _IGC_DEFINES_H_ */
drivers/net/ethernet/intel/igc/igc_ethtool.c +100 -0
118 lines not on this page · raw message
drivers/net/ethernet/intel/igc/igc_hw.h +1 -0
@@ -191,6 +191,7 @@ struct igc_fc_info {struct igc_dev_spec_base {bool clear_semaphore_once; +bool eee_enable; };struct igc_hw {
drivers/net/ethernet/intel/igc/igc_i225.c +57 -0
60 lines not on this page · raw message
drivers/net/ethernet/intel/igc/igc_i225.h +2 -0
@@ -9,5 +9,7 @@ void igc_release_swfw_sync_i225(struct igc_hw *hw, u16 mask);s32 igc_init_nvm_params_i225 (struct igc_hw *hw);bool igc_get_flash_presence_i225 (struct igc_hw *hw); +s32 igc_set_eee_i225 (struct igc_hw *hw,bool adv2p5G,bool adv1G, +bool adv100M);#endif
drivers/net/ethernet/intel/igc/igc_main.c +16 -0
@@ -105,6 +105,9 @@ void igc_reset(struct igc_adapter *adapter)if (hw->mac.ops.init_hw (hw))netdev_err (dev,"Error on hardware initialization" ); +/* Re-establish EEE setting */ +igc_set_eee_i225 (hw, true, true, true); +if (!netif_running (adapter->netdev))igc_power_down_link (adapter);
@@ -4259,6 +4262,15 @@ static void igc_watchdog_task(struct work_struct *work) (ctrl &IGC_CTRL_RFCE ) ?"RX" : (ctrl & IGC_CTRL_TFCE) ? "TX" : "None"); +/* disable EEE if enabled */ +if ((adapter->flags &IGC_FLAG_EEE ) && + adapter->link_duplex ==HALF_DUPLEX ) { +netdev_info (netdev, +"EEE Disabled: unsupported at half duplex. Re-enable using ethtool when at full duplex\n" ); + adapter->hw.dev_spec._base.eee_enable = false; + adapter->flags &= ~IGC_FLAG_EEE ; + } +/* check if SmartSpeed worked */ igc_check_downshift (hw);if (phy->speed_downgraded)
@@ -5190,6 +5202,10 @@ static int igc_probe(struct pci_dev *pdev,netdev_info (netdev,"MAC: %pM" , netdev->dev_addr);dev_pm_set_driver_flags (&pdev->dev,DPM_FLAG_NEVER_SKIP ); +/* Disable EEE for internal copper PHY devices */ + hw->dev_spec._base.eee_enable = false; + adapter->flags &= ~IGC_FLAG_EEE ; +igc_set_eee_i225 (hw, false, false, false);pm_runtime_put_noidle (&pdev->dev);
drivers/net/ethernet/intel/igc/igc_regs.h +5 -0
@@ -249,6 +249,11 @@/* Wake Up packet memory */ #define IGC_WUPM_REG (_i) (0x05A00 + ((_i) * 4)) +/* Energy Efficient Ethernet "EEE" registers */ +#define IGC_EEER 0x0E30/* Energy Efficient Ethernet "EEE"*/ +#define IGC_IPCNFG 0x0E38/* Internal PHY Configuration */ +#define IGC_EEE_SU 0x0E34/* EEE Setup */ +/* forward declaration */ struct igc_hw ;u32 igc_rd32 (struct igc_hw *hw,u32 reg);
Signature · 1 line
2.11.0
PATCH v2 1/1 igc: Add initial EEE support
Hi Sasha,
Quoting Sasha Neftin (2020-05-20 22:10:33)
Quoted 4 lines
drivers/net/ethernet/intel/igc/igc_ethtool.c +0
-0
[...]
Quoted 40 lines
drivers/net/ethernet/intel/igc/igc_ethtool.c +40
-0+static int igc_ethtool_set_eee (struct net_device *netdev, +struct ethtool_eee *edata) +{ +struct igc_adapter *adapter =netdev_priv (netdev); +struct igc_hw *hw = &adapter->hw; +struct ethtool_eee eee_curr; +s32 ret_val; + +memset (&eee_curr,0 ,sizeof (struct ethtool_eee )); + + ret_val =igc_ethtool_get_eee (netdev, &eee_curr); +if (ret_val) +return ret_val; + +if (eee_curr.eee_enabled) { +if (eee_curr.tx_lpi_enabled != edata->tx_lpi_enabled) { +netdev_err (netdev, +"Setting EEE tx-lpi is not supported\n" ); +return -EINVAL ; + } + +/* Tx LPI timer is not implemented currently */ +if (edata->tx_lpi_timer) { +netdev_err (netdev, +"Setting EEE Tx LPI timer is not supported\n" ); +return -EINVAL ; + } + }else if (!edata->eee_enabled) { +netdev_err (netdev, +"Setting EEE options are not supported with EEE disabled\n" ); +return -EINVAL ; + } + + adapter->eee_advert =ethtool_adv_to_mmd_eee_adv_t (edata->advertised); +if (hw->dev_spec._base.eee_enable != edata->eee_enabled) { + hw->dev_spec._base.eee_enable = edata->eee_enabled; + adapter->flags |=IGC_FLAG_EEE ; + +/* reset link */ +if (netif_running (netdev))
drivers/net/ethernet/intel/igc/igc_ethtool.c static int igc_ethtool_set_priv_flags(struct net_device *netdev, u32 priv_flags) · line 1645
Quoted 10 lines
drivers/net/ethernet/intel/igc/igc_ethtool.c +10
-0+igc_reinit_locked (adapter); + else +igc_reset (adapter ); + } + +if (ret_val) { +netdev_err (netdev, +"Problem setting EEE advertisement options\n" ); +return -EINVAL ; + }
'ret_val' is already checked in the beginning of this function, and it is not set afterwards. So it seems this check is pointless.
Quoted 4 lines
drivers/net/ethernet/intel/igc/igc_main.c +0
-0
[...]
drivers/net/ethernet/intel/igc/igc_main.c static int igc_probe(struct pci_dev *pdev, · line 5208
Quoted 8 lines
drivers/net/ethernet/intel/igc/igc_main.c +4
-0@@ -5190,6 +5202,10 @@ static int igc_probe(struct pci_dev *pdev,netdev_info (netdev,"MAC: %pM" , netdev->dev_addr);dev_pm_set_driver_flags (&pdev->dev,DPM_FLAG_NEVER_SKIP ); +/* Disable EEE for internal copper PHY devices */ + hw->dev_spec._base.eee_enable = false; + adapter->flags &= ~IGC_FLAG_EEE ; +igc_set_eee_i225 (hw, false, false, false);
Could you please clarify if EEE is expected to be enabled or disabled by default? IIUC this code, EEE is disabled by default. But in IGB it is enabled by default.
In addition to that, the comment above mentions it disables EEE for copper devices, but there is no check for such device. Is the comment indeed applicable here?
Regards,
Andre
Neftin
PATCH v2 1/1 igc: Add initial EEE support
Quoted 53 lines · Andre Guedes
Hi Sasha,
Quoting Sasha Neftin (2020-05-20 22:10:33)
Quoted 4 lines
drivers/net/ethernet/intel/igc/igc_ethtool.c +0
-0[...]
Quoted 45 lines
drivers/net/ethernet/intel/igc/igc_ethtool.c +45
-0+static int igc_ethtool_set_eee (struct net_device *netdev, +struct ethtool_eee *edata) +{ +struct igc_adapter *adapter =netdev_priv (netdev); +struct igc_hw *hw = &adapter->hw; +struct ethtool_eee eee_curr; +s32 ret_val; + +memset (&eee_curr,0 ,sizeof (struct ethtool_eee )); + + ret_val =igc_ethtool_get_eee (netdev, &eee_curr); +if (ret_val) +return ret_val; + +if (eee_curr.eee_enabled) { +if (eee_curr.tx_lpi_enabled != edata->tx_lpi_enabled) { +netdev_err (netdev, +"Setting EEE tx-lpi is not supported\n" ); +return -EINVAL ; + } + +/* Tx LPI timer is not implemented currently */ +if (edata->tx_lpi_timer) { +netdev_err (netdev, +"Setting EEE Tx LPI timer is not supported\n" ); +return -EINVAL ; + } + }else if (!edata->eee_enabled) { +netdev_err (netdev, +"Setting EEE options are not supported with EEE disabled\n" ); +return -EINVAL ; + } + + adapter->eee_advert =ethtool_adv_to_mmd_eee_adv_t (edata->advertised); +if (hw->dev_spec._base.eee_enable != edata->eee_enabled) { + hw->dev_spec._base.eee_enable = edata->eee_enabled; + adapter->flags |=IGC_FLAG_EEE ; + +/* reset link */ +if (netif_running (netdev)) +igc_reinit_locked (adapter); +else +igc_reset (adapter); + } +
Quoted 8 lines
drivers/net/ethernet/intel/igc/igc_ethtool.c static int igc_ethtool_set_priv_flags(struct net_device *netdev, u32 priv_flags) · line 1645
Quoted 5 lines
drivers/net/ethernet/intel/igc/igc_ethtool.c +5
-0+if (ret_val) { +netdev_err (netdev, +"Problem setting EEE advertisement options\n" ); +return -EINVAL ; + }'
ret_val' is already checked in the beginning of this function, and it is not set afterwards. So it seems this check is pointless.
Correct, I will fix in v3.
Quoted 9 lines
Quoted 5 lines
drivers/net/ethernet/intel/igc/igc_main.c +0
-0[...]
Quoted 3 lines
drivers/net/ethernet/intel/igc/igc_main.c +0
-0@@ -5190,6 +5202,10 @@ static int igc_probe(struct pci_dev *pdev,netdev_info (netdev,"MAC: %pM" , netdev->dev_addr);
Quoted 10 lines
drivers/net/ethernet/intel/igc/igc_main.c static int igc_probe(struct pci_dev *pdev, · line 5208
Quoted 5 lines
drivers/net/ethernet/intel/igc/igc_main.c +4
-0dev_pm_set_driver_flags (&pdev->dev,DPM_FLAG_NEVER_SKIP ); +/* Disable EEE for internal copper PHY devices */ + hw->dev_spec._base.eee_enable = false; + adapter->flags &= ~IGC_FLAG_EEE ; +igc_set_eee_i225 (hw, false, false, false);Could you please clarify if EEE is expected to be enabled or disabled by default? IIUC this code, EEE is disabled by default. But in IGB it is enabled by default.
EEE is expected to be disabled by default. This is our HW design's expert recommendation. The reason for that: gPHY firmware (running in PHY) release is not the final version yet.
Since gPHY firmware will be done and validated we will reconsider this recommendation.
EEE should be disabled when TSN in use, but actually this is not reason for currently decision to keep EEE disabled.
Quoted 3 lines
In addition to that, the comment above mentions it disables EEE for copper devices, but there is no check for such device. Is the comment indeed applicable here?
We support only copper devices. I will clarify in v3 Thanks, Sasha
Quoted 5 lines
Regards,
Andre