diff options
author | David S. Miller <davem@davemloft.net> | 2011-05-09 15:48:05 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-05-09 15:48:05 -0400 |
commit | 4a9e25d8de3e1435a0b5155e0195de20744894fe (patch) | |
tree | b415fdc68381a0fe56824c896053b6f93ddbd87b | |
parent | 4940fc889e1e63667a15243028ddcd84d471cd8e (diff) | |
parent | 5d320a205de277774962782a4b1923e4f8cdf781 (diff) |
Merge branch 'davem-next.r8169' of git://git.kernel.org/pub/scm/linux/kernel/git/romieu/netdev-2.6
-rw-r--r-- | drivers/net/r8169.c | 574 |
1 files changed, 261 insertions, 313 deletions
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c index a8976a753814..04f4e6086cd0 100644 --- a/drivers/net/r8169.c +++ b/drivers/net/r8169.c | |||
@@ -98,40 +98,40 @@ static const int multicast_filter_limit = 32; | |||
98 | #define RTL_R32(reg) readl (ioaddr + (reg)) | 98 | #define RTL_R32(reg) readl (ioaddr + (reg)) |
99 | 99 | ||
100 | enum mac_version { | 100 | enum mac_version { |
101 | RTL_GIGA_MAC_NONE = 0x00, | 101 | RTL_GIGA_MAC_VER_01 = 0, |
102 | RTL_GIGA_MAC_VER_01 = 0x01, // 8169 | 102 | RTL_GIGA_MAC_VER_02, |
103 | RTL_GIGA_MAC_VER_02 = 0x02, // 8169S | 103 | RTL_GIGA_MAC_VER_03, |
104 | RTL_GIGA_MAC_VER_03 = 0x03, // 8110S | 104 | RTL_GIGA_MAC_VER_04, |
105 | RTL_GIGA_MAC_VER_04 = 0x04, // 8169SB | 105 | RTL_GIGA_MAC_VER_05, |
106 | RTL_GIGA_MAC_VER_05 = 0x05, // 8110SCd | 106 | RTL_GIGA_MAC_VER_06, |
107 | RTL_GIGA_MAC_VER_06 = 0x06, // 8110SCe | 107 | RTL_GIGA_MAC_VER_07, |
108 | RTL_GIGA_MAC_VER_07 = 0x07, // 8102e | 108 | RTL_GIGA_MAC_VER_08, |
109 | RTL_GIGA_MAC_VER_08 = 0x08, // 8102e | 109 | RTL_GIGA_MAC_VER_09, |
110 | RTL_GIGA_MAC_VER_09 = 0x09, // 8102e | 110 | RTL_GIGA_MAC_VER_10, |
111 | RTL_GIGA_MAC_VER_10 = 0x0a, // 8101e | 111 | RTL_GIGA_MAC_VER_11, |
112 | RTL_GIGA_MAC_VER_11 = 0x0b, // 8168Bb | 112 | RTL_GIGA_MAC_VER_12, |
113 | RTL_GIGA_MAC_VER_12 = 0x0c, // 8168Be | 113 | RTL_GIGA_MAC_VER_13, |
114 | RTL_GIGA_MAC_VER_13 = 0x0d, // 8101Eb | 114 | RTL_GIGA_MAC_VER_14, |
115 | RTL_GIGA_MAC_VER_14 = 0x0e, // 8101 ? | 115 | RTL_GIGA_MAC_VER_15, |
116 | RTL_GIGA_MAC_VER_15 = 0x0f, // 8101 ? | 116 | RTL_GIGA_MAC_VER_16, |
117 | RTL_GIGA_MAC_VER_16 = 0x11, // 8101Ec | 117 | RTL_GIGA_MAC_VER_17, |
118 | RTL_GIGA_MAC_VER_17 = 0x10, // 8168Bf | 118 | RTL_GIGA_MAC_VER_18, |
119 | RTL_GIGA_MAC_VER_18 = 0x12, // 8168CP | 119 | RTL_GIGA_MAC_VER_19, |
120 | RTL_GIGA_MAC_VER_19 = 0x13, // 8168C | 120 | RTL_GIGA_MAC_VER_20, |
121 | RTL_GIGA_MAC_VER_20 = 0x14, // 8168C | 121 | RTL_GIGA_MAC_VER_21, |
122 | RTL_GIGA_MAC_VER_21 = 0x15, // 8168C | 122 | RTL_GIGA_MAC_VER_22, |
123 | RTL_GIGA_MAC_VER_22 = 0x16, // 8168C | 123 | RTL_GIGA_MAC_VER_23, |
124 | RTL_GIGA_MAC_VER_23 = 0x17, // 8168CP | 124 | RTL_GIGA_MAC_VER_24, |
125 | RTL_GIGA_MAC_VER_24 = 0x18, // 8168CP | 125 | RTL_GIGA_MAC_VER_25, |
126 | RTL_GIGA_MAC_VER_25 = 0x19, // 8168D | 126 | RTL_GIGA_MAC_VER_26, |
127 | RTL_GIGA_MAC_VER_26 = 0x1a, // 8168D | 127 | RTL_GIGA_MAC_VER_27, |
128 | RTL_GIGA_MAC_VER_27 = 0x1b, // 8168DP | 128 | RTL_GIGA_MAC_VER_28, |
129 | RTL_GIGA_MAC_VER_28 = 0x1c, // 8168DP | 129 | RTL_GIGA_MAC_VER_29, |
130 | RTL_GIGA_MAC_VER_29 = 0x1d, // 8105E | 130 | RTL_GIGA_MAC_VER_30, |
131 | RTL_GIGA_MAC_VER_30 = 0x1e, // 8105E | 131 | RTL_GIGA_MAC_VER_31, |
132 | RTL_GIGA_MAC_VER_31 = 0x1f, // 8168DP | 132 | RTL_GIGA_MAC_VER_32, |
133 | RTL_GIGA_MAC_VER_32 = 0x20, // 8168E | 133 | RTL_GIGA_MAC_VER_33, |
134 | RTL_GIGA_MAC_VER_33 = 0x21, // 8168E | 134 | RTL_GIGA_MAC_NONE = 0xff, |
135 | }; | 135 | }; |
136 | 136 | ||
137 | enum rtl_tx_desc_version { | 137 | enum rtl_tx_desc_version { |
@@ -139,61 +139,84 @@ enum rtl_tx_desc_version { | |||
139 | RTL_TD_1 = 1, | 139 | RTL_TD_1 = 1, |
140 | }; | 140 | }; |
141 | 141 | ||
142 | #define _R(NAME,MAC,TD) \ | 142 | #define _R(NAME,TD,FW) \ |
143 | { .name = NAME, .mac_version = MAC, .txd_version = TD } | 143 | { .name = NAME, .txd_version = TD, .fw_name = FW } |
144 | 144 | ||
145 | static const struct { | 145 | static const struct { |
146 | const char *name; | 146 | const char *name; |
147 | u8 mac_version; | ||
148 | enum rtl_tx_desc_version txd_version; | 147 | enum rtl_tx_desc_version txd_version; |
149 | } rtl_chip_info[] = { | ||
150 | _R("RTL8169", RTL_GIGA_MAC_VER_01, RTL_TD_0), // 8169 | ||
151 | _R("RTL8169s", RTL_GIGA_MAC_VER_02, RTL_TD_0), // 8169S | ||
152 | _R("RTL8110s", RTL_GIGA_MAC_VER_03, RTL_TD_0), // 8110S | ||
153 | _R("RTL8169sb/8110sb", RTL_GIGA_MAC_VER_04, RTL_TD_0), // 8169SB | ||
154 | _R("RTL8169sc/8110sc", RTL_GIGA_MAC_VER_05, RTL_TD_0), // 8110SCd | ||
155 | _R("RTL8169sc/8110sc", RTL_GIGA_MAC_VER_06, RTL_TD_0), // 8110SCe | ||
156 | _R("RTL8102e", RTL_GIGA_MAC_VER_07, RTL_TD_1), // PCI-E | ||
157 | _R("RTL8102e", RTL_GIGA_MAC_VER_08, RTL_TD_1), // PCI-E | ||
158 | _R("RTL8102e", RTL_GIGA_MAC_VER_09, RTL_TD_1), // PCI-E | ||
159 | _R("RTL8101e", RTL_GIGA_MAC_VER_10, RTL_TD_0), // PCI-E | ||
160 | _R("RTL8168b/8111b", RTL_GIGA_MAC_VER_11, RTL_TD_0), // PCI-E | ||
161 | _R("RTL8168b/8111b", RTL_GIGA_MAC_VER_12, RTL_TD_0), // PCI-E | ||
162 | _R("RTL8101e", RTL_GIGA_MAC_VER_13, RTL_TD_0), // PCI-E 8139 | ||
163 | _R("RTL8100e", RTL_GIGA_MAC_VER_14, RTL_TD_0), // PCI-E 8139 | ||
164 | _R("RTL8100e", RTL_GIGA_MAC_VER_15, RTL_TD_0), // PCI-E 8139 | ||
165 | _R("RTL8168b/8111b", RTL_GIGA_MAC_VER_17, RTL_TD_0), // PCI-E | ||
166 | _R("RTL8101e", RTL_GIGA_MAC_VER_16, RTL_TD_0), // PCI-E | ||
167 | _R("RTL8168cp/8111cp", RTL_GIGA_MAC_VER_18, RTL_TD_1), // PCI-E | ||
168 | _R("RTL8168c/8111c", RTL_GIGA_MAC_VER_19, RTL_TD_1), // PCI-E | ||
169 | _R("RTL8168c/8111c", RTL_GIGA_MAC_VER_20, RTL_TD_1), // PCI-E | ||
170 | _R("RTL8168c/8111c", RTL_GIGA_MAC_VER_21, RTL_TD_1), // PCI-E | ||
171 | _R("RTL8168c/8111c", RTL_GIGA_MAC_VER_22, RTL_TD_1), // PCI-E | ||
172 | _R("RTL8168cp/8111cp", RTL_GIGA_MAC_VER_23, RTL_TD_1), // PCI-E | ||
173 | _R("RTL8168cp/8111cp", RTL_GIGA_MAC_VER_24, RTL_TD_1), // PCI-E | ||
174 | _R("RTL8168d/8111d", RTL_GIGA_MAC_VER_25, RTL_TD_1), // PCI-E | ||
175 | _R("RTL8168d/8111d", RTL_GIGA_MAC_VER_26, RTL_TD_1), // PCI-E | ||
176 | _R("RTL8168dp/8111dp", RTL_GIGA_MAC_VER_27, RTL_TD_1), // PCI-E | ||
177 | _R("RTL8168dp/8111dp", RTL_GIGA_MAC_VER_28, RTL_TD_1), // PCI-E | ||
178 | _R("RTL8105e", RTL_GIGA_MAC_VER_29, RTL_TD_1), // PCI-E | ||
179 | _R("RTL8105e", RTL_GIGA_MAC_VER_30, RTL_TD_1), // PCI-E | ||
180 | _R("RTL8168dp/8111dp", RTL_GIGA_MAC_VER_31, RTL_TD_1), // PCI-E | ||
181 | _R("RTL8168e/8111e", RTL_GIGA_MAC_VER_32, RTL_TD_1), // PCI-E | ||
182 | _R("RTL8168e/8111e", RTL_GIGA_MAC_VER_33, RTL_TD_1) // PCI-E | ||
183 | }; | ||
184 | #undef _R | ||
185 | |||
186 | static const struct rtl_firmware_info { | ||
187 | int mac_version; | ||
188 | const char *fw_name; | 148 | const char *fw_name; |
189 | } rtl_firmware_infos[] = { | 149 | } rtl_chip_infos[] = { |
190 | { .mac_version = RTL_GIGA_MAC_VER_25, .fw_name = FIRMWARE_8168D_1 }, | 150 | /* PCI devices. */ |
191 | { .mac_version = RTL_GIGA_MAC_VER_26, .fw_name = FIRMWARE_8168D_2 }, | 151 | [RTL_GIGA_MAC_VER_01] = |
192 | { .mac_version = RTL_GIGA_MAC_VER_29, .fw_name = FIRMWARE_8105E_1 }, | 152 | _R("RTL8169", RTL_TD_0, NULL), |
193 | { .mac_version = RTL_GIGA_MAC_VER_30, .fw_name = FIRMWARE_8105E_1 }, | 153 | [RTL_GIGA_MAC_VER_02] = |
194 | { .mac_version = RTL_GIGA_MAC_VER_32, .fw_name = FIRMWARE_8168E_1 }, | 154 | _R("RTL8169s", RTL_TD_0, NULL), |
195 | { .mac_version = RTL_GIGA_MAC_VER_33, .fw_name = FIRMWARE_8168E_2 } | 155 | [RTL_GIGA_MAC_VER_03] = |
156 | _R("RTL8110s", RTL_TD_0, NULL), | ||
157 | [RTL_GIGA_MAC_VER_04] = | ||
158 | _R("RTL8169sb/8110sb", RTL_TD_0, NULL), | ||
159 | [RTL_GIGA_MAC_VER_05] = | ||
160 | _R("RTL8169sc/8110sc", RTL_TD_0, NULL), | ||
161 | [RTL_GIGA_MAC_VER_06] = | ||
162 | _R("RTL8169sc/8110sc", RTL_TD_0, NULL), | ||
163 | /* PCI-E devices. */ | ||
164 | [RTL_GIGA_MAC_VER_07] = | ||
165 | _R("RTL8102e", RTL_TD_1, NULL), | ||
166 | [RTL_GIGA_MAC_VER_08] = | ||
167 | _R("RTL8102e", RTL_TD_1, NULL), | ||
168 | [RTL_GIGA_MAC_VER_09] = | ||
169 | _R("RTL8102e", RTL_TD_1, NULL), | ||
170 | [RTL_GIGA_MAC_VER_10] = | ||
171 | _R("RTL8101e", RTL_TD_0, NULL), | ||
172 | [RTL_GIGA_MAC_VER_11] = | ||
173 | _R("RTL8168b/8111b", RTL_TD_0, NULL), | ||
174 | [RTL_GIGA_MAC_VER_12] = | ||
175 | _R("RTL8168b/8111b", RTL_TD_0, NULL), | ||
176 | [RTL_GIGA_MAC_VER_13] = | ||
177 | _R("RTL8101e", RTL_TD_0, NULL), | ||
178 | [RTL_GIGA_MAC_VER_14] = | ||
179 | _R("RTL8100e", RTL_TD_0, NULL), | ||
180 | [RTL_GIGA_MAC_VER_15] = | ||
181 | _R("RTL8100e", RTL_TD_0, NULL), | ||
182 | [RTL_GIGA_MAC_VER_16] = | ||
183 | _R("RTL8101e", RTL_TD_0, NULL), | ||
184 | [RTL_GIGA_MAC_VER_17] = | ||
185 | _R("RTL8168b/8111b", RTL_TD_0, NULL), | ||
186 | [RTL_GIGA_MAC_VER_18] = | ||
187 | _R("RTL8168cp/8111cp", RTL_TD_1, NULL), | ||
188 | [RTL_GIGA_MAC_VER_19] = | ||
189 | _R("RTL8168c/8111c", RTL_TD_1, NULL), | ||
190 | [RTL_GIGA_MAC_VER_20] = | ||
191 | _R("RTL8168c/8111c", RTL_TD_1, NULL), | ||
192 | [RTL_GIGA_MAC_VER_21] = | ||
193 | _R("RTL8168c/8111c", RTL_TD_1, NULL), | ||
194 | [RTL_GIGA_MAC_VER_22] = | ||
195 | _R("RTL8168c/8111c", RTL_TD_1, NULL), | ||
196 | [RTL_GIGA_MAC_VER_23] = | ||
197 | _R("RTL8168cp/8111cp", RTL_TD_1, NULL), | ||
198 | [RTL_GIGA_MAC_VER_24] = | ||
199 | _R("RTL8168cp/8111cp", RTL_TD_1, NULL), | ||
200 | [RTL_GIGA_MAC_VER_25] = | ||
201 | _R("RTL8168d/8111d", RTL_TD_1, FIRMWARE_8168D_1), | ||
202 | [RTL_GIGA_MAC_VER_26] = | ||
203 | _R("RTL8168d/8111d", RTL_TD_1, FIRMWARE_8168D_2), | ||
204 | [RTL_GIGA_MAC_VER_27] = | ||
205 | _R("RTL8168dp/8111dp", RTL_TD_1, NULL), | ||
206 | [RTL_GIGA_MAC_VER_28] = | ||
207 | _R("RTL8168dp/8111dp", RTL_TD_1, NULL), | ||
208 | [RTL_GIGA_MAC_VER_29] = | ||
209 | _R("RTL8105e", RTL_TD_1, FIRMWARE_8105E_1), | ||
210 | [RTL_GIGA_MAC_VER_30] = | ||
211 | _R("RTL8105e", RTL_TD_1, FIRMWARE_8105E_1), | ||
212 | [RTL_GIGA_MAC_VER_31] = | ||
213 | _R("RTL8168dp/8111dp", RTL_TD_1, NULL), | ||
214 | [RTL_GIGA_MAC_VER_32] = | ||
215 | _R("RTL8168e/8111e", RTL_TD_1, FIRMWARE_8168E_1), | ||
216 | [RTL_GIGA_MAC_VER_33] = | ||
217 | _R("RTL8168e/8111e", RTL_TD_1, FIRMWARE_8168E_2) | ||
196 | }; | 218 | }; |
219 | #undef _R | ||
197 | 220 | ||
198 | enum cfg_version { | 221 | enum cfg_version { |
199 | RTL_CFG_0 = 0x00, | 222 | RTL_CFG_0 = 0x00, |
@@ -345,7 +368,7 @@ enum rtl8168_registers { | |||
345 | #define OCPAR_GPHY_READ_CMD 0x0000f060 | 368 | #define OCPAR_GPHY_READ_CMD 0x0000f060 |
346 | RDSAR1 = 0xd0, /* 8168c only. Undocumented on 8168dp */ | 369 | RDSAR1 = 0xd0, /* 8168c only. Undocumented on 8168dp */ |
347 | MISC = 0xf0, /* 8168e only. */ | 370 | MISC = 0xf0, /* 8168e only. */ |
348 | txpla_rst = (1 << 29) | 371 | #define TXPLA_RST (1 << 29) |
349 | }; | 372 | }; |
350 | 373 | ||
351 | enum rtl_register_content { | 374 | enum rtl_register_content { |
@@ -423,7 +446,7 @@ enum rtl_register_content { | |||
423 | BWF = (1 << 6), /* Accept Broadcast wakeup frame */ | 446 | BWF = (1 << 6), /* Accept Broadcast wakeup frame */ |
424 | MWF = (1 << 5), /* Accept Multicast wakeup frame */ | 447 | MWF = (1 << 5), /* Accept Multicast wakeup frame */ |
425 | UWF = (1 << 4), /* Accept Unicast wakeup frame */ | 448 | UWF = (1 << 4), /* Accept Unicast wakeup frame */ |
426 | spi_en = (1 << 3), | 449 | Spi_en = (1 << 3), |
427 | LanWake = (1 << 1), /* LanWake enable/disable */ | 450 | LanWake = (1 << 1), /* LanWake enable/disable */ |
428 | PMEStatus = (1 << 0), /* PME status can be reset by PCI RST# */ | 451 | PMEStatus = (1 << 0), /* PME status can be reset by PCI RST# */ |
429 | 452 | ||
@@ -594,10 +617,10 @@ struct rtl8169_counters { | |||
594 | 617 | ||
595 | struct rtl8169_private { | 618 | struct rtl8169_private { |
596 | void __iomem *mmio_addr; /* memory map physical address */ | 619 | void __iomem *mmio_addr; /* memory map physical address */ |
597 | struct pci_dev *pci_dev; /* Index of PCI device */ | 620 | struct pci_dev *pci_dev; |
598 | struct net_device *dev; | 621 | struct net_device *dev; |
599 | struct napi_struct napi; | 622 | struct napi_struct napi; |
600 | spinlock_t lock; /* spin lock flag */ | 623 | spinlock_t lock; |
601 | u32 msg_enable; | 624 | u32 msg_enable; |
602 | u16 txd_version; | 625 | u16 txd_version; |
603 | u16 mac_version; | 626 | u16 mac_version; |
@@ -616,7 +639,6 @@ struct rtl8169_private { | |||
616 | u16 intr_event; | 639 | u16 intr_event; |
617 | u16 napi_event; | 640 | u16 napi_event; |
618 | u16 intr_mask; | 641 | u16 intr_mask; |
619 | int phy_1000_ctrl_reg; | ||
620 | 642 | ||
621 | struct mdio_ops { | 643 | struct mdio_ops { |
622 | void (*write)(void __iomem *, int, int); | 644 | void (*write)(void __iomem *, int, int); |
@@ -730,17 +752,19 @@ static void rtl8168_oob_notify(struct rtl8169_private *tp, u8 cmd) | |||
730 | #define OOB_CMD_DRIVER_START 0x05 | 752 | #define OOB_CMD_DRIVER_START 0x05 |
731 | #define OOB_CMD_DRIVER_STOP 0x06 | 753 | #define OOB_CMD_DRIVER_STOP 0x06 |
732 | 754 | ||
755 | static u16 rtl8168_get_ocp_reg(struct rtl8169_private *tp) | ||
756 | { | ||
757 | return (tp->mac_version == RTL_GIGA_MAC_VER_31) ? 0xb8 : 0x10; | ||
758 | } | ||
759 | |||
733 | static void rtl8168_driver_start(struct rtl8169_private *tp) | 760 | static void rtl8168_driver_start(struct rtl8169_private *tp) |
734 | { | 761 | { |
762 | u16 reg; | ||
735 | int i; | 763 | int i; |
736 | u32 reg; | ||
737 | 764 | ||
738 | rtl8168_oob_notify(tp, OOB_CMD_DRIVER_START); | 765 | rtl8168_oob_notify(tp, OOB_CMD_DRIVER_START); |
739 | 766 | ||
740 | if (tp->mac_version == RTL_GIGA_MAC_VER_31) | 767 | reg = rtl8168_get_ocp_reg(tp); |
741 | reg = 0xb8; | ||
742 | else | ||
743 | reg = 0x10; | ||
744 | 768 | ||
745 | for (i = 0; i < 10; i++) { | 769 | for (i = 0; i < 10; i++) { |
746 | msleep(10); | 770 | msleep(10); |
@@ -751,15 +775,12 @@ static void rtl8168_driver_start(struct rtl8169_private *tp) | |||
751 | 775 | ||
752 | static void rtl8168_driver_stop(struct rtl8169_private *tp) | 776 | static void rtl8168_driver_stop(struct rtl8169_private *tp) |
753 | { | 777 | { |
778 | u16 reg; | ||
754 | int i; | 779 | int i; |
755 | u32 reg; | ||
756 | 780 | ||
757 | rtl8168_oob_notify(tp, OOB_CMD_DRIVER_STOP); | 781 | rtl8168_oob_notify(tp, OOB_CMD_DRIVER_STOP); |
758 | 782 | ||
759 | if (tp->mac_version == RTL_GIGA_MAC_VER_31) | 783 | reg = rtl8168_get_ocp_reg(tp); |
760 | reg = 0xb8; | ||
761 | else | ||
762 | reg = 0x10; | ||
763 | 784 | ||
764 | for (i = 0; i < 10; i++) { | 785 | for (i = 0; i < 10; i++) { |
765 | msleep(10); | 786 | msleep(10); |
@@ -770,17 +791,9 @@ static void rtl8168_driver_stop(struct rtl8169_private *tp) | |||
770 | 791 | ||
771 | static int r8168dp_check_dash(struct rtl8169_private *tp) | 792 | static int r8168dp_check_dash(struct rtl8169_private *tp) |
772 | { | 793 | { |
773 | u32 reg; | 794 | u16 reg = rtl8168_get_ocp_reg(tp); |
774 | |||
775 | if (tp->mac_version == RTL_GIGA_MAC_VER_31) | ||
776 | reg = 0xb8; | ||
777 | else | ||
778 | reg = 0x10; | ||
779 | 795 | ||
780 | if (ocp_read(tp, 0xF, reg) & 0x00008000) | 796 | return (ocp_read(tp, 0x0f, reg) & 0x00008000) ? 1 : 0; |
781 | return 1; | ||
782 | else | ||
783 | return 0; | ||
784 | } | 797 | } |
785 | 798 | ||
786 | static void r8169_mdio_write(void __iomem *ioaddr, int reg_addr, int value) | 799 | static void r8169_mdio_write(void __iomem *ioaddr, int reg_addr, int value) |
@@ -1080,9 +1093,8 @@ static void rtl8169_xmii_reset_enable(struct rtl8169_private *tp) | |||
1080 | } | 1093 | } |
1081 | 1094 | ||
1082 | static void __rtl8169_check_link_status(struct net_device *dev, | 1095 | static void __rtl8169_check_link_status(struct net_device *dev, |
1083 | struct rtl8169_private *tp, | 1096 | struct rtl8169_private *tp, |
1084 | void __iomem *ioaddr, | 1097 | void __iomem *ioaddr, bool pm) |
1085 | bool pm) | ||
1086 | { | 1098 | { |
1087 | unsigned long flags; | 1099 | unsigned long flags; |
1088 | 1100 | ||
@@ -1199,6 +1211,11 @@ static int rtl8169_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol) | |||
1199 | return 0; | 1211 | return 0; |
1200 | } | 1212 | } |
1201 | 1213 | ||
1214 | static const char *rtl_lookup_firmware_name(struct rtl8169_private *tp) | ||
1215 | { | ||
1216 | return rtl_chip_infos[tp->mac_version].fw_name; | ||
1217 | } | ||
1218 | |||
1202 | static void rtl8169_get_drvinfo(struct net_device *dev, | 1219 | static void rtl8169_get_drvinfo(struct net_device *dev, |
1203 | struct ethtool_drvinfo *info) | 1220 | struct ethtool_drvinfo *info) |
1204 | { | 1221 | { |
@@ -1207,6 +1224,8 @@ static void rtl8169_get_drvinfo(struct net_device *dev, | |||
1207 | strcpy(info->driver, MODULENAME); | 1224 | strcpy(info->driver, MODULENAME); |
1208 | strcpy(info->version, RTL8169_VERSION); | 1225 | strcpy(info->version, RTL8169_VERSION); |
1209 | strcpy(info->bus_info, pci_name(tp->pci_dev)); | 1226 | strcpy(info->bus_info, pci_name(tp->pci_dev)); |
1227 | strncpy(info->fw_version, IS_ERR_OR_NULL(tp->fw) ? "N/A" : | ||
1228 | rtl_lookup_firmware_name(tp), sizeof(info->fw_version) - 1); | ||
1210 | } | 1229 | } |
1211 | 1230 | ||
1212 | static int rtl8169_get_regs_len(struct net_device *dev) | 1231 | static int rtl8169_get_regs_len(struct net_device *dev) |
@@ -1268,16 +1287,7 @@ static int rtl8169_set_speed_xmii(struct net_device *dev, | |||
1268 | giga_ctrl &= ~(ADVERTISE_1000FULL | ADVERTISE_1000HALF); | 1287 | giga_ctrl &= ~(ADVERTISE_1000FULL | ADVERTISE_1000HALF); |
1269 | 1288 | ||
1270 | /* The 8100e/8101e/8102e do Fast Ethernet only. */ | 1289 | /* The 8100e/8101e/8102e do Fast Ethernet only. */ |
1271 | if ((tp->mac_version != RTL_GIGA_MAC_VER_07) && | 1290 | if (tp->mii.supports_gmii) { |
1272 | (tp->mac_version != RTL_GIGA_MAC_VER_08) && | ||
1273 | (tp->mac_version != RTL_GIGA_MAC_VER_09) && | ||
1274 | (tp->mac_version != RTL_GIGA_MAC_VER_10) && | ||
1275 | (tp->mac_version != RTL_GIGA_MAC_VER_13) && | ||
1276 | (tp->mac_version != RTL_GIGA_MAC_VER_14) && | ||
1277 | (tp->mac_version != RTL_GIGA_MAC_VER_15) && | ||
1278 | (tp->mac_version != RTL_GIGA_MAC_VER_16) && | ||
1279 | (tp->mac_version != RTL_GIGA_MAC_VER_29) && | ||
1280 | (tp->mac_version != RTL_GIGA_MAC_VER_30)) { | ||
1281 | if (adv & ADVERTISED_1000baseT_Half) | 1291 | if (adv & ADVERTISED_1000baseT_Half) |
1282 | giga_ctrl |= ADVERTISE_1000HALF; | 1292 | giga_ctrl |= ADVERTISE_1000HALF; |
1283 | if (adv & ADVERTISED_1000baseT_Full) | 1293 | if (adv & ADVERTISED_1000baseT_Full) |
@@ -1307,12 +1317,10 @@ static int rtl8169_set_speed_xmii(struct net_device *dev, | |||
1307 | bmcr |= BMCR_FULLDPLX; | 1317 | bmcr |= BMCR_FULLDPLX; |
1308 | } | 1318 | } |
1309 | 1319 | ||
1310 | tp->phy_1000_ctrl_reg = giga_ctrl; | ||
1311 | |||
1312 | rtl_writephy(tp, MII_BMCR, bmcr); | 1320 | rtl_writephy(tp, MII_BMCR, bmcr); |
1313 | 1321 | ||
1314 | if ((tp->mac_version == RTL_GIGA_MAC_VER_02) || | 1322 | if (tp->mac_version == RTL_GIGA_MAC_VER_02 || |
1315 | (tp->mac_version == RTL_GIGA_MAC_VER_03)) { | 1323 | tp->mac_version == RTL_GIGA_MAC_VER_03) { |
1316 | if ((speed == SPEED_100) && (autoneg != AUTONEG_ENABLE)) { | 1324 | if ((speed == SPEED_100) && (autoneg != AUTONEG_ENABLE)) { |
1317 | rtl_writephy(tp, 0x17, 0x2138); | 1325 | rtl_writephy(tp, 0x17, 0x2138); |
1318 | rtl_writephy(tp, 0x0e, 0x0260); | 1326 | rtl_writephy(tp, 0x0e, 0x0260); |
@@ -1334,10 +1342,14 @@ static int rtl8169_set_speed(struct net_device *dev, | |||
1334 | int ret; | 1342 | int ret; |
1335 | 1343 | ||
1336 | ret = tp->set_speed(dev, autoneg, speed, duplex, advertising); | 1344 | ret = tp->set_speed(dev, autoneg, speed, duplex, advertising); |
1345 | if (ret < 0) | ||
1346 | goto out; | ||
1337 | 1347 | ||
1338 | if (netif_running(dev) && (tp->phy_1000_ctrl_reg & ADVERTISE_1000FULL)) | 1348 | if (netif_running(dev) && (autoneg == AUTONEG_ENABLE) && |
1349 | (advertising & ADVERTISED_1000baseT_Full)) { | ||
1339 | mod_timer(&tp->timer, jiffies + RTL8169_PHY_TIMEOUT); | 1350 | mod_timer(&tp->timer, jiffies + RTL8169_PHY_TIMEOUT); |
1340 | 1351 | } | |
1352 | out: | ||
1341 | return ret; | 1353 | return ret; |
1342 | } | 1354 | } |
1343 | 1355 | ||
@@ -1347,9 +1359,10 @@ static int rtl8169_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
1347 | unsigned long flags; | 1359 | unsigned long flags; |
1348 | int ret; | 1360 | int ret; |
1349 | 1361 | ||
1362 | del_timer_sync(&tp->timer); | ||
1363 | |||
1350 | spin_lock_irqsave(&tp->lock, flags); | 1364 | spin_lock_irqsave(&tp->lock, flags); |
1351 | ret = rtl8169_set_speed(dev, | 1365 | ret = rtl8169_set_speed(dev, cmd->autoneg, ethtool_cmd_speed(cmd), |
1352 | cmd->autoneg, ethtool_cmd_speed(cmd), | ||
1353 | cmd->duplex, cmd->advertising); | 1366 | cmd->duplex, cmd->advertising); |
1354 | spin_unlock_irqrestore(&tp->lock, flags); | 1367 | spin_unlock_irqrestore(&tp->lock, flags); |
1355 | 1368 | ||
@@ -1507,11 +1520,11 @@ static void rtl8169_update_counters(struct net_device *dev) | |||
1507 | { | 1520 | { |
1508 | struct rtl8169_private *tp = netdev_priv(dev); | 1521 | struct rtl8169_private *tp = netdev_priv(dev); |
1509 | void __iomem *ioaddr = tp->mmio_addr; | 1522 | void __iomem *ioaddr = tp->mmio_addr; |
1523 | struct device *d = &tp->pci_dev->dev; | ||
1510 | struct rtl8169_counters *counters; | 1524 | struct rtl8169_counters *counters; |
1511 | dma_addr_t paddr; | 1525 | dma_addr_t paddr; |
1512 | u32 cmd; | 1526 | u32 cmd; |
1513 | int wait = 1000; | 1527 | int wait = 1000; |
1514 | struct device *d = &tp->pci_dev->dev; | ||
1515 | 1528 | ||
1516 | /* | 1529 | /* |
1517 | * Some chips are unable to dump tally counters when the receiver | 1530 | * Some chips are unable to dump tally counters when the receiver |
@@ -1531,7 +1544,6 @@ static void rtl8169_update_counters(struct net_device *dev) | |||
1531 | 1544 | ||
1532 | while (wait--) { | 1545 | while (wait--) { |
1533 | if ((RTL_R32(CounterAddrLow) & CounterDump) == 0) { | 1546 | if ((RTL_R32(CounterAddrLow) & CounterDump) == 0) { |
1534 | /* copy updated counters */ | ||
1535 | memcpy(&tp->counters, counters, sizeof(*counters)); | 1547 | memcpy(&tp->counters, counters, sizeof(*counters)); |
1536 | break; | 1548 | break; |
1537 | } | 1549 | } |
@@ -1594,8 +1606,9 @@ static const struct ethtool_ops rtl8169_ethtool_ops = { | |||
1594 | }; | 1606 | }; |
1595 | 1607 | ||
1596 | static void rtl8169_get_mac_version(struct rtl8169_private *tp, | 1608 | static void rtl8169_get_mac_version(struct rtl8169_private *tp, |
1597 | void __iomem *ioaddr) | 1609 | struct net_device *dev, u8 default_version) |
1598 | { | 1610 | { |
1611 | void __iomem *ioaddr = tp->mmio_addr; | ||
1599 | /* | 1612 | /* |
1600 | * The driver currently handles the 8168Bf and the 8168Be identically | 1613 | * The driver currently handles the 8168Bf and the 8168Be identically |
1601 | * but they can be identified more specifically through the test below | 1614 | * but they can be identified more specifically through the test below |
@@ -1682,6 +1695,12 @@ static void rtl8169_get_mac_version(struct rtl8169_private *tp, | |||
1682 | while ((reg & p->mask) != p->val) | 1695 | while ((reg & p->mask) != p->val) |
1683 | p++; | 1696 | p++; |
1684 | tp->mac_version = p->mac_version; | 1697 | tp->mac_version = p->mac_version; |
1698 | |||
1699 | if (tp->mac_version == RTL_GIGA_MAC_NONE) { | ||
1700 | netif_notice(tp, probe, dev, | ||
1701 | "unknown MAC, using family default\n"); | ||
1702 | tp->mac_version = default_version; | ||
1703 | } | ||
1685 | } | 1704 | } |
1686 | 1705 | ||
1687 | static void rtl8169_print_mac_version(struct rtl8169_private *tp) | 1706 | static void rtl8169_print_mac_version(struct rtl8169_private *tp) |
@@ -1751,14 +1770,14 @@ rtl_phy_write_fw(struct rtl8169_private *tp, const struct firmware *fw) | |||
1751 | case PHY_BJMPN: | 1770 | case PHY_BJMPN: |
1752 | if (regno > index) { | 1771 | if (regno > index) { |
1753 | netif_err(tp, probe, tp->dev, | 1772 | netif_err(tp, probe, tp->dev, |
1754 | "Out of range of firmware\n"); | 1773 | "Out of range of firmware\n"); |
1755 | return; | 1774 | return; |
1756 | } | 1775 | } |
1757 | break; | 1776 | break; |
1758 | case PHY_READCOUNT_EQ_SKIP: | 1777 | case PHY_READCOUNT_EQ_SKIP: |
1759 | if (index + 2 >= fw_size) { | 1778 | if (index + 2 >= fw_size) { |
1760 | netif_err(tp, probe, tp->dev, | 1779 | netif_err(tp, probe, tp->dev, |
1761 | "Out of range of firmware\n"); | 1780 | "Out of range of firmware\n"); |
1762 | return; | 1781 | return; |
1763 | } | 1782 | } |
1764 | break; | 1783 | break; |
@@ -1767,7 +1786,7 @@ rtl_phy_write_fw(struct rtl8169_private *tp, const struct firmware *fw) | |||
1767 | case PHY_SKIPN: | 1786 | case PHY_SKIPN: |
1768 | if (index + 1 + regno >= fw_size) { | 1787 | if (index + 1 + regno >= fw_size) { |
1769 | netif_err(tp, probe, tp->dev, | 1788 | netif_err(tp, probe, tp->dev, |
1770 | "Out of range of firmware\n"); | 1789 | "Out of range of firmware\n"); |
1771 | return; | 1790 | return; |
1772 | } | 1791 | } |
1773 | break; | 1792 | break; |
@@ -1823,10 +1842,7 @@ rtl_phy_write_fw(struct rtl8169_private *tp, const struct firmware *fw) | |||
1823 | index++; | 1842 | index++; |
1824 | break; | 1843 | break; |
1825 | case PHY_READCOUNT_EQ_SKIP: | 1844 | case PHY_READCOUNT_EQ_SKIP: |
1826 | if (count == data) | 1845 | index += (count == data) ? 2 : 1; |
1827 | index += 2; | ||
1828 | else | ||
1829 | index += 1; | ||
1830 | break; | 1846 | break; |
1831 | case PHY_COMP_EQ_SKIPN: | 1847 | case PHY_COMP_EQ_SKIPN: |
1832 | if (predata == data) | 1848 | if (predata == data) |
@@ -2237,7 +2253,7 @@ static void rtl8168d_1_hw_phy_config(struct rtl8169_private *tp) | |||
2237 | 2253 | ||
2238 | /* | 2254 | /* |
2239 | * Tx Error Issue | 2255 | * Tx Error Issue |
2240 | * enhance line driver power | 2256 | * Enhance line driver power |
2241 | */ | 2257 | */ |
2242 | { 0x1f, 0x0002 }, | 2258 | { 0x1f, 0x0002 }, |
2243 | { 0x06, 0x5561 }, | 2259 | { 0x06, 0x5561 }, |
@@ -2349,7 +2365,7 @@ static void rtl8168d_2_hw_phy_config(struct rtl8169_private *tp) | |||
2349 | 2365 | ||
2350 | /* | 2366 | /* |
2351 | * Tx Error Issue | 2367 | * Tx Error Issue |
2352 | * enhance line driver power | 2368 | * Enhance line driver power |
2353 | */ | 2369 | */ |
2354 | { 0x1f, 0x0002 }, | 2370 | { 0x1f, 0x0002 }, |
2355 | { 0x06, 0x5561 }, | 2371 | { 0x06, 0x5561 }, |
@@ -2548,7 +2564,7 @@ static void rtl8168e_hw_phy_config(struct rtl8169_private *tp) | |||
2548 | /* For impedance matching */ | 2564 | /* For impedance matching */ |
2549 | rtl_writephy(tp, 0x1f, 0x0002); | 2565 | rtl_writephy(tp, 0x1f, 0x0002); |
2550 | rtl_w1w0_phy(tp, 0x08, 0x8000, 0x7f00); | 2566 | rtl_w1w0_phy(tp, 0x08, 0x8000, 0x7f00); |
2551 | rtl_writephy(tp, 0x1F, 0x0000); | 2567 | rtl_writephy(tp, 0x1f, 0x0000); |
2552 | 2568 | ||
2553 | /* PHY auto speed down */ | 2569 | /* PHY auto speed down */ |
2554 | rtl_writephy(tp, 0x1f, 0x0007); | 2570 | rtl_writephy(tp, 0x1f, 0x0007); |
@@ -2692,6 +2708,9 @@ static void rtl_hw_phy_config(struct net_device *dev) | |||
2692 | case RTL_GIGA_MAC_VER_30: | 2708 | case RTL_GIGA_MAC_VER_30: |
2693 | rtl8105e_hw_phy_config(tp); | 2709 | rtl8105e_hw_phy_config(tp); |
2694 | break; | 2710 | break; |
2711 | case RTL_GIGA_MAC_VER_31: | ||
2712 | /* None. */ | ||
2713 | break; | ||
2695 | case RTL_GIGA_MAC_VER_32: | 2714 | case RTL_GIGA_MAC_VER_32: |
2696 | case RTL_GIGA_MAC_VER_33: | 2715 | case RTL_GIGA_MAC_VER_33: |
2697 | rtl8168e_hw_phy_config(tp); | 2716 | rtl8168e_hw_phy_config(tp); |
@@ -2712,9 +2731,6 @@ static void rtl8169_phy_timer(unsigned long __opaque) | |||
2712 | 2731 | ||
2713 | assert(tp->mac_version > RTL_GIGA_MAC_VER_01); | 2732 | assert(tp->mac_version > RTL_GIGA_MAC_VER_01); |
2714 | 2733 | ||
2715 | if (!(tp->phy_1000_ctrl_reg & ADVERTISE_1000FULL)) | ||
2716 | return; | ||
2717 | |||
2718 | spin_lock_irq(&tp->lock); | 2734 | spin_lock_irq(&tp->lock); |
2719 | 2735 | ||
2720 | if (tp->phy_reset_pending(tp)) { | 2736 | if (tp->phy_reset_pending(tp)) { |
@@ -2739,28 +2755,6 @@ out_unlock: | |||
2739 | spin_unlock_irq(&tp->lock); | 2755 | spin_unlock_irq(&tp->lock); |
2740 | } | 2756 | } |
2741 | 2757 | ||
2742 | static inline void rtl8169_delete_timer(struct net_device *dev) | ||
2743 | { | ||
2744 | struct rtl8169_private *tp = netdev_priv(dev); | ||
2745 | struct timer_list *timer = &tp->timer; | ||
2746 | |||
2747 | if (tp->mac_version <= RTL_GIGA_MAC_VER_01) | ||
2748 | return; | ||
2749 | |||
2750 | del_timer_sync(timer); | ||
2751 | } | ||
2752 | |||
2753 | static inline void rtl8169_request_timer(struct net_device *dev) | ||
2754 | { | ||
2755 | struct rtl8169_private *tp = netdev_priv(dev); | ||
2756 | struct timer_list *timer = &tp->timer; | ||
2757 | |||
2758 | if (tp->mac_version <= RTL_GIGA_MAC_VER_01) | ||
2759 | return; | ||
2760 | |||
2761 | mod_timer(timer, jiffies + RTL8169_PHY_TIMEOUT); | ||
2762 | } | ||
2763 | |||
2764 | #ifdef CONFIG_NET_POLL_CONTROLLER | 2758 | #ifdef CONFIG_NET_POLL_CONTROLLER |
2765 | /* | 2759 | /* |
2766 | * Polling 'interrupt' - used by things like netconsole to send skbs | 2760 | * Polling 'interrupt' - used by things like netconsole to send skbs |
@@ -2828,11 +2822,11 @@ static void rtl8169_init_phy(struct net_device *dev, struct rtl8169_private *tp) | |||
2828 | rtl8169_phy_reset(dev, tp); | 2822 | rtl8169_phy_reset(dev, tp); |
2829 | 2823 | ||
2830 | rtl8169_set_speed(dev, AUTONEG_ENABLE, SPEED_1000, DUPLEX_FULL, | 2824 | rtl8169_set_speed(dev, AUTONEG_ENABLE, SPEED_1000, DUPLEX_FULL, |
2831 | ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full | | 2825 | ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full | |
2832 | ADVERTISED_100baseT_Half | ADVERTISED_100baseT_Full | | 2826 | ADVERTISED_100baseT_Half | ADVERTISED_100baseT_Full | |
2833 | (tp->mii.supports_gmii ? | 2827 | (tp->mii.supports_gmii ? |
2834 | ADVERTISED_1000baseT_Half | | 2828 | ADVERTISED_1000baseT_Half | |
2835 | ADVERTISED_1000baseT_Full : 0)); | 2829 | ADVERTISED_1000baseT_Full : 0)); |
2836 | 2830 | ||
2837 | if (RTL_R8(PHYstatus) & TBI_Enable) | 2831 | if (RTL_R8(PHYstatus) & TBI_Enable) |
2838 | netif_info(tp, link, dev, "TBI auto-negotiating\n"); | 2832 | netif_info(tp, link, dev, "TBI auto-negotiating\n"); |
@@ -2885,7 +2879,8 @@ static int rtl8169_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) | |||
2885 | return netif_running(dev) ? tp->do_ioctl(tp, data, cmd) : -ENODEV; | 2879 | return netif_running(dev) ? tp->do_ioctl(tp, data, cmd) : -ENODEV; |
2886 | } | 2880 | } |
2887 | 2881 | ||
2888 | static int rtl_xmii_ioctl(struct rtl8169_private *tp, struct mii_ioctl_data *data, int cmd) | 2882 | static int rtl_xmii_ioctl(struct rtl8169_private *tp, |
2883 | struct mii_ioctl_data *data, int cmd) | ||
2889 | { | 2884 | { |
2890 | switch (cmd) { | 2885 | switch (cmd) { |
2891 | case SIOCGMIIPHY: | 2886 | case SIOCGMIIPHY: |
@@ -3107,15 +3102,15 @@ static void r8168_pll_power_down(struct rtl8169_private *tp) | |||
3107 | { | 3102 | { |
3108 | void __iomem *ioaddr = tp->mmio_addr; | 3103 | void __iomem *ioaddr = tp->mmio_addr; |
3109 | 3104 | ||
3110 | if (((tp->mac_version == RTL_GIGA_MAC_VER_27) || | 3105 | if ((tp->mac_version == RTL_GIGA_MAC_VER_27 || |
3111 | (tp->mac_version == RTL_GIGA_MAC_VER_28) || | 3106 | tp->mac_version == RTL_GIGA_MAC_VER_28 || |
3112 | (tp->mac_version == RTL_GIGA_MAC_VER_31)) && | 3107 | tp->mac_version == RTL_GIGA_MAC_VER_31) && |
3113 | r8168dp_check_dash(tp)) { | 3108 | r8168dp_check_dash(tp)) { |
3114 | return; | 3109 | return; |
3115 | } | 3110 | } |
3116 | 3111 | ||
3117 | if (((tp->mac_version == RTL_GIGA_MAC_VER_23) || | 3112 | if ((tp->mac_version == RTL_GIGA_MAC_VER_23 || |
3118 | (tp->mac_version == RTL_GIGA_MAC_VER_24)) && | 3113 | tp->mac_version == RTL_GIGA_MAC_VER_24) && |
3119 | (RTL_R16(CPlusCmd) & ASF)) { | 3114 | (RTL_R16(CPlusCmd) & ASF)) { |
3120 | return; | 3115 | return; |
3121 | } | 3116 | } |
@@ -3152,9 +3147,9 @@ static void r8168_pll_power_up(struct rtl8169_private *tp) | |||
3152 | { | 3147 | { |
3153 | void __iomem *ioaddr = tp->mmio_addr; | 3148 | void __iomem *ioaddr = tp->mmio_addr; |
3154 | 3149 | ||
3155 | if (((tp->mac_version == RTL_GIGA_MAC_VER_27) || | 3150 | if ((tp->mac_version == RTL_GIGA_MAC_VER_27 || |
3156 | (tp->mac_version == RTL_GIGA_MAC_VER_28) || | 3151 | tp->mac_version == RTL_GIGA_MAC_VER_28 || |
3157 | (tp->mac_version == RTL_GIGA_MAC_VER_31)) && | 3152 | tp->mac_version == RTL_GIGA_MAC_VER_31) && |
3158 | r8168dp_check_dash(tp)) { | 3153 | r8168dp_check_dash(tp)) { |
3159 | return; | 3154 | return; |
3160 | } | 3155 | } |
@@ -3235,6 +3230,22 @@ static void __devinit rtl_init_pll_power_ops(struct rtl8169_private *tp) | |||
3235 | } | 3230 | } |
3236 | } | 3231 | } |
3237 | 3232 | ||
3233 | static void rtl_hw_reset(struct rtl8169_private *tp) | ||
3234 | { | ||
3235 | void __iomem *ioaddr = tp->mmio_addr; | ||
3236 | int i; | ||
3237 | |||
3238 | /* Soft reset the chip. */ | ||
3239 | RTL_W8(ChipCmd, CmdReset); | ||
3240 | |||
3241 | /* Check that the chip has finished the reset. */ | ||
3242 | for (i = 0; i < 100; i++) { | ||
3243 | if ((RTL_R8(ChipCmd) & CmdReset) == 0) | ||
3244 | break; | ||
3245 | msleep_interruptible(1); | ||
3246 | } | ||
3247 | } | ||
3248 | |||
3238 | static int __devinit | 3249 | static int __devinit |
3239 | rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | 3250 | rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) |
3240 | { | 3251 | { |
@@ -3334,6 +3345,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
3334 | rc = -EIO; | 3345 | rc = -EIO; |
3335 | goto err_out_free_res_3; | 3346 | goto err_out_free_res_3; |
3336 | } | 3347 | } |
3348 | tp->mmio_addr = ioaddr; | ||
3337 | 3349 | ||
3338 | tp->pcie_cap = pci_find_capability(pdev, PCI_CAP_ID_EXP); | 3350 | tp->pcie_cap = pci_find_capability(pdev, PCI_CAP_ID_EXP); |
3339 | if (!tp->pcie_cap) | 3351 | if (!tp->pcie_cap) |
@@ -3341,22 +3353,14 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
3341 | 3353 | ||
3342 | RTL_W16(IntrMask, 0x0000); | 3354 | RTL_W16(IntrMask, 0x0000); |
3343 | 3355 | ||
3344 | /* Soft reset the chip. */ | 3356 | rtl_hw_reset(tp); |
3345 | RTL_W8(ChipCmd, CmdReset); | ||
3346 | |||
3347 | /* Check that the chip has finished the reset. */ | ||
3348 | for (i = 0; i < 100; i++) { | ||
3349 | if ((RTL_R8(ChipCmd) & CmdReset) == 0) | ||
3350 | break; | ||
3351 | msleep_interruptible(1); | ||
3352 | } | ||
3353 | 3357 | ||
3354 | RTL_W16(IntrStatus, 0xffff); | 3358 | RTL_W16(IntrStatus, 0xffff); |
3355 | 3359 | ||
3356 | pci_set_master(pdev); | 3360 | pci_set_master(pdev); |
3357 | 3361 | ||
3358 | /* Identify chip attached to board */ | 3362 | /* Identify chip attached to board */ |
3359 | rtl8169_get_mac_version(tp, ioaddr); | 3363 | rtl8169_get_mac_version(tp, dev, cfg->default_ver); |
3360 | 3364 | ||
3361 | /* | 3365 | /* |
3362 | * Pretend we are using VLANs; This bypasses a nasty bug where | 3366 | * Pretend we are using VLANs; This bypasses a nasty bug where |
@@ -3368,26 +3372,10 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
3368 | rtl_init_mdio_ops(tp); | 3372 | rtl_init_mdio_ops(tp); |
3369 | rtl_init_pll_power_ops(tp); | 3373 | rtl_init_pll_power_ops(tp); |
3370 | 3374 | ||
3371 | /* Use appropriate default if unknown */ | ||
3372 | if (tp->mac_version == RTL_GIGA_MAC_NONE) { | ||
3373 | netif_notice(tp, probe, dev, | ||
3374 | "unknown MAC, using family default\n"); | ||
3375 | tp->mac_version = cfg->default_ver; | ||
3376 | } | ||
3377 | |||
3378 | rtl8169_print_mac_version(tp); | 3375 | rtl8169_print_mac_version(tp); |
3379 | 3376 | ||
3380 | for (i = 0; i < ARRAY_SIZE(rtl_chip_info); i++) { | 3377 | chipset = tp->mac_version; |
3381 | if (tp->mac_version == rtl_chip_info[i].mac_version) | 3378 | tp->txd_version = rtl_chip_infos[chipset].txd_version; |
3382 | break; | ||
3383 | } | ||
3384 | if (i == ARRAY_SIZE(rtl_chip_info)) { | ||
3385 | dev_err(&pdev->dev, | ||
3386 | "driver bug, MAC version not found in rtl_chip_info\n"); | ||
3387 | goto err_out_msi_4; | ||
3388 | } | ||
3389 | chipset = i; | ||
3390 | tp->txd_version = rtl_chip_info[chipset].txd_version; | ||
3391 | 3379 | ||
3392 | RTL_W8(Cfg9346, Cfg9346_Unlock); | 3380 | RTL_W8(Cfg9346, Cfg9346_Unlock); |
3393 | RTL_W8(Config1, RTL_R8(Config1) | PMEnable); | 3381 | RTL_W8(Config1, RTL_R8(Config1) | PMEnable); |
@@ -3407,8 +3395,6 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
3407 | tp->phy_reset_pending = rtl8169_tbi_reset_pending; | 3395 | tp->phy_reset_pending = rtl8169_tbi_reset_pending; |
3408 | tp->link_ok = rtl8169_tbi_link_ok; | 3396 | tp->link_ok = rtl8169_tbi_link_ok; |
3409 | tp->do_ioctl = rtl_tbi_ioctl; | 3397 | tp->do_ioctl = rtl_tbi_ioctl; |
3410 | |||
3411 | tp->phy_1000_ctrl_reg = ADVERTISE_1000FULL; /* Implied by TBI */ | ||
3412 | } else { | 3398 | } else { |
3413 | tp->set_speed = rtl8169_set_speed_xmii; | 3399 | tp->set_speed = rtl8169_set_speed_xmii; |
3414 | tp->get_settings = rtl8169_gset_xmii; | 3400 | tp->get_settings = rtl8169_gset_xmii; |
@@ -3420,8 +3406,6 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
3420 | 3406 | ||
3421 | spin_lock_init(&tp->lock); | 3407 | spin_lock_init(&tp->lock); |
3422 | 3408 | ||
3423 | tp->mmio_addr = ioaddr; | ||
3424 | |||
3425 | /* Get MAC address */ | 3409 | /* Get MAC address */ |
3426 | for (i = 0; i < MAC_ADDR_LEN; i++) | 3410 | for (i = 0; i < MAC_ADDR_LEN; i++) |
3427 | dev->dev_addr[i] = RTL_R8(MAC0 + i); | 3411 | dev->dev_addr[i] = RTL_R8(MAC0 + i); |
@@ -3466,12 +3450,12 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
3466 | pci_set_drvdata(pdev, dev); | 3450 | pci_set_drvdata(pdev, dev); |
3467 | 3451 | ||
3468 | netif_info(tp, probe, dev, "%s at 0x%lx, %pM, XID %08x IRQ %d\n", | 3452 | netif_info(tp, probe, dev, "%s at 0x%lx, %pM, XID %08x IRQ %d\n", |
3469 | rtl_chip_info[chipset].name, dev->base_addr, dev->dev_addr, | 3453 | rtl_chip_infos[chipset].name, dev->base_addr, dev->dev_addr, |
3470 | (u32)(RTL_R32(TxConfig) & 0x9cf0f8ff), dev->irq); | 3454 | (u32)(RTL_R32(TxConfig) & 0x9cf0f8ff), dev->irq); |
3471 | 3455 | ||
3472 | if ((tp->mac_version == RTL_GIGA_MAC_VER_27) || | 3456 | if (tp->mac_version == RTL_GIGA_MAC_VER_27 || |
3473 | (tp->mac_version == RTL_GIGA_MAC_VER_28) || | 3457 | tp->mac_version == RTL_GIGA_MAC_VER_28 || |
3474 | (tp->mac_version == RTL_GIGA_MAC_VER_31)) { | 3458 | tp->mac_version == RTL_GIGA_MAC_VER_31) { |
3475 | rtl8168_driver_start(tp); | 3459 | rtl8168_driver_start(tp); |
3476 | } | 3460 | } |
3477 | 3461 | ||
@@ -3503,9 +3487,9 @@ static void __devexit rtl8169_remove_one(struct pci_dev *pdev) | |||
3503 | struct net_device *dev = pci_get_drvdata(pdev); | 3487 | struct net_device *dev = pci_get_drvdata(pdev); |
3504 | struct rtl8169_private *tp = netdev_priv(dev); | 3488 | struct rtl8169_private *tp = netdev_priv(dev); |
3505 | 3489 | ||
3506 | if ((tp->mac_version == RTL_GIGA_MAC_VER_27) || | 3490 | if (tp->mac_version == RTL_GIGA_MAC_VER_27 || |
3507 | (tp->mac_version == RTL_GIGA_MAC_VER_28) || | 3491 | tp->mac_version == RTL_GIGA_MAC_VER_28 || |
3508 | (tp->mac_version == RTL_GIGA_MAC_VER_31)) { | 3492 | tp->mac_version == RTL_GIGA_MAC_VER_31) { |
3509 | rtl8168_driver_stop(tp); | 3493 | rtl8168_driver_stop(tp); |
3510 | } | 3494 | } |
3511 | 3495 | ||
@@ -3528,33 +3512,23 @@ static void __devexit rtl8169_remove_one(struct pci_dev *pdev) | |||
3528 | 3512 | ||
3529 | static void rtl_request_firmware(struct rtl8169_private *tp) | 3513 | static void rtl_request_firmware(struct rtl8169_private *tp) |
3530 | { | 3514 | { |
3531 | int i; | ||
3532 | |||
3533 | /* Return early if the firmware is already loaded / cached. */ | 3515 | /* Return early if the firmware is already loaded / cached. */ |
3534 | if (!IS_ERR(tp->fw)) | 3516 | if (IS_ERR(tp->fw)) { |
3535 | goto out; | 3517 | const char *name; |
3536 | |||
3537 | for (i = 0; i < ARRAY_SIZE(rtl_firmware_infos); i++) { | ||
3538 | const struct rtl_firmware_info *info = rtl_firmware_infos + i; | ||
3539 | 3518 | ||
3540 | if (info->mac_version == tp->mac_version) { | 3519 | name = rtl_lookup_firmware_name(tp); |
3541 | const char *name = info->fw_name; | 3520 | if (name) { |
3542 | int rc; | 3521 | int rc; |
3543 | 3522 | ||
3544 | rc = request_firmware(&tp->fw, name, &tp->pci_dev->dev); | 3523 | rc = request_firmware(&tp->fw, name, &tp->pci_dev->dev); |
3545 | if (rc < 0) { | 3524 | if (rc >= 0) |
3546 | netif_warn(tp, ifup, tp->dev, "unable to load " | 3525 | return; |
3547 | "firmware patch %s (%d)\n", name, rc); | 3526 | |
3548 | goto out_disable_request_firmware; | 3527 | netif_warn(tp, ifup, tp->dev, "unable to load " |
3549 | } | 3528 | "firmware patch %s (%d)\n", name, rc); |
3550 | goto out; | ||
3551 | } | 3529 | } |
3530 | tp->fw = NULL; | ||
3552 | } | 3531 | } |
3553 | |||
3554 | out_disable_request_firmware: | ||
3555 | tp->fw = NULL; | ||
3556 | out: | ||
3557 | return; | ||
3558 | } | 3532 | } |
3559 | 3533 | ||
3560 | static int rtl8169_open(struct net_device *dev) | 3534 | static int rtl8169_open(struct net_device *dev) |
@@ -3606,8 +3580,6 @@ static int rtl8169_open(struct net_device *dev) | |||
3606 | 3580 | ||
3607 | rtl_hw_start(dev); | 3581 | rtl_hw_start(dev); |
3608 | 3582 | ||
3609 | rtl8169_request_timer(dev); | ||
3610 | |||
3611 | tp->saved_wolopts = 0; | 3583 | tp->saved_wolopts = 0; |
3612 | pm_runtime_put_noidle(&pdev->dev); | 3584 | pm_runtime_put_noidle(&pdev->dev); |
3613 | 3585 | ||
@@ -3669,25 +3641,14 @@ static void rtl_set_rx_tx_config_registers(struct rtl8169_private *tp) | |||
3669 | static void rtl_hw_start(struct net_device *dev) | 3641 | static void rtl_hw_start(struct net_device *dev) |
3670 | { | 3642 | { |
3671 | struct rtl8169_private *tp = netdev_priv(dev); | 3643 | struct rtl8169_private *tp = netdev_priv(dev); |
3672 | void __iomem *ioaddr = tp->mmio_addr; | ||
3673 | unsigned int i; | ||
3674 | |||
3675 | /* Soft reset the chip. */ | ||
3676 | RTL_W8(ChipCmd, CmdReset); | ||
3677 | 3644 | ||
3678 | /* Check that the chip has finished the reset. */ | 3645 | rtl_hw_reset(tp); |
3679 | for (i = 0; i < 100; i++) { | ||
3680 | if ((RTL_R8(ChipCmd) & CmdReset) == 0) | ||
3681 | break; | ||
3682 | msleep_interruptible(1); | ||
3683 | } | ||
3684 | 3646 | ||
3685 | tp->hw_start(dev); | 3647 | tp->hw_start(dev); |
3686 | 3648 | ||
3687 | netif_start_queue(dev); | 3649 | netif_start_queue(dev); |
3688 | } | 3650 | } |
3689 | 3651 | ||
3690 | |||
3691 | static void rtl_set_rx_tx_desc_registers(struct rtl8169_private *tp, | 3652 | static void rtl_set_rx_tx_desc_registers(struct rtl8169_private *tp, |
3692 | void __iomem *ioaddr) | 3653 | void __iomem *ioaddr) |
3693 | { | 3654 | { |
@@ -3753,26 +3714,26 @@ static void rtl_hw_start_8169(struct net_device *dev) | |||
3753 | } | 3714 | } |
3754 | 3715 | ||
3755 | RTL_W8(Cfg9346, Cfg9346_Unlock); | 3716 | RTL_W8(Cfg9346, Cfg9346_Unlock); |
3756 | if ((tp->mac_version == RTL_GIGA_MAC_VER_01) || | 3717 | if (tp->mac_version == RTL_GIGA_MAC_VER_01 || |
3757 | (tp->mac_version == RTL_GIGA_MAC_VER_02) || | 3718 | tp->mac_version == RTL_GIGA_MAC_VER_02 || |
3758 | (tp->mac_version == RTL_GIGA_MAC_VER_03) || | 3719 | tp->mac_version == RTL_GIGA_MAC_VER_03 || |
3759 | (tp->mac_version == RTL_GIGA_MAC_VER_04)) | 3720 | tp->mac_version == RTL_GIGA_MAC_VER_04) |
3760 | RTL_W8(ChipCmd, CmdTxEnb | CmdRxEnb); | 3721 | RTL_W8(ChipCmd, CmdTxEnb | CmdRxEnb); |
3761 | 3722 | ||
3762 | RTL_W8(EarlyTxThres, NoEarlyTx); | 3723 | RTL_W8(EarlyTxThres, NoEarlyTx); |
3763 | 3724 | ||
3764 | rtl_set_rx_max_size(ioaddr, rx_buf_sz); | 3725 | rtl_set_rx_max_size(ioaddr, rx_buf_sz); |
3765 | 3726 | ||
3766 | if ((tp->mac_version == RTL_GIGA_MAC_VER_01) || | 3727 | if (tp->mac_version == RTL_GIGA_MAC_VER_01 || |
3767 | (tp->mac_version == RTL_GIGA_MAC_VER_02) || | 3728 | tp->mac_version == RTL_GIGA_MAC_VER_02 || |
3768 | (tp->mac_version == RTL_GIGA_MAC_VER_03) || | 3729 | tp->mac_version == RTL_GIGA_MAC_VER_03 || |
3769 | (tp->mac_version == RTL_GIGA_MAC_VER_04)) | 3730 | tp->mac_version == RTL_GIGA_MAC_VER_04) |
3770 | rtl_set_rx_tx_config_registers(tp); | 3731 | rtl_set_rx_tx_config_registers(tp); |
3771 | 3732 | ||
3772 | tp->cp_cmd |= rtl_rw_cpluscmd(ioaddr) | PCIMulRW; | 3733 | tp->cp_cmd |= rtl_rw_cpluscmd(ioaddr) | PCIMulRW; |
3773 | 3734 | ||
3774 | if ((tp->mac_version == RTL_GIGA_MAC_VER_02) || | 3735 | if (tp->mac_version == RTL_GIGA_MAC_VER_02 || |
3775 | (tp->mac_version == RTL_GIGA_MAC_VER_03)) { | 3736 | tp->mac_version == RTL_GIGA_MAC_VER_03) { |
3776 | dprintk("Set MAC Reg C+CR Offset 0xE0. " | 3737 | dprintk("Set MAC Reg C+CR Offset 0xE0. " |
3777 | "Bit-3 and bit-14 MUST be 1\n"); | 3738 | "Bit-3 and bit-14 MUST be 1\n"); |
3778 | tp->cp_cmd |= (1 << 14); | 3739 | tp->cp_cmd |= (1 << 14); |
@@ -3790,10 +3751,10 @@ static void rtl_hw_start_8169(struct net_device *dev) | |||
3790 | 3751 | ||
3791 | rtl_set_rx_tx_desc_registers(tp, ioaddr); | 3752 | rtl_set_rx_tx_desc_registers(tp, ioaddr); |
3792 | 3753 | ||
3793 | if ((tp->mac_version != RTL_GIGA_MAC_VER_01) && | 3754 | if (tp->mac_version != RTL_GIGA_MAC_VER_01 && |
3794 | (tp->mac_version != RTL_GIGA_MAC_VER_02) && | 3755 | tp->mac_version != RTL_GIGA_MAC_VER_02 && |
3795 | (tp->mac_version != RTL_GIGA_MAC_VER_03) && | 3756 | tp->mac_version != RTL_GIGA_MAC_VER_03 && |
3796 | (tp->mac_version != RTL_GIGA_MAC_VER_04)) { | 3757 | tp->mac_version != RTL_GIGA_MAC_VER_04) { |
3797 | RTL_W8(ChipCmd, CmdTxEnb | CmdRxEnb); | 3758 | RTL_W8(ChipCmd, CmdTxEnb | CmdRxEnb); |
3798 | rtl_set_rx_tx_config_registers(tp); | 3759 | rtl_set_rx_tx_config_registers(tp); |
3799 | } | 3760 | } |
@@ -4103,10 +4064,10 @@ static void rtl_hw_start_8168e(void __iomem *ioaddr, struct pci_dev *pdev) | |||
4103 | rtl_disable_clock_request(pdev); | 4064 | rtl_disable_clock_request(pdev); |
4104 | 4065 | ||
4105 | /* Reset tx FIFO pointer */ | 4066 | /* Reset tx FIFO pointer */ |
4106 | RTL_W32(MISC, RTL_R32(MISC) | txpla_rst); | 4067 | RTL_W32(MISC, RTL_R32(MISC) | TXPLA_RST); |
4107 | RTL_W32(MISC, RTL_R32(MISC) & ~txpla_rst); | 4068 | RTL_W32(MISC, RTL_R32(MISC) & ~TXPLA_RST); |
4108 | 4069 | ||
4109 | RTL_W8(Config5, RTL_R8(Config5) & ~spi_en); | 4070 | RTL_W8(Config5, RTL_R8(Config5) & ~Spi_en); |
4110 | } | 4071 | } |
4111 | 4072 | ||
4112 | static void rtl_hw_start_8168(struct net_device *dev) | 4073 | static void rtl_hw_start_8168(struct net_device *dev) |
@@ -4190,6 +4151,7 @@ static void rtl_hw_start_8168(struct net_device *dev) | |||
4190 | case RTL_GIGA_MAC_VER_28: | 4151 | case RTL_GIGA_MAC_VER_28: |
4191 | rtl_hw_start_8168d_4(ioaddr, pdev); | 4152 | rtl_hw_start_8168d_4(ioaddr, pdev); |
4192 | break; | 4153 | break; |
4154 | |||
4193 | case RTL_GIGA_MAC_VER_31: | 4155 | case RTL_GIGA_MAC_VER_31: |
4194 | rtl_hw_start_8168dp(ioaddr, pdev); | 4156 | rtl_hw_start_8168dp(ioaddr, pdev); |
4195 | break; | 4157 | break; |
@@ -4286,10 +4248,10 @@ static void rtl_hw_start_8105e_1(void __iomem *ioaddr, struct pci_dev *pdev) | |||
4286 | { 0x0a, 0, 0x0020 } | 4248 | { 0x0a, 0, 0x0020 } |
4287 | }; | 4249 | }; |
4288 | 4250 | ||
4289 | /* Force LAN exit from ASPM if Rx/Tx are not idel */ | 4251 | /* Force LAN exit from ASPM if Rx/Tx are not idle */ |
4290 | RTL_W32(FuncEvent, RTL_R32(FuncEvent) | 0x002800); | 4252 | RTL_W32(FuncEvent, RTL_R32(FuncEvent) | 0x002800); |
4291 | 4253 | ||
4292 | /* disable Early Tally Counter */ | 4254 | /* Disable Early Tally Counter */ |
4293 | RTL_W32(FuncEvent, RTL_R32(FuncEvent) & ~0x010000); | 4255 | RTL_W32(FuncEvent, RTL_R32(FuncEvent) & ~0x010000); |
4294 | 4256 | ||
4295 | RTL_W8(MCU, RTL_R8(MCU) | EN_NDP | EN_OOB_RESET); | 4257 | RTL_W8(MCU, RTL_R8(MCU) | EN_NDP | EN_OOB_RESET); |
@@ -4310,8 +4272,8 @@ static void rtl_hw_start_8101(struct net_device *dev) | |||
4310 | void __iomem *ioaddr = tp->mmio_addr; | 4272 | void __iomem *ioaddr = tp->mmio_addr; |
4311 | struct pci_dev *pdev = tp->pci_dev; | 4273 | struct pci_dev *pdev = tp->pci_dev; |
4312 | 4274 | ||
4313 | if ((tp->mac_version == RTL_GIGA_MAC_VER_13) || | 4275 | if (tp->mac_version == RTL_GIGA_MAC_VER_13 || |
4314 | (tp->mac_version == RTL_GIGA_MAC_VER_16)) { | 4276 | tp->mac_version == RTL_GIGA_MAC_VER_16) { |
4315 | int cap = tp->pcie_cap; | 4277 | int cap = tp->pcie_cap; |
4316 | 4278 | ||
4317 | if (cap) { | 4279 | if (cap) { |
@@ -4613,6 +4575,7 @@ static void rtl8169_reset_task(struct work_struct *work) | |||
4613 | struct rtl8169_private *tp = | 4575 | struct rtl8169_private *tp = |
4614 | container_of(work, struct rtl8169_private, task.work); | 4576 | container_of(work, struct rtl8169_private, task.work); |
4615 | struct net_device *dev = tp->dev; | 4577 | struct net_device *dev = tp->dev; |
4578 | int i; | ||
4616 | 4579 | ||
4617 | rtnl_lock(); | 4580 | rtnl_lock(); |
4618 | 4581 | ||
@@ -4621,19 +4584,15 @@ static void rtl8169_reset_task(struct work_struct *work) | |||
4621 | 4584 | ||
4622 | rtl8169_wait_for_quiescence(dev); | 4585 | rtl8169_wait_for_quiescence(dev); |
4623 | 4586 | ||
4624 | rtl8169_rx_interrupt(dev, tp, tp->mmio_addr, ~(u32)0); | 4587 | for (i = 0; i < NUM_RX_DESC; i++) |
4588 | rtl8169_mark_to_asic(tp->RxDescArray + i, rx_buf_sz); | ||
4589 | |||
4625 | rtl8169_tx_clear(tp); | 4590 | rtl8169_tx_clear(tp); |
4626 | 4591 | ||
4627 | if (tp->dirty_rx == tp->cur_rx) { | 4592 | rtl8169_init_ring_indexes(tp); |
4628 | rtl8169_init_ring_indexes(tp); | 4593 | rtl_hw_start(dev); |
4629 | rtl_hw_start(dev); | 4594 | netif_wake_queue(dev); |
4630 | netif_wake_queue(dev); | 4595 | rtl8169_check_link_status(dev, tp, tp->mmio_addr); |
4631 | rtl8169_check_link_status(dev, tp, tp->mmio_addr); | ||
4632 | } else { | ||
4633 | if (net_ratelimit()) | ||
4634 | netif_emerg(tp, intr, dev, "Rx buffers shortage\n"); | ||
4635 | rtl8169_schedule_work(dev, rtl8169_reset_task); | ||
4636 | } | ||
4637 | 4596 | ||
4638 | out_unlock: | 4597 | out_unlock: |
4639 | rtnl_unlock(); | 4598 | rtnl_unlock(); |
@@ -4677,7 +4636,7 @@ static int rtl8169_xmit_frags(struct rtl8169_private *tp, struct sk_buff *skb, | |||
4677 | goto err_out; | 4636 | goto err_out; |
4678 | } | 4637 | } |
4679 | 4638 | ||
4680 | /* anti gcc 2.95.3 bugware (sic) */ | 4639 | /* Anti gcc 2.95.3 bugware (sic) */ |
4681 | status = opts[0] | len | | 4640 | status = opts[0] | len | |
4682 | (RingEnd * !((entry + 1) % NUM_TX_DESC)); | 4641 | (RingEnd * !((entry + 1) % NUM_TX_DESC)); |
4683 | 4642 | ||
@@ -4773,7 +4732,7 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb, | |||
4773 | 4732 | ||
4774 | wmb(); | 4733 | wmb(); |
4775 | 4734 | ||
4776 | /* anti gcc 2.95.3 bugware (sic) */ | 4735 | /* Anti gcc 2.95.3 bugware (sic) */ |
4777 | status = opts[0] | len | (RingEnd * !((entry + 1) % NUM_TX_DESC)); | 4736 | status = opts[0] | len | (RingEnd * !((entry + 1) % NUM_TX_DESC)); |
4778 | txd->opts1 = cpu_to_le32(status); | 4737 | txd->opts1 = cpu_to_le32(status); |
4779 | 4738 | ||
@@ -4781,7 +4740,7 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb, | |||
4781 | 4740 | ||
4782 | wmb(); | 4741 | wmb(); |
4783 | 4742 | ||
4784 | RTL_W8(TxPoll, NPQ); /* set polling bit */ | 4743 | RTL_W8(TxPoll, NPQ); |
4785 | 4744 | ||
4786 | if (TX_BUFFS_AVAIL(tp) < MAX_SKB_FRAGS) { | 4745 | if (TX_BUFFS_AVAIL(tp) < MAX_SKB_FRAGS) { |
4787 | netif_stop_queue(dev); | 4746 | netif_stop_queue(dev); |
@@ -4938,20 +4897,12 @@ static struct sk_buff *rtl8169_try_rx_copy(void *data, | |||
4938 | return skb; | 4897 | return skb; |
4939 | } | 4898 | } |
4940 | 4899 | ||
4941 | /* | ||
4942 | * Warning : rtl8169_rx_interrupt() might be called : | ||
4943 | * 1) from NAPI (softirq) context | ||
4944 | * (polling = 1 : we should call netif_receive_skb()) | ||
4945 | * 2) from process context (rtl8169_reset_task()) | ||
4946 | * (polling = 0 : we must call netif_rx() instead) | ||
4947 | */ | ||
4948 | static int rtl8169_rx_interrupt(struct net_device *dev, | 4900 | static int rtl8169_rx_interrupt(struct net_device *dev, |
4949 | struct rtl8169_private *tp, | 4901 | struct rtl8169_private *tp, |
4950 | void __iomem *ioaddr, u32 budget) | 4902 | void __iomem *ioaddr, u32 budget) |
4951 | { | 4903 | { |
4952 | unsigned int cur_rx, rx_left; | 4904 | unsigned int cur_rx, rx_left; |
4953 | unsigned int count; | 4905 | unsigned int count; |
4954 | int polling = (budget != ~(u32)0) ? 1 : 0; | ||
4955 | 4906 | ||
4956 | cur_rx = tp->cur_rx; | 4907 | cur_rx = tp->cur_rx; |
4957 | rx_left = NUM_RX_DESC + tp->dirty_rx - cur_rx; | 4908 | rx_left = NUM_RX_DESC + tp->dirty_rx - cur_rx; |
@@ -5011,10 +4962,7 @@ static int rtl8169_rx_interrupt(struct net_device *dev, | |||
5011 | 4962 | ||
5012 | rtl8169_rx_vlan_tag(desc, skb); | 4963 | rtl8169_rx_vlan_tag(desc, skb); |
5013 | 4964 | ||
5014 | if (likely(polling)) | 4965 | napi_gro_receive(&tp->napi, skb); |
5015 | napi_gro_receive(&tp->napi, skb); | ||
5016 | else | ||
5017 | netif_rx(skb); | ||
5018 | 4966 | ||
5019 | dev->stats.rx_bytes += pkt_size; | 4967 | dev->stats.rx_bytes += pkt_size; |
5020 | dev->stats.rx_packets++; | 4968 | dev->stats.rx_packets++; |
@@ -5170,7 +5118,7 @@ static void rtl8169_down(struct net_device *dev) | |||
5170 | struct rtl8169_private *tp = netdev_priv(dev); | 5118 | struct rtl8169_private *tp = netdev_priv(dev); |
5171 | void __iomem *ioaddr = tp->mmio_addr; | 5119 | void __iomem *ioaddr = tp->mmio_addr; |
5172 | 5120 | ||
5173 | rtl8169_delete_timer(dev); | 5121 | del_timer_sync(&tp->timer); |
5174 | 5122 | ||
5175 | netif_stop_queue(dev); | 5123 | netif_stop_queue(dev); |
5176 | 5124 | ||
@@ -5207,7 +5155,7 @@ static int rtl8169_close(struct net_device *dev) | |||
5207 | 5155 | ||
5208 | pm_runtime_get_sync(&pdev->dev); | 5156 | pm_runtime_get_sync(&pdev->dev); |
5209 | 5157 | ||
5210 | /* update counters before going down */ | 5158 | /* Update counters before going down */ |
5211 | rtl8169_update_counters(dev); | 5159 | rtl8169_update_counters(dev); |
5212 | 5160 | ||
5213 | rtl8169_down(dev); | 5161 | rtl8169_down(dev); |
@@ -5400,15 +5348,15 @@ static int rtl8169_runtime_idle(struct device *device) | |||
5400 | } | 5348 | } |
5401 | 5349 | ||
5402 | static const struct dev_pm_ops rtl8169_pm_ops = { | 5350 | static const struct dev_pm_ops rtl8169_pm_ops = { |
5403 | .suspend = rtl8169_suspend, | 5351 | .suspend = rtl8169_suspend, |
5404 | .resume = rtl8169_resume, | 5352 | .resume = rtl8169_resume, |
5405 | .freeze = rtl8169_suspend, | 5353 | .freeze = rtl8169_suspend, |
5406 | .thaw = rtl8169_resume, | 5354 | .thaw = rtl8169_resume, |
5407 | .poweroff = rtl8169_suspend, | 5355 | .poweroff = rtl8169_suspend, |
5408 | .restore = rtl8169_resume, | 5356 | .restore = rtl8169_resume, |
5409 | .runtime_suspend = rtl8169_runtime_suspend, | 5357 | .runtime_suspend = rtl8169_runtime_suspend, |
5410 | .runtime_resume = rtl8169_runtime_resume, | 5358 | .runtime_resume = rtl8169_runtime_resume, |
5411 | .runtime_idle = rtl8169_runtime_idle, | 5359 | .runtime_idle = rtl8169_runtime_idle, |
5412 | }; | 5360 | }; |
5413 | 5361 | ||
5414 | #define RTL8169_PM_OPS (&rtl8169_pm_ops) | 5362 | #define RTL8169_PM_OPS (&rtl8169_pm_ops) |
@@ -5427,7 +5375,7 @@ static void rtl_shutdown(struct pci_dev *pdev) | |||
5427 | 5375 | ||
5428 | rtl8169_net_suspend(dev); | 5376 | rtl8169_net_suspend(dev); |
5429 | 5377 | ||
5430 | /* restore original MAC address */ | 5378 | /* Restore original MAC address */ |
5431 | rtl_rar_set(tp, dev->perm_addr); | 5379 | rtl_rar_set(tp, dev->perm_addr); |
5432 | 5380 | ||
5433 | spin_lock_irq(&tp->lock); | 5381 | spin_lock_irq(&tp->lock); |