aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/e1000e/ethtool.c
diff options
context:
space:
mode:
authorLen Brown <len.brown@intel.com>2009-01-09 03:39:43 -0500
committerLen Brown <len.brown@intel.com>2009-01-09 03:39:43 -0500
commitb2576e1d4408e134e2188c967b1f28af39cd79d4 (patch)
tree004f3c82faab760f304ce031d6d2f572e7746a50 /drivers/net/e1000e/ethtool.c
parent3cc8a5f4ba91f67bbdb81a43a99281a26aab8d77 (diff)
parent2150edc6c5cf00f7adb54538b9ea2a3e9cedca3f (diff)
Merge branch 'linus' into release
Diffstat (limited to 'drivers/net/e1000e/ethtool.c')
-rw-r--r--drivers/net/e1000e/ethtool.c82
1 files changed, 42 insertions, 40 deletions
diff --git a/drivers/net/e1000e/ethtool.c b/drivers/net/e1000e/ethtool.c
index 62421ce96311..e48956d924b0 100644
--- a/drivers/net/e1000e/ethtool.c
+++ b/drivers/net/e1000e/ethtool.c
@@ -173,11 +173,8 @@ static int e1000_get_settings(struct net_device *netdev,
173static u32 e1000_get_link(struct net_device *netdev) 173static u32 e1000_get_link(struct net_device *netdev)
174{ 174{
175 struct e1000_adapter *adapter = netdev_priv(netdev); 175 struct e1000_adapter *adapter = netdev_priv(netdev);
176 struct e1000_hw *hw = &adapter->hw; 176
177 u32 status; 177 return e1000_has_link(adapter);
178
179 status = er32(STATUS);
180 return (status & E1000_STATUS_LU) ? 1 : 0;
181} 178}
182 179
183static int e1000_set_spd_dplx(struct e1000_adapter *adapter, u16 spddplx) 180static int e1000_set_spd_dplx(struct e1000_adapter *adapter, u16 spddplx)
@@ -249,7 +246,7 @@ static int e1000_set_settings(struct net_device *netdev,
249 ADVERTISED_Autoneg; 246 ADVERTISED_Autoneg;
250 ecmd->advertising = hw->phy.autoneg_advertised; 247 ecmd->advertising = hw->phy.autoneg_advertised;
251 if (adapter->fc_autoneg) 248 if (adapter->fc_autoneg)
252 hw->fc.original_type = e1000_fc_default; 249 hw->fc.requested_mode = e1000_fc_default;
253 } else { 250 } else {
254 if (e1000_set_spd_dplx(adapter, ecmd->speed + ecmd->duplex)) { 251 if (e1000_set_spd_dplx(adapter, ecmd->speed + ecmd->duplex)) {
255 clear_bit(__E1000_RESETTING, &adapter->state); 252 clear_bit(__E1000_RESETTING, &adapter->state);
@@ -279,11 +276,11 @@ static void e1000_get_pauseparam(struct net_device *netdev,
279 pause->autoneg = 276 pause->autoneg =
280 (adapter->fc_autoneg ? AUTONEG_ENABLE : AUTONEG_DISABLE); 277 (adapter->fc_autoneg ? AUTONEG_ENABLE : AUTONEG_DISABLE);
281 278
282 if (hw->fc.type == e1000_fc_rx_pause) { 279 if (hw->fc.current_mode == e1000_fc_rx_pause) {
283 pause->rx_pause = 1; 280 pause->rx_pause = 1;
284 } else if (hw->fc.type == e1000_fc_tx_pause) { 281 } else if (hw->fc.current_mode == e1000_fc_tx_pause) {
285 pause->tx_pause = 1; 282 pause->tx_pause = 1;
286 } else if (hw->fc.type == e1000_fc_full) { 283 } else if (hw->fc.current_mode == e1000_fc_full) {
287 pause->rx_pause = 1; 284 pause->rx_pause = 1;
288 pause->tx_pause = 1; 285 pause->tx_pause = 1;
289 } 286 }
@@ -301,19 +298,8 @@ static int e1000_set_pauseparam(struct net_device *netdev,
301 while (test_and_set_bit(__E1000_RESETTING, &adapter->state)) 298 while (test_and_set_bit(__E1000_RESETTING, &adapter->state))
302 msleep(1); 299 msleep(1);
303 300
304 if (pause->rx_pause && pause->tx_pause)
305 hw->fc.type = e1000_fc_full;
306 else if (pause->rx_pause && !pause->tx_pause)
307 hw->fc.type = e1000_fc_rx_pause;
308 else if (!pause->rx_pause && pause->tx_pause)
309 hw->fc.type = e1000_fc_tx_pause;
310 else if (!pause->rx_pause && !pause->tx_pause)
311 hw->fc.type = e1000_fc_none;
312
313 hw->fc.original_type = hw->fc.type;
314
315 if (adapter->fc_autoneg == AUTONEG_ENABLE) { 301 if (adapter->fc_autoneg == AUTONEG_ENABLE) {
316 hw->fc.type = e1000_fc_default; 302 hw->fc.requested_mode = e1000_fc_default;
317 if (netif_running(adapter->netdev)) { 303 if (netif_running(adapter->netdev)) {
318 e1000e_down(adapter); 304 e1000e_down(adapter);
319 e1000e_up(adapter); 305 e1000e_up(adapter);
@@ -321,6 +307,17 @@ static int e1000_set_pauseparam(struct net_device *netdev,
321 e1000e_reset(adapter); 307 e1000e_reset(adapter);
322 } 308 }
323 } else { 309 } else {
310 if (pause->rx_pause && pause->tx_pause)
311 hw->fc.requested_mode = e1000_fc_full;
312 else if (pause->rx_pause && !pause->tx_pause)
313 hw->fc.requested_mode = e1000_fc_rx_pause;
314 else if (!pause->rx_pause && pause->tx_pause)
315 hw->fc.requested_mode = e1000_fc_tx_pause;
316 else if (!pause->rx_pause && !pause->tx_pause)
317 hw->fc.requested_mode = e1000_fc_none;
318
319 hw->fc.current_mode = hw->fc.requested_mode;
320
324 retval = ((hw->phy.media_type == e1000_media_type_fiber) ? 321 retval = ((hw->phy.media_type == e1000_media_type_fiber) ?
325 hw->mac.ops.setup_link(hw) : e1000e_force_mac_fc(hw)); 322 hw->mac.ops.setup_link(hw) : e1000e_force_mac_fc(hw));
326 } 323 }
@@ -495,18 +492,19 @@ static int e1000_get_eeprom(struct net_device *netdev,
495 for (i = 0; i < last_word - first_word + 1; i++) { 492 for (i = 0; i < last_word - first_word + 1; i++) {
496 ret_val = e1000_read_nvm(hw, first_word + i, 1, 493 ret_val = e1000_read_nvm(hw, first_word + i, 1,
497 &eeprom_buff[i]); 494 &eeprom_buff[i]);
498 if (ret_val) { 495 if (ret_val)
499 /* a read error occurred, throw away the
500 * result */
501 memset(eeprom_buff, 0xff, sizeof(eeprom_buff));
502 break; 496 break;
503 }
504 } 497 }
505 } 498 }
506 499
507 /* Device's eeprom is always little-endian, word addressable */ 500 if (ret_val) {
508 for (i = 0; i < last_word - first_word + 1; i++) 501 /* a read error occurred, throw away the result */
509 le16_to_cpus(&eeprom_buff[i]); 502 memset(eeprom_buff, 0xff, sizeof(eeprom_buff));
503 } else {
504 /* Device's eeprom is always little-endian, word addressable */
505 for (i = 0; i < last_word - first_word + 1; i++)
506 le16_to_cpus(&eeprom_buff[i]);
507 }
510 508
511 memcpy(bytes, (u8 *)eeprom_buff + (eeprom->offset & 1), eeprom->len); 509 memcpy(bytes, (u8 *)eeprom_buff + (eeprom->offset & 1), eeprom->len);
512 kfree(eeprom_buff); 510 kfree(eeprom_buff);
@@ -558,6 +556,9 @@ static int e1000_set_eeprom(struct net_device *netdev,
558 ret_val = e1000_read_nvm(hw, last_word, 1, 556 ret_val = e1000_read_nvm(hw, last_word, 1,
559 &eeprom_buff[last_word - first_word]); 557 &eeprom_buff[last_word - first_word]);
560 558
559 if (ret_val)
560 goto out;
561
561 /* Device's eeprom is always little-endian, word addressable */ 562 /* Device's eeprom is always little-endian, word addressable */
562 for (i = 0; i < last_word - first_word + 1; i++) 563 for (i = 0; i < last_word - first_word + 1; i++)
563 le16_to_cpus(&eeprom_buff[i]); 564 le16_to_cpus(&eeprom_buff[i]);
@@ -570,15 +571,18 @@ static int e1000_set_eeprom(struct net_device *netdev,
570 ret_val = e1000_write_nvm(hw, first_word, 571 ret_val = e1000_write_nvm(hw, first_word,
571 last_word - first_word + 1, eeprom_buff); 572 last_word - first_word + 1, eeprom_buff);
572 573
574 if (ret_val)
575 goto out;
576
573 /* 577 /*
574 * Update the checksum over the first part of the EEPROM if needed 578 * Update the checksum over the first part of the EEPROM if needed
575 * and flush shadow RAM for 82573 controllers 579 * and flush shadow RAM for applicable controllers
576 */ 580 */
577 if ((ret_val == 0) && ((first_word <= NVM_CHECKSUM_REG) || 581 if ((first_word <= NVM_CHECKSUM_REG) ||
578 (hw->mac.type == e1000_82574) || 582 (hw->mac.type == e1000_82574) || (hw->mac.type == e1000_82573))
579 (hw->mac.type == e1000_82573))) 583 ret_val = e1000e_update_nvm_checksum(hw);
580 e1000e_update_nvm_checksum(hw);
581 584
585out:
582 kfree(eeprom_buff); 586 kfree(eeprom_buff);
583 return ret_val; 587 return ret_val;
584} 588}
@@ -588,7 +592,6 @@ static void e1000_get_drvinfo(struct net_device *netdev,
588{ 592{
589 struct e1000_adapter *adapter = netdev_priv(netdev); 593 struct e1000_adapter *adapter = netdev_priv(netdev);
590 char firmware_version[32]; 594 char firmware_version[32];
591 u16 eeprom_data;
592 595
593 strncpy(drvinfo->driver, e1000e_driver_name, 32); 596 strncpy(drvinfo->driver, e1000e_driver_name, 32);
594 strncpy(drvinfo->version, e1000e_driver_version, 32); 597 strncpy(drvinfo->version, e1000e_driver_version, 32);
@@ -597,11 +600,10 @@ static void e1000_get_drvinfo(struct net_device *netdev,
597 * EEPROM image version # is reported as firmware version # for 600 * EEPROM image version # is reported as firmware version # for
598 * PCI-E controllers 601 * PCI-E controllers
599 */ 602 */
600 e1000_read_nvm(&adapter->hw, 5, 1, &eeprom_data);
601 sprintf(firmware_version, "%d.%d-%d", 603 sprintf(firmware_version, "%d.%d-%d",
602 (eeprom_data & 0xF000) >> 12, 604 (adapter->eeprom_vers & 0xF000) >> 12,
603 (eeprom_data & 0x0FF0) >> 4, 605 (adapter->eeprom_vers & 0x0FF0) >> 4,
604 eeprom_data & 0x000F); 606 (adapter->eeprom_vers & 0x000F));
605 607
606 strncpy(drvinfo->fw_version, firmware_version, 32); 608 strncpy(drvinfo->fw_version, firmware_version, 32);
607 strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 32); 609 strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 32);
@@ -865,7 +867,7 @@ static int e1000_eeprom_test(struct e1000_adapter *adapter, u64 *data)
865 for (i = 0; i < (NVM_CHECKSUM_REG + 1); i++) { 867 for (i = 0; i < (NVM_CHECKSUM_REG + 1); i++) {
866 if ((e1000_read_nvm(&adapter->hw, i, 1, &temp)) < 0) { 868 if ((e1000_read_nvm(&adapter->hw, i, 1, &temp)) < 0) {
867 *data = 1; 869 *data = 1;
868 break; 870 return *data;
869 } 871 }
870 checksum += temp; 872 checksum += temp;
871 } 873 }