|
1 /******************************************************************************* |
|
2 |
|
3 Intel PRO/1000 Linux driver |
|
4 Copyright(c) 1999 - 2009 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 <linux/netdevice.h> |
|
32 #include <linux/ethtool.h> |
|
33 #include <linux/pci.h> |
|
34 #include <linux/slab.h> |
|
35 #include <linux/delay.h> |
|
36 |
|
37 #include "e1000-2.6.35-ethercat.h" |
|
38 |
|
39 enum {NETDEV_STATS, E1000_STATS}; |
|
40 |
|
41 struct e1000_stats { |
|
42 char stat_string[ETH_GSTRING_LEN]; |
|
43 int type; |
|
44 int sizeof_stat; |
|
45 int stat_offset; |
|
46 }; |
|
47 |
|
48 #define E1000_STAT(m) E1000_STATS, \ |
|
49 sizeof(((struct e1000_adapter *)0)->m), \ |
|
50 offsetof(struct e1000_adapter, m) |
|
51 #define E1000_NETDEV_STAT(m) NETDEV_STATS, \ |
|
52 sizeof(((struct net_device *)0)->m), \ |
|
53 offsetof(struct net_device, m) |
|
54 |
|
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.gorc) }, |
|
59 { "tx_bytes", E1000_STAT(stats.gotc) }, |
|
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_NETDEV_STAT(stats.rx_errors) }, |
|
65 { "tx_errors", E1000_NETDEV_STAT(stats.tx_errors) }, |
|
66 { "tx_dropped", E1000_NETDEV_STAT(stats.tx_dropped) }, |
|
67 { "multicast", E1000_STAT(stats.mprc) }, |
|
68 { "collisions", E1000_STAT(stats.colc) }, |
|
69 { "rx_length_errors", E1000_NETDEV_STAT(stats.rx_length_errors) }, |
|
70 { "rx_over_errors", E1000_NETDEV_STAT(stats.rx_over_errors) }, |
|
71 { "rx_crc_errors", E1000_STAT(stats.crcerrs) }, |
|
72 { "rx_frame_errors", E1000_NETDEV_STAT(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_NETDEV_STAT(stats.tx_fifo_errors) }, |
|
78 { "tx_heartbeat_errors", E1000_NETDEV_STAT(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.gorc) }, |
|
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 { "rx_dma_failed", E1000_STAT(rx_dma_failed) }, |
|
104 { "tx_dma_failed", E1000_STAT(tx_dma_failed) }, |
|
105 }; |
|
106 |
|
107 #define E1000_GLOBAL_STATS_LEN ARRAY_SIZE(e1000_gstrings_stats) |
|
108 #define E1000_STATS_LEN (E1000_GLOBAL_STATS_LEN) |
|
109 static const char e1000_gstrings_test[][ETH_GSTRING_LEN] = { |
|
110 "Register test (offline)", "Eeprom test (offline)", |
|
111 "Interrupt test (offline)", "Loopback test (offline)", |
|
112 "Link test (on/offline)" |
|
113 }; |
|
114 #define E1000_TEST_LEN ARRAY_SIZE(e1000_gstrings_test) |
|
115 |
|
116 static int e1000_get_settings(struct net_device *netdev, |
|
117 struct ethtool_cmd *ecmd) |
|
118 { |
|
119 struct e1000_adapter *adapter = netdev_priv(netdev); |
|
120 struct e1000_hw *hw = &adapter->hw; |
|
121 u32 status; |
|
122 |
|
123 if (hw->phy.media_type == e1000_media_type_copper) { |
|
124 |
|
125 ecmd->supported = (SUPPORTED_10baseT_Half | |
|
126 SUPPORTED_10baseT_Full | |
|
127 SUPPORTED_100baseT_Half | |
|
128 SUPPORTED_100baseT_Full | |
|
129 SUPPORTED_1000baseT_Full | |
|
130 SUPPORTED_Autoneg | |
|
131 SUPPORTED_TP); |
|
132 if (hw->phy.type == e1000_phy_ife) |
|
133 ecmd->supported &= ~SUPPORTED_1000baseT_Full; |
|
134 ecmd->advertising = ADVERTISED_TP; |
|
135 |
|
136 if (hw->mac.autoneg == 1) { |
|
137 ecmd->advertising |= ADVERTISED_Autoneg; |
|
138 /* the e1000 autoneg seems to match ethtool nicely */ |
|
139 ecmd->advertising |= hw->phy.autoneg_advertised; |
|
140 } |
|
141 |
|
142 ecmd->port = PORT_TP; |
|
143 ecmd->phy_address = hw->phy.addr; |
|
144 ecmd->transceiver = XCVR_INTERNAL; |
|
145 |
|
146 } else { |
|
147 ecmd->supported = (SUPPORTED_1000baseT_Full | |
|
148 SUPPORTED_FIBRE | |
|
149 SUPPORTED_Autoneg); |
|
150 |
|
151 ecmd->advertising = (ADVERTISED_1000baseT_Full | |
|
152 ADVERTISED_FIBRE | |
|
153 ADVERTISED_Autoneg); |
|
154 |
|
155 ecmd->port = PORT_FIBRE; |
|
156 ecmd->transceiver = XCVR_EXTERNAL; |
|
157 } |
|
158 |
|
159 status = er32(STATUS); |
|
160 if (status & E1000_STATUS_LU) { |
|
161 if (status & E1000_STATUS_SPEED_1000) |
|
162 ecmd->speed = 1000; |
|
163 else if (status & E1000_STATUS_SPEED_100) |
|
164 ecmd->speed = 100; |
|
165 else |
|
166 ecmd->speed = 10; |
|
167 |
|
168 if (status & E1000_STATUS_FD) |
|
169 ecmd->duplex = DUPLEX_FULL; |
|
170 else |
|
171 ecmd->duplex = DUPLEX_HALF; |
|
172 } else { |
|
173 ecmd->speed = -1; |
|
174 ecmd->duplex = -1; |
|
175 } |
|
176 |
|
177 ecmd->autoneg = ((hw->phy.media_type == e1000_media_type_fiber) || |
|
178 hw->mac.autoneg) ? AUTONEG_ENABLE : AUTONEG_DISABLE; |
|
179 |
|
180 /* MDI-X => 2; MDI =>1; Invalid =>0 */ |
|
181 if ((hw->phy.media_type == e1000_media_type_copper) && |
|
182 !hw->mac.get_link_status) |
|
183 ecmd->eth_tp_mdix = hw->phy.is_mdix ? ETH_TP_MDI_X : |
|
184 ETH_TP_MDI; |
|
185 else |
|
186 ecmd->eth_tp_mdix = ETH_TP_MDI_INVALID; |
|
187 |
|
188 return 0; |
|
189 } |
|
190 |
|
191 static u32 e1000_get_link(struct net_device *netdev) |
|
192 { |
|
193 struct e1000_adapter *adapter = netdev_priv(netdev); |
|
194 struct e1000_mac_info *mac = &adapter->hw.mac; |
|
195 |
|
196 /* |
|
197 * If the link is not reported up to netdev, interrupts are disabled, |
|
198 * and so the physical link state may have changed since we last |
|
199 * looked. Set get_link_status to make sure that the true link |
|
200 * state is interrogated, rather than pulling a cached and possibly |
|
201 * stale link state from the driver. |
|
202 */ |
|
203 if (!netif_carrier_ok(netdev)) |
|
204 mac->get_link_status = 1; |
|
205 |
|
206 return e1000e_has_link(adapter); |
|
207 } |
|
208 |
|
209 static int e1000_set_spd_dplx(struct e1000_adapter *adapter, u16 spddplx) |
|
210 { |
|
211 struct e1000_mac_info *mac = &adapter->hw.mac; |
|
212 |
|
213 mac->autoneg = 0; |
|
214 |
|
215 /* Fiber NICs only allow 1000 gbps Full duplex */ |
|
216 if ((adapter->hw.phy.media_type == e1000_media_type_fiber) && |
|
217 spddplx != (SPEED_1000 + DUPLEX_FULL)) { |
|
218 e_err("Unsupported Speed/Duplex configuration\n"); |
|
219 return -EINVAL; |
|
220 } |
|
221 |
|
222 switch (spddplx) { |
|
223 case SPEED_10 + DUPLEX_HALF: |
|
224 mac->forced_speed_duplex = ADVERTISE_10_HALF; |
|
225 break; |
|
226 case SPEED_10 + DUPLEX_FULL: |
|
227 mac->forced_speed_duplex = ADVERTISE_10_FULL; |
|
228 break; |
|
229 case SPEED_100 + DUPLEX_HALF: |
|
230 mac->forced_speed_duplex = ADVERTISE_100_HALF; |
|
231 break; |
|
232 case SPEED_100 + DUPLEX_FULL: |
|
233 mac->forced_speed_duplex = ADVERTISE_100_FULL; |
|
234 break; |
|
235 case SPEED_1000 + DUPLEX_FULL: |
|
236 mac->autoneg = 1; |
|
237 adapter->hw.phy.autoneg_advertised = ADVERTISE_1000_FULL; |
|
238 break; |
|
239 case SPEED_1000 + DUPLEX_HALF: /* not supported */ |
|
240 default: |
|
241 e_err("Unsupported Speed/Duplex configuration\n"); |
|
242 return -EINVAL; |
|
243 } |
|
244 return 0; |
|
245 } |
|
246 |
|
247 static int e1000_set_settings(struct net_device *netdev, |
|
248 struct ethtool_cmd *ecmd) |
|
249 { |
|
250 struct e1000_adapter *adapter = netdev_priv(netdev); |
|
251 struct e1000_hw *hw = &adapter->hw; |
|
252 |
|
253 if (adapter->ecdev) |
|
254 return -EBUSY; |
|
255 |
|
256 /* |
|
257 * When SoL/IDER sessions are active, autoneg/speed/duplex |
|
258 * cannot be changed |
|
259 */ |
|
260 if (e1000_check_reset_block(hw)) { |
|
261 e_err("Cannot change link characteristics when SoL/IDER is " |
|
262 "active.\n"); |
|
263 return -EINVAL; |
|
264 } |
|
265 |
|
266 while (test_and_set_bit(__E1000_RESETTING, &adapter->state)) |
|
267 msleep(1); |
|
268 |
|
269 if (ecmd->autoneg == AUTONEG_ENABLE) { |
|
270 hw->mac.autoneg = 1; |
|
271 if (hw->phy.media_type == e1000_media_type_fiber) |
|
272 hw->phy.autoneg_advertised = ADVERTISED_1000baseT_Full | |
|
273 ADVERTISED_FIBRE | |
|
274 ADVERTISED_Autoneg; |
|
275 else |
|
276 hw->phy.autoneg_advertised = ecmd->advertising | |
|
277 ADVERTISED_TP | |
|
278 ADVERTISED_Autoneg; |
|
279 ecmd->advertising = hw->phy.autoneg_advertised; |
|
280 if (adapter->fc_autoneg) |
|
281 hw->fc.requested_mode = e1000_fc_default; |
|
282 } else { |
|
283 if (e1000_set_spd_dplx(adapter, ecmd->speed + ecmd->duplex)) { |
|
284 clear_bit(__E1000_RESETTING, &adapter->state); |
|
285 return -EINVAL; |
|
286 } |
|
287 } |
|
288 |
|
289 /* reset the link */ |
|
290 |
|
291 if (netif_running(adapter->netdev)) { |
|
292 e1000e_down(adapter); |
|
293 e1000e_up(adapter); |
|
294 } else { |
|
295 e1000e_reset(adapter); |
|
296 } |
|
297 |
|
298 clear_bit(__E1000_RESETTING, &adapter->state); |
|
299 return 0; |
|
300 } |
|
301 |
|
302 static void e1000_get_pauseparam(struct net_device *netdev, |
|
303 struct ethtool_pauseparam *pause) |
|
304 { |
|
305 struct e1000_adapter *adapter = netdev_priv(netdev); |
|
306 struct e1000_hw *hw = &adapter->hw; |
|
307 |
|
308 pause->autoneg = |
|
309 (adapter->fc_autoneg ? AUTONEG_ENABLE : AUTONEG_DISABLE); |
|
310 |
|
311 if (hw->fc.current_mode == e1000_fc_rx_pause) { |
|
312 pause->rx_pause = 1; |
|
313 } else if (hw->fc.current_mode == e1000_fc_tx_pause) { |
|
314 pause->tx_pause = 1; |
|
315 } else if (hw->fc.current_mode == e1000_fc_full) { |
|
316 pause->rx_pause = 1; |
|
317 pause->tx_pause = 1; |
|
318 } |
|
319 } |
|
320 |
|
321 static int e1000_set_pauseparam(struct net_device *netdev, |
|
322 struct ethtool_pauseparam *pause) |
|
323 { |
|
324 struct e1000_adapter *adapter = netdev_priv(netdev); |
|
325 struct e1000_hw *hw = &adapter->hw; |
|
326 int retval = 0; |
|
327 |
|
328 if (adapter->ecdev) |
|
329 return -EBUSY; |
|
330 |
|
331 adapter->fc_autoneg = pause->autoneg; |
|
332 |
|
333 while (test_and_set_bit(__E1000_RESETTING, &adapter->state)) |
|
334 msleep(1); |
|
335 |
|
336 if (adapter->fc_autoneg == AUTONEG_ENABLE) { |
|
337 hw->fc.requested_mode = e1000_fc_default; |
|
338 if (netif_running(adapter->netdev)) { |
|
339 e1000e_down(adapter); |
|
340 e1000e_up(adapter); |
|
341 } else { |
|
342 e1000e_reset(adapter); |
|
343 } |
|
344 } else { |
|
345 if (pause->rx_pause && pause->tx_pause) |
|
346 hw->fc.requested_mode = e1000_fc_full; |
|
347 else if (pause->rx_pause && !pause->tx_pause) |
|
348 hw->fc.requested_mode = e1000_fc_rx_pause; |
|
349 else if (!pause->rx_pause && pause->tx_pause) |
|
350 hw->fc.requested_mode = e1000_fc_tx_pause; |
|
351 else if (!pause->rx_pause && !pause->tx_pause) |
|
352 hw->fc.requested_mode = e1000_fc_none; |
|
353 |
|
354 hw->fc.current_mode = hw->fc.requested_mode; |
|
355 |
|
356 if (hw->phy.media_type == e1000_media_type_fiber) { |
|
357 retval = hw->mac.ops.setup_link(hw); |
|
358 /* implicit goto out */ |
|
359 } else { |
|
360 retval = e1000e_force_mac_fc(hw); |
|
361 if (retval) |
|
362 goto out; |
|
363 e1000e_set_fc_watermarks(hw); |
|
364 } |
|
365 } |
|
366 |
|
367 out: |
|
368 clear_bit(__E1000_RESETTING, &adapter->state); |
|
369 return retval; |
|
370 } |
|
371 |
|
372 static u32 e1000_get_rx_csum(struct net_device *netdev) |
|
373 { |
|
374 struct e1000_adapter *adapter = netdev_priv(netdev); |
|
375 return (adapter->flags & FLAG_RX_CSUM_ENABLED); |
|
376 } |
|
377 |
|
378 static int e1000_set_rx_csum(struct net_device *netdev, u32 data) |
|
379 { |
|
380 struct e1000_adapter *adapter = netdev_priv(netdev); |
|
381 |
|
382 if (adapter->ecdev) |
|
383 return -EBUSY; |
|
384 |
|
385 if (data) |
|
386 adapter->flags |= FLAG_RX_CSUM_ENABLED; |
|
387 else |
|
388 adapter->flags &= ~FLAG_RX_CSUM_ENABLED; |
|
389 |
|
390 if (netif_running(netdev)) |
|
391 e1000e_reinit_locked(adapter); |
|
392 else |
|
393 e1000e_reset(adapter); |
|
394 return 0; |
|
395 } |
|
396 |
|
397 static u32 e1000_get_tx_csum(struct net_device *netdev) |
|
398 { |
|
399 return ((netdev->features & NETIF_F_HW_CSUM) != 0); |
|
400 } |
|
401 |
|
402 static int e1000_set_tx_csum(struct net_device *netdev, u32 data) |
|
403 { |
|
404 if (data) |
|
405 netdev->features |= NETIF_F_HW_CSUM; |
|
406 else |
|
407 netdev->features &= ~NETIF_F_HW_CSUM; |
|
408 |
|
409 return 0; |
|
410 } |
|
411 |
|
412 static int e1000_set_tso(struct net_device *netdev, u32 data) |
|
413 { |
|
414 struct e1000_adapter *adapter = netdev_priv(netdev); |
|
415 |
|
416 if (data) { |
|
417 netdev->features |= NETIF_F_TSO; |
|
418 netdev->features |= NETIF_F_TSO6; |
|
419 } else { |
|
420 netdev->features &= ~NETIF_F_TSO; |
|
421 netdev->features &= ~NETIF_F_TSO6; |
|
422 } |
|
423 |
|
424 adapter->flags |= FLAG_TSO_FORCE; |
|
425 return 0; |
|
426 } |
|
427 |
|
428 static u32 e1000_get_msglevel(struct net_device *netdev) |
|
429 { |
|
430 struct e1000_adapter *adapter = netdev_priv(netdev); |
|
431 return adapter->msg_enable; |
|
432 } |
|
433 |
|
434 static void e1000_set_msglevel(struct net_device *netdev, u32 data) |
|
435 { |
|
436 struct e1000_adapter *adapter = netdev_priv(netdev); |
|
437 adapter->msg_enable = data; |
|
438 } |
|
439 |
|
440 static int e1000_get_regs_len(struct net_device *netdev) |
|
441 { |
|
442 #define E1000_REGS_LEN 32 /* overestimate */ |
|
443 return E1000_REGS_LEN * sizeof(u32); |
|
444 } |
|
445 |
|
446 static void e1000_get_regs(struct net_device *netdev, |
|
447 struct ethtool_regs *regs, void *p) |
|
448 { |
|
449 struct e1000_adapter *adapter = netdev_priv(netdev); |
|
450 struct e1000_hw *hw = &adapter->hw; |
|
451 u32 *regs_buff = p; |
|
452 u16 phy_data; |
|
453 u8 revision_id; |
|
454 |
|
455 memset(p, 0, E1000_REGS_LEN * sizeof(u32)); |
|
456 |
|
457 pci_read_config_byte(adapter->pdev, PCI_REVISION_ID, &revision_id); |
|
458 |
|
459 regs->version = (1 << 24) | (revision_id << 16) | adapter->pdev->device; |
|
460 |
|
461 regs_buff[0] = er32(CTRL); |
|
462 regs_buff[1] = er32(STATUS); |
|
463 |
|
464 regs_buff[2] = er32(RCTL); |
|
465 regs_buff[3] = er32(RDLEN); |
|
466 regs_buff[4] = er32(RDH); |
|
467 regs_buff[5] = er32(RDT); |
|
468 regs_buff[6] = er32(RDTR); |
|
469 |
|
470 regs_buff[7] = er32(TCTL); |
|
471 regs_buff[8] = er32(TDLEN); |
|
472 regs_buff[9] = er32(TDH); |
|
473 regs_buff[10] = er32(TDT); |
|
474 regs_buff[11] = er32(TIDV); |
|
475 |
|
476 regs_buff[12] = adapter->hw.phy.type; /* PHY type (IGP=1, M88=0) */ |
|
477 |
|
478 /* ethtool doesn't use anything past this point, so all this |
|
479 * code is likely legacy junk for apps that may or may not |
|
480 * exist */ |
|
481 if (hw->phy.type == e1000_phy_m88) { |
|
482 e1e_rphy(hw, M88E1000_PHY_SPEC_STATUS, &phy_data); |
|
483 regs_buff[13] = (u32)phy_data; /* cable length */ |
|
484 regs_buff[14] = 0; /* Dummy (to align w/ IGP phy reg dump) */ |
|
485 regs_buff[15] = 0; /* Dummy (to align w/ IGP phy reg dump) */ |
|
486 regs_buff[16] = 0; /* Dummy (to align w/ IGP phy reg dump) */ |
|
487 e1e_rphy(hw, M88E1000_PHY_SPEC_CTRL, &phy_data); |
|
488 regs_buff[17] = (u32)phy_data; /* extended 10bt distance */ |
|
489 regs_buff[18] = regs_buff[13]; /* cable polarity */ |
|
490 regs_buff[19] = 0; /* Dummy (to align w/ IGP phy reg dump) */ |
|
491 regs_buff[20] = regs_buff[17]; /* polarity correction */ |
|
492 /* phy receive errors */ |
|
493 regs_buff[22] = adapter->phy_stats.receive_errors; |
|
494 regs_buff[23] = regs_buff[13]; /* mdix mode */ |
|
495 } |
|
496 regs_buff[21] = 0; /* was idle_errors */ |
|
497 e1e_rphy(hw, PHY_1000T_STATUS, &phy_data); |
|
498 regs_buff[24] = (u32)phy_data; /* phy local receiver status */ |
|
499 regs_buff[25] = regs_buff[24]; /* phy remote receiver status */ |
|
500 } |
|
501 |
|
502 static int e1000_get_eeprom_len(struct net_device *netdev) |
|
503 { |
|
504 struct e1000_adapter *adapter = netdev_priv(netdev); |
|
505 return adapter->hw.nvm.word_size * 2; |
|
506 } |
|
507 |
|
508 static int e1000_get_eeprom(struct net_device *netdev, |
|
509 struct ethtool_eeprom *eeprom, u8 *bytes) |
|
510 { |
|
511 struct e1000_adapter *adapter = netdev_priv(netdev); |
|
512 struct e1000_hw *hw = &adapter->hw; |
|
513 u16 *eeprom_buff; |
|
514 int first_word; |
|
515 int last_word; |
|
516 int ret_val = 0; |
|
517 u16 i; |
|
518 |
|
519 if (eeprom->len == 0) |
|
520 return -EINVAL; |
|
521 |
|
522 eeprom->magic = adapter->pdev->vendor | (adapter->pdev->device << 16); |
|
523 |
|
524 first_word = eeprom->offset >> 1; |
|
525 last_word = (eeprom->offset + eeprom->len - 1) >> 1; |
|
526 |
|
527 eeprom_buff = kmalloc(sizeof(u16) * |
|
528 (last_word - first_word + 1), GFP_KERNEL); |
|
529 if (!eeprom_buff) |
|
530 return -ENOMEM; |
|
531 |
|
532 if (hw->nvm.type == e1000_nvm_eeprom_spi) { |
|
533 ret_val = e1000_read_nvm(hw, first_word, |
|
534 last_word - first_word + 1, |
|
535 eeprom_buff); |
|
536 } else { |
|
537 for (i = 0; i < last_word - first_word + 1; i++) { |
|
538 ret_val = e1000_read_nvm(hw, first_word + i, 1, |
|
539 &eeprom_buff[i]); |
|
540 if (ret_val) |
|
541 break; |
|
542 } |
|
543 } |
|
544 |
|
545 if (ret_val) { |
|
546 /* a read error occurred, throw away the result */ |
|
547 memset(eeprom_buff, 0xff, sizeof(u16) * |
|
548 (last_word - first_word + 1)); |
|
549 } else { |
|
550 /* Device's eeprom is always little-endian, word addressable */ |
|
551 for (i = 0; i < last_word - first_word + 1; i++) |
|
552 le16_to_cpus(&eeprom_buff[i]); |
|
553 } |
|
554 |
|
555 memcpy(bytes, (u8 *)eeprom_buff + (eeprom->offset & 1), eeprom->len); |
|
556 kfree(eeprom_buff); |
|
557 |
|
558 return ret_val; |
|
559 } |
|
560 |
|
561 static int e1000_set_eeprom(struct net_device *netdev, |
|
562 struct ethtool_eeprom *eeprom, u8 *bytes) |
|
563 { |
|
564 struct e1000_adapter *adapter = netdev_priv(netdev); |
|
565 struct e1000_hw *hw = &adapter->hw; |
|
566 u16 *eeprom_buff; |
|
567 void *ptr; |
|
568 int max_len; |
|
569 int first_word; |
|
570 int last_word; |
|
571 int ret_val = 0; |
|
572 u16 i; |
|
573 |
|
574 if (eeprom->len == 0) |
|
575 return -EOPNOTSUPP; |
|
576 |
|
577 if (eeprom->magic != (adapter->pdev->vendor | (adapter->pdev->device << 16))) |
|
578 return -EFAULT; |
|
579 |
|
580 if (adapter->flags & FLAG_READ_ONLY_NVM) |
|
581 return -EINVAL; |
|
582 |
|
583 max_len = hw->nvm.word_size * 2; |
|
584 |
|
585 first_word = eeprom->offset >> 1; |
|
586 last_word = (eeprom->offset + eeprom->len - 1) >> 1; |
|
587 eeprom_buff = kmalloc(max_len, GFP_KERNEL); |
|
588 if (!eeprom_buff) |
|
589 return -ENOMEM; |
|
590 |
|
591 ptr = (void *)eeprom_buff; |
|
592 |
|
593 if (eeprom->offset & 1) { |
|
594 /* need read/modify/write of first changed EEPROM word */ |
|
595 /* only the second byte of the word is being modified */ |
|
596 ret_val = e1000_read_nvm(hw, first_word, 1, &eeprom_buff[0]); |
|
597 ptr++; |
|
598 } |
|
599 if (((eeprom->offset + eeprom->len) & 1) && (ret_val == 0)) |
|
600 /* need read/modify/write of last changed EEPROM word */ |
|
601 /* only the first byte of the word is being modified */ |
|
602 ret_val = e1000_read_nvm(hw, last_word, 1, |
|
603 &eeprom_buff[last_word - first_word]); |
|
604 |
|
605 if (ret_val) |
|
606 goto out; |
|
607 |
|
608 /* Device's eeprom is always little-endian, word addressable */ |
|
609 for (i = 0; i < last_word - first_word + 1; i++) |
|
610 le16_to_cpus(&eeprom_buff[i]); |
|
611 |
|
612 memcpy(ptr, bytes, eeprom->len); |
|
613 |
|
614 for (i = 0; i < last_word - first_word + 1; i++) |
|
615 eeprom_buff[i] = cpu_to_le16(eeprom_buff[i]); |
|
616 |
|
617 ret_val = e1000_write_nvm(hw, first_word, |
|
618 last_word - first_word + 1, eeprom_buff); |
|
619 |
|
620 if (ret_val) |
|
621 goto out; |
|
622 |
|
623 /* |
|
624 * Update the checksum over the first part of the EEPROM if needed |
|
625 * and flush shadow RAM for applicable controllers |
|
626 */ |
|
627 if ((first_word <= NVM_CHECKSUM_REG) || |
|
628 (hw->mac.type == e1000_82583) || |
|
629 (hw->mac.type == e1000_82574) || |
|
630 (hw->mac.type == e1000_82573)) |
|
631 ret_val = e1000e_update_nvm_checksum(hw); |
|
632 |
|
633 out: |
|
634 kfree(eeprom_buff); |
|
635 return ret_val; |
|
636 } |
|
637 |
|
638 static void e1000_get_drvinfo(struct net_device *netdev, |
|
639 struct ethtool_drvinfo *drvinfo) |
|
640 { |
|
641 struct e1000_adapter *adapter = netdev_priv(netdev); |
|
642 char firmware_version[32]; |
|
643 |
|
644 strncpy(drvinfo->driver, e1000e_driver_name, 32); |
|
645 strncpy(drvinfo->version, e1000e_driver_version, 32); |
|
646 |
|
647 /* |
|
648 * EEPROM image version # is reported as firmware version # for |
|
649 * PCI-E controllers |
|
650 */ |
|
651 sprintf(firmware_version, "%d.%d-%d", |
|
652 (adapter->eeprom_vers & 0xF000) >> 12, |
|
653 (adapter->eeprom_vers & 0x0FF0) >> 4, |
|
654 (adapter->eeprom_vers & 0x000F)); |
|
655 |
|
656 strncpy(drvinfo->fw_version, firmware_version, 32); |
|
657 strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 32); |
|
658 drvinfo->regdump_len = e1000_get_regs_len(netdev); |
|
659 drvinfo->eedump_len = e1000_get_eeprom_len(netdev); |
|
660 } |
|
661 |
|
662 static void e1000_get_ringparam(struct net_device *netdev, |
|
663 struct ethtool_ringparam *ring) |
|
664 { |
|
665 struct e1000_adapter *adapter = netdev_priv(netdev); |
|
666 struct e1000_ring *tx_ring = adapter->tx_ring; |
|
667 struct e1000_ring *rx_ring = adapter->rx_ring; |
|
668 |
|
669 ring->rx_max_pending = E1000_MAX_RXD; |
|
670 ring->tx_max_pending = E1000_MAX_TXD; |
|
671 ring->rx_mini_max_pending = 0; |
|
672 ring->rx_jumbo_max_pending = 0; |
|
673 ring->rx_pending = rx_ring->count; |
|
674 ring->tx_pending = tx_ring->count; |
|
675 ring->rx_mini_pending = 0; |
|
676 ring->rx_jumbo_pending = 0; |
|
677 } |
|
678 |
|
679 static int e1000_set_ringparam(struct net_device *netdev, |
|
680 struct ethtool_ringparam *ring) |
|
681 { |
|
682 struct e1000_adapter *adapter = netdev_priv(netdev); |
|
683 struct e1000_ring *tx_ring, *tx_old; |
|
684 struct e1000_ring *rx_ring, *rx_old; |
|
685 int err; |
|
686 |
|
687 if (adapter->ecdev) |
|
688 return -EBUSY; |
|
689 |
|
690 if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending)) |
|
691 return -EINVAL; |
|
692 |
|
693 while (test_and_set_bit(__E1000_RESETTING, &adapter->state)) |
|
694 msleep(1); |
|
695 |
|
696 if (netif_running(adapter->netdev)) |
|
697 e1000e_down(adapter); |
|
698 |
|
699 tx_old = adapter->tx_ring; |
|
700 rx_old = adapter->rx_ring; |
|
701 |
|
702 err = -ENOMEM; |
|
703 tx_ring = kzalloc(sizeof(struct e1000_ring), GFP_KERNEL); |
|
704 if (!tx_ring) |
|
705 goto err_alloc_tx; |
|
706 /* |
|
707 * use a memcpy to save any previously configured |
|
708 * items like napi structs from having to be |
|
709 * reinitialized |
|
710 */ |
|
711 memcpy(tx_ring, tx_old, sizeof(struct e1000_ring)); |
|
712 |
|
713 rx_ring = kzalloc(sizeof(struct e1000_ring), GFP_KERNEL); |
|
714 if (!rx_ring) |
|
715 goto err_alloc_rx; |
|
716 memcpy(rx_ring, rx_old, sizeof(struct e1000_ring)); |
|
717 |
|
718 adapter->tx_ring = tx_ring; |
|
719 adapter->rx_ring = rx_ring; |
|
720 |
|
721 rx_ring->count = max(ring->rx_pending, (u32)E1000_MIN_RXD); |
|
722 rx_ring->count = min(rx_ring->count, (u32)(E1000_MAX_RXD)); |
|
723 rx_ring->count = ALIGN(rx_ring->count, REQ_RX_DESCRIPTOR_MULTIPLE); |
|
724 |
|
725 tx_ring->count = max(ring->tx_pending, (u32)E1000_MIN_TXD); |
|
726 tx_ring->count = min(tx_ring->count, (u32)(E1000_MAX_TXD)); |
|
727 tx_ring->count = ALIGN(tx_ring->count, REQ_TX_DESCRIPTOR_MULTIPLE); |
|
728 |
|
729 if (netif_running(adapter->netdev)) { |
|
730 /* Try to get new resources before deleting old */ |
|
731 err = e1000e_setup_rx_resources(adapter); |
|
732 if (err) |
|
733 goto err_setup_rx; |
|
734 err = e1000e_setup_tx_resources(adapter); |
|
735 if (err) |
|
736 goto err_setup_tx; |
|
737 |
|
738 /* |
|
739 * restore the old in order to free it, |
|
740 * then add in the new |
|
741 */ |
|
742 adapter->rx_ring = rx_old; |
|
743 adapter->tx_ring = tx_old; |
|
744 e1000e_free_rx_resources(adapter); |
|
745 e1000e_free_tx_resources(adapter); |
|
746 kfree(tx_old); |
|
747 kfree(rx_old); |
|
748 adapter->rx_ring = rx_ring; |
|
749 adapter->tx_ring = tx_ring; |
|
750 err = e1000e_up(adapter); |
|
751 if (err) |
|
752 goto err_setup; |
|
753 } |
|
754 |
|
755 clear_bit(__E1000_RESETTING, &adapter->state); |
|
756 return 0; |
|
757 err_setup_tx: |
|
758 e1000e_free_rx_resources(adapter); |
|
759 err_setup_rx: |
|
760 adapter->rx_ring = rx_old; |
|
761 adapter->tx_ring = tx_old; |
|
762 kfree(rx_ring); |
|
763 err_alloc_rx: |
|
764 kfree(tx_ring); |
|
765 err_alloc_tx: |
|
766 e1000e_up(adapter); |
|
767 err_setup: |
|
768 clear_bit(__E1000_RESETTING, &adapter->state); |
|
769 return err; |
|
770 } |
|
771 |
|
772 static bool reg_pattern_test(struct e1000_adapter *adapter, u64 *data, |
|
773 int reg, int offset, u32 mask, u32 write) |
|
774 { |
|
775 u32 pat, val; |
|
776 static const u32 test[] = |
|
777 {0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF}; |
|
778 for (pat = 0; pat < ARRAY_SIZE(test); pat++) { |
|
779 E1000_WRITE_REG_ARRAY(&adapter->hw, reg, offset, |
|
780 (test[pat] & write)); |
|
781 val = E1000_READ_REG_ARRAY(&adapter->hw, reg, offset); |
|
782 if (val != (test[pat] & write & mask)) { |
|
783 e_err("pattern test reg %04X failed: got 0x%08X " |
|
784 "expected 0x%08X\n", reg + offset, val, |
|
785 (test[pat] & write & mask)); |
|
786 *data = reg; |
|
787 return 1; |
|
788 } |
|
789 } |
|
790 return 0; |
|
791 } |
|
792 |
|
793 static bool reg_set_and_check(struct e1000_adapter *adapter, u64 *data, |
|
794 int reg, u32 mask, u32 write) |
|
795 { |
|
796 u32 val; |
|
797 __ew32(&adapter->hw, reg, write & mask); |
|
798 val = __er32(&adapter->hw, reg); |
|
799 if ((write & mask) != (val & mask)) { |
|
800 e_err("set/check reg %04X test failed: got 0x%08X " |
|
801 "expected 0x%08X\n", reg, (val & mask), (write & mask)); |
|
802 *data = reg; |
|
803 return 1; |
|
804 } |
|
805 return 0; |
|
806 } |
|
807 #define REG_PATTERN_TEST_ARRAY(reg, offset, mask, write) \ |
|
808 do { \ |
|
809 if (reg_pattern_test(adapter, data, reg, offset, mask, write)) \ |
|
810 return 1; \ |
|
811 } while (0) |
|
812 #define REG_PATTERN_TEST(reg, mask, write) \ |
|
813 REG_PATTERN_TEST_ARRAY(reg, 0, mask, write) |
|
814 |
|
815 #define REG_SET_AND_CHECK(reg, mask, write) \ |
|
816 do { \ |
|
817 if (reg_set_and_check(adapter, data, reg, mask, write)) \ |
|
818 return 1; \ |
|
819 } while (0) |
|
820 |
|
821 static int e1000_reg_test(struct e1000_adapter *adapter, u64 *data) |
|
822 { |
|
823 struct e1000_hw *hw = &adapter->hw; |
|
824 struct e1000_mac_info *mac = &adapter->hw.mac; |
|
825 u32 value; |
|
826 u32 before; |
|
827 u32 after; |
|
828 u32 i; |
|
829 u32 toggle; |
|
830 u32 mask; |
|
831 |
|
832 /* |
|
833 * The status register is Read Only, so a write should fail. |
|
834 * Some bits that get toggled are ignored. |
|
835 */ |
|
836 switch (mac->type) { |
|
837 /* there are several bits on newer hardware that are r/w */ |
|
838 case e1000_82571: |
|
839 case e1000_82572: |
|
840 case e1000_80003es2lan: |
|
841 toggle = 0x7FFFF3FF; |
|
842 break; |
|
843 default: |
|
844 toggle = 0x7FFFF033; |
|
845 break; |
|
846 } |
|
847 |
|
848 before = er32(STATUS); |
|
849 value = (er32(STATUS) & toggle); |
|
850 ew32(STATUS, toggle); |
|
851 after = er32(STATUS) & toggle; |
|
852 if (value != after) { |
|
853 e_err("failed STATUS register test got: 0x%08X expected: " |
|
854 "0x%08X\n", after, value); |
|
855 *data = 1; |
|
856 return 1; |
|
857 } |
|
858 /* restore previous status */ |
|
859 ew32(STATUS, before); |
|
860 |
|
861 if (!(adapter->flags & FLAG_IS_ICH)) { |
|
862 REG_PATTERN_TEST(E1000_FCAL, 0xFFFFFFFF, 0xFFFFFFFF); |
|
863 REG_PATTERN_TEST(E1000_FCAH, 0x0000FFFF, 0xFFFFFFFF); |
|
864 REG_PATTERN_TEST(E1000_FCT, 0x0000FFFF, 0xFFFFFFFF); |
|
865 REG_PATTERN_TEST(E1000_VET, 0x0000FFFF, 0xFFFFFFFF); |
|
866 } |
|
867 |
|
868 REG_PATTERN_TEST(E1000_RDTR, 0x0000FFFF, 0xFFFFFFFF); |
|
869 REG_PATTERN_TEST(E1000_RDBAH, 0xFFFFFFFF, 0xFFFFFFFF); |
|
870 REG_PATTERN_TEST(E1000_RDLEN, 0x000FFF80, 0x000FFFFF); |
|
871 REG_PATTERN_TEST(E1000_RDH, 0x0000FFFF, 0x0000FFFF); |
|
872 REG_PATTERN_TEST(E1000_RDT, 0x0000FFFF, 0x0000FFFF); |
|
873 REG_PATTERN_TEST(E1000_FCRTH, 0x0000FFF8, 0x0000FFF8); |
|
874 REG_PATTERN_TEST(E1000_FCTTV, 0x0000FFFF, 0x0000FFFF); |
|
875 REG_PATTERN_TEST(E1000_TIPG, 0x3FFFFFFF, 0x3FFFFFFF); |
|
876 REG_PATTERN_TEST(E1000_TDBAH, 0xFFFFFFFF, 0xFFFFFFFF); |
|
877 REG_PATTERN_TEST(E1000_TDLEN, 0x000FFF80, 0x000FFFFF); |
|
878 |
|
879 REG_SET_AND_CHECK(E1000_RCTL, 0xFFFFFFFF, 0x00000000); |
|
880 |
|
881 before = ((adapter->flags & FLAG_IS_ICH) ? 0x06C3B33E : 0x06DFB3FE); |
|
882 REG_SET_AND_CHECK(E1000_RCTL, before, 0x003FFFFB); |
|
883 REG_SET_AND_CHECK(E1000_TCTL, 0xFFFFFFFF, 0x00000000); |
|
884 |
|
885 REG_SET_AND_CHECK(E1000_RCTL, before, 0xFFFFFFFF); |
|
886 REG_PATTERN_TEST(E1000_RDBAL, 0xFFFFFFF0, 0xFFFFFFFF); |
|
887 if (!(adapter->flags & FLAG_IS_ICH)) |
|
888 REG_PATTERN_TEST(E1000_TXCW, 0xC000FFFF, 0x0000FFFF); |
|
889 REG_PATTERN_TEST(E1000_TDBAL, 0xFFFFFFF0, 0xFFFFFFFF); |
|
890 REG_PATTERN_TEST(E1000_TIDV, 0x0000FFFF, 0x0000FFFF); |
|
891 mask = 0x8003FFFF; |
|
892 switch (mac->type) { |
|
893 case e1000_ich10lan: |
|
894 case e1000_pchlan: |
|
895 mask |= (1 << 18); |
|
896 break; |
|
897 default: |
|
898 break; |
|
899 } |
|
900 for (i = 0; i < mac->rar_entry_count; i++) |
|
901 REG_PATTERN_TEST_ARRAY(E1000_RA, ((i << 1) + 1), |
|
902 mask, 0xFFFFFFFF); |
|
903 |
|
904 for (i = 0; i < mac->mta_reg_count; i++) |
|
905 REG_PATTERN_TEST_ARRAY(E1000_MTA, i, 0xFFFFFFFF, 0xFFFFFFFF); |
|
906 |
|
907 *data = 0; |
|
908 return 0; |
|
909 } |
|
910 |
|
911 static int e1000_eeprom_test(struct e1000_adapter *adapter, u64 *data) |
|
912 { |
|
913 u16 temp; |
|
914 u16 checksum = 0; |
|
915 u16 i; |
|
916 |
|
917 *data = 0; |
|
918 /* Read and add up the contents of the EEPROM */ |
|
919 for (i = 0; i < (NVM_CHECKSUM_REG + 1); i++) { |
|
920 if ((e1000_read_nvm(&adapter->hw, i, 1, &temp)) < 0) { |
|
921 *data = 1; |
|
922 return *data; |
|
923 } |
|
924 checksum += temp; |
|
925 } |
|
926 |
|
927 /* If Checksum is not Correct return error else test passed */ |
|
928 if ((checksum != (u16) NVM_SUM) && !(*data)) |
|
929 *data = 2; |
|
930 |
|
931 return *data; |
|
932 } |
|
933 |
|
934 static irqreturn_t e1000_test_intr(int irq, void *data) |
|
935 { |
|
936 struct net_device *netdev = (struct net_device *) data; |
|
937 struct e1000_adapter *adapter = netdev_priv(netdev); |
|
938 struct e1000_hw *hw = &adapter->hw; |
|
939 |
|
940 adapter->test_icr |= er32(ICR); |
|
941 |
|
942 return IRQ_HANDLED; |
|
943 } |
|
944 |
|
945 static int e1000_intr_test(struct e1000_adapter *adapter, u64 *data) |
|
946 { |
|
947 struct net_device *netdev = adapter->netdev; |
|
948 struct e1000_hw *hw = &adapter->hw; |
|
949 u32 mask; |
|
950 u32 shared_int = 1; |
|
951 u32 irq = adapter->pdev->irq; |
|
952 int i; |
|
953 int ret_val = 0; |
|
954 int int_mode = E1000E_INT_MODE_LEGACY; |
|
955 |
|
956 *data = 0; |
|
957 |
|
958 /* NOTE: we don't test MSI/MSI-X interrupts here, yet */ |
|
959 if (adapter->int_mode == E1000E_INT_MODE_MSIX) { |
|
960 int_mode = adapter->int_mode; |
|
961 e1000e_reset_interrupt_capability(adapter); |
|
962 adapter->int_mode = E1000E_INT_MODE_LEGACY; |
|
963 e1000e_set_interrupt_capability(adapter); |
|
964 } |
|
965 /* Hook up test interrupt handler just for this test */ |
|
966 if (!request_irq(irq, e1000_test_intr, IRQF_PROBE_SHARED, netdev->name, |
|
967 netdev)) { |
|
968 shared_int = 0; |
|
969 } else if (request_irq(irq, e1000_test_intr, IRQF_SHARED, |
|
970 netdev->name, netdev)) { |
|
971 *data = 1; |
|
972 ret_val = -1; |
|
973 goto out; |
|
974 } |
|
975 e_info("testing %s interrupt\n", (shared_int ? "shared" : "unshared")); |
|
976 |
|
977 /* Disable all the interrupts */ |
|
978 ew32(IMC, 0xFFFFFFFF); |
|
979 msleep(10); |
|
980 |
|
981 /* Test each interrupt */ |
|
982 for (i = 0; i < 10; i++) { |
|
983 /* Interrupt to test */ |
|
984 mask = 1 << i; |
|
985 |
|
986 if (adapter->flags & FLAG_IS_ICH) { |
|
987 switch (mask) { |
|
988 case E1000_ICR_RXSEQ: |
|
989 continue; |
|
990 case 0x00000100: |
|
991 if (adapter->hw.mac.type == e1000_ich8lan || |
|
992 adapter->hw.mac.type == e1000_ich9lan) |
|
993 continue; |
|
994 break; |
|
995 default: |
|
996 break; |
|
997 } |
|
998 } |
|
999 |
|
1000 if (!shared_int) { |
|
1001 /* |
|
1002 * Disable the interrupt to be reported in |
|
1003 * the cause register and then force the same |
|
1004 * interrupt and see if one gets posted. If |
|
1005 * an interrupt was posted to the bus, the |
|
1006 * test failed. |
|
1007 */ |
|
1008 adapter->test_icr = 0; |
|
1009 ew32(IMC, mask); |
|
1010 ew32(ICS, mask); |
|
1011 msleep(10); |
|
1012 |
|
1013 if (adapter->test_icr & mask) { |
|
1014 *data = 3; |
|
1015 break; |
|
1016 } |
|
1017 } |
|
1018 |
|
1019 /* |
|
1020 * Enable the interrupt to be reported in |
|
1021 * the cause register and then force the same |
|
1022 * interrupt and see if one gets posted. If |
|
1023 * an interrupt was not posted to the bus, the |
|
1024 * test failed. |
|
1025 */ |
|
1026 adapter->test_icr = 0; |
|
1027 ew32(IMS, mask); |
|
1028 ew32(ICS, mask); |
|
1029 msleep(10); |
|
1030 |
|
1031 if (!(adapter->test_icr & mask)) { |
|
1032 *data = 4; |
|
1033 break; |
|
1034 } |
|
1035 |
|
1036 if (!shared_int) { |
|
1037 /* |
|
1038 * Disable the other interrupts to be reported in |
|
1039 * the cause register and then force the other |
|
1040 * interrupts and see if any get posted. If |
|
1041 * an interrupt was posted to the bus, the |
|
1042 * test failed. |
|
1043 */ |
|
1044 adapter->test_icr = 0; |
|
1045 ew32(IMC, ~mask & 0x00007FFF); |
|
1046 ew32(ICS, ~mask & 0x00007FFF); |
|
1047 msleep(10); |
|
1048 |
|
1049 if (adapter->test_icr) { |
|
1050 *data = 5; |
|
1051 break; |
|
1052 } |
|
1053 } |
|
1054 } |
|
1055 |
|
1056 /* Disable all the interrupts */ |
|
1057 ew32(IMC, 0xFFFFFFFF); |
|
1058 msleep(10); |
|
1059 |
|
1060 /* Unhook test interrupt handler */ |
|
1061 free_irq(irq, netdev); |
|
1062 |
|
1063 out: |
|
1064 if (int_mode == E1000E_INT_MODE_MSIX) { |
|
1065 e1000e_reset_interrupt_capability(adapter); |
|
1066 adapter->int_mode = int_mode; |
|
1067 e1000e_set_interrupt_capability(adapter); |
|
1068 } |
|
1069 |
|
1070 return ret_val; |
|
1071 } |
|
1072 |
|
1073 static void e1000_free_desc_rings(struct e1000_adapter *adapter) |
|
1074 { |
|
1075 struct e1000_ring *tx_ring = &adapter->test_tx_ring; |
|
1076 struct e1000_ring *rx_ring = &adapter->test_rx_ring; |
|
1077 struct pci_dev *pdev = adapter->pdev; |
|
1078 int i; |
|
1079 |
|
1080 if (tx_ring->desc && tx_ring->buffer_info) { |
|
1081 for (i = 0; i < tx_ring->count; i++) { |
|
1082 if (tx_ring->buffer_info[i].dma) |
|
1083 dma_unmap_single(&pdev->dev, |
|
1084 tx_ring->buffer_info[i].dma, |
|
1085 tx_ring->buffer_info[i].length, |
|
1086 DMA_TO_DEVICE); |
|
1087 if (tx_ring->buffer_info[i].skb) |
|
1088 dev_kfree_skb(tx_ring->buffer_info[i].skb); |
|
1089 } |
|
1090 } |
|
1091 |
|
1092 if (rx_ring->desc && rx_ring->buffer_info) { |
|
1093 for (i = 0; i < rx_ring->count; i++) { |
|
1094 if (rx_ring->buffer_info[i].dma) |
|
1095 dma_unmap_single(&pdev->dev, |
|
1096 rx_ring->buffer_info[i].dma, |
|
1097 2048, DMA_FROM_DEVICE); |
|
1098 if (rx_ring->buffer_info[i].skb) |
|
1099 dev_kfree_skb(rx_ring->buffer_info[i].skb); |
|
1100 } |
|
1101 } |
|
1102 |
|
1103 if (tx_ring->desc) { |
|
1104 dma_free_coherent(&pdev->dev, tx_ring->size, tx_ring->desc, |
|
1105 tx_ring->dma); |
|
1106 tx_ring->desc = NULL; |
|
1107 } |
|
1108 if (rx_ring->desc) { |
|
1109 dma_free_coherent(&pdev->dev, rx_ring->size, rx_ring->desc, |
|
1110 rx_ring->dma); |
|
1111 rx_ring->desc = NULL; |
|
1112 } |
|
1113 |
|
1114 kfree(tx_ring->buffer_info); |
|
1115 tx_ring->buffer_info = NULL; |
|
1116 kfree(rx_ring->buffer_info); |
|
1117 rx_ring->buffer_info = NULL; |
|
1118 } |
|
1119 |
|
1120 static int e1000_setup_desc_rings(struct e1000_adapter *adapter) |
|
1121 { |
|
1122 struct e1000_ring *tx_ring = &adapter->test_tx_ring; |
|
1123 struct e1000_ring *rx_ring = &adapter->test_rx_ring; |
|
1124 struct pci_dev *pdev = adapter->pdev; |
|
1125 struct e1000_hw *hw = &adapter->hw; |
|
1126 u32 rctl; |
|
1127 int i; |
|
1128 int ret_val; |
|
1129 |
|
1130 /* Setup Tx descriptor ring and Tx buffers */ |
|
1131 |
|
1132 if (!tx_ring->count) |
|
1133 tx_ring->count = E1000_DEFAULT_TXD; |
|
1134 |
|
1135 tx_ring->buffer_info = kcalloc(tx_ring->count, |
|
1136 sizeof(struct e1000_buffer), |
|
1137 GFP_KERNEL); |
|
1138 if (!(tx_ring->buffer_info)) { |
|
1139 ret_val = 1; |
|
1140 goto err_nomem; |
|
1141 } |
|
1142 |
|
1143 tx_ring->size = tx_ring->count * sizeof(struct e1000_tx_desc); |
|
1144 tx_ring->size = ALIGN(tx_ring->size, 4096); |
|
1145 tx_ring->desc = dma_alloc_coherent(&pdev->dev, tx_ring->size, |
|
1146 &tx_ring->dma, GFP_KERNEL); |
|
1147 if (!tx_ring->desc) { |
|
1148 ret_val = 2; |
|
1149 goto err_nomem; |
|
1150 } |
|
1151 tx_ring->next_to_use = 0; |
|
1152 tx_ring->next_to_clean = 0; |
|
1153 |
|
1154 ew32(TDBAL, ((u64) tx_ring->dma & 0x00000000FFFFFFFF)); |
|
1155 ew32(TDBAH, ((u64) tx_ring->dma >> 32)); |
|
1156 ew32(TDLEN, tx_ring->count * sizeof(struct e1000_tx_desc)); |
|
1157 ew32(TDH, 0); |
|
1158 ew32(TDT, 0); |
|
1159 ew32(TCTL, E1000_TCTL_PSP | E1000_TCTL_EN | E1000_TCTL_MULR | |
|
1160 E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT | |
|
1161 E1000_COLLISION_DISTANCE << E1000_COLD_SHIFT); |
|
1162 |
|
1163 for (i = 0; i < tx_ring->count; i++) { |
|
1164 struct e1000_tx_desc *tx_desc = E1000_TX_DESC(*tx_ring, i); |
|
1165 struct sk_buff *skb; |
|
1166 unsigned int skb_size = 1024; |
|
1167 |
|
1168 skb = alloc_skb(skb_size, GFP_KERNEL); |
|
1169 if (!skb) { |
|
1170 ret_val = 3; |
|
1171 goto err_nomem; |
|
1172 } |
|
1173 skb_put(skb, skb_size); |
|
1174 tx_ring->buffer_info[i].skb = skb; |
|
1175 tx_ring->buffer_info[i].length = skb->len; |
|
1176 tx_ring->buffer_info[i].dma = |
|
1177 dma_map_single(&pdev->dev, skb->data, skb->len, |
|
1178 DMA_TO_DEVICE); |
|
1179 if (dma_mapping_error(&pdev->dev, |
|
1180 tx_ring->buffer_info[i].dma)) { |
|
1181 ret_val = 4; |
|
1182 goto err_nomem; |
|
1183 } |
|
1184 tx_desc->buffer_addr = cpu_to_le64(tx_ring->buffer_info[i].dma); |
|
1185 tx_desc->lower.data = cpu_to_le32(skb->len); |
|
1186 tx_desc->lower.data |= cpu_to_le32(E1000_TXD_CMD_EOP | |
|
1187 E1000_TXD_CMD_IFCS | |
|
1188 E1000_TXD_CMD_RS); |
|
1189 tx_desc->upper.data = 0; |
|
1190 } |
|
1191 |
|
1192 /* Setup Rx descriptor ring and Rx buffers */ |
|
1193 |
|
1194 if (!rx_ring->count) |
|
1195 rx_ring->count = E1000_DEFAULT_RXD; |
|
1196 |
|
1197 rx_ring->buffer_info = kcalloc(rx_ring->count, |
|
1198 sizeof(struct e1000_buffer), |
|
1199 GFP_KERNEL); |
|
1200 if (!(rx_ring->buffer_info)) { |
|
1201 ret_val = 5; |
|
1202 goto err_nomem; |
|
1203 } |
|
1204 |
|
1205 rx_ring->size = rx_ring->count * sizeof(struct e1000_rx_desc); |
|
1206 rx_ring->desc = dma_alloc_coherent(&pdev->dev, rx_ring->size, |
|
1207 &rx_ring->dma, GFP_KERNEL); |
|
1208 if (!rx_ring->desc) { |
|
1209 ret_val = 6; |
|
1210 goto err_nomem; |
|
1211 } |
|
1212 rx_ring->next_to_use = 0; |
|
1213 rx_ring->next_to_clean = 0; |
|
1214 |
|
1215 rctl = er32(RCTL); |
|
1216 ew32(RCTL, rctl & ~E1000_RCTL_EN); |
|
1217 ew32(RDBAL, ((u64) rx_ring->dma & 0xFFFFFFFF)); |
|
1218 ew32(RDBAH, ((u64) rx_ring->dma >> 32)); |
|
1219 ew32(RDLEN, rx_ring->size); |
|
1220 ew32(RDH, 0); |
|
1221 ew32(RDT, 0); |
|
1222 rctl = E1000_RCTL_EN | E1000_RCTL_BAM | E1000_RCTL_SZ_2048 | |
|
1223 E1000_RCTL_UPE | E1000_RCTL_MPE | E1000_RCTL_LPE | |
|
1224 E1000_RCTL_SBP | E1000_RCTL_SECRC | |
|
1225 E1000_RCTL_LBM_NO | E1000_RCTL_RDMTS_HALF | |
|
1226 (adapter->hw.mac.mc_filter_type << E1000_RCTL_MO_SHIFT); |
|
1227 ew32(RCTL, rctl); |
|
1228 |
|
1229 for (i = 0; i < rx_ring->count; i++) { |
|
1230 struct e1000_rx_desc *rx_desc = E1000_RX_DESC(*rx_ring, i); |
|
1231 struct sk_buff *skb; |
|
1232 |
|
1233 skb = alloc_skb(2048 + NET_IP_ALIGN, GFP_KERNEL); |
|
1234 if (!skb) { |
|
1235 ret_val = 7; |
|
1236 goto err_nomem; |
|
1237 } |
|
1238 skb_reserve(skb, NET_IP_ALIGN); |
|
1239 rx_ring->buffer_info[i].skb = skb; |
|
1240 rx_ring->buffer_info[i].dma = |
|
1241 dma_map_single(&pdev->dev, skb->data, 2048, |
|
1242 DMA_FROM_DEVICE); |
|
1243 if (dma_mapping_error(&pdev->dev, |
|
1244 rx_ring->buffer_info[i].dma)) { |
|
1245 ret_val = 8; |
|
1246 goto err_nomem; |
|
1247 } |
|
1248 rx_desc->buffer_addr = |
|
1249 cpu_to_le64(rx_ring->buffer_info[i].dma); |
|
1250 memset(skb->data, 0x00, skb->len); |
|
1251 } |
|
1252 |
|
1253 return 0; |
|
1254 |
|
1255 err_nomem: |
|
1256 e1000_free_desc_rings(adapter); |
|
1257 return ret_val; |
|
1258 } |
|
1259 |
|
1260 static void e1000_phy_disable_receiver(struct e1000_adapter *adapter) |
|
1261 { |
|
1262 /* Write out to PHY registers 29 and 30 to disable the Receiver. */ |
|
1263 e1e_wphy(&adapter->hw, 29, 0x001F); |
|
1264 e1e_wphy(&adapter->hw, 30, 0x8FFC); |
|
1265 e1e_wphy(&adapter->hw, 29, 0x001A); |
|
1266 e1e_wphy(&adapter->hw, 30, 0x8FF0); |
|
1267 } |
|
1268 |
|
1269 static int e1000_integrated_phy_loopback(struct e1000_adapter *adapter) |
|
1270 { |
|
1271 struct e1000_hw *hw = &adapter->hw; |
|
1272 u32 ctrl_reg = 0; |
|
1273 u32 stat_reg = 0; |
|
1274 u16 phy_reg = 0; |
|
1275 |
|
1276 hw->mac.autoneg = 0; |
|
1277 |
|
1278 /* Workaround: K1 must be disabled for stable 1Gbps operation */ |
|
1279 if (hw->mac.type == e1000_pchlan) |
|
1280 e1000_configure_k1_ich8lan(hw, false); |
|
1281 |
|
1282 if (hw->phy.type == e1000_phy_m88) { |
|
1283 /* Auto-MDI/MDIX Off */ |
|
1284 e1e_wphy(hw, M88E1000_PHY_SPEC_CTRL, 0x0808); |
|
1285 /* reset to update Auto-MDI/MDIX */ |
|
1286 e1e_wphy(hw, PHY_CONTROL, 0x9140); |
|
1287 /* autoneg off */ |
|
1288 e1e_wphy(hw, PHY_CONTROL, 0x8140); |
|
1289 } else if (hw->phy.type == e1000_phy_gg82563) |
|
1290 e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, 0x1CC); |
|
1291 |
|
1292 ctrl_reg = er32(CTRL); |
|
1293 |
|
1294 switch (hw->phy.type) { |
|
1295 case e1000_phy_ife: |
|
1296 /* force 100, set loopback */ |
|
1297 e1e_wphy(hw, PHY_CONTROL, 0x6100); |
|
1298 |
|
1299 /* Now set up the MAC to the same speed/duplex as the PHY. */ |
|
1300 ctrl_reg &= ~E1000_CTRL_SPD_SEL; /* Clear the speed sel bits */ |
|
1301 ctrl_reg |= (E1000_CTRL_FRCSPD | /* Set the Force Speed Bit */ |
|
1302 E1000_CTRL_FRCDPX | /* Set the Force Duplex Bit */ |
|
1303 E1000_CTRL_SPD_100 |/* Force Speed to 100 */ |
|
1304 E1000_CTRL_FD); /* Force Duplex to FULL */ |
|
1305 break; |
|
1306 case e1000_phy_bm: |
|
1307 /* Set Default MAC Interface speed to 1GB */ |
|
1308 e1e_rphy(hw, PHY_REG(2, 21), &phy_reg); |
|
1309 phy_reg &= ~0x0007; |
|
1310 phy_reg |= 0x006; |
|
1311 e1e_wphy(hw, PHY_REG(2, 21), phy_reg); |
|
1312 /* Assert SW reset for above settings to take effect */ |
|
1313 e1000e_commit_phy(hw); |
|
1314 mdelay(1); |
|
1315 /* Force Full Duplex */ |
|
1316 e1e_rphy(hw, PHY_REG(769, 16), &phy_reg); |
|
1317 e1e_wphy(hw, PHY_REG(769, 16), phy_reg | 0x000C); |
|
1318 /* Set Link Up (in force link) */ |
|
1319 e1e_rphy(hw, PHY_REG(776, 16), &phy_reg); |
|
1320 e1e_wphy(hw, PHY_REG(776, 16), phy_reg | 0x0040); |
|
1321 /* Force Link */ |
|
1322 e1e_rphy(hw, PHY_REG(769, 16), &phy_reg); |
|
1323 e1e_wphy(hw, PHY_REG(769, 16), phy_reg | 0x0040); |
|
1324 /* Set Early Link Enable */ |
|
1325 e1e_rphy(hw, PHY_REG(769, 20), &phy_reg); |
|
1326 e1e_wphy(hw, PHY_REG(769, 20), phy_reg | 0x0400); |
|
1327 /* fall through */ |
|
1328 default: |
|
1329 /* force 1000, set loopback */ |
|
1330 e1e_wphy(hw, PHY_CONTROL, 0x4140); |
|
1331 mdelay(250); |
|
1332 |
|
1333 /* Now set up the MAC to the same speed/duplex as the PHY. */ |
|
1334 ctrl_reg = er32(CTRL); |
|
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_1000 |/* Force Speed to 1000 */ |
|
1339 E1000_CTRL_FD); /* Force Duplex to FULL */ |
|
1340 |
|
1341 if (adapter->flags & FLAG_IS_ICH) |
|
1342 ctrl_reg |= E1000_CTRL_SLU; /* Set Link Up */ |
|
1343 } |
|
1344 |
|
1345 if (hw->phy.media_type == e1000_media_type_copper && |
|
1346 hw->phy.type == e1000_phy_m88) { |
|
1347 ctrl_reg |= E1000_CTRL_ILOS; /* Invert Loss of Signal */ |
|
1348 } else { |
|
1349 /* |
|
1350 * Set the ILOS bit on the fiber Nic if half duplex link is |
|
1351 * detected. |
|
1352 */ |
|
1353 stat_reg = er32(STATUS); |
|
1354 if ((stat_reg & E1000_STATUS_FD) == 0) |
|
1355 ctrl_reg |= (E1000_CTRL_ILOS | E1000_CTRL_SLU); |
|
1356 } |
|
1357 |
|
1358 ew32(CTRL, ctrl_reg); |
|
1359 |
|
1360 /* |
|
1361 * Disable the receiver on the PHY so when a cable is plugged in, the |
|
1362 * PHY does not begin to autoneg when a cable is reconnected to the NIC. |
|
1363 */ |
|
1364 if (hw->phy.type == e1000_phy_m88) |
|
1365 e1000_phy_disable_receiver(adapter); |
|
1366 |
|
1367 udelay(500); |
|
1368 |
|
1369 return 0; |
|
1370 } |
|
1371 |
|
1372 static int e1000_set_82571_fiber_loopback(struct e1000_adapter *adapter) |
|
1373 { |
|
1374 struct e1000_hw *hw = &adapter->hw; |
|
1375 u32 ctrl = er32(CTRL); |
|
1376 int link = 0; |
|
1377 |
|
1378 /* special requirements for 82571/82572 fiber adapters */ |
|
1379 |
|
1380 /* |
|
1381 * jump through hoops to make sure link is up because serdes |
|
1382 * link is hardwired up |
|
1383 */ |
|
1384 ctrl |= E1000_CTRL_SLU; |
|
1385 ew32(CTRL, ctrl); |
|
1386 |
|
1387 /* disable autoneg */ |
|
1388 ctrl = er32(TXCW); |
|
1389 ctrl &= ~(1 << 31); |
|
1390 ew32(TXCW, ctrl); |
|
1391 |
|
1392 link = (er32(STATUS) & E1000_STATUS_LU); |
|
1393 |
|
1394 if (!link) { |
|
1395 /* set invert loss of signal */ |
|
1396 ctrl = er32(CTRL); |
|
1397 ctrl |= E1000_CTRL_ILOS; |
|
1398 ew32(CTRL, ctrl); |
|
1399 } |
|
1400 |
|
1401 /* |
|
1402 * special write to serdes control register to enable SerDes analog |
|
1403 * loopback |
|
1404 */ |
|
1405 #define E1000_SERDES_LB_ON 0x410 |
|
1406 ew32(SCTL, E1000_SERDES_LB_ON); |
|
1407 msleep(10); |
|
1408 |
|
1409 return 0; |
|
1410 } |
|
1411 |
|
1412 /* only call this for fiber/serdes connections to es2lan */ |
|
1413 static int e1000_set_es2lan_mac_loopback(struct e1000_adapter *adapter) |
|
1414 { |
|
1415 struct e1000_hw *hw = &adapter->hw; |
|
1416 u32 ctrlext = er32(CTRL_EXT); |
|
1417 u32 ctrl = er32(CTRL); |
|
1418 |
|
1419 /* |
|
1420 * save CTRL_EXT to restore later, reuse an empty variable (unused |
|
1421 * on mac_type 80003es2lan) |
|
1422 */ |
|
1423 adapter->tx_fifo_head = ctrlext; |
|
1424 |
|
1425 /* clear the serdes mode bits, putting the device into mac loopback */ |
|
1426 ctrlext &= ~E1000_CTRL_EXT_LINK_MODE_PCIE_SERDES; |
|
1427 ew32(CTRL_EXT, ctrlext); |
|
1428 |
|
1429 /* force speed to 1000/FD, link up */ |
|
1430 ctrl &= ~(E1000_CTRL_SPD_1000 | E1000_CTRL_SPD_100); |
|
1431 ctrl |= (E1000_CTRL_SLU | E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX | |
|
1432 E1000_CTRL_SPD_1000 | E1000_CTRL_FD); |
|
1433 ew32(CTRL, ctrl); |
|
1434 |
|
1435 /* set mac loopback */ |
|
1436 ctrl = er32(RCTL); |
|
1437 ctrl |= E1000_RCTL_LBM_MAC; |
|
1438 ew32(RCTL, ctrl); |
|
1439 |
|
1440 /* set testing mode parameters (no need to reset later) */ |
|
1441 #define KMRNCTRLSTA_OPMODE (0x1F << 16) |
|
1442 #define KMRNCTRLSTA_OPMODE_1GB_FD_GMII 0x0582 |
|
1443 ew32(KMRNCTRLSTA, |
|
1444 (KMRNCTRLSTA_OPMODE | KMRNCTRLSTA_OPMODE_1GB_FD_GMII)); |
|
1445 |
|
1446 return 0; |
|
1447 } |
|
1448 |
|
1449 static int e1000_setup_loopback_test(struct e1000_adapter *adapter) |
|
1450 { |
|
1451 struct e1000_hw *hw = &adapter->hw; |
|
1452 u32 rctl; |
|
1453 |
|
1454 if (hw->phy.media_type == e1000_media_type_fiber || |
|
1455 hw->phy.media_type == e1000_media_type_internal_serdes) { |
|
1456 switch (hw->mac.type) { |
|
1457 case e1000_80003es2lan: |
|
1458 return e1000_set_es2lan_mac_loopback(adapter); |
|
1459 break; |
|
1460 case e1000_82571: |
|
1461 case e1000_82572: |
|
1462 return e1000_set_82571_fiber_loopback(adapter); |
|
1463 break; |
|
1464 default: |
|
1465 rctl = er32(RCTL); |
|
1466 rctl |= E1000_RCTL_LBM_TCVR; |
|
1467 ew32(RCTL, rctl); |
|
1468 return 0; |
|
1469 } |
|
1470 } else if (hw->phy.media_type == e1000_media_type_copper) { |
|
1471 return e1000_integrated_phy_loopback(adapter); |
|
1472 } |
|
1473 |
|
1474 return 7; |
|
1475 } |
|
1476 |
|
1477 static void e1000_loopback_cleanup(struct e1000_adapter *adapter) |
|
1478 { |
|
1479 struct e1000_hw *hw = &adapter->hw; |
|
1480 u32 rctl; |
|
1481 u16 phy_reg; |
|
1482 |
|
1483 rctl = er32(RCTL); |
|
1484 rctl &= ~(E1000_RCTL_LBM_TCVR | E1000_RCTL_LBM_MAC); |
|
1485 ew32(RCTL, rctl); |
|
1486 |
|
1487 switch (hw->mac.type) { |
|
1488 case e1000_80003es2lan: |
|
1489 if (hw->phy.media_type == e1000_media_type_fiber || |
|
1490 hw->phy.media_type == e1000_media_type_internal_serdes) { |
|
1491 /* restore CTRL_EXT, stealing space from tx_fifo_head */ |
|
1492 ew32(CTRL_EXT, adapter->tx_fifo_head); |
|
1493 adapter->tx_fifo_head = 0; |
|
1494 } |
|
1495 /* fall through */ |
|
1496 case e1000_82571: |
|
1497 case e1000_82572: |
|
1498 if (hw->phy.media_type == e1000_media_type_fiber || |
|
1499 hw->phy.media_type == e1000_media_type_internal_serdes) { |
|
1500 #define E1000_SERDES_LB_OFF 0x400 |
|
1501 ew32(SCTL, E1000_SERDES_LB_OFF); |
|
1502 msleep(10); |
|
1503 break; |
|
1504 } |
|
1505 /* Fall Through */ |
|
1506 default: |
|
1507 hw->mac.autoneg = 1; |
|
1508 if (hw->phy.type == e1000_phy_gg82563) |
|
1509 e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, 0x180); |
|
1510 e1e_rphy(hw, PHY_CONTROL, &phy_reg); |
|
1511 if (phy_reg & MII_CR_LOOPBACK) { |
|
1512 phy_reg &= ~MII_CR_LOOPBACK; |
|
1513 e1e_wphy(hw, PHY_CONTROL, phy_reg); |
|
1514 e1000e_commit_phy(hw); |
|
1515 } |
|
1516 break; |
|
1517 } |
|
1518 } |
|
1519 |
|
1520 static void e1000_create_lbtest_frame(struct sk_buff *skb, |
|
1521 unsigned int frame_size) |
|
1522 { |
|
1523 memset(skb->data, 0xFF, frame_size); |
|
1524 frame_size &= ~1; |
|
1525 memset(&skb->data[frame_size / 2], 0xAA, frame_size / 2 - 1); |
|
1526 memset(&skb->data[frame_size / 2 + 10], 0xBE, 1); |
|
1527 memset(&skb->data[frame_size / 2 + 12], 0xAF, 1); |
|
1528 } |
|
1529 |
|
1530 static int e1000_check_lbtest_frame(struct sk_buff *skb, |
|
1531 unsigned int frame_size) |
|
1532 { |
|
1533 frame_size &= ~1; |
|
1534 if (*(skb->data + 3) == 0xFF) |
|
1535 if ((*(skb->data + frame_size / 2 + 10) == 0xBE) && |
|
1536 (*(skb->data + frame_size / 2 + 12) == 0xAF)) |
|
1537 return 0; |
|
1538 return 13; |
|
1539 } |
|
1540 |
|
1541 static int e1000_run_loopback_test(struct e1000_adapter *adapter) |
|
1542 { |
|
1543 struct e1000_ring *tx_ring = &adapter->test_tx_ring; |
|
1544 struct e1000_ring *rx_ring = &adapter->test_rx_ring; |
|
1545 struct pci_dev *pdev = adapter->pdev; |
|
1546 struct e1000_hw *hw = &adapter->hw; |
|
1547 int i, j, k, l; |
|
1548 int lc; |
|
1549 int good_cnt; |
|
1550 int ret_val = 0; |
|
1551 unsigned long time; |
|
1552 |
|
1553 ew32(RDT, rx_ring->count - 1); |
|
1554 |
|
1555 /* |
|
1556 * Calculate the loop count based on the largest descriptor ring |
|
1557 * The idea is to wrap the largest ring a number of times using 64 |
|
1558 * send/receive pairs during each loop |
|
1559 */ |
|
1560 |
|
1561 if (rx_ring->count <= tx_ring->count) |
|
1562 lc = ((tx_ring->count / 64) * 2) + 1; |
|
1563 else |
|
1564 lc = ((rx_ring->count / 64) * 2) + 1; |
|
1565 |
|
1566 k = 0; |
|
1567 l = 0; |
|
1568 for (j = 0; j <= lc; j++) { /* loop count loop */ |
|
1569 for (i = 0; i < 64; i++) { /* send the packets */ |
|
1570 e1000_create_lbtest_frame(tx_ring->buffer_info[k].skb, |
|
1571 1024); |
|
1572 dma_sync_single_for_device(&pdev->dev, |
|
1573 tx_ring->buffer_info[k].dma, |
|
1574 tx_ring->buffer_info[k].length, |
|
1575 DMA_TO_DEVICE); |
|
1576 k++; |
|
1577 if (k == tx_ring->count) |
|
1578 k = 0; |
|
1579 } |
|
1580 ew32(TDT, k); |
|
1581 msleep(200); |
|
1582 time = jiffies; /* set the start time for the receive */ |
|
1583 good_cnt = 0; |
|
1584 do { /* receive the sent packets */ |
|
1585 dma_sync_single_for_cpu(&pdev->dev, |
|
1586 rx_ring->buffer_info[l].dma, 2048, |
|
1587 DMA_FROM_DEVICE); |
|
1588 |
|
1589 ret_val = e1000_check_lbtest_frame( |
|
1590 rx_ring->buffer_info[l].skb, 1024); |
|
1591 if (!ret_val) |
|
1592 good_cnt++; |
|
1593 l++; |
|
1594 if (l == rx_ring->count) |
|
1595 l = 0; |
|
1596 /* |
|
1597 * time + 20 msecs (200 msecs on 2.4) is more than |
|
1598 * enough time to complete the receives, if it's |
|
1599 * exceeded, break and error off |
|
1600 */ |
|
1601 } while ((good_cnt < 64) && !time_after(jiffies, time + 20)); |
|
1602 if (good_cnt != 64) { |
|
1603 ret_val = 13; /* ret_val is the same as mis-compare */ |
|
1604 break; |
|
1605 } |
|
1606 if (jiffies >= (time + 20)) { |
|
1607 ret_val = 14; /* error code for time out error */ |
|
1608 break; |
|
1609 } |
|
1610 } /* end loop count loop */ |
|
1611 return ret_val; |
|
1612 } |
|
1613 |
|
1614 static int e1000_loopback_test(struct e1000_adapter *adapter, u64 *data) |
|
1615 { |
|
1616 /* |
|
1617 * PHY loopback cannot be performed if SoL/IDER |
|
1618 * sessions are active |
|
1619 */ |
|
1620 if (e1000_check_reset_block(&adapter->hw)) { |
|
1621 e_err("Cannot do PHY loopback test when SoL/IDER is active.\n"); |
|
1622 *data = 0; |
|
1623 goto out; |
|
1624 } |
|
1625 |
|
1626 *data = e1000_setup_desc_rings(adapter); |
|
1627 if (*data) |
|
1628 goto out; |
|
1629 |
|
1630 *data = e1000_setup_loopback_test(adapter); |
|
1631 if (*data) |
|
1632 goto err_loopback; |
|
1633 |
|
1634 *data = e1000_run_loopback_test(adapter); |
|
1635 e1000_loopback_cleanup(adapter); |
|
1636 |
|
1637 err_loopback: |
|
1638 e1000_free_desc_rings(adapter); |
|
1639 out: |
|
1640 return *data; |
|
1641 } |
|
1642 |
|
1643 static int e1000_link_test(struct e1000_adapter *adapter, u64 *data) |
|
1644 { |
|
1645 struct e1000_hw *hw = &adapter->hw; |
|
1646 |
|
1647 *data = 0; |
|
1648 if (hw->phy.media_type == e1000_media_type_internal_serdes) { |
|
1649 int i = 0; |
|
1650 hw->mac.serdes_has_link = false; |
|
1651 |
|
1652 /* |
|
1653 * On some blade server designs, link establishment |
|
1654 * could take as long as 2-3 minutes |
|
1655 */ |
|
1656 do { |
|
1657 hw->mac.ops.check_for_link(hw); |
|
1658 if (hw->mac.serdes_has_link) |
|
1659 return *data; |
|
1660 msleep(20); |
|
1661 } while (i++ < 3750); |
|
1662 |
|
1663 *data = 1; |
|
1664 } else { |
|
1665 hw->mac.ops.check_for_link(hw); |
|
1666 if (hw->mac.autoneg) |
|
1667 msleep(4000); |
|
1668 |
|
1669 if (!(er32(STATUS) & |
|
1670 E1000_STATUS_LU)) |
|
1671 *data = 1; |
|
1672 } |
|
1673 return *data; |
|
1674 } |
|
1675 |
|
1676 static int e1000e_get_sset_count(struct net_device *netdev, int sset) |
|
1677 { |
|
1678 switch (sset) { |
|
1679 case ETH_SS_TEST: |
|
1680 return E1000_TEST_LEN; |
|
1681 case ETH_SS_STATS: |
|
1682 return E1000_STATS_LEN; |
|
1683 default: |
|
1684 return -EOPNOTSUPP; |
|
1685 } |
|
1686 } |
|
1687 |
|
1688 static void e1000_diag_test(struct net_device *netdev, |
|
1689 struct ethtool_test *eth_test, u64 *data) |
|
1690 { |
|
1691 struct e1000_adapter *adapter = netdev_priv(netdev); |
|
1692 u16 autoneg_advertised; |
|
1693 u8 forced_speed_duplex; |
|
1694 u8 autoneg; |
|
1695 bool if_running = 0; |
|
1696 |
|
1697 if (adapter->ecdev) |
|
1698 return; |
|
1699 |
|
1700 if_running = netif_running(netdev); |
|
1701 |
|
1702 set_bit(__E1000_TESTING, &adapter->state); |
|
1703 if (eth_test->flags == ETH_TEST_FL_OFFLINE) { |
|
1704 /* Offline tests */ |
|
1705 |
|
1706 /* save speed, duplex, autoneg settings */ |
|
1707 autoneg_advertised = adapter->hw.phy.autoneg_advertised; |
|
1708 forced_speed_duplex = adapter->hw.mac.forced_speed_duplex; |
|
1709 autoneg = adapter->hw.mac.autoneg; |
|
1710 |
|
1711 e_info("offline testing starting\n"); |
|
1712 |
|
1713 /* |
|
1714 * Link test performed before hardware reset so autoneg doesn't |
|
1715 * interfere with test result |
|
1716 */ |
|
1717 if (e1000_link_test(adapter, &data[4])) |
|
1718 eth_test->flags |= ETH_TEST_FL_FAILED; |
|
1719 |
|
1720 if (if_running) |
|
1721 /* indicate we're in test mode */ |
|
1722 dev_close(netdev); |
|
1723 else |
|
1724 e1000e_reset(adapter); |
|
1725 |
|
1726 if (e1000_reg_test(adapter, &data[0])) |
|
1727 eth_test->flags |= ETH_TEST_FL_FAILED; |
|
1728 |
|
1729 e1000e_reset(adapter); |
|
1730 if (e1000_eeprom_test(adapter, &data[1])) |
|
1731 eth_test->flags |= ETH_TEST_FL_FAILED; |
|
1732 |
|
1733 e1000e_reset(adapter); |
|
1734 if (e1000_intr_test(adapter, &data[2])) |
|
1735 eth_test->flags |= ETH_TEST_FL_FAILED; |
|
1736 |
|
1737 e1000e_reset(adapter); |
|
1738 /* make sure the phy is powered up */ |
|
1739 e1000e_power_up_phy(adapter); |
|
1740 if (e1000_loopback_test(adapter, &data[3])) |
|
1741 eth_test->flags |= ETH_TEST_FL_FAILED; |
|
1742 |
|
1743 /* restore speed, duplex, autoneg settings */ |
|
1744 adapter->hw.phy.autoneg_advertised = autoneg_advertised; |
|
1745 adapter->hw.mac.forced_speed_duplex = forced_speed_duplex; |
|
1746 adapter->hw.mac.autoneg = autoneg; |
|
1747 |
|
1748 /* force this routine to wait until autoneg complete/timeout */ |
|
1749 adapter->hw.phy.autoneg_wait_to_complete = 1; |
|
1750 e1000e_reset(adapter); |
|
1751 adapter->hw.phy.autoneg_wait_to_complete = 0; |
|
1752 |
|
1753 clear_bit(__E1000_TESTING, &adapter->state); |
|
1754 if (if_running) |
|
1755 dev_open(netdev); |
|
1756 } else { |
|
1757 if (!if_running && (adapter->flags & FLAG_HAS_AMT)) { |
|
1758 clear_bit(__E1000_TESTING, &adapter->state); |
|
1759 dev_open(netdev); |
|
1760 set_bit(__E1000_TESTING, &adapter->state); |
|
1761 } |
|
1762 |
|
1763 e_info("online testing starting\n"); |
|
1764 /* Online tests */ |
|
1765 if (e1000_link_test(adapter, &data[4])) |
|
1766 eth_test->flags |= ETH_TEST_FL_FAILED; |
|
1767 |
|
1768 /* Online tests aren't run; pass by default */ |
|
1769 data[0] = 0; |
|
1770 data[1] = 0; |
|
1771 data[2] = 0; |
|
1772 data[3] = 0; |
|
1773 |
|
1774 if (!if_running && (adapter->flags & FLAG_HAS_AMT)) |
|
1775 dev_close(netdev); |
|
1776 |
|
1777 clear_bit(__E1000_TESTING, &adapter->state); |
|
1778 } |
|
1779 msleep_interruptible(4 * 1000); |
|
1780 } |
|
1781 |
|
1782 static void e1000_get_wol(struct net_device *netdev, |
|
1783 struct ethtool_wolinfo *wol) |
|
1784 { |
|
1785 struct e1000_adapter *adapter = netdev_priv(netdev); |
|
1786 |
|
1787 wol->supported = 0; |
|
1788 wol->wolopts = 0; |
|
1789 |
|
1790 if (!(adapter->flags & FLAG_HAS_WOL) || |
|
1791 !device_can_wakeup(&adapter->pdev->dev)) |
|
1792 return; |
|
1793 |
|
1794 wol->supported = WAKE_UCAST | WAKE_MCAST | |
|
1795 WAKE_BCAST | WAKE_MAGIC | |
|
1796 WAKE_PHY | WAKE_ARP; |
|
1797 |
|
1798 /* apply any specific unsupported masks here */ |
|
1799 if (adapter->flags & FLAG_NO_WAKE_UCAST) { |
|
1800 wol->supported &= ~WAKE_UCAST; |
|
1801 |
|
1802 if (adapter->wol & E1000_WUFC_EX) |
|
1803 e_err("Interface does not support directed (unicast) " |
|
1804 "frame wake-up packets\n"); |
|
1805 } |
|
1806 |
|
1807 if (adapter->wol & E1000_WUFC_EX) |
|
1808 wol->wolopts |= WAKE_UCAST; |
|
1809 if (adapter->wol & E1000_WUFC_MC) |
|
1810 wol->wolopts |= WAKE_MCAST; |
|
1811 if (adapter->wol & E1000_WUFC_BC) |
|
1812 wol->wolopts |= WAKE_BCAST; |
|
1813 if (adapter->wol & E1000_WUFC_MAG) |
|
1814 wol->wolopts |= WAKE_MAGIC; |
|
1815 if (adapter->wol & E1000_WUFC_LNKC) |
|
1816 wol->wolopts |= WAKE_PHY; |
|
1817 if (adapter->wol & E1000_WUFC_ARP) |
|
1818 wol->wolopts |= WAKE_ARP; |
|
1819 } |
|
1820 |
|
1821 static int e1000_set_wol(struct net_device *netdev, |
|
1822 struct ethtool_wolinfo *wol) |
|
1823 { |
|
1824 struct e1000_adapter *adapter = netdev_priv(netdev); |
|
1825 |
|
1826 if (!(adapter->flags & FLAG_HAS_WOL) || |
|
1827 !device_can_wakeup(&adapter->pdev->dev) || |
|
1828 (wol->wolopts & ~(WAKE_UCAST | WAKE_MCAST | WAKE_BCAST | |
|
1829 WAKE_MAGIC | WAKE_PHY | WAKE_ARP))) |
|
1830 return -EOPNOTSUPP; |
|
1831 |
|
1832 /* these settings will always override what we currently have */ |
|
1833 adapter->wol = 0; |
|
1834 |
|
1835 if (wol->wolopts & WAKE_UCAST) |
|
1836 adapter->wol |= E1000_WUFC_EX; |
|
1837 if (wol->wolopts & WAKE_MCAST) |
|
1838 adapter->wol |= E1000_WUFC_MC; |
|
1839 if (wol->wolopts & WAKE_BCAST) |
|
1840 adapter->wol |= E1000_WUFC_BC; |
|
1841 if (wol->wolopts & WAKE_MAGIC) |
|
1842 adapter->wol |= E1000_WUFC_MAG; |
|
1843 if (wol->wolopts & WAKE_PHY) |
|
1844 adapter->wol |= E1000_WUFC_LNKC; |
|
1845 if (wol->wolopts & WAKE_ARP) |
|
1846 adapter->wol |= E1000_WUFC_ARP; |
|
1847 |
|
1848 device_set_wakeup_enable(&adapter->pdev->dev, adapter->wol); |
|
1849 |
|
1850 return 0; |
|
1851 } |
|
1852 |
|
1853 /* toggle LED 4 times per second = 2 "blinks" per second */ |
|
1854 #define E1000_ID_INTERVAL (HZ/4) |
|
1855 |
|
1856 /* bit defines for adapter->led_status */ |
|
1857 #define E1000_LED_ON 0 |
|
1858 |
|
1859 static void e1000e_led_blink_task(struct work_struct *work) |
|
1860 { |
|
1861 struct e1000_adapter *adapter = container_of(work, |
|
1862 struct e1000_adapter, led_blink_task); |
|
1863 |
|
1864 if (test_and_change_bit(E1000_LED_ON, &adapter->led_status)) |
|
1865 adapter->hw.mac.ops.led_off(&adapter->hw); |
|
1866 else |
|
1867 adapter->hw.mac.ops.led_on(&adapter->hw); |
|
1868 } |
|
1869 |
|
1870 static void e1000_led_blink_callback(unsigned long data) |
|
1871 { |
|
1872 struct e1000_adapter *adapter = (struct e1000_adapter *) data; |
|
1873 |
|
1874 schedule_work(&adapter->led_blink_task); |
|
1875 mod_timer(&adapter->blink_timer, jiffies + E1000_ID_INTERVAL); |
|
1876 } |
|
1877 |
|
1878 static int e1000_phys_id(struct net_device *netdev, u32 data) |
|
1879 { |
|
1880 struct e1000_adapter *adapter = netdev_priv(netdev); |
|
1881 struct e1000_hw *hw = &adapter->hw; |
|
1882 |
|
1883 if (!data) |
|
1884 data = INT_MAX; |
|
1885 |
|
1886 if ((hw->phy.type == e1000_phy_ife) || |
|
1887 (hw->mac.type == e1000_pchlan) || |
|
1888 (hw->mac.type == e1000_82583) || |
|
1889 (hw->mac.type == e1000_82574)) { |
|
1890 INIT_WORK(&adapter->led_blink_task, e1000e_led_blink_task); |
|
1891 if (!adapter->blink_timer.function) { |
|
1892 init_timer(&adapter->blink_timer); |
|
1893 adapter->blink_timer.function = |
|
1894 e1000_led_blink_callback; |
|
1895 adapter->blink_timer.data = (unsigned long) adapter; |
|
1896 } |
|
1897 mod_timer(&adapter->blink_timer, jiffies); |
|
1898 msleep_interruptible(data * 1000); |
|
1899 del_timer_sync(&adapter->blink_timer); |
|
1900 if (hw->phy.type == e1000_phy_ife) |
|
1901 e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED, 0); |
|
1902 } else { |
|
1903 e1000e_blink_led(hw); |
|
1904 msleep_interruptible(data * 1000); |
|
1905 } |
|
1906 |
|
1907 hw->mac.ops.led_off(hw); |
|
1908 clear_bit(E1000_LED_ON, &adapter->led_status); |
|
1909 hw->mac.ops.cleanup_led(hw); |
|
1910 |
|
1911 return 0; |
|
1912 } |
|
1913 |
|
1914 static int e1000_get_coalesce(struct net_device *netdev, |
|
1915 struct ethtool_coalesce *ec) |
|
1916 { |
|
1917 struct e1000_adapter *adapter = netdev_priv(netdev); |
|
1918 |
|
1919 if (adapter->itr_setting <= 4) |
|
1920 ec->rx_coalesce_usecs = adapter->itr_setting; |
|
1921 else |
|
1922 ec->rx_coalesce_usecs = 1000000 / adapter->itr_setting; |
|
1923 |
|
1924 return 0; |
|
1925 } |
|
1926 |
|
1927 static int e1000_set_coalesce(struct net_device *netdev, |
|
1928 struct ethtool_coalesce *ec) |
|
1929 { |
|
1930 struct e1000_adapter *adapter = netdev_priv(netdev); |
|
1931 struct e1000_hw *hw = &adapter->hw; |
|
1932 |
|
1933 if ((ec->rx_coalesce_usecs > E1000_MAX_ITR_USECS) || |
|
1934 ((ec->rx_coalesce_usecs > 4) && |
|
1935 (ec->rx_coalesce_usecs < E1000_MIN_ITR_USECS)) || |
|
1936 (ec->rx_coalesce_usecs == 2)) |
|
1937 return -EINVAL; |
|
1938 |
|
1939 if (ec->rx_coalesce_usecs == 4) { |
|
1940 adapter->itr = adapter->itr_setting = 4; |
|
1941 } else if (ec->rx_coalesce_usecs <= 3) { |
|
1942 adapter->itr = 20000; |
|
1943 adapter->itr_setting = ec->rx_coalesce_usecs; |
|
1944 } else { |
|
1945 adapter->itr = (1000000 / ec->rx_coalesce_usecs); |
|
1946 adapter->itr_setting = adapter->itr & ~3; |
|
1947 } |
|
1948 |
|
1949 if (adapter->itr_setting != 0) |
|
1950 ew32(ITR, 1000000000 / (adapter->itr * 256)); |
|
1951 else |
|
1952 ew32(ITR, 0); |
|
1953 |
|
1954 return 0; |
|
1955 } |
|
1956 |
|
1957 static int e1000_nway_reset(struct net_device *netdev) |
|
1958 { |
|
1959 struct e1000_adapter *adapter = netdev_priv(netdev); |
|
1960 |
|
1961 if (adapter->ecdev) |
|
1962 return -EBUSY; |
|
1963 |
|
1964 if (netif_running(netdev)) |
|
1965 e1000e_reinit_locked(adapter); |
|
1966 return 0; |
|
1967 } |
|
1968 |
|
1969 static void e1000_get_ethtool_stats(struct net_device *netdev, |
|
1970 struct ethtool_stats *stats, |
|
1971 u64 *data) |
|
1972 { |
|
1973 struct e1000_adapter *adapter = netdev_priv(netdev); |
|
1974 int i; |
|
1975 char *p = NULL; |
|
1976 |
|
1977 e1000e_update_stats(adapter); |
|
1978 for (i = 0; i < E1000_GLOBAL_STATS_LEN; i++) { |
|
1979 switch (e1000_gstrings_stats[i].type) { |
|
1980 case NETDEV_STATS: |
|
1981 p = (char *) netdev + |
|
1982 e1000_gstrings_stats[i].stat_offset; |
|
1983 break; |
|
1984 case E1000_STATS: |
|
1985 p = (char *) adapter + |
|
1986 e1000_gstrings_stats[i].stat_offset; |
|
1987 break; |
|
1988 } |
|
1989 |
|
1990 data[i] = (e1000_gstrings_stats[i].sizeof_stat == |
|
1991 sizeof(u64)) ? *(u64 *)p : *(u32 *)p; |
|
1992 } |
|
1993 } |
|
1994 |
|
1995 static void e1000_get_strings(struct net_device *netdev, u32 stringset, |
|
1996 u8 *data) |
|
1997 { |
|
1998 u8 *p = data; |
|
1999 int i; |
|
2000 |
|
2001 switch (stringset) { |
|
2002 case ETH_SS_TEST: |
|
2003 memcpy(data, *e1000_gstrings_test, sizeof(e1000_gstrings_test)); |
|
2004 break; |
|
2005 case ETH_SS_STATS: |
|
2006 for (i = 0; i < E1000_GLOBAL_STATS_LEN; i++) { |
|
2007 memcpy(p, e1000_gstrings_stats[i].stat_string, |
|
2008 ETH_GSTRING_LEN); |
|
2009 p += ETH_GSTRING_LEN; |
|
2010 } |
|
2011 break; |
|
2012 } |
|
2013 } |
|
2014 |
|
2015 static const struct ethtool_ops e1000_ethtool_ops = { |
|
2016 .get_settings = e1000_get_settings, |
|
2017 .set_settings = e1000_set_settings, |
|
2018 .get_drvinfo = e1000_get_drvinfo, |
|
2019 .get_regs_len = e1000_get_regs_len, |
|
2020 .get_regs = e1000_get_regs, |
|
2021 .get_wol = e1000_get_wol, |
|
2022 .set_wol = e1000_set_wol, |
|
2023 .get_msglevel = e1000_get_msglevel, |
|
2024 .set_msglevel = e1000_set_msglevel, |
|
2025 .nway_reset = e1000_nway_reset, |
|
2026 .get_link = e1000_get_link, |
|
2027 .get_eeprom_len = e1000_get_eeprom_len, |
|
2028 .get_eeprom = e1000_get_eeprom, |
|
2029 .set_eeprom = e1000_set_eeprom, |
|
2030 .get_ringparam = e1000_get_ringparam, |
|
2031 .set_ringparam = e1000_set_ringparam, |
|
2032 .get_pauseparam = e1000_get_pauseparam, |
|
2033 .set_pauseparam = e1000_set_pauseparam, |
|
2034 .get_rx_csum = e1000_get_rx_csum, |
|
2035 .set_rx_csum = e1000_set_rx_csum, |
|
2036 .get_tx_csum = e1000_get_tx_csum, |
|
2037 .set_tx_csum = e1000_set_tx_csum, |
|
2038 .get_sg = ethtool_op_get_sg, |
|
2039 .set_sg = ethtool_op_set_sg, |
|
2040 .get_tso = ethtool_op_get_tso, |
|
2041 .set_tso = e1000_set_tso, |
|
2042 .self_test = e1000_diag_test, |
|
2043 .get_strings = e1000_get_strings, |
|
2044 .phys_id = e1000_phys_id, |
|
2045 .get_ethtool_stats = e1000_get_ethtool_stats, |
|
2046 .get_sset_count = e1000e_get_sset_count, |
|
2047 .get_coalesce = e1000_get_coalesce, |
|
2048 .set_coalesce = e1000_set_coalesce, |
|
2049 .get_flags = ethtool_op_get_flags, |
|
2050 .set_flags = ethtool_op_set_flags, |
|
2051 }; |
|
2052 |
|
2053 void e1000e_set_ethtool_ops(struct net_device *netdev) |
|
2054 { |
|
2055 SET_ETHTOOL_OPS(netdev, &e1000_ethtool_ops); |
|
2056 } |