aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/e1000/e1000_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/e1000/e1000_main.c')
-rw-r--r--drivers/net/e1000/e1000_main.c910
1 files changed, 472 insertions, 438 deletions
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 9a20ba39346b..ad1f052c3d3a 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -269,12 +269,13 @@ module_exit(e1000_exit_module);
269 269
270static int e1000_request_irq(struct e1000_adapter *adapter) 270static int e1000_request_irq(struct e1000_adapter *adapter)
271{ 271{
272 struct e1000_hw *hw = &adapter->hw;
272 struct net_device *netdev = adapter->netdev; 273 struct net_device *netdev = adapter->netdev;
273 irq_handler_t handler = e1000_intr; 274 irq_handler_t handler = e1000_intr;
274 int irq_flags = IRQF_SHARED; 275 int irq_flags = IRQF_SHARED;
275 int err; 276 int err;
276 277
277 if (adapter->hw.mac_type >= e1000_82571) { 278 if (hw->mac_type >= e1000_82571) {
278 adapter->have_msi = !pci_enable_msi(adapter->pdev); 279 adapter->have_msi = !pci_enable_msi(adapter->pdev);
279 if (adapter->have_msi) { 280 if (adapter->have_msi) {
280 handler = e1000_intr_msi; 281 handler = e1000_intr_msi;
@@ -311,8 +312,10 @@ static void e1000_free_irq(struct e1000_adapter *adapter)
311 312
312static void e1000_irq_disable(struct e1000_adapter *adapter) 313static void e1000_irq_disable(struct e1000_adapter *adapter)
313{ 314{
314 E1000_WRITE_REG(&adapter->hw, IMC, ~0); 315 struct e1000_hw *hw = &adapter->hw;
315 E1000_WRITE_FLUSH(&adapter->hw); 316
317 ew32(IMC, ~0);
318 E1000_WRITE_FLUSH();
316 synchronize_irq(adapter->pdev->irq); 319 synchronize_irq(adapter->pdev->irq);
317} 320}
318 321
@@ -323,18 +326,21 @@ static void e1000_irq_disable(struct e1000_adapter *adapter)
323 326
324static void e1000_irq_enable(struct e1000_adapter *adapter) 327static void e1000_irq_enable(struct e1000_adapter *adapter)
325{ 328{
326 E1000_WRITE_REG(&adapter->hw, IMS, IMS_ENABLE_MASK); 329 struct e1000_hw *hw = &adapter->hw;
327 E1000_WRITE_FLUSH(&adapter->hw); 330
331 ew32(IMS, IMS_ENABLE_MASK);
332 E1000_WRITE_FLUSH();
328} 333}
329 334
330static void e1000_update_mng_vlan(struct e1000_adapter *adapter) 335static void e1000_update_mng_vlan(struct e1000_adapter *adapter)
331{ 336{
337 struct e1000_hw *hw = &adapter->hw;
332 struct net_device *netdev = adapter->netdev; 338 struct net_device *netdev = adapter->netdev;
333 u16 vid = adapter->hw.mng_cookie.vlan_id; 339 u16 vid = hw->mng_cookie.vlan_id;
334 u16 old_vid = adapter->mng_vlan_id; 340 u16 old_vid = adapter->mng_vlan_id;
335 if (adapter->vlgrp) { 341 if (adapter->vlgrp) {
336 if (!vlan_group_get_device(adapter->vlgrp, vid)) { 342 if (!vlan_group_get_device(adapter->vlgrp, vid)) {
337 if (adapter->hw.mng_cookie.status & 343 if (hw->mng_cookie.status &
338 E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) { 344 E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) {
339 e1000_vlan_rx_add_vid(netdev, vid); 345 e1000_vlan_rx_add_vid(netdev, vid);
340 adapter->mng_vlan_id = vid; 346 adapter->mng_vlan_id = vid;
@@ -365,21 +371,20 @@ static void e1000_release_hw_control(struct e1000_adapter *adapter)
365{ 371{
366 u32 ctrl_ext; 372 u32 ctrl_ext;
367 u32 swsm; 373 u32 swsm;
374 struct e1000_hw *hw = &adapter->hw;
368 375
369 /* Let firmware taken over control of h/w */ 376 /* Let firmware taken over control of h/w */
370 switch (adapter->hw.mac_type) { 377 switch (hw->mac_type) {
371 case e1000_82573: 378 case e1000_82573:
372 swsm = E1000_READ_REG(&adapter->hw, SWSM); 379 swsm = er32(SWSM);
373 E1000_WRITE_REG(&adapter->hw, SWSM, 380 ew32(SWSM, swsm & ~E1000_SWSM_DRV_LOAD);
374 swsm & ~E1000_SWSM_DRV_LOAD);
375 break; 381 break;
376 case e1000_82571: 382 case e1000_82571:
377 case e1000_82572: 383 case e1000_82572:
378 case e1000_80003es2lan: 384 case e1000_80003es2lan:
379 case e1000_ich8lan: 385 case e1000_ich8lan:
380 ctrl_ext = E1000_READ_REG(&adapter->hw, CTRL_EXT); 386 ctrl_ext = er32(CTRL_EXT);
381 E1000_WRITE_REG(&adapter->hw, CTRL_EXT, 387 ew32(CTRL_EXT, ctrl_ext & ~E1000_CTRL_EXT_DRV_LOAD);
382 ctrl_ext & ~E1000_CTRL_EXT_DRV_LOAD);
383 break; 388 break;
384 default: 389 default:
385 break; 390 break;
@@ -401,21 +406,20 @@ static void e1000_get_hw_control(struct e1000_adapter *adapter)
401{ 406{
402 u32 ctrl_ext; 407 u32 ctrl_ext;
403 u32 swsm; 408 u32 swsm;
409 struct e1000_hw *hw = &adapter->hw;
404 410
405 /* Let firmware know the driver has taken over */ 411 /* Let firmware know the driver has taken over */
406 switch (adapter->hw.mac_type) { 412 switch (hw->mac_type) {
407 case e1000_82573: 413 case e1000_82573:
408 swsm = E1000_READ_REG(&adapter->hw, SWSM); 414 swsm = er32(SWSM);
409 E1000_WRITE_REG(&adapter->hw, SWSM, 415 ew32(SWSM, swsm | E1000_SWSM_DRV_LOAD);
410 swsm | E1000_SWSM_DRV_LOAD);
411 break; 416 break;
412 case e1000_82571: 417 case e1000_82571:
413 case e1000_82572: 418 case e1000_82572:
414 case e1000_80003es2lan: 419 case e1000_80003es2lan:
415 case e1000_ich8lan: 420 case e1000_ich8lan:
416 ctrl_ext = E1000_READ_REG(&adapter->hw, CTRL_EXT); 421 ctrl_ext = er32(CTRL_EXT);
417 E1000_WRITE_REG(&adapter->hw, CTRL_EXT, 422 ew32(CTRL_EXT, ctrl_ext | E1000_CTRL_EXT_DRV_LOAD);
418 ctrl_ext | E1000_CTRL_EXT_DRV_LOAD);
419 break; 423 break;
420 default: 424 default:
421 break; 425 break;
@@ -424,8 +428,10 @@ static void e1000_get_hw_control(struct e1000_adapter *adapter)
424 428
425static void e1000_init_manageability(struct e1000_adapter *adapter) 429static void e1000_init_manageability(struct e1000_adapter *adapter)
426{ 430{
431 struct e1000_hw *hw = &adapter->hw;
432
427 if (adapter->en_mng_pt) { 433 if (adapter->en_mng_pt) {
428 u32 manc = E1000_READ_REG(&adapter->hw, MANC); 434 u32 manc = er32(MANC);
429 435
430 /* disable hardware interception of ARP */ 436 /* disable hardware interception of ARP */
431 manc &= ~(E1000_MANC_ARP_EN); 437 manc &= ~(E1000_MANC_ARP_EN);
@@ -433,36 +439,38 @@ static void e1000_init_manageability(struct e1000_adapter *adapter)
433 /* enable receiving management packets to the host */ 439 /* enable receiving management packets to the host */
434 /* this will probably generate destination unreachable messages 440 /* this will probably generate destination unreachable messages
435 * from the host OS, but the packets will be handled on SMBUS */ 441 * from the host OS, but the packets will be handled on SMBUS */
436 if (adapter->hw.has_manc2h) { 442 if (hw->has_manc2h) {
437 u32 manc2h = E1000_READ_REG(&adapter->hw, MANC2H); 443 u32 manc2h = er32(MANC2H);
438 444
439 manc |= E1000_MANC_EN_MNG2HOST; 445 manc |= E1000_MANC_EN_MNG2HOST;
440#define E1000_MNG2HOST_PORT_623 (1 << 5) 446#define E1000_MNG2HOST_PORT_623 (1 << 5)
441#define E1000_MNG2HOST_PORT_664 (1 << 6) 447#define E1000_MNG2HOST_PORT_664 (1 << 6)
442 manc2h |= E1000_MNG2HOST_PORT_623; 448 manc2h |= E1000_MNG2HOST_PORT_623;
443 manc2h |= E1000_MNG2HOST_PORT_664; 449 manc2h |= E1000_MNG2HOST_PORT_664;
444 E1000_WRITE_REG(&adapter->hw, MANC2H, manc2h); 450 ew32(MANC2H, manc2h);
445 } 451 }
446 452
447 E1000_WRITE_REG(&adapter->hw, MANC, manc); 453 ew32(MANC, manc);
448 } 454 }
449} 455}
450 456
451static void e1000_release_manageability(struct e1000_adapter *adapter) 457static void e1000_release_manageability(struct e1000_adapter *adapter)
452{ 458{
459 struct e1000_hw *hw = &adapter->hw;
460
453 if (adapter->en_mng_pt) { 461 if (adapter->en_mng_pt) {
454 u32 manc = E1000_READ_REG(&adapter->hw, MANC); 462 u32 manc = er32(MANC);
455 463
456 /* re-enable hardware interception of ARP */ 464 /* re-enable hardware interception of ARP */
457 manc |= E1000_MANC_ARP_EN; 465 manc |= E1000_MANC_ARP_EN;
458 466
459 if (adapter->hw.has_manc2h) 467 if (hw->has_manc2h)
460 manc &= ~E1000_MANC_EN_MNG2HOST; 468 manc &= ~E1000_MANC_EN_MNG2HOST;
461 469
462 /* don't explicitly have to mess with MANC2H since 470 /* don't explicitly have to mess with MANC2H since
463 * MANC has an enable disable that gates MANC2H */ 471 * MANC has an enable disable that gates MANC2H */
464 472
465 E1000_WRITE_REG(&adapter->hw, MANC, manc); 473 ew32(MANC, manc);
466 } 474 }
467} 475}
468 476
@@ -497,6 +505,8 @@ static void e1000_configure(struct e1000_adapter *adapter)
497 505
498int e1000_up(struct e1000_adapter *adapter) 506int e1000_up(struct e1000_adapter *adapter)
499{ 507{
508 struct e1000_hw *hw = &adapter->hw;
509
500 /* hardware has been reset, we need to reload some things */ 510 /* hardware has been reset, we need to reload some things */
501 e1000_configure(adapter); 511 e1000_configure(adapter);
502 512
@@ -508,7 +518,7 @@ int e1000_up(struct e1000_adapter *adapter)
508 e1000_irq_enable(adapter); 518 e1000_irq_enable(adapter);
509 519
510 /* fire a link change interrupt to start the watchdog */ 520 /* fire a link change interrupt to start the watchdog */
511 E1000_WRITE_REG(&adapter->hw, ICS, E1000_ICS_LSC); 521 ew32(ICS, E1000_ICS_LSC);
512 return 0; 522 return 0;
513} 523}
514 524
@@ -524,30 +534,33 @@ int e1000_up(struct e1000_adapter *adapter)
524 534
525void e1000_power_up_phy(struct e1000_adapter *adapter) 535void e1000_power_up_phy(struct e1000_adapter *adapter)
526{ 536{
537 struct e1000_hw *hw = &adapter->hw;
527 u16 mii_reg = 0; 538 u16 mii_reg = 0;
528 539
529 /* Just clear the power down bit to wake the phy back up */ 540 /* Just clear the power down bit to wake the phy back up */
530 if (adapter->hw.media_type == e1000_media_type_copper) { 541 if (hw->media_type == e1000_media_type_copper) {
531 /* according to the manual, the phy will retain its 542 /* according to the manual, the phy will retain its
532 * settings across a power-down/up cycle */ 543 * settings across a power-down/up cycle */
533 e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &mii_reg); 544 e1000_read_phy_reg(hw, PHY_CTRL, &mii_reg);
534 mii_reg &= ~MII_CR_POWER_DOWN; 545 mii_reg &= ~MII_CR_POWER_DOWN;
535 e1000_write_phy_reg(&adapter->hw, PHY_CTRL, mii_reg); 546 e1000_write_phy_reg(hw, PHY_CTRL, mii_reg);
536 } 547 }
537} 548}
538 549
539static void e1000_power_down_phy(struct e1000_adapter *adapter) 550static void e1000_power_down_phy(struct e1000_adapter *adapter)
540{ 551{
552 struct e1000_hw *hw = &adapter->hw;
553
541 /* Power down the PHY so no link is implied when interface is down * 554 /* Power down the PHY so no link is implied when interface is down *
542 * The PHY cannot be powered down if any of the following is true * 555 * The PHY cannot be powered down if any of the following is true *
543 * (a) WoL is enabled 556 * (a) WoL is enabled
544 * (b) AMT is active 557 * (b) AMT is active
545 * (c) SoL/IDER session is active */ 558 * (c) SoL/IDER session is active */
546 if (!adapter->wol && adapter->hw.mac_type >= e1000_82540 && 559 if (!adapter->wol && hw->mac_type >= e1000_82540 &&
547 adapter->hw.media_type == e1000_media_type_copper) { 560 hw->media_type == e1000_media_type_copper) {
548 u16 mii_reg = 0; 561 u16 mii_reg = 0;
549 562
550 switch (adapter->hw.mac_type) { 563 switch (hw->mac_type) {
551 case e1000_82540: 564 case e1000_82540:
552 case e1000_82545: 565 case e1000_82545:
553 case e1000_82545_rev_3: 566 case e1000_82545_rev_3:
@@ -557,8 +570,7 @@ static void e1000_power_down_phy(struct e1000_adapter *adapter)
557 case e1000_82541_rev_2: 570 case e1000_82541_rev_2:
558 case e1000_82547: 571 case e1000_82547:
559 case e1000_82547_rev_2: 572 case e1000_82547_rev_2:
560 if (E1000_READ_REG(&adapter->hw, MANC) & 573 if (er32(MANC) & E1000_MANC_SMBUS_EN)
561 E1000_MANC_SMBUS_EN)
562 goto out; 574 goto out;
563 break; 575 break;
564 case e1000_82571: 576 case e1000_82571:
@@ -566,16 +578,16 @@ static void e1000_power_down_phy(struct e1000_adapter *adapter)
566 case e1000_82573: 578 case e1000_82573:
567 case e1000_80003es2lan: 579 case e1000_80003es2lan:
568 case e1000_ich8lan: 580 case e1000_ich8lan:
569 if (e1000_check_mng_mode(&adapter->hw) || 581 if (e1000_check_mng_mode(hw) ||
570 e1000_check_phy_reset_block(&adapter->hw)) 582 e1000_check_phy_reset_block(hw))
571 goto out; 583 goto out;
572 break; 584 break;
573 default: 585 default:
574 goto out; 586 goto out;
575 } 587 }
576 e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &mii_reg); 588 e1000_read_phy_reg(hw, PHY_CTRL, &mii_reg);
577 mii_reg |= MII_CR_POWER_DOWN; 589 mii_reg |= MII_CR_POWER_DOWN;
578 e1000_write_phy_reg(&adapter->hw, PHY_CTRL, mii_reg); 590 e1000_write_phy_reg(hw, PHY_CTRL, mii_reg);
579 mdelay(1); 591 mdelay(1);
580 } 592 }
581out: 593out:
@@ -622,6 +634,7 @@ void e1000_reinit_locked(struct e1000_adapter *adapter)
622 634
623void e1000_reset(struct e1000_adapter *adapter) 635void e1000_reset(struct e1000_adapter *adapter)
624{ 636{
637 struct e1000_hw *hw = &adapter->hw;
625 u32 pba = 0, tx_space, min_tx_space, min_rx_space; 638 u32 pba = 0, tx_space, min_tx_space, min_rx_space;
626 u16 fc_high_water_mark = E1000_FC_HIGH_DIFF; 639 u16 fc_high_water_mark = E1000_FC_HIGH_DIFF;
627 bool legacy_pba_adjust = false; 640 bool legacy_pba_adjust = false;
@@ -630,7 +643,7 @@ void e1000_reset(struct e1000_adapter *adapter)
630 * To take effect CTRL.RST is required. 643 * To take effect CTRL.RST is required.
631 */ 644 */
632 645
633 switch (adapter->hw.mac_type) { 646 switch (hw->mac_type) {
634 case e1000_82542_rev2_0: 647 case e1000_82542_rev2_0:
635 case e1000_82542_rev2_1: 648 case e1000_82542_rev2_1:
636 case e1000_82543: 649 case e1000_82543:
@@ -671,16 +684,16 @@ void e1000_reset(struct e1000_adapter *adapter)
671 if (adapter->netdev->mtu > E1000_RXBUFFER_8192) 684 if (adapter->netdev->mtu > E1000_RXBUFFER_8192)
672 pba -= 8; /* allocate more FIFO for Tx */ 685 pba -= 8; /* allocate more FIFO for Tx */
673 686
674 if (adapter->hw.mac_type == e1000_82547) { 687 if (hw->mac_type == e1000_82547) {
675 adapter->tx_fifo_head = 0; 688 adapter->tx_fifo_head = 0;
676 adapter->tx_head_addr = pba << E1000_TX_HEAD_ADDR_SHIFT; 689 adapter->tx_head_addr = pba << E1000_TX_HEAD_ADDR_SHIFT;
677 adapter->tx_fifo_size = 690 adapter->tx_fifo_size =
678 (E1000_PBA_40K - pba) << E1000_PBA_BYTES_SHIFT; 691 (E1000_PBA_40K - pba) << E1000_PBA_BYTES_SHIFT;
679 atomic_set(&adapter->tx_fifo_stall, 0); 692 atomic_set(&adapter->tx_fifo_stall, 0);
680 } 693 }
681 } else if (adapter->hw.max_frame_size > MAXIMUM_ETHERNET_FRAME_SIZE) { 694 } else if (hw->max_frame_size > MAXIMUM_ETHERNET_FRAME_SIZE) {
682 /* adjust PBA for jumbo frames */ 695 /* adjust PBA for jumbo frames */
683 E1000_WRITE_REG(&adapter->hw, PBA, pba); 696 ew32(PBA, pba);
684 697
685 /* To maintain wire speed transmits, the Tx FIFO should be 698 /* To maintain wire speed transmits, the Tx FIFO should be
686 * large enough to accomodate two full transmit packets, 699 * large enough to accomodate two full transmit packets,
@@ -688,7 +701,7 @@ void e1000_reset(struct e1000_adapter *adapter)
688 * the Rx FIFO should be large enough to accomodate at least 701 * the Rx FIFO should be large enough to accomodate at least
689 * one full receive packet and is similarly rounded up and 702 * one full receive packet and is similarly rounded up and
690 * expressed in KB. */ 703 * expressed in KB. */
691 pba = E1000_READ_REG(&adapter->hw, PBA); 704 pba = er32(PBA);
692 /* upper 16 bits has Tx packet buffer allocation size in KB */ 705 /* upper 16 bits has Tx packet buffer allocation size in KB */
693 tx_space = pba >> 16; 706 tx_space = pba >> 16;
694 /* lower 16 bits has Rx packet buffer allocation size in KB */ 707 /* lower 16 bits has Rx packet buffer allocation size in KB */
@@ -711,7 +724,7 @@ void e1000_reset(struct e1000_adapter *adapter)
711 pba = pba - (min_tx_space - tx_space); 724 pba = pba - (min_tx_space - tx_space);
712 725
713 /* PCI/PCIx hardware has PBA alignment constraints */ 726 /* PCI/PCIx hardware has PBA alignment constraints */
714 switch (adapter->hw.mac_type) { 727 switch (hw->mac_type) {
715 case e1000_82545 ... e1000_82546_rev_3: 728 case e1000_82545 ... e1000_82546_rev_3:
716 pba &= ~(E1000_PBA_8K - 1); 729 pba &= ~(E1000_PBA_8K - 1);
717 break; 730 break;
@@ -722,7 +735,7 @@ void e1000_reset(struct e1000_adapter *adapter)
722 /* if short on rx space, rx wins and must trump tx 735 /* if short on rx space, rx wins and must trump tx
723 * adjustment or use Early Receive if available */ 736 * adjustment or use Early Receive if available */
724 if (pba < min_rx_space) { 737 if (pba < min_rx_space) {
725 switch (adapter->hw.mac_type) { 738 switch (hw->mac_type) {
726 case e1000_82573: 739 case e1000_82573:
727 /* ERT enabled in e1000_configure_rx */ 740 /* ERT enabled in e1000_configure_rx */
728 break; 741 break;
@@ -734,7 +747,7 @@ void e1000_reset(struct e1000_adapter *adapter)
734 } 747 }
735 } 748 }
736 749
737 E1000_WRITE_REG(&adapter->hw, PBA, pba); 750 ew32(PBA, pba);
738 751
739 /* flow control settings */ 752 /* flow control settings */
740 /* Set the FC high water mark to 90% of the FIFO size. 753 /* Set the FC high water mark to 90% of the FIFO size.
@@ -747,54 +760,54 @@ void e1000_reset(struct e1000_adapter *adapter)
747 if (pba < E1000_PBA_16K) 760 if (pba < E1000_PBA_16K)
748 fc_high_water_mark = (pba * 1024) - 1600; 761 fc_high_water_mark = (pba * 1024) - 1600;
749 762
750 adapter->hw.fc_high_water = fc_high_water_mark; 763 hw->fc_high_water = fc_high_water_mark;
751 adapter->hw.fc_low_water = fc_high_water_mark - 8; 764 hw->fc_low_water = fc_high_water_mark - 8;
752 if (adapter->hw.mac_type == e1000_80003es2lan) 765 if (hw->mac_type == e1000_80003es2lan)
753 adapter->hw.fc_pause_time = 0xFFFF; 766 hw->fc_pause_time = 0xFFFF;
754 else 767 else
755 adapter->hw.fc_pause_time = E1000_FC_PAUSE_TIME; 768 hw->fc_pause_time = E1000_FC_PAUSE_TIME;
756 adapter->hw.fc_send_xon = 1; 769 hw->fc_send_xon = 1;
757 adapter->hw.fc = adapter->hw.original_fc; 770 hw->fc = hw->original_fc;
758 771
759 /* Allow time for pending master requests to run */ 772 /* Allow time for pending master requests to run */
760 e1000_reset_hw(&adapter->hw); 773 e1000_reset_hw(hw);
761 if (adapter->hw.mac_type >= e1000_82544) 774 if (hw->mac_type >= e1000_82544)
762 E1000_WRITE_REG(&adapter->hw, WUC, 0); 775 ew32(WUC, 0);
763 776
764 if (e1000_init_hw(&adapter->hw)) 777 if (e1000_init_hw(hw))
765 DPRINTK(PROBE, ERR, "Hardware Error\n"); 778 DPRINTK(PROBE, ERR, "Hardware Error\n");
766 e1000_update_mng_vlan(adapter); 779 e1000_update_mng_vlan(adapter);
767 780
768 /* if (adapter->hwflags & HWFLAGS_PHY_PWR_BIT) { */ 781 /* if (adapter->hwflags & HWFLAGS_PHY_PWR_BIT) { */
769 if (adapter->hw.mac_type >= e1000_82544 && 782 if (hw->mac_type >= e1000_82544 &&
770 adapter->hw.mac_type <= e1000_82547_rev_2 && 783 hw->mac_type <= e1000_82547_rev_2 &&
771 adapter->hw.autoneg == 1 && 784 hw->autoneg == 1 &&
772 adapter->hw.autoneg_advertised == ADVERTISE_1000_FULL) { 785 hw->autoneg_advertised == ADVERTISE_1000_FULL) {
773 u32 ctrl = E1000_READ_REG(&adapter->hw, CTRL); 786 u32 ctrl = er32(CTRL);
774 /* clear phy power management bit if we are in gig only mode, 787 /* clear phy power management bit if we are in gig only mode,
775 * which if enabled will attempt negotiation to 100Mb, which 788 * which if enabled will attempt negotiation to 100Mb, which
776 * can cause a loss of link at power off or driver unload */ 789 * can cause a loss of link at power off or driver unload */
777 ctrl &= ~E1000_CTRL_SWDPIN3; 790 ctrl &= ~E1000_CTRL_SWDPIN3;
778 E1000_WRITE_REG(&adapter->hw, CTRL, ctrl); 791 ew32(CTRL, ctrl);
779 } 792 }
780 793
781 /* Enable h/w to recognize an 802.1Q VLAN Ethernet packet */ 794 /* Enable h/w to recognize an 802.1Q VLAN Ethernet packet */
782 E1000_WRITE_REG(&adapter->hw, VET, ETHERNET_IEEE_VLAN_TYPE); 795 ew32(VET, ETHERNET_IEEE_VLAN_TYPE);
783 796
784 e1000_reset_adaptive(&adapter->hw); 797 e1000_reset_adaptive(hw);
785 e1000_phy_get_info(&adapter->hw, &adapter->phy_info); 798 e1000_phy_get_info(hw, &adapter->phy_info);
786 799
787 if (!adapter->smart_power_down && 800 if (!adapter->smart_power_down &&
788 (adapter->hw.mac_type == e1000_82571 || 801 (hw->mac_type == e1000_82571 ||
789 adapter->hw.mac_type == e1000_82572)) { 802 hw->mac_type == e1000_82572)) {
790 u16 phy_data = 0; 803 u16 phy_data = 0;
791 /* speed up time to link by disabling smart power down, ignore 804 /* speed up time to link by disabling smart power down, ignore
792 * the return value of this function because there is nothing 805 * the return value of this function because there is nothing
793 * different we would do if it failed */ 806 * different we would do if it failed */
794 e1000_read_phy_reg(&adapter->hw, IGP02E1000_PHY_POWER_MGMT, 807 e1000_read_phy_reg(hw, IGP02E1000_PHY_POWER_MGMT,
795 &phy_data); 808 &phy_data);
796 phy_data &= ~IGP02E1000_PM_SPD; 809 phy_data &= ~IGP02E1000_PM_SPD;
797 e1000_write_phy_reg(&adapter->hw, IGP02E1000_PHY_POWER_MGMT, 810 e1000_write_phy_reg(hw, IGP02E1000_PHY_POWER_MGMT,
798 phy_data); 811 phy_data);
799 } 812 }
800 813
@@ -871,12 +884,12 @@ static void e1000_dump_eeprom(struct e1000_adapter *adapter)
871 * and a hardware reset occur. 884 * and a hardware reset occur.
872 **/ 885 **/
873 886
874static int __devinit 887static int __devinit e1000_probe(struct pci_dev *pdev,
875e1000_probe(struct pci_dev *pdev, 888 const struct pci_device_id *ent)
876 const struct pci_device_id *ent)
877{ 889{
878 struct net_device *netdev; 890 struct net_device *netdev;
879 struct e1000_adapter *adapter; 891 struct e1000_adapter *adapter;
892 struct e1000_hw *hw;
880 893
881 static int cards_found = 0; 894 static int cards_found = 0;
882 static int global_quad_port_a = 0; /* global ksp3 port a indication */ 895 static int global_quad_port_a = 0; /* global ksp3 port a indication */
@@ -916,20 +929,22 @@ e1000_probe(struct pci_dev *pdev,
916 adapter = netdev_priv(netdev); 929 adapter = netdev_priv(netdev);
917 adapter->netdev = netdev; 930 adapter->netdev = netdev;
918 adapter->pdev = pdev; 931 adapter->pdev = pdev;
919 adapter->hw.back = adapter;
920 adapter->msg_enable = (1 << debug) - 1; 932 adapter->msg_enable = (1 << debug) - 1;
921 933
934 hw = &adapter->hw;
935 hw->back = adapter;
936
922 err = -EIO; 937 err = -EIO;
923 adapter->hw.hw_addr = ioremap(pci_resource_start(pdev, BAR_0), 938 hw->hw_addr = ioremap(pci_resource_start(pdev, BAR_0),
924 pci_resource_len(pdev, BAR_0)); 939 pci_resource_len(pdev, BAR_0));
925 if (!adapter->hw.hw_addr) 940 if (!hw->hw_addr)
926 goto err_ioremap; 941 goto err_ioremap;
927 942
928 for (i = BAR_1; i <= BAR_5; i++) { 943 for (i = BAR_1; i <= BAR_5; i++) {
929 if (pci_resource_len(pdev, i) == 0) 944 if (pci_resource_len(pdev, i) == 0)
930 continue; 945 continue;
931 if (pci_resource_flags(pdev, i) & IORESOURCE_IO) { 946 if (pci_resource_flags(pdev, i) & IORESOURCE_IO) {
932 adapter->hw.io_base = pci_resource_start(pdev, i); 947 hw->io_base = pci_resource_start(pdev, i);
933 break; 948 break;
934 } 949 }
935 } 950 }
@@ -966,43 +981,43 @@ e1000_probe(struct pci_dev *pdev,
966 err = -EIO; 981 err = -EIO;
967 /* Flash BAR mapping must happen after e1000_sw_init 982 /* Flash BAR mapping must happen after e1000_sw_init
968 * because it depends on mac_type */ 983 * because it depends on mac_type */
969 if ((adapter->hw.mac_type == e1000_ich8lan) && 984 if ((hw->mac_type == e1000_ich8lan) &&
970 (pci_resource_flags(pdev, 1) & IORESOURCE_MEM)) { 985 (pci_resource_flags(pdev, 1) & IORESOURCE_MEM)) {
971 adapter->hw.flash_address = 986 hw->flash_address =
972 ioremap(pci_resource_start(pdev, 1), 987 ioremap(pci_resource_start(pdev, 1),
973 pci_resource_len(pdev, 1)); 988 pci_resource_len(pdev, 1));
974 if (!adapter->hw.flash_address) 989 if (!hw->flash_address)
975 goto err_flashmap; 990 goto err_flashmap;
976 } 991 }
977 992
978 if (e1000_check_phy_reset_block(&adapter->hw)) 993 if (e1000_check_phy_reset_block(hw))
979 DPRINTK(PROBE, INFO, "PHY reset is blocked due to SOL/IDER session.\n"); 994 DPRINTK(PROBE, INFO, "PHY reset is blocked due to SOL/IDER session.\n");
980 995
981 if (adapter->hw.mac_type >= e1000_82543) { 996 if (hw->mac_type >= e1000_82543) {
982 netdev->features = NETIF_F_SG | 997 netdev->features = NETIF_F_SG |
983 NETIF_F_HW_CSUM | 998 NETIF_F_HW_CSUM |
984 NETIF_F_HW_VLAN_TX | 999 NETIF_F_HW_VLAN_TX |
985 NETIF_F_HW_VLAN_RX | 1000 NETIF_F_HW_VLAN_RX |
986 NETIF_F_HW_VLAN_FILTER; 1001 NETIF_F_HW_VLAN_FILTER;
987 if (adapter->hw.mac_type == e1000_ich8lan) 1002 if (hw->mac_type == e1000_ich8lan)
988 netdev->features &= ~NETIF_F_HW_VLAN_FILTER; 1003 netdev->features &= ~NETIF_F_HW_VLAN_FILTER;
989 } 1004 }
990 1005
991 if ((adapter->hw.mac_type >= e1000_82544) && 1006 if ((hw->mac_type >= e1000_82544) &&
992 (adapter->hw.mac_type != e1000_82547)) 1007 (hw->mac_type != e1000_82547))
993 netdev->features |= NETIF_F_TSO; 1008 netdev->features |= NETIF_F_TSO;
994 1009
995 if (adapter->hw.mac_type > e1000_82547_rev_2) 1010 if (hw->mac_type > e1000_82547_rev_2)
996 netdev->features |= NETIF_F_TSO6; 1011 netdev->features |= NETIF_F_TSO6;
997 if (pci_using_dac) 1012 if (pci_using_dac)
998 netdev->features |= NETIF_F_HIGHDMA; 1013 netdev->features |= NETIF_F_HIGHDMA;
999 1014
1000 netdev->features |= NETIF_F_LLTX; 1015 netdev->features |= NETIF_F_LLTX;
1001 1016
1002 adapter->en_mng_pt = e1000_enable_mng_pass_thru(&adapter->hw); 1017 adapter->en_mng_pt = e1000_enable_mng_pass_thru(hw);
1003 1018
1004 /* initialize eeprom parameters */ 1019 /* initialize eeprom parameters */
1005 if (e1000_init_eeprom_params(&adapter->hw)) { 1020 if (e1000_init_eeprom_params(hw)) {
1006 E1000_ERR("EEPROM initialization failed\n"); 1021 E1000_ERR("EEPROM initialization failed\n");
1007 goto err_eeprom; 1022 goto err_eeprom;
1008 } 1023 }
@@ -1010,10 +1025,10 @@ e1000_probe(struct pci_dev *pdev,
1010 /* before reading the EEPROM, reset the controller to 1025 /* before reading the EEPROM, reset the controller to
1011 * put the device in a known good starting state */ 1026 * put the device in a known good starting state */
1012 1027
1013 e1000_reset_hw(&adapter->hw); 1028 e1000_reset_hw(hw);
1014 1029
1015 /* make sure the EEPROM is good */ 1030 /* make sure the EEPROM is good */
1016 if (e1000_validate_eeprom_checksum(&adapter->hw) < 0) { 1031 if (e1000_validate_eeprom_checksum(hw) < 0) {
1017 DPRINTK(PROBE, ERR, "The EEPROM Checksum Is Not Valid\n"); 1032 DPRINTK(PROBE, ERR, "The EEPROM Checksum Is Not Valid\n");
1018 e1000_dump_eeprom(adapter); 1033 e1000_dump_eeprom(adapter);
1019 /* 1034 /*
@@ -1024,20 +1039,20 @@ e1000_probe(struct pci_dev *pdev,
1024 * interface after manually setting a hw addr using 1039 * interface after manually setting a hw addr using
1025 * `ip set address` 1040 * `ip set address`
1026 */ 1041 */
1027 memset(adapter->hw.mac_addr, 0, netdev->addr_len); 1042 memset(hw->mac_addr, 0, netdev->addr_len);
1028 } else { 1043 } else {
1029 /* copy the MAC address out of the EEPROM */ 1044 /* copy the MAC address out of the EEPROM */
1030 if (e1000_read_mac_addr(&adapter->hw)) 1045 if (e1000_read_mac_addr(hw))
1031 DPRINTK(PROBE, ERR, "EEPROM Read Error\n"); 1046 DPRINTK(PROBE, ERR, "EEPROM Read Error\n");
1032 } 1047 }
1033 /* don't block initalization here due to bad MAC address */ 1048 /* don't block initalization here due to bad MAC address */
1034 memcpy(netdev->dev_addr, adapter->hw.mac_addr, netdev->addr_len); 1049 memcpy(netdev->dev_addr, hw->mac_addr, netdev->addr_len);
1035 memcpy(netdev->perm_addr, adapter->hw.mac_addr, netdev->addr_len); 1050 memcpy(netdev->perm_addr, hw->mac_addr, netdev->addr_len);
1036 1051
1037 if (!is_valid_ether_addr(netdev->perm_addr)) 1052 if (!is_valid_ether_addr(netdev->perm_addr))
1038 DPRINTK(PROBE, ERR, "Invalid MAC Address\n"); 1053 DPRINTK(PROBE, ERR, "Invalid MAC Address\n");
1039 1054
1040 e1000_get_bus_info(&adapter->hw); 1055 e1000_get_bus_info(hw);
1041 1056
1042 init_timer(&adapter->tx_fifo_stall_timer); 1057 init_timer(&adapter->tx_fifo_stall_timer);
1043 adapter->tx_fifo_stall_timer.function = &e1000_82547_tx_fifo_stall; 1058 adapter->tx_fifo_stall_timer.function = &e1000_82547_tx_fifo_stall;
@@ -1060,18 +1075,18 @@ e1000_probe(struct pci_dev *pdev,
1060 * enable the ACPI Magic Packet filter 1075 * enable the ACPI Magic Packet filter
1061 */ 1076 */
1062 1077
1063 switch (adapter->hw.mac_type) { 1078 switch (hw->mac_type) {
1064 case e1000_82542_rev2_0: 1079 case e1000_82542_rev2_0:
1065 case e1000_82542_rev2_1: 1080 case e1000_82542_rev2_1:
1066 case e1000_82543: 1081 case e1000_82543:
1067 break; 1082 break;
1068 case e1000_82544: 1083 case e1000_82544:
1069 e1000_read_eeprom(&adapter->hw, 1084 e1000_read_eeprom(hw,
1070 EEPROM_INIT_CONTROL2_REG, 1, &eeprom_data); 1085 EEPROM_INIT_CONTROL2_REG, 1, &eeprom_data);
1071 eeprom_apme_mask = E1000_EEPROM_82544_APM; 1086 eeprom_apme_mask = E1000_EEPROM_82544_APM;
1072 break; 1087 break;
1073 case e1000_ich8lan: 1088 case e1000_ich8lan:
1074 e1000_read_eeprom(&adapter->hw, 1089 e1000_read_eeprom(hw,
1075 EEPROM_INIT_CONTROL1_REG, 1, &eeprom_data); 1090 EEPROM_INIT_CONTROL1_REG, 1, &eeprom_data);
1076 eeprom_apme_mask = E1000_EEPROM_ICH8_APME; 1091 eeprom_apme_mask = E1000_EEPROM_ICH8_APME;
1077 break; 1092 break;
@@ -1079,14 +1094,14 @@ e1000_probe(struct pci_dev *pdev,
1079 case e1000_82546_rev_3: 1094 case e1000_82546_rev_3:
1080 case e1000_82571: 1095 case e1000_82571:
1081 case e1000_80003es2lan: 1096 case e1000_80003es2lan:
1082 if (E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_FUNC_1){ 1097 if (er32(STATUS) & E1000_STATUS_FUNC_1){
1083 e1000_read_eeprom(&adapter->hw, 1098 e1000_read_eeprom(hw,
1084 EEPROM_INIT_CONTROL3_PORT_B, 1, &eeprom_data); 1099 EEPROM_INIT_CONTROL3_PORT_B, 1, &eeprom_data);
1085 break; 1100 break;
1086 } 1101 }
1087 /* Fall Through */ 1102 /* Fall Through */
1088 default: 1103 default:
1089 e1000_read_eeprom(&adapter->hw, 1104 e1000_read_eeprom(hw,
1090 EEPROM_INIT_CONTROL3_PORT_A, 1, &eeprom_data); 1105 EEPROM_INIT_CONTROL3_PORT_A, 1, &eeprom_data);
1091 break; 1106 break;
1092 } 1107 }
@@ -1105,7 +1120,7 @@ e1000_probe(struct pci_dev *pdev,
1105 case E1000_DEV_ID_82571EB_FIBER: 1120 case E1000_DEV_ID_82571EB_FIBER:
1106 /* Wake events only supported on port A for dual fiber 1121 /* Wake events only supported on port A for dual fiber
1107 * regardless of eeprom setting */ 1122 * regardless of eeprom setting */
1108 if (E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_FUNC_1) 1123 if (er32(STATUS) & E1000_STATUS_FUNC_1)
1109 adapter->eeprom_wol = 0; 1124 adapter->eeprom_wol = 0;
1110 break; 1125 break;
1111 case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3: 1126 case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3:
@@ -1128,8 +1143,6 @@ e1000_probe(struct pci_dev *pdev,
1128 adapter->wol = adapter->eeprom_wol; 1143 adapter->wol = adapter->eeprom_wol;
1129 1144
1130 /* print bus type/speed/width info */ 1145 /* print bus type/speed/width info */
1131 {
1132 struct e1000_hw *hw = &adapter->hw;
1133 DPRINTK(PROBE, INFO, "(PCI%s:%s:%s) ", 1146 DPRINTK(PROBE, INFO, "(PCI%s:%s:%s) ",
1134 ((hw->bus_type == e1000_bus_type_pcix) ? "-X" : 1147 ((hw->bus_type == e1000_bus_type_pcix) ? "-X" :
1135 (hw->bus_type == e1000_bus_type_pci_express ? " Express":"")), 1148 (hw->bus_type == e1000_bus_type_pci_express ? " Express":"")),
@@ -1142,11 +1155,10 @@ e1000_probe(struct pci_dev *pdev,
1142 (hw->bus_width == e1000_bus_width_pciex_4) ? "Width x4" : 1155 (hw->bus_width == e1000_bus_width_pciex_4) ? "Width x4" :
1143 (hw->bus_width == e1000_bus_width_pciex_1) ? "Width x1" : 1156 (hw->bus_width == e1000_bus_width_pciex_1) ? "Width x1" :
1144 "32-bit")); 1157 "32-bit"));
1145 }
1146 1158
1147 printk("%s\n", print_mac(mac, netdev->dev_addr)); 1159 printk("%s\n", print_mac(mac, netdev->dev_addr));
1148 1160
1149 if (adapter->hw.bus_type == e1000_bus_type_pci_express) { 1161 if (hw->bus_type == e1000_bus_type_pci_express) {
1150 DPRINTK(PROBE, WARNING, "This device (id %04x:%04x) will no " 1162 DPRINTK(PROBE, WARNING, "This device (id %04x:%04x) will no "
1151 "longer be supported by this driver in the future.\n", 1163 "longer be supported by this driver in the future.\n",
1152 pdev->vendor, pdev->device); 1164 pdev->vendor, pdev->device);
@@ -1161,8 +1173,8 @@ e1000_probe(struct pci_dev *pdev,
1161 * DRV_LOAD until the interface is up. For all other cases, 1173 * DRV_LOAD until the interface is up. For all other cases,
1162 * let the f/w know that the h/w is now under the control 1174 * let the f/w know that the h/w is now under the control
1163 * of the driver. */ 1175 * of the driver. */
1164 if (adapter->hw.mac_type != e1000_82573 || 1176 if (hw->mac_type != e1000_82573 ||
1165 !e1000_check_mng_mode(&adapter->hw)) 1177 !e1000_check_mng_mode(hw))
1166 e1000_get_hw_control(adapter); 1178 e1000_get_hw_control(adapter);
1167 1179
1168 /* tell the stack to leave us alone until e1000_open() is called */ 1180 /* tell the stack to leave us alone until e1000_open() is called */
@@ -1181,11 +1193,11 @@ e1000_probe(struct pci_dev *pdev,
1181err_register: 1193err_register:
1182 e1000_release_hw_control(adapter); 1194 e1000_release_hw_control(adapter);
1183err_eeprom: 1195err_eeprom:
1184 if (!e1000_check_phy_reset_block(&adapter->hw)) 1196 if (!e1000_check_phy_reset_block(hw))
1185 e1000_phy_hw_reset(&adapter->hw); 1197 e1000_phy_hw_reset(hw);
1186 1198
1187 if (adapter->hw.flash_address) 1199 if (hw->flash_address)
1188 iounmap(adapter->hw.flash_address); 1200 iounmap(hw->flash_address);
1189err_flashmap: 1201err_flashmap:
1190#ifdef CONFIG_E1000_NAPI 1202#ifdef CONFIG_E1000_NAPI
1191 for (i = 0; i < adapter->num_rx_queues; i++) 1203 for (i = 0; i < adapter->num_rx_queues; i++)
@@ -1198,7 +1210,7 @@ err_flashmap:
1198 kfree(adapter->polling_netdev); 1210 kfree(adapter->polling_netdev);
1199#endif 1211#endif
1200err_sw_init: 1212err_sw_init:
1201 iounmap(adapter->hw.hw_addr); 1213 iounmap(hw->hw_addr);
1202err_ioremap: 1214err_ioremap:
1203 free_netdev(netdev); 1215 free_netdev(netdev);
1204err_alloc_etherdev: 1216err_alloc_etherdev:
@@ -1223,6 +1235,7 @@ static void __devexit e1000_remove(struct pci_dev *pdev)
1223{ 1235{
1224 struct net_device *netdev = pci_get_drvdata(pdev); 1236 struct net_device *netdev = pci_get_drvdata(pdev);
1225 struct e1000_adapter *adapter = netdev_priv(netdev); 1237 struct e1000_adapter *adapter = netdev_priv(netdev);
1238 struct e1000_hw *hw = &adapter->hw;
1226#ifdef CONFIG_E1000_NAPI 1239#ifdef CONFIG_E1000_NAPI
1227 int i; 1240 int i;
1228#endif 1241#endif
@@ -1242,8 +1255,8 @@ static void __devexit e1000_remove(struct pci_dev *pdev)
1242 1255
1243 unregister_netdev(netdev); 1256 unregister_netdev(netdev);
1244 1257
1245 if (!e1000_check_phy_reset_block(&adapter->hw)) 1258 if (!e1000_check_phy_reset_block(hw))
1246 e1000_phy_hw_reset(&adapter->hw); 1259 e1000_phy_hw_reset(hw);
1247 1260
1248 kfree(adapter->tx_ring); 1261 kfree(adapter->tx_ring);
1249 kfree(adapter->rx_ring); 1262 kfree(adapter->rx_ring);
@@ -1251,9 +1264,9 @@ static void __devexit e1000_remove(struct pci_dev *pdev)
1251 kfree(adapter->polling_netdev); 1264 kfree(adapter->polling_netdev);
1252#endif 1265#endif
1253 1266
1254 iounmap(adapter->hw.hw_addr); 1267 iounmap(hw->hw_addr);
1255 if (adapter->hw.flash_address) 1268 if (hw->flash_address)
1256 iounmap(adapter->hw.flash_address); 1269 iounmap(hw->flash_address);
1257 pci_release_regions(pdev); 1270 pci_release_regions(pdev);
1258 1271
1259 free_netdev(netdev); 1272 free_netdev(netdev);
@@ -1407,6 +1420,7 @@ static int __devinit e1000_alloc_queues(struct e1000_adapter *adapter)
1407static int e1000_open(struct net_device *netdev) 1420static int e1000_open(struct net_device *netdev)
1408{ 1421{
1409 struct e1000_adapter *adapter = netdev_priv(netdev); 1422 struct e1000_adapter *adapter = netdev_priv(netdev);
1423 struct e1000_hw *hw = &adapter->hw;
1410 int err; 1424 int err;
1411 1425
1412 /* disallow open during test */ 1426 /* disallow open during test */
@@ -1426,15 +1440,15 @@ static int e1000_open(struct net_device *netdev)
1426 e1000_power_up_phy(adapter); 1440 e1000_power_up_phy(adapter);
1427 1441
1428 adapter->mng_vlan_id = E1000_MNG_VLAN_NONE; 1442 adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
1429 if ((adapter->hw.mng_cookie.status & 1443 if ((hw->mng_cookie.status &
1430 E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) { 1444 E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) {
1431 e1000_update_mng_vlan(adapter); 1445 e1000_update_mng_vlan(adapter);
1432 } 1446 }
1433 1447
1434 /* If AMT is enabled, let the firmware know that the network 1448 /* If AMT is enabled, let the firmware know that the network
1435 * interface is now open */ 1449 * interface is now open */
1436 if (adapter->hw.mac_type == e1000_82573 && 1450 if (hw->mac_type == e1000_82573 &&
1437 e1000_check_mng_mode(&adapter->hw)) 1451 e1000_check_mng_mode(hw))
1438 e1000_get_hw_control(adapter); 1452 e1000_get_hw_control(adapter);
1439 1453
1440 /* before we allocate an interrupt, we must be ready to handle it. 1454 /* before we allocate an interrupt, we must be ready to handle it.
@@ -1459,7 +1473,7 @@ static int e1000_open(struct net_device *netdev)
1459 netif_start_queue(netdev); 1473 netif_start_queue(netdev);
1460 1474
1461 /* fire a link status change interrupt to start the watchdog */ 1475 /* fire a link status change interrupt to start the watchdog */
1462 E1000_WRITE_REG(&adapter->hw, ICS, E1000_ICS_LSC); 1476 ew32(ICS, E1000_ICS_LSC);
1463 1477
1464 return E1000_SUCCESS; 1478 return E1000_SUCCESS;
1465 1479
@@ -1490,6 +1504,7 @@ err_setup_tx:
1490static int e1000_close(struct net_device *netdev) 1504static int e1000_close(struct net_device *netdev)
1491{ 1505{
1492 struct e1000_adapter *adapter = netdev_priv(netdev); 1506 struct e1000_adapter *adapter = netdev_priv(netdev);
1507 struct e1000_hw *hw = &adapter->hw;
1493 1508
1494 WARN_ON(test_bit(__E1000_RESETTING, &adapter->flags)); 1509 WARN_ON(test_bit(__E1000_RESETTING, &adapter->flags));
1495 e1000_down(adapter); 1510 e1000_down(adapter);
@@ -1501,7 +1516,7 @@ static int e1000_close(struct net_device *netdev)
1501 1516
1502 /* kill manageability vlan ID if supported, but not if a vlan with 1517 /* kill manageability vlan ID if supported, but not if a vlan with
1503 * the same ID is registered on the host OS (let 8021q kill it) */ 1518 * the same ID is registered on the host OS (let 8021q kill it) */
1504 if ((adapter->hw.mng_cookie.status & 1519 if ((hw->mng_cookie.status &
1505 E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) && 1520 E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) &&
1506 !(adapter->vlgrp && 1521 !(adapter->vlgrp &&
1507 vlan_group_get_device(adapter->vlgrp, adapter->mng_vlan_id))) { 1522 vlan_group_get_device(adapter->vlgrp, adapter->mng_vlan_id))) {
@@ -1510,8 +1525,8 @@ static int e1000_close(struct net_device *netdev)
1510 1525
1511 /* If AMT is enabled, let the firmware know that the network 1526 /* If AMT is enabled, let the firmware know that the network
1512 * interface is now closed */ 1527 * interface is now closed */
1513 if (adapter->hw.mac_type == e1000_82573 && 1528 if (hw->mac_type == e1000_82573 &&
1514 e1000_check_mng_mode(&adapter->hw)) 1529 e1000_check_mng_mode(hw))
1515 e1000_release_hw_control(adapter); 1530 e1000_release_hw_control(adapter);
1516 1531
1517 return 0; 1532 return 0;
@@ -1526,13 +1541,14 @@ static int e1000_close(struct net_device *netdev)
1526static bool e1000_check_64k_bound(struct e1000_adapter *adapter, void *start, 1541static bool e1000_check_64k_bound(struct e1000_adapter *adapter, void *start,
1527 unsigned long len) 1542 unsigned long len)
1528{ 1543{
1544 struct e1000_hw *hw = &adapter->hw;
1529 unsigned long begin = (unsigned long) start; 1545 unsigned long begin = (unsigned long) start;
1530 unsigned long end = begin + len; 1546 unsigned long end = begin + len;
1531 1547
1532 /* First rev 82545 and 82546 need to not allow any memory 1548 /* First rev 82545 and 82546 need to not allow any memory
1533 * write location to cross 64k boundary due to errata 23 */ 1549 * write location to cross 64k boundary due to errata 23 */
1534 if (adapter->hw.mac_type == e1000_82545 || 1550 if (hw->mac_type == e1000_82545 ||
1535 adapter->hw.mac_type == e1000_82546) { 1551 hw->mac_type == e1000_82546) {
1536 return ((begin ^ (end - 1)) >> 16) != 0 ? false : true; 1552 return ((begin ^ (end - 1)) >> 16) != 0 ? false : true;
1537 } 1553 }
1538 1554
@@ -1663,18 +1679,18 @@ static void e1000_configure_tx(struct e1000_adapter *adapter)
1663 tdba = adapter->tx_ring[0].dma; 1679 tdba = adapter->tx_ring[0].dma;
1664 tdlen = adapter->tx_ring[0].count * 1680 tdlen = adapter->tx_ring[0].count *
1665 sizeof(struct e1000_tx_desc); 1681 sizeof(struct e1000_tx_desc);
1666 E1000_WRITE_REG(hw, TDLEN, tdlen); 1682 ew32(TDLEN, tdlen);
1667 E1000_WRITE_REG(hw, TDBAH, (tdba >> 32)); 1683 ew32(TDBAH, (tdba >> 32));
1668 E1000_WRITE_REG(hw, TDBAL, (tdba & 0x00000000ffffffffULL)); 1684 ew32(TDBAL, (tdba & 0x00000000ffffffffULL));
1669 E1000_WRITE_REG(hw, TDT, 0); 1685 ew32(TDT, 0);
1670 E1000_WRITE_REG(hw, TDH, 0); 1686 ew32(TDH, 0);
1671 adapter->tx_ring[0].tdh = ((hw->mac_type >= e1000_82543) ? E1000_TDH : E1000_82542_TDH); 1687 adapter->tx_ring[0].tdh = ((hw->mac_type >= e1000_82543) ? E1000_TDH : E1000_82542_TDH);
1672 adapter->tx_ring[0].tdt = ((hw->mac_type >= e1000_82543) ? E1000_TDT : E1000_82542_TDT); 1688 adapter->tx_ring[0].tdt = ((hw->mac_type >= e1000_82543) ? E1000_TDT : E1000_82542_TDT);
1673 break; 1689 break;
1674 } 1690 }
1675 1691
1676 /* Set the default values for the Tx Inter Packet Gap timer */ 1692 /* Set the default values for the Tx Inter Packet Gap timer */
1677 if (adapter->hw.mac_type <= e1000_82547_rev_2 && 1693 if (hw->mac_type <= e1000_82547_rev_2 &&
1678 (hw->media_type == e1000_media_type_fiber || 1694 (hw->media_type == e1000_media_type_fiber ||
1679 hw->media_type == e1000_media_type_internal_serdes)) 1695 hw->media_type == e1000_media_type_internal_serdes))
1680 tipg = DEFAULT_82543_TIPG_IPGT_FIBER; 1696 tipg = DEFAULT_82543_TIPG_IPGT_FIBER;
@@ -1699,34 +1715,34 @@ static void e1000_configure_tx(struct e1000_adapter *adapter)
1699 } 1715 }
1700 tipg |= ipgr1 << E1000_TIPG_IPGR1_SHIFT; 1716 tipg |= ipgr1 << E1000_TIPG_IPGR1_SHIFT;
1701 tipg |= ipgr2 << E1000_TIPG_IPGR2_SHIFT; 1717 tipg |= ipgr2 << E1000_TIPG_IPGR2_SHIFT;
1702 E1000_WRITE_REG(hw, TIPG, tipg); 1718 ew32(TIPG, tipg);
1703 1719
1704 /* Set the Tx Interrupt Delay register */ 1720 /* Set the Tx Interrupt Delay register */
1705 1721
1706 E1000_WRITE_REG(hw, TIDV, adapter->tx_int_delay); 1722 ew32(TIDV, adapter->tx_int_delay);
1707 if (hw->mac_type >= e1000_82540) 1723 if (hw->mac_type >= e1000_82540)
1708 E1000_WRITE_REG(hw, TADV, adapter->tx_abs_int_delay); 1724 ew32(TADV, adapter->tx_abs_int_delay);
1709 1725
1710 /* Program the Transmit Control Register */ 1726 /* Program the Transmit Control Register */
1711 1727
1712 tctl = E1000_READ_REG(hw, TCTL); 1728 tctl = er32(TCTL);
1713 tctl &= ~E1000_TCTL_CT; 1729 tctl &= ~E1000_TCTL_CT;
1714 tctl |= E1000_TCTL_PSP | E1000_TCTL_RTLC | 1730 tctl |= E1000_TCTL_PSP | E1000_TCTL_RTLC |
1715 (E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT); 1731 (E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT);
1716 1732
1717 if (hw->mac_type == e1000_82571 || hw->mac_type == e1000_82572) { 1733 if (hw->mac_type == e1000_82571 || hw->mac_type == e1000_82572) {
1718 tarc = E1000_READ_REG(hw, TARC0); 1734 tarc = er32(TARC0);
1719 /* set the speed mode bit, we'll clear it if we're not at 1735 /* set the speed mode bit, we'll clear it if we're not at
1720 * gigabit link later */ 1736 * gigabit link later */
1721 tarc |= (1 << 21); 1737 tarc |= (1 << 21);
1722 E1000_WRITE_REG(hw, TARC0, tarc); 1738 ew32(TARC0, tarc);
1723 } else if (hw->mac_type == e1000_80003es2lan) { 1739 } else if (hw->mac_type == e1000_80003es2lan) {
1724 tarc = E1000_READ_REG(hw, TARC0); 1740 tarc = er32(TARC0);
1725 tarc |= 1; 1741 tarc |= 1;
1726 E1000_WRITE_REG(hw, TARC0, tarc); 1742 ew32(TARC0, tarc);
1727 tarc = E1000_READ_REG(hw, TARC1); 1743 tarc = er32(TARC1);
1728 tarc |= 1; 1744 tarc |= 1;
1729 E1000_WRITE_REG(hw, TARC1, tarc); 1745 ew32(TARC1, tarc);
1730 } 1746 }
1731 1747
1732 e1000_config_collision_dist(hw); 1748 e1000_config_collision_dist(hw);
@@ -1749,7 +1765,7 @@ static void e1000_configure_tx(struct e1000_adapter *adapter)
1749 hw->bus_type == e1000_bus_type_pcix) 1765 hw->bus_type == e1000_bus_type_pcix)
1750 adapter->pcix_82544 = 1; 1766 adapter->pcix_82544 = 1;
1751 1767
1752 E1000_WRITE_REG(hw, TCTL, tctl); 1768 ew32(TCTL, tctl);
1753 1769
1754} 1770}
1755 1771
@@ -1764,6 +1780,7 @@ static void e1000_configure_tx(struct e1000_adapter *adapter)
1764static int e1000_setup_rx_resources(struct e1000_adapter *adapter, 1780static int e1000_setup_rx_resources(struct e1000_adapter *adapter,
1765 struct e1000_rx_ring *rxdr) 1781 struct e1000_rx_ring *rxdr)
1766{ 1782{
1783 struct e1000_hw *hw = &adapter->hw;
1767 struct pci_dev *pdev = adapter->pdev; 1784 struct pci_dev *pdev = adapter->pdev;
1768 int size, desc_len; 1785 int size, desc_len;
1769 1786
@@ -1796,7 +1813,7 @@ static int e1000_setup_rx_resources(struct e1000_adapter *adapter,
1796 return -ENOMEM; 1813 return -ENOMEM;
1797 } 1814 }
1798 1815
1799 if (adapter->hw.mac_type <= e1000_82547_rev_2) 1816 if (hw->mac_type <= e1000_82547_rev_2)
1800 desc_len = sizeof(struct e1000_rx_desc); 1817 desc_len = sizeof(struct e1000_rx_desc);
1801 else 1818 else
1802 desc_len = sizeof(union e1000_rx_desc_packet_split); 1819 desc_len = sizeof(union e1000_rx_desc_packet_split);
@@ -1892,21 +1909,22 @@ int e1000_setup_all_rx_resources(struct e1000_adapter *adapter)
1892 (((S) & (PAGE_SIZE - 1)) ? 1 : 0)) 1909 (((S) & (PAGE_SIZE - 1)) ? 1 : 0))
1893static void e1000_setup_rctl(struct e1000_adapter *adapter) 1910static void e1000_setup_rctl(struct e1000_adapter *adapter)
1894{ 1911{
1912 struct e1000_hw *hw = &adapter->hw;
1895 u32 rctl, rfctl; 1913 u32 rctl, rfctl;
1896 u32 psrctl = 0; 1914 u32 psrctl = 0;
1897#ifndef CONFIG_E1000_DISABLE_PACKET_SPLIT 1915#ifndef CONFIG_E1000_DISABLE_PACKET_SPLIT
1898 u32 pages = 0; 1916 u32 pages = 0;
1899#endif 1917#endif
1900 1918
1901 rctl = E1000_READ_REG(&adapter->hw, RCTL); 1919 rctl = er32(RCTL);
1902 1920
1903 rctl &= ~(3 << E1000_RCTL_MO_SHIFT); 1921 rctl &= ~(3 << E1000_RCTL_MO_SHIFT);
1904 1922
1905 rctl |= E1000_RCTL_EN | E1000_RCTL_BAM | 1923 rctl |= E1000_RCTL_EN | E1000_RCTL_BAM |
1906 E1000_RCTL_LBM_NO | E1000_RCTL_RDMTS_HALF | 1924 E1000_RCTL_LBM_NO | E1000_RCTL_RDMTS_HALF |
1907 (adapter->hw.mc_filter_type << E1000_RCTL_MO_SHIFT); 1925 (hw->mc_filter_type << E1000_RCTL_MO_SHIFT);
1908 1926
1909 if (adapter->hw.tbi_compatibility_on == 1) 1927 if (hw->tbi_compatibility_on == 1)
1910 rctl |= E1000_RCTL_SBP; 1928 rctl |= E1000_RCTL_SBP;
1911 else 1929 else
1912 rctl &= ~E1000_RCTL_SBP; 1930 rctl &= ~E1000_RCTL_SBP;
@@ -1959,7 +1977,7 @@ static void e1000_setup_rctl(struct e1000_adapter *adapter)
1959 /* allocations using alloc_page take too long for regular MTU 1977 /* allocations using alloc_page take too long for regular MTU
1960 * so only enable packet split for jumbo frames */ 1978 * so only enable packet split for jumbo frames */
1961 pages = PAGE_USE_COUNT(adapter->netdev->mtu); 1979 pages = PAGE_USE_COUNT(adapter->netdev->mtu);
1962 if ((adapter->hw.mac_type >= e1000_82571) && (pages <= 3) && 1980 if ((hw->mac_type >= e1000_82571) && (pages <= 3) &&
1963 PAGE_SIZE <= 16384 && (rctl & E1000_RCTL_LPE)) 1981 PAGE_SIZE <= 16384 && (rctl & E1000_RCTL_LPE))
1964 adapter->rx_ps_pages = pages; 1982 adapter->rx_ps_pages = pages;
1965 else 1983 else
@@ -1967,14 +1985,14 @@ static void e1000_setup_rctl(struct e1000_adapter *adapter)
1967#endif 1985#endif
1968 if (adapter->rx_ps_pages) { 1986 if (adapter->rx_ps_pages) {
1969 /* Configure extra packet-split registers */ 1987 /* Configure extra packet-split registers */
1970 rfctl = E1000_READ_REG(&adapter->hw, RFCTL); 1988 rfctl = er32(RFCTL);
1971 rfctl |= E1000_RFCTL_EXTEN; 1989 rfctl |= E1000_RFCTL_EXTEN;
1972 /* disable packet split support for IPv6 extension headers, 1990 /* disable packet split support for IPv6 extension headers,
1973 * because some malformed IPv6 headers can hang the RX */ 1991 * because some malformed IPv6 headers can hang the RX */
1974 rfctl |= (E1000_RFCTL_IPV6_EX_DIS | 1992 rfctl |= (E1000_RFCTL_IPV6_EX_DIS |
1975 E1000_RFCTL_NEW_IPV6_EXT_DIS); 1993 E1000_RFCTL_NEW_IPV6_EXT_DIS);
1976 1994
1977 E1000_WRITE_REG(&adapter->hw, RFCTL, rfctl); 1995 ew32(RFCTL, rfctl);
1978 1996
1979 rctl |= E1000_RCTL_DTYP_PS; 1997 rctl |= E1000_RCTL_DTYP_PS;
1980 1998
@@ -1994,10 +2012,10 @@ static void e1000_setup_rctl(struct e1000_adapter *adapter)
1994 break; 2012 break;
1995 } 2013 }
1996 2014
1997 E1000_WRITE_REG(&adapter->hw, PSRCTL, psrctl); 2015 ew32(PSRCTL, psrctl);
1998 } 2016 }
1999 2017
2000 E1000_WRITE_REG(&adapter->hw, RCTL, rctl); 2018 ew32(RCTL, rctl);
2001} 2019}
2002 2020
2003/** 2021/**
@@ -2027,30 +2045,29 @@ static void e1000_configure_rx(struct e1000_adapter *adapter)
2027 } 2045 }
2028 2046
2029 /* disable receives while setting up the descriptors */ 2047 /* disable receives while setting up the descriptors */
2030 rctl = E1000_READ_REG(hw, RCTL); 2048 rctl = er32(RCTL);
2031 E1000_WRITE_REG(hw, RCTL, rctl & ~E1000_RCTL_EN); 2049 ew32(RCTL, rctl & ~E1000_RCTL_EN);
2032 2050
2033 /* set the Receive Delay Timer Register */ 2051 /* set the Receive Delay Timer Register */
2034 E1000_WRITE_REG(hw, RDTR, adapter->rx_int_delay); 2052 ew32(RDTR, adapter->rx_int_delay);
2035 2053
2036 if (hw->mac_type >= e1000_82540) { 2054 if (hw->mac_type >= e1000_82540) {
2037 E1000_WRITE_REG(hw, RADV, adapter->rx_abs_int_delay); 2055 ew32(RADV, adapter->rx_abs_int_delay);
2038 if (adapter->itr_setting != 0) 2056 if (adapter->itr_setting != 0)
2039 E1000_WRITE_REG(hw, ITR, 2057 ew32(ITR, 1000000000 / (adapter->itr * 256));
2040 1000000000 / (adapter->itr * 256));
2041 } 2058 }
2042 2059
2043 if (hw->mac_type >= e1000_82571) { 2060 if (hw->mac_type >= e1000_82571) {
2044 ctrl_ext = E1000_READ_REG(hw, CTRL_EXT); 2061 ctrl_ext = er32(CTRL_EXT);
2045 /* Reset delay timers after every interrupt */ 2062 /* Reset delay timers after every interrupt */
2046 ctrl_ext |= E1000_CTRL_EXT_INT_TIMER_CLR; 2063 ctrl_ext |= E1000_CTRL_EXT_INT_TIMER_CLR;
2047#ifdef CONFIG_E1000_NAPI 2064#ifdef CONFIG_E1000_NAPI
2048 /* Auto-Mask interrupts upon ICR access */ 2065 /* Auto-Mask interrupts upon ICR access */
2049 ctrl_ext |= E1000_CTRL_EXT_IAME; 2066 ctrl_ext |= E1000_CTRL_EXT_IAME;
2050 E1000_WRITE_REG(hw, IAM, 0xffffffff); 2067 ew32(IAM, 0xffffffff);
2051#endif 2068#endif
2052 E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext); 2069 ew32(CTRL_EXT, ctrl_ext);
2053 E1000_WRITE_FLUSH(hw); 2070 E1000_WRITE_FLUSH();
2054 } 2071 }
2055 2072
2056 /* Setup the HW Rx Head and Tail Descriptor Pointers and 2073 /* Setup the HW Rx Head and Tail Descriptor Pointers and
@@ -2059,11 +2076,11 @@ static void e1000_configure_rx(struct e1000_adapter *adapter)
2059 case 1: 2076 case 1:
2060 default: 2077 default:
2061 rdba = adapter->rx_ring[0].dma; 2078 rdba = adapter->rx_ring[0].dma;
2062 E1000_WRITE_REG(hw, RDLEN, rdlen); 2079 ew32(RDLEN, rdlen);
2063 E1000_WRITE_REG(hw, RDBAH, (rdba >> 32)); 2080 ew32(RDBAH, (rdba >> 32));
2064 E1000_WRITE_REG(hw, RDBAL, (rdba & 0x00000000ffffffffULL)); 2081 ew32(RDBAL, (rdba & 0x00000000ffffffffULL));
2065 E1000_WRITE_REG(hw, RDT, 0); 2082 ew32(RDT, 0);
2066 E1000_WRITE_REG(hw, RDH, 0); 2083 ew32(RDH, 0);
2067 adapter->rx_ring[0].rdh = ((hw->mac_type >= e1000_82543) ? E1000_RDH : E1000_82542_RDH); 2084 adapter->rx_ring[0].rdh = ((hw->mac_type >= e1000_82543) ? E1000_RDH : E1000_82542_RDH);
2068 adapter->rx_ring[0].rdt = ((hw->mac_type >= e1000_82543) ? E1000_RDT : E1000_82542_RDT); 2085 adapter->rx_ring[0].rdt = ((hw->mac_type >= e1000_82543) ? E1000_RDT : E1000_82542_RDT);
2069 break; 2086 break;
@@ -2071,7 +2088,7 @@ static void e1000_configure_rx(struct e1000_adapter *adapter)
2071 2088
2072 /* Enable 82543 Receive Checksum Offload for TCP and UDP */ 2089 /* Enable 82543 Receive Checksum Offload for TCP and UDP */
2073 if (hw->mac_type >= e1000_82543) { 2090 if (hw->mac_type >= e1000_82543) {
2074 rxcsum = E1000_READ_REG(hw, RXCSUM); 2091 rxcsum = er32(RXCSUM);
2075 if (adapter->rx_csum) { 2092 if (adapter->rx_csum) {
2076 rxcsum |= E1000_RXCSUM_TUOFL; 2093 rxcsum |= E1000_RXCSUM_TUOFL;
2077 2094
@@ -2085,17 +2102,17 @@ static void e1000_configure_rx(struct e1000_adapter *adapter)
2085 rxcsum &= ~E1000_RXCSUM_TUOFL; 2102 rxcsum &= ~E1000_RXCSUM_TUOFL;
2086 /* don't need to clear IPPCSE as it defaults to 0 */ 2103 /* don't need to clear IPPCSE as it defaults to 0 */
2087 } 2104 }
2088 E1000_WRITE_REG(hw, RXCSUM, rxcsum); 2105 ew32(RXCSUM, rxcsum);
2089 } 2106 }
2090 2107
2091 /* enable early receives on 82573, only takes effect if using > 2048 2108 /* enable early receives on 82573, only takes effect if using > 2048
2092 * byte total frame size. for example only for jumbo frames */ 2109 * byte total frame size. for example only for jumbo frames */
2093#define E1000_ERT_2048 0x100 2110#define E1000_ERT_2048 0x100
2094 if (hw->mac_type == e1000_82573) 2111 if (hw->mac_type == e1000_82573)
2095 E1000_WRITE_REG(hw, ERT, E1000_ERT_2048); 2112 ew32(ERT, E1000_ERT_2048);
2096 2113
2097 /* Enable Receives */ 2114 /* Enable Receives */
2098 E1000_WRITE_REG(hw, RCTL, rctl); 2115 ew32(RCTL, rctl);
2099} 2116}
2100 2117
2101/** 2118/**
@@ -2162,6 +2179,7 @@ static void e1000_unmap_and_free_tx_resource(struct e1000_adapter *adapter,
2162static void e1000_clean_tx_ring(struct e1000_adapter *adapter, 2179static void e1000_clean_tx_ring(struct e1000_adapter *adapter,
2163 struct e1000_tx_ring *tx_ring) 2180 struct e1000_tx_ring *tx_ring)
2164{ 2181{
2182 struct e1000_hw *hw = &adapter->hw;
2165 struct e1000_buffer *buffer_info; 2183 struct e1000_buffer *buffer_info;
2166 unsigned long size; 2184 unsigned long size;
2167 unsigned int i; 2185 unsigned int i;
@@ -2184,8 +2202,8 @@ static void e1000_clean_tx_ring(struct e1000_adapter *adapter,
2184 tx_ring->next_to_clean = 0; 2202 tx_ring->next_to_clean = 0;
2185 tx_ring->last_tx_tso = 0; 2203 tx_ring->last_tx_tso = 0;
2186 2204
2187 writel(0, adapter->hw.hw_addr + tx_ring->tdh); 2205 writel(0, hw->hw_addr + tx_ring->tdh);
2188 writel(0, adapter->hw.hw_addr + tx_ring->tdt); 2206 writel(0, hw->hw_addr + tx_ring->tdt);
2189} 2207}
2190 2208
2191/** 2209/**
@@ -2252,6 +2270,7 @@ void e1000_free_all_rx_resources(struct e1000_adapter *adapter)
2252static void e1000_clean_rx_ring(struct e1000_adapter *adapter, 2270static void e1000_clean_rx_ring(struct e1000_adapter *adapter,
2253 struct e1000_rx_ring *rx_ring) 2271 struct e1000_rx_ring *rx_ring)
2254{ 2272{
2273 struct e1000_hw *hw = &adapter->hw;
2255 struct e1000_buffer *buffer_info; 2274 struct e1000_buffer *buffer_info;
2256 struct e1000_ps_page *ps_page; 2275 struct e1000_ps_page *ps_page;
2257 struct e1000_ps_page_dma *ps_page_dma; 2276 struct e1000_ps_page_dma *ps_page_dma;
@@ -2298,8 +2317,8 @@ static void e1000_clean_rx_ring(struct e1000_adapter *adapter,
2298 rx_ring->next_to_clean = 0; 2317 rx_ring->next_to_clean = 0;
2299 rx_ring->next_to_use = 0; 2318 rx_ring->next_to_use = 0;
2300 2319
2301 writel(0, adapter->hw.hw_addr + rx_ring->rdh); 2320 writel(0, hw->hw_addr + rx_ring->rdh);
2302 writel(0, adapter->hw.hw_addr + rx_ring->rdt); 2321 writel(0, hw->hw_addr + rx_ring->rdt);
2303} 2322}
2304 2323
2305/** 2324/**
@@ -2320,15 +2339,16 @@ static void e1000_clean_all_rx_rings(struct e1000_adapter *adapter)
2320 */ 2339 */
2321static void e1000_enter_82542_rst(struct e1000_adapter *adapter) 2340static void e1000_enter_82542_rst(struct e1000_adapter *adapter)
2322{ 2341{
2342 struct e1000_hw *hw = &adapter->hw;
2323 struct net_device *netdev = adapter->netdev; 2343 struct net_device *netdev = adapter->netdev;
2324 u32 rctl; 2344 u32 rctl;
2325 2345
2326 e1000_pci_clear_mwi(&adapter->hw); 2346 e1000_pci_clear_mwi(hw);
2327 2347
2328 rctl = E1000_READ_REG(&adapter->hw, RCTL); 2348 rctl = er32(RCTL);
2329 rctl |= E1000_RCTL_RST; 2349 rctl |= E1000_RCTL_RST;
2330 E1000_WRITE_REG(&adapter->hw, RCTL, rctl); 2350 ew32(RCTL, rctl);
2331 E1000_WRITE_FLUSH(&adapter->hw); 2351 E1000_WRITE_FLUSH();
2332 mdelay(5); 2352 mdelay(5);
2333 2353
2334 if (netif_running(netdev)) 2354 if (netif_running(netdev))
@@ -2337,17 +2357,18 @@ static void e1000_enter_82542_rst(struct e1000_adapter *adapter)
2337 2357
2338static void e1000_leave_82542_rst(struct e1000_adapter *adapter) 2358static void e1000_leave_82542_rst(struct e1000_adapter *adapter)
2339{ 2359{
2360 struct e1000_hw *hw = &adapter->hw;
2340 struct net_device *netdev = adapter->netdev; 2361 struct net_device *netdev = adapter->netdev;
2341 u32 rctl; 2362 u32 rctl;
2342 2363
2343 rctl = E1000_READ_REG(&adapter->hw, RCTL); 2364 rctl = er32(RCTL);
2344 rctl &= ~E1000_RCTL_RST; 2365 rctl &= ~E1000_RCTL_RST;
2345 E1000_WRITE_REG(&adapter->hw, RCTL, rctl); 2366 ew32(RCTL, rctl);
2346 E1000_WRITE_FLUSH(&adapter->hw); 2367 E1000_WRITE_FLUSH();
2347 mdelay(5); 2368 mdelay(5);
2348 2369
2349 if (adapter->hw.pci_cmd_word & PCI_COMMAND_INVALIDATE) 2370 if (hw->pci_cmd_word & PCI_COMMAND_INVALIDATE)
2350 e1000_pci_set_mwi(&adapter->hw); 2371 e1000_pci_set_mwi(hw);
2351 2372
2352 if (netif_running(netdev)) { 2373 if (netif_running(netdev)) {
2353 /* No need to loop, because 82542 supports only 1 queue */ 2374 /* No need to loop, because 82542 supports only 1 queue */
@@ -2368,6 +2389,7 @@ static void e1000_leave_82542_rst(struct e1000_adapter *adapter)
2368static int e1000_set_mac(struct net_device *netdev, void *p) 2389static int e1000_set_mac(struct net_device *netdev, void *p)
2369{ 2390{
2370 struct e1000_adapter *adapter = netdev_priv(netdev); 2391 struct e1000_adapter *adapter = netdev_priv(netdev);
2392 struct e1000_hw *hw = &adapter->hw;
2371 struct sockaddr *addr = p; 2393 struct sockaddr *addr = p;
2372 2394
2373 if (!is_valid_ether_addr(addr->sa_data)) 2395 if (!is_valid_ether_addr(addr->sa_data))
@@ -2375,19 +2397,19 @@ static int e1000_set_mac(struct net_device *netdev, void *p)
2375 2397
2376 /* 82542 2.0 needs to be in reset to write receive address registers */ 2398 /* 82542 2.0 needs to be in reset to write receive address registers */
2377 2399
2378 if (adapter->hw.mac_type == e1000_82542_rev2_0) 2400 if (hw->mac_type == e1000_82542_rev2_0)
2379 e1000_enter_82542_rst(adapter); 2401 e1000_enter_82542_rst(adapter);
2380 2402
2381 memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len); 2403 memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
2382 memcpy(adapter->hw.mac_addr, addr->sa_data, netdev->addr_len); 2404 memcpy(hw->mac_addr, addr->sa_data, netdev->addr_len);
2383 2405
2384 e1000_rar_set(&adapter->hw, adapter->hw.mac_addr, 0); 2406 e1000_rar_set(hw, hw->mac_addr, 0);
2385 2407
2386 /* With 82571 controllers, LAA may be overwritten (with the default) 2408 /* With 82571 controllers, LAA may be overwritten (with the default)
2387 * due to controller reset from the other port. */ 2409 * due to controller reset from the other port. */
2388 if (adapter->hw.mac_type == e1000_82571) { 2410 if (hw->mac_type == e1000_82571) {
2389 /* activate the work around */ 2411 /* activate the work around */
2390 adapter->hw.laa_is_present = 1; 2412 hw->laa_is_present = 1;
2391 2413
2392 /* Hold a copy of the LAA in RAR[14] This is done so that 2414 /* Hold a copy of the LAA in RAR[14] This is done so that
2393 * between the time RAR[0] gets clobbered and the time it 2415 * between the time RAR[0] gets clobbered and the time it
@@ -2395,11 +2417,11 @@ static int e1000_set_mac(struct net_device *netdev, void *p)
2395 * of the RARs and no incoming packets directed to this port 2417 * of the RARs and no incoming packets directed to this port
2396 * are dropped. Eventaully the LAA will be in RAR[0] and 2418 * are dropped. Eventaully the LAA will be in RAR[0] and
2397 * RAR[14] */ 2419 * RAR[14] */
2398 e1000_rar_set(&adapter->hw, adapter->hw.mac_addr, 2420 e1000_rar_set(hw, hw->mac_addr,
2399 E1000_RAR_ENTRIES - 1); 2421 E1000_RAR_ENTRIES - 1);
2400 } 2422 }
2401 2423
2402 if (adapter->hw.mac_type == e1000_82542_rev2_0) 2424 if (hw->mac_type == e1000_82542_rev2_0)
2403 e1000_leave_82542_rst(adapter); 2425 e1000_leave_82542_rst(adapter);
2404 2426
2405 return 0; 2427 return 0;
@@ -2428,16 +2450,16 @@ static void e1000_set_rx_mode(struct net_device *netdev)
2428 E1000_NUM_MTA_REGISTERS_ICH8LAN : 2450 E1000_NUM_MTA_REGISTERS_ICH8LAN :
2429 E1000_NUM_MTA_REGISTERS; 2451 E1000_NUM_MTA_REGISTERS;
2430 2452
2431 if (adapter->hw.mac_type == e1000_ich8lan) 2453 if (hw->mac_type == e1000_ich8lan)
2432 rar_entries = E1000_RAR_ENTRIES_ICH8LAN; 2454 rar_entries = E1000_RAR_ENTRIES_ICH8LAN;
2433 2455
2434 /* reserve RAR[14] for LAA over-write work-around */ 2456 /* reserve RAR[14] for LAA over-write work-around */
2435 if (adapter->hw.mac_type == e1000_82571) 2457 if (hw->mac_type == e1000_82571)
2436 rar_entries--; 2458 rar_entries--;
2437 2459
2438 /* Check for Promiscuous and All Multicast modes */ 2460 /* Check for Promiscuous and All Multicast modes */
2439 2461
2440 rctl = E1000_READ_REG(hw, RCTL); 2462 rctl = er32(RCTL);
2441 2463
2442 if (netdev->flags & IFF_PROMISC) { 2464 if (netdev->flags & IFF_PROMISC) {
2443 rctl |= (E1000_RCTL_UPE | E1000_RCTL_MPE); 2465 rctl |= (E1000_RCTL_UPE | E1000_RCTL_MPE);
@@ -2460,7 +2482,7 @@ static void e1000_set_rx_mode(struct net_device *netdev)
2460 uc_ptr = netdev->uc_list; 2482 uc_ptr = netdev->uc_list;
2461 } 2483 }
2462 2484
2463 E1000_WRITE_REG(hw, RCTL, rctl); 2485 ew32(RCTL, rctl);
2464 2486
2465 /* 82542 2.0 needs to be in reset to write receive address registers */ 2487 /* 82542 2.0 needs to be in reset to write receive address registers */
2466 2488
@@ -2486,9 +2508,9 @@ static void e1000_set_rx_mode(struct net_device *netdev)
2486 mc_ptr = mc_ptr->next; 2508 mc_ptr = mc_ptr->next;
2487 } else { 2509 } else {
2488 E1000_WRITE_REG_ARRAY(hw, RA, i << 1, 0); 2510 E1000_WRITE_REG_ARRAY(hw, RA, i << 1, 0);
2489 E1000_WRITE_FLUSH(hw); 2511 E1000_WRITE_FLUSH();
2490 E1000_WRITE_REG_ARRAY(hw, RA, (i << 1) + 1, 0); 2512 E1000_WRITE_REG_ARRAY(hw, RA, (i << 1) + 1, 0);
2491 E1000_WRITE_FLUSH(hw); 2513 E1000_WRITE_FLUSH();
2492 } 2514 }
2493 } 2515 }
2494 WARN_ON(uc_ptr != NULL); 2516 WARN_ON(uc_ptr != NULL);
@@ -2497,7 +2519,7 @@ static void e1000_set_rx_mode(struct net_device *netdev)
2497 2519
2498 for (i = 0; i < mta_reg_count; i++) { 2520 for (i = 0; i < mta_reg_count; i++) {
2499 E1000_WRITE_REG_ARRAY(hw, MTA, i, 0); 2521 E1000_WRITE_REG_ARRAY(hw, MTA, i, 0);
2500 E1000_WRITE_FLUSH(hw); 2522 E1000_WRITE_FLUSH();
2501 } 2523 }
2502 2524
2503 /* load any remaining addresses into the hash table */ 2525 /* load any remaining addresses into the hash table */
@@ -2517,7 +2539,8 @@ static void e1000_set_rx_mode(struct net_device *netdev)
2517static void e1000_update_phy_info(unsigned long data) 2539static void e1000_update_phy_info(unsigned long data)
2518{ 2540{
2519 struct e1000_adapter *adapter = (struct e1000_adapter *) data; 2541 struct e1000_adapter *adapter = (struct e1000_adapter *) data;
2520 e1000_phy_get_info(&adapter->hw, &adapter->phy_info); 2542 struct e1000_hw *hw = &adapter->hw;
2543 e1000_phy_get_info(hw, &adapter->phy_info);
2521} 2544}
2522 2545
2523/** 2546/**
@@ -2528,29 +2551,22 @@ static void e1000_update_phy_info(unsigned long data)
2528static void e1000_82547_tx_fifo_stall(unsigned long data) 2551static void e1000_82547_tx_fifo_stall(unsigned long data)
2529{ 2552{
2530 struct e1000_adapter *adapter = (struct e1000_adapter *) data; 2553 struct e1000_adapter *adapter = (struct e1000_adapter *) data;
2554 struct e1000_hw *hw = &adapter->hw;
2531 struct net_device *netdev = adapter->netdev; 2555 struct net_device *netdev = adapter->netdev;
2532 u32 tctl; 2556 u32 tctl;
2533 2557
2534 if (atomic_read(&adapter->tx_fifo_stall)) { 2558 if (atomic_read(&adapter->tx_fifo_stall)) {
2535 if ((E1000_READ_REG(&adapter->hw, TDT) == 2559 if ((er32(TDT) == er32(TDH)) &&
2536 E1000_READ_REG(&adapter->hw, TDH)) && 2560 (er32(TDFT) == er32(TDFH)) &&
2537 (E1000_READ_REG(&adapter->hw, TDFT) == 2561 (er32(TDFTS) == er32(TDFHS))) {
2538 E1000_READ_REG(&adapter->hw, TDFH)) && 2562 tctl = er32(TCTL);
2539 (E1000_READ_REG(&adapter->hw, TDFTS) == 2563 ew32(TCTL, tctl & ~E1000_TCTL_EN);
2540 E1000_READ_REG(&adapter->hw, TDFHS))) { 2564 ew32(TDFT, adapter->tx_head_addr);
2541 tctl = E1000_READ_REG(&adapter->hw, TCTL); 2565 ew32(TDFH, adapter->tx_head_addr);
2542 E1000_WRITE_REG(&adapter->hw, TCTL, 2566 ew32(TDFTS, adapter->tx_head_addr);
2543 tctl & ~E1000_TCTL_EN); 2567 ew32(TDFHS, adapter->tx_head_addr);
2544 E1000_WRITE_REG(&adapter->hw, TDFT, 2568 ew32(TCTL, tctl);
2545 adapter->tx_head_addr); 2569 E1000_WRITE_FLUSH();
2546 E1000_WRITE_REG(&adapter->hw, TDFH,
2547 adapter->tx_head_addr);
2548 E1000_WRITE_REG(&adapter->hw, TDFTS,
2549 adapter->tx_head_addr);
2550 E1000_WRITE_REG(&adapter->hw, TDFHS,
2551 adapter->tx_head_addr);
2552 E1000_WRITE_REG(&adapter->hw, TCTL, tctl);
2553 E1000_WRITE_FLUSH(&adapter->hw);
2554 2570
2555 adapter->tx_fifo_head = 0; 2571 adapter->tx_fifo_head = 0;
2556 atomic_set(&adapter->tx_fifo_stall, 0); 2572 atomic_set(&adapter->tx_fifo_stall, 0);
@@ -2568,41 +2584,42 @@ static void e1000_82547_tx_fifo_stall(unsigned long data)
2568static void e1000_watchdog(unsigned long data) 2584static void e1000_watchdog(unsigned long data)
2569{ 2585{
2570 struct e1000_adapter *adapter = (struct e1000_adapter *) data; 2586 struct e1000_adapter *adapter = (struct e1000_adapter *) data;
2587 struct e1000_hw *hw = &adapter->hw;
2571 struct net_device *netdev = adapter->netdev; 2588 struct net_device *netdev = adapter->netdev;
2572 struct e1000_tx_ring *txdr = adapter->tx_ring; 2589 struct e1000_tx_ring *txdr = adapter->tx_ring;
2573 u32 link, tctl; 2590 u32 link, tctl;
2574 s32 ret_val; 2591 s32 ret_val;
2575 2592
2576 ret_val = e1000_check_for_link(&adapter->hw); 2593 ret_val = e1000_check_for_link(hw);
2577 if ((ret_val == E1000_ERR_PHY) && 2594 if ((ret_val == E1000_ERR_PHY) &&
2578 (adapter->hw.phy_type == e1000_phy_igp_3) && 2595 (hw->phy_type == e1000_phy_igp_3) &&
2579 (E1000_READ_REG(&adapter->hw, CTRL) & E1000_PHY_CTRL_GBE_DISABLE)) { 2596 (er32(CTRL) & E1000_PHY_CTRL_GBE_DISABLE)) {
2580 /* See e1000_kumeran_lock_loss_workaround() */ 2597 /* See e1000_kumeran_lock_loss_workaround() */
2581 DPRINTK(LINK, INFO, 2598 DPRINTK(LINK, INFO,
2582 "Gigabit has been disabled, downgrading speed\n"); 2599 "Gigabit has been disabled, downgrading speed\n");
2583 } 2600 }
2584 2601
2585 if (adapter->hw.mac_type == e1000_82573) { 2602 if (hw->mac_type == e1000_82573) {
2586 e1000_enable_tx_pkt_filtering(&adapter->hw); 2603 e1000_enable_tx_pkt_filtering(hw);
2587 if (adapter->mng_vlan_id != adapter->hw.mng_cookie.vlan_id) 2604 if (adapter->mng_vlan_id != hw->mng_cookie.vlan_id)
2588 e1000_update_mng_vlan(adapter); 2605 e1000_update_mng_vlan(adapter);
2589 } 2606 }
2590 2607
2591 if ((adapter->hw.media_type == e1000_media_type_internal_serdes) && 2608 if ((hw->media_type == e1000_media_type_internal_serdes) &&
2592 !(E1000_READ_REG(&adapter->hw, TXCW) & E1000_TXCW_ANE)) 2609 !(er32(TXCW) & E1000_TXCW_ANE))
2593 link = !adapter->hw.serdes_link_down; 2610 link = !hw->serdes_link_down;
2594 else 2611 else
2595 link = E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_LU; 2612 link = er32(STATUS) & E1000_STATUS_LU;
2596 2613
2597 if (link) { 2614 if (link) {
2598 if (!netif_carrier_ok(netdev)) { 2615 if (!netif_carrier_ok(netdev)) {
2599 u32 ctrl; 2616 u32 ctrl;
2600 bool txb2b = true; 2617 bool txb2b = true;
2601 e1000_get_speed_and_duplex(&adapter->hw, 2618 e1000_get_speed_and_duplex(hw,
2602 &adapter->link_speed, 2619 &adapter->link_speed,
2603 &adapter->link_duplex); 2620 &adapter->link_duplex);
2604 2621
2605 ctrl = E1000_READ_REG(&adapter->hw, CTRL); 2622 ctrl = er32(CTRL);
2606 DPRINTK(LINK, INFO, "NIC Link is Up %d Mbps %s, " 2623 DPRINTK(LINK, INFO, "NIC Link is Up %d Mbps %s, "
2607 "Flow Control: %s\n", 2624 "Flow Control: %s\n",
2608 adapter->link_speed, 2625 adapter->link_speed,
@@ -2630,19 +2647,19 @@ static void e1000_watchdog(unsigned long data)
2630 break; 2647 break;
2631 } 2648 }
2632 2649
2633 if ((adapter->hw.mac_type == e1000_82571 || 2650 if ((hw->mac_type == e1000_82571 ||
2634 adapter->hw.mac_type == e1000_82572) && 2651 hw->mac_type == e1000_82572) &&
2635 !txb2b) { 2652 !txb2b) {
2636 u32 tarc0; 2653 u32 tarc0;
2637 tarc0 = E1000_READ_REG(&adapter->hw, TARC0); 2654 tarc0 = er32(TARC0);
2638 tarc0 &= ~(1 << 21); 2655 tarc0 &= ~(1 << 21);
2639 E1000_WRITE_REG(&adapter->hw, TARC0, tarc0); 2656 ew32(TARC0, tarc0);
2640 } 2657 }
2641 2658
2642 /* disable TSO for pcie and 10/100 speeds, to avoid 2659 /* disable TSO for pcie and 10/100 speeds, to avoid
2643 * some hardware issues */ 2660 * some hardware issues */
2644 if (!adapter->tso_force && 2661 if (!adapter->tso_force &&
2645 adapter->hw.bus_type == e1000_bus_type_pci_express){ 2662 hw->bus_type == e1000_bus_type_pci_express){
2646 switch (adapter->link_speed) { 2663 switch (adapter->link_speed) {
2647 case SPEED_10: 2664 case SPEED_10:
2648 case SPEED_100: 2665 case SPEED_100:
@@ -2663,9 +2680,9 @@ static void e1000_watchdog(unsigned long data)
2663 2680
2664 /* enable transmits in the hardware, need to do this 2681 /* enable transmits in the hardware, need to do this
2665 * after setting TARC0 */ 2682 * after setting TARC0 */
2666 tctl = E1000_READ_REG(&adapter->hw, TCTL); 2683 tctl = er32(TCTL);
2667 tctl |= E1000_TCTL_EN; 2684 tctl |= E1000_TCTL_EN;
2668 E1000_WRITE_REG(&adapter->hw, TCTL, tctl); 2685 ew32(TCTL, tctl);
2669 2686
2670 netif_carrier_on(netdev); 2687 netif_carrier_on(netdev);
2671 netif_wake_queue(netdev); 2688 netif_wake_queue(netdev);
@@ -2673,10 +2690,9 @@ static void e1000_watchdog(unsigned long data)
2673 adapter->smartspeed = 0; 2690 adapter->smartspeed = 0;
2674 } else { 2691 } else {
2675 /* make sure the receive unit is started */ 2692 /* make sure the receive unit is started */
2676 if (adapter->hw.rx_needs_kicking) { 2693 if (hw->rx_needs_kicking) {
2677 struct e1000_hw *hw = &adapter->hw; 2694 u32 rctl = er32(RCTL);
2678 u32 rctl = E1000_READ_REG(hw, RCTL); 2695 ew32(RCTL, rctl | E1000_RCTL_EN);
2679 E1000_WRITE_REG(hw, RCTL, rctl | E1000_RCTL_EN);
2680 } 2696 }
2681 } 2697 }
2682 } else { 2698 } else {
@@ -2693,7 +2709,7 @@ static void e1000_watchdog(unsigned long data)
2693 * disable receives in the ISR and 2709 * disable receives in the ISR and
2694 * reset device here in the watchdog 2710 * reset device here in the watchdog
2695 */ 2711 */
2696 if (adapter->hw.mac_type == e1000_80003es2lan) 2712 if (hw->mac_type == e1000_80003es2lan)
2697 /* reset device */ 2713 /* reset device */
2698 schedule_work(&adapter->reset_task); 2714 schedule_work(&adapter->reset_task);
2699 } 2715 }
@@ -2703,9 +2719,9 @@ static void e1000_watchdog(unsigned long data)
2703 2719
2704 e1000_update_stats(adapter); 2720 e1000_update_stats(adapter);
2705 2721
2706 adapter->hw.tx_packet_delta = adapter->stats.tpt - adapter->tpt_old; 2722 hw->tx_packet_delta = adapter->stats.tpt - adapter->tpt_old;
2707 adapter->tpt_old = adapter->stats.tpt; 2723 adapter->tpt_old = adapter->stats.tpt;
2708 adapter->hw.collision_delta = adapter->stats.colc - adapter->colc_old; 2724 hw->collision_delta = adapter->stats.colc - adapter->colc_old;
2709 adapter->colc_old = adapter->stats.colc; 2725 adapter->colc_old = adapter->stats.colc;
2710 2726
2711 adapter->gorcl = adapter->stats.gorcl - adapter->gorcl_old; 2727 adapter->gorcl = adapter->stats.gorcl - adapter->gorcl_old;
@@ -2713,7 +2729,7 @@ static void e1000_watchdog(unsigned long data)
2713 adapter->gotcl = adapter->stats.gotcl - adapter->gotcl_old; 2729 adapter->gotcl = adapter->stats.gotcl - adapter->gotcl_old;
2714 adapter->gotcl_old = adapter->stats.gotcl; 2730 adapter->gotcl_old = adapter->stats.gotcl;
2715 2731
2716 e1000_update_adaptive(&adapter->hw); 2732 e1000_update_adaptive(hw);
2717 2733
2718 if (!netif_carrier_ok(netdev)) { 2734 if (!netif_carrier_ok(netdev)) {
2719 if (E1000_DESC_UNUSED(txdr) + 1 < txdr->count) { 2735 if (E1000_DESC_UNUSED(txdr) + 1 < txdr->count) {
@@ -2727,15 +2743,15 @@ static void e1000_watchdog(unsigned long data)
2727 } 2743 }
2728 2744
2729 /* Cause software interrupt to ensure rx ring is cleaned */ 2745 /* Cause software interrupt to ensure rx ring is cleaned */
2730 E1000_WRITE_REG(&adapter->hw, ICS, E1000_ICS_RXDMT0); 2746 ew32(ICS, E1000_ICS_RXDMT0);
2731 2747
2732 /* Force detection of hung controller every watchdog period */ 2748 /* Force detection of hung controller every watchdog period */
2733 adapter->detect_tx_hung = true; 2749 adapter->detect_tx_hung = true;
2734 2750
2735 /* With 82571 controllers, LAA may be overwritten due to controller 2751 /* With 82571 controllers, LAA may be overwritten due to controller
2736 * reset from the other port. Set the appropriate LAA in RAR[0] */ 2752 * reset from the other port. Set the appropriate LAA in RAR[0] */
2737 if (adapter->hw.mac_type == e1000_82571 && adapter->hw.laa_is_present) 2753 if (hw->mac_type == e1000_82571 && hw->laa_is_present)
2738 e1000_rar_set(&adapter->hw, adapter->hw.mac_addr, 0); 2754 e1000_rar_set(hw, hw->mac_addr, 0);
2739 2755
2740 /* Reset the timer */ 2756 /* Reset the timer */
2741 mod_timer(&adapter->watchdog_timer, round_jiffies(jiffies + 2 * HZ)); 2757 mod_timer(&adapter->watchdog_timer, round_jiffies(jiffies + 2 * HZ));
@@ -2870,7 +2886,7 @@ set_itr_now:
2870 min(adapter->itr + (new_itr >> 2), new_itr) : 2886 min(adapter->itr + (new_itr >> 2), new_itr) :
2871 new_itr; 2887 new_itr;
2872 adapter->itr = new_itr; 2888 adapter->itr = new_itr;
2873 E1000_WRITE_REG(hw, ITR, 1000000000 / (new_itr * 256)); 2889 ew32(ITR, 1000000000 / (new_itr * 256));
2874 } 2890 }
2875 2891
2876 return; 2892 return;
@@ -2999,6 +3015,7 @@ static int e1000_tx_map(struct e1000_adapter *adapter,
2999 unsigned int max_per_txd, unsigned int nr_frags, 3015 unsigned int max_per_txd, unsigned int nr_frags,
3000 unsigned int mss) 3016 unsigned int mss)
3001{ 3017{
3018 struct e1000_hw *hw = &adapter->hw;
3002 struct e1000_buffer *buffer_info; 3019 struct e1000_buffer *buffer_info;
3003 unsigned int len = skb->len; 3020 unsigned int len = skb->len;
3004 unsigned int offset = 0, size, count = 0, i; 3021 unsigned int offset = 0, size, count = 0, i;
@@ -3029,7 +3046,7 @@ static int e1000_tx_map(struct e1000_adapter *adapter,
3029 * The fix is to make sure that the first descriptor of a 3046 * The fix is to make sure that the first descriptor of a
3030 * packet is smaller than 2048 - 16 - 16 (or 2016) bytes 3047 * packet is smaller than 2048 - 16 - 16 (or 2016) bytes
3031 */ 3048 */
3032 if (unlikely((adapter->hw.bus_type == e1000_bus_type_pcix) && 3049 if (unlikely((hw->bus_type == e1000_bus_type_pcix) &&
3033 (size > 2015) && count == 0)) 3050 (size > 2015) && count == 0))
3034 size = 2015; 3051 size = 2015;
3035 3052
@@ -3105,6 +3122,7 @@ static void e1000_tx_queue(struct e1000_adapter *adapter,
3105 struct e1000_tx_ring *tx_ring, int tx_flags, 3122 struct e1000_tx_ring *tx_ring, int tx_flags,
3106 int count) 3123 int count)
3107{ 3124{
3125 struct e1000_hw *hw = &adapter->hw;
3108 struct e1000_tx_desc *tx_desc = NULL; 3126 struct e1000_tx_desc *tx_desc = NULL;
3109 struct e1000_buffer *buffer_info; 3127 struct e1000_buffer *buffer_info;
3110 u32 txd_upper = 0, txd_lower = E1000_TXD_CMD_IFCS; 3128 u32 txd_upper = 0, txd_lower = E1000_TXD_CMD_IFCS;
@@ -3150,7 +3168,7 @@ static void e1000_tx_queue(struct e1000_adapter *adapter,
3150 wmb(); 3168 wmb();
3151 3169
3152 tx_ring->next_to_use = i; 3170 tx_ring->next_to_use = i;
3153 writel(i, adapter->hw.hw_addr + tx_ring->tdt); 3171 writel(i, hw->hw_addr + tx_ring->tdt);
3154 /* we need this if more than one processor can write to our tail 3172 /* we need this if more than one processor can write to our tail
3155 * at a time, it syncronizes IO on IA64/Altix systems */ 3173 * at a time, it syncronizes IO on IA64/Altix systems */
3156 mmiowb(); 3174 mmiowb();
@@ -3201,8 +3219,8 @@ static int e1000_transfer_dhcp_info(struct e1000_adapter *adapter,
3201 struct e1000_hw *hw = &adapter->hw; 3219 struct e1000_hw *hw = &adapter->hw;
3202 u16 length, offset; 3220 u16 length, offset;
3203 if (vlan_tx_tag_present(skb)) { 3221 if (vlan_tx_tag_present(skb)) {
3204 if (!((vlan_tx_tag_get(skb) == adapter->hw.mng_cookie.vlan_id) && 3222 if (!((vlan_tx_tag_get(skb) == hw->mng_cookie.vlan_id) &&
3205 ( adapter->hw.mng_cookie.status & 3223 ( hw->mng_cookie.status &
3206 E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) ) 3224 E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) )
3207 return 0; 3225 return 0;
3208 } 3226 }
@@ -3263,6 +3281,7 @@ static int e1000_maybe_stop_tx(struct net_device *netdev,
3263static int e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev) 3281static int e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
3264{ 3282{
3265 struct e1000_adapter *adapter = netdev_priv(netdev); 3283 struct e1000_adapter *adapter = netdev_priv(netdev);
3284 struct e1000_hw *hw = &adapter->hw;
3266 struct e1000_tx_ring *tx_ring; 3285 struct e1000_tx_ring *tx_ring;
3267 unsigned int first, max_per_txd = E1000_MAX_DATA_PER_TXD; 3286 unsigned int first, max_per_txd = E1000_MAX_DATA_PER_TXD;
3268 unsigned int max_txd_pwr = E1000_MAX_TXD_PWR; 3287 unsigned int max_txd_pwr = E1000_MAX_TXD_PWR;
@@ -3288,7 +3307,7 @@ static int e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
3288 3307
3289 /* 82571 and newer doesn't need the workaround that limited descriptor 3308 /* 82571 and newer doesn't need the workaround that limited descriptor
3290 * length to 4kB */ 3309 * length to 4kB */
3291 if (adapter->hw.mac_type >= e1000_82571) 3310 if (hw->mac_type >= e1000_82571)
3292 max_per_txd = 8192; 3311 max_per_txd = 8192;
3293 3312
3294 mss = skb_shinfo(skb)->gso_size; 3313 mss = skb_shinfo(skb)->gso_size;
@@ -3308,7 +3327,7 @@ static int e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
3308 * frags into skb->data */ 3327 * frags into skb->data */
3309 hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb); 3328 hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
3310 if (skb->data_len && hdr_len == len) { 3329 if (skb->data_len && hdr_len == len) {
3311 switch (adapter->hw.mac_type) { 3330 switch (hw->mac_type) {
3312 unsigned int pull_size; 3331 unsigned int pull_size;
3313 case e1000_82544: 3332 case e1000_82544:
3314 /* Make sure we have room to chop off 4 bytes, 3333 /* Make sure we have room to chop off 4 bytes,
@@ -3357,7 +3376,7 @@ static int e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
3357 /* work-around for errata 10 and it applies to all controllers 3376 /* work-around for errata 10 and it applies to all controllers
3358 * in PCI-X mode, so add one more descriptor to the count 3377 * in PCI-X mode, so add one more descriptor to the count
3359 */ 3378 */
3360 if (unlikely((adapter->hw.bus_type == e1000_bus_type_pcix) && 3379 if (unlikely((hw->bus_type == e1000_bus_type_pcix) &&
3361 (len > 2015))) 3380 (len > 2015)))
3362 count++; 3381 count++;
3363 3382
@@ -3369,8 +3388,8 @@ static int e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
3369 count += nr_frags; 3388 count += nr_frags;
3370 3389
3371 3390
3372 if (adapter->hw.tx_pkt_filtering && 3391 if (hw->tx_pkt_filtering &&
3373 (adapter->hw.mac_type == e1000_82573)) 3392 (hw->mac_type == e1000_82573))
3374 e1000_transfer_dhcp_info(adapter, skb); 3393 e1000_transfer_dhcp_info(adapter, skb);
3375 3394
3376 if (!spin_trylock_irqsave(&tx_ring->tx_lock, flags)) 3395 if (!spin_trylock_irqsave(&tx_ring->tx_lock, flags))
@@ -3384,7 +3403,7 @@ static int e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
3384 return NETDEV_TX_BUSY; 3403 return NETDEV_TX_BUSY;
3385 } 3404 }
3386 3405
3387 if (unlikely(adapter->hw.mac_type == e1000_82547)) { 3406 if (unlikely(hw->mac_type == e1000_82547)) {
3388 if (unlikely(e1000_82547_fifo_workaround(adapter, skb))) { 3407 if (unlikely(e1000_82547_fifo_workaround(adapter, skb))) {
3389 netif_stop_queue(netdev); 3408 netif_stop_queue(netdev);
3390 mod_timer(&adapter->tx_fifo_stall_timer, jiffies + 1); 3409 mod_timer(&adapter->tx_fifo_stall_timer, jiffies + 1);
@@ -3481,6 +3500,7 @@ static struct net_device_stats *e1000_get_stats(struct net_device *netdev)
3481static int e1000_change_mtu(struct net_device *netdev, int new_mtu) 3500static int e1000_change_mtu(struct net_device *netdev, int new_mtu)
3482{ 3501{
3483 struct e1000_adapter *adapter = netdev_priv(netdev); 3502 struct e1000_adapter *adapter = netdev_priv(netdev);
3503 struct e1000_hw *hw = &adapter->hw;
3484 int max_frame = new_mtu + ENET_HEADER_SIZE + ETHERNET_FCS_SIZE; 3504 int max_frame = new_mtu + ENET_HEADER_SIZE + ETHERNET_FCS_SIZE;
3485 u16 eeprom_data = 0; 3505 u16 eeprom_data = 0;
3486 3506
@@ -3491,7 +3511,7 @@ static int e1000_change_mtu(struct net_device *netdev, int new_mtu)
3491 } 3511 }
3492 3512
3493 /* Adapter-specific max frame size limits. */ 3513 /* Adapter-specific max frame size limits. */
3494 switch (adapter->hw.mac_type) { 3514 switch (hw->mac_type) {
3495 case e1000_undefined ... e1000_82542_rev2_1: 3515 case e1000_undefined ... e1000_82542_rev2_1:
3496 case e1000_ich8lan: 3516 case e1000_ich8lan:
3497 if (max_frame > MAXIMUM_ETHERNET_FRAME_SIZE) { 3517 if (max_frame > MAXIMUM_ETHERNET_FRAME_SIZE) {
@@ -3503,9 +3523,9 @@ static int e1000_change_mtu(struct net_device *netdev, int new_mtu)
3503 /* Jumbo Frames not supported if: 3523 /* Jumbo Frames not supported if:
3504 * - this is not an 82573L device 3524 * - this is not an 82573L device
3505 * - ASPM is enabled in any way (0x1A bits 3:2) */ 3525 * - ASPM is enabled in any way (0x1A bits 3:2) */
3506 e1000_read_eeprom(&adapter->hw, EEPROM_INIT_3GIO_3, 1, 3526 e1000_read_eeprom(hw, EEPROM_INIT_3GIO_3, 1,
3507 &eeprom_data); 3527 &eeprom_data);
3508 if ((adapter->hw.device_id != E1000_DEV_ID_82573L) || 3528 if ((hw->device_id != E1000_DEV_ID_82573L) ||
3509 (eeprom_data & EEPROM_WORD1A_ASPM_MASK)) { 3529 (eeprom_data & EEPROM_WORD1A_ASPM_MASK)) {
3510 if (max_frame > MAXIMUM_ETHERNET_FRAME_SIZE) { 3530 if (max_frame > MAXIMUM_ETHERNET_FRAME_SIZE) {
3511 DPRINTK(PROBE, ERR, 3531 DPRINTK(PROBE, ERR,
@@ -3552,13 +3572,13 @@ static int e1000_change_mtu(struct net_device *netdev, int new_mtu)
3552 adapter->rx_buffer_len = E1000_RXBUFFER_16384; 3572 adapter->rx_buffer_len = E1000_RXBUFFER_16384;
3553 3573
3554 /* adjust allocation if LPE protects us, and we aren't using SBP */ 3574 /* adjust allocation if LPE protects us, and we aren't using SBP */
3555 if (!adapter->hw.tbi_compatibility_on && 3575 if (!hw->tbi_compatibility_on &&
3556 ((max_frame == MAXIMUM_ETHERNET_FRAME_SIZE) || 3576 ((max_frame == MAXIMUM_ETHERNET_FRAME_SIZE) ||
3557 (max_frame == MAXIMUM_ETHERNET_VLAN_SIZE))) 3577 (max_frame == MAXIMUM_ETHERNET_VLAN_SIZE)))
3558 adapter->rx_buffer_len = MAXIMUM_ETHERNET_VLAN_SIZE; 3578 adapter->rx_buffer_len = MAXIMUM_ETHERNET_VLAN_SIZE;
3559 3579
3560 netdev->mtu = new_mtu; 3580 netdev->mtu = new_mtu;
3561 adapter->hw.max_frame_size = max_frame; 3581 hw->max_frame_size = max_frame;
3562 3582
3563 if (netif_running(netdev)) 3583 if (netif_running(netdev))
3564 e1000_reinit_locked(adapter); 3584 e1000_reinit_locked(adapter);
@@ -3596,89 +3616,89 @@ void e1000_update_stats(struct e1000_adapter *adapter)
3596 * be written while holding adapter->stats_lock 3616 * be written while holding adapter->stats_lock
3597 */ 3617 */
3598 3618
3599 adapter->stats.crcerrs += E1000_READ_REG(hw, CRCERRS); 3619 adapter->stats.crcerrs += er32(CRCERRS);
3600 adapter->stats.gprc += E1000_READ_REG(hw, GPRC); 3620 adapter->stats.gprc += er32(GPRC);
3601 adapter->stats.gorcl += E1000_READ_REG(hw, GORCL); 3621 adapter->stats.gorcl += er32(GORCL);
3602 adapter->stats.gorch += E1000_READ_REG(hw, GORCH); 3622 adapter->stats.gorch += er32(GORCH);
3603 adapter->stats.bprc += E1000_READ_REG(hw, BPRC); 3623 adapter->stats.bprc += er32(BPRC);
3604 adapter->stats.mprc += E1000_READ_REG(hw, MPRC); 3624 adapter->stats.mprc += er32(MPRC);
3605 adapter->stats.roc += E1000_READ_REG(hw, ROC); 3625 adapter->stats.roc += er32(ROC);
3606 3626
3607 if (adapter->hw.mac_type != e1000_ich8lan) { 3627 if (hw->mac_type != e1000_ich8lan) {
3608 adapter->stats.prc64 += E1000_READ_REG(hw, PRC64); 3628 adapter->stats.prc64 += er32(PRC64);
3609 adapter->stats.prc127 += E1000_READ_REG(hw, PRC127); 3629 adapter->stats.prc127 += er32(PRC127);
3610 adapter->stats.prc255 += E1000_READ_REG(hw, PRC255); 3630 adapter->stats.prc255 += er32(PRC255);
3611 adapter->stats.prc511 += E1000_READ_REG(hw, PRC511); 3631 adapter->stats.prc511 += er32(PRC511);
3612 adapter->stats.prc1023 += E1000_READ_REG(hw, PRC1023); 3632 adapter->stats.prc1023 += er32(PRC1023);
3613 adapter->stats.prc1522 += E1000_READ_REG(hw, PRC1522); 3633 adapter->stats.prc1522 += er32(PRC1522);
3614 } 3634 }
3615 3635
3616 adapter->stats.symerrs += E1000_READ_REG(hw, SYMERRS); 3636 adapter->stats.symerrs += er32(SYMERRS);
3617 adapter->stats.mpc += E1000_READ_REG(hw, MPC); 3637 adapter->stats.mpc += er32(MPC);
3618 adapter->stats.scc += E1000_READ_REG(hw, SCC); 3638 adapter->stats.scc += er32(SCC);
3619 adapter->stats.ecol += E1000_READ_REG(hw, ECOL); 3639 adapter->stats.ecol += er32(ECOL);
3620 adapter->stats.mcc += E1000_READ_REG(hw, MCC); 3640 adapter->stats.mcc += er32(MCC);
3621 adapter->stats.latecol += E1000_READ_REG(hw, LATECOL); 3641 adapter->stats.latecol += er32(LATECOL);
3622 adapter->stats.dc += E1000_READ_REG(hw, DC); 3642 adapter->stats.dc += er32(DC);
3623 adapter->stats.sec += E1000_READ_REG(hw, SEC); 3643 adapter->stats.sec += er32(SEC);
3624 adapter->stats.rlec += E1000_READ_REG(hw, RLEC); 3644 adapter->stats.rlec += er32(RLEC);
3625 adapter->stats.xonrxc += E1000_READ_REG(hw, XONRXC); 3645 adapter->stats.xonrxc += er32(XONRXC);
3626 adapter->stats.xontxc += E1000_READ_REG(hw, XONTXC); 3646 adapter->stats.xontxc += er32(XONTXC);
3627 adapter->stats.xoffrxc += E1000_READ_REG(hw, XOFFRXC); 3647 adapter->stats.xoffrxc += er32(XOFFRXC);
3628 adapter->stats.xofftxc += E1000_READ_REG(hw, XOFFTXC); 3648 adapter->stats.xofftxc += er32(XOFFTXC);
3629 adapter->stats.fcruc += E1000_READ_REG(hw, FCRUC); 3649 adapter->stats.fcruc += er32(FCRUC);
3630 adapter->stats.gptc += E1000_READ_REG(hw, GPTC); 3650 adapter->stats.gptc += er32(GPTC);
3631 adapter->stats.gotcl += E1000_READ_REG(hw, GOTCL); 3651 adapter->stats.gotcl += er32(GOTCL);
3632 adapter->stats.gotch += E1000_READ_REG(hw, GOTCH); 3652 adapter->stats.gotch += er32(GOTCH);
3633 adapter->stats.rnbc += E1000_READ_REG(hw, RNBC); 3653 adapter->stats.rnbc += er32(RNBC);
3634 adapter->stats.ruc += E1000_READ_REG(hw, RUC); 3654 adapter->stats.ruc += er32(RUC);
3635 adapter->stats.rfc += E1000_READ_REG(hw, RFC); 3655 adapter->stats.rfc += er32(RFC);
3636 adapter->stats.rjc += E1000_READ_REG(hw, RJC); 3656 adapter->stats.rjc += er32(RJC);
3637 adapter->stats.torl += E1000_READ_REG(hw, TORL); 3657 adapter->stats.torl += er32(TORL);
3638 adapter->stats.torh += E1000_READ_REG(hw, TORH); 3658 adapter->stats.torh += er32(TORH);
3639 adapter->stats.totl += E1000_READ_REG(hw, TOTL); 3659 adapter->stats.totl += er32(TOTL);
3640 adapter->stats.toth += E1000_READ_REG(hw, TOTH); 3660 adapter->stats.toth += er32(TOTH);
3641 adapter->stats.tpr += E1000_READ_REG(hw, TPR); 3661 adapter->stats.tpr += er32(TPR);
3642 3662
3643 if (adapter->hw.mac_type != e1000_ich8lan) { 3663 if (hw->mac_type != e1000_ich8lan) {
3644 adapter->stats.ptc64 += E1000_READ_REG(hw, PTC64); 3664 adapter->stats.ptc64 += er32(PTC64);
3645 adapter->stats.ptc127 += E1000_READ_REG(hw, PTC127); 3665 adapter->stats.ptc127 += er32(PTC127);
3646 adapter->stats.ptc255 += E1000_READ_REG(hw, PTC255); 3666 adapter->stats.ptc255 += er32(PTC255);
3647 adapter->stats.ptc511 += E1000_READ_REG(hw, PTC511); 3667 adapter->stats.ptc511 += er32(PTC511);
3648 adapter->stats.ptc1023 += E1000_READ_REG(hw, PTC1023); 3668 adapter->stats.ptc1023 += er32(PTC1023);
3649 adapter->stats.ptc1522 += E1000_READ_REG(hw, PTC1522); 3669 adapter->stats.ptc1522 += er32(PTC1522);
3650 } 3670 }
3651 3671
3652 adapter->stats.mptc += E1000_READ_REG(hw, MPTC); 3672 adapter->stats.mptc += er32(MPTC);
3653 adapter->stats.bptc += E1000_READ_REG(hw, BPTC); 3673 adapter->stats.bptc += er32(BPTC);
3654 3674
3655 /* used for adaptive IFS */ 3675 /* used for adaptive IFS */
3656 3676
3657 hw->tx_packet_delta = E1000_READ_REG(hw, TPT); 3677 hw->tx_packet_delta = er32(TPT);
3658 adapter->stats.tpt += hw->tx_packet_delta; 3678 adapter->stats.tpt += hw->tx_packet_delta;
3659 hw->collision_delta = E1000_READ_REG(hw, COLC); 3679 hw->collision_delta = er32(COLC);
3660 adapter->stats.colc += hw->collision_delta; 3680 adapter->stats.colc += hw->collision_delta;
3661 3681
3662 if (hw->mac_type >= e1000_82543) { 3682 if (hw->mac_type >= e1000_82543) {
3663 adapter->stats.algnerrc += E1000_READ_REG(hw, ALGNERRC); 3683 adapter->stats.algnerrc += er32(ALGNERRC);
3664 adapter->stats.rxerrc += E1000_READ_REG(hw, RXERRC); 3684 adapter->stats.rxerrc += er32(RXERRC);
3665 adapter->stats.tncrs += E1000_READ_REG(hw, TNCRS); 3685 adapter->stats.tncrs += er32(TNCRS);
3666 adapter->stats.cexterr += E1000_READ_REG(hw, CEXTERR); 3686 adapter->stats.cexterr += er32(CEXTERR);
3667 adapter->stats.tsctc += E1000_READ_REG(hw, TSCTC); 3687 adapter->stats.tsctc += er32(TSCTC);
3668 adapter->stats.tsctfc += E1000_READ_REG(hw, TSCTFC); 3688 adapter->stats.tsctfc += er32(TSCTFC);
3669 } 3689 }
3670 if (hw->mac_type > e1000_82547_rev_2) { 3690 if (hw->mac_type > e1000_82547_rev_2) {
3671 adapter->stats.iac += E1000_READ_REG(hw, IAC); 3691 adapter->stats.iac += er32(IAC);
3672 adapter->stats.icrxoc += E1000_READ_REG(hw, ICRXOC); 3692 adapter->stats.icrxoc += er32(ICRXOC);
3673 3693
3674 if (adapter->hw.mac_type != e1000_ich8lan) { 3694 if (hw->mac_type != e1000_ich8lan) {
3675 adapter->stats.icrxptc += E1000_READ_REG(hw, ICRXPTC); 3695 adapter->stats.icrxptc += er32(ICRXPTC);
3676 adapter->stats.icrxatc += E1000_READ_REG(hw, ICRXATC); 3696 adapter->stats.icrxatc += er32(ICRXATC);
3677 adapter->stats.ictxptc += E1000_READ_REG(hw, ICTXPTC); 3697 adapter->stats.ictxptc += er32(ICTXPTC);
3678 adapter->stats.ictxatc += E1000_READ_REG(hw, ICTXATC); 3698 adapter->stats.ictxatc += er32(ICTXATC);
3679 adapter->stats.ictxqec += E1000_READ_REG(hw, ICTXQEC); 3699 adapter->stats.ictxqec += er32(ICTXQEC);
3680 adapter->stats.ictxqmtc += E1000_READ_REG(hw, ICTXQMTC); 3700 adapter->stats.ictxqmtc += er32(ICTXQMTC);
3681 adapter->stats.icrxdmtc += E1000_READ_REG(hw, ICRXDMTC); 3701 adapter->stats.icrxdmtc += er32(ICRXDMTC);
3682 } 3702 }
3683 } 3703 }
3684 3704
@@ -3706,7 +3726,7 @@ void e1000_update_stats(struct e1000_adapter *adapter)
3706 adapter->net_stats.tx_aborted_errors = adapter->stats.ecol; 3726 adapter->net_stats.tx_aborted_errors = adapter->stats.ecol;
3707 adapter->net_stats.tx_window_errors = adapter->stats.latecol; 3727 adapter->net_stats.tx_window_errors = adapter->stats.latecol;
3708 adapter->net_stats.tx_carrier_errors = adapter->stats.tncrs; 3728 adapter->net_stats.tx_carrier_errors = adapter->stats.tncrs;
3709 if (adapter->hw.bad_tx_carr_stats_fd && 3729 if (hw->bad_tx_carr_stats_fd &&
3710 adapter->link_duplex == FULL_DUPLEX) { 3730 adapter->link_duplex == FULL_DUPLEX) {
3711 adapter->net_stats.tx_carrier_errors = 0; 3731 adapter->net_stats.tx_carrier_errors = 0;
3712 adapter->stats.tncrs = 0; 3732 adapter->stats.tncrs = 0;
@@ -3729,10 +3749,10 @@ void e1000_update_stats(struct e1000_adapter *adapter)
3729 } 3749 }
3730 3750
3731 /* Management Stats */ 3751 /* Management Stats */
3732 if (adapter->hw.has_smbus) { 3752 if (hw->has_smbus) {
3733 adapter->stats.mgptc += E1000_READ_REG(hw, MGTPTC); 3753 adapter->stats.mgptc += er32(MGTPTC);
3734 adapter->stats.mgprc += E1000_READ_REG(hw, MGTPRC); 3754 adapter->stats.mgprc += er32(MGTPRC);
3735 adapter->stats.mgpdc += E1000_READ_REG(hw, MGTPDC); 3755 adapter->stats.mgpdc += er32(MGTPDC);
3736 } 3756 }
3737 3757
3738 spin_unlock_irqrestore(&adapter->stats_lock, flags); 3758 spin_unlock_irqrestore(&adapter->stats_lock, flags);
@@ -3752,7 +3772,7 @@ static irqreturn_t e1000_intr_msi(int irq, void *data)
3752#ifndef CONFIG_E1000_NAPI 3772#ifndef CONFIG_E1000_NAPI
3753 int i; 3773 int i;
3754#endif 3774#endif
3755 u32 icr = E1000_READ_REG(hw, ICR); 3775 u32 icr = er32(ICR);
3756 3776
3757 /* in NAPI mode read ICR disables interrupts using IAM */ 3777 /* in NAPI mode read ICR disables interrupts using IAM */
3758 3778
@@ -3762,10 +3782,10 @@ static irqreturn_t e1000_intr_msi(int irq, void *data)
3762 * link down event; disable receives here in the ISR and reset 3782 * link down event; disable receives here in the ISR and reset
3763 * adapter in watchdog */ 3783 * adapter in watchdog */
3764 if (netif_carrier_ok(netdev) && 3784 if (netif_carrier_ok(netdev) &&
3765 (adapter->hw.mac_type == e1000_80003es2lan)) { 3785 (hw->mac_type == e1000_80003es2lan)) {
3766 /* disable receives */ 3786 /* disable receives */
3767 u32 rctl = E1000_READ_REG(hw, RCTL); 3787 u32 rctl = er32(RCTL);
3768 E1000_WRITE_REG(hw, RCTL, rctl & ~E1000_RCTL_EN); 3788 ew32(RCTL, rctl & ~E1000_RCTL_EN);
3769 } 3789 }
3770 /* guard against interrupt when we're going down */ 3790 /* guard against interrupt when we're going down */
3771 if (!test_bit(__E1000_DOWN, &adapter->flags)) 3791 if (!test_bit(__E1000_DOWN, &adapter->flags))
@@ -3810,7 +3830,7 @@ static irqreturn_t e1000_intr(int irq, void *data)
3810 struct net_device *netdev = data; 3830 struct net_device *netdev = data;
3811 struct e1000_adapter *adapter = netdev_priv(netdev); 3831 struct e1000_adapter *adapter = netdev_priv(netdev);
3812 struct e1000_hw *hw = &adapter->hw; 3832 struct e1000_hw *hw = &adapter->hw;
3813 u32 rctl, icr = E1000_READ_REG(hw, ICR); 3833 u32 rctl, icr = er32(ICR);
3814#ifndef CONFIG_E1000_NAPI 3834#ifndef CONFIG_E1000_NAPI
3815 int i; 3835 int i;
3816#endif 3836#endif
@@ -3836,10 +3856,10 @@ static irqreturn_t e1000_intr(int irq, void *data)
3836 * reset adapter in watchdog 3856 * reset adapter in watchdog
3837 */ 3857 */
3838 if (netif_carrier_ok(netdev) && 3858 if (netif_carrier_ok(netdev) &&
3839 (adapter->hw.mac_type == e1000_80003es2lan)) { 3859 (hw->mac_type == e1000_80003es2lan)) {
3840 /* disable receives */ 3860 /* disable receives */
3841 rctl = E1000_READ_REG(hw, RCTL); 3861 rctl = er32(RCTL);
3842 E1000_WRITE_REG(hw, RCTL, rctl & ~E1000_RCTL_EN); 3862 ew32(RCTL, rctl & ~E1000_RCTL_EN);
3843 } 3863 }
3844 /* guard against interrupt when we're going down */ 3864 /* guard against interrupt when we're going down */
3845 if (!test_bit(__E1000_DOWN, &adapter->flags)) 3865 if (!test_bit(__E1000_DOWN, &adapter->flags))
@@ -3849,8 +3869,8 @@ static irqreturn_t e1000_intr(int irq, void *data)
3849#ifdef CONFIG_E1000_NAPI 3869#ifdef CONFIG_E1000_NAPI
3850 if (unlikely(hw->mac_type < e1000_82571)) { 3870 if (unlikely(hw->mac_type < e1000_82571)) {
3851 /* disable interrupts, without the synchronize_irq bit */ 3871 /* disable interrupts, without the synchronize_irq bit */
3852 E1000_WRITE_REG(hw, IMC, ~0); 3872 ew32(IMC, ~0);
3853 E1000_WRITE_FLUSH(hw); 3873 E1000_WRITE_FLUSH();
3854 } 3874 }
3855 if (likely(netif_rx_schedule_prep(netdev, &adapter->napi))) { 3875 if (likely(netif_rx_schedule_prep(netdev, &adapter->napi))) {
3856 adapter->total_tx_bytes = 0; 3876 adapter->total_tx_bytes = 0;
@@ -3874,7 +3894,7 @@ static irqreturn_t e1000_intr(int irq, void *data)
3874 * de-assertion state. 3894 * de-assertion state.
3875 */ 3895 */
3876 if (hw->mac_type == e1000_82547 || hw->mac_type == e1000_82547_rev_2) 3896 if (hw->mac_type == e1000_82547 || hw->mac_type == e1000_82547_rev_2)
3877 E1000_WRITE_REG(hw, IMC, ~0); 3897 ew32(IMC, ~0);
3878 3898
3879 adapter->total_tx_bytes = 0; 3899 adapter->total_tx_bytes = 0;
3880 adapter->total_rx_bytes = 0; 3900 adapter->total_rx_bytes = 0;
@@ -3947,6 +3967,7 @@ static int e1000_clean(struct napi_struct *napi, int budget)
3947static bool e1000_clean_tx_irq(struct e1000_adapter *adapter, 3967static bool e1000_clean_tx_irq(struct e1000_adapter *adapter,
3948 struct e1000_tx_ring *tx_ring) 3968 struct e1000_tx_ring *tx_ring)
3949{ 3969{
3970 struct e1000_hw *hw = &adapter->hw;
3950 struct net_device *netdev = adapter->netdev; 3971 struct net_device *netdev = adapter->netdev;
3951 struct e1000_tx_desc *tx_desc, *eop_desc; 3972 struct e1000_tx_desc *tx_desc, *eop_desc;
3952 struct e1000_buffer *buffer_info; 3973 struct e1000_buffer *buffer_info;
@@ -4014,8 +4035,7 @@ static bool e1000_clean_tx_irq(struct e1000_adapter *adapter,
4014 if (tx_ring->buffer_info[eop].dma && 4035 if (tx_ring->buffer_info[eop].dma &&
4015 time_after(jiffies, tx_ring->buffer_info[eop].time_stamp + 4036 time_after(jiffies, tx_ring->buffer_info[eop].time_stamp +
4016 (adapter->tx_timeout_factor * HZ)) 4037 (adapter->tx_timeout_factor * HZ))
4017 && !(E1000_READ_REG(&adapter->hw, STATUS) & 4038 && !(er32(STATUS) & E1000_STATUS_TXOFF)) {
4018 E1000_STATUS_TXOFF)) {
4019 4039
4020 /* detected Tx unit hang */ 4040 /* detected Tx unit hang */
4021 DPRINTK(DRV, ERR, "Detected Tx Unit Hang\n" 4041 DPRINTK(DRV, ERR, "Detected Tx Unit Hang\n"
@@ -4031,8 +4051,8 @@ static bool e1000_clean_tx_irq(struct e1000_adapter *adapter,
4031 " next_to_watch.status <%x>\n", 4051 " next_to_watch.status <%x>\n",
4032 (unsigned long)((tx_ring - adapter->tx_ring) / 4052 (unsigned long)((tx_ring - adapter->tx_ring) /
4033 sizeof(struct e1000_tx_ring)), 4053 sizeof(struct e1000_tx_ring)),
4034 readl(adapter->hw.hw_addr + tx_ring->tdh), 4054 readl(hw->hw_addr + tx_ring->tdh),
4035 readl(adapter->hw.hw_addr + tx_ring->tdt), 4055 readl(hw->hw_addr + tx_ring->tdt),
4036 tx_ring->next_to_use, 4056 tx_ring->next_to_use,
4037 tx_ring->next_to_clean, 4057 tx_ring->next_to_clean,
4038 tx_ring->buffer_info[eop].time_stamp, 4058 tx_ring->buffer_info[eop].time_stamp,
@@ -4060,12 +4080,13 @@ static bool e1000_clean_tx_irq(struct e1000_adapter *adapter,
4060static void e1000_rx_checksum(struct e1000_adapter *adapter, u32 status_err, 4080static void e1000_rx_checksum(struct e1000_adapter *adapter, u32 status_err,
4061 u32 csum, struct sk_buff *skb) 4081 u32 csum, struct sk_buff *skb)
4062{ 4082{
4083 struct e1000_hw *hw = &adapter->hw;
4063 u16 status = (u16)status_err; 4084 u16 status = (u16)status_err;
4064 u8 errors = (u8)(status_err >> 24); 4085 u8 errors = (u8)(status_err >> 24);
4065 skb->ip_summed = CHECKSUM_NONE; 4086 skb->ip_summed = CHECKSUM_NONE;
4066 4087
4067 /* 82543 or newer only */ 4088 /* 82543 or newer only */
4068 if (unlikely(adapter->hw.mac_type < e1000_82543)) return; 4089 if (unlikely(hw->mac_type < e1000_82543)) return;
4069 /* Ignore Checksum bit is set */ 4090 /* Ignore Checksum bit is set */
4070 if (unlikely(status & E1000_RXD_STAT_IXSM)) return; 4091 if (unlikely(status & E1000_RXD_STAT_IXSM)) return;
4071 /* TCP/UDP checksum error bit is set */ 4092 /* TCP/UDP checksum error bit is set */
@@ -4075,7 +4096,7 @@ static void e1000_rx_checksum(struct e1000_adapter *adapter, u32 status_err,
4075 return; 4096 return;
4076 } 4097 }
4077 /* TCP/UDP Checksum has not been calculated */ 4098 /* TCP/UDP Checksum has not been calculated */
4078 if (adapter->hw.mac_type <= e1000_82547_rev_2) { 4099 if (hw->mac_type <= e1000_82547_rev_2) {
4079 if (!(status & E1000_RXD_STAT_TCPCS)) 4100 if (!(status & E1000_RXD_STAT_TCPCS))
4080 return; 4101 return;
4081 } else { 4102 } else {
@@ -4086,7 +4107,7 @@ static void e1000_rx_checksum(struct e1000_adapter *adapter, u32 status_err,
4086 if (likely(status & E1000_RXD_STAT_TCPCS)) { 4107 if (likely(status & E1000_RXD_STAT_TCPCS)) {
4087 /* TCP checksum is good */ 4108 /* TCP checksum is good */
4088 skb->ip_summed = CHECKSUM_UNNECESSARY; 4109 skb->ip_summed = CHECKSUM_UNNECESSARY;
4089 } else if (adapter->hw.mac_type > e1000_82547_rev_2) { 4110 } else if (hw->mac_type > e1000_82547_rev_2) {
4090 /* IP fragment with UDP payload */ 4111 /* IP fragment with UDP payload */
4091 /* Hardware complements the payload checksum, so we undo it 4112 /* Hardware complements the payload checksum, so we undo it
4092 * and then put the value in host order for further stack use. 4113 * and then put the value in host order for further stack use.
@@ -4111,6 +4132,7 @@ static bool e1000_clean_rx_irq(struct e1000_adapter *adapter,
4111 struct e1000_rx_ring *rx_ring) 4132 struct e1000_rx_ring *rx_ring)
4112#endif 4133#endif
4113{ 4134{
4135 struct e1000_hw *hw = &adapter->hw;
4114 struct net_device *netdev = adapter->netdev; 4136 struct net_device *netdev = adapter->netdev;
4115 struct pci_dev *pdev = adapter->pdev; 4137 struct pci_dev *pdev = adapter->pdev;
4116 struct e1000_rx_desc *rx_desc, *next_rxd; 4138 struct e1000_rx_desc *rx_desc, *next_rxd;
@@ -4168,11 +4190,10 @@ static bool e1000_clean_rx_irq(struct e1000_adapter *adapter,
4168 4190
4169 if (unlikely(rx_desc->errors & E1000_RXD_ERR_FRAME_ERR_MASK)) { 4191 if (unlikely(rx_desc->errors & E1000_RXD_ERR_FRAME_ERR_MASK)) {
4170 last_byte = *(skb->data + length - 1); 4192 last_byte = *(skb->data + length - 1);
4171 if (TBI_ACCEPT(&adapter->hw, status, 4193 if (TBI_ACCEPT(hw, status, rx_desc->errors, length,
4172 rx_desc->errors, length, last_byte)) { 4194 last_byte)) {
4173 spin_lock_irqsave(&adapter->stats_lock, flags); 4195 spin_lock_irqsave(&adapter->stats_lock, flags);
4174 e1000_tbi_adjust_stats(&adapter->hw, 4196 e1000_tbi_adjust_stats(hw, &adapter->stats,
4175 &adapter->stats,
4176 length, skb->data); 4197 length, skb->data);
4177 spin_unlock_irqrestore(&adapter->stats_lock, 4198 spin_unlock_irqrestore(&adapter->stats_lock,
4178 flags); 4199 flags);
@@ -4462,6 +4483,7 @@ static void e1000_alloc_rx_buffers(struct e1000_adapter *adapter,
4462 struct e1000_rx_ring *rx_ring, 4483 struct e1000_rx_ring *rx_ring,
4463 int cleaned_count) 4484 int cleaned_count)
4464{ 4485{
4486 struct e1000_hw *hw = &adapter->hw;
4465 struct net_device *netdev = adapter->netdev; 4487 struct net_device *netdev = adapter->netdev;
4466 struct pci_dev *pdev = adapter->pdev; 4488 struct pci_dev *pdev = adapter->pdev;
4467 struct e1000_rx_desc *rx_desc; 4489 struct e1000_rx_desc *rx_desc;
@@ -4559,7 +4581,7 @@ map_skb:
4559 * applicable for weak-ordered memory model archs, 4581 * applicable for weak-ordered memory model archs,
4560 * such as IA-64). */ 4582 * such as IA-64). */
4561 wmb(); 4583 wmb();
4562 writel(i, adapter->hw.hw_addr + rx_ring->rdt); 4584 writel(i, hw->hw_addr + rx_ring->rdt);
4563 } 4585 }
4564} 4586}
4565 4587
@@ -4572,6 +4594,7 @@ static void e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter,
4572 struct e1000_rx_ring *rx_ring, 4594 struct e1000_rx_ring *rx_ring,
4573 int cleaned_count) 4595 int cleaned_count)
4574{ 4596{
4597 struct e1000_hw *hw = &adapter->hw;
4575 struct net_device *netdev = adapter->netdev; 4598 struct net_device *netdev = adapter->netdev;
4576 struct pci_dev *pdev = adapter->pdev; 4599 struct pci_dev *pdev = adapter->pdev;
4577 union e1000_rx_desc_packet_split *rx_desc; 4600 union e1000_rx_desc_packet_split *rx_desc;
@@ -4656,7 +4679,7 @@ no_buffers:
4656 * descriptors are 32 bytes...so we increment tail 4679 * descriptors are 32 bytes...so we increment tail
4657 * twice as much. 4680 * twice as much.
4658 */ 4681 */
4659 writel(i<<1, adapter->hw.hw_addr + rx_ring->rdt); 4682 writel(i<<1, hw->hw_addr + rx_ring->rdt);
4660 } 4683 }
4661} 4684}
4662 4685
@@ -4667,46 +4690,47 @@ no_buffers:
4667 4690
4668static void e1000_smartspeed(struct e1000_adapter *adapter) 4691static void e1000_smartspeed(struct e1000_adapter *adapter)
4669{ 4692{
4693 struct e1000_hw *hw = &adapter->hw;
4670 u16 phy_status; 4694 u16 phy_status;
4671 u16 phy_ctrl; 4695 u16 phy_ctrl;
4672 4696
4673 if ((adapter->hw.phy_type != e1000_phy_igp) || !adapter->hw.autoneg || 4697 if ((hw->phy_type != e1000_phy_igp) || !hw->autoneg ||
4674 !(adapter->hw.autoneg_advertised & ADVERTISE_1000_FULL)) 4698 !(hw->autoneg_advertised & ADVERTISE_1000_FULL))
4675 return; 4699 return;
4676 4700
4677 if (adapter->smartspeed == 0) { 4701 if (adapter->smartspeed == 0) {
4678 /* If Master/Slave config fault is asserted twice, 4702 /* If Master/Slave config fault is asserted twice,
4679 * we assume back-to-back */ 4703 * we assume back-to-back */
4680 e1000_read_phy_reg(&adapter->hw, PHY_1000T_STATUS, &phy_status); 4704 e1000_read_phy_reg(hw, PHY_1000T_STATUS, &phy_status);
4681 if (!(phy_status & SR_1000T_MS_CONFIG_FAULT)) return; 4705 if (!(phy_status & SR_1000T_MS_CONFIG_FAULT)) return;
4682 e1000_read_phy_reg(&adapter->hw, PHY_1000T_STATUS, &phy_status); 4706 e1000_read_phy_reg(hw, PHY_1000T_STATUS, &phy_status);
4683 if (!(phy_status & SR_1000T_MS_CONFIG_FAULT)) return; 4707 if (!(phy_status & SR_1000T_MS_CONFIG_FAULT)) return;
4684 e1000_read_phy_reg(&adapter->hw, PHY_1000T_CTRL, &phy_ctrl); 4708 e1000_read_phy_reg(hw, PHY_1000T_CTRL, &phy_ctrl);
4685 if (phy_ctrl & CR_1000T_MS_ENABLE) { 4709 if (phy_ctrl & CR_1000T_MS_ENABLE) {
4686 phy_ctrl &= ~CR_1000T_MS_ENABLE; 4710 phy_ctrl &= ~CR_1000T_MS_ENABLE;
4687 e1000_write_phy_reg(&adapter->hw, PHY_1000T_CTRL, 4711 e1000_write_phy_reg(hw, PHY_1000T_CTRL,
4688 phy_ctrl); 4712 phy_ctrl);
4689 adapter->smartspeed++; 4713 adapter->smartspeed++;
4690 if (!e1000_phy_setup_autoneg(&adapter->hw) && 4714 if (!e1000_phy_setup_autoneg(hw) &&
4691 !e1000_read_phy_reg(&adapter->hw, PHY_CTRL, 4715 !e1000_read_phy_reg(hw, PHY_CTRL,
4692 &phy_ctrl)) { 4716 &phy_ctrl)) {
4693 phy_ctrl |= (MII_CR_AUTO_NEG_EN | 4717 phy_ctrl |= (MII_CR_AUTO_NEG_EN |
4694 MII_CR_RESTART_AUTO_NEG); 4718 MII_CR_RESTART_AUTO_NEG);
4695 e1000_write_phy_reg(&adapter->hw, PHY_CTRL, 4719 e1000_write_phy_reg(hw, PHY_CTRL,
4696 phy_ctrl); 4720 phy_ctrl);
4697 } 4721 }
4698 } 4722 }
4699 return; 4723 return;
4700 } else if (adapter->smartspeed == E1000_SMARTSPEED_DOWNSHIFT) { 4724 } else if (adapter->smartspeed == E1000_SMARTSPEED_DOWNSHIFT) {
4701 /* If still no link, perhaps using 2/3 pair cable */ 4725 /* If still no link, perhaps using 2/3 pair cable */
4702 e1000_read_phy_reg(&adapter->hw, PHY_1000T_CTRL, &phy_ctrl); 4726 e1000_read_phy_reg(hw, PHY_1000T_CTRL, &phy_ctrl);
4703 phy_ctrl |= CR_1000T_MS_ENABLE; 4727 phy_ctrl |= CR_1000T_MS_ENABLE;
4704 e1000_write_phy_reg(&adapter->hw, PHY_1000T_CTRL, phy_ctrl); 4728 e1000_write_phy_reg(hw, PHY_1000T_CTRL, phy_ctrl);
4705 if (!e1000_phy_setup_autoneg(&adapter->hw) && 4729 if (!e1000_phy_setup_autoneg(hw) &&
4706 !e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &phy_ctrl)) { 4730 !e1000_read_phy_reg(hw, PHY_CTRL, &phy_ctrl)) {
4707 phy_ctrl |= (MII_CR_AUTO_NEG_EN | 4731 phy_ctrl |= (MII_CR_AUTO_NEG_EN |
4708 MII_CR_RESTART_AUTO_NEG); 4732 MII_CR_RESTART_AUTO_NEG);
4709 e1000_write_phy_reg(&adapter->hw, PHY_CTRL, phy_ctrl); 4733 e1000_write_phy_reg(hw, PHY_CTRL, phy_ctrl);
4710 } 4734 }
4711 } 4735 }
4712 /* Restart process after E1000_SMARTSPEED_MAX iterations */ 4736 /* Restart process after E1000_SMARTSPEED_MAX iterations */
@@ -4744,24 +4768,25 @@ static int e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr,
4744 int cmd) 4768 int cmd)
4745{ 4769{
4746 struct e1000_adapter *adapter = netdev_priv(netdev); 4770 struct e1000_adapter *adapter = netdev_priv(netdev);
4771 struct e1000_hw *hw = &adapter->hw;
4747 struct mii_ioctl_data *data = if_mii(ifr); 4772 struct mii_ioctl_data *data = if_mii(ifr);
4748 int retval; 4773 int retval;
4749 u16 mii_reg; 4774 u16 mii_reg;
4750 u16 spddplx; 4775 u16 spddplx;
4751 unsigned long flags; 4776 unsigned long flags;
4752 4777
4753 if (adapter->hw.media_type != e1000_media_type_copper) 4778 if (hw->media_type != e1000_media_type_copper)
4754 return -EOPNOTSUPP; 4779 return -EOPNOTSUPP;
4755 4780
4756 switch (cmd) { 4781 switch (cmd) {
4757 case SIOCGMIIPHY: 4782 case SIOCGMIIPHY:
4758 data->phy_id = adapter->hw.phy_addr; 4783 data->phy_id = hw->phy_addr;
4759 break; 4784 break;
4760 case SIOCGMIIREG: 4785 case SIOCGMIIREG:
4761 if (!capable(CAP_NET_ADMIN)) 4786 if (!capable(CAP_NET_ADMIN))
4762 return -EPERM; 4787 return -EPERM;
4763 spin_lock_irqsave(&adapter->stats_lock, flags); 4788 spin_lock_irqsave(&adapter->stats_lock, flags);
4764 if (e1000_read_phy_reg(&adapter->hw, data->reg_num & 0x1F, 4789 if (e1000_read_phy_reg(hw, data->reg_num & 0x1F,
4765 &data->val_out)) { 4790 &data->val_out)) {
4766 spin_unlock_irqrestore(&adapter->stats_lock, flags); 4791 spin_unlock_irqrestore(&adapter->stats_lock, flags);
4767 return -EIO; 4792 return -EIO;
@@ -4775,20 +4800,20 @@ static int e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr,
4775 return -EFAULT; 4800 return -EFAULT;
4776 mii_reg = data->val_in; 4801 mii_reg = data->val_in;
4777 spin_lock_irqsave(&adapter->stats_lock, flags); 4802 spin_lock_irqsave(&adapter->stats_lock, flags);
4778 if (e1000_write_phy_reg(&adapter->hw, data->reg_num, 4803 if (e1000_write_phy_reg(hw, data->reg_num,
4779 mii_reg)) { 4804 mii_reg)) {
4780 spin_unlock_irqrestore(&adapter->stats_lock, flags); 4805 spin_unlock_irqrestore(&adapter->stats_lock, flags);
4781 return -EIO; 4806 return -EIO;
4782 } 4807 }
4783 spin_unlock_irqrestore(&adapter->stats_lock, flags); 4808 spin_unlock_irqrestore(&adapter->stats_lock, flags);
4784 if (adapter->hw.media_type == e1000_media_type_copper) { 4809 if (hw->media_type == e1000_media_type_copper) {
4785 switch (data->reg_num) { 4810 switch (data->reg_num) {
4786 case PHY_CTRL: 4811 case PHY_CTRL:
4787 if (mii_reg & MII_CR_POWER_DOWN) 4812 if (mii_reg & MII_CR_POWER_DOWN)
4788 break; 4813 break;
4789 if (mii_reg & MII_CR_AUTO_NEG_EN) { 4814 if (mii_reg & MII_CR_AUTO_NEG_EN) {
4790 adapter->hw.autoneg = 1; 4815 hw->autoneg = 1;
4791 adapter->hw.autoneg_advertised = 0x2F; 4816 hw->autoneg_advertised = 0x2F;
4792 } else { 4817 } else {
4793 if (mii_reg & 0x40) 4818 if (mii_reg & 0x40)
4794 spddplx = SPEED_1000; 4819 spddplx = SPEED_1000;
@@ -4811,7 +4836,7 @@ static int e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr,
4811 break; 4836 break;
4812 case M88E1000_PHY_SPEC_CTRL: 4837 case M88E1000_PHY_SPEC_CTRL:
4813 case M88E1000_EXT_PHY_SPEC_CTRL: 4838 case M88E1000_EXT_PHY_SPEC_CTRL:
4814 if (e1000_phy_reset(&adapter->hw)) 4839 if (e1000_phy_reset(hw))
4815 return -EIO; 4840 return -EIO;
4816 break; 4841 break;
4817 } 4842 }
@@ -4885,6 +4910,7 @@ static void e1000_vlan_rx_register(struct net_device *netdev,
4885 struct vlan_group *grp) 4910 struct vlan_group *grp)
4886{ 4911{
4887 struct e1000_adapter *adapter = netdev_priv(netdev); 4912 struct e1000_adapter *adapter = netdev_priv(netdev);
4913 struct e1000_hw *hw = &adapter->hw;
4888 u32 ctrl, rctl; 4914 u32 ctrl, rctl;
4889 4915
4890 if (!test_bit(__E1000_DOWN, &adapter->flags)) 4916 if (!test_bit(__E1000_DOWN, &adapter->flags))
@@ -4893,22 +4919,22 @@ static void e1000_vlan_rx_register(struct net_device *netdev,
4893 4919
4894 if (grp) { 4920 if (grp) {
4895 /* enable VLAN tag insert/strip */ 4921 /* enable VLAN tag insert/strip */
4896 ctrl = E1000_READ_REG(&adapter->hw, CTRL); 4922 ctrl = er32(CTRL);
4897 ctrl |= E1000_CTRL_VME; 4923 ctrl |= E1000_CTRL_VME;
4898 E1000_WRITE_REG(&adapter->hw, CTRL, ctrl); 4924 ew32(CTRL, ctrl);
4899 4925
4900 if (adapter->hw.mac_type != e1000_ich8lan) { 4926 if (adapter->hw.mac_type != e1000_ich8lan) {
4901 /* enable VLAN receive filtering */ 4927 /* enable VLAN receive filtering */
4902 rctl = E1000_READ_REG(&adapter->hw, RCTL); 4928 rctl = er32(RCTL);
4903 rctl &= ~E1000_RCTL_CFIEN; 4929 rctl &= ~E1000_RCTL_CFIEN;
4904 E1000_WRITE_REG(&adapter->hw, RCTL, rctl); 4930 ew32(RCTL, rctl);
4905 e1000_update_mng_vlan(adapter); 4931 e1000_update_mng_vlan(adapter);
4906 } 4932 }
4907 } else { 4933 } else {
4908 /* disable VLAN tag insert/strip */ 4934 /* disable VLAN tag insert/strip */
4909 ctrl = E1000_READ_REG(&adapter->hw, CTRL); 4935 ctrl = er32(CTRL);
4910 ctrl &= ~E1000_CTRL_VME; 4936 ctrl &= ~E1000_CTRL_VME;
4911 E1000_WRITE_REG(&adapter->hw, CTRL, ctrl); 4937 ew32(CTRL, ctrl);
4912 4938
4913 if (adapter->hw.mac_type != e1000_ich8lan) { 4939 if (adapter->hw.mac_type != e1000_ich8lan) {
4914 if (adapter->mng_vlan_id != 4940 if (adapter->mng_vlan_id !=
@@ -4927,22 +4953,24 @@ static void e1000_vlan_rx_register(struct net_device *netdev,
4927static void e1000_vlan_rx_add_vid(struct net_device *netdev, u16 vid) 4953static void e1000_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
4928{ 4954{
4929 struct e1000_adapter *adapter = netdev_priv(netdev); 4955 struct e1000_adapter *adapter = netdev_priv(netdev);
4956 struct e1000_hw *hw = &adapter->hw;
4930 u32 vfta, index; 4957 u32 vfta, index;
4931 4958
4932 if ((adapter->hw.mng_cookie.status & 4959 if ((hw->mng_cookie.status &
4933 E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) && 4960 E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) &&
4934 (vid == adapter->mng_vlan_id)) 4961 (vid == adapter->mng_vlan_id))
4935 return; 4962 return;
4936 /* add VID to filter table */ 4963 /* add VID to filter table */
4937 index = (vid >> 5) & 0x7F; 4964 index = (vid >> 5) & 0x7F;
4938 vfta = E1000_READ_REG_ARRAY(&adapter->hw, VFTA, index); 4965 vfta = E1000_READ_REG_ARRAY(hw, VFTA, index);
4939 vfta |= (1 << (vid & 0x1F)); 4966 vfta |= (1 << (vid & 0x1F));
4940 e1000_write_vfta(&adapter->hw, index, vfta); 4967 e1000_write_vfta(hw, index, vfta);
4941} 4968}
4942 4969
4943static void e1000_vlan_rx_kill_vid(struct net_device *netdev, u16 vid) 4970static void e1000_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
4944{ 4971{
4945 struct e1000_adapter *adapter = netdev_priv(netdev); 4972 struct e1000_adapter *adapter = netdev_priv(netdev);
4973 struct e1000_hw *hw = &adapter->hw;
4946 u32 vfta, index; 4974 u32 vfta, index;
4947 4975
4948 if (!test_bit(__E1000_DOWN, &adapter->flags)) 4976 if (!test_bit(__E1000_DOWN, &adapter->flags))
@@ -4951,7 +4979,7 @@ static void e1000_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
4951 if (!test_bit(__E1000_DOWN, &adapter->flags)) 4979 if (!test_bit(__E1000_DOWN, &adapter->flags))
4952 e1000_irq_enable(adapter); 4980 e1000_irq_enable(adapter);
4953 4981
4954 if ((adapter->hw.mng_cookie.status & 4982 if ((hw->mng_cookie.status &
4955 E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) && 4983 E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) &&
4956 (vid == adapter->mng_vlan_id)) { 4984 (vid == adapter->mng_vlan_id)) {
4957 /* release control to f/w */ 4985 /* release control to f/w */
@@ -4961,9 +4989,9 @@ static void e1000_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
4961 4989
4962 /* remove VID from filter table */ 4990 /* remove VID from filter table */
4963 index = (vid >> 5) & 0x7F; 4991 index = (vid >> 5) & 0x7F;
4964 vfta = E1000_READ_REG_ARRAY(&adapter->hw, VFTA, index); 4992 vfta = E1000_READ_REG_ARRAY(hw, VFTA, index);
4965 vfta &= ~(1 << (vid & 0x1F)); 4993 vfta &= ~(1 << (vid & 0x1F));
4966 e1000_write_vfta(&adapter->hw, index, vfta); 4994 e1000_write_vfta(hw, index, vfta);
4967} 4995}
4968 4996
4969static void e1000_restore_vlan(struct e1000_adapter *adapter) 4997static void e1000_restore_vlan(struct e1000_adapter *adapter)
@@ -4982,10 +5010,12 @@ static void e1000_restore_vlan(struct e1000_adapter *adapter)
4982 5010
4983int e1000_set_spd_dplx(struct e1000_adapter *adapter, u16 spddplx) 5011int e1000_set_spd_dplx(struct e1000_adapter *adapter, u16 spddplx)
4984{ 5012{
4985 adapter->hw.autoneg = 0; 5013 struct e1000_hw *hw = &adapter->hw;
5014
5015 hw->autoneg = 0;
4986 5016
4987 /* Fiber NICs only allow 1000 gbps Full duplex */ 5017 /* Fiber NICs only allow 1000 gbps Full duplex */
4988 if ((adapter->hw.media_type == e1000_media_type_fiber) && 5018 if ((hw->media_type == e1000_media_type_fiber) &&
4989 spddplx != (SPEED_1000 + DUPLEX_FULL)) { 5019 spddplx != (SPEED_1000 + DUPLEX_FULL)) {
4990 DPRINTK(PROBE, ERR, "Unsupported Speed/Duplex configuration\n"); 5020 DPRINTK(PROBE, ERR, "Unsupported Speed/Duplex configuration\n");
4991 return -EINVAL; 5021 return -EINVAL;
@@ -4993,20 +5023,20 @@ int e1000_set_spd_dplx(struct e1000_adapter *adapter, u16 spddplx)
4993 5023
4994 switch (spddplx) { 5024 switch (spddplx) {
4995 case SPEED_10 + DUPLEX_HALF: 5025 case SPEED_10 + DUPLEX_HALF:
4996 adapter->hw.forced_speed_duplex = e1000_10_half; 5026 hw->forced_speed_duplex = e1000_10_half;
4997 break; 5027 break;
4998 case SPEED_10 + DUPLEX_FULL: 5028 case SPEED_10 + DUPLEX_FULL:
4999 adapter->hw.forced_speed_duplex = e1000_10_full; 5029 hw->forced_speed_duplex = e1000_10_full;
5000 break; 5030 break;
5001 case SPEED_100 + DUPLEX_HALF: 5031 case SPEED_100 + DUPLEX_HALF:
5002 adapter->hw.forced_speed_duplex = e1000_100_half; 5032 hw->forced_speed_duplex = e1000_100_half;
5003 break; 5033 break;
5004 case SPEED_100 + DUPLEX_FULL: 5034 case SPEED_100 + DUPLEX_FULL:
5005 adapter->hw.forced_speed_duplex = e1000_100_full; 5035 hw->forced_speed_duplex = e1000_100_full;
5006 break; 5036 break;
5007 case SPEED_1000 + DUPLEX_FULL: 5037 case SPEED_1000 + DUPLEX_FULL:
5008 adapter->hw.autoneg = 1; 5038 hw->autoneg = 1;
5009 adapter->hw.autoneg_advertised = ADVERTISE_1000_FULL; 5039 hw->autoneg_advertised = ADVERTISE_1000_FULL;
5010 break; 5040 break;
5011 case SPEED_1000 + DUPLEX_HALF: /* not supported */ 5041 case SPEED_1000 + DUPLEX_HALF: /* not supported */
5012 default: 5042 default:
@@ -5020,6 +5050,7 @@ static int e1000_suspend(struct pci_dev *pdev, pm_message_t state)
5020{ 5050{
5021 struct net_device *netdev = pci_get_drvdata(pdev); 5051 struct net_device *netdev = pci_get_drvdata(pdev);
5022 struct e1000_adapter *adapter = netdev_priv(netdev); 5052 struct e1000_adapter *adapter = netdev_priv(netdev);
5053 struct e1000_hw *hw = &adapter->hw;
5023 u32 ctrl, ctrl_ext, rctl, status; 5054 u32 ctrl, ctrl_ext, rctl, status;
5024 u32 wufc = adapter->wol; 5055 u32 wufc = adapter->wol;
5025#ifdef CONFIG_PM 5056#ifdef CONFIG_PM
@@ -5039,7 +5070,7 @@ static int e1000_suspend(struct pci_dev *pdev, pm_message_t state)
5039 return retval; 5070 return retval;
5040#endif 5071#endif
5041 5072
5042 status = E1000_READ_REG(&adapter->hw, STATUS); 5073 status = er32(STATUS);
5043 if (status & E1000_STATUS_LU) 5074 if (status & E1000_STATUS_LU)
5044 wufc &= ~E1000_WUFC_LNKC; 5075 wufc &= ~E1000_WUFC_LNKC;
5045 5076
@@ -5049,40 +5080,40 @@ static int e1000_suspend(struct pci_dev *pdev, pm_message_t state)
5049 5080
5050 /* turn on all-multi mode if wake on multicast is enabled */ 5081 /* turn on all-multi mode if wake on multicast is enabled */
5051 if (wufc & E1000_WUFC_MC) { 5082 if (wufc & E1000_WUFC_MC) {
5052 rctl = E1000_READ_REG(&adapter->hw, RCTL); 5083 rctl = er32(RCTL);
5053 rctl |= E1000_RCTL_MPE; 5084 rctl |= E1000_RCTL_MPE;
5054 E1000_WRITE_REG(&adapter->hw, RCTL, rctl); 5085 ew32(RCTL, rctl);
5055 } 5086 }
5056 5087
5057 if (adapter->hw.mac_type >= e1000_82540) { 5088 if (hw->mac_type >= e1000_82540) {
5058 ctrl = E1000_READ_REG(&adapter->hw, CTRL); 5089 ctrl = er32(CTRL);
5059 /* advertise wake from D3Cold */ 5090 /* advertise wake from D3Cold */
5060 #define E1000_CTRL_ADVD3WUC 0x00100000 5091 #define E1000_CTRL_ADVD3WUC 0x00100000
5061 /* phy power management enable */ 5092 /* phy power management enable */
5062 #define E1000_CTRL_EN_PHY_PWR_MGMT 0x00200000 5093 #define E1000_CTRL_EN_PHY_PWR_MGMT 0x00200000
5063 ctrl |= E1000_CTRL_ADVD3WUC | 5094 ctrl |= E1000_CTRL_ADVD3WUC |
5064 E1000_CTRL_EN_PHY_PWR_MGMT; 5095 E1000_CTRL_EN_PHY_PWR_MGMT;
5065 E1000_WRITE_REG(&adapter->hw, CTRL, ctrl); 5096 ew32(CTRL, ctrl);
5066 } 5097 }
5067 5098
5068 if (adapter->hw.media_type == e1000_media_type_fiber || 5099 if (hw->media_type == e1000_media_type_fiber ||
5069 adapter->hw.media_type == e1000_media_type_internal_serdes) { 5100 hw->media_type == e1000_media_type_internal_serdes) {
5070 /* keep the laser running in D3 */ 5101 /* keep the laser running in D3 */
5071 ctrl_ext = E1000_READ_REG(&adapter->hw, CTRL_EXT); 5102 ctrl_ext = er32(CTRL_EXT);
5072 ctrl_ext |= E1000_CTRL_EXT_SDP7_DATA; 5103 ctrl_ext |= E1000_CTRL_EXT_SDP7_DATA;
5073 E1000_WRITE_REG(&adapter->hw, CTRL_EXT, ctrl_ext); 5104 ew32(CTRL_EXT, ctrl_ext);
5074 } 5105 }
5075 5106
5076 /* Allow time for pending master requests to run */ 5107 /* Allow time for pending master requests to run */
5077 e1000_disable_pciex_master(&adapter->hw); 5108 e1000_disable_pciex_master(hw);
5078 5109
5079 E1000_WRITE_REG(&adapter->hw, WUC, E1000_WUC_PME_EN); 5110 ew32(WUC, E1000_WUC_PME_EN);
5080 E1000_WRITE_REG(&adapter->hw, WUFC, wufc); 5111 ew32(WUFC, wufc);
5081 pci_enable_wake(pdev, PCI_D3hot, 1); 5112 pci_enable_wake(pdev, PCI_D3hot, 1);
5082 pci_enable_wake(pdev, PCI_D3cold, 1); 5113 pci_enable_wake(pdev, PCI_D3cold, 1);
5083 } else { 5114 } else {
5084 E1000_WRITE_REG(&adapter->hw, WUC, 0); 5115 ew32(WUC, 0);
5085 E1000_WRITE_REG(&adapter->hw, WUFC, 0); 5116 ew32(WUFC, 0);
5086 pci_enable_wake(pdev, PCI_D3hot, 0); 5117 pci_enable_wake(pdev, PCI_D3hot, 0);
5087 pci_enable_wake(pdev, PCI_D3cold, 0); 5118 pci_enable_wake(pdev, PCI_D3cold, 0);
5088 } 5119 }
@@ -5095,8 +5126,8 @@ static int e1000_suspend(struct pci_dev *pdev, pm_message_t state)
5095 pci_enable_wake(pdev, PCI_D3cold, 1); 5126 pci_enable_wake(pdev, PCI_D3cold, 1);
5096 } 5127 }
5097 5128
5098 if (adapter->hw.phy_type == e1000_phy_igp_3) 5129 if (hw->phy_type == e1000_phy_igp_3)
5099 e1000_phy_powerdown_workaround(&adapter->hw); 5130 e1000_phy_powerdown_workaround(hw);
5100 5131
5101 if (netif_running(netdev)) 5132 if (netif_running(netdev))
5102 e1000_free_irq(adapter); 5133 e1000_free_irq(adapter);
@@ -5117,6 +5148,7 @@ static int e1000_resume(struct pci_dev *pdev)
5117{ 5148{
5118 struct net_device *netdev = pci_get_drvdata(pdev); 5149 struct net_device *netdev = pci_get_drvdata(pdev);
5119 struct e1000_adapter *adapter = netdev_priv(netdev); 5150 struct e1000_adapter *adapter = netdev_priv(netdev);
5151 struct e1000_hw *hw = &adapter->hw;
5120 u32 err; 5152 u32 err;
5121 5153
5122 pci_set_power_state(pdev, PCI_D0); 5154 pci_set_power_state(pdev, PCI_D0);
@@ -5135,7 +5167,7 @@ static int e1000_resume(struct pci_dev *pdev)
5135 5167
5136 e1000_power_up_phy(adapter); 5168 e1000_power_up_phy(adapter);
5137 e1000_reset(adapter); 5169 e1000_reset(adapter);
5138 E1000_WRITE_REG(&adapter->hw, WUS, ~0); 5170 ew32(WUS, ~0);
5139 5171
5140 e1000_init_manageability(adapter); 5172 e1000_init_manageability(adapter);
5141 5173
@@ -5148,8 +5180,8 @@ static int e1000_resume(struct pci_dev *pdev)
5148 * DRV_LOAD until the interface is up. For all other cases, 5180 * DRV_LOAD until the interface is up. For all other cases,
5149 * let the f/w know that the h/w is now under the control 5181 * let the f/w know that the h/w is now under the control
5150 * of the driver. */ 5182 * of the driver. */
5151 if (adapter->hw.mac_type != e1000_82573 || 5183 if (hw->mac_type != e1000_82573 ||
5152 !e1000_check_mng_mode(&adapter->hw)) 5184 !e1000_check_mng_mode(hw))
5153 e1000_get_hw_control(adapter); 5185 e1000_get_hw_control(adapter);
5154 5186
5155 return 0; 5187 return 0;
@@ -5215,6 +5247,7 @@ static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev)
5215{ 5247{
5216 struct net_device *netdev = pci_get_drvdata(pdev); 5248 struct net_device *netdev = pci_get_drvdata(pdev);
5217 struct e1000_adapter *adapter = netdev->priv; 5249 struct e1000_adapter *adapter = netdev->priv;
5250 struct e1000_hw *hw = &adapter->hw;
5218 5251
5219 if (pci_enable_device(pdev)) { 5252 if (pci_enable_device(pdev)) {
5220 printk(KERN_ERR "e1000: Cannot re-enable PCI device after reset.\n"); 5253 printk(KERN_ERR "e1000: Cannot re-enable PCI device after reset.\n");
@@ -5226,7 +5259,7 @@ static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev)
5226 pci_enable_wake(pdev, PCI_D3cold, 0); 5259 pci_enable_wake(pdev, PCI_D3cold, 0);
5227 5260
5228 e1000_reset(adapter); 5261 e1000_reset(adapter);
5229 E1000_WRITE_REG(&adapter->hw, WUS, ~0); 5262 ew32(WUS, ~0);
5230 5263
5231 return PCI_ERS_RESULT_RECOVERED; 5264 return PCI_ERS_RESULT_RECOVERED;
5232} 5265}
@@ -5243,6 +5276,7 @@ static void e1000_io_resume(struct pci_dev *pdev)
5243{ 5276{
5244 struct net_device *netdev = pci_get_drvdata(pdev); 5277 struct net_device *netdev = pci_get_drvdata(pdev);
5245 struct e1000_adapter *adapter = netdev->priv; 5278 struct e1000_adapter *adapter = netdev->priv;
5279 struct e1000_hw *hw = &adapter->hw;
5246 5280
5247 e1000_init_manageability(adapter); 5281 e1000_init_manageability(adapter);
5248 5282
@@ -5259,8 +5293,8 @@ static void e1000_io_resume(struct pci_dev *pdev)
5259 * DRV_LOAD until the interface is up. For all other cases, 5293 * DRV_LOAD until the interface is up. For all other cases,
5260 * let the f/w know that the h/w is now under the control 5294 * let the f/w know that the h/w is now under the control
5261 * of the driver. */ 5295 * of the driver. */
5262 if (adapter->hw.mac_type != e1000_82573 || 5296 if (hw->mac_type != e1000_82573 ||
5263 !e1000_check_mng_mode(&adapter->hw)) 5297 !e1000_check_mng_mode(hw))
5264 e1000_get_hw_control(adapter); 5298 e1000_get_hw_control(adapter);
5265 5299
5266} 5300}