aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/intel/e1000/e1000_ethtool.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/ethernet/intel/e1000/e1000_ethtool.c')
-rw-r--r--drivers/net/ethernet/intel/e1000/e1000_ethtool.c140
1 files changed, 72 insertions, 68 deletions
diff --git a/drivers/net/ethernet/intel/e1000/e1000_ethtool.c b/drivers/net/ethernet/intel/e1000/e1000_ethtool.c
index 14e30515f6aa..43462d596a4e 100644
--- a/drivers/net/ethernet/intel/e1000/e1000_ethtool.c
+++ b/drivers/net/ethernet/intel/e1000/e1000_ethtool.c
@@ -115,12 +115,12 @@ static int e1000_get_settings(struct net_device *netdev,
115 if (hw->media_type == e1000_media_type_copper) { 115 if (hw->media_type == e1000_media_type_copper) {
116 116
117 ecmd->supported = (SUPPORTED_10baseT_Half | 117 ecmd->supported = (SUPPORTED_10baseT_Half |
118 SUPPORTED_10baseT_Full | 118 SUPPORTED_10baseT_Full |
119 SUPPORTED_100baseT_Half | 119 SUPPORTED_100baseT_Half |
120 SUPPORTED_100baseT_Full | 120 SUPPORTED_100baseT_Full |
121 SUPPORTED_1000baseT_Full| 121 SUPPORTED_1000baseT_Full|
122 SUPPORTED_Autoneg | 122 SUPPORTED_Autoneg |
123 SUPPORTED_TP); 123 SUPPORTED_TP);
124 ecmd->advertising = ADVERTISED_TP; 124 ecmd->advertising = ADVERTISED_TP;
125 125
126 if (hw->autoneg == 1) { 126 if (hw->autoneg == 1) {
@@ -161,8 +161,8 @@ static int e1000_get_settings(struct net_device *netdev,
161 ethtool_cmd_speed_set(ecmd, adapter->link_speed); 161 ethtool_cmd_speed_set(ecmd, adapter->link_speed);
162 162
163 /* unfortunately FULL_DUPLEX != DUPLEX_FULL 163 /* unfortunately FULL_DUPLEX != DUPLEX_FULL
164 * and HALF_DUPLEX != DUPLEX_HALF */ 164 * and HALF_DUPLEX != DUPLEX_HALF
165 165 */
166 if (adapter->link_duplex == FULL_DUPLEX) 166 if (adapter->link_duplex == FULL_DUPLEX)
167 ecmd->duplex = DUPLEX_FULL; 167 ecmd->duplex = DUPLEX_FULL;
168 else 168 else
@@ -179,8 +179,7 @@ static int e1000_get_settings(struct net_device *netdev,
179 if ((hw->media_type == e1000_media_type_copper) && 179 if ((hw->media_type == e1000_media_type_copper) &&
180 netif_carrier_ok(netdev)) 180 netif_carrier_ok(netdev))
181 ecmd->eth_tp_mdix = (!!adapter->phy_info.mdix_mode ? 181 ecmd->eth_tp_mdix = (!!adapter->phy_info.mdix_mode ?
182 ETH_TP_MDI_X : 182 ETH_TP_MDI_X : ETH_TP_MDI);
183 ETH_TP_MDI);
184 else 183 else
185 ecmd->eth_tp_mdix = ETH_TP_MDI_INVALID; 184 ecmd->eth_tp_mdix = ETH_TP_MDI_INVALID;
186 185
@@ -197,8 +196,7 @@ static int e1000_set_settings(struct net_device *netdev,
197 struct e1000_adapter *adapter = netdev_priv(netdev); 196 struct e1000_adapter *adapter = netdev_priv(netdev);
198 struct e1000_hw *hw = &adapter->hw; 197 struct e1000_hw *hw = &adapter->hw;
199 198
200 /* 199 /* MDI setting is only allowed when autoneg enabled because
201 * MDI setting is only allowed when autoneg enabled because
202 * some hardware doesn't allow MDI setting when speed or 200 * some hardware doesn't allow MDI setting when speed or
203 * duplex is forced. 201 * duplex is forced.
204 */ 202 */
@@ -224,8 +222,8 @@ static int e1000_set_settings(struct net_device *netdev,
224 ADVERTISED_Autoneg; 222 ADVERTISED_Autoneg;
225 else 223 else
226 hw->autoneg_advertised = ecmd->advertising | 224 hw->autoneg_advertised = ecmd->advertising |
227 ADVERTISED_TP | 225 ADVERTISED_TP |
228 ADVERTISED_Autoneg; 226 ADVERTISED_Autoneg;
229 ecmd->advertising = hw->autoneg_advertised; 227 ecmd->advertising = hw->autoneg_advertised;
230 } else { 228 } else {
231 u32 speed = ethtool_cmd_speed(ecmd); 229 u32 speed = ethtool_cmd_speed(ecmd);
@@ -260,8 +258,7 @@ static u32 e1000_get_link(struct net_device *netdev)
260{ 258{
261 struct e1000_adapter *adapter = netdev_priv(netdev); 259 struct e1000_adapter *adapter = netdev_priv(netdev);
262 260
263 /* 261 /* If the link is not reported up to netdev, interrupts are disabled,
264 * If the link is not reported up to netdev, interrupts are disabled,
265 * and so the physical link state may have changed since we last 262 * and so the physical link state may have changed since we last
266 * looked. Set get_link_status to make sure that the true link 263 * looked. Set get_link_status to make sure that the true link
267 * state is interrogated, rather than pulling a cached and possibly 264 * state is interrogated, rather than pulling a cached and possibly
@@ -484,7 +481,7 @@ static int e1000_get_eeprom(struct net_device *netdev,
484 le16_to_cpus(&eeprom_buff[i]); 481 le16_to_cpus(&eeprom_buff[i]);
485 482
486 memcpy(bytes, (u8 *)eeprom_buff + (eeprom->offset & 1), 483 memcpy(bytes, (u8 *)eeprom_buff + (eeprom->offset & 1),
487 eeprom->len); 484 eeprom->len);
488 kfree(eeprom_buff); 485 kfree(eeprom_buff);
489 486
490 return ret_val; 487 return ret_val;
@@ -517,15 +514,17 @@ static int e1000_set_eeprom(struct net_device *netdev,
517 ptr = (void *)eeprom_buff; 514 ptr = (void *)eeprom_buff;
518 515
519 if (eeprom->offset & 1) { 516 if (eeprom->offset & 1) {
520 /* need read/modify/write of first changed EEPROM word */ 517 /* need read/modify/write of first changed EEPROM word
521 /* only the second byte of the word is being modified */ 518 * only the second byte of the word is being modified
519 */
522 ret_val = e1000_read_eeprom(hw, first_word, 1, 520 ret_val = e1000_read_eeprom(hw, first_word, 1,
523 &eeprom_buff[0]); 521 &eeprom_buff[0]);
524 ptr++; 522 ptr++;
525 } 523 }
526 if (((eeprom->offset + eeprom->len) & 1) && (ret_val == 0)) { 524 if (((eeprom->offset + eeprom->len) & 1) && (ret_val == 0)) {
527 /* need read/modify/write of last changed EEPROM word */ 525 /* need read/modify/write of last changed EEPROM word
528 /* only the first byte of the word is being modified */ 526 * only the first byte of the word is being modified
527 */
529 ret_val = e1000_read_eeprom(hw, last_word, 1, 528 ret_val = e1000_read_eeprom(hw, last_word, 1,
530 &eeprom_buff[last_word - first_word]); 529 &eeprom_buff[last_word - first_word]);
531 } 530 }
@@ -606,11 +605,13 @@ static int e1000_set_ringparam(struct net_device *netdev,
606 rx_old = adapter->rx_ring; 605 rx_old = adapter->rx_ring;
607 606
608 err = -ENOMEM; 607 err = -ENOMEM;
609 txdr = kcalloc(adapter->num_tx_queues, sizeof(struct e1000_tx_ring), GFP_KERNEL); 608 txdr = kcalloc(adapter->num_tx_queues, sizeof(struct e1000_tx_ring),
609 GFP_KERNEL);
610 if (!txdr) 610 if (!txdr)
611 goto err_alloc_tx; 611 goto err_alloc_tx;
612 612
613 rxdr = kcalloc(adapter->num_rx_queues, sizeof(struct e1000_rx_ring), GFP_KERNEL); 613 rxdr = kcalloc(adapter->num_rx_queues, sizeof(struct e1000_rx_ring),
614 GFP_KERNEL);
614 if (!rxdr) 615 if (!rxdr)
615 goto err_alloc_rx; 616 goto err_alloc_rx;
616 617
@@ -619,12 +620,12 @@ static int e1000_set_ringparam(struct net_device *netdev,
619 620
620 rxdr->count = max(ring->rx_pending,(u32)E1000_MIN_RXD); 621 rxdr->count = max(ring->rx_pending,(u32)E1000_MIN_RXD);
621 rxdr->count = min(rxdr->count,(u32)(mac_type < e1000_82544 ? 622 rxdr->count = min(rxdr->count,(u32)(mac_type < e1000_82544 ?
622 E1000_MAX_RXD : E1000_MAX_82544_RXD)); 623 E1000_MAX_RXD : E1000_MAX_82544_RXD));
623 rxdr->count = ALIGN(rxdr->count, REQ_RX_DESCRIPTOR_MULTIPLE); 624 rxdr->count = ALIGN(rxdr->count, REQ_RX_DESCRIPTOR_MULTIPLE);
624 625
625 txdr->count = max(ring->tx_pending,(u32)E1000_MIN_TXD); 626 txdr->count = max(ring->tx_pending,(u32)E1000_MIN_TXD);
626 txdr->count = min(txdr->count,(u32)(mac_type < e1000_82544 ? 627 txdr->count = min(txdr->count,(u32)(mac_type < e1000_82544 ?
627 E1000_MAX_TXD : E1000_MAX_82544_TXD)); 628 E1000_MAX_TXD : E1000_MAX_82544_TXD));
628 txdr->count = ALIGN(txdr->count, REQ_TX_DESCRIPTOR_MULTIPLE); 629 txdr->count = ALIGN(txdr->count, REQ_TX_DESCRIPTOR_MULTIPLE);
629 630
630 for (i = 0; i < adapter->num_tx_queues; i++) 631 for (i = 0; i < adapter->num_tx_queues; i++)
@@ -642,7 +643,8 @@ static int e1000_set_ringparam(struct net_device *netdev,
642 goto err_setup_tx; 643 goto err_setup_tx;
643 644
644 /* save the new, restore the old in order to free it, 645 /* save the new, restore the old in order to free it,
645 * then restore the new back again */ 646 * then restore the new back again
647 */
646 648
647 adapter->rx_ring = rx_old; 649 adapter->rx_ring = rx_old;
648 adapter->tx_ring = tx_old; 650 adapter->tx_ring = tx_old;
@@ -784,7 +786,6 @@ static int e1000_reg_test(struct e1000_adapter *adapter, u64 *data)
784 REG_SET_AND_CHECK(TCTL, 0xFFFFFFFF, 0x00000000); 786 REG_SET_AND_CHECK(TCTL, 0xFFFFFFFF, 0x00000000);
785 787
786 if (hw->mac_type >= e1000_82543) { 788 if (hw->mac_type >= e1000_82543) {
787
788 REG_SET_AND_CHECK(RCTL, before, 0xFFFFFFFF); 789 REG_SET_AND_CHECK(RCTL, before, 0xFFFFFFFF);
789 REG_PATTERN_TEST(RDBAL, 0xFFFFFFF0, 0xFFFFFFFF); 790 REG_PATTERN_TEST(RDBAL, 0xFFFFFFF0, 0xFFFFFFFF);
790 REG_PATTERN_TEST(TXCW, 0xC000FFFF, 0x0000FFFF); 791 REG_PATTERN_TEST(TXCW, 0xC000FFFF, 0x0000FFFF);
@@ -795,14 +796,11 @@ static int e1000_reg_test(struct e1000_adapter *adapter, u64 *data)
795 REG_PATTERN_TEST(RA + (((i << 1) + 1) << 2), 0x8003FFFF, 796 REG_PATTERN_TEST(RA + (((i << 1) + 1) << 2), 0x8003FFFF,
796 0xFFFFFFFF); 797 0xFFFFFFFF);
797 } 798 }
798
799 } else { 799 } else {
800
801 REG_SET_AND_CHECK(RCTL, 0xFFFFFFFF, 0x01FFFFFF); 800 REG_SET_AND_CHECK(RCTL, 0xFFFFFFFF, 0x01FFFFFF);
802 REG_PATTERN_TEST(RDBAL, 0xFFFFF000, 0xFFFFFFFF); 801 REG_PATTERN_TEST(RDBAL, 0xFFFFF000, 0xFFFFFFFF);
803 REG_PATTERN_TEST(TXCW, 0x0000FFFF, 0x0000FFFF); 802 REG_PATTERN_TEST(TXCW, 0x0000FFFF, 0x0000FFFF);
804 REG_PATTERN_TEST(TDBAL, 0xFFFFF000, 0xFFFFFFFF); 803 REG_PATTERN_TEST(TDBAL, 0xFFFFF000, 0xFFFFFFFF);
805
806 } 804 }
807 805
808 value = E1000_MC_TBL_SIZE; 806 value = E1000_MC_TBL_SIZE;
@@ -858,13 +856,14 @@ static int e1000_intr_test(struct e1000_adapter *adapter, u64 *data)
858 856
859 *data = 0; 857 *data = 0;
860 858
861 /* NOTE: we don't test MSI interrupts here, yet */ 859 /* NOTE: we don't test MSI interrupts here, yet
862 /* Hook up test interrupt handler just for this test */ 860 * Hook up test interrupt handler just for this test
861 */
863 if (!request_irq(irq, e1000_test_intr, IRQF_PROBE_SHARED, netdev->name, 862 if (!request_irq(irq, e1000_test_intr, IRQF_PROBE_SHARED, netdev->name,
864 netdev)) 863 netdev))
865 shared_int = false; 864 shared_int = false;
866 else if (request_irq(irq, e1000_test_intr, IRQF_SHARED, 865 else if (request_irq(irq, e1000_test_intr, IRQF_SHARED,
867 netdev->name, netdev)) { 866 netdev->name, netdev)) {
868 *data = 1; 867 *data = 1;
869 return -1; 868 return -1;
870 } 869 }
@@ -1253,14 +1252,15 @@ static int e1000_integrated_phy_loopback(struct e1000_adapter *adapter)
1253 ctrl_reg |= (E1000_CTRL_FRCSPD | /* Set the Force Speed Bit */ 1252 ctrl_reg |= (E1000_CTRL_FRCSPD | /* Set the Force Speed Bit */
1254 E1000_CTRL_FRCDPX | /* Set the Force Duplex Bit */ 1253 E1000_CTRL_FRCDPX | /* Set the Force Duplex Bit */
1255 E1000_CTRL_SPD_1000 |/* Force Speed to 1000 */ 1254 E1000_CTRL_SPD_1000 |/* Force Speed to 1000 */
1256 E1000_CTRL_FD); /* Force Duplex to FULL */ 1255 E1000_CTRL_FD); /* Force Duplex to FULL */
1257 1256
1258 if (hw->media_type == e1000_media_type_copper && 1257 if (hw->media_type == e1000_media_type_copper &&
1259 hw->phy_type == e1000_phy_m88) 1258 hw->phy_type == e1000_phy_m88)
1260 ctrl_reg |= E1000_CTRL_ILOS; /* Invert Loss of Signal */ 1259 ctrl_reg |= E1000_CTRL_ILOS; /* Invert Loss of Signal */
1261 else { 1260 else {
1262 /* Set the ILOS bit on the fiber Nic is half 1261 /* Set the ILOS bit on the fiber Nic is half
1263 * duplex link is detected. */ 1262 * duplex link is detected.
1263 */
1264 stat_reg = er32(STATUS); 1264 stat_reg = er32(STATUS);
1265 if ((stat_reg & E1000_STATUS_FD) == 0) 1265 if ((stat_reg & E1000_STATUS_FD) == 0)
1266 ctrl_reg |= (E1000_CTRL_ILOS | E1000_CTRL_SLU); 1266 ctrl_reg |= (E1000_CTRL_ILOS | E1000_CTRL_SLU);
@@ -1446,7 +1446,7 @@ static int e1000_run_loopback_test(struct e1000_adapter *adapter)
1446 1446
1447 ret_val = e1000_check_lbtest_frame( 1447 ret_val = e1000_check_lbtest_frame(
1448 rxdr->buffer_info[l].skb, 1448 rxdr->buffer_info[l].skb,
1449 1024); 1449 1024);
1450 if (!ret_val) 1450 if (!ret_val)
1451 good_cnt++; 1451 good_cnt++;
1452 if (unlikely(++l == rxdr->count)) l = 0; 1452 if (unlikely(++l == rxdr->count)) l = 0;
@@ -1493,7 +1493,8 @@ static int e1000_link_test(struct e1000_adapter *adapter, u64 *data)
1493 hw->serdes_has_link = false; 1493 hw->serdes_has_link = false;
1494 1494
1495 /* On some blade server designs, link establishment 1495 /* On some blade server designs, link establishment
1496 * could take as long as 2-3 minutes */ 1496 * could take as long as 2-3 minutes
1497 */
1497 do { 1498 do {
1498 e1000_check_for_link(hw); 1499 e1000_check_for_link(hw);
1499 if (hw->serdes_has_link) 1500 if (hw->serdes_has_link)
@@ -1545,7 +1546,8 @@ static void e1000_diag_test(struct net_device *netdev,
1545 e_info(hw, "offline testing starting\n"); 1546 e_info(hw, "offline testing starting\n");
1546 1547
1547 /* Link test performed before hardware reset so autoneg doesn't 1548 /* Link test performed before hardware reset so autoneg doesn't
1548 * interfere with test result */ 1549 * interfere with test result
1550 */
1549 if (e1000_link_test(adapter, &data[4])) 1551 if (e1000_link_test(adapter, &data[4]))
1550 eth_test->flags |= ETH_TEST_FL_FAILED; 1552 eth_test->flags |= ETH_TEST_FL_FAILED;
1551 1553
@@ -1639,7 +1641,8 @@ static int e1000_wol_exclusion(struct e1000_adapter *adapter,
1639 default: 1641 default:
1640 /* dual port cards only support WoL on port A from now on 1642 /* dual port cards only support WoL on port A from now on
1641 * unless it was enabled in the eeprom for port B 1643 * unless it was enabled in the eeprom for port B
1642 * so exclude FUNC_1 ports from having WoL enabled */ 1644 * so exclude FUNC_1 ports from having WoL enabled
1645 */
1643 if (er32(STATUS) & E1000_STATUS_FUNC_1 && 1646 if (er32(STATUS) & E1000_STATUS_FUNC_1 &&
1644 !adapter->eeprom_wol) { 1647 !adapter->eeprom_wol) {
1645 wol->supported = 0; 1648 wol->supported = 0;
@@ -1663,7 +1666,8 @@ static void e1000_get_wol(struct net_device *netdev,
1663 wol->wolopts = 0; 1666 wol->wolopts = 0;
1664 1667
1665 /* this function will set ->supported = 0 and return 1 if wol is not 1668 /* this function will set ->supported = 0 and return 1 if wol is not
1666 * supported by this hardware */ 1669 * supported by this hardware
1670 */
1667 if (e1000_wol_exclusion(adapter, wol) || 1671 if (e1000_wol_exclusion(adapter, wol) ||
1668 !device_can_wakeup(&adapter->pdev->dev)) 1672 !device_can_wakeup(&adapter->pdev->dev))
1669 return; 1673 return;
@@ -1839,7 +1843,7 @@ static void e1000_get_ethtool_stats(struct net_device *netdev,
1839 data[i] = (e1000_gstrings_stats[i].sizeof_stat == 1843 data[i] = (e1000_gstrings_stats[i].sizeof_stat ==
1840 sizeof(u64)) ? *(u64 *)p : *(u32 *)p; 1844 sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
1841 } 1845 }
1842/* BUG_ON(i != E1000_STATS_LEN); */ 1846/* BUG_ON(i != E1000_STATS_LEN); */
1843} 1847}
1844 1848
1845static void e1000_get_strings(struct net_device *netdev, u32 stringset, 1849static void e1000_get_strings(struct net_device *netdev, u32 stringset,
@@ -1859,37 +1863,37 @@ static void e1000_get_strings(struct net_device *netdev, u32 stringset,
1859 ETH_GSTRING_LEN); 1863 ETH_GSTRING_LEN);
1860 p += ETH_GSTRING_LEN; 1864 p += ETH_GSTRING_LEN;
1861 } 1865 }
1862/* BUG_ON(p - data != E1000_STATS_LEN * ETH_GSTRING_LEN); */ 1866 /* BUG_ON(p - data != E1000_STATS_LEN * ETH_GSTRING_LEN); */
1863 break; 1867 break;
1864 } 1868 }
1865} 1869}
1866 1870
1867static const struct ethtool_ops e1000_ethtool_ops = { 1871static const struct ethtool_ops e1000_ethtool_ops = {
1868 .get_settings = e1000_get_settings, 1872 .get_settings = e1000_get_settings,
1869 .set_settings = e1000_set_settings, 1873 .set_settings = e1000_set_settings,
1870 .get_drvinfo = e1000_get_drvinfo, 1874 .get_drvinfo = e1000_get_drvinfo,
1871 .get_regs_len = e1000_get_regs_len, 1875 .get_regs_len = e1000_get_regs_len,
1872 .get_regs = e1000_get_regs, 1876 .get_regs = e1000_get_regs,
1873 .get_wol = e1000_get_wol, 1877 .get_wol = e1000_get_wol,
1874 .set_wol = e1000_set_wol, 1878 .set_wol = e1000_set_wol,
1875 .get_msglevel = e1000_get_msglevel, 1879 .get_msglevel = e1000_get_msglevel,
1876 .set_msglevel = e1000_set_msglevel, 1880 .set_msglevel = e1000_set_msglevel,
1877 .nway_reset = e1000_nway_reset, 1881 .nway_reset = e1000_nway_reset,
1878 .get_link = e1000_get_link, 1882 .get_link = e1000_get_link,
1879 .get_eeprom_len = e1000_get_eeprom_len, 1883 .get_eeprom_len = e1000_get_eeprom_len,
1880 .get_eeprom = e1000_get_eeprom, 1884 .get_eeprom = e1000_get_eeprom,
1881 .set_eeprom = e1000_set_eeprom, 1885 .set_eeprom = e1000_set_eeprom,
1882 .get_ringparam = e1000_get_ringparam, 1886 .get_ringparam = e1000_get_ringparam,
1883 .set_ringparam = e1000_set_ringparam, 1887 .set_ringparam = e1000_set_ringparam,
1884 .get_pauseparam = e1000_get_pauseparam, 1888 .get_pauseparam = e1000_get_pauseparam,
1885 .set_pauseparam = e1000_set_pauseparam, 1889 .set_pauseparam = e1000_set_pauseparam,
1886 .self_test = e1000_diag_test, 1890 .self_test = e1000_diag_test,
1887 .get_strings = e1000_get_strings, 1891 .get_strings = e1000_get_strings,
1888 .set_phys_id = e1000_set_phys_id, 1892 .set_phys_id = e1000_set_phys_id,
1889 .get_ethtool_stats = e1000_get_ethtool_stats, 1893 .get_ethtool_stats = e1000_get_ethtool_stats,
1890 .get_sset_count = e1000_get_sset_count, 1894 .get_sset_count = e1000_get_sset_count,
1891 .get_coalesce = e1000_get_coalesce, 1895 .get_coalesce = e1000_get_coalesce,
1892 .set_coalesce = e1000_set_coalesce, 1896 .set_coalesce = e1000_set_coalesce,
1893 .get_ts_info = ethtool_op_get_ts_info, 1897 .get_ts_info = ethtool_op_get_ts_info,
1894}; 1898};
1895 1899