|
1 /******************************************************************************* |
|
2 |
|
3 Intel PRO/1000 Linux driver |
|
4 Copyright(c) 1999 - 2006 Intel Corporation. |
|
5 |
|
6 This program is free software; you can redistribute it and/or modify it |
|
7 under the terms and conditions of the GNU General Public License, |
|
8 version 2, as published by the Free Software Foundation. |
|
9 |
|
10 This program is distributed in the hope it will be useful, but WITHOUT |
|
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
|
13 more details. |
|
14 |
|
15 You should have received a copy of the GNU General Public License along with |
|
16 this program; if not, write to the Free Software Foundation, Inc., |
|
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
|
19 The full GNU General Public License is included in this distribution in |
|
20 the file called "COPYING". |
|
21 |
|
22 Contact Information: |
|
23 Linux NICS <linux.nics@intel.com> |
|
24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> |
|
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 |
|
26 |
|
27 *******************************************************************************/ |
|
28 |
|
29 /* ethtool support for e1000 */ |
|
30 |
|
31 #include "e1000-2.6.26-ethercat.h" |
|
32 |
|
33 #include <asm/uaccess.h> |
|
34 |
|
35 extern int e1000_up(struct e1000_adapter *adapter); |
|
36 extern void e1000_down(struct e1000_adapter *adapter); |
|
37 extern void e1000_reinit_locked(struct e1000_adapter *adapter); |
|
38 extern void e1000_reset(struct e1000_adapter *adapter); |
|
39 extern int e1000_set_spd_dplx(struct e1000_adapter *adapter, u16 spddplx); |
|
40 extern int e1000_setup_all_rx_resources(struct e1000_adapter *adapter); |
|
41 extern int e1000_setup_all_tx_resources(struct e1000_adapter *adapter); |
|
42 extern void e1000_free_all_rx_resources(struct e1000_adapter *adapter); |
|
43 extern void e1000_free_all_tx_resources(struct e1000_adapter *adapter); |
|
44 extern void e1000_update_stats(struct e1000_adapter *adapter); |
|
45 |
|
46 |
|
47 struct e1000_stats { |
|
48 char stat_string[ETH_GSTRING_LEN]; |
|
49 int sizeof_stat; |
|
50 int stat_offset; |
|
51 }; |
|
52 |
|
53 #define E1000_STAT(m) FIELD_SIZEOF(struct e1000_adapter, m), \ |
|
54 offsetof(struct e1000_adapter, m) |
|
55 static const struct e1000_stats e1000_gstrings_stats[] = { |
|
56 { "rx_packets", E1000_STAT(stats.gprc) }, |
|
57 { "tx_packets", E1000_STAT(stats.gptc) }, |
|
58 { "rx_bytes", E1000_STAT(stats.gorcl) }, |
|
59 { "tx_bytes", E1000_STAT(stats.gotcl) }, |
|
60 { "rx_broadcast", E1000_STAT(stats.bprc) }, |
|
61 { "tx_broadcast", E1000_STAT(stats.bptc) }, |
|
62 { "rx_multicast", E1000_STAT(stats.mprc) }, |
|
63 { "tx_multicast", E1000_STAT(stats.mptc) }, |
|
64 { "rx_errors", E1000_STAT(stats.rxerrc) }, |
|
65 { "tx_errors", E1000_STAT(stats.txerrc) }, |
|
66 { "tx_dropped", E1000_STAT(net_stats.tx_dropped) }, |
|
67 { "multicast", E1000_STAT(stats.mprc) }, |
|
68 { "collisions", E1000_STAT(stats.colc) }, |
|
69 { "rx_length_errors", E1000_STAT(stats.rlerrc) }, |
|
70 { "rx_over_errors", E1000_STAT(net_stats.rx_over_errors) }, |
|
71 { "rx_crc_errors", E1000_STAT(stats.crcerrs) }, |
|
72 { "rx_frame_errors", E1000_STAT(net_stats.rx_frame_errors) }, |
|
73 { "rx_no_buffer_count", E1000_STAT(stats.rnbc) }, |
|
74 { "rx_missed_errors", E1000_STAT(stats.mpc) }, |
|
75 { "tx_aborted_errors", E1000_STAT(stats.ecol) }, |
|
76 { "tx_carrier_errors", E1000_STAT(stats.tncrs) }, |
|
77 { "tx_fifo_errors", E1000_STAT(net_stats.tx_fifo_errors) }, |
|
78 { "tx_heartbeat_errors", E1000_STAT(net_stats.tx_heartbeat_errors) }, |
|
79 { "tx_window_errors", E1000_STAT(stats.latecol) }, |
|
80 { "tx_abort_late_coll", E1000_STAT(stats.latecol) }, |
|
81 { "tx_deferred_ok", E1000_STAT(stats.dc) }, |
|
82 { "tx_single_coll_ok", E1000_STAT(stats.scc) }, |
|
83 { "tx_multi_coll_ok", E1000_STAT(stats.mcc) }, |
|
84 { "tx_timeout_count", E1000_STAT(tx_timeout_count) }, |
|
85 { "tx_restart_queue", E1000_STAT(restart_queue) }, |
|
86 { "rx_long_length_errors", E1000_STAT(stats.roc) }, |
|
87 { "rx_short_length_errors", E1000_STAT(stats.ruc) }, |
|
88 { "rx_align_errors", E1000_STAT(stats.algnerrc) }, |
|
89 { "tx_tcp_seg_good", E1000_STAT(stats.tsctc) }, |
|
90 { "tx_tcp_seg_failed", E1000_STAT(stats.tsctfc) }, |
|
91 { "rx_flow_control_xon", E1000_STAT(stats.xonrxc) }, |
|
92 { "rx_flow_control_xoff", E1000_STAT(stats.xoffrxc) }, |
|
93 { "tx_flow_control_xon", E1000_STAT(stats.xontxc) }, |
|
94 { "tx_flow_control_xoff", E1000_STAT(stats.xofftxc) }, |
|
95 { "rx_long_byte_count", E1000_STAT(stats.gorcl) }, |
|
96 { "rx_csum_offload_good", E1000_STAT(hw_csum_good) }, |
|
97 { "rx_csum_offload_errors", E1000_STAT(hw_csum_err) }, |
|
98 { "rx_header_split", E1000_STAT(rx_hdr_split) }, |
|
99 { "alloc_rx_buff_failed", E1000_STAT(alloc_rx_buff_failed) }, |
|
100 { "tx_smbus", E1000_STAT(stats.mgptc) }, |
|
101 { "rx_smbus", E1000_STAT(stats.mgprc) }, |
|
102 { "dropped_smbus", E1000_STAT(stats.mgpdc) }, |
|
103 }; |
|
104 |
|
105 #define E1000_QUEUE_STATS_LEN 0 |
|
106 #define E1000_GLOBAL_STATS_LEN ARRAY_SIZE(e1000_gstrings_stats) |
|
107 #define E1000_STATS_LEN (E1000_GLOBAL_STATS_LEN + E1000_QUEUE_STATS_LEN) |
|
108 static const char e1000_gstrings_test[][ETH_GSTRING_LEN] = { |
|
109 "Register test (offline)", "Eeprom test (offline)", |
|
110 "Interrupt test (offline)", "Loopback test (offline)", |
|
111 "Link test (on/offline)" |
|
112 }; |
|
113 #define E1000_TEST_LEN ARRAY_SIZE(e1000_gstrings_test) |
|
114 |
|
115 static int |
|
116 e1000_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd) |
|
117 { |
|
118 struct e1000_adapter *adapter = netdev_priv(netdev); |
|
119 struct e1000_hw *hw = &adapter->hw; |
|
120 |
|
121 if (hw->media_type == e1000_media_type_copper) { |
|
122 |
|
123 ecmd->supported = (SUPPORTED_10baseT_Half | |
|
124 SUPPORTED_10baseT_Full | |
|
125 SUPPORTED_100baseT_Half | |
|
126 SUPPORTED_100baseT_Full | |
|
127 SUPPORTED_1000baseT_Full| |
|
128 SUPPORTED_Autoneg | |
|
129 SUPPORTED_TP); |
|
130 if (hw->phy_type == e1000_phy_ife) |
|
131 ecmd->supported &= ~SUPPORTED_1000baseT_Full; |
|
132 ecmd->advertising = ADVERTISED_TP; |
|
133 |
|
134 if (hw->autoneg == 1) { |
|
135 ecmd->advertising |= ADVERTISED_Autoneg; |
|
136 /* the e1000 autoneg seems to match ethtool nicely */ |
|
137 ecmd->advertising |= hw->autoneg_advertised; |
|
138 } |
|
139 |
|
140 ecmd->port = PORT_TP; |
|
141 ecmd->phy_address = hw->phy_addr; |
|
142 |
|
143 if (hw->mac_type == e1000_82543) |
|
144 ecmd->transceiver = XCVR_EXTERNAL; |
|
145 else |
|
146 ecmd->transceiver = XCVR_INTERNAL; |
|
147 |
|
148 } else { |
|
149 ecmd->supported = (SUPPORTED_1000baseT_Full | |
|
150 SUPPORTED_FIBRE | |
|
151 SUPPORTED_Autoneg); |
|
152 |
|
153 ecmd->advertising = (ADVERTISED_1000baseT_Full | |
|
154 ADVERTISED_FIBRE | |
|
155 ADVERTISED_Autoneg); |
|
156 |
|
157 ecmd->port = PORT_FIBRE; |
|
158 |
|
159 if (hw->mac_type >= e1000_82545) |
|
160 ecmd->transceiver = XCVR_INTERNAL; |
|
161 else |
|
162 ecmd->transceiver = XCVR_EXTERNAL; |
|
163 } |
|
164 |
|
165 if ((adapter->ecdev && ecdev_get_link(adapter->ecdev)) |
|
166 || (!adapter->ecdev && (E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_LU))) { |
|
167 |
|
168 e1000_get_speed_and_duplex(hw, &adapter->link_speed, |
|
169 &adapter->link_duplex); |
|
170 ecmd->speed = adapter->link_speed; |
|
171 |
|
172 /* unfortunatly FULL_DUPLEX != DUPLEX_FULL |
|
173 * and HALF_DUPLEX != DUPLEX_HALF */ |
|
174 |
|
175 if (adapter->link_duplex == FULL_DUPLEX) |
|
176 ecmd->duplex = DUPLEX_FULL; |
|
177 else |
|
178 ecmd->duplex = DUPLEX_HALF; |
|
179 } else { |
|
180 ecmd->speed = -1; |
|
181 ecmd->duplex = -1; |
|
182 } |
|
183 |
|
184 ecmd->autoneg = ((hw->media_type == e1000_media_type_fiber) || |
|
185 hw->autoneg) ? AUTONEG_ENABLE : AUTONEG_DISABLE; |
|
186 return 0; |
|
187 } |
|
188 |
|
189 static int |
|
190 e1000_set_settings(struct net_device *netdev, struct ethtool_cmd *ecmd) |
|
191 { |
|
192 struct e1000_adapter *adapter = netdev_priv(netdev); |
|
193 struct e1000_hw *hw = &adapter->hw; |
|
194 |
|
195 if (adapter->ecdev) |
|
196 return -EBUSY; |
|
197 |
|
198 /* When SoL/IDER sessions are active, autoneg/speed/duplex |
|
199 * cannot be changed */ |
|
200 if (e1000_check_phy_reset_block(hw)) { |
|
201 DPRINTK(DRV, ERR, "Cannot change link characteristics " |
|
202 "when SoL/IDER is active.\n"); |
|
203 return -EINVAL; |
|
204 } |
|
205 |
|
206 while (test_and_set_bit(__E1000_RESETTING, &adapter->flags)) |
|
207 msleep(1); |
|
208 |
|
209 if (ecmd->autoneg == AUTONEG_ENABLE) { |
|
210 hw->autoneg = 1; |
|
211 if (hw->media_type == e1000_media_type_fiber) |
|
212 hw->autoneg_advertised = ADVERTISED_1000baseT_Full | |
|
213 ADVERTISED_FIBRE | |
|
214 ADVERTISED_Autoneg; |
|
215 else |
|
216 hw->autoneg_advertised = ecmd->advertising | |
|
217 ADVERTISED_TP | |
|
218 ADVERTISED_Autoneg; |
|
219 ecmd->advertising = hw->autoneg_advertised; |
|
220 } else |
|
221 if (e1000_set_spd_dplx(adapter, ecmd->speed + ecmd->duplex)) { |
|
222 clear_bit(__E1000_RESETTING, &adapter->flags); |
|
223 return -EINVAL; |
|
224 } |
|
225 |
|
226 /* reset the link */ |
|
227 |
|
228 if (netif_running(adapter->netdev)) { |
|
229 e1000_down(adapter); |
|
230 e1000_up(adapter); |
|
231 } else |
|
232 e1000_reset(adapter); |
|
233 |
|
234 clear_bit(__E1000_RESETTING, &adapter->flags); |
|
235 return 0; |
|
236 } |
|
237 |
|
238 static void |
|
239 e1000_get_pauseparam(struct net_device *netdev, |
|
240 struct ethtool_pauseparam *pause) |
|
241 { |
|
242 struct e1000_adapter *adapter = netdev_priv(netdev); |
|
243 struct e1000_hw *hw = &adapter->hw; |
|
244 |
|
245 pause->autoneg = |
|
246 (adapter->fc_autoneg ? AUTONEG_ENABLE : AUTONEG_DISABLE); |
|
247 |
|
248 if (hw->fc == E1000_FC_RX_PAUSE) |
|
249 pause->rx_pause = 1; |
|
250 else if (hw->fc == E1000_FC_TX_PAUSE) |
|
251 pause->tx_pause = 1; |
|
252 else if (hw->fc == E1000_FC_FULL) { |
|
253 pause->rx_pause = 1; |
|
254 pause->tx_pause = 1; |
|
255 } |
|
256 } |
|
257 |
|
258 static int |
|
259 e1000_set_pauseparam(struct net_device *netdev, |
|
260 struct ethtool_pauseparam *pause) |
|
261 { |
|
262 struct e1000_adapter *adapter = netdev_priv(netdev); |
|
263 struct e1000_hw *hw = &adapter->hw; |
|
264 int retval = 0; |
|
265 |
|
266 if (adapter->ecdev) |
|
267 return -EBUSY; |
|
268 |
|
269 adapter->fc_autoneg = pause->autoneg; |
|
270 |
|
271 while (test_and_set_bit(__E1000_RESETTING, &adapter->flags)) |
|
272 msleep(1); |
|
273 |
|
274 if (pause->rx_pause && pause->tx_pause) |
|
275 hw->fc = E1000_FC_FULL; |
|
276 else if (pause->rx_pause && !pause->tx_pause) |
|
277 hw->fc = E1000_FC_RX_PAUSE; |
|
278 else if (!pause->rx_pause && pause->tx_pause) |
|
279 hw->fc = E1000_FC_TX_PAUSE; |
|
280 else if (!pause->rx_pause && !pause->tx_pause) |
|
281 hw->fc = E1000_FC_NONE; |
|
282 |
|
283 hw->original_fc = hw->fc; |
|
284 |
|
285 if (adapter->fc_autoneg == AUTONEG_ENABLE) { |
|
286 if (netif_running(adapter->netdev)) { |
|
287 e1000_down(adapter); |
|
288 e1000_up(adapter); |
|
289 } else |
|
290 e1000_reset(adapter); |
|
291 } else |
|
292 retval = ((hw->media_type == e1000_media_type_fiber) ? |
|
293 e1000_setup_link(hw) : e1000_force_mac_fc(hw)); |
|
294 |
|
295 clear_bit(__E1000_RESETTING, &adapter->flags); |
|
296 return retval; |
|
297 } |
|
298 |
|
299 static u32 |
|
300 e1000_get_rx_csum(struct net_device *netdev) |
|
301 { |
|
302 struct e1000_adapter *adapter = netdev_priv(netdev); |
|
303 return adapter->rx_csum; |
|
304 } |
|
305 |
|
306 static int |
|
307 e1000_set_rx_csum(struct net_device *netdev, u32 data) |
|
308 { |
|
309 struct e1000_adapter *adapter = netdev_priv(netdev); |
|
310 |
|
311 if (adapter->ecdev) |
|
312 return -EBUSY; |
|
313 |
|
314 adapter->rx_csum = data; |
|
315 |
|
316 if (netif_running(netdev)) |
|
317 e1000_reinit_locked(adapter); |
|
318 else |
|
319 e1000_reset(adapter); |
|
320 return 0; |
|
321 } |
|
322 |
|
323 static u32 |
|
324 e1000_get_tx_csum(struct net_device *netdev) |
|
325 { |
|
326 return (netdev->features & NETIF_F_HW_CSUM) != 0; |
|
327 } |
|
328 |
|
329 static int |
|
330 e1000_set_tx_csum(struct net_device *netdev, u32 data) |
|
331 { |
|
332 struct e1000_adapter *adapter = netdev_priv(netdev); |
|
333 |
|
334 if (adapter->hw.mac_type < e1000_82543) { |
|
335 if (!data) |
|
336 return -EINVAL; |
|
337 return 0; |
|
338 } |
|
339 |
|
340 if (data) |
|
341 netdev->features |= NETIF_F_HW_CSUM; |
|
342 else |
|
343 netdev->features &= ~NETIF_F_HW_CSUM; |
|
344 |
|
345 return 0; |
|
346 } |
|
347 |
|
348 static int |
|
349 e1000_set_tso(struct net_device *netdev, u32 data) |
|
350 { |
|
351 struct e1000_adapter *adapter = netdev_priv(netdev); |
|
352 if ((adapter->hw.mac_type < e1000_82544) || |
|
353 (adapter->hw.mac_type == e1000_82547)) |
|
354 return data ? -EINVAL : 0; |
|
355 |
|
356 if (data) |
|
357 netdev->features |= NETIF_F_TSO; |
|
358 else |
|
359 netdev->features &= ~NETIF_F_TSO; |
|
360 |
|
361 if (data && (adapter->hw.mac_type > e1000_82547_rev_2)) |
|
362 netdev->features |= NETIF_F_TSO6; |
|
363 else |
|
364 netdev->features &= ~NETIF_F_TSO6; |
|
365 |
|
366 DPRINTK(PROBE, INFO, "TSO is %s\n", data ? "Enabled" : "Disabled"); |
|
367 adapter->tso_force = true; |
|
368 return 0; |
|
369 } |
|
370 |
|
371 static u32 |
|
372 e1000_get_msglevel(struct net_device *netdev) |
|
373 { |
|
374 struct e1000_adapter *adapter = netdev_priv(netdev); |
|
375 return adapter->msg_enable; |
|
376 } |
|
377 |
|
378 static void |
|
379 e1000_set_msglevel(struct net_device *netdev, u32 data) |
|
380 { |
|
381 struct e1000_adapter *adapter = netdev_priv(netdev); |
|
382 adapter->msg_enable = data; |
|
383 } |
|
384 |
|
385 static int |
|
386 e1000_get_regs_len(struct net_device *netdev) |
|
387 { |
|
388 #define E1000_REGS_LEN 32 |
|
389 return E1000_REGS_LEN * sizeof(u32); |
|
390 } |
|
391 |
|
392 static void |
|
393 e1000_get_regs(struct net_device *netdev, |
|
394 struct ethtool_regs *regs, void *p) |
|
395 { |
|
396 struct e1000_adapter *adapter = netdev_priv(netdev); |
|
397 struct e1000_hw *hw = &adapter->hw; |
|
398 u32 *regs_buff = p; |
|
399 u16 phy_data; |
|
400 |
|
401 memset(p, 0, E1000_REGS_LEN * sizeof(u32)); |
|
402 |
|
403 regs->version = (1 << 24) | (hw->revision_id << 16) | hw->device_id; |
|
404 |
|
405 regs_buff[0] = E1000_READ_REG(hw, CTRL); |
|
406 regs_buff[1] = E1000_READ_REG(hw, STATUS); |
|
407 |
|
408 regs_buff[2] = E1000_READ_REG(hw, RCTL); |
|
409 regs_buff[3] = E1000_READ_REG(hw, RDLEN); |
|
410 regs_buff[4] = E1000_READ_REG(hw, RDH); |
|
411 regs_buff[5] = E1000_READ_REG(hw, RDT); |
|
412 regs_buff[6] = E1000_READ_REG(hw, RDTR); |
|
413 |
|
414 regs_buff[7] = E1000_READ_REG(hw, TCTL); |
|
415 regs_buff[8] = E1000_READ_REG(hw, TDLEN); |
|
416 regs_buff[9] = E1000_READ_REG(hw, TDH); |
|
417 regs_buff[10] = E1000_READ_REG(hw, TDT); |
|
418 regs_buff[11] = E1000_READ_REG(hw, TIDV); |
|
419 |
|
420 regs_buff[12] = adapter->hw.phy_type; /* PHY type (IGP=1, M88=0) */ |
|
421 if (hw->phy_type == e1000_phy_igp) { |
|
422 e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT, |
|
423 IGP01E1000_PHY_AGC_A); |
|
424 e1000_read_phy_reg(hw, IGP01E1000_PHY_AGC_A & |
|
425 IGP01E1000_PHY_PAGE_SELECT, &phy_data); |
|
426 regs_buff[13] = (u32)phy_data; /* cable length */ |
|
427 e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT, |
|
428 IGP01E1000_PHY_AGC_B); |
|
429 e1000_read_phy_reg(hw, IGP01E1000_PHY_AGC_B & |
|
430 IGP01E1000_PHY_PAGE_SELECT, &phy_data); |
|
431 regs_buff[14] = (u32)phy_data; /* cable length */ |
|
432 e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT, |
|
433 IGP01E1000_PHY_AGC_C); |
|
434 e1000_read_phy_reg(hw, IGP01E1000_PHY_AGC_C & |
|
435 IGP01E1000_PHY_PAGE_SELECT, &phy_data); |
|
436 regs_buff[15] = (u32)phy_data; /* cable length */ |
|
437 e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT, |
|
438 IGP01E1000_PHY_AGC_D); |
|
439 e1000_read_phy_reg(hw, IGP01E1000_PHY_AGC_D & |
|
440 IGP01E1000_PHY_PAGE_SELECT, &phy_data); |
|
441 regs_buff[16] = (u32)phy_data; /* cable length */ |
|
442 regs_buff[17] = 0; /* extended 10bt distance (not needed) */ |
|
443 e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT, 0x0); |
|
444 e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_STATUS & |
|
445 IGP01E1000_PHY_PAGE_SELECT, &phy_data); |
|
446 regs_buff[18] = (u32)phy_data; /* cable polarity */ |
|
447 e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT, |
|
448 IGP01E1000_PHY_PCS_INIT_REG); |
|
449 e1000_read_phy_reg(hw, IGP01E1000_PHY_PCS_INIT_REG & |
|
450 IGP01E1000_PHY_PAGE_SELECT, &phy_data); |
|
451 regs_buff[19] = (u32)phy_data; /* cable polarity */ |
|
452 regs_buff[20] = 0; /* polarity correction enabled (always) */ |
|
453 regs_buff[22] = 0; /* phy receive errors (unavailable) */ |
|
454 regs_buff[23] = regs_buff[18]; /* mdix mode */ |
|
455 e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT, 0x0); |
|
456 } else { |
|
457 e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_STATUS, &phy_data); |
|
458 regs_buff[13] = (u32)phy_data; /* cable length */ |
|
459 regs_buff[14] = 0; /* Dummy (to align w/ IGP phy reg dump) */ |
|
460 regs_buff[15] = 0; /* Dummy (to align w/ IGP phy reg dump) */ |
|
461 regs_buff[16] = 0; /* Dummy (to align w/ IGP phy reg dump) */ |
|
462 e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data); |
|
463 regs_buff[17] = (u32)phy_data; /* extended 10bt distance */ |
|
464 regs_buff[18] = regs_buff[13]; /* cable polarity */ |
|
465 regs_buff[19] = 0; /* Dummy (to align w/ IGP phy reg dump) */ |
|
466 regs_buff[20] = regs_buff[17]; /* polarity correction */ |
|
467 /* phy receive errors */ |
|
468 regs_buff[22] = adapter->phy_stats.receive_errors; |
|
469 regs_buff[23] = regs_buff[13]; /* mdix mode */ |
|
470 } |
|
471 regs_buff[21] = adapter->phy_stats.idle_errors; /* phy idle errors */ |
|
472 e1000_read_phy_reg(hw, PHY_1000T_STATUS, &phy_data); |
|
473 regs_buff[24] = (u32)phy_data; /* phy local receiver status */ |
|
474 regs_buff[25] = regs_buff[24]; /* phy remote receiver status */ |
|
475 if (hw->mac_type >= e1000_82540 && |
|
476 hw->mac_type < e1000_82571 && |
|
477 hw->media_type == e1000_media_type_copper) { |
|
478 regs_buff[26] = E1000_READ_REG(hw, MANC); |
|
479 } |
|
480 } |
|
481 |
|
482 static int |
|
483 e1000_get_eeprom_len(struct net_device *netdev) |
|
484 { |
|
485 struct e1000_adapter *adapter = netdev_priv(netdev); |
|
486 return adapter->hw.eeprom.word_size * 2; |
|
487 } |
|
488 |
|
489 static int |
|
490 e1000_get_eeprom(struct net_device *netdev, |
|
491 struct ethtool_eeprom *eeprom, u8 *bytes) |
|
492 { |
|
493 struct e1000_adapter *adapter = netdev_priv(netdev); |
|
494 struct e1000_hw *hw = &adapter->hw; |
|
495 u16 *eeprom_buff; |
|
496 int first_word, last_word; |
|
497 int ret_val = 0; |
|
498 u16 i; |
|
499 |
|
500 if (eeprom->len == 0) |
|
501 return -EINVAL; |
|
502 |
|
503 eeprom->magic = hw->vendor_id | (hw->device_id << 16); |
|
504 |
|
505 first_word = eeprom->offset >> 1; |
|
506 last_word = (eeprom->offset + eeprom->len - 1) >> 1; |
|
507 |
|
508 eeprom_buff = kmalloc(sizeof(u16) * |
|
509 (last_word - first_word + 1), GFP_KERNEL); |
|
510 if (!eeprom_buff) |
|
511 return -ENOMEM; |
|
512 |
|
513 if (hw->eeprom.type == e1000_eeprom_spi) |
|
514 ret_val = e1000_read_eeprom(hw, first_word, |
|
515 last_word - first_word + 1, |
|
516 eeprom_buff); |
|
517 else { |
|
518 for (i = 0; i < last_word - first_word + 1; i++) |
|
519 if ((ret_val = e1000_read_eeprom(hw, first_word + i, 1, |
|
520 &eeprom_buff[i]))) |
|
521 break; |
|
522 } |
|
523 |
|
524 /* Device's eeprom is always little-endian, word addressable */ |
|
525 for (i = 0; i < last_word - first_word + 1; i++) |
|
526 le16_to_cpus(&eeprom_buff[i]); |
|
527 |
|
528 memcpy(bytes, (u8 *)eeprom_buff + (eeprom->offset & 1), |
|
529 eeprom->len); |
|
530 kfree(eeprom_buff); |
|
531 |
|
532 return ret_val; |
|
533 } |
|
534 |
|
535 static int |
|
536 e1000_set_eeprom(struct net_device *netdev, |
|
537 struct ethtool_eeprom *eeprom, u8 *bytes) |
|
538 { |
|
539 struct e1000_adapter *adapter = netdev_priv(netdev); |
|
540 struct e1000_hw *hw = &adapter->hw; |
|
541 u16 *eeprom_buff; |
|
542 void *ptr; |
|
543 int max_len, first_word, last_word, ret_val = 0; |
|
544 u16 i; |
|
545 |
|
546 if (eeprom->len == 0) |
|
547 return -EOPNOTSUPP; |
|
548 |
|
549 if (eeprom->magic != (hw->vendor_id | (hw->device_id << 16))) |
|
550 return -EFAULT; |
|
551 |
|
552 max_len = hw->eeprom.word_size * 2; |
|
553 |
|
554 first_word = eeprom->offset >> 1; |
|
555 last_word = (eeprom->offset + eeprom->len - 1) >> 1; |
|
556 eeprom_buff = kmalloc(max_len, GFP_KERNEL); |
|
557 if (!eeprom_buff) |
|
558 return -ENOMEM; |
|
559 |
|
560 ptr = (void *)eeprom_buff; |
|
561 |
|
562 if (eeprom->offset & 1) { |
|
563 /* need read/modify/write of first changed EEPROM word */ |
|
564 /* only the second byte of the word is being modified */ |
|
565 ret_val = e1000_read_eeprom(hw, first_word, 1, |
|
566 &eeprom_buff[0]); |
|
567 ptr++; |
|
568 } |
|
569 if (((eeprom->offset + eeprom->len) & 1) && (ret_val == 0)) { |
|
570 /* need read/modify/write of last changed EEPROM word */ |
|
571 /* only the first byte of the word is being modified */ |
|
572 ret_val = e1000_read_eeprom(hw, last_word, 1, |
|
573 &eeprom_buff[last_word - first_word]); |
|
574 } |
|
575 |
|
576 /* Device's eeprom is always little-endian, word addressable */ |
|
577 for (i = 0; i < last_word - first_word + 1; i++) |
|
578 le16_to_cpus(&eeprom_buff[i]); |
|
579 |
|
580 memcpy(ptr, bytes, eeprom->len); |
|
581 |
|
582 for (i = 0; i < last_word - first_word + 1; i++) |
|
583 eeprom_buff[i] = cpu_to_le16(eeprom_buff[i]); |
|
584 |
|
585 ret_val = e1000_write_eeprom(hw, first_word, |
|
586 last_word - first_word + 1, eeprom_buff); |
|
587 |
|
588 /* Update the checksum over the first part of the EEPROM if needed |
|
589 * and flush shadow RAM for 82573 conrollers */ |
|
590 if ((ret_val == 0) && ((first_word <= EEPROM_CHECKSUM_REG) || |
|
591 (hw->mac_type == e1000_82573))) |
|
592 e1000_update_eeprom_checksum(hw); |
|
593 |
|
594 kfree(eeprom_buff); |
|
595 return ret_val; |
|
596 } |
|
597 |
|
598 static void |
|
599 e1000_get_drvinfo(struct net_device *netdev, |
|
600 struct ethtool_drvinfo *drvinfo) |
|
601 { |
|
602 struct e1000_adapter *adapter = netdev_priv(netdev); |
|
603 char firmware_version[32]; |
|
604 u16 eeprom_data; |
|
605 |
|
606 strncpy(drvinfo->driver, e1000_driver_name, 32); |
|
607 strncpy(drvinfo->version, e1000_driver_version, 32); |
|
608 |
|
609 /* EEPROM image version # is reported as firmware version # for |
|
610 * 8257{1|2|3} controllers */ |
|
611 e1000_read_eeprom(&adapter->hw, 5, 1, &eeprom_data); |
|
612 switch (adapter->hw.mac_type) { |
|
613 case e1000_82571: |
|
614 case e1000_82572: |
|
615 case e1000_82573: |
|
616 case e1000_80003es2lan: |
|
617 case e1000_ich8lan: |
|
618 sprintf(firmware_version, "%d.%d-%d", |
|
619 (eeprom_data & 0xF000) >> 12, |
|
620 (eeprom_data & 0x0FF0) >> 4, |
|
621 eeprom_data & 0x000F); |
|
622 break; |
|
623 default: |
|
624 sprintf(firmware_version, "N/A"); |
|
625 } |
|
626 |
|
627 strncpy(drvinfo->fw_version, firmware_version, 32); |
|
628 strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 32); |
|
629 drvinfo->regdump_len = e1000_get_regs_len(netdev); |
|
630 drvinfo->eedump_len = e1000_get_eeprom_len(netdev); |
|
631 } |
|
632 |
|
633 static void |
|
634 e1000_get_ringparam(struct net_device *netdev, |
|
635 struct ethtool_ringparam *ring) |
|
636 { |
|
637 struct e1000_adapter *adapter = netdev_priv(netdev); |
|
638 e1000_mac_type mac_type = adapter->hw.mac_type; |
|
639 struct e1000_tx_ring *txdr = adapter->tx_ring; |
|
640 struct e1000_rx_ring *rxdr = adapter->rx_ring; |
|
641 |
|
642 ring->rx_max_pending = (mac_type < e1000_82544) ? E1000_MAX_RXD : |
|
643 E1000_MAX_82544_RXD; |
|
644 ring->tx_max_pending = (mac_type < e1000_82544) ? E1000_MAX_TXD : |
|
645 E1000_MAX_82544_TXD; |
|
646 ring->rx_mini_max_pending = 0; |
|
647 ring->rx_jumbo_max_pending = 0; |
|
648 ring->rx_pending = rxdr->count; |
|
649 ring->tx_pending = txdr->count; |
|
650 ring->rx_mini_pending = 0; |
|
651 ring->rx_jumbo_pending = 0; |
|
652 } |
|
653 |
|
654 static int |
|
655 e1000_set_ringparam(struct net_device *netdev, |
|
656 struct ethtool_ringparam *ring) |
|
657 { |
|
658 struct e1000_adapter *adapter = netdev_priv(netdev); |
|
659 e1000_mac_type mac_type = adapter->hw.mac_type; |
|
660 struct e1000_tx_ring *txdr, *tx_old; |
|
661 struct e1000_rx_ring *rxdr, *rx_old; |
|
662 int i, err; |
|
663 |
|
664 if (adapter->ecdev) |
|
665 return -EBUSY; |
|
666 |
|
667 if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending)) |
|
668 return -EINVAL; |
|
669 |
|
670 while (test_and_set_bit(__E1000_RESETTING, &adapter->flags)) |
|
671 msleep(1); |
|
672 |
|
673 if (netif_running(adapter->netdev)) |
|
674 e1000_down(adapter); |
|
675 |
|
676 tx_old = adapter->tx_ring; |
|
677 rx_old = adapter->rx_ring; |
|
678 |
|
679 err = -ENOMEM; |
|
680 txdr = kcalloc(adapter->num_tx_queues, sizeof(struct e1000_tx_ring), GFP_KERNEL); |
|
681 if (!txdr) |
|
682 goto err_alloc_tx; |
|
683 |
|
684 rxdr = kcalloc(adapter->num_rx_queues, sizeof(struct e1000_rx_ring), GFP_KERNEL); |
|
685 if (!rxdr) |
|
686 goto err_alloc_rx; |
|
687 |
|
688 adapter->tx_ring = txdr; |
|
689 adapter->rx_ring = rxdr; |
|
690 |
|
691 rxdr->count = max(ring->rx_pending,(u32)E1000_MIN_RXD); |
|
692 rxdr->count = min(rxdr->count,(u32)(mac_type < e1000_82544 ? |
|
693 E1000_MAX_RXD : E1000_MAX_82544_RXD)); |
|
694 rxdr->count = ALIGN(rxdr->count, REQ_RX_DESCRIPTOR_MULTIPLE); |
|
695 |
|
696 txdr->count = max(ring->tx_pending,(u32)E1000_MIN_TXD); |
|
697 txdr->count = min(txdr->count,(u32)(mac_type < e1000_82544 ? |
|
698 E1000_MAX_TXD : E1000_MAX_82544_TXD)); |
|
699 txdr->count = ALIGN(txdr->count, REQ_TX_DESCRIPTOR_MULTIPLE); |
|
700 |
|
701 for (i = 0; i < adapter->num_tx_queues; i++) |
|
702 txdr[i].count = txdr->count; |
|
703 for (i = 0; i < adapter->num_rx_queues; i++) |
|
704 rxdr[i].count = rxdr->count; |
|
705 |
|
706 if (netif_running(adapter->netdev)) { |
|
707 /* Try to get new resources before deleting old */ |
|
708 if ((err = e1000_setup_all_rx_resources(adapter))) |
|
709 goto err_setup_rx; |
|
710 if ((err = e1000_setup_all_tx_resources(adapter))) |
|
711 goto err_setup_tx; |
|
712 |
|
713 /* save the new, restore the old in order to free it, |
|
714 * then restore the new back again */ |
|
715 |
|
716 adapter->rx_ring = rx_old; |
|
717 adapter->tx_ring = tx_old; |
|
718 e1000_free_all_rx_resources(adapter); |
|
719 e1000_free_all_tx_resources(adapter); |
|
720 kfree(tx_old); |
|
721 kfree(rx_old); |
|
722 adapter->rx_ring = rxdr; |
|
723 adapter->tx_ring = txdr; |
|
724 if ((err = e1000_up(adapter))) |
|
725 goto err_setup; |
|
726 } |
|
727 |
|
728 clear_bit(__E1000_RESETTING, &adapter->flags); |
|
729 return 0; |
|
730 err_setup_tx: |
|
731 e1000_free_all_rx_resources(adapter); |
|
732 err_setup_rx: |
|
733 adapter->rx_ring = rx_old; |
|
734 adapter->tx_ring = tx_old; |
|
735 kfree(rxdr); |
|
736 err_alloc_rx: |
|
737 kfree(txdr); |
|
738 err_alloc_tx: |
|
739 e1000_up(adapter); |
|
740 err_setup: |
|
741 clear_bit(__E1000_RESETTING, &adapter->flags); |
|
742 return err; |
|
743 } |
|
744 |
|
745 static bool reg_pattern_test(struct e1000_adapter *adapter, u64 *data, |
|
746 int reg, u32 mask, u32 write) |
|
747 { |
|
748 static const u32 test[] = |
|
749 {0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF}; |
|
750 u8 __iomem *address = adapter->hw.hw_addr + reg; |
|
751 u32 read; |
|
752 int i; |
|
753 |
|
754 for (i = 0; i < ARRAY_SIZE(test); i++) { |
|
755 writel(write & test[i], address); |
|
756 read = readl(address); |
|
757 if (read != (write & test[i] & mask)) { |
|
758 DPRINTK(DRV, ERR, "pattern test reg %04X failed: " |
|
759 "got 0x%08X expected 0x%08X\n", |
|
760 reg, read, (write & test[i] & mask)); |
|
761 *data = reg; |
|
762 return true; |
|
763 } |
|
764 } |
|
765 return false; |
|
766 } |
|
767 |
|
768 static bool reg_set_and_check(struct e1000_adapter *adapter, u64 *data, |
|
769 int reg, u32 mask, u32 write) |
|
770 { |
|
771 u8 __iomem *address = adapter->hw.hw_addr + reg; |
|
772 u32 read; |
|
773 |
|
774 writel(write & mask, address); |
|
775 read = readl(address); |
|
776 if ((read & mask) != (write & mask)) { |
|
777 DPRINTK(DRV, ERR, "set/check reg %04X test failed: " |
|
778 "got 0x%08X expected 0x%08X\n", |
|
779 reg, (read & mask), (write & mask)); |
|
780 *data = reg; |
|
781 return true; |
|
782 } |
|
783 return false; |
|
784 } |
|
785 |
|
786 #define REG_PATTERN_TEST(reg, mask, write) \ |
|
787 do { \ |
|
788 if (reg_pattern_test(adapter, data, \ |
|
789 (adapter->hw.mac_type >= e1000_82543) \ |
|
790 ? E1000_##reg : E1000_82542_##reg, \ |
|
791 mask, write)) \ |
|
792 return 1; \ |
|
793 } while (0) |
|
794 |
|
795 #define REG_SET_AND_CHECK(reg, mask, write) \ |
|
796 do { \ |
|
797 if (reg_set_and_check(adapter, data, \ |
|
798 (adapter->hw.mac_type >= e1000_82543) \ |
|
799 ? E1000_##reg : E1000_82542_##reg, \ |
|
800 mask, write)) \ |
|
801 return 1; \ |
|
802 } while (0) |
|
803 |
|
804 static int |
|
805 e1000_reg_test(struct e1000_adapter *adapter, u64 *data) |
|
806 { |
|
807 u32 value, before, after; |
|
808 u32 i, toggle; |
|
809 |
|
810 /* The status register is Read Only, so a write should fail. |
|
811 * Some bits that get toggled are ignored. |
|
812 */ |
|
813 switch (adapter->hw.mac_type) { |
|
814 /* there are several bits on newer hardware that are r/w */ |
|
815 case e1000_82571: |
|
816 case e1000_82572: |
|
817 case e1000_80003es2lan: |
|
818 toggle = 0x7FFFF3FF; |
|
819 break; |
|
820 case e1000_82573: |
|
821 case e1000_ich8lan: |
|
822 toggle = 0x7FFFF033; |
|
823 break; |
|
824 default: |
|
825 toggle = 0xFFFFF833; |
|
826 break; |
|
827 } |
|
828 |
|
829 before = E1000_READ_REG(&adapter->hw, STATUS); |
|
830 value = (E1000_READ_REG(&adapter->hw, STATUS) & toggle); |
|
831 E1000_WRITE_REG(&adapter->hw, STATUS, toggle); |
|
832 after = E1000_READ_REG(&adapter->hw, STATUS) & toggle; |
|
833 if (value != after) { |
|
834 DPRINTK(DRV, ERR, "failed STATUS register test got: " |
|
835 "0x%08X expected: 0x%08X\n", after, value); |
|
836 *data = 1; |
|
837 return 1; |
|
838 } |
|
839 /* restore previous status */ |
|
840 E1000_WRITE_REG(&adapter->hw, STATUS, before); |
|
841 |
|
842 if (adapter->hw.mac_type != e1000_ich8lan) { |
|
843 REG_PATTERN_TEST(FCAL, 0xFFFFFFFF, 0xFFFFFFFF); |
|
844 REG_PATTERN_TEST(FCAH, 0x0000FFFF, 0xFFFFFFFF); |
|
845 REG_PATTERN_TEST(FCT, 0x0000FFFF, 0xFFFFFFFF); |
|
846 REG_PATTERN_TEST(VET, 0x0000FFFF, 0xFFFFFFFF); |
|
847 } |
|
848 |
|
849 REG_PATTERN_TEST(RDTR, 0x0000FFFF, 0xFFFFFFFF); |
|
850 REG_PATTERN_TEST(RDBAH, 0xFFFFFFFF, 0xFFFFFFFF); |
|
851 REG_PATTERN_TEST(RDLEN, 0x000FFF80, 0x000FFFFF); |
|
852 REG_PATTERN_TEST(RDH, 0x0000FFFF, 0x0000FFFF); |
|
853 REG_PATTERN_TEST(RDT, 0x0000FFFF, 0x0000FFFF); |
|
854 REG_PATTERN_TEST(FCRTH, 0x0000FFF8, 0x0000FFF8); |
|
855 REG_PATTERN_TEST(FCTTV, 0x0000FFFF, 0x0000FFFF); |
|
856 REG_PATTERN_TEST(TIPG, 0x3FFFFFFF, 0x3FFFFFFF); |
|
857 REG_PATTERN_TEST(TDBAH, 0xFFFFFFFF, 0xFFFFFFFF); |
|
858 REG_PATTERN_TEST(TDLEN, 0x000FFF80, 0x000FFFFF); |
|
859 |
|
860 REG_SET_AND_CHECK(RCTL, 0xFFFFFFFF, 0x00000000); |
|
861 |
|
862 before = (adapter->hw.mac_type == e1000_ich8lan ? |
|
863 0x06C3B33E : 0x06DFB3FE); |
|
864 REG_SET_AND_CHECK(RCTL, before, 0x003FFFFB); |
|
865 REG_SET_AND_CHECK(TCTL, 0xFFFFFFFF, 0x00000000); |
|
866 |
|
867 if (adapter->hw.mac_type >= e1000_82543) { |
|
868 |
|
869 REG_SET_AND_CHECK(RCTL, before, 0xFFFFFFFF); |
|
870 REG_PATTERN_TEST(RDBAL, 0xFFFFFFF0, 0xFFFFFFFF); |
|
871 if (adapter->hw.mac_type != e1000_ich8lan) |
|
872 REG_PATTERN_TEST(TXCW, 0xC000FFFF, 0x0000FFFF); |
|
873 REG_PATTERN_TEST(TDBAL, 0xFFFFFFF0, 0xFFFFFFFF); |
|
874 REG_PATTERN_TEST(TIDV, 0x0000FFFF, 0x0000FFFF); |
|
875 value = (adapter->hw.mac_type == e1000_ich8lan ? |
|
876 E1000_RAR_ENTRIES_ICH8LAN : E1000_RAR_ENTRIES); |
|
877 for (i = 0; i < value; i++) { |
|
878 REG_PATTERN_TEST(RA + (((i << 1) + 1) << 2), 0x8003FFFF, |
|
879 0xFFFFFFFF); |
|
880 } |
|
881 |
|
882 } else { |
|
883 |
|
884 REG_SET_AND_CHECK(RCTL, 0xFFFFFFFF, 0x01FFFFFF); |
|
885 REG_PATTERN_TEST(RDBAL, 0xFFFFF000, 0xFFFFFFFF); |
|
886 REG_PATTERN_TEST(TXCW, 0x0000FFFF, 0x0000FFFF); |
|
887 REG_PATTERN_TEST(TDBAL, 0xFFFFF000, 0xFFFFFFFF); |
|
888 |
|
889 } |
|
890 |
|
891 value = (adapter->hw.mac_type == e1000_ich8lan ? |
|
892 E1000_MC_TBL_SIZE_ICH8LAN : E1000_MC_TBL_SIZE); |
|
893 for (i = 0; i < value; i++) |
|
894 REG_PATTERN_TEST(MTA + (i << 2), 0xFFFFFFFF, 0xFFFFFFFF); |
|
895 |
|
896 *data = 0; |
|
897 return 0; |
|
898 } |
|
899 |
|
900 static int |
|
901 e1000_eeprom_test(struct e1000_adapter *adapter, u64 *data) |
|
902 { |
|
903 u16 temp; |
|
904 u16 checksum = 0; |
|
905 u16 i; |
|
906 |
|
907 *data = 0; |
|
908 /* Read and add up the contents of the EEPROM */ |
|
909 for (i = 0; i < (EEPROM_CHECKSUM_REG + 1); i++) { |
|
910 if ((e1000_read_eeprom(&adapter->hw, i, 1, &temp)) < 0) { |
|
911 *data = 1; |
|
912 break; |
|
913 } |
|
914 checksum += temp; |
|
915 } |
|
916 |
|
917 /* If Checksum is not Correct return error else test passed */ |
|
918 if ((checksum != (u16) EEPROM_SUM) && !(*data)) |
|
919 *data = 2; |
|
920 |
|
921 return *data; |
|
922 } |
|
923 |
|
924 static irqreturn_t |
|
925 e1000_test_intr(int irq, void *data) |
|
926 { |
|
927 struct net_device *netdev = (struct net_device *) data; |
|
928 struct e1000_adapter *adapter = netdev_priv(netdev); |
|
929 |
|
930 adapter->test_icr |= E1000_READ_REG(&adapter->hw, ICR); |
|
931 |
|
932 return IRQ_HANDLED; |
|
933 } |
|
934 |
|
935 static int |
|
936 e1000_intr_test(struct e1000_adapter *adapter, u64 *data) |
|
937 { |
|
938 struct net_device *netdev = adapter->netdev; |
|
939 u32 mask, i = 0; |
|
940 bool shared_int = true; |
|
941 u32 irq = adapter->pdev->irq; |
|
942 |
|
943 *data = 0; |
|
944 |
|
945 /* NOTE: we don't test MSI interrupts here, yet */ |
|
946 /* Hook up test interrupt handler just for this test */ |
|
947 if (!request_irq(irq, &e1000_test_intr, IRQF_PROBE_SHARED, netdev->name, |
|
948 netdev)) |
|
949 shared_int = false; |
|
950 else if (request_irq(irq, &e1000_test_intr, IRQF_SHARED, |
|
951 netdev->name, netdev)) { |
|
952 *data = 1; |
|
953 return -1; |
|
954 } |
|
955 DPRINTK(HW, INFO, "testing %s interrupt\n", |
|
956 (shared_int ? "shared" : "unshared")); |
|
957 |
|
958 /* Disable all the interrupts */ |
|
959 E1000_WRITE_REG(&adapter->hw, IMC, 0xFFFFFFFF); |
|
960 msleep(10); |
|
961 |
|
962 /* Test each interrupt */ |
|
963 for (; i < 10; i++) { |
|
964 |
|
965 if (adapter->hw.mac_type == e1000_ich8lan && i == 8) |
|
966 continue; |
|
967 |
|
968 /* Interrupt to test */ |
|
969 mask = 1 << i; |
|
970 |
|
971 if (!shared_int) { |
|
972 /* Disable the interrupt to be reported in |
|
973 * the cause register and then force the same |
|
974 * interrupt and see if one gets posted. If |
|
975 * an interrupt was posted to the bus, the |
|
976 * test failed. |
|
977 */ |
|
978 adapter->test_icr = 0; |
|
979 E1000_WRITE_REG(&adapter->hw, IMC, mask); |
|
980 E1000_WRITE_REG(&adapter->hw, ICS, mask); |
|
981 msleep(10); |
|
982 |
|
983 if (adapter->test_icr & mask) { |
|
984 *data = 3; |
|
985 break; |
|
986 } |
|
987 } |
|
988 |
|
989 /* Enable the interrupt to be reported in |
|
990 * the cause register and then force the same |
|
991 * interrupt and see if one gets posted. If |
|
992 * an interrupt was not posted to the bus, the |
|
993 * test failed. |
|
994 */ |
|
995 adapter->test_icr = 0; |
|
996 E1000_WRITE_REG(&adapter->hw, IMS, mask); |
|
997 E1000_WRITE_REG(&adapter->hw, ICS, mask); |
|
998 msleep(10); |
|
999 |
|
1000 if (!(adapter->test_icr & mask)) { |
|
1001 *data = 4; |
|
1002 break; |
|
1003 } |
|
1004 |
|
1005 if (!shared_int) { |
|
1006 /* Disable the other interrupts to be reported in |
|
1007 * the cause register and then force the other |
|
1008 * interrupts and see if any get posted. If |
|
1009 * an interrupt was posted to the bus, the |
|
1010 * test failed. |
|
1011 */ |
|
1012 adapter->test_icr = 0; |
|
1013 E1000_WRITE_REG(&adapter->hw, IMC, ~mask & 0x00007FFF); |
|
1014 E1000_WRITE_REG(&adapter->hw, ICS, ~mask & 0x00007FFF); |
|
1015 msleep(10); |
|
1016 |
|
1017 if (adapter->test_icr) { |
|
1018 *data = 5; |
|
1019 break; |
|
1020 } |
|
1021 } |
|
1022 } |
|
1023 |
|
1024 /* Disable all the interrupts */ |
|
1025 E1000_WRITE_REG(&adapter->hw, IMC, 0xFFFFFFFF); |
|
1026 msleep(10); |
|
1027 |
|
1028 /* Unhook test interrupt handler */ |
|
1029 free_irq(irq, netdev); |
|
1030 |
|
1031 return *data; |
|
1032 } |
|
1033 |
|
1034 static void |
|
1035 e1000_free_desc_rings(struct e1000_adapter *adapter) |
|
1036 { |
|
1037 struct e1000_tx_ring *txdr = &adapter->test_tx_ring; |
|
1038 struct e1000_rx_ring *rxdr = &adapter->test_rx_ring; |
|
1039 struct pci_dev *pdev = adapter->pdev; |
|
1040 int i; |
|
1041 |
|
1042 if (txdr->desc && txdr->buffer_info) { |
|
1043 for (i = 0; i < txdr->count; i++) { |
|
1044 if (txdr->buffer_info[i].dma) |
|
1045 pci_unmap_single(pdev, txdr->buffer_info[i]dma, |
|
1046 txdr->buffer_info[i].length, |
|
1047 PCI_DMA_TODEVICE); |
|
1048 if (txdr->buffer_info[i].skb) |
|
1049 dev_kfree_skb(txdr->buffer_info[i].skb); |
|
1050 } |
|
1051 } |
|
1052 |
|
1053 if (rxdr->desc && rxdr->buffer_info) { |
|
1054 for (i = 0; i < rxdr->count; i++) { |
|
1055 if (rxdr->buffer_info[i].dma) |
|
1056 pci_unmap_single(pdev, rxdr->buffer_info[i]dma, |
|
1057 rxdr->buffer_info[i].length, |
|
1058 PCI_DMA_FROMDEVICE); |
|
1059 if (rxdr->buffer_info[i].skb) |
|
1060 dev_kfree_skb(rxdr->buffer_info[i].skb); |
|
1061 } |
|
1062 } |
|
1063 |
|
1064 if (txdr->desc) { |
|
1065 pci_free_consistent(pdev, txdr->size, txdr->desc, txdr->dma); |
|
1066 txdr->desc = NULL; |
|
1067 } |
|
1068 if (rxdr->desc) { |
|
1069 pci_free_consistent(pdev, rxdr->size, rxdr->desc, rxdr->dma); |
|
1070 rxdr->desc = NULL; |
|
1071 } |
|
1072 |
|
1073 kfree(txdr->buffer_info); |
|
1074 txdr->buffer_info = NULL; |
|
1075 kfree(rxdr->buffer_info); |
|
1076 rxdr->buffer_info = NULL; |
|
1077 |
|
1078 return; |
|
1079 } |
|
1080 |
|
1081 static int |
|
1082 e1000_setup_desc_rings(struct e1000_adapter *adapter) |
|
1083 { |
|
1084 struct e1000_tx_ring *txdr = &adapter->test_tx_ring; |
|
1085 struct e1000_rx_ring *rxdr = &adapter->test_rx_ring; |
|
1086 struct pci_dev *pdev = adapter->pdev; |
|
1087 u32 rctl; |
|
1088 int i, ret_val; |
|
1089 |
|
1090 /* Setup Tx descriptor ring and Tx buffers */ |
|
1091 |
|
1092 if (!txdr->count) |
|
1093 txdr->count = E1000_DEFAULT_TXD; |
|
1094 |
|
1095 if (!(txdr->buffer_info = kcalloc(txdr->count, |
|
1096 sizeof(struct e1000_buffer), |
|
1097 GFP_KERNEL))) { |
|
1098 ret_val = 1; |
|
1099 goto err_nomem; |
|
1100 } |
|
1101 |
|
1102 txdr->size = txdr->count * sizeof(struct e1000_tx_desc); |
|
1103 txdr->size = ALIGN(txdr->size, 4096); |
|
1104 if (!(txdr->desc = pci_alloc_consistent(pdev, txdr->size, |
|
1105 &txdr->dma))) { |
|
1106 ret_val = 2; |
|
1107 goto err_nomem; |
|
1108 } |
|
1109 memset(txdr->desc, 0, txdr->size); |
|
1110 txdr->next_to_use = txdr->next_to_clean = 0; |
|
1111 |
|
1112 E1000_WRITE_REG(&adapter->hw, TDBAL, |
|
1113 ((u64) txdr->dma & 0x00000000FFFFFFFF)); |
|
1114 E1000_WRITE_REG(&adapter->hw, TDBAH, ((u64) txdr->dma >> 32)); |
|
1115 E1000_WRITE_REG(&adapter->hw, TDLEN, |
|
1116 txdr->count * sizeof(struct e1000_tx_desc)); |
|
1117 E1000_WRITE_REG(&adapter->hw, TDH, 0); |
|
1118 E1000_WRITE_REG(&adapter->hw, TDT, 0); |
|
1119 E1000_WRITE_REG(&adapter->hw, TCTL, |
|
1120 E1000_TCTL_PSP | E1000_TCTL_EN | |
|
1121 E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT | |
|
1122 E1000_FDX_COLLISION_DISTANCE << E1000_COLD_SHIFT); |
|
1123 |
|
1124 for (i = 0; i < txdr->count; i++) { |
|
1125 struct e1000_tx_desc *tx_desc = E1000_TX_DESC(*txdr, i); |
|
1126 struct sk_buff *skb; |
|
1127 unsigned int size = 1024; |
|
1128 |
|
1129 if (!(skb = alloc_skb(size, GFP_KERNEL))) { |
|
1130 ret_val = 3; |
|
1131 goto err_nomem; |
|
1132 } |
|
1133 skb_put(skb, size); |
|
1134 txdr->buffer_info[i].skb = skb; |
|
1135 txdr->buffer_info[i].length = skb->len; |
|
1136 txdr->buffer_info[i].dma = |
|
1137 pci_map_single(pdev, skb->data, skb->len, |
|
1138 PCI_DMA_TODEVICE); |
|
1139 tx_desc->buffer_addr = cpu_to_le64(txdr->buffer_info[i].dma); |
|
1140 tx_desc->lower.data = cpu_to_le32(skb->len); |
|
1141 tx_desc->lower.data |= cpu_to_le32(E1000_TXD_CMD_EOP | |
|
1142 E1000_TXD_CMD_IFCS | |
|
1143 E1000_TXD_CMD_RPS); |
|
1144 tx_desc->upper.data = 0; |
|
1145 } |
|
1146 |
|
1147 /* Setup Rx descriptor ring and Rx buffers */ |
|
1148 |
|
1149 if (!rxdr->count) |
|
1150 rxdr->count = E1000_DEFAULT_RXD; |
|
1151 |
|
1152 if (!(rxdr->buffer_info = kcalloc(rxdr->count, |
|
1153 sizeof(struct e1000_buffer), |
|
1154 GFP_KERNEL))) { |
|
1155 ret_val = 4; |
|
1156 goto err_nomem; |
|
1157 } |
|
1158 |
|
1159 rxdr->size = rxdr->count * sizeof(struct e1000_rx_desc); |
|
1160 if (!(rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma))) { |
|
1161 ret_val = 5; |
|
1162 goto err_nomem; |
|
1163 } |
|
1164 memset(rxdr->desc, 0, rxdr->size); |
|
1165 rxdr->next_to_use = rxdr->next_to_clean = 0; |
|
1166 |
|
1167 rctl = E1000_READ_REG(&adapter->hw, RCTL); |
|
1168 E1000_WRITE_REG(&adapter->hw, RCTL, rctl & ~E1000_RCTL_EN); |
|
1169 E1000_WRITE_REG(&adapter->hw, RDBAL, |
|
1170 ((u64) rxdr->dma & 0xFFFFFFFF)); |
|
1171 E1000_WRITE_REG(&adapter->hw, RDBAH, ((u64) rxdr->dma >> 32)); |
|
1172 E1000_WRITE_REG(&adapter->hw, RDLEN, rxdr->size); |
|
1173 E1000_WRITE_REG(&adapter->hw, RDH, 0); |
|
1174 E1000_WRITE_REG(&adapter->hw, RDT, 0); |
|
1175 rctl = E1000_RCTL_EN | E1000_RCTL_BAM | E1000_RCTL_SZ_2048 | |
|
1176 E1000_RCTL_LBM_NO | E1000_RCTL_RDMTS_HALF | |
|
1177 (adapter->hw.mc_filter_type << E1000_RCTL_MO_SHIFT); |
|
1178 E1000_WRITE_REG(&adapter->hw, RCTL, rctl); |
|
1179 |
|
1180 for (i = 0; i < rxdr->count; i++) { |
|
1181 struct e1000_rx_desc *rx_desc = E1000_RX_DESC(*rxdr, i); |
|
1182 struct sk_buff *skb; |
|
1183 |
|
1184 if (!(skb = alloc_skb(E1000_RXBUFFER_2048 + NET_IP_ALIGN, |
|
1185 GFP_KERNEL))) { |
|
1186 ret_val = 6; |
|
1187 goto err_nomem; |
|
1188 } |
|
1189 skb_reserve(skb, NET_IP_ALIGN); |
|
1190 rxdr->buffer_info[i].skb = skb; |
|
1191 rxdr->buffer_info[i].length = E1000_RXBUFFER_2048; |
|
1192 rxdr->buffer_info[i].dma = |
|
1193 pci_map_single(pdev, skb->data, E1000_RXBUFFER_2048, |
|
1194 PCI_DMA_FROMDEVICE); |
|
1195 rx_desc->buffer_addr = cpu_to_le64(rxdr->buffer_info[i].dma); |
|
1196 memset(skb->data, 0x00, skb->len); |
|
1197 } |
|
1198 |
|
1199 return 0; |
|
1200 |
|
1201 err_nomem: |
|
1202 e1000_free_desc_rings(adapter); |
|
1203 return ret_val; |
|
1204 } |
|
1205 |
|
1206 static void |
|
1207 e1000_phy_disable_receiver(struct e1000_adapter *adapter) |
|
1208 { |
|
1209 /* Write out to PHY registers 29 and 30 to disable the Receiver. */ |
|
1210 e1000_write_phy_reg(&adapter->hw, 29, 0x001F); |
|
1211 e1000_write_phy_reg(&adapter->hw, 30, 0x8FFC); |
|
1212 e1000_write_phy_reg(&adapter->hw, 29, 0x001A); |
|
1213 e1000_write_phy_reg(&adapter->hw, 30, 0x8FF0); |
|
1214 } |
|
1215 |
|
1216 static void |
|
1217 e1000_phy_reset_clk_and_crs(struct e1000_adapter *adapter) |
|
1218 { |
|
1219 u16 phy_reg; |
|
1220 |
|
1221 /* Because we reset the PHY above, we need to re-force TX_CLK in the |
|
1222 * Extended PHY Specific Control Register to 25MHz clock. This |
|
1223 * value defaults back to a 2.5MHz clock when the PHY is reset. |
|
1224 */ |
|
1225 e1000_read_phy_reg(&adapter->hw, M88E1000_EXT_PHY_SPEC_CTRL, &phy_reg); |
|
1226 phy_reg |= M88E1000_EPSCR_TX_CLK_25; |
|
1227 e1000_write_phy_reg(&adapter->hw, |
|
1228 M88E1000_EXT_PHY_SPEC_CTRL, phy_reg); |
|
1229 |
|
1230 /* In addition, because of the s/w reset above, we need to enable |
|
1231 * CRS on TX. This must be set for both full and half duplex |
|
1232 * operation. |
|
1233 */ |
|
1234 e1000_read_phy_reg(&adapter->hw, M88E1000_PHY_SPEC_CTRL, &phy_reg); |
|
1235 phy_reg |= M88E1000_PSCR_ASSERT_CRS_ON_TX; |
|
1236 e1000_write_phy_reg(&adapter->hw, |
|
1237 M88E1000_PHY_SPEC_CTRL, phy_reg); |
|
1238 } |
|
1239 |
|
1240 static int |
|
1241 e1000_nonintegrated_phy_loopback(struct e1000_adapter *adapter) |
|
1242 { |
|
1243 u32 ctrl_reg; |
|
1244 u16 phy_reg; |
|
1245 |
|
1246 /* Setup the Device Control Register for PHY loopback test. */ |
|
1247 |
|
1248 ctrl_reg = E1000_READ_REG(&adapter->hw, CTRL); |
|
1249 ctrl_reg |= (E1000_CTRL_ILOS | /* Invert Loss-Of-Signal */ |
|
1250 E1000_CTRL_FRCSPD | /* Set the Force Speed Bit */ |
|
1251 E1000_CTRL_FRCDPX | /* Set the Force Duplex Bit */ |
|
1252 E1000_CTRL_SPD_1000 | /* Force Speed to 1000 */ |
|
1253 E1000_CTRL_FD); /* Force Duplex to FULL */ |
|
1254 |
|
1255 E1000_WRITE_REG(&adapter->hw, CTRL, ctrl_reg); |
|
1256 |
|
1257 /* Read the PHY Specific Control Register (0x10) */ |
|
1258 e1000_read_phy_reg(&adapter->hw, M88E1000_PHY_SPEC_CTRL, &phy_reg); |
|
1259 |
|
1260 /* Clear Auto-Crossover bits in PHY Specific Control Register |
|
1261 * (bits 6:5). |
|
1262 */ |
|
1263 phy_reg &= ~M88E1000_PSCR_AUTO_X_MODE; |
|
1264 e1000_write_phy_reg(&adapter->hw, M88E1000_PHY_SPEC_CTRL, phy_reg); |
|
1265 |
|
1266 /* Perform software reset on the PHY */ |
|
1267 e1000_phy_reset(&adapter->hw); |
|
1268 |
|
1269 /* Have to setup TX_CLK and TX_CRS after software reset */ |
|
1270 e1000_phy_reset_clk_and_crs(adapter); |
|
1271 |
|
1272 e1000_write_phy_reg(&adapter->hw, PHY_CTRL, 0x8100); |
|
1273 |
|
1274 /* Wait for reset to complete. */ |
|
1275 udelay(500); |
|
1276 |
|
1277 /* Have to setup TX_CLK and TX_CRS after software reset */ |
|
1278 e1000_phy_reset_clk_and_crs(adapter); |
|
1279 |
|
1280 /* Write out to PHY registers 29 and 30 to disable the Receiver. */ |
|
1281 e1000_phy_disable_receiver(adapter); |
|
1282 |
|
1283 /* Set the loopback bit in the PHY control register. */ |
|
1284 e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &phy_reg); |
|
1285 phy_reg |= MII_CR_LOOPBACK; |
|
1286 e1000_write_phy_reg(&adapter->hw, PHY_CTRL, phy_reg); |
|
1287 |
|
1288 /* Setup TX_CLK and TX_CRS one more time. */ |
|
1289 e1000_phy_reset_clk_and_crs(adapter); |
|
1290 |
|
1291 /* Check Phy Configuration */ |
|
1292 e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &phy_reg); |
|
1293 if (phy_reg != 0x4100) |
|
1294 return 9; |
|
1295 |
|
1296 e1000_read_phy_reg(&adapter->hw, M88E1000_EXT_PHY_SPEC_CTRL, &phy_reg); |
|
1297 if (phy_reg != 0x0070) |
|
1298 return 10; |
|
1299 |
|
1300 e1000_read_phy_reg(&adapter->hw, 29, &phy_reg); |
|
1301 if (phy_reg != 0x001A) |
|
1302 return 11; |
|
1303 |
|
1304 return 0; |
|
1305 } |
|
1306 |
|
1307 static int |
|
1308 e1000_integrated_phy_loopback(struct e1000_adapter *adapter) |
|
1309 { |
|
1310 u32 ctrl_reg = 0; |
|
1311 u32 stat_reg = 0; |
|
1312 |
|
1313 adapter->hw.autoneg = false; |
|
1314 |
|
1315 if (adapter->hw.phy_type == e1000_phy_m88) { |
|
1316 /* Auto-MDI/MDIX Off */ |
|
1317 e1000_write_phy_reg(&adapter->hw, |
|
1318 M88E1000_PHY_SPEC_CTRL, 0x0808); |
|
1319 /* reset to update Auto-MDI/MDIX */ |
|
1320 e1000_write_phy_reg(&adapter->hw, PHY_CTRL, 0x9140); |
|
1321 /* autoneg off */ |
|
1322 e1000_write_phy_reg(&adapter->hw, PHY_CTRL, 0x8140); |
|
1323 } else if (adapter->hw.phy_type == e1000_phy_gg82563) |
|
1324 e1000_write_phy_reg(&adapter->hw, |
|
1325 GG82563_PHY_KMRN_MODE_CTRL, |
|
1326 0x1CC); |
|
1327 |
|
1328 ctrl_reg = E1000_READ_REG(&adapter->hw, CTRL); |
|
1329 |
|
1330 if (adapter->hw.phy_type == e1000_phy_ife) { |
|
1331 /* force 100, set loopback */ |
|
1332 e1000_write_phy_reg(&adapter->hw, PHY_CTRL, 0x6100); |
|
1333 |
|
1334 /* Now set up the MAC to the same speed/duplex as the PHY. */ |
|
1335 ctrl_reg &= ~E1000_CTRL_SPD_SEL; /* Clear the speed sel bits */ |
|
1336 ctrl_reg |= (E1000_CTRL_FRCSPD | /* Set the Force Speed Bit */ |
|
1337 E1000_CTRL_FRCDPX | /* Set the Force Duplex Bit */ |
|
1338 E1000_CTRL_SPD_100 |/* Force Speed to 100 */ |
|
1339 E1000_CTRL_FD); /* Force Duplex to FULL */ |
|
1340 } else { |
|
1341 /* force 1000, set loopback */ |
|
1342 e1000_write_phy_reg(&adapter->hw, PHY_CTRL, 0x4140); |
|
1343 |
|
1344 /* Now set up the MAC to the same speed/duplex as the PHY. */ |
|
1345 ctrl_reg = E1000_READ_REG(&adapter->hw, CTRL); |
|
1346 ctrl_reg &= ~E1000_CTRL_SPD_SEL; /* Clear the speed sel bits */ |
|
1347 ctrl_reg |= (E1000_CTRL_FRCSPD | /* Set the Force Speed Bit */ |
|
1348 E1000_CTRL_FRCDPX | /* Set the Force Duplex Bit */ |
|
1349 E1000_CTRL_SPD_1000 |/* Force Speed to 1000 */ |
|
1350 E1000_CTRL_FD); /* Force Duplex to FULL */ |
|
1351 } |
|
1352 |
|
1353 if (adapter->hw.media_type == e1000_media_type_copper && |
|
1354 adapter->hw.phy_type == e1000_phy_m88) |
|
1355 ctrl_reg |= E1000_CTRL_ILOS; /* Invert Loss of Signal */ |
|
1356 else { |
|
1357 /* Set the ILOS bit on the fiber Nic is half |
|
1358 * duplex link is detected. */ |
|
1359 stat_reg = E1000_READ_REG(&adapter->hw, STATUS); |
|
1360 if ((stat_reg & E1000_STATUS_FD) == 0) |
|
1361 ctrl_reg |= (E1000_CTRL_ILOS | E1000_CTRL_SLU); |
|
1362 } |
|
1363 |
|
1364 E1000_WRITE_REG(&adapter->hw, CTRL, ctrl_reg); |
|
1365 |
|
1366 /* Disable the receiver on the PHY so when a cable is plugged in, the |
|
1367 * PHY does not begin to autoneg when a cable is reconnected to the NIC. |
|
1368 */ |
|
1369 if (adapter->hw.phy_type == e1000_phy_m88) |
|
1370 e1000_phy_disable_receiver(adapter); |
|
1371 |
|
1372 udelay(500); |
|
1373 |
|
1374 return 0; |
|
1375 } |
|
1376 |
|
1377 static int |
|
1378 e1000_set_phy_loopback(struct e1000_adapter *adapter) |
|
1379 { |
|
1380 u16 phy_reg = 0; |
|
1381 u16 count = 0; |
|
1382 |
|
1383 switch (adapter->hw.mac_type) { |
|
1384 case e1000_82543: |
|
1385 if (adapter->hw.media_type == e1000_media_type_copper) { |
|
1386 /* Attempt to setup Loopback mode on Non-integrated PHY. |
|
1387 * Some PHY registers get corrupted at random, so |
|
1388 * attempt this 10 times. |
|
1389 */ |
|
1390 while (e1000_nonintegrated_phy_loopback(adapter) && |
|
1391 count++ < 10); |
|
1392 if (count < 11) |
|
1393 return 0; |
|
1394 } |
|
1395 break; |
|
1396 |
|
1397 case e1000_82544: |
|
1398 case e1000_82540: |
|
1399 case e1000_82545: |
|
1400 case e1000_82545_rev_3: |
|
1401 case e1000_82546: |
|
1402 case e1000_82546_rev_3: |
|
1403 case e1000_82541: |
|
1404 case e1000_82541_rev_2: |
|
1405 case e1000_82547: |
|
1406 case e1000_82547_rev_2: |
|
1407 case e1000_82571: |
|
1408 case e1000_82572: |
|
1409 case e1000_82573: |
|
1410 case e1000_80003es2lan: |
|
1411 case e1000_ich8lan: |
|
1412 return e1000_integrated_phy_loopback(adapter); |
|
1413 break; |
|
1414 |
|
1415 default: |
|
1416 /* Default PHY loopback work is to read the MII |
|
1417 * control register and assert bit 14 (loopback mode). |
|
1418 */ |
|
1419 e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &phy_reg); |
|
1420 phy_reg |= MII_CR_LOOPBACK; |
|
1421 e1000_write_phy_reg(&adapter->hw, PHY_CTRL, phy_reg); |
|
1422 return 0; |
|
1423 break; |
|
1424 } |
|
1425 |
|
1426 return 8; |
|
1427 } |
|
1428 |
|
1429 static int |
|
1430 e1000_setup_loopback_test(struct e1000_adapter *adapter) |
|
1431 { |
|
1432 struct e1000_hw *hw = &adapter->hw; |
|
1433 u32 rctl; |
|
1434 |
|
1435 if (hw->media_type == e1000_media_type_fiber || |
|
1436 hw->media_type == e1000_media_type_internal_serdes) { |
|
1437 switch (hw->mac_type) { |
|
1438 case e1000_82545: |
|
1439 case e1000_82546: |
|
1440 case e1000_82545_rev_3: |
|
1441 case e1000_82546_rev_3: |
|
1442 return e1000_set_phy_loopback(adapter); |
|
1443 break; |
|
1444 case e1000_82571: |
|
1445 case e1000_82572: |
|
1446 #define E1000_SERDES_LB_ON 0x410 |
|
1447 e1000_set_phy_loopback(adapter); |
|
1448 E1000_WRITE_REG(hw, SCTL, E1000_SERDES_LB_ON); |
|
1449 msleep(10); |
|
1450 return 0; |
|
1451 break; |
|
1452 default: |
|
1453 rctl = E1000_READ_REG(hw, RCTL); |
|
1454 rctl |= E1000_RCTL_LBM_TCVR; |
|
1455 E1000_WRITE_REG(hw, RCTL, rctl); |
|
1456 return 0; |
|
1457 } |
|
1458 } else if (hw->media_type == e1000_media_type_copper) |
|
1459 return e1000_set_phy_loopback(adapter); |
|
1460 |
|
1461 return 7; |
|
1462 } |
|
1463 |
|
1464 static void |
|
1465 e1000_loopback_cleanup(struct e1000_adapter *adapter) |
|
1466 { |
|
1467 struct e1000_hw *hw = &adapter->hw; |
|
1468 u32 rctl; |
|
1469 u16 phy_reg; |
|
1470 |
|
1471 rctl = E1000_READ_REG(hw, RCTL); |
|
1472 rctl &= ~(E1000_RCTL_LBM_TCVR | E1000_RCTL_LBM_MAC); |
|
1473 E1000_WRITE_REG(hw, RCTL, rctl); |
|
1474 |
|
1475 switch (hw->mac_type) { |
|
1476 case e1000_82571: |
|
1477 case e1000_82572: |
|
1478 if (hw->media_type == e1000_media_type_fiber || |
|
1479 hw->media_type == e1000_media_type_internal_serdes) { |
|
1480 #define E1000_SERDES_LB_OFF 0x400 |
|
1481 E1000_WRITE_REG(hw, SCTL, E1000_SERDES_LB_OFF); |
|
1482 msleep(10); |
|
1483 break; |
|
1484 } |
|
1485 /* Fall Through */ |
|
1486 case e1000_82545: |
|
1487 case e1000_82546: |
|
1488 case e1000_82545_rev_3: |
|
1489 case e1000_82546_rev_3: |
|
1490 default: |
|
1491 hw->autoneg = true; |
|
1492 if (hw->phy_type == e1000_phy_gg82563) |
|
1493 e1000_write_phy_reg(hw, |
|
1494 GG82563_PHY_KMRN_MODE_CTRL, |
|
1495 0x180); |
|
1496 e1000_read_phy_reg(hw, PHY_CTRL, &phy_reg); |
|
1497 if (phy_reg & MII_CR_LOOPBACK) { |
|
1498 phy_reg &= ~MII_CR_LOOPBACK; |
|
1499 e1000_write_phy_reg(hw, PHY_CTRL, phy_reg); |
|
1500 e1000_phy_reset(hw); |
|
1501 } |
|
1502 break; |
|
1503 } |
|
1504 } |
|
1505 |
|
1506 static void |
|
1507 e1000_create_lbtest_frame(struct sk_buff *skb, unsigned int frame_size) |
|
1508 { |
|
1509 memset(skb->data, 0xFF, frame_size); |
|
1510 frame_size &= ~1; |
|
1511 memset(&skb->data[frame_size / 2], 0xAA, frame_size / 2 - 1); |
|
1512 memset(&skb->data[frame_size / 2 + 10], 0xBE, 1); |
|
1513 memset(&skb->data[frame_size / 2 + 12], 0xAF, 1); |
|
1514 } |
|
1515 |
|
1516 static int |
|
1517 e1000_check_lbtest_frame(struct sk_buff *skb, unsigned int frame_size) |
|
1518 { |
|
1519 frame_size &= ~1; |
|
1520 if (*(skb->data + 3) == 0xFF) { |
|
1521 if ((*(skb->data + frame_size / 2 + 10) == 0xBE) && |
|
1522 (*(skb->data + frame_size / 2 + 12) == 0xAF)) { |
|
1523 return 0; |
|
1524 } |
|
1525 } |
|
1526 return 13; |
|
1527 } |
|
1528 |
|
1529 static int |
|
1530 e1000_run_loopback_test(struct e1000_adapter *adapter) |
|
1531 { |
|
1532 struct e1000_tx_ring *txdr = &adapter->test_tx_ring; |
|
1533 struct e1000_rx_ring *rxdr = &adapter->test_rx_ring; |
|
1534 struct pci_dev *pdev = adapter->pdev; |
|
1535 int i, j, k, l, lc, good_cnt, ret_val=0; |
|
1536 unsigned long time; |
|
1537 |
|
1538 E1000_WRITE_REG(&adapter->hw, RDT, rxdr->count - 1); |
|
1539 |
|
1540 /* Calculate the loop count based on the largest descriptor ring |
|
1541 * The idea is to wrap the largest ring a number of times using 64 |
|
1542 * send/receive pairs during each loop |
|
1543 */ |
|
1544 |
|
1545 if (rxdr->count <= txdr->count) |
|
1546 lc = ((txdr->count / 64) * 2) + 1; |
|
1547 else |
|
1548 lc = ((rxdr->count / 64) * 2) + 1; |
|
1549 |
|
1550 k = l = 0; |
|
1551 for (j = 0; j <= lc; j++) { /* loop count loop */ |
|
1552 for (i = 0; i < 64; i++) { /* send the packets */ |
|
1553 e1000_create_lbtest_frame(txdr->buffer_info[i].skb, |
|
1554 1024); |
|
1555 pci_dma_sync_single_for_device(pdev, |
|
1556 txdr->buffer_info[k].dma, |
|
1557 txdr->buffer_info[k].length, |
|
1558 PCI_DMA_TODEVICE); |
|
1559 if (unlikely(++k == txdr->count)) k = 0; |
|
1560 } |
|
1561 E1000_WRITE_REG(&adapter->hw, TDT, k); |
|
1562 msleep(200); |
|
1563 time = jiffies; /* set the start time for the receive */ |
|
1564 good_cnt = 0; |
|
1565 do { /* receive the sent packets */ |
|
1566 pci_dma_sync_single_for_cpu(pdev, |
|
1567 rxdr->buffer_info[l].dma, |
|
1568 rxdr->buffer_info[l].length, |
|
1569 PCI_DMA_FROMDEVICE); |
|
1570 |
|
1571 ret_val = e1000_check_lbtest_frame( |
|
1572 rxdr->buffer_info[l].skb, |
|
1573 1024); |
|
1574 if (!ret_val) |
|
1575 good_cnt++; |
|
1576 if (unlikely(++l == rxdr->count)) l = 0; |
|
1577 /* time + 20 msecs (200 msecs on 2.4) is more than |
|
1578 * enough time to complete the receives, if it's |
|
1579 * exceeded, break and error off |
|
1580 */ |
|
1581 } while (good_cnt < 64 && jiffies < (time + 20)); |
|
1582 if (good_cnt != 64) { |
|
1583 ret_val = 13; /* ret_val is the same as mis-compare */ |
|
1584 break; |
|
1585 } |
|
1586 if (jiffies >= (time + 2)) { |
|
1587 ret_val = 14; /* error code for time out error */ |
|
1588 break; |
|
1589 } |
|
1590 } /* end loop count loop */ |
|
1591 return ret_val; |
|
1592 } |
|
1593 |
|
1594 static int |
|
1595 e1000_loopback_test(struct e1000_adapter *adapter, u64 *data) |
|
1596 { |
|
1597 /* PHY loopback cannot be performed if SoL/IDER |
|
1598 * sessions are active */ |
|
1599 if (e1000_check_phy_reset_block(&adapter->hw)) { |
|
1600 DPRINTK(DRV, ERR, "Cannot do PHY loopback test " |
|
1601 "when SoL/IDER is active.\n"); |
|
1602 *data = 0; |
|
1603 goto out; |
|
1604 } |
|
1605 |
|
1606 if ((*data = e1000_setup_desc_rings(adapter))) |
|
1607 goto out; |
|
1608 if ((*data = e1000_setup_loopback_test(adapter))) |
|
1609 goto err_loopback; |
|
1610 *data = e1000_run_loopback_test(adapter); |
|
1611 e1000_loopback_cleanup(adapter); |
|
1612 |
|
1613 err_loopback: |
|
1614 e1000_free_desc_rings(adapter); |
|
1615 out: |
|
1616 return *data; |
|
1617 } |
|
1618 |
|
1619 static int |
|
1620 e1000_link_test(struct e1000_adapter *adapter, u64 *data) |
|
1621 { |
|
1622 *data = 0; |
|
1623 if (adapter->hw.media_type == e1000_media_type_internal_serdes) { |
|
1624 int i = 0; |
|
1625 adapter->hw.serdes_link_down = true; |
|
1626 |
|
1627 /* On some blade server designs, link establishment |
|
1628 * could take as long as 2-3 minutes */ |
|
1629 do { |
|
1630 e1000_check_for_link(&adapter->hw); |
|
1631 if (!adapter->hw.serdes_link_down) |
|
1632 return *data; |
|
1633 msleep(20); |
|
1634 } while (i++ < 3750); |
|
1635 |
|
1636 *data = 1; |
|
1637 } else { |
|
1638 e1000_check_for_link(&adapter->hw); |
|
1639 if (adapter->hw.autoneg) /* if auto_neg is set wait for it */ |
|
1640 msleep(4000); |
|
1641 |
|
1642 if (!(E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_LU)) { |
|
1643 *data = 1; |
|
1644 } |
|
1645 } |
|
1646 return *data; |
|
1647 } |
|
1648 |
|
1649 static int |
|
1650 e1000_get_sset_count(struct net_device *netdev, int sset) |
|
1651 { |
|
1652 switch (sset) { |
|
1653 case ETH_SS_TEST: |
|
1654 return E1000_TEST_LEN; |
|
1655 case ETH_SS_STATS: |
|
1656 return E1000_STATS_LEN; |
|
1657 default: |
|
1658 return -EOPNOTSUPP; |
|
1659 } |
|
1660 } |
|
1661 |
|
1662 static void |
|
1663 e1000_diag_test(struct net_device *netdev, |
|
1664 struct ethtool_test *eth_test, u64 *data) |
|
1665 { |
|
1666 struct e1000_adapter *adapter = netdev_priv(netdev); |
|
1667 bool if_running; |
|
1668 |
|
1669 if (adapter->ecdev) |
|
1670 return; |
|
1671 |
|
1672 if_running = netif_running(netdev); |
|
1673 |
|
1674 set_bit(__E1000_TESTING, &adapter->flags); |
|
1675 if (eth_test->flags == ETH_TEST_FL_OFFLINE) { |
|
1676 /* Offline tests */ |
|
1677 |
|
1678 /* save speed, duplex, autoneg settings */ |
|
1679 u16 autoneg_advertised = adapter->hw.autoneg_advertised; |
|
1680 u8 forced_speed_duplex = adapter->hw.forced_speed_duplex; |
|
1681 u8 autoneg = adapter->hw.autoneg; |
|
1682 |
|
1683 DPRINTK(HW, INFO, "offline testing starting\n"); |
|
1684 |
|
1685 /* Link test performed before hardware reset so autoneg doesn't |
|
1686 * interfere with test result */ |
|
1687 if (e1000_link_test(adapter, &data[4])) |
|
1688 eth_test->flags |= ETH_TEST_FL_FAILED; |
|
1689 |
|
1690 if (if_running) |
|
1691 /* indicate we're in test mode */ |
|
1692 dev_close(netdev); |
|
1693 else |
|
1694 e1000_reset(adapter); |
|
1695 |
|
1696 if (e1000_reg_test(adapter, &data[0])) |
|
1697 eth_test->flags |= ETH_TEST_FL_FAILED; |
|
1698 |
|
1699 e1000_reset(adapter); |
|
1700 if (e1000_eeprom_test(adapter, &data[1])) |
|
1701 eth_test->flags |= ETH_TEST_FL_FAILED; |
|
1702 |
|
1703 e1000_reset(adapter); |
|
1704 if (e1000_intr_test(adapter, &data[2])) |
|
1705 eth_test->flags |= ETH_TEST_FL_FAILED; |
|
1706 |
|
1707 e1000_reset(adapter); |
|
1708 /* make sure the phy is powered up */ |
|
1709 e1000_power_up_phy(adapter); |
|
1710 if (e1000_loopback_test(adapter, &data[3])) |
|
1711 eth_test->flags |= ETH_TEST_FL_FAILED; |
|
1712 |
|
1713 /* restore speed, duplex, autoneg settings */ |
|
1714 adapter->hw.autoneg_advertised = autoneg_advertised; |
|
1715 adapter->hw.forced_speed_duplex = forced_speed_duplex; |
|
1716 adapter->hw.autoneg = autoneg; |
|
1717 |
|
1718 e1000_reset(adapter); |
|
1719 clear_bit(__E1000_TESTING, &adapter->flags); |
|
1720 if (if_running) |
|
1721 dev_open(netdev); |
|
1722 } else { |
|
1723 DPRINTK(HW, INFO, "online testing starting\n"); |
|
1724 /* Online tests */ |
|
1725 if (e1000_link_test(adapter, &data[4])) |
|
1726 eth_test->flags |= ETH_TEST_FL_FAILED; |
|
1727 |
|
1728 /* Online tests aren't run; pass by default */ |
|
1729 data[0] = 0; |
|
1730 data[1] = 0; |
|
1731 data[2] = 0; |
|
1732 data[3] = 0; |
|
1733 |
|
1734 clear_bit(__E1000_TESTING, &adapter->flags); |
|
1735 } |
|
1736 msleep_interruptible(4 * 1000); |
|
1737 } |
|
1738 |
|
1739 static int e1000_wol_exclusion(struct e1000_adapter *adapter, struct ethtool_wolinfo *wol) |
|
1740 { |
|
1741 struct e1000_hw *hw = &adapter->hw; |
|
1742 int retval = 1; /* fail by default */ |
|
1743 |
|
1744 switch (hw->device_id) { |
|
1745 case E1000_DEV_ID_82542: |
|
1746 case E1000_DEV_ID_82543GC_FIBER: |
|
1747 case E1000_DEV_ID_82543GC_COPPER: |
|
1748 case E1000_DEV_ID_82544EI_FIBER: |
|
1749 case E1000_DEV_ID_82546EB_QUAD_COPPER: |
|
1750 case E1000_DEV_ID_82545EM_FIBER: |
|
1751 case E1000_DEV_ID_82545EM_COPPER: |
|
1752 case E1000_DEV_ID_82546GB_QUAD_COPPER: |
|
1753 case E1000_DEV_ID_82546GB_PCIE: |
|
1754 case E1000_DEV_ID_82571EB_SERDES_QUAD: |
|
1755 /* these don't support WoL at all */ |
|
1756 wol->supported = 0; |
|
1757 break; |
|
1758 case E1000_DEV_ID_82546EB_FIBER: |
|
1759 case E1000_DEV_ID_82546GB_FIBER: |
|
1760 case E1000_DEV_ID_82571EB_FIBER: |
|
1761 case E1000_DEV_ID_82571EB_SERDES: |
|
1762 case E1000_DEV_ID_82571EB_COPPER: |
|
1763 /* Wake events not supported on port B */ |
|
1764 if (E1000_READ_REG(hw, STATUS) & E1000_STATUS_FUNC_1) { |
|
1765 wol->supported = 0; |
|
1766 break; |
|
1767 } |
|
1768 /* return success for non excluded adapter ports */ |
|
1769 retval = 0; |
|
1770 break; |
|
1771 case E1000_DEV_ID_82571EB_QUAD_COPPER: |
|
1772 case E1000_DEV_ID_82571EB_QUAD_FIBER: |
|
1773 case E1000_DEV_ID_82571EB_QUAD_COPPER_LOWPROFILE: |
|
1774 case E1000_DEV_ID_82571PT_QUAD_COPPER: |
|
1775 case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3: |
|
1776 /* quad port adapters only support WoL on port A */ |
|
1777 if (!adapter->quad_port_a) { |
|
1778 wol->supported = 0; |
|
1779 break; |
|
1780 } |
|
1781 /* return success for non excluded adapter ports */ |
|
1782 retval = 0; |
|
1783 break; |
|
1784 default: |
|
1785 /* dual port cards only support WoL on port A from now on |
|
1786 * unless it was enabled in the eeprom for port B |
|
1787 * so exclude FUNC_1 ports from having WoL enabled */ |
|
1788 if (E1000_READ_REG(hw, STATUS) & E1000_STATUS_FUNC_1 && |
|
1789 !adapter->eeprom_wol) { |
|
1790 wol->supported = 0; |
|
1791 break; |
|
1792 } |
|
1793 |
|
1794 retval = 0; |
|
1795 } |
|
1796 |
|
1797 return retval; |
|
1798 } |
|
1799 |
|
1800 static void |
|
1801 e1000_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) |
|
1802 { |
|
1803 struct e1000_adapter *adapter = netdev_priv(netdev); |
|
1804 |
|
1805 wol->supported = WAKE_UCAST | WAKE_MCAST | |
|
1806 WAKE_BCAST | WAKE_MAGIC; |
|
1807 wol->wolopts = 0; |
|
1808 |
|
1809 /* this function will set ->supported = 0 and return 1 if wol is not |
|
1810 * supported by this hardware */ |
|
1811 if (e1000_wol_exclusion(adapter, wol)) |
|
1812 return; |
|
1813 |
|
1814 /* apply any specific unsupported masks here */ |
|
1815 switch (adapter->hw.device_id) { |
|
1816 case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3: |
|
1817 /* KSP3 does not suppport UCAST wake-ups */ |
|
1818 wol->supported &= ~WAKE_UCAST; |
|
1819 |
|
1820 if (adapter->wol & E1000_WUFC_EX) |
|
1821 DPRINTK(DRV, ERR, "Interface does not support " |
|
1822 "directed (unicast) frame wake-up packets\n"); |
|
1823 break; |
|
1824 default: |
|
1825 break; |
|
1826 } |
|
1827 |
|
1828 if (adapter->wol & E1000_WUFC_EX) |
|
1829 wol->wolopts |= WAKE_UCAST; |
|
1830 if (adapter->wol & E1000_WUFC_MC) |
|
1831 wol->wolopts |= WAKE_MCAST; |
|
1832 if (adapter->wol & E1000_WUFC_BC) |
|
1833 wol->wolopts |= WAKE_BCAST; |
|
1834 if (adapter->wol & E1000_WUFC_MAG) |
|
1835 wol->wolopts |= WAKE_MAGIC; |
|
1836 |
|
1837 return; |
|
1838 } |
|
1839 |
|
1840 static int |
|
1841 e1000_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) |
|
1842 { |
|
1843 struct e1000_adapter *adapter = netdev_priv(netdev); |
|
1844 struct e1000_hw *hw = &adapter->hw; |
|
1845 |
|
1846 if (wol->wolopts & (WAKE_PHY | WAKE_ARP | WAKE_MAGICSECURE)) |
|
1847 return -EOPNOTSUPP; |
|
1848 |
|
1849 if (e1000_wol_exclusion(adapter, wol)) |
|
1850 return wol->wolopts ? -EOPNOTSUPP : 0; |
|
1851 |
|
1852 switch (hw->device_id) { |
|
1853 case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3: |
|
1854 if (wol->wolopts & WAKE_UCAST) { |
|
1855 DPRINTK(DRV, ERR, "Interface does not support " |
|
1856 "directed (unicast) frame wake-up packets\n"); |
|
1857 return -EOPNOTSUPP; |
|
1858 } |
|
1859 break; |
|
1860 default: |
|
1861 break; |
|
1862 } |
|
1863 |
|
1864 /* these settings will always override what we currently have */ |
|
1865 adapter->wol = 0; |
|
1866 |
|
1867 if (wol->wolopts & WAKE_UCAST) |
|
1868 adapter->wol |= E1000_WUFC_EX; |
|
1869 if (wol->wolopts & WAKE_MCAST) |
|
1870 adapter->wol |= E1000_WUFC_MC; |
|
1871 if (wol->wolopts & WAKE_BCAST) |
|
1872 adapter->wol |= E1000_WUFC_BC; |
|
1873 if (wol->wolopts & WAKE_MAGIC) |
|
1874 adapter->wol |= E1000_WUFC_MAG; |
|
1875 |
|
1876 return 0; |
|
1877 } |
|
1878 |
|
1879 /* toggle LED 4 times per second = 2 "blinks" per second */ |
|
1880 #define E1000_ID_INTERVAL (HZ/4) |
|
1881 |
|
1882 /* bit defines for adapter->led_status */ |
|
1883 #define E1000_LED_ON 0 |
|
1884 |
|
1885 static void |
|
1886 e1000_led_blink_callback(unsigned long data) |
|
1887 { |
|
1888 struct e1000_adapter *adapter = (struct e1000_adapter *) data; |
|
1889 |
|
1890 if (test_and_change_bit(E1000_LED_ON, &adapter->led_status)) |
|
1891 e1000_led_off(&adapter->hw); |
|
1892 else |
|
1893 e1000_led_on(&adapter->hw); |
|
1894 |
|
1895 mod_timer(&adapter->blink_timer, jiffies + E1000_ID_INTERVAL); |
|
1896 } |
|
1897 |
|
1898 static int |
|
1899 e1000_phys_id(struct net_device *netdev, u32 data) |
|
1900 { |
|
1901 struct e1000_adapter *adapter = netdev_priv(netdev); |
|
1902 |
|
1903 if (!data) |
|
1904 data = INT_MAX; |
|
1905 |
|
1906 if (adapter->hw.mac_type < e1000_82571) { |
|
1907 if (!adapter->blink_timer.function) { |
|
1908 init_timer(&adapter->blink_timer); |
|
1909 adapter->blink_timer.function = e1000_led_blink_callback; |
|
1910 adapter->blink_timer.data = (unsigned long) adapter; |
|
1911 } |
|
1912 e1000_setup_led(&adapter->hw); |
|
1913 mod_timer(&adapter->blink_timer, jiffies); |
|
1914 msleep_interruptible(data * 1000); |
|
1915 del_timer_sync(&adapter->blink_timer); |
|
1916 } else if (adapter->hw.phy_type == e1000_phy_ife) { |
|
1917 if (!adapter->blink_timer.function) { |
|
1918 init_timer(&adapter->blink_timer); |
|
1919 adapter->blink_timer.function = e1000_led_blink_callback; |
|
1920 adapter->blink_timer.data = (unsigned long) adapter; |
|
1921 } |
|
1922 mod_timer(&adapter->blink_timer, jiffies); |
|
1923 msleep_interruptible(data * 1000); |
|
1924 del_timer_sync(&adapter->blink_timer); |
|
1925 e1000_write_phy_reg(&(adapter->hw), IFE_PHY_SPECIAL_CONTROL_LED, 0); |
|
1926 } else { |
|
1927 e1000_blink_led_start(&adapter->hw); |
|
1928 msleep_interruptible(data * 1000); |
|
1929 } |
|
1930 |
|
1931 e1000_led_off(&adapter->hw); |
|
1932 clear_bit(E1000_LED_ON, &adapter->led_status); |
|
1933 e1000_cleanup_led(&adapter->hw); |
|
1934 |
|
1935 return 0; |
|
1936 } |
|
1937 |
|
1938 static int |
|
1939 e1000_nway_reset(struct net_device *netdev) |
|
1940 { |
|
1941 struct e1000_adapter *adapter = netdev_priv(netdev); |
|
1942 |
|
1943 if (adapter->ecdev) |
|
1944 return -EBUSY; |
|
1945 |
|
1946 if (netif_running(netdev)) |
|
1947 e1000_reinit_locked(adapter); |
|
1948 return 0; |
|
1949 } |
|
1950 |
|
1951 static void |
|
1952 e1000_get_ethtool_stats(struct net_device *netdev, |
|
1953 struct ethtool_stats *stats, u64 *data) |
|
1954 { |
|
1955 struct e1000_adapter *adapter = netdev_priv(netdev); |
|
1956 int i; |
|
1957 |
|
1958 e1000_update_stats(adapter); |
|
1959 for (i = 0; i < E1000_GLOBAL_STATS_LEN; i++) { |
|
1960 char *p = (char *)adapter+e1000_gstrings_stats[i].stat_offset; |
|
1961 data[i] = (e1000_gstrings_stats[i].sizeof_stat == |
|
1962 sizeof(u64)) ? *(u64 *)p : *(u32 *)p; |
|
1963 } |
|
1964 /* BUG_ON(i != E1000_STATS_LEN); */ |
|
1965 } |
|
1966 |
|
1967 static void |
|
1968 e1000_get_strings(struct net_device *netdev, u32 stringset, u8 *data) |
|
1969 { |
|
1970 u8 *p = data; |
|
1971 int i; |
|
1972 |
|
1973 switch (stringset) { |
|
1974 case ETH_SS_TEST: |
|
1975 memcpy(data, *e1000_gstrings_test, |
|
1976 sizeof(e1000_gstrings_test)); |
|
1977 break; |
|
1978 case ETH_SS_STATS: |
|
1979 for (i = 0; i < E1000_GLOBAL_STATS_LEN; i++) { |
|
1980 memcpy(p, e1000_gstrings_stats[i].stat_string, |
|
1981 ETH_GSTRING_LEN); |
|
1982 p += ETH_GSTRING_LEN; |
|
1983 } |
|
1984 /* BUG_ON(p - data != E1000_STATS_LEN * ETH_GSTRING_LEN); */ |
|
1985 break; |
|
1986 } |
|
1987 } |
|
1988 |
|
1989 static const struct ethtool_ops e1000_ethtool_ops = { |
|
1990 .get_settings = e1000_get_settings, |
|
1991 .set_settings = e1000_set_settings, |
|
1992 .get_drvinfo = e1000_get_drvinfo, |
|
1993 .get_regs_len = e1000_get_regs_len, |
|
1994 .get_regs = e1000_get_regs, |
|
1995 .get_wol = e1000_get_wol, |
|
1996 .set_wol = e1000_set_wol, |
|
1997 .get_msglevel = e1000_get_msglevel, |
|
1998 .set_msglevel = e1000_set_msglevel, |
|
1999 .nway_reset = e1000_nway_reset, |
|
2000 .get_link = ethtool_op_get_link, |
|
2001 .get_eeprom_len = e1000_get_eeprom_len, |
|
2002 .get_eeprom = e1000_get_eeprom, |
|
2003 .set_eeprom = e1000_set_eeprom, |
|
2004 .get_ringparam = e1000_get_ringparam, |
|
2005 .set_ringparam = e1000_set_ringparam, |
|
2006 .get_pauseparam = e1000_get_pauseparam, |
|
2007 .set_pauseparam = e1000_set_pauseparam, |
|
2008 .get_rx_csum = e1000_get_rx_csum, |
|
2009 .set_rx_csum = e1000_set_rx_csum, |
|
2010 .get_tx_csum = e1000_get_tx_csum, |
|
2011 .set_tx_csum = e1000_set_tx_csum, |
|
2012 .set_sg = ethtool_op_set_sg, |
|
2013 .set_tso = e1000_set_tso, |
|
2014 .self_test = e1000_diag_test, |
|
2015 .get_strings = e1000_get_strings, |
|
2016 .phys_id = e1000_phys_id, |
|
2017 .get_ethtool_stats = e1000_get_ethtool_stats, |
|
2018 .get_sset_count = e1000_get_sset_count, |
|
2019 }; |
|
2020 |
|
2021 void e1000_set_ethtool_ops(struct net_device *netdev) |
|
2022 { |
|
2023 SET_ETHTOOL_OPS(netdev, &e1000_ethtool_ops); |
|
2024 } |