aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/e1000/e1000_ethtool.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/e1000/e1000_ethtool.c')
-rw-r--r--drivers/net/e1000/e1000_ethtool.c313
1 files changed, 169 insertions, 144 deletions
diff --git a/drivers/net/e1000/e1000_ethtool.c b/drivers/net/e1000/e1000_ethtool.c
index 4bcfa374f4d6..966d52a529ec 100644
--- a/drivers/net/e1000/e1000_ethtool.c
+++ b/drivers/net/e1000/e1000_ethtool.c
@@ -162,7 +162,7 @@ static int e1000_get_settings(struct net_device *netdev,
162 ecmd->transceiver = XCVR_EXTERNAL; 162 ecmd->transceiver = XCVR_EXTERNAL;
163 } 163 }
164 164
165 if (E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_LU) { 165 if (er32(STATUS) & E1000_STATUS_LU) {
166 166
167 e1000_get_speed_and_duplex(hw, &adapter->link_speed, 167 e1000_get_speed_and_duplex(hw, &adapter->link_speed,
168 &adapter->link_duplex); 168 &adapter->link_duplex);
@@ -313,8 +313,9 @@ static u32 e1000_get_tx_csum(struct net_device *netdev)
313static int e1000_set_tx_csum(struct net_device *netdev, u32 data) 313static int e1000_set_tx_csum(struct net_device *netdev, u32 data)
314{ 314{
315 struct e1000_adapter *adapter = netdev_priv(netdev); 315 struct e1000_adapter *adapter = netdev_priv(netdev);
316 struct e1000_hw *hw = &adapter->hw;
316 317
317 if (adapter->hw.mac_type < e1000_82543) { 318 if (hw->mac_type < e1000_82543) {
318 if (!data) 319 if (!data)
319 return -EINVAL; 320 return -EINVAL;
320 return 0; 321 return 0;
@@ -331,8 +332,10 @@ static int e1000_set_tx_csum(struct net_device *netdev, u32 data)
331static int e1000_set_tso(struct net_device *netdev, u32 data) 332static int e1000_set_tso(struct net_device *netdev, u32 data)
332{ 333{
333 struct e1000_adapter *adapter = netdev_priv(netdev); 334 struct e1000_adapter *adapter = netdev_priv(netdev);
334 if ((adapter->hw.mac_type < e1000_82544) || 335 struct e1000_hw *hw = &adapter->hw;
335 (adapter->hw.mac_type == e1000_82547)) 336
337 if ((hw->mac_type < e1000_82544) ||
338 (hw->mac_type == e1000_82547))
336 return data ? -EINVAL : 0; 339 return data ? -EINVAL : 0;
337 340
338 if (data) 341 if (data)
@@ -380,22 +383,22 @@ static void e1000_get_regs(struct net_device *netdev, struct ethtool_regs *regs,
380 383
381 regs->version = (1 << 24) | (hw->revision_id << 16) | hw->device_id; 384 regs->version = (1 << 24) | (hw->revision_id << 16) | hw->device_id;
382 385
383 regs_buff[0] = E1000_READ_REG(hw, CTRL); 386 regs_buff[0] = er32(CTRL);
384 regs_buff[1] = E1000_READ_REG(hw, STATUS); 387 regs_buff[1] = er32(STATUS);
385 388
386 regs_buff[2] = E1000_READ_REG(hw, RCTL); 389 regs_buff[2] = er32(RCTL);
387 regs_buff[3] = E1000_READ_REG(hw, RDLEN); 390 regs_buff[3] = er32(RDLEN);
388 regs_buff[4] = E1000_READ_REG(hw, RDH); 391 regs_buff[4] = er32(RDH);
389 regs_buff[5] = E1000_READ_REG(hw, RDT); 392 regs_buff[5] = er32(RDT);
390 regs_buff[6] = E1000_READ_REG(hw, RDTR); 393 regs_buff[6] = er32(RDTR);
391 394
392 regs_buff[7] = E1000_READ_REG(hw, TCTL); 395 regs_buff[7] = er32(TCTL);
393 regs_buff[8] = E1000_READ_REG(hw, TDLEN); 396 regs_buff[8] = er32(TDLEN);
394 regs_buff[9] = E1000_READ_REG(hw, TDH); 397 regs_buff[9] = er32(TDH);
395 regs_buff[10] = E1000_READ_REG(hw, TDT); 398 regs_buff[10] = er32(TDT);
396 regs_buff[11] = E1000_READ_REG(hw, TIDV); 399 regs_buff[11] = er32(TIDV);
397 400
398 regs_buff[12] = adapter->hw.phy_type; /* PHY type (IGP=1, M88=0) */ 401 regs_buff[12] = hw->phy_type; /* PHY type (IGP=1, M88=0) */
399 if (hw->phy_type == e1000_phy_igp) { 402 if (hw->phy_type == e1000_phy_igp) {
400 e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT, 403 e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT,
401 IGP01E1000_PHY_AGC_A); 404 IGP01E1000_PHY_AGC_A);
@@ -453,14 +456,16 @@ static void e1000_get_regs(struct net_device *netdev, struct ethtool_regs *regs,
453 if (hw->mac_type >= e1000_82540 && 456 if (hw->mac_type >= e1000_82540 &&
454 hw->mac_type < e1000_82571 && 457 hw->mac_type < e1000_82571 &&
455 hw->media_type == e1000_media_type_copper) { 458 hw->media_type == e1000_media_type_copper) {
456 regs_buff[26] = E1000_READ_REG(hw, MANC); 459 regs_buff[26] = er32(MANC);
457 } 460 }
458} 461}
459 462
460static int e1000_get_eeprom_len(struct net_device *netdev) 463static int e1000_get_eeprom_len(struct net_device *netdev)
461{ 464{
462 struct e1000_adapter *adapter = netdev_priv(netdev); 465 struct e1000_adapter *adapter = netdev_priv(netdev);
463 return adapter->hw.eeprom.word_size * 2; 466 struct e1000_hw *hw = &adapter->hw;
467
468 return hw->eeprom.word_size * 2;
464} 469}
465 470
466static int e1000_get_eeprom(struct net_device *netdev, 471static int e1000_get_eeprom(struct net_device *netdev,
@@ -574,6 +579,7 @@ static void e1000_get_drvinfo(struct net_device *netdev,
574 struct ethtool_drvinfo *drvinfo) 579 struct ethtool_drvinfo *drvinfo)
575{ 580{
576 struct e1000_adapter *adapter = netdev_priv(netdev); 581 struct e1000_adapter *adapter = netdev_priv(netdev);
582 struct e1000_hw *hw = &adapter->hw;
577 char firmware_version[32]; 583 char firmware_version[32];
578 u16 eeprom_data; 584 u16 eeprom_data;
579 585
@@ -582,8 +588,8 @@ static void e1000_get_drvinfo(struct net_device *netdev,
582 588
583 /* EEPROM image version # is reported as firmware version # for 589 /* EEPROM image version # is reported as firmware version # for
584 * 8257{1|2|3} controllers */ 590 * 8257{1|2|3} controllers */
585 e1000_read_eeprom(&adapter->hw, 5, 1, &eeprom_data); 591 e1000_read_eeprom(hw, 5, 1, &eeprom_data);
586 switch (adapter->hw.mac_type) { 592 switch (hw->mac_type) {
587 case e1000_82571: 593 case e1000_82571:
588 case e1000_82572: 594 case e1000_82572:
589 case e1000_82573: 595 case e1000_82573:
@@ -608,7 +614,8 @@ static void e1000_get_ringparam(struct net_device *netdev,
608 struct ethtool_ringparam *ring) 614 struct ethtool_ringparam *ring)
609{ 615{
610 struct e1000_adapter *adapter = netdev_priv(netdev); 616 struct e1000_adapter *adapter = netdev_priv(netdev);
611 e1000_mac_type mac_type = adapter->hw.mac_type; 617 struct e1000_hw *hw = &adapter->hw;
618 e1000_mac_type mac_type = hw->mac_type;
612 struct e1000_tx_ring *txdr = adapter->tx_ring; 619 struct e1000_tx_ring *txdr = adapter->tx_ring;
613 struct e1000_rx_ring *rxdr = adapter->rx_ring; 620 struct e1000_rx_ring *rxdr = adapter->rx_ring;
614 621
@@ -628,7 +635,8 @@ static int e1000_set_ringparam(struct net_device *netdev,
628 struct ethtool_ringparam *ring) 635 struct ethtool_ringparam *ring)
629{ 636{
630 struct e1000_adapter *adapter = netdev_priv(netdev); 637 struct e1000_adapter *adapter = netdev_priv(netdev);
631 e1000_mac_type mac_type = adapter->hw.mac_type; 638 struct e1000_hw *hw = &adapter->hw;
639 e1000_mac_type mac_type = hw->mac_type;
632 struct e1000_tx_ring *txdr, *tx_old; 640 struct e1000_tx_ring *txdr, *tx_old;
633 struct e1000_rx_ring *rxdr, *rx_old; 641 struct e1000_rx_ring *rxdr, *rx_old;
634 int i, err; 642 int i, err;
@@ -714,9 +722,10 @@ err_setup:
714static bool reg_pattern_test(struct e1000_adapter *adapter, u64 *data, int reg, 722static bool reg_pattern_test(struct e1000_adapter *adapter, u64 *data, int reg,
715 u32 mask, u32 write) 723 u32 mask, u32 write)
716{ 724{
725 struct e1000_hw *hw = &adapter->hw;
717 static const u32 test[] = 726 static const u32 test[] =
718 {0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF}; 727 {0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF};
719 u8 __iomem *address = adapter->hw.hw_addr + reg; 728 u8 __iomem *address = hw->hw_addr + reg;
720 u32 read; 729 u32 read;
721 int i; 730 int i;
722 731
@@ -737,7 +746,8 @@ static bool reg_pattern_test(struct e1000_adapter *adapter, u64 *data, int reg,
737static bool reg_set_and_check(struct e1000_adapter *adapter, u64 *data, int reg, 746static bool reg_set_and_check(struct e1000_adapter *adapter, u64 *data, int reg,
738 u32 mask, u32 write) 747 u32 mask, u32 write)
739{ 748{
740 u8 __iomem *address = adapter->hw.hw_addr + reg; 749 struct e1000_hw *hw = &adapter->hw;
750 u8 __iomem *address = hw->hw_addr + reg;
741 u32 read; 751 u32 read;
742 752
743 writel(write & mask, address); 753 writel(write & mask, address);
@@ -755,7 +765,7 @@ static bool reg_set_and_check(struct e1000_adapter *adapter, u64 *data, int reg,
755#define REG_PATTERN_TEST(reg, mask, write) \ 765#define REG_PATTERN_TEST(reg, mask, write) \
756 do { \ 766 do { \
757 if (reg_pattern_test(adapter, data, \ 767 if (reg_pattern_test(adapter, data, \
758 (adapter->hw.mac_type >= e1000_82543) \ 768 (hw->mac_type >= e1000_82543) \
759 ? E1000_##reg : E1000_82542_##reg, \ 769 ? E1000_##reg : E1000_82542_##reg, \
760 mask, write)) \ 770 mask, write)) \
761 return 1; \ 771 return 1; \
@@ -764,7 +774,7 @@ static bool reg_set_and_check(struct e1000_adapter *adapter, u64 *data, int reg,
764#define REG_SET_AND_CHECK(reg, mask, write) \ 774#define REG_SET_AND_CHECK(reg, mask, write) \
765 do { \ 775 do { \
766 if (reg_set_and_check(adapter, data, \ 776 if (reg_set_and_check(adapter, data, \
767 (adapter->hw.mac_type >= e1000_82543) \ 777 (hw->mac_type >= e1000_82543) \
768 ? E1000_##reg : E1000_82542_##reg, \ 778 ? E1000_##reg : E1000_82542_##reg, \
769 mask, write)) \ 779 mask, write)) \
770 return 1; \ 780 return 1; \
@@ -774,11 +784,12 @@ static int e1000_reg_test(struct e1000_adapter *adapter, u64 *data)
774{ 784{
775 u32 value, before, after; 785 u32 value, before, after;
776 u32 i, toggle; 786 u32 i, toggle;
787 struct e1000_hw *hw = &adapter->hw;
777 788
778 /* The status register is Read Only, so a write should fail. 789 /* The status register is Read Only, so a write should fail.
779 * Some bits that get toggled are ignored. 790 * Some bits that get toggled are ignored.
780 */ 791 */
781 switch (adapter->hw.mac_type) { 792 switch (hw->mac_type) {
782 /* there are several bits on newer hardware that are r/w */ 793 /* there are several bits on newer hardware that are r/w */
783 case e1000_82571: 794 case e1000_82571:
784 case e1000_82572: 795 case e1000_82572:
@@ -794,10 +805,10 @@ static int e1000_reg_test(struct e1000_adapter *adapter, u64 *data)
794 break; 805 break;
795 } 806 }
796 807
797 before = E1000_READ_REG(&adapter->hw, STATUS); 808 before = er32(STATUS);
798 value = (E1000_READ_REG(&adapter->hw, STATUS) & toggle); 809 value = (er32(STATUS) & toggle);
799 E1000_WRITE_REG(&adapter->hw, STATUS, toggle); 810 ew32(STATUS, toggle);
800 after = E1000_READ_REG(&adapter->hw, STATUS) & toggle; 811 after = er32(STATUS) & toggle;
801 if (value != after) { 812 if (value != after) {
802 DPRINTK(DRV, ERR, "failed STATUS register test got: " 813 DPRINTK(DRV, ERR, "failed STATUS register test got: "
803 "0x%08X expected: 0x%08X\n", after, value); 814 "0x%08X expected: 0x%08X\n", after, value);
@@ -805,9 +816,9 @@ static int e1000_reg_test(struct e1000_adapter *adapter, u64 *data)
805 return 1; 816 return 1;
806 } 817 }
807 /* restore previous status */ 818 /* restore previous status */
808 E1000_WRITE_REG(&adapter->hw, STATUS, before); 819 ew32(STATUS, before);
809 820
810 if (adapter->hw.mac_type != e1000_ich8lan) { 821 if (hw->mac_type != e1000_ich8lan) {
811 REG_PATTERN_TEST(FCAL, 0xFFFFFFFF, 0xFFFFFFFF); 822 REG_PATTERN_TEST(FCAL, 0xFFFFFFFF, 0xFFFFFFFF);
812 REG_PATTERN_TEST(FCAH, 0x0000FFFF, 0xFFFFFFFF); 823 REG_PATTERN_TEST(FCAH, 0x0000FFFF, 0xFFFFFFFF);
813 REG_PATTERN_TEST(FCT, 0x0000FFFF, 0xFFFFFFFF); 824 REG_PATTERN_TEST(FCT, 0x0000FFFF, 0xFFFFFFFF);
@@ -827,20 +838,20 @@ static int e1000_reg_test(struct e1000_adapter *adapter, u64 *data)
827 838
828 REG_SET_AND_CHECK(RCTL, 0xFFFFFFFF, 0x00000000); 839 REG_SET_AND_CHECK(RCTL, 0xFFFFFFFF, 0x00000000);
829 840
830 before = (adapter->hw.mac_type == e1000_ich8lan ? 841 before = (hw->mac_type == e1000_ich8lan ?
831 0x06C3B33E : 0x06DFB3FE); 842 0x06C3B33E : 0x06DFB3FE);
832 REG_SET_AND_CHECK(RCTL, before, 0x003FFFFB); 843 REG_SET_AND_CHECK(RCTL, before, 0x003FFFFB);
833 REG_SET_AND_CHECK(TCTL, 0xFFFFFFFF, 0x00000000); 844 REG_SET_AND_CHECK(TCTL, 0xFFFFFFFF, 0x00000000);
834 845
835 if (adapter->hw.mac_type >= e1000_82543) { 846 if (hw->mac_type >= e1000_82543) {
836 847
837 REG_SET_AND_CHECK(RCTL, before, 0xFFFFFFFF); 848 REG_SET_AND_CHECK(RCTL, before, 0xFFFFFFFF);
838 REG_PATTERN_TEST(RDBAL, 0xFFFFFFF0, 0xFFFFFFFF); 849 REG_PATTERN_TEST(RDBAL, 0xFFFFFFF0, 0xFFFFFFFF);
839 if (adapter->hw.mac_type != e1000_ich8lan) 850 if (hw->mac_type != e1000_ich8lan)
840 REG_PATTERN_TEST(TXCW, 0xC000FFFF, 0x0000FFFF); 851 REG_PATTERN_TEST(TXCW, 0xC000FFFF, 0x0000FFFF);
841 REG_PATTERN_TEST(TDBAL, 0xFFFFFFF0, 0xFFFFFFFF); 852 REG_PATTERN_TEST(TDBAL, 0xFFFFFFF0, 0xFFFFFFFF);
842 REG_PATTERN_TEST(TIDV, 0x0000FFFF, 0x0000FFFF); 853 REG_PATTERN_TEST(TIDV, 0x0000FFFF, 0x0000FFFF);
843 value = (adapter->hw.mac_type == e1000_ich8lan ? 854 value = (hw->mac_type == e1000_ich8lan ?
844 E1000_RAR_ENTRIES_ICH8LAN : E1000_RAR_ENTRIES); 855 E1000_RAR_ENTRIES_ICH8LAN : E1000_RAR_ENTRIES);
845 for (i = 0; i < value; i++) { 856 for (i = 0; i < value; i++) {
846 REG_PATTERN_TEST(RA + (((i << 1) + 1) << 2), 0x8003FFFF, 857 REG_PATTERN_TEST(RA + (((i << 1) + 1) << 2), 0x8003FFFF,
@@ -856,7 +867,7 @@ static int e1000_reg_test(struct e1000_adapter *adapter, u64 *data)
856 867
857 } 868 }
858 869
859 value = (adapter->hw.mac_type == e1000_ich8lan ? 870 value = (hw->mac_type == e1000_ich8lan ?
860 E1000_MC_TBL_SIZE_ICH8LAN : E1000_MC_TBL_SIZE); 871 E1000_MC_TBL_SIZE_ICH8LAN : E1000_MC_TBL_SIZE);
861 for (i = 0; i < value; i++) 872 for (i = 0; i < value; i++)
862 REG_PATTERN_TEST(MTA + (i << 2), 0xFFFFFFFF, 0xFFFFFFFF); 873 REG_PATTERN_TEST(MTA + (i << 2), 0xFFFFFFFF, 0xFFFFFFFF);
@@ -867,6 +878,7 @@ static int e1000_reg_test(struct e1000_adapter *adapter, u64 *data)
867 878
868static int e1000_eeprom_test(struct e1000_adapter *adapter, u64 *data) 879static int e1000_eeprom_test(struct e1000_adapter *adapter, u64 *data)
869{ 880{
881 struct e1000_hw *hw = &adapter->hw;
870 u16 temp; 882 u16 temp;
871 u16 checksum = 0; 883 u16 checksum = 0;
872 u16 i; 884 u16 i;
@@ -874,7 +886,7 @@ static int e1000_eeprom_test(struct e1000_adapter *adapter, u64 *data)
874 *data = 0; 886 *data = 0;
875 /* Read and add up the contents of the EEPROM */ 887 /* Read and add up the contents of the EEPROM */
876 for (i = 0; i < (EEPROM_CHECKSUM_REG + 1); i++) { 888 for (i = 0; i < (EEPROM_CHECKSUM_REG + 1); i++) {
877 if ((e1000_read_eeprom(&adapter->hw, i, 1, &temp)) < 0) { 889 if ((e1000_read_eeprom(hw, i, 1, &temp)) < 0) {
878 *data = 1; 890 *data = 1;
879 break; 891 break;
880 } 892 }
@@ -892,8 +904,9 @@ static irqreturn_t e1000_test_intr(int irq, void *data)
892{ 904{
893 struct net_device *netdev = (struct net_device *) data; 905 struct net_device *netdev = (struct net_device *) data;
894 struct e1000_adapter *adapter = netdev_priv(netdev); 906 struct e1000_adapter *adapter = netdev_priv(netdev);
907 struct e1000_hw *hw = &adapter->hw;
895 908
896 adapter->test_icr |= E1000_READ_REG(&adapter->hw, ICR); 909 adapter->test_icr |= er32(ICR);
897 910
898 return IRQ_HANDLED; 911 return IRQ_HANDLED;
899} 912}
@@ -904,6 +917,7 @@ static int e1000_intr_test(struct e1000_adapter *adapter, u64 *data)
904 u32 mask, i = 0; 917 u32 mask, i = 0;
905 bool shared_int = true; 918 bool shared_int = true;
906 u32 irq = adapter->pdev->irq; 919 u32 irq = adapter->pdev->irq;
920 struct e1000_hw *hw = &adapter->hw;
907 921
908 *data = 0; 922 *data = 0;
909 923
@@ -921,13 +935,13 @@ static int e1000_intr_test(struct e1000_adapter *adapter, u64 *data)
921 (shared_int ? "shared" : "unshared")); 935 (shared_int ? "shared" : "unshared"));
922 936
923 /* Disable all the interrupts */ 937 /* Disable all the interrupts */
924 E1000_WRITE_REG(&adapter->hw, IMC, 0xFFFFFFFF); 938 ew32(IMC, 0xFFFFFFFF);
925 msleep(10); 939 msleep(10);
926 940
927 /* Test each interrupt */ 941 /* Test each interrupt */
928 for (; i < 10; i++) { 942 for (; i < 10; i++) {
929 943
930 if (adapter->hw.mac_type == e1000_ich8lan && i == 8) 944 if (hw->mac_type == e1000_ich8lan && i == 8)
931 continue; 945 continue;
932 946
933 /* Interrupt to test */ 947 /* Interrupt to test */
@@ -941,8 +955,8 @@ static int e1000_intr_test(struct e1000_adapter *adapter, u64 *data)
941 * test failed. 955 * test failed.
942 */ 956 */
943 adapter->test_icr = 0; 957 adapter->test_icr = 0;
944 E1000_WRITE_REG(&adapter->hw, IMC, mask); 958 ew32(IMC, mask);
945 E1000_WRITE_REG(&adapter->hw, ICS, mask); 959 ew32(ICS, mask);
946 msleep(10); 960 msleep(10);
947 961
948 if (adapter->test_icr & mask) { 962 if (adapter->test_icr & mask) {
@@ -958,8 +972,8 @@ static int e1000_intr_test(struct e1000_adapter *adapter, u64 *data)
958 * test failed. 972 * test failed.
959 */ 973 */
960 adapter->test_icr = 0; 974 adapter->test_icr = 0;
961 E1000_WRITE_REG(&adapter->hw, IMS, mask); 975 ew32(IMS, mask);
962 E1000_WRITE_REG(&adapter->hw, ICS, mask); 976 ew32(ICS, mask);
963 msleep(10); 977 msleep(10);
964 978
965 if (!(adapter->test_icr & mask)) { 979 if (!(adapter->test_icr & mask)) {
@@ -975,8 +989,8 @@ static int e1000_intr_test(struct e1000_adapter *adapter, u64 *data)
975 * test failed. 989 * test failed.
976 */ 990 */
977 adapter->test_icr = 0; 991 adapter->test_icr = 0;
978 E1000_WRITE_REG(&adapter->hw, IMC, ~mask & 0x00007FFF); 992 ew32(IMC, ~mask & 0x00007FFF);
979 E1000_WRITE_REG(&adapter->hw, ICS, ~mask & 0x00007FFF); 993 ew32(ICS, ~mask & 0x00007FFF);
980 msleep(10); 994 msleep(10);
981 995
982 if (adapter->test_icr) { 996 if (adapter->test_icr) {
@@ -987,7 +1001,7 @@ static int e1000_intr_test(struct e1000_adapter *adapter, u64 *data)
987 } 1001 }
988 1002
989 /* Disable all the interrupts */ 1003 /* Disable all the interrupts */
990 E1000_WRITE_REG(&adapter->hw, IMC, 0xFFFFFFFF); 1004 ew32(IMC, 0xFFFFFFFF);
991 msleep(10); 1005 msleep(10);
992 1006
993 /* Unhook test interrupt handler */ 1007 /* Unhook test interrupt handler */
@@ -1044,6 +1058,7 @@ static void e1000_free_desc_rings(struct e1000_adapter *adapter)
1044 1058
1045static int e1000_setup_desc_rings(struct e1000_adapter *adapter) 1059static int e1000_setup_desc_rings(struct e1000_adapter *adapter)
1046{ 1060{
1061 struct e1000_hw *hw = &adapter->hw;
1047 struct e1000_tx_ring *txdr = &adapter->test_tx_ring; 1062 struct e1000_tx_ring *txdr = &adapter->test_tx_ring;
1048 struct e1000_rx_ring *rxdr = &adapter->test_rx_ring; 1063 struct e1000_rx_ring *rxdr = &adapter->test_rx_ring;
1049 struct pci_dev *pdev = adapter->pdev; 1064 struct pci_dev *pdev = adapter->pdev;
@@ -1072,17 +1087,14 @@ static int e1000_setup_desc_rings(struct e1000_adapter *adapter)
1072 memset(txdr->desc, 0, txdr->size); 1087 memset(txdr->desc, 0, txdr->size);
1073 txdr->next_to_use = txdr->next_to_clean = 0; 1088 txdr->next_to_use = txdr->next_to_clean = 0;
1074 1089
1075 E1000_WRITE_REG(&adapter->hw, TDBAL, 1090 ew32(TDBAL, ((u64) txdr->dma & 0x00000000FFFFFFFF));
1076 ((u64) txdr->dma & 0x00000000FFFFFFFF)); 1091 ew32(TDBAH, ((u64) txdr->dma >> 32));
1077 E1000_WRITE_REG(&adapter->hw, TDBAH, ((u64) txdr->dma >> 32)); 1092 ew32(TDLEN, txdr->count * sizeof(struct e1000_tx_desc));
1078 E1000_WRITE_REG(&adapter->hw, TDLEN, 1093 ew32(TDH, 0);
1079 txdr->count * sizeof(struct e1000_tx_desc)); 1094 ew32(TDT, 0);
1080 E1000_WRITE_REG(&adapter->hw, TDH, 0); 1095 ew32(TCTL, E1000_TCTL_PSP | E1000_TCTL_EN |
1081 E1000_WRITE_REG(&adapter->hw, TDT, 0); 1096 E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT |
1082 E1000_WRITE_REG(&adapter->hw, TCTL, 1097 E1000_FDX_COLLISION_DISTANCE << E1000_COLD_SHIFT);
1083 E1000_TCTL_PSP | E1000_TCTL_EN |
1084 E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT |
1085 E1000_FDX_COLLISION_DISTANCE << E1000_COLD_SHIFT);
1086 1098
1087 for (i = 0; i < txdr->count; i++) { 1099 for (i = 0; i < txdr->count; i++) {
1088 struct e1000_tx_desc *tx_desc = E1000_TX_DESC(*txdr, i); 1100 struct e1000_tx_desc *tx_desc = E1000_TX_DESC(*txdr, i);
@@ -1127,18 +1139,17 @@ static int e1000_setup_desc_rings(struct e1000_adapter *adapter)
1127 memset(rxdr->desc, 0, rxdr->size); 1139 memset(rxdr->desc, 0, rxdr->size);
1128 rxdr->next_to_use = rxdr->next_to_clean = 0; 1140 rxdr->next_to_use = rxdr->next_to_clean = 0;
1129 1141
1130 rctl = E1000_READ_REG(&adapter->hw, RCTL); 1142 rctl = er32(RCTL);
1131 E1000_WRITE_REG(&adapter->hw, RCTL, rctl & ~E1000_RCTL_EN); 1143 ew32(RCTL, rctl & ~E1000_RCTL_EN);
1132 E1000_WRITE_REG(&adapter->hw, RDBAL, 1144 ew32(RDBAL, ((u64) rxdr->dma & 0xFFFFFFFF));
1133 ((u64) rxdr->dma & 0xFFFFFFFF)); 1145 ew32(RDBAH, ((u64) rxdr->dma >> 32));
1134 E1000_WRITE_REG(&adapter->hw, RDBAH, ((u64) rxdr->dma >> 32)); 1146 ew32(RDLEN, rxdr->size);
1135 E1000_WRITE_REG(&adapter->hw, RDLEN, rxdr->size); 1147 ew32(RDH, 0);
1136 E1000_WRITE_REG(&adapter->hw, RDH, 0); 1148 ew32(RDT, 0);
1137 E1000_WRITE_REG(&adapter->hw, RDT, 0);
1138 rctl = E1000_RCTL_EN | E1000_RCTL_BAM | E1000_RCTL_SZ_2048 | 1149 rctl = E1000_RCTL_EN | E1000_RCTL_BAM | E1000_RCTL_SZ_2048 |
1139 E1000_RCTL_LBM_NO | E1000_RCTL_RDMTS_HALF | 1150 E1000_RCTL_LBM_NO | E1000_RCTL_RDMTS_HALF |
1140 (adapter->hw.mc_filter_type << E1000_RCTL_MO_SHIFT); 1151 (hw->mc_filter_type << E1000_RCTL_MO_SHIFT);
1141 E1000_WRITE_REG(&adapter->hw, RCTL, rctl); 1152 ew32(RCTL, rctl);
1142 1153
1143 for (i = 0; i < rxdr->count; i++) { 1154 for (i = 0; i < rxdr->count; i++) {
1144 struct e1000_rx_desc *rx_desc = E1000_RX_DESC(*rxdr, i); 1155 struct e1000_rx_desc *rx_desc = E1000_RX_DESC(*rxdr, i);
@@ -1168,68 +1179,72 @@ err_nomem:
1168 1179
1169static void e1000_phy_disable_receiver(struct e1000_adapter *adapter) 1180static void e1000_phy_disable_receiver(struct e1000_adapter *adapter)
1170{ 1181{
1182 struct e1000_hw *hw = &adapter->hw;
1183
1171 /* Write out to PHY registers 29 and 30 to disable the Receiver. */ 1184 /* Write out to PHY registers 29 and 30 to disable the Receiver. */
1172 e1000_write_phy_reg(&adapter->hw, 29, 0x001F); 1185 e1000_write_phy_reg(hw, 29, 0x001F);
1173 e1000_write_phy_reg(&adapter->hw, 30, 0x8FFC); 1186 e1000_write_phy_reg(hw, 30, 0x8FFC);
1174 e1000_write_phy_reg(&adapter->hw, 29, 0x001A); 1187 e1000_write_phy_reg(hw, 29, 0x001A);
1175 e1000_write_phy_reg(&adapter->hw, 30, 0x8FF0); 1188 e1000_write_phy_reg(hw, 30, 0x8FF0);
1176} 1189}
1177 1190
1178static void e1000_phy_reset_clk_and_crs(struct e1000_adapter *adapter) 1191static void e1000_phy_reset_clk_and_crs(struct e1000_adapter *adapter)
1179{ 1192{
1193 struct e1000_hw *hw = &adapter->hw;
1180 u16 phy_reg; 1194 u16 phy_reg;
1181 1195
1182 /* Because we reset the PHY above, we need to re-force TX_CLK in the 1196 /* Because we reset the PHY above, we need to re-force TX_CLK in the
1183 * Extended PHY Specific Control Register to 25MHz clock. This 1197 * Extended PHY Specific Control Register to 25MHz clock. This
1184 * value defaults back to a 2.5MHz clock when the PHY is reset. 1198 * value defaults back to a 2.5MHz clock when the PHY is reset.
1185 */ 1199 */
1186 e1000_read_phy_reg(&adapter->hw, M88E1000_EXT_PHY_SPEC_CTRL, &phy_reg); 1200 e1000_read_phy_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, &phy_reg);
1187 phy_reg |= M88E1000_EPSCR_TX_CLK_25; 1201 phy_reg |= M88E1000_EPSCR_TX_CLK_25;
1188 e1000_write_phy_reg(&adapter->hw, 1202 e1000_write_phy_reg(hw,
1189 M88E1000_EXT_PHY_SPEC_CTRL, phy_reg); 1203 M88E1000_EXT_PHY_SPEC_CTRL, phy_reg);
1190 1204
1191 /* In addition, because of the s/w reset above, we need to enable 1205 /* In addition, because of the s/w reset above, we need to enable
1192 * CRS on TX. This must be set for both full and half duplex 1206 * CRS on TX. This must be set for both full and half duplex
1193 * operation. 1207 * operation.
1194 */ 1208 */
1195 e1000_read_phy_reg(&adapter->hw, M88E1000_PHY_SPEC_CTRL, &phy_reg); 1209 e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_reg);
1196 phy_reg |= M88E1000_PSCR_ASSERT_CRS_ON_TX; 1210 phy_reg |= M88E1000_PSCR_ASSERT_CRS_ON_TX;
1197 e1000_write_phy_reg(&adapter->hw, 1211 e1000_write_phy_reg(hw,
1198 M88E1000_PHY_SPEC_CTRL, phy_reg); 1212 M88E1000_PHY_SPEC_CTRL, phy_reg);
1199} 1213}
1200 1214
1201static int e1000_nonintegrated_phy_loopback(struct e1000_adapter *adapter) 1215static int e1000_nonintegrated_phy_loopback(struct e1000_adapter *adapter)
1202{ 1216{
1217 struct e1000_hw *hw = &adapter->hw;
1203 u32 ctrl_reg; 1218 u32 ctrl_reg;
1204 u16 phy_reg; 1219 u16 phy_reg;
1205 1220
1206 /* Setup the Device Control Register for PHY loopback test. */ 1221 /* Setup the Device Control Register for PHY loopback test. */
1207 1222
1208 ctrl_reg = E1000_READ_REG(&adapter->hw, CTRL); 1223 ctrl_reg = er32(CTRL);
1209 ctrl_reg |= (E1000_CTRL_ILOS | /* Invert Loss-Of-Signal */ 1224 ctrl_reg |= (E1000_CTRL_ILOS | /* Invert Loss-Of-Signal */
1210 E1000_CTRL_FRCSPD | /* Set the Force Speed Bit */ 1225 E1000_CTRL_FRCSPD | /* Set the Force Speed Bit */
1211 E1000_CTRL_FRCDPX | /* Set the Force Duplex Bit */ 1226 E1000_CTRL_FRCDPX | /* Set the Force Duplex Bit */
1212 E1000_CTRL_SPD_1000 | /* Force Speed to 1000 */ 1227 E1000_CTRL_SPD_1000 | /* Force Speed to 1000 */
1213 E1000_CTRL_FD); /* Force Duplex to FULL */ 1228 E1000_CTRL_FD); /* Force Duplex to FULL */
1214 1229
1215 E1000_WRITE_REG(&adapter->hw, CTRL, ctrl_reg); 1230 ew32(CTRL, ctrl_reg);
1216 1231
1217 /* Read the PHY Specific Control Register (0x10) */ 1232 /* Read the PHY Specific Control Register (0x10) */
1218 e1000_read_phy_reg(&adapter->hw, M88E1000_PHY_SPEC_CTRL, &phy_reg); 1233 e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_reg);
1219 1234
1220 /* Clear Auto-Crossover bits in PHY Specific Control Register 1235 /* Clear Auto-Crossover bits in PHY Specific Control Register
1221 * (bits 6:5). 1236 * (bits 6:5).
1222 */ 1237 */
1223 phy_reg &= ~M88E1000_PSCR_AUTO_X_MODE; 1238 phy_reg &= ~M88E1000_PSCR_AUTO_X_MODE;
1224 e1000_write_phy_reg(&adapter->hw, M88E1000_PHY_SPEC_CTRL, phy_reg); 1239 e1000_write_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, phy_reg);
1225 1240
1226 /* Perform software reset on the PHY */ 1241 /* Perform software reset on the PHY */
1227 e1000_phy_reset(&adapter->hw); 1242 e1000_phy_reset(hw);
1228 1243
1229 /* Have to setup TX_CLK and TX_CRS after software reset */ 1244 /* Have to setup TX_CLK and TX_CRS after software reset */
1230 e1000_phy_reset_clk_and_crs(adapter); 1245 e1000_phy_reset_clk_and_crs(adapter);
1231 1246
1232 e1000_write_phy_reg(&adapter->hw, PHY_CTRL, 0x8100); 1247 e1000_write_phy_reg(hw, PHY_CTRL, 0x8100);
1233 1248
1234 /* Wait for reset to complete. */ 1249 /* Wait for reset to complete. */
1235 udelay(500); 1250 udelay(500);
@@ -1241,23 +1256,23 @@ static int e1000_nonintegrated_phy_loopback(struct e1000_adapter *adapter)
1241 e1000_phy_disable_receiver(adapter); 1256 e1000_phy_disable_receiver(adapter);
1242 1257
1243 /* Set the loopback bit in the PHY control register. */ 1258 /* Set the loopback bit in the PHY control register. */
1244 e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &phy_reg); 1259 e1000_read_phy_reg(hw, PHY_CTRL, &phy_reg);
1245 phy_reg |= MII_CR_LOOPBACK; 1260 phy_reg |= MII_CR_LOOPBACK;
1246 e1000_write_phy_reg(&adapter->hw, PHY_CTRL, phy_reg); 1261 e1000_write_phy_reg(hw, PHY_CTRL, phy_reg);
1247 1262
1248 /* Setup TX_CLK and TX_CRS one more time. */ 1263 /* Setup TX_CLK and TX_CRS one more time. */
1249 e1000_phy_reset_clk_and_crs(adapter); 1264 e1000_phy_reset_clk_and_crs(adapter);
1250 1265
1251 /* Check Phy Configuration */ 1266 /* Check Phy Configuration */
1252 e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &phy_reg); 1267 e1000_read_phy_reg(hw, PHY_CTRL, &phy_reg);
1253 if (phy_reg != 0x4100) 1268 if (phy_reg != 0x4100)
1254 return 9; 1269 return 9;
1255 1270
1256 e1000_read_phy_reg(&adapter->hw, M88E1000_EXT_PHY_SPEC_CTRL, &phy_reg); 1271 e1000_read_phy_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, &phy_reg);
1257 if (phy_reg != 0x0070) 1272 if (phy_reg != 0x0070)
1258 return 10; 1273 return 10;
1259 1274
1260 e1000_read_phy_reg(&adapter->hw, 29, &phy_reg); 1275 e1000_read_phy_reg(hw, 29, &phy_reg);
1261 if (phy_reg != 0x001A) 1276 if (phy_reg != 0x001A)
1262 return 11; 1277 return 11;
1263 1278
@@ -1266,29 +1281,30 @@ static int e1000_nonintegrated_phy_loopback(struct e1000_adapter *adapter)
1266 1281
1267static int e1000_integrated_phy_loopback(struct e1000_adapter *adapter) 1282static int e1000_integrated_phy_loopback(struct e1000_adapter *adapter)
1268{ 1283{
1284 struct e1000_hw *hw = &adapter->hw;
1269 u32 ctrl_reg = 0; 1285 u32 ctrl_reg = 0;
1270 u32 stat_reg = 0; 1286 u32 stat_reg = 0;
1271 1287
1272 adapter->hw.autoneg = false; 1288 hw->autoneg = false;
1273 1289
1274 if (adapter->hw.phy_type == e1000_phy_m88) { 1290 if (hw->phy_type == e1000_phy_m88) {
1275 /* Auto-MDI/MDIX Off */ 1291 /* Auto-MDI/MDIX Off */
1276 e1000_write_phy_reg(&adapter->hw, 1292 e1000_write_phy_reg(hw,
1277 M88E1000_PHY_SPEC_CTRL, 0x0808); 1293 M88E1000_PHY_SPEC_CTRL, 0x0808);
1278 /* reset to update Auto-MDI/MDIX */ 1294 /* reset to update Auto-MDI/MDIX */
1279 e1000_write_phy_reg(&adapter->hw, PHY_CTRL, 0x9140); 1295 e1000_write_phy_reg(hw, PHY_CTRL, 0x9140);
1280 /* autoneg off */ 1296 /* autoneg off */
1281 e1000_write_phy_reg(&adapter->hw, PHY_CTRL, 0x8140); 1297 e1000_write_phy_reg(hw, PHY_CTRL, 0x8140);
1282 } else if (adapter->hw.phy_type == e1000_phy_gg82563) 1298 } else if (hw->phy_type == e1000_phy_gg82563)
1283 e1000_write_phy_reg(&adapter->hw, 1299 e1000_write_phy_reg(hw,
1284 GG82563_PHY_KMRN_MODE_CTRL, 1300 GG82563_PHY_KMRN_MODE_CTRL,
1285 0x1CC); 1301 0x1CC);
1286 1302
1287 ctrl_reg = E1000_READ_REG(&adapter->hw, CTRL); 1303 ctrl_reg = er32(CTRL);
1288 1304
1289 if (adapter->hw.phy_type == e1000_phy_ife) { 1305 if (hw->phy_type == e1000_phy_ife) {
1290 /* force 100, set loopback */ 1306 /* force 100, set loopback */
1291 e1000_write_phy_reg(&adapter->hw, PHY_CTRL, 0x6100); 1307 e1000_write_phy_reg(hw, PHY_CTRL, 0x6100);
1292 1308
1293 /* Now set up the MAC to the same speed/duplex as the PHY. */ 1309 /* Now set up the MAC to the same speed/duplex as the PHY. */
1294 ctrl_reg &= ~E1000_CTRL_SPD_SEL; /* Clear the speed sel bits */ 1310 ctrl_reg &= ~E1000_CTRL_SPD_SEL; /* Clear the speed sel bits */
@@ -1298,10 +1314,10 @@ static int e1000_integrated_phy_loopback(struct e1000_adapter *adapter)
1298 E1000_CTRL_FD); /* Force Duplex to FULL */ 1314 E1000_CTRL_FD); /* Force Duplex to FULL */
1299 } else { 1315 } else {
1300 /* force 1000, set loopback */ 1316 /* force 1000, set loopback */
1301 e1000_write_phy_reg(&adapter->hw, PHY_CTRL, 0x4140); 1317 e1000_write_phy_reg(hw, PHY_CTRL, 0x4140);
1302 1318
1303 /* Now set up the MAC to the same speed/duplex as the PHY. */ 1319 /* Now set up the MAC to the same speed/duplex as the PHY. */
1304 ctrl_reg = E1000_READ_REG(&adapter->hw, CTRL); 1320 ctrl_reg = er32(CTRL);
1305 ctrl_reg &= ~E1000_CTRL_SPD_SEL; /* Clear the speed sel bits */ 1321 ctrl_reg &= ~E1000_CTRL_SPD_SEL; /* Clear the speed sel bits */
1306 ctrl_reg |= (E1000_CTRL_FRCSPD | /* Set the Force Speed Bit */ 1322 ctrl_reg |= (E1000_CTRL_FRCSPD | /* Set the Force Speed Bit */
1307 E1000_CTRL_FRCDPX | /* Set the Force Duplex Bit */ 1323 E1000_CTRL_FRCDPX | /* Set the Force Duplex Bit */
@@ -1309,23 +1325,23 @@ static int e1000_integrated_phy_loopback(struct e1000_adapter *adapter)
1309 E1000_CTRL_FD); /* Force Duplex to FULL */ 1325 E1000_CTRL_FD); /* Force Duplex to FULL */
1310 } 1326 }
1311 1327
1312 if (adapter->hw.media_type == e1000_media_type_copper && 1328 if (hw->media_type == e1000_media_type_copper &&
1313 adapter->hw.phy_type == e1000_phy_m88) 1329 hw->phy_type == e1000_phy_m88)
1314 ctrl_reg |= E1000_CTRL_ILOS; /* Invert Loss of Signal */ 1330 ctrl_reg |= E1000_CTRL_ILOS; /* Invert Loss of Signal */
1315 else { 1331 else {
1316 /* Set the ILOS bit on the fiber Nic is half 1332 /* Set the ILOS bit on the fiber Nic is half
1317 * duplex link is detected. */ 1333 * duplex link is detected. */
1318 stat_reg = E1000_READ_REG(&adapter->hw, STATUS); 1334 stat_reg = er32(STATUS);
1319 if ((stat_reg & E1000_STATUS_FD) == 0) 1335 if ((stat_reg & E1000_STATUS_FD) == 0)
1320 ctrl_reg |= (E1000_CTRL_ILOS | E1000_CTRL_SLU); 1336 ctrl_reg |= (E1000_CTRL_ILOS | E1000_CTRL_SLU);
1321 } 1337 }
1322 1338
1323 E1000_WRITE_REG(&adapter->hw, CTRL, ctrl_reg); 1339 ew32(CTRL, ctrl_reg);
1324 1340
1325 /* Disable the receiver on the PHY so when a cable is plugged in, the 1341 /* Disable the receiver on the PHY so when a cable is plugged in, the
1326 * PHY does not begin to autoneg when a cable is reconnected to the NIC. 1342 * PHY does not begin to autoneg when a cable is reconnected to the NIC.
1327 */ 1343 */
1328 if (adapter->hw.phy_type == e1000_phy_m88) 1344 if (hw->phy_type == e1000_phy_m88)
1329 e1000_phy_disable_receiver(adapter); 1345 e1000_phy_disable_receiver(adapter);
1330 1346
1331 udelay(500); 1347 udelay(500);
@@ -1335,12 +1351,13 @@ static int e1000_integrated_phy_loopback(struct e1000_adapter *adapter)
1335 1351
1336static int e1000_set_phy_loopback(struct e1000_adapter *adapter) 1352static int e1000_set_phy_loopback(struct e1000_adapter *adapter)
1337{ 1353{
1354 struct e1000_hw *hw = &adapter->hw;
1338 u16 phy_reg = 0; 1355 u16 phy_reg = 0;
1339 u16 count = 0; 1356 u16 count = 0;
1340 1357
1341 switch (adapter->hw.mac_type) { 1358 switch (hw->mac_type) {
1342 case e1000_82543: 1359 case e1000_82543:
1343 if (adapter->hw.media_type == e1000_media_type_copper) { 1360 if (hw->media_type == e1000_media_type_copper) {
1344 /* Attempt to setup Loopback mode on Non-integrated PHY. 1361 /* Attempt to setup Loopback mode on Non-integrated PHY.
1345 * Some PHY registers get corrupted at random, so 1362 * Some PHY registers get corrupted at random, so
1346 * attempt this 10 times. 1363 * attempt this 10 times.
@@ -1374,9 +1391,9 @@ static int e1000_set_phy_loopback(struct e1000_adapter *adapter)
1374 /* Default PHY loopback work is to read the MII 1391 /* Default PHY loopback work is to read the MII
1375 * control register and assert bit 14 (loopback mode). 1392 * control register and assert bit 14 (loopback mode).
1376 */ 1393 */
1377 e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &phy_reg); 1394 e1000_read_phy_reg(hw, PHY_CTRL, &phy_reg);
1378 phy_reg |= MII_CR_LOOPBACK; 1395 phy_reg |= MII_CR_LOOPBACK;
1379 e1000_write_phy_reg(&adapter->hw, PHY_CTRL, phy_reg); 1396 e1000_write_phy_reg(hw, PHY_CTRL, phy_reg);
1380 return 0; 1397 return 0;
1381 break; 1398 break;
1382 } 1399 }
@@ -1402,14 +1419,14 @@ static int e1000_setup_loopback_test(struct e1000_adapter *adapter)
1402 case e1000_82572: 1419 case e1000_82572:
1403#define E1000_SERDES_LB_ON 0x410 1420#define E1000_SERDES_LB_ON 0x410
1404 e1000_set_phy_loopback(adapter); 1421 e1000_set_phy_loopback(adapter);
1405 E1000_WRITE_REG(hw, SCTL, E1000_SERDES_LB_ON); 1422 ew32(SCTL, E1000_SERDES_LB_ON);
1406 msleep(10); 1423 msleep(10);
1407 return 0; 1424 return 0;
1408 break; 1425 break;
1409 default: 1426 default:
1410 rctl = E1000_READ_REG(hw, RCTL); 1427 rctl = er32(RCTL);
1411 rctl |= E1000_RCTL_LBM_TCVR; 1428 rctl |= E1000_RCTL_LBM_TCVR;
1412 E1000_WRITE_REG(hw, RCTL, rctl); 1429 ew32(RCTL, rctl);
1413 return 0; 1430 return 0;
1414 } 1431 }
1415 } else if (hw->media_type == e1000_media_type_copper) 1432 } else if (hw->media_type == e1000_media_type_copper)
@@ -1424,9 +1441,9 @@ static void e1000_loopback_cleanup(struct e1000_adapter *adapter)
1424 u32 rctl; 1441 u32 rctl;
1425 u16 phy_reg; 1442 u16 phy_reg;
1426 1443
1427 rctl = E1000_READ_REG(hw, RCTL); 1444 rctl = er32(RCTL);
1428 rctl &= ~(E1000_RCTL_LBM_TCVR | E1000_RCTL_LBM_MAC); 1445 rctl &= ~(E1000_RCTL_LBM_TCVR | E1000_RCTL_LBM_MAC);
1429 E1000_WRITE_REG(hw, RCTL, rctl); 1446 ew32(RCTL, rctl);
1430 1447
1431 switch (hw->mac_type) { 1448 switch (hw->mac_type) {
1432 case e1000_82571: 1449 case e1000_82571:
@@ -1434,7 +1451,7 @@ static void e1000_loopback_cleanup(struct e1000_adapter *adapter)
1434 if (hw->media_type == e1000_media_type_fiber || 1451 if (hw->media_type == e1000_media_type_fiber ||
1435 hw->media_type == e1000_media_type_internal_serdes) { 1452 hw->media_type == e1000_media_type_internal_serdes) {
1436#define E1000_SERDES_LB_OFF 0x400 1453#define E1000_SERDES_LB_OFF 0x400
1437 E1000_WRITE_REG(hw, SCTL, E1000_SERDES_LB_OFF); 1454 ew32(SCTL, E1000_SERDES_LB_OFF);
1438 msleep(10); 1455 msleep(10);
1439 break; 1456 break;
1440 } 1457 }
@@ -1484,13 +1501,14 @@ static int e1000_check_lbtest_frame(struct sk_buff *skb,
1484 1501
1485static int e1000_run_loopback_test(struct e1000_adapter *adapter) 1502static int e1000_run_loopback_test(struct e1000_adapter *adapter)
1486{ 1503{
1504 struct e1000_hw *hw = &adapter->hw;
1487 struct e1000_tx_ring *txdr = &adapter->test_tx_ring; 1505 struct e1000_tx_ring *txdr = &adapter->test_tx_ring;
1488 struct e1000_rx_ring *rxdr = &adapter->test_rx_ring; 1506 struct e1000_rx_ring *rxdr = &adapter->test_rx_ring;
1489 struct pci_dev *pdev = adapter->pdev; 1507 struct pci_dev *pdev = adapter->pdev;
1490 int i, j, k, l, lc, good_cnt, ret_val=0; 1508 int i, j, k, l, lc, good_cnt, ret_val=0;
1491 unsigned long time; 1509 unsigned long time;
1492 1510
1493 E1000_WRITE_REG(&adapter->hw, RDT, rxdr->count - 1); 1511 ew32(RDT, rxdr->count - 1);
1494 1512
1495 /* Calculate the loop count based on the largest descriptor ring 1513 /* Calculate the loop count based on the largest descriptor ring
1496 * The idea is to wrap the largest ring a number of times using 64 1514 * The idea is to wrap the largest ring a number of times using 64
@@ -1513,7 +1531,7 @@ static int e1000_run_loopback_test(struct e1000_adapter *adapter)
1513 PCI_DMA_TODEVICE); 1531 PCI_DMA_TODEVICE);
1514 if (unlikely(++k == txdr->count)) k = 0; 1532 if (unlikely(++k == txdr->count)) k = 0;
1515 } 1533 }
1516 E1000_WRITE_REG(&adapter->hw, TDT, k); 1534 ew32(TDT, k);
1517 msleep(200); 1535 msleep(200);
1518 time = jiffies; /* set the start time for the receive */ 1536 time = jiffies; /* set the start time for the receive */
1519 good_cnt = 0; 1537 good_cnt = 0;
@@ -1548,9 +1566,11 @@ static int e1000_run_loopback_test(struct e1000_adapter *adapter)
1548 1566
1549static int e1000_loopback_test(struct e1000_adapter *adapter, u64 *data) 1567static int e1000_loopback_test(struct e1000_adapter *adapter, u64 *data)
1550{ 1568{
1569 struct e1000_hw *hw = &adapter->hw;
1570
1551 /* PHY loopback cannot be performed if SoL/IDER 1571 /* PHY loopback cannot be performed if SoL/IDER
1552 * sessions are active */ 1572 * sessions are active */
1553 if (e1000_check_phy_reset_block(&adapter->hw)) { 1573 if (e1000_check_phy_reset_block(hw)) {
1554 DPRINTK(DRV, ERR, "Cannot do PHY loopback test " 1574 DPRINTK(DRV, ERR, "Cannot do PHY loopback test "
1555 "when SoL/IDER is active.\n"); 1575 "when SoL/IDER is active.\n");
1556 *data = 0; 1576 *data = 0;
@@ -1572,27 +1592,28 @@ out:
1572 1592
1573static int e1000_link_test(struct e1000_adapter *adapter, u64 *data) 1593static int e1000_link_test(struct e1000_adapter *adapter, u64 *data)
1574{ 1594{
1595 struct e1000_hw *hw = &adapter->hw;
1575 *data = 0; 1596 *data = 0;
1576 if (adapter->hw.media_type == e1000_media_type_internal_serdes) { 1597 if (hw->media_type == e1000_media_type_internal_serdes) {
1577 int i = 0; 1598 int i = 0;
1578 adapter->hw.serdes_link_down = true; 1599 hw->serdes_link_down = true;
1579 1600
1580 /* On some blade server designs, link establishment 1601 /* On some blade server designs, link establishment
1581 * could take as long as 2-3 minutes */ 1602 * could take as long as 2-3 minutes */
1582 do { 1603 do {
1583 e1000_check_for_link(&adapter->hw); 1604 e1000_check_for_link(hw);
1584 if (!adapter->hw.serdes_link_down) 1605 if (!hw->serdes_link_down)
1585 return *data; 1606 return *data;
1586 msleep(20); 1607 msleep(20);
1587 } while (i++ < 3750); 1608 } while (i++ < 3750);
1588 1609
1589 *data = 1; 1610 *data = 1;
1590 } else { 1611 } else {
1591 e1000_check_for_link(&adapter->hw); 1612 e1000_check_for_link(hw);
1592 if (adapter->hw.autoneg) /* if auto_neg is set wait for it */ 1613 if (hw->autoneg) /* if auto_neg is set wait for it */
1593 msleep(4000); 1614 msleep(4000);
1594 1615
1595 if (!(E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_LU)) { 1616 if (!(er32(STATUS) & E1000_STATUS_LU)) {
1596 *data = 1; 1617 *data = 1;
1597 } 1618 }
1598 } 1619 }
@@ -1615,6 +1636,7 @@ static void e1000_diag_test(struct net_device *netdev,
1615 struct ethtool_test *eth_test, u64 *data) 1636 struct ethtool_test *eth_test, u64 *data)
1616{ 1637{
1617 struct e1000_adapter *adapter = netdev_priv(netdev); 1638 struct e1000_adapter *adapter = netdev_priv(netdev);
1639 struct e1000_hw *hw = &adapter->hw;
1618 bool if_running = netif_running(netdev); 1640 bool if_running = netif_running(netdev);
1619 1641
1620 set_bit(__E1000_TESTING, &adapter->flags); 1642 set_bit(__E1000_TESTING, &adapter->flags);
@@ -1622,9 +1644,9 @@ static void e1000_diag_test(struct net_device *netdev,
1622 /* Offline tests */ 1644 /* Offline tests */
1623 1645
1624 /* save speed, duplex, autoneg settings */ 1646 /* save speed, duplex, autoneg settings */
1625 u16 autoneg_advertised = adapter->hw.autoneg_advertised; 1647 u16 autoneg_advertised = hw->autoneg_advertised;
1626 u8 forced_speed_duplex = adapter->hw.forced_speed_duplex; 1648 u8 forced_speed_duplex = hw->forced_speed_duplex;
1627 u8 autoneg = adapter->hw.autoneg; 1649 u8 autoneg = hw->autoneg;
1628 1650
1629 DPRINTK(HW, INFO, "offline testing starting\n"); 1651 DPRINTK(HW, INFO, "offline testing starting\n");
1630 1652
@@ -1657,9 +1679,9 @@ static void e1000_diag_test(struct net_device *netdev,
1657 eth_test->flags |= ETH_TEST_FL_FAILED; 1679 eth_test->flags |= ETH_TEST_FL_FAILED;
1658 1680
1659 /* restore speed, duplex, autoneg settings */ 1681 /* restore speed, duplex, autoneg settings */
1660 adapter->hw.autoneg_advertised = autoneg_advertised; 1682 hw->autoneg_advertised = autoneg_advertised;
1661 adapter->hw.forced_speed_duplex = forced_speed_duplex; 1683 hw->forced_speed_duplex = forced_speed_duplex;
1662 adapter->hw.autoneg = autoneg; 1684 hw->autoneg = autoneg;
1663 1685
1664 e1000_reset(adapter); 1686 e1000_reset(adapter);
1665 clear_bit(__E1000_TESTING, &adapter->flags); 1687 clear_bit(__E1000_TESTING, &adapter->flags);
@@ -1708,7 +1730,7 @@ static int e1000_wol_exclusion(struct e1000_adapter *adapter,
1708 case E1000_DEV_ID_82571EB_SERDES: 1730 case E1000_DEV_ID_82571EB_SERDES:
1709 case E1000_DEV_ID_82571EB_COPPER: 1731 case E1000_DEV_ID_82571EB_COPPER:
1710 /* Wake events not supported on port B */ 1732 /* Wake events not supported on port B */
1711 if (E1000_READ_REG(hw, STATUS) & E1000_STATUS_FUNC_1) { 1733 if (er32(STATUS) & E1000_STATUS_FUNC_1) {
1712 wol->supported = 0; 1734 wol->supported = 0;
1713 break; 1735 break;
1714 } 1736 }
@@ -1732,7 +1754,7 @@ static int e1000_wol_exclusion(struct e1000_adapter *adapter,
1732 /* dual port cards only support WoL on port A from now on 1754 /* dual port cards only support WoL on port A from now on
1733 * unless it was enabled in the eeprom for port B 1755 * unless it was enabled in the eeprom for port B
1734 * so exclude FUNC_1 ports from having WoL enabled */ 1756 * so exclude FUNC_1 ports from having WoL enabled */
1735 if (E1000_READ_REG(hw, STATUS) & E1000_STATUS_FUNC_1 && 1757 if (er32(STATUS) & E1000_STATUS_FUNC_1 &&
1736 !adapter->eeprom_wol) { 1758 !adapter->eeprom_wol) {
1737 wol->supported = 0; 1759 wol->supported = 0;
1738 break; 1760 break;
@@ -1748,6 +1770,7 @@ static void e1000_get_wol(struct net_device *netdev,
1748 struct ethtool_wolinfo *wol) 1770 struct ethtool_wolinfo *wol)
1749{ 1771{
1750 struct e1000_adapter *adapter = netdev_priv(netdev); 1772 struct e1000_adapter *adapter = netdev_priv(netdev);
1773 struct e1000_hw *hw = &adapter->hw;
1751 1774
1752 wol->supported = WAKE_UCAST | WAKE_MCAST | 1775 wol->supported = WAKE_UCAST | WAKE_MCAST |
1753 WAKE_BCAST | WAKE_MAGIC; 1776 WAKE_BCAST | WAKE_MAGIC;
@@ -1759,7 +1782,7 @@ static void e1000_get_wol(struct net_device *netdev,
1759 return; 1782 return;
1760 1783
1761 /* apply any specific unsupported masks here */ 1784 /* apply any specific unsupported masks here */
1762 switch (adapter->hw.device_id) { 1785 switch (hw->device_id) {
1763 case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3: 1786 case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3:
1764 /* KSP3 does not suppport UCAST wake-ups */ 1787 /* KSP3 does not suppport UCAST wake-ups */
1765 wol->supported &= ~WAKE_UCAST; 1788 wol->supported &= ~WAKE_UCAST;
@@ -1831,11 +1854,12 @@ static int e1000_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
1831static void e1000_led_blink_callback(unsigned long data) 1854static void e1000_led_blink_callback(unsigned long data)
1832{ 1855{
1833 struct e1000_adapter *adapter = (struct e1000_adapter *) data; 1856 struct e1000_adapter *adapter = (struct e1000_adapter *) data;
1857 struct e1000_hw *hw = &adapter->hw;
1834 1858
1835 if (test_and_change_bit(E1000_LED_ON, &adapter->led_status)) 1859 if (test_and_change_bit(E1000_LED_ON, &adapter->led_status))
1836 e1000_led_off(&adapter->hw); 1860 e1000_led_off(hw);
1837 else 1861 else
1838 e1000_led_on(&adapter->hw); 1862 e1000_led_on(hw);
1839 1863
1840 mod_timer(&adapter->blink_timer, jiffies + E1000_ID_INTERVAL); 1864 mod_timer(&adapter->blink_timer, jiffies + E1000_ID_INTERVAL);
1841} 1865}
@@ -1843,21 +1867,22 @@ static void e1000_led_blink_callback(unsigned long data)
1843static int e1000_phys_id(struct net_device *netdev, u32 data) 1867static int e1000_phys_id(struct net_device *netdev, u32 data)
1844{ 1868{
1845 struct e1000_adapter *adapter = netdev_priv(netdev); 1869 struct e1000_adapter *adapter = netdev_priv(netdev);
1870 struct e1000_hw *hw = &adapter->hw;
1846 1871
1847 if (!data) 1872 if (!data)
1848 data = INT_MAX; 1873 data = INT_MAX;
1849 1874
1850 if (adapter->hw.mac_type < e1000_82571) { 1875 if (hw->mac_type < e1000_82571) {
1851 if (!adapter->blink_timer.function) { 1876 if (!adapter->blink_timer.function) {
1852 init_timer(&adapter->blink_timer); 1877 init_timer(&adapter->blink_timer);
1853 adapter->blink_timer.function = e1000_led_blink_callback; 1878 adapter->blink_timer.function = e1000_led_blink_callback;
1854 adapter->blink_timer.data = (unsigned long) adapter; 1879 adapter->blink_timer.data = (unsigned long) adapter;
1855 } 1880 }
1856 e1000_setup_led(&adapter->hw); 1881 e1000_setup_led(hw);
1857 mod_timer(&adapter->blink_timer, jiffies); 1882 mod_timer(&adapter->blink_timer, jiffies);
1858 msleep_interruptible(data * 1000); 1883 msleep_interruptible(data * 1000);
1859 del_timer_sync(&adapter->blink_timer); 1884 del_timer_sync(&adapter->blink_timer);
1860 } else if (adapter->hw.phy_type == e1000_phy_ife) { 1885 } else if (hw->phy_type == e1000_phy_ife) {
1861 if (!adapter->blink_timer.function) { 1886 if (!adapter->blink_timer.function) {
1862 init_timer(&adapter->blink_timer); 1887 init_timer(&adapter->blink_timer);
1863 adapter->blink_timer.function = e1000_led_blink_callback; 1888 adapter->blink_timer.function = e1000_led_blink_callback;
@@ -1868,13 +1893,13 @@ static int e1000_phys_id(struct net_device *netdev, u32 data)
1868 del_timer_sync(&adapter->blink_timer); 1893 del_timer_sync(&adapter->blink_timer);
1869 e1000_write_phy_reg(&(adapter->hw), IFE_PHY_SPECIAL_CONTROL_LED, 0); 1894 e1000_write_phy_reg(&(adapter->hw), IFE_PHY_SPECIAL_CONTROL_LED, 0);
1870 } else { 1895 } else {
1871 e1000_blink_led_start(&adapter->hw); 1896 e1000_blink_led_start(hw);
1872 msleep_interruptible(data * 1000); 1897 msleep_interruptible(data * 1000);
1873 } 1898 }
1874 1899
1875 e1000_led_off(&adapter->hw); 1900 e1000_led_off(hw);
1876 clear_bit(E1000_LED_ON, &adapter->led_status); 1901 clear_bit(E1000_LED_ON, &adapter->led_status);
1877 e1000_cleanup_led(&adapter->hw); 1902 e1000_cleanup_led(hw);
1878 1903
1879 return 0; 1904 return 0;
1880} 1905}