aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/intel/e1000e/ethtool.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/ethernet/intel/e1000e/ethtool.c')
-rw-r--r--drivers/net/ethernet/intel/e1000e/ethtool.c107
1 files changed, 78 insertions, 29 deletions
diff --git a/drivers/net/ethernet/intel/e1000e/ethtool.c b/drivers/net/ethernet/intel/e1000e/ethtool.c
index 59c22bf18701..a8633b8f0ac5 100644
--- a/drivers/net/ethernet/intel/e1000e/ethtool.c
+++ b/drivers/net/ethernet/intel/e1000e/ethtool.c
@@ -173,7 +173,7 @@ static int e1000_get_settings(struct net_device *netdev,
173 speed = adapter->link_speed; 173 speed = adapter->link_speed;
174 ecmd->duplex = adapter->link_duplex - 1; 174 ecmd->duplex = adapter->link_duplex - 1;
175 } 175 }
176 } else { 176 } else if (!pm_runtime_suspended(netdev->dev.parent)) {
177 u32 status = er32(STATUS); 177 u32 status = er32(STATUS);
178 if (status & E1000_STATUS_LU) { 178 if (status & E1000_STATUS_LU) {
179 if (status & E1000_STATUS_SPEED_1000) 179 if (status & E1000_STATUS_SPEED_1000)
@@ -264,6 +264,9 @@ static int e1000_set_settings(struct net_device *netdev,
264{ 264{
265 struct e1000_adapter *adapter = netdev_priv(netdev); 265 struct e1000_adapter *adapter = netdev_priv(netdev);
266 struct e1000_hw *hw = &adapter->hw; 266 struct e1000_hw *hw = &adapter->hw;
267 int ret_val = 0;
268
269 pm_runtime_get_sync(netdev->dev.parent);
267 270
268 /* When SoL/IDER sessions are active, autoneg/speed/duplex 271 /* When SoL/IDER sessions are active, autoneg/speed/duplex
269 * cannot be changed 272 * cannot be changed
@@ -271,7 +274,8 @@ static int e1000_set_settings(struct net_device *netdev,
271 if (hw->phy.ops.check_reset_block && 274 if (hw->phy.ops.check_reset_block &&
272 hw->phy.ops.check_reset_block(hw)) { 275 hw->phy.ops.check_reset_block(hw)) {
273 e_err("Cannot change link characteristics when SoL/IDER is active.\n"); 276 e_err("Cannot change link characteristics when SoL/IDER is active.\n");
274 return -EINVAL; 277 ret_val = -EINVAL;
278 goto out;
275 } 279 }
276 280
277 /* MDI setting is only allowed when autoneg enabled because 281 /* MDI setting is only allowed when autoneg enabled because
@@ -279,13 +283,16 @@ static int e1000_set_settings(struct net_device *netdev,
279 * duplex is forced. 283 * duplex is forced.
280 */ 284 */
281 if (ecmd->eth_tp_mdix_ctrl) { 285 if (ecmd->eth_tp_mdix_ctrl) {
282 if (hw->phy.media_type != e1000_media_type_copper) 286 if (hw->phy.media_type != e1000_media_type_copper) {
283 return -EOPNOTSUPP; 287 ret_val = -EOPNOTSUPP;
288 goto out;
289 }
284 290
285 if ((ecmd->eth_tp_mdix_ctrl != ETH_TP_MDI_AUTO) && 291 if ((ecmd->eth_tp_mdix_ctrl != ETH_TP_MDI_AUTO) &&
286 (ecmd->autoneg != AUTONEG_ENABLE)) { 292 (ecmd->autoneg != AUTONEG_ENABLE)) {
287 e_err("forcing MDI/MDI-X state is not supported when link speed and/or duplex are forced\n"); 293 e_err("forcing MDI/MDI-X state is not supported when link speed and/or duplex are forced\n");
288 return -EINVAL; 294 ret_val = -EINVAL;
295 goto out;
289 } 296 }
290 } 297 }
291 298
@@ -307,8 +314,8 @@ static int e1000_set_settings(struct net_device *netdev,
307 u32 speed = ethtool_cmd_speed(ecmd); 314 u32 speed = ethtool_cmd_speed(ecmd);
308 /* calling this overrides forced MDI setting */ 315 /* calling this overrides forced MDI setting */
309 if (e1000_set_spd_dplx(adapter, speed, ecmd->duplex)) { 316 if (e1000_set_spd_dplx(adapter, speed, ecmd->duplex)) {
310 clear_bit(__E1000_RESETTING, &adapter->state); 317 ret_val = -EINVAL;
311 return -EINVAL; 318 goto out;
312 } 319 }
313 } 320 }
314 321
@@ -331,8 +338,10 @@ static int e1000_set_settings(struct net_device *netdev,
331 e1000e_reset(adapter); 338 e1000e_reset(adapter);
332 } 339 }
333 340
341out:
342 pm_runtime_put_sync(netdev->dev.parent);
334 clear_bit(__E1000_RESETTING, &adapter->state); 343 clear_bit(__E1000_RESETTING, &adapter->state);
335 return 0; 344 return ret_val;
336} 345}
337 346
338static void e1000_get_pauseparam(struct net_device *netdev, 347static void e1000_get_pauseparam(struct net_device *netdev,
@@ -366,6 +375,8 @@ static int e1000_set_pauseparam(struct net_device *netdev,
366 while (test_and_set_bit(__E1000_RESETTING, &adapter->state)) 375 while (test_and_set_bit(__E1000_RESETTING, &adapter->state))
367 usleep_range(1000, 2000); 376 usleep_range(1000, 2000);
368 377
378 pm_runtime_get_sync(netdev->dev.parent);
379
369 if (adapter->fc_autoneg == AUTONEG_ENABLE) { 380 if (adapter->fc_autoneg == AUTONEG_ENABLE) {
370 hw->fc.requested_mode = e1000_fc_default; 381 hw->fc.requested_mode = e1000_fc_default;
371 if (netif_running(adapter->netdev)) { 382 if (netif_running(adapter->netdev)) {
@@ -398,6 +409,7 @@ static int e1000_set_pauseparam(struct net_device *netdev,
398 } 409 }
399 410
400out: 411out:
412 pm_runtime_put_sync(netdev->dev.parent);
401 clear_bit(__E1000_RESETTING, &adapter->state); 413 clear_bit(__E1000_RESETTING, &adapter->state);
402 return retval; 414 return retval;
403} 415}
@@ -428,6 +440,8 @@ static void e1000_get_regs(struct net_device *netdev,
428 u32 *regs_buff = p; 440 u32 *regs_buff = p;
429 u16 phy_data; 441 u16 phy_data;
430 442
443 pm_runtime_get_sync(netdev->dev.parent);
444
431 memset(p, 0, E1000_REGS_LEN * sizeof(u32)); 445 memset(p, 0, E1000_REGS_LEN * sizeof(u32));
432 446
433 regs->version = (1 << 24) | (adapter->pdev->revision << 16) | 447 regs->version = (1 << 24) | (adapter->pdev->revision << 16) |
@@ -472,6 +486,8 @@ static void e1000_get_regs(struct net_device *netdev,
472 e1e_rphy(hw, MII_STAT1000, &phy_data); 486 e1e_rphy(hw, MII_STAT1000, &phy_data);
473 regs_buff[24] = (u32)phy_data; /* phy local receiver status */ 487 regs_buff[24] = (u32)phy_data; /* phy local receiver status */
474 regs_buff[25] = regs_buff[24]; /* phy remote receiver status */ 488 regs_buff[25] = regs_buff[24]; /* phy remote receiver status */
489
490 pm_runtime_put_sync(netdev->dev.parent);
475} 491}
476 492
477static int e1000_get_eeprom_len(struct net_device *netdev) 493static int e1000_get_eeprom_len(struct net_device *netdev)
@@ -504,6 +520,8 @@ static int e1000_get_eeprom(struct net_device *netdev,
504 if (!eeprom_buff) 520 if (!eeprom_buff)
505 return -ENOMEM; 521 return -ENOMEM;
506 522
523 pm_runtime_get_sync(netdev->dev.parent);
524
507 if (hw->nvm.type == e1000_nvm_eeprom_spi) { 525 if (hw->nvm.type == e1000_nvm_eeprom_spi) {
508 ret_val = e1000_read_nvm(hw, first_word, 526 ret_val = e1000_read_nvm(hw, first_word,
509 last_word - first_word + 1, 527 last_word - first_word + 1,
@@ -517,6 +535,8 @@ static int e1000_get_eeprom(struct net_device *netdev,
517 } 535 }
518 } 536 }
519 537
538 pm_runtime_put_sync(netdev->dev.parent);
539
520 if (ret_val) { 540 if (ret_val) {
521 /* a read error occurred, throw away the result */ 541 /* a read error occurred, throw away the result */
522 memset(eeprom_buff, 0xff, sizeof(u16) * 542 memset(eeprom_buff, 0xff, sizeof(u16) *
@@ -566,6 +586,8 @@ static int e1000_set_eeprom(struct net_device *netdev,
566 586
567 ptr = (void *)eeprom_buff; 587 ptr = (void *)eeprom_buff;
568 588
589 pm_runtime_get_sync(netdev->dev.parent);
590
569 if (eeprom->offset & 1) { 591 if (eeprom->offset & 1) {
570 /* need read/modify/write of first changed EEPROM word */ 592 /* need read/modify/write of first changed EEPROM word */
571 /* only the second byte of the word is being modified */ 593 /* only the second byte of the word is being modified */
@@ -606,6 +628,7 @@ static int e1000_set_eeprom(struct net_device *netdev,
606 ret_val = e1000e_update_nvm_checksum(hw); 628 ret_val = e1000e_update_nvm_checksum(hw);
607 629
608out: 630out:
631 pm_runtime_put_sync(netdev->dev.parent);
609 kfree(eeprom_buff); 632 kfree(eeprom_buff);
610 return ret_val; 633 return ret_val;
611} 634}
@@ -701,6 +724,8 @@ static int e1000_set_ringparam(struct net_device *netdev,
701 } 724 }
702 } 725 }
703 726
727 pm_runtime_get_sync(netdev->dev.parent);
728
704 e1000e_down(adapter); 729 e1000e_down(adapter);
705 730
706 /* We can't just free everything and then setup again, because the 731 /* We can't just free everything and then setup again, because the
@@ -739,6 +764,7 @@ err_setup_rx:
739 e1000e_free_tx_resources(temp_tx); 764 e1000e_free_tx_resources(temp_tx);
740err_setup: 765err_setup:
741 e1000e_up(adapter); 766 e1000e_up(adapter);
767 pm_runtime_put_sync(netdev->dev.parent);
742free_temp: 768free_temp:
743 vfree(temp_tx); 769 vfree(temp_tx);
744 vfree(temp_rx); 770 vfree(temp_rx);
@@ -1639,7 +1665,7 @@ static int e1000_run_loopback_test(struct e1000_adapter *adapter)
1639 ret_val = 13; /* ret_val is the same as mis-compare */ 1665 ret_val = 13; /* ret_val is the same as mis-compare */
1640 break; 1666 break;
1641 } 1667 }
1642 if (jiffies >= (time + 20)) { 1668 if (time_after(jiffies, time + 20)) {
1643 ret_val = 14; /* error code for time out error */ 1669 ret_val = 14; /* error code for time out error */
1644 break; 1670 break;
1645 } 1671 }
@@ -1732,6 +1758,8 @@ static void e1000_diag_test(struct net_device *netdev,
1732 u8 autoneg; 1758 u8 autoneg;
1733 bool if_running = netif_running(netdev); 1759 bool if_running = netif_running(netdev);
1734 1760
1761 pm_runtime_get_sync(netdev->dev.parent);
1762
1735 set_bit(__E1000_TESTING, &adapter->state); 1763 set_bit(__E1000_TESTING, &adapter->state);
1736 1764
1737 if (!if_running) { 1765 if (!if_running) {
@@ -1817,6 +1845,8 @@ static void e1000_diag_test(struct net_device *netdev,
1817 } 1845 }
1818 1846
1819 msleep_interruptible(4 * 1000); 1847 msleep_interruptible(4 * 1000);
1848
1849 pm_runtime_put_sync(netdev->dev.parent);
1820} 1850}
1821 1851
1822static void e1000_get_wol(struct net_device *netdev, 1852static void e1000_get_wol(struct net_device *netdev,
@@ -1891,6 +1921,8 @@ static int e1000_set_phys_id(struct net_device *netdev,
1891 1921
1892 switch (state) { 1922 switch (state) {
1893 case ETHTOOL_ID_ACTIVE: 1923 case ETHTOOL_ID_ACTIVE:
1924 pm_runtime_get_sync(netdev->dev.parent);
1925
1894 if (!hw->mac.ops.blink_led) 1926 if (!hw->mac.ops.blink_led)
1895 return 2; /* cycle on/off twice per second */ 1927 return 2; /* cycle on/off twice per second */
1896 1928
@@ -1902,6 +1934,7 @@ static int e1000_set_phys_id(struct net_device *netdev,
1902 e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED, 0); 1934 e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED, 0);
1903 hw->mac.ops.led_off(hw); 1935 hw->mac.ops.led_off(hw);
1904 hw->mac.ops.cleanup_led(hw); 1936 hw->mac.ops.cleanup_led(hw);
1937 pm_runtime_put_sync(netdev->dev.parent);
1905 break; 1938 break;
1906 1939
1907 case ETHTOOL_ID_ON: 1940 case ETHTOOL_ID_ON:
@@ -1912,6 +1945,7 @@ static int e1000_set_phys_id(struct net_device *netdev,
1912 hw->mac.ops.led_off(hw); 1945 hw->mac.ops.led_off(hw);
1913 break; 1946 break;
1914 } 1947 }
1948
1915 return 0; 1949 return 0;
1916} 1950}
1917 1951
@@ -1950,11 +1984,15 @@ static int e1000_set_coalesce(struct net_device *netdev,
1950 adapter->itr_setting = adapter->itr & ~3; 1984 adapter->itr_setting = adapter->itr & ~3;
1951 } 1985 }
1952 1986
1987 pm_runtime_get_sync(netdev->dev.parent);
1988
1953 if (adapter->itr_setting != 0) 1989 if (adapter->itr_setting != 0)
1954 e1000e_write_itr(adapter, adapter->itr); 1990 e1000e_write_itr(adapter, adapter->itr);
1955 else 1991 else
1956 e1000e_write_itr(adapter, 0); 1992 e1000e_write_itr(adapter, 0);
1957 1993
1994 pm_runtime_put_sync(netdev->dev.parent);
1995
1958 return 0; 1996 return 0;
1959} 1997}
1960 1998
@@ -1968,7 +2006,9 @@ static int e1000_nway_reset(struct net_device *netdev)
1968 if (!adapter->hw.mac.autoneg) 2006 if (!adapter->hw.mac.autoneg)
1969 return -EINVAL; 2007 return -EINVAL;
1970 2008
2009 pm_runtime_get_sync(netdev->dev.parent);
1971 e1000e_reinit_locked(adapter); 2010 e1000e_reinit_locked(adapter);
2011 pm_runtime_put_sync(netdev->dev.parent);
1972 2012
1973 return 0; 2013 return 0;
1974} 2014}
@@ -1982,7 +2022,12 @@ static void e1000_get_ethtool_stats(struct net_device *netdev,
1982 int i; 2022 int i;
1983 char *p = NULL; 2023 char *p = NULL;
1984 2024
2025 pm_runtime_get_sync(netdev->dev.parent);
2026
1985 e1000e_get_stats64(netdev, &net_stats); 2027 e1000e_get_stats64(netdev, &net_stats);
2028
2029 pm_runtime_put_sync(netdev->dev.parent);
2030
1986 for (i = 0; i < E1000_GLOBAL_STATS_LEN; i++) { 2031 for (i = 0; i < E1000_GLOBAL_STATS_LEN; i++) {
1987 switch (e1000_gstrings_stats[i].type) { 2032 switch (e1000_gstrings_stats[i].type) {
1988 case NETDEV_STATS: 2033 case NETDEV_STATS:
@@ -2033,7 +2078,11 @@ static int e1000_get_rxnfc(struct net_device *netdev,
2033 case ETHTOOL_GRXFH: { 2078 case ETHTOOL_GRXFH: {
2034 struct e1000_adapter *adapter = netdev_priv(netdev); 2079 struct e1000_adapter *adapter = netdev_priv(netdev);
2035 struct e1000_hw *hw = &adapter->hw; 2080 struct e1000_hw *hw = &adapter->hw;
2036 u32 mrqc = er32(MRQC); 2081 u32 mrqc;
2082
2083 pm_runtime_get_sync(netdev->dev.parent);
2084 mrqc = er32(MRQC);
2085 pm_runtime_put_sync(netdev->dev.parent);
2037 2086
2038 if (!(mrqc & E1000_MRQC_RSS_FIELD_MASK)) 2087 if (!(mrqc & E1000_MRQC_RSS_FIELD_MASK))
2039 return 0; 2088 return 0;
@@ -2096,9 +2145,13 @@ static int e1000e_get_eee(struct net_device *netdev, struct ethtool_eee *edata)
2096 return -EOPNOTSUPP; 2145 return -EOPNOTSUPP;
2097 } 2146 }
2098 2147
2148 pm_runtime_get_sync(netdev->dev.parent);
2149
2099 ret_val = hw->phy.ops.acquire(hw); 2150 ret_val = hw->phy.ops.acquire(hw);
2100 if (ret_val) 2151 if (ret_val) {
2152 pm_runtime_put_sync(netdev->dev.parent);
2101 return -EBUSY; 2153 return -EBUSY;
2154 }
2102 2155
2103 /* EEE Capability */ 2156 /* EEE Capability */
2104 ret_val = e1000_read_emi_reg_locked(hw, cap_addr, &phy_data); 2157 ret_val = e1000_read_emi_reg_locked(hw, cap_addr, &phy_data);
@@ -2117,14 +2170,11 @@ static int e1000e_get_eee(struct net_device *netdev, struct ethtool_eee *edata)
2117 2170
2118 /* EEE PCS Status */ 2171 /* EEE PCS Status */
2119 ret_val = e1000_read_emi_reg_locked(hw, pcs_stat_addr, &phy_data); 2172 ret_val = e1000_read_emi_reg_locked(hw, pcs_stat_addr, &phy_data);
2173 if (ret_val)
2174 goto release;
2120 if (hw->phy.type == e1000_phy_82579) 2175 if (hw->phy.type == e1000_phy_82579)
2121 phy_data <<= 8; 2176 phy_data <<= 8;
2122 2177
2123release:
2124 hw->phy.ops.release(hw);
2125 if (ret_val)
2126 return -ENODATA;
2127
2128 /* Result of the EEE auto negotiation - there is no register that 2178 /* Result of the EEE auto negotiation - there is no register that
2129 * has the status of the EEE negotiation so do a best-guess based 2179 * has the status of the EEE negotiation so do a best-guess based
2130 * on whether Tx or Rx LPI indications have been received. 2180 * on whether Tx or Rx LPI indications have been received.
@@ -2136,7 +2186,14 @@ release:
2136 edata->tx_lpi_enabled = true; 2186 edata->tx_lpi_enabled = true;
2137 edata->tx_lpi_timer = er32(LPIC) >> E1000_LPIC_LPIET_SHIFT; 2187 edata->tx_lpi_timer = er32(LPIC) >> E1000_LPIC_LPIET_SHIFT;
2138 2188
2139 return 0; 2189release:
2190 hw->phy.ops.release(hw);
2191 if (ret_val)
2192 ret_val = -ENODATA;
2193
2194 pm_runtime_put_sync(netdev->dev.parent);
2195
2196 return ret_val;
2140} 2197}
2141 2198
2142static int e1000e_set_eee(struct net_device *netdev, struct ethtool_eee *edata) 2199static int e1000e_set_eee(struct net_device *netdev, struct ethtool_eee *edata)
@@ -2169,12 +2226,16 @@ static int e1000e_set_eee(struct net_device *netdev, struct ethtool_eee *edata)
2169 2226
2170 hw->dev_spec.ich8lan.eee_disable = !edata->eee_enabled; 2227 hw->dev_spec.ich8lan.eee_disable = !edata->eee_enabled;
2171 2228
2229 pm_runtime_get_sync(netdev->dev.parent);
2230
2172 /* reset the link */ 2231 /* reset the link */
2173 if (netif_running(netdev)) 2232 if (netif_running(netdev))
2174 e1000e_reinit_locked(adapter); 2233 e1000e_reinit_locked(adapter);
2175 else 2234 else
2176 e1000e_reset(adapter); 2235 e1000e_reset(adapter);
2177 2236
2237 pm_runtime_put_sync(netdev->dev.parent);
2238
2178 return 0; 2239 return 0;
2179} 2240}
2180 2241
@@ -2212,19 +2273,7 @@ static int e1000e_get_ts_info(struct net_device *netdev,
2212 return 0; 2273 return 0;
2213} 2274}
2214 2275
2215static int e1000e_ethtool_begin(struct net_device *netdev)
2216{
2217 return pm_runtime_get_sync(netdev->dev.parent);
2218}
2219
2220static void e1000e_ethtool_complete(struct net_device *netdev)
2221{
2222 pm_runtime_put_sync(netdev->dev.parent);
2223}
2224
2225static const struct ethtool_ops e1000_ethtool_ops = { 2276static const struct ethtool_ops e1000_ethtool_ops = {
2226 .begin = e1000e_ethtool_begin,
2227 .complete = e1000e_ethtool_complete,
2228 .get_settings = e1000_get_settings, 2277 .get_settings = e1000_get_settings,
2229 .set_settings = e1000_set_settings, 2278 .set_settings = e1000_set_settings,
2230 .get_drvinfo = e1000_get_drvinfo, 2279 .get_drvinfo = e1000_get_drvinfo,