1 /*******************************************************************************
3 Intel PRO/10GbE Linux driver
4 Copyright(c) 1999 - 2006 Intel Corporation.
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.
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
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.
19 The full GNU General Public License is included in this distribution in
20 the file called "COPYING".
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
27 *******************************************************************************/
29 /* ethtool support for ixgb */
33 #include <asm/uaccess.h>
35 extern int ixgb_up(struct ixgb_adapter
*adapter
);
36 extern void ixgb_down(struct ixgb_adapter
*adapter
, boolean_t kill_watchdog
);
37 extern void ixgb_reset(struct ixgb_adapter
*adapter
);
38 extern int ixgb_setup_rx_resources(struct ixgb_adapter
*adapter
);
39 extern int ixgb_setup_tx_resources(struct ixgb_adapter
*adapter
);
40 extern void ixgb_free_rx_resources(struct ixgb_adapter
*adapter
);
41 extern void ixgb_free_tx_resources(struct ixgb_adapter
*adapter
);
42 extern void ixgb_update_stats(struct ixgb_adapter
*adapter
);
44 #define IXGB_ALL_RAR_ENTRIES 16
47 char stat_string
[ETH_GSTRING_LEN
];
52 <<<<<<< HEAD
:drivers
/net
/ixgb
/ixgb_ethtool
.c
53 #define IXGB_STAT(m) sizeof(((struct ixgb_adapter *)0)->m), \
55 #define IXGB_STAT(m) FIELD_SIZEOF(struct ixgb_adapter, m), \
56 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/net/ixgb/ixgb_ethtool.c
57 offsetof(struct ixgb_adapter
, m
)
58 static struct ixgb_stats ixgb_gstrings_stats
[] = {
59 {"rx_packets", IXGB_STAT(net_stats
.rx_packets
)},
60 {"tx_packets", IXGB_STAT(net_stats
.tx_packets
)},
61 {"rx_bytes", IXGB_STAT(net_stats
.rx_bytes
)},
62 {"tx_bytes", IXGB_STAT(net_stats
.tx_bytes
)},
63 {"rx_errors", IXGB_STAT(net_stats
.rx_errors
)},
64 {"tx_errors", IXGB_STAT(net_stats
.tx_errors
)},
65 {"rx_dropped", IXGB_STAT(net_stats
.rx_dropped
)},
66 {"tx_dropped", IXGB_STAT(net_stats
.tx_dropped
)},
67 {"multicast", IXGB_STAT(net_stats
.multicast
)},
68 {"collisions", IXGB_STAT(net_stats
.collisions
)},
70 /* { "rx_length_errors", IXGB_STAT(net_stats.rx_length_errors) }, */
71 {"rx_over_errors", IXGB_STAT(net_stats
.rx_over_errors
)},
72 {"rx_crc_errors", IXGB_STAT(net_stats
.rx_crc_errors
)},
73 {"rx_frame_errors", IXGB_STAT(net_stats
.rx_frame_errors
)},
74 <<<<<<< HEAD
:drivers
/net
/ixgb
/ixgb_ethtool
.c
76 {"rx_no_buffer_count", IXGB_STAT(stats
.rnbc
)},
77 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/net
/ixgb
/ixgb_ethtool
.c
78 {"rx_fifo_errors", IXGB_STAT(net_stats
.rx_fifo_errors
)},
79 {"rx_missed_errors", IXGB_STAT(net_stats
.rx_missed_errors
)},
80 {"tx_aborted_errors", IXGB_STAT(net_stats
.tx_aborted_errors
)},
81 {"tx_carrier_errors", IXGB_STAT(net_stats
.tx_carrier_errors
)},
82 {"tx_fifo_errors", IXGB_STAT(net_stats
.tx_fifo_errors
)},
83 {"tx_heartbeat_errors", IXGB_STAT(net_stats
.tx_heartbeat_errors
)},
84 {"tx_window_errors", IXGB_STAT(net_stats
.tx_window_errors
)},
85 {"tx_deferred_ok", IXGB_STAT(stats
.dc
)},
86 {"tx_timeout_count", IXGB_STAT(tx_timeout_count
) },
87 {"tx_restart_queue", IXGB_STAT(restart_queue
) },
88 {"rx_long_length_errors", IXGB_STAT(stats
.roc
)},
89 {"rx_short_length_errors", IXGB_STAT(stats
.ruc
)},
90 {"tx_tcp_seg_good", IXGB_STAT(stats
.tsctc
)},
91 {"tx_tcp_seg_failed", IXGB_STAT(stats
.tsctfc
)},
92 {"rx_flow_control_xon", IXGB_STAT(stats
.xonrxc
)},
93 {"rx_flow_control_xoff", IXGB_STAT(stats
.xoffrxc
)},
94 {"tx_flow_control_xon", IXGB_STAT(stats
.xontxc
)},
95 {"tx_flow_control_xoff", IXGB_STAT(stats
.xofftxc
)},
96 {"rx_csum_offload_good", IXGB_STAT(hw_csum_rx_good
)},
97 {"rx_csum_offload_errors", IXGB_STAT(hw_csum_rx_error
)},
98 {"tx_csum_offload_good", IXGB_STAT(hw_csum_tx_good
)},
99 {"tx_csum_offload_errors", IXGB_STAT(hw_csum_tx_error
)}
102 #define IXGB_STATS_LEN ARRAY_SIZE(ixgb_gstrings_stats)
105 ixgb_get_settings(struct net_device
*netdev
, struct ethtool_cmd
*ecmd
)
107 struct ixgb_adapter
*adapter
= netdev_priv(netdev
);
109 ecmd
->supported
= (SUPPORTED_10000baseT_Full
| SUPPORTED_FIBRE
);
110 ecmd
->advertising
= (ADVERTISED_10000baseT_Full
| ADVERTISED_FIBRE
);
111 ecmd
->port
= PORT_FIBRE
;
112 ecmd
->transceiver
= XCVR_EXTERNAL
;
114 if(netif_carrier_ok(adapter
->netdev
)) {
115 ecmd
->speed
= SPEED_10000
;
116 ecmd
->duplex
= DUPLEX_FULL
;
122 ecmd
->autoneg
= AUTONEG_DISABLE
;
126 static void ixgb_set_speed_duplex(struct net_device
*netdev
)
128 struct ixgb_adapter
*adapter
= netdev_priv(netdev
);
129 /* be optimistic about our link, since we were up before */
130 adapter
->link_speed
= 10000;
131 adapter
->link_duplex
= FULL_DUPLEX
;
132 netif_carrier_on(netdev
);
133 netif_wake_queue(netdev
);
137 ixgb_set_settings(struct net_device
*netdev
, struct ethtool_cmd
*ecmd
)
139 struct ixgb_adapter
*adapter
= netdev_priv(netdev
);
141 if(ecmd
->autoneg
== AUTONEG_ENABLE
||
142 ecmd
->speed
+ ecmd
->duplex
!= SPEED_10000
+ DUPLEX_FULL
)
145 if(netif_running(adapter
->netdev
)) {
146 ixgb_down(adapter
, TRUE
);
149 ixgb_set_speed_duplex(netdev
);
157 ixgb_get_pauseparam(struct net_device
*netdev
,
158 struct ethtool_pauseparam
*pause
)
160 struct ixgb_adapter
*adapter
= netdev_priv(netdev
);
161 struct ixgb_hw
*hw
= &adapter
->hw
;
163 pause
->autoneg
= AUTONEG_DISABLE
;
165 if(hw
->fc
.type
== ixgb_fc_rx_pause
)
167 else if(hw
->fc
.type
== ixgb_fc_tx_pause
)
169 else if(hw
->fc
.type
== ixgb_fc_full
) {
176 ixgb_set_pauseparam(struct net_device
*netdev
,
177 struct ethtool_pauseparam
*pause
)
179 struct ixgb_adapter
*adapter
= netdev_priv(netdev
);
180 struct ixgb_hw
*hw
= &adapter
->hw
;
182 if(pause
->autoneg
== AUTONEG_ENABLE
)
185 if(pause
->rx_pause
&& pause
->tx_pause
)
186 hw
->fc
.type
= ixgb_fc_full
;
187 else if(pause
->rx_pause
&& !pause
->tx_pause
)
188 hw
->fc
.type
= ixgb_fc_rx_pause
;
189 else if(!pause
->rx_pause
&& pause
->tx_pause
)
190 hw
->fc
.type
= ixgb_fc_tx_pause
;
191 else if(!pause
->rx_pause
&& !pause
->tx_pause
)
192 hw
->fc
.type
= ixgb_fc_none
;
194 if(netif_running(adapter
->netdev
)) {
195 ixgb_down(adapter
, TRUE
);
197 ixgb_set_speed_duplex(netdev
);
205 ixgb_get_rx_csum(struct net_device
*netdev
)
207 struct ixgb_adapter
*adapter
= netdev_priv(netdev
);
209 return adapter
->rx_csum
;
213 ixgb_set_rx_csum(struct net_device
*netdev
, uint32_t data
)
215 struct ixgb_adapter
*adapter
= netdev_priv(netdev
);
217 adapter
->rx_csum
= data
;
219 if(netif_running(netdev
)) {
220 ixgb_down(adapter
,TRUE
);
222 ixgb_set_speed_duplex(netdev
);
229 ixgb_get_tx_csum(struct net_device
*netdev
)
231 return (netdev
->features
& NETIF_F_HW_CSUM
) != 0;
235 ixgb_set_tx_csum(struct net_device
*netdev
, uint32_t data
)
238 netdev
->features
|= NETIF_F_HW_CSUM
;
240 netdev
->features
&= ~NETIF_F_HW_CSUM
;
246 ixgb_set_tso(struct net_device
*netdev
, uint32_t data
)
249 netdev
->features
|= NETIF_F_TSO
;
251 netdev
->features
&= ~NETIF_F_TSO
;
256 ixgb_get_msglevel(struct net_device
*netdev
)
258 struct ixgb_adapter
*adapter
= netdev_priv(netdev
);
259 return adapter
->msg_enable
;
263 ixgb_set_msglevel(struct net_device
*netdev
, uint32_t data
)
265 struct ixgb_adapter
*adapter
= netdev_priv(netdev
);
266 adapter
->msg_enable
= data
;
268 #define IXGB_GET_STAT(_A_, _R_) _A_->stats._R_
271 ixgb_get_regs_len(struct net_device
*netdev
)
273 #define IXGB_REG_DUMP_LEN 136*sizeof(uint32_t)
274 return IXGB_REG_DUMP_LEN
;
278 ixgb_get_regs(struct net_device
*netdev
,
279 struct ethtool_regs
*regs
, void *p
)
281 struct ixgb_adapter
*adapter
= netdev_priv(netdev
);
282 struct ixgb_hw
*hw
= &adapter
->hw
;
284 uint32_t *reg_start
= reg
;
287 /* the 1 (one) below indicates an attempt at versioning, if the
288 * interface in ethtool or the driver changes, this 1 should be
290 regs
->version
= (1<<24) | hw
->revision_id
<< 16 | hw
->device_id
;
292 /* General Registers */
293 *reg
++ = IXGB_READ_REG(hw
, CTRL0
); /* 0 */
294 *reg
++ = IXGB_READ_REG(hw
, CTRL1
); /* 1 */
295 *reg
++ = IXGB_READ_REG(hw
, STATUS
); /* 2 */
296 *reg
++ = IXGB_READ_REG(hw
, EECD
); /* 3 */
297 *reg
++ = IXGB_READ_REG(hw
, MFS
); /* 4 */
300 *reg
++ = IXGB_READ_REG(hw
, ICR
); /* 5 */
301 *reg
++ = IXGB_READ_REG(hw
, ICS
); /* 6 */
302 *reg
++ = IXGB_READ_REG(hw
, IMS
); /* 7 */
303 *reg
++ = IXGB_READ_REG(hw
, IMC
); /* 8 */
306 *reg
++ = IXGB_READ_REG(hw
, RCTL
); /* 9 */
307 *reg
++ = IXGB_READ_REG(hw
, FCRTL
); /* 10 */
308 *reg
++ = IXGB_READ_REG(hw
, FCRTH
); /* 11 */
309 *reg
++ = IXGB_READ_REG(hw
, RDBAL
); /* 12 */
310 *reg
++ = IXGB_READ_REG(hw
, RDBAH
); /* 13 */
311 *reg
++ = IXGB_READ_REG(hw
, RDLEN
); /* 14 */
312 *reg
++ = IXGB_READ_REG(hw
, RDH
); /* 15 */
313 *reg
++ = IXGB_READ_REG(hw
, RDT
); /* 16 */
314 *reg
++ = IXGB_READ_REG(hw
, RDTR
); /* 17 */
315 *reg
++ = IXGB_READ_REG(hw
, RXDCTL
); /* 18 */
316 *reg
++ = IXGB_READ_REG(hw
, RAIDC
); /* 19 */
317 *reg
++ = IXGB_READ_REG(hw
, RXCSUM
); /* 20 */
319 /* there are 16 RAR entries in hardware, we only use 3 */
320 for(i
= 0; i
< IXGB_ALL_RAR_ENTRIES
; i
++) {
321 *reg
++ = IXGB_READ_REG_ARRAY(hw
, RAL
, (i
<< 1)); /*21,...,51 */
322 *reg
++ = IXGB_READ_REG_ARRAY(hw
, RAH
, (i
<< 1)); /*22,...,52 */
326 *reg
++ = IXGB_READ_REG(hw
, TCTL
); /* 53 */
327 *reg
++ = IXGB_READ_REG(hw
, TDBAL
); /* 54 */
328 *reg
++ = IXGB_READ_REG(hw
, TDBAH
); /* 55 */
329 *reg
++ = IXGB_READ_REG(hw
, TDLEN
); /* 56 */
330 *reg
++ = IXGB_READ_REG(hw
, TDH
); /* 57 */
331 *reg
++ = IXGB_READ_REG(hw
, TDT
); /* 58 */
332 *reg
++ = IXGB_READ_REG(hw
, TIDV
); /* 59 */
333 *reg
++ = IXGB_READ_REG(hw
, TXDCTL
); /* 60 */
334 *reg
++ = IXGB_READ_REG(hw
, TSPMT
); /* 61 */
335 *reg
++ = IXGB_READ_REG(hw
, PAP
); /* 62 */
338 *reg
++ = IXGB_READ_REG(hw
, PCSC1
); /* 63 */
339 *reg
++ = IXGB_READ_REG(hw
, PCSC2
); /* 64 */
340 *reg
++ = IXGB_READ_REG(hw
, PCSS1
); /* 65 */
341 *reg
++ = IXGB_READ_REG(hw
, PCSS2
); /* 66 */
342 *reg
++ = IXGB_READ_REG(hw
, XPCSS
); /* 67 */
343 *reg
++ = IXGB_READ_REG(hw
, UCCR
); /* 68 */
344 *reg
++ = IXGB_READ_REG(hw
, XPCSTC
); /* 69 */
345 *reg
++ = IXGB_READ_REG(hw
, MACA
); /* 70 */
346 *reg
++ = IXGB_READ_REG(hw
, APAE
); /* 71 */
347 *reg
++ = IXGB_READ_REG(hw
, ARD
); /* 72 */
348 *reg
++ = IXGB_READ_REG(hw
, AIS
); /* 73 */
349 *reg
++ = IXGB_READ_REG(hw
, MSCA
); /* 74 */
350 *reg
++ = IXGB_READ_REG(hw
, MSRWD
); /* 75 */
353 *reg
++ = IXGB_GET_STAT(adapter
, tprl
); /* 76 */
354 *reg
++ = IXGB_GET_STAT(adapter
, tprh
); /* 77 */
355 *reg
++ = IXGB_GET_STAT(adapter
, gprcl
); /* 78 */
356 *reg
++ = IXGB_GET_STAT(adapter
, gprch
); /* 79 */
357 *reg
++ = IXGB_GET_STAT(adapter
, bprcl
); /* 80 */
358 *reg
++ = IXGB_GET_STAT(adapter
, bprch
); /* 81 */
359 *reg
++ = IXGB_GET_STAT(adapter
, mprcl
); /* 82 */
360 *reg
++ = IXGB_GET_STAT(adapter
, mprch
); /* 83 */
361 *reg
++ = IXGB_GET_STAT(adapter
, uprcl
); /* 84 */
362 *reg
++ = IXGB_GET_STAT(adapter
, uprch
); /* 85 */
363 *reg
++ = IXGB_GET_STAT(adapter
, vprcl
); /* 86 */
364 *reg
++ = IXGB_GET_STAT(adapter
, vprch
); /* 87 */
365 *reg
++ = IXGB_GET_STAT(adapter
, jprcl
); /* 88 */
366 *reg
++ = IXGB_GET_STAT(adapter
, jprch
); /* 89 */
367 *reg
++ = IXGB_GET_STAT(adapter
, gorcl
); /* 90 */
368 *reg
++ = IXGB_GET_STAT(adapter
, gorch
); /* 91 */
369 *reg
++ = IXGB_GET_STAT(adapter
, torl
); /* 92 */
370 *reg
++ = IXGB_GET_STAT(adapter
, torh
); /* 93 */
371 *reg
++ = IXGB_GET_STAT(adapter
, rnbc
); /* 94 */
372 *reg
++ = IXGB_GET_STAT(adapter
, ruc
); /* 95 */
373 *reg
++ = IXGB_GET_STAT(adapter
, roc
); /* 96 */
374 *reg
++ = IXGB_GET_STAT(adapter
, rlec
); /* 97 */
375 *reg
++ = IXGB_GET_STAT(adapter
, crcerrs
); /* 98 */
376 *reg
++ = IXGB_GET_STAT(adapter
, icbc
); /* 99 */
377 *reg
++ = IXGB_GET_STAT(adapter
, ecbc
); /* 100 */
378 *reg
++ = IXGB_GET_STAT(adapter
, mpc
); /* 101 */
379 *reg
++ = IXGB_GET_STAT(adapter
, tptl
); /* 102 */
380 *reg
++ = IXGB_GET_STAT(adapter
, tpth
); /* 103 */
381 *reg
++ = IXGB_GET_STAT(adapter
, gptcl
); /* 104 */
382 *reg
++ = IXGB_GET_STAT(adapter
, gptch
); /* 105 */
383 *reg
++ = IXGB_GET_STAT(adapter
, bptcl
); /* 106 */
384 *reg
++ = IXGB_GET_STAT(adapter
, bptch
); /* 107 */
385 *reg
++ = IXGB_GET_STAT(adapter
, mptcl
); /* 108 */
386 *reg
++ = IXGB_GET_STAT(adapter
, mptch
); /* 109 */
387 *reg
++ = IXGB_GET_STAT(adapter
, uptcl
); /* 110 */
388 *reg
++ = IXGB_GET_STAT(adapter
, uptch
); /* 111 */
389 *reg
++ = IXGB_GET_STAT(adapter
, vptcl
); /* 112 */
390 *reg
++ = IXGB_GET_STAT(adapter
, vptch
); /* 113 */
391 *reg
++ = IXGB_GET_STAT(adapter
, jptcl
); /* 114 */
392 *reg
++ = IXGB_GET_STAT(adapter
, jptch
); /* 115 */
393 *reg
++ = IXGB_GET_STAT(adapter
, gotcl
); /* 116 */
394 *reg
++ = IXGB_GET_STAT(adapter
, gotch
); /* 117 */
395 *reg
++ = IXGB_GET_STAT(adapter
, totl
); /* 118 */
396 *reg
++ = IXGB_GET_STAT(adapter
, toth
); /* 119 */
397 *reg
++ = IXGB_GET_STAT(adapter
, dc
); /* 120 */
398 *reg
++ = IXGB_GET_STAT(adapter
, plt64c
); /* 121 */
399 *reg
++ = IXGB_GET_STAT(adapter
, tsctc
); /* 122 */
400 *reg
++ = IXGB_GET_STAT(adapter
, tsctfc
); /* 123 */
401 *reg
++ = IXGB_GET_STAT(adapter
, ibic
); /* 124 */
402 *reg
++ = IXGB_GET_STAT(adapter
, rfc
); /* 125 */
403 *reg
++ = IXGB_GET_STAT(adapter
, lfc
); /* 126 */
404 *reg
++ = IXGB_GET_STAT(adapter
, pfrc
); /* 127 */
405 *reg
++ = IXGB_GET_STAT(adapter
, pftc
); /* 128 */
406 *reg
++ = IXGB_GET_STAT(adapter
, mcfrc
); /* 129 */
407 *reg
++ = IXGB_GET_STAT(adapter
, mcftc
); /* 130 */
408 *reg
++ = IXGB_GET_STAT(adapter
, xonrxc
); /* 131 */
409 *reg
++ = IXGB_GET_STAT(adapter
, xontxc
); /* 132 */
410 *reg
++ = IXGB_GET_STAT(adapter
, xoffrxc
); /* 133 */
411 *reg
++ = IXGB_GET_STAT(adapter
, xofftxc
); /* 134 */
412 *reg
++ = IXGB_GET_STAT(adapter
, rjc
); /* 135 */
414 regs
->len
= (reg
- reg_start
) * sizeof(uint32_t);
418 ixgb_get_eeprom_len(struct net_device
*netdev
)
420 /* return size in bytes */
421 return (IXGB_EEPROM_SIZE
<< 1);
425 ixgb_get_eeprom(struct net_device
*netdev
,
426 struct ethtool_eeprom
*eeprom
, uint8_t *bytes
)
428 struct ixgb_adapter
*adapter
= netdev_priv(netdev
);
429 struct ixgb_hw
*hw
= &adapter
->hw
;
431 int i
, max_len
, first_word
, last_word
;
434 if(eeprom
->len
== 0) {
439 eeprom
->magic
= hw
->vendor_id
| (hw
->device_id
<< 16);
441 max_len
= ixgb_get_eeprom_len(netdev
);
443 if(eeprom
->offset
> eeprom
->offset
+ eeprom
->len
) {
448 if((eeprom
->offset
+ eeprom
->len
) > max_len
)
449 eeprom
->len
= (max_len
- eeprom
->offset
);
451 first_word
= eeprom
->offset
>> 1;
452 last_word
= (eeprom
->offset
+ eeprom
->len
- 1) >> 1;
454 eeprom_buff
= kmalloc(sizeof(__le16
) *
455 (last_word
- first_word
+ 1), GFP_KERNEL
);
459 /* note the eeprom was good because the driver loaded */
460 for(i
= 0; i
<= (last_word
- first_word
); i
++) {
461 eeprom_buff
[i
] = ixgb_get_eeprom_word(hw
, (first_word
+ i
));
464 memcpy(bytes
, (uint8_t *)eeprom_buff
+ (eeprom
->offset
& 1),
473 ixgb_set_eeprom(struct net_device
*netdev
,
474 struct ethtool_eeprom
*eeprom
, uint8_t *bytes
)
476 struct ixgb_adapter
*adapter
= netdev_priv(netdev
);
477 struct ixgb_hw
*hw
= &adapter
->hw
;
478 uint16_t *eeprom_buff
;
480 int max_len
, first_word
, last_word
;
486 if(eeprom
->magic
!= (hw
->vendor_id
| (hw
->device_id
<< 16)))
489 max_len
= ixgb_get_eeprom_len(netdev
);
491 if(eeprom
->offset
> eeprom
->offset
+ eeprom
->len
)
494 if((eeprom
->offset
+ eeprom
->len
) > max_len
)
495 eeprom
->len
= (max_len
- eeprom
->offset
);
497 first_word
= eeprom
->offset
>> 1;
498 last_word
= (eeprom
->offset
+ eeprom
->len
- 1) >> 1;
499 eeprom_buff
= kmalloc(max_len
, GFP_KERNEL
);
503 ptr
= (void *)eeprom_buff
;
505 if(eeprom
->offset
& 1) {
506 /* need read/modify/write of first changed EEPROM word */
507 /* only the second byte of the word is being modified */
508 eeprom_buff
[0] = ixgb_read_eeprom(hw
, first_word
);
511 if((eeprom
->offset
+ eeprom
->len
) & 1) {
512 /* need read/modify/write of last changed EEPROM word */
513 /* only the first byte of the word is being modified */
514 eeprom_buff
[last_word
- first_word
]
515 = ixgb_read_eeprom(hw
, last_word
);
518 memcpy(ptr
, bytes
, eeprom
->len
);
519 for(i
= 0; i
<= (last_word
- first_word
); i
++)
520 ixgb_write_eeprom(hw
, first_word
+ i
, eeprom_buff
[i
]);
522 /* Update the checksum over the first part of the EEPROM if needed */
523 if(first_word
<= EEPROM_CHECKSUM_REG
)
524 ixgb_update_eeprom_checksum(hw
);
531 ixgb_get_drvinfo(struct net_device
*netdev
,
532 struct ethtool_drvinfo
*drvinfo
)
534 struct ixgb_adapter
*adapter
= netdev_priv(netdev
);
536 strncpy(drvinfo
->driver
, ixgb_driver_name
, 32);
537 strncpy(drvinfo
->version
, ixgb_driver_version
, 32);
538 strncpy(drvinfo
->fw_version
, "N/A", 32);
539 strncpy(drvinfo
->bus_info
, pci_name(adapter
->pdev
), 32);
540 drvinfo
->n_stats
= IXGB_STATS_LEN
;
541 drvinfo
->regdump_len
= ixgb_get_regs_len(netdev
);
542 drvinfo
->eedump_len
= ixgb_get_eeprom_len(netdev
);
546 ixgb_get_ringparam(struct net_device
*netdev
,
547 struct ethtool_ringparam
*ring
)
549 struct ixgb_adapter
*adapter
= netdev_priv(netdev
);
550 struct ixgb_desc_ring
*txdr
= &adapter
->tx_ring
;
551 struct ixgb_desc_ring
*rxdr
= &adapter
->rx_ring
;
553 ring
->rx_max_pending
= MAX_RXD
;
554 ring
->tx_max_pending
= MAX_TXD
;
555 ring
->rx_mini_max_pending
= 0;
556 ring
->rx_jumbo_max_pending
= 0;
557 ring
->rx_pending
= rxdr
->count
;
558 ring
->tx_pending
= txdr
->count
;
559 ring
->rx_mini_pending
= 0;
560 ring
->rx_jumbo_pending
= 0;
564 ixgb_set_ringparam(struct net_device
*netdev
,
565 struct ethtool_ringparam
*ring
)
567 struct ixgb_adapter
*adapter
= netdev_priv(netdev
);
568 struct ixgb_desc_ring
*txdr
= &adapter
->tx_ring
;
569 struct ixgb_desc_ring
*rxdr
= &adapter
->rx_ring
;
570 struct ixgb_desc_ring tx_old
, tx_new
, rx_old
, rx_new
;
573 tx_old
= adapter
->tx_ring
;
574 rx_old
= adapter
->rx_ring
;
576 if((ring
->rx_mini_pending
) || (ring
->rx_jumbo_pending
))
579 if(netif_running(adapter
->netdev
))
580 ixgb_down(adapter
,TRUE
);
582 rxdr
->count
= max(ring
->rx_pending
,(uint32_t)MIN_RXD
);
583 rxdr
->count
= min(rxdr
->count
,(uint32_t)MAX_RXD
);
584 rxdr
->count
= ALIGN(rxdr
->count
, IXGB_REQ_RX_DESCRIPTOR_MULTIPLE
);
586 txdr
->count
= max(ring
->tx_pending
,(uint32_t)MIN_TXD
);
587 txdr
->count
= min(txdr
->count
,(uint32_t)MAX_TXD
);
588 txdr
->count
= ALIGN(txdr
->count
, IXGB_REQ_TX_DESCRIPTOR_MULTIPLE
);
590 if(netif_running(adapter
->netdev
)) {
591 /* Try to get new resources before deleting old */
592 if((err
= ixgb_setup_rx_resources(adapter
)))
594 if((err
= ixgb_setup_tx_resources(adapter
)))
597 /* save the new, restore the old in order to free it,
598 * then restore the new back again */
600 rx_new
= adapter
->rx_ring
;
601 tx_new
= adapter
->tx_ring
;
602 adapter
->rx_ring
= rx_old
;
603 adapter
->tx_ring
= tx_old
;
604 ixgb_free_rx_resources(adapter
);
605 ixgb_free_tx_resources(adapter
);
606 adapter
->rx_ring
= rx_new
;
607 adapter
->tx_ring
= tx_new
;
608 if((err
= ixgb_up(adapter
)))
610 ixgb_set_speed_duplex(netdev
);
615 ixgb_free_rx_resources(adapter
);
617 adapter
->rx_ring
= rx_old
;
618 adapter
->tx_ring
= tx_old
;
623 /* toggle LED 4 times per second = 2 "blinks" per second */
624 #define IXGB_ID_INTERVAL (HZ/4)
626 /* bit defines for adapter->led_status */
627 #define IXGB_LED_ON 0
630 ixgb_led_blink_callback(unsigned long data
)
632 struct ixgb_adapter
*adapter
= (struct ixgb_adapter
*)data
;
634 if(test_and_change_bit(IXGB_LED_ON
, &adapter
->led_status
))
635 ixgb_led_off(&adapter
->hw
);
637 ixgb_led_on(&adapter
->hw
);
639 mod_timer(&adapter
->blink_timer
, jiffies
+ IXGB_ID_INTERVAL
);
643 ixgb_phys_id(struct net_device
*netdev
, uint32_t data
)
645 struct ixgb_adapter
*adapter
= netdev_priv(netdev
);
650 if(!adapter
->blink_timer
.function
) {
651 init_timer(&adapter
->blink_timer
);
652 adapter
->blink_timer
.function
= ixgb_led_blink_callback
;
653 adapter
->blink_timer
.data
= (unsigned long)adapter
;
656 mod_timer(&adapter
->blink_timer
, jiffies
);
658 msleep_interruptible(data
* 1000);
659 del_timer_sync(&adapter
->blink_timer
);
660 ixgb_led_off(&adapter
->hw
);
661 clear_bit(IXGB_LED_ON
, &adapter
->led_status
);
667 ixgb_get_sset_count(struct net_device
*netdev
, int sset
)
671 return IXGB_STATS_LEN
;
678 ixgb_get_ethtool_stats(struct net_device
*netdev
,
679 struct ethtool_stats
*stats
, uint64_t *data
)
681 struct ixgb_adapter
*adapter
= netdev_priv(netdev
);
684 ixgb_update_stats(adapter
);
685 for(i
= 0; i
< IXGB_STATS_LEN
; i
++) {
686 char *p
= (char *)adapter
+ixgb_gstrings_stats
[i
].stat_offset
;
687 data
[i
] = (ixgb_gstrings_stats
[i
].sizeof_stat
==
688 sizeof(uint64_t)) ? *(uint64_t *)p
: *(uint32_t *)p
;
693 ixgb_get_strings(struct net_device
*netdev
, uint32_t stringset
, uint8_t *data
)
699 for(i
=0; i
< IXGB_STATS_LEN
; i
++) {
700 memcpy(data
+ i
* ETH_GSTRING_LEN
,
701 ixgb_gstrings_stats
[i
].stat_string
,
708 static const struct ethtool_ops ixgb_ethtool_ops
= {
709 .get_settings
= ixgb_get_settings
,
710 .set_settings
= ixgb_set_settings
,
711 .get_drvinfo
= ixgb_get_drvinfo
,
712 .get_regs_len
= ixgb_get_regs_len
,
713 .get_regs
= ixgb_get_regs
,
714 .get_link
= ethtool_op_get_link
,
715 .get_eeprom_len
= ixgb_get_eeprom_len
,
716 .get_eeprom
= ixgb_get_eeprom
,
717 .set_eeprom
= ixgb_set_eeprom
,
718 .get_ringparam
= ixgb_get_ringparam
,
719 .set_ringparam
= ixgb_set_ringparam
,
720 .get_pauseparam
= ixgb_get_pauseparam
,
721 .set_pauseparam
= ixgb_set_pauseparam
,
722 .get_rx_csum
= ixgb_get_rx_csum
,
723 .set_rx_csum
= ixgb_set_rx_csum
,
724 .get_tx_csum
= ixgb_get_tx_csum
,
725 .set_tx_csum
= ixgb_set_tx_csum
,
726 .set_sg
= ethtool_op_set_sg
,
727 .get_msglevel
= ixgb_get_msglevel
,
728 .set_msglevel
= ixgb_set_msglevel
,
729 .set_tso
= ixgb_set_tso
,
730 .get_strings
= ixgb_get_strings
,
731 .phys_id
= ixgb_phys_id
,
732 .get_sset_count
= ixgb_get_sset_count
,
733 .get_ethtool_stats
= ixgb_get_ethtool_stats
,
736 void ixgb_set_ethtool_ops(struct net_device
*netdev
)
738 SET_ETHTOOL_OPS(netdev
, &ixgb_ethtool_ops
);