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