1 /*******************************************************************************
4 Copyright(c) 1999 - 2004 Intel Corporation. All rights reserved.
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)
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
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.
20 The full GNU General Public License is included in this distribution in the
24 Linux NICS <linux.nics@intel.com>
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 char ixgb_driver_name[];
36 extern char ixgb_driver_version[];
38 extern int ixgb_up(struct ixgb_adapter *adapter);
39 extern void ixgb_down(struct ixgb_adapter *adapter, boolean_t kill_watchdog);
41 static inline int ixgb_eeprom_size(struct ixgb_hw *hw)
43 /* return size in bytes */
44 return (IXGB_EEPROM_SIZE << 1);
48 char stat_string[ETH_GSTRING_LEN];
53 #define IXGB_STAT(m) sizeof(((struct ixgb_adapter *)0)->m), \
54 offsetof(struct ixgb_adapter, m)
55 static struct ixgb_stats ixgb_gstrings_stats[] = {
56 {"rx_packets", IXGB_STAT(net_stats.rx_packets)},
57 {"tx_packets", IXGB_STAT(net_stats.tx_packets)},
58 {"rx_bytes", IXGB_STAT(net_stats.rx_bytes)},
59 {"tx_bytes", IXGB_STAT(net_stats.tx_bytes)},
60 {"rx_errors", IXGB_STAT(net_stats.rx_errors)},
61 {"tx_errors", IXGB_STAT(net_stats.tx_errors)},
62 {"rx_dropped", IXGB_STAT(net_stats.rx_dropped)},
63 {"tx_dropped", IXGB_STAT(net_stats.tx_dropped)},
64 {"multicast", IXGB_STAT(net_stats.multicast)},
65 {"collisions", IXGB_STAT(net_stats.collisions)},
66 /* { "rx_length_errors", IXGB_STAT(net_stats.rx_length_errors) }, */
67 {"rx_over_errors", IXGB_STAT(net_stats.rx_over_errors)},
68 {"rx_crc_errors", IXGB_STAT(net_stats.rx_crc_errors)},
69 {"rx_frame_errors", IXGB_STAT(net_stats.rx_frame_errors)},
70 {"rx_fifo_errors", IXGB_STAT(net_stats.rx_fifo_errors)},
71 {"rx_missed_errors", IXGB_STAT(net_stats.rx_missed_errors)},
72 {"tx_aborted_errors", IXGB_STAT(net_stats.tx_aborted_errors)},
73 {"tx_carrier_errors", IXGB_STAT(net_stats.tx_carrier_errors)},
74 {"tx_fifo_errors", IXGB_STAT(net_stats.tx_fifo_errors)},
75 {"tx_heartbeat_errors", IXGB_STAT(net_stats.tx_heartbeat_errors)},
76 {"tx_window_errors", IXGB_STAT(net_stats.tx_window_errors)},
77 {"tx_deferred_ok", IXGB_STAT(stats.dc)},
78 {"rx_long_length_errors", IXGB_STAT(stats.roc)},
79 {"rx_short_length_errors", IXGB_STAT(stats.ruc)},
81 {"tx_tcp_seg_good", IXGB_STAT(stats.tsctc)},
82 {"tx_tcp_seg_failed", IXGB_STAT(stats.tsctfc)},
84 {"rx_flow_control_xon", IXGB_STAT(stats.xonrxc)},
85 {"rx_flow_control_xoff", IXGB_STAT(stats.xoffrxc)},
86 {"tx_flow_control_xon", IXGB_STAT(stats.xontxc)},
87 {"tx_flow_control_xoff", IXGB_STAT(stats.xofftxc)},
88 {"rx_csum_offload_good", IXGB_STAT(hw_csum_rx_good)},
89 {"rx_csum_offload_errors", IXGB_STAT(hw_csum_rx_error)},
90 {"tx_csum_offload_good", IXGB_STAT(hw_csum_tx_good)},
91 {"tx_csum_offload_errors", IXGB_STAT(hw_csum_tx_error)}
94 #define IXGB_STATS_LEN \
95 sizeof(ixgb_gstrings_stats) / sizeof(struct ixgb_stats)
98 ixgb_ethtool_gset(struct ixgb_adapter *adapter, struct ethtool_cmd *ecmd)
100 ecmd->supported = (SUPPORTED_10000baseT_Full | SUPPORTED_FIBRE);
101 ecmd->advertising = (SUPPORTED_10000baseT_Full | SUPPORTED_FIBRE);
102 ecmd->port = PORT_FIBRE;
103 ecmd->transceiver = XCVR_EXTERNAL;
105 if (netif_carrier_ok(adapter->netdev)) {
106 ecmd->speed = SPEED_10000;
107 ecmd->duplex = DUPLEX_FULL;
113 ecmd->autoneg = AUTONEG_DISABLE;
117 ixgb_ethtool_sset(struct ixgb_adapter *adapter, struct ethtool_cmd *ecmd)
119 if (ecmd->autoneg == AUTONEG_ENABLE ||
120 ecmd->speed + ecmd->duplex != SPEED_10000 + DUPLEX_FULL)
123 ixgb_down(adapter, TRUE);
131 ixgb_ethtool_gpause(struct ixgb_adapter *adapter,
132 struct ethtool_pauseparam *epause)
134 struct ixgb_hw *hw = &adapter->hw;
136 epause->autoneg = AUTONEG_DISABLE;
138 if (hw->fc.type == ixgb_fc_rx_pause)
139 epause->rx_pause = 1;
140 else if (hw->fc.type == ixgb_fc_tx_pause)
141 epause->tx_pause = 1;
142 else if (hw->fc.type == ixgb_fc_full) {
143 epause->rx_pause = 1;
144 epause->tx_pause = 1;
151 ixgb_ethtool_spause(struct ixgb_adapter *adapter,
152 struct ethtool_pauseparam *epause)
154 struct ixgb_hw *hw = &adapter->hw;
156 if (epause->autoneg == AUTONEG_ENABLE)
159 if (epause->rx_pause && epause->tx_pause)
160 hw->fc.type = ixgb_fc_full;
161 else if (epause->rx_pause && !epause->tx_pause)
162 hw->fc.type = ixgb_fc_rx_pause;
163 else if (!epause->rx_pause && epause->tx_pause)
164 hw->fc.type = ixgb_fc_tx_pause;
165 else if (!epause->rx_pause && !epause->tx_pause)
166 hw->fc.type = ixgb_fc_none;
168 ixgb_down(adapter, TRUE);
175 ixgb_ethtool_gdrvinfo(struct ixgb_adapter *adapter,
176 struct ethtool_drvinfo *drvinfo)
178 strncpy(drvinfo->driver, ixgb_driver_name, 32);
179 strncpy(drvinfo->version, ixgb_driver_version, 32);
180 strncpy(drvinfo->fw_version, "N/A", 32);
181 strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 32);
182 drvinfo->n_stats = IXGB_STATS_LEN;
183 #define IXGB_REG_DUMP_LEN 136*sizeof(uint32_t)
184 drvinfo->regdump_len = IXGB_REG_DUMP_LEN;
185 drvinfo->eedump_len = ixgb_eeprom_size(&adapter->hw);
188 #define IXGB_GET_STAT(_A_, _R_) _A_->stats._R_
190 ixgb_ethtool_gregs(struct ixgb_adapter *adapter,
191 struct ethtool_regs *regs, uint32_t * regs_buff)
193 struct ixgb_hw *hw = &adapter->hw;
194 uint32_t *reg = regs_buff;
195 uint32_t *reg_start = reg;
199 (adapter->hw.device_id << 16) | adapter->hw.subsystem_id;
201 /* General Registers */
202 *reg++ = IXGB_READ_REG(hw, CTRL0); /* 0 */
203 *reg++ = IXGB_READ_REG(hw, CTRL1); /* 1 */
204 *reg++ = IXGB_READ_REG(hw, STATUS); /* 2 */
205 *reg++ = IXGB_READ_REG(hw, EECD); /* 3 */
206 *reg++ = IXGB_READ_REG(hw, MFS); /* 4 */
209 *reg++ = IXGB_READ_REG(hw, ICR); /* 5 */
210 *reg++ = IXGB_READ_REG(hw, ICS); /* 6 */
211 *reg++ = IXGB_READ_REG(hw, IMS); /* 7 */
212 *reg++ = IXGB_READ_REG(hw, IMC); /* 8 */
215 *reg++ = IXGB_READ_REG(hw, RCTL); /* 9 */
216 *reg++ = IXGB_READ_REG(hw, FCRTL); /* 10 */
217 *reg++ = IXGB_READ_REG(hw, FCRTH); /* 11 */
218 *reg++ = IXGB_READ_REG(hw, RDBAL); /* 12 */
219 *reg++ = IXGB_READ_REG(hw, RDBAH); /* 13 */
220 *reg++ = IXGB_READ_REG(hw, RDLEN); /* 14 */
221 *reg++ = IXGB_READ_REG(hw, RDH); /* 15 */
222 *reg++ = IXGB_READ_REG(hw, RDT); /* 16 */
223 *reg++ = IXGB_READ_REG(hw, RDTR); /* 17 */
224 *reg++ = IXGB_READ_REG(hw, RXDCTL); /* 18 */
225 *reg++ = IXGB_READ_REG(hw, RAIDC); /* 19 */
226 *reg++ = IXGB_READ_REG(hw, RXCSUM); /* 20 */
228 for (i = 0; i < IXGB_RAR_ENTRIES; i++) {
229 *reg++ = IXGB_READ_REG_ARRAY(hw, RAL, (i << 1)); /*21,...,51 */
230 *reg++ = IXGB_READ_REG_ARRAY(hw, RAH, (i << 1)); /*22,...,52 */
234 *reg++ = IXGB_READ_REG(hw, TCTL); /* 53 */
235 *reg++ = IXGB_READ_REG(hw, TDBAL); /* 54 */
236 *reg++ = IXGB_READ_REG(hw, TDBAH); /* 55 */
237 *reg++ = IXGB_READ_REG(hw, TDLEN); /* 56 */
238 *reg++ = IXGB_READ_REG(hw, TDH); /* 57 */
239 *reg++ = IXGB_READ_REG(hw, TDT); /* 58 */
240 *reg++ = IXGB_READ_REG(hw, TIDV); /* 59 */
241 *reg++ = IXGB_READ_REG(hw, TXDCTL); /* 60 */
242 *reg++ = IXGB_READ_REG(hw, TSPMT); /* 61 */
243 *reg++ = IXGB_READ_REG(hw, PAP); /* 62 */
246 *reg++ = IXGB_READ_REG(hw, PCSC1); /* 63 */
247 *reg++ = IXGB_READ_REG(hw, PCSC2); /* 64 */
248 *reg++ = IXGB_READ_REG(hw, PCSS1); /* 65 */
249 *reg++ = IXGB_READ_REG(hw, PCSS2); /* 66 */
250 *reg++ = IXGB_READ_REG(hw, XPCSS); /* 67 */
251 *reg++ = IXGB_READ_REG(hw, UCCR); /* 68 */
252 *reg++ = IXGB_READ_REG(hw, XPCSTC); /* 69 */
253 *reg++ = IXGB_READ_REG(hw, MACA); /* 70 */
254 *reg++ = IXGB_READ_REG(hw, APAE); /* 71 */
255 *reg++ = IXGB_READ_REG(hw, ARD); /* 72 */
256 *reg++ = IXGB_READ_REG(hw, AIS); /* 73 */
257 *reg++ = IXGB_READ_REG(hw, MSCA); /* 74 */
258 *reg++ = IXGB_READ_REG(hw, MSRWD); /* 75 */
261 *reg++ = IXGB_GET_STAT(adapter, tprl); /* 76 */
262 *reg++ = IXGB_GET_STAT(adapter, tprh); /* 77 */
263 *reg++ = IXGB_GET_STAT(adapter, gprcl); /* 78 */
264 *reg++ = IXGB_GET_STAT(adapter, gprch); /* 79 */
265 *reg++ = IXGB_GET_STAT(adapter, bprcl); /* 80 */
266 *reg++ = IXGB_GET_STAT(adapter, bprch); /* 81 */
267 *reg++ = IXGB_GET_STAT(adapter, mprcl); /* 82 */
268 *reg++ = IXGB_GET_STAT(adapter, mprch); /* 83 */
269 *reg++ = IXGB_GET_STAT(adapter, uprcl); /* 84 */
270 *reg++ = IXGB_GET_STAT(adapter, uprch); /* 85 */
271 *reg++ = IXGB_GET_STAT(adapter, vprcl); /* 86 */
272 *reg++ = IXGB_GET_STAT(adapter, vprch); /* 87 */
273 *reg++ = IXGB_GET_STAT(adapter, jprcl); /* 88 */
274 *reg++ = IXGB_GET_STAT(adapter, jprch); /* 89 */
275 *reg++ = IXGB_GET_STAT(adapter, gorcl); /* 90 */
276 *reg++ = IXGB_GET_STAT(adapter, gorch); /* 91 */
277 *reg++ = IXGB_GET_STAT(adapter, torl); /* 92 */
278 *reg++ = IXGB_GET_STAT(adapter, torh); /* 93 */
279 *reg++ = IXGB_GET_STAT(adapter, rnbc); /* 94 */
280 *reg++ = IXGB_GET_STAT(adapter, ruc); /* 95 */
281 *reg++ = IXGB_GET_STAT(adapter, roc); /* 96 */
282 *reg++ = IXGB_GET_STAT(adapter, rlec); /* 97 */
283 *reg++ = IXGB_GET_STAT(adapter, crcerrs); /* 98 */
284 *reg++ = IXGB_GET_STAT(adapter, icbc); /* 99 */
285 *reg++ = IXGB_GET_STAT(adapter, ecbc); /* 100 */
286 *reg++ = IXGB_GET_STAT(adapter, mpc); /* 101 */
287 *reg++ = IXGB_GET_STAT(adapter, tptl); /* 102 */
288 *reg++ = IXGB_GET_STAT(adapter, tpth); /* 103 */
289 *reg++ = IXGB_GET_STAT(adapter, gptcl); /* 104 */
290 *reg++ = IXGB_GET_STAT(adapter, gptch); /* 105 */
291 *reg++ = IXGB_GET_STAT(adapter, bptcl); /* 106 */
292 *reg++ = IXGB_GET_STAT(adapter, bptch); /* 107 */
293 *reg++ = IXGB_GET_STAT(adapter, mptcl); /* 108 */
294 *reg++ = IXGB_GET_STAT(adapter, mptch); /* 109 */
295 *reg++ = IXGB_GET_STAT(adapter, uptcl); /* 110 */
296 *reg++ = IXGB_GET_STAT(adapter, uptch); /* 111 */
297 *reg++ = IXGB_GET_STAT(adapter, vptcl); /* 112 */
298 *reg++ = IXGB_GET_STAT(adapter, vptch); /* 113 */
299 *reg++ = IXGB_GET_STAT(adapter, jptcl); /* 114 */
300 *reg++ = IXGB_GET_STAT(adapter, jptch); /* 115 */
301 *reg++ = IXGB_GET_STAT(adapter, gotcl); /* 116 */
302 *reg++ = IXGB_GET_STAT(adapter, gotch); /* 117 */
303 *reg++ = IXGB_GET_STAT(adapter, totl); /* 118 */
304 *reg++ = IXGB_GET_STAT(adapter, toth); /* 119 */
305 *reg++ = IXGB_GET_STAT(adapter, dc); /* 120 */
306 *reg++ = IXGB_GET_STAT(adapter, plt64c); /* 121 */
307 *reg++ = IXGB_GET_STAT(adapter, tsctc); /* 122 */
308 *reg++ = IXGB_GET_STAT(adapter, tsctfc); /* 123 */
309 *reg++ = IXGB_GET_STAT(adapter, ibic); /* 124 */
310 *reg++ = IXGB_GET_STAT(adapter, rfc); /* 125 */
311 *reg++ = IXGB_GET_STAT(adapter, lfc); /* 126 */
312 *reg++ = IXGB_GET_STAT(adapter, pfrc); /* 127 */
313 *reg++ = IXGB_GET_STAT(adapter, pftc); /* 128 */
314 *reg++ = IXGB_GET_STAT(adapter, mcfrc); /* 129 */
315 *reg++ = IXGB_GET_STAT(adapter, mcftc); /* 130 */
316 *reg++ = IXGB_GET_STAT(adapter, xonrxc); /* 131 */
317 *reg++ = IXGB_GET_STAT(adapter, xontxc); /* 132 */
318 *reg++ = IXGB_GET_STAT(adapter, xoffrxc); /* 133 */
319 *reg++ = IXGB_GET_STAT(adapter, xofftxc); /* 134 */
320 *reg++ = IXGB_GET_STAT(adapter, rjc); /* 135 */
322 regs->len = (reg - reg_start) * sizeof(uint32_t);
326 ixgb_ethtool_geeprom(struct ixgb_adapter *adapter,
327 struct ethtool_eeprom *eeprom, uint16_t * eeprom_buff)
329 struct ixgb_hw *hw = &adapter->hw;
330 int i, max_len, first_word, last_word;
333 if (eeprom->len == 0) {
338 eeprom->magic = hw->vendor_id | (hw->device_id << 16);
340 max_len = ixgb_eeprom_size(hw);
342 /* use our function to read the eeprom and update our cache */
343 ixgb_get_eeprom_data(hw);
345 if (eeprom->offset > eeprom->offset + eeprom->len) {
350 if ((eeprom->offset + eeprom->len) > max_len)
351 eeprom->len = (max_len - eeprom->offset);
353 first_word = eeprom->offset >> 1;
354 last_word = (eeprom->offset + eeprom->len - 1) >> 1;
356 for (i = 0; i <= (last_word - first_word); i++) {
357 eeprom_buff[i] = hw->eeprom[first_word + i];
364 ixgb_ethtool_seeprom(struct ixgb_adapter *adapter,
365 struct ethtool_eeprom *eeprom, void __user *user_data)
367 struct ixgb_hw *hw = &adapter->hw;
368 uint16_t eeprom_buff[256];
369 int i, max_len, first_word, last_word;
372 if (eeprom->magic != (hw->vendor_id | (hw->device_id << 16)))
375 if (eeprom->len == 0)
378 max_len = ixgb_eeprom_size(hw);
380 if (eeprom->offset > eeprom->offset + eeprom->len)
383 if ((eeprom->offset + eeprom->len) > max_len)
384 eeprom->len = (max_len - eeprom->offset);
386 first_word = eeprom->offset >> 1;
387 last_word = (eeprom->offset + eeprom->len - 1) >> 1;
388 ptr = (void *)eeprom_buff;
390 if (eeprom->offset & 1) {
391 /* need read/modify/write of first changed EEPROM word */
392 /* only the second byte of the word is being modified */
393 eeprom_buff[0] = ixgb_read_eeprom(hw, first_word);
396 if ((eeprom->offset + eeprom->len) & 1) {
397 /* need read/modify/write of last changed EEPROM word */
398 /* only the first byte of the word is being modified */
399 eeprom_buff[last_word - first_word]
400 = ixgb_read_eeprom(hw, last_word);
402 if (copy_from_user(ptr, user_data, eeprom->len))
405 for (i = 0; i <= (last_word - first_word); i++)
406 ixgb_write_eeprom(hw, first_word + i, eeprom_buff[i]);
408 /* Update the checksum over the first part of the EEPROM if needed */
409 if (first_word <= EEPROM_CHECKSUM_REG)
410 ixgb_update_eeprom_checksum(hw);
415 /* toggle LED 4 times per second = 2 "blinks" per second */
416 #define IXGB_ID_INTERVAL (HZ/4)
418 /* bit defines for adapter->led_status */
419 #define IXGB_LED_ON 0
421 static void ixgb_led_blink_callback(unsigned long data)
423 struct ixgb_adapter *adapter = (struct ixgb_adapter *)data;
425 if (test_and_change_bit(IXGB_LED_ON, &adapter->led_status))
426 ixgb_led_off(&adapter->hw);
428 ixgb_led_on(&adapter->hw);
430 mod_timer(&adapter->blink_timer, jiffies + IXGB_ID_INTERVAL);
434 ixgb_ethtool_led_blink(struct ixgb_adapter *adapter, struct ethtool_value *id)
436 if (!adapter->blink_timer.function) {
437 init_timer(&adapter->blink_timer);
438 adapter->blink_timer.function = ixgb_led_blink_callback;
439 adapter->blink_timer.data = (unsigned long)adapter;
442 mod_timer(&adapter->blink_timer, jiffies);
444 set_current_state(TASK_INTERRUPTIBLE);
446 schedule_timeout(id->data * HZ);
448 schedule_timeout(MAX_SCHEDULE_TIMEOUT);
450 del_timer_sync(&adapter->blink_timer);
451 ixgb_led_off(&adapter->hw);
452 clear_bit(IXGB_LED_ON, &adapter->led_status);
457 int ixgb_ethtool_ioctl(struct net_device *netdev, struct ifreq *ifr)
459 struct ixgb_adapter *adapter = netdev->priv;
460 void __user *addr = ifr->ifr_data;
463 if (get_user(cmd, (uint32_t __user *) addr))
468 struct ethtool_cmd ecmd = { ETHTOOL_GSET };
469 ixgb_ethtool_gset(adapter, &ecmd);
470 if (copy_to_user(addr, &ecmd, sizeof(ecmd)))
475 struct ethtool_cmd ecmd;
476 if (copy_from_user(&ecmd, addr, sizeof(ecmd)))
478 return ixgb_ethtool_sset(adapter, &ecmd);
480 case ETHTOOL_GDRVINFO:{
481 struct ethtool_drvinfo drvinfo = { ETHTOOL_GDRVINFO };
482 ixgb_ethtool_gdrvinfo(adapter, &drvinfo);
483 if (copy_to_user(addr, &drvinfo, sizeof(drvinfo)))
487 case ETHTOOL_GSTRINGS:{
488 struct ethtool_gstrings gstrings = { ETHTOOL_GSTRINGS };
489 char *strings = NULL;
492 if (copy_from_user(&gstrings, addr, sizeof(gstrings)))
494 switch (gstrings.string_set) {
497 gstrings.len = IXGB_STATS_LEN;
499 kmalloc(IXGB_STATS_LEN *
504 for (i = 0; i < IXGB_STATS_LEN; i++) {
506 [i * ETH_GSTRING_LEN],
507 ixgb_gstrings_stats[i].
516 if (copy_to_user(addr, &gstrings, sizeof(gstrings)))
518 addr += offsetof(struct ethtool_gstrings, data);
519 if (!err && copy_to_user(addr, strings,
528 struct ethtool_regs regs = { ETHTOOL_GREGS };
529 uint32_t regs_buff[IXGB_REG_DUMP_LEN];
531 if (copy_from_user(®s, addr, sizeof(regs)))
533 ixgb_ethtool_gregs(adapter, ®s, regs_buff);
534 if (copy_to_user(addr, ®s, sizeof(regs)))
537 addr += offsetof(struct ethtool_regs, data);
538 if (copy_to_user(addr, regs_buff, regs.len))
543 case ETHTOOL_NWAY_RST:{
544 if (netif_running(netdev)) {
545 ixgb_down(adapter, TRUE);
550 case ETHTOOL_PHYS_ID:{
551 struct ethtool_value id;
552 if (copy_from_user(&id, addr, sizeof(id)))
554 return ixgb_ethtool_led_blink(adapter, &id);
557 struct ethtool_value link = { ETHTOOL_GLINK };
558 link.data = netif_carrier_ok(netdev);
559 if (copy_to_user(addr, &link, sizeof(link)))
564 case ETHTOOL_GEEPROM:{
565 struct ethtool_eeprom eeprom = { ETHTOOL_GEEPROM };
566 uint16_t eeprom_buff[IXGB_EEPROM_SIZE];
570 if (copy_from_user(&eeprom, addr, sizeof(eeprom)))
574 ixgb_ethtool_geeprom(adapter, &eeprom,
578 if (copy_to_user(addr, &eeprom, sizeof(eeprom)))
581 addr += offsetof(struct ethtool_eeprom, data);
582 ptr = ((void *)eeprom_buff) + (eeprom.offset & 1);
584 if (copy_to_user(addr, ptr, eeprom.len))
588 case ETHTOOL_SEEPROM:{
589 struct ethtool_eeprom eeprom;
591 if (copy_from_user(&eeprom, addr, sizeof(eeprom)))
594 addr += offsetof(struct ethtool_eeprom, data);
595 return ixgb_ethtool_seeprom(adapter, &eeprom, addr);
597 case ETHTOOL_GPAUSEPARAM:{
598 struct ethtool_pauseparam epause =
599 { ETHTOOL_GPAUSEPARAM };
600 ixgb_ethtool_gpause(adapter, &epause);
601 if (copy_to_user(addr, &epause, sizeof(epause)))
605 case ETHTOOL_SPAUSEPARAM:{
606 struct ethtool_pauseparam epause;
607 if (copy_from_user(&epause, addr, sizeof(epause)))
609 return ixgb_ethtool_spause(adapter, &epause);
611 case ETHTOOL_GSTATS:{
613 struct ethtool_stats eth_stats;
614 uint64_t data[IXGB_STATS_LEN];
616 ETHTOOL_GSTATS, IXGB_STATS_LEN}};
619 for (i = 0; i < IXGB_STATS_LEN; i++)
621 (ixgb_gstrings_stats[i].sizeof_stat ==
622 sizeof(uint64_t)) ? *(uint64_t *) ((char *)
628 : *(uint32_t *) ((char *)adapter +
629 ixgb_gstrings_stats[i].
631 if (copy_to_user(addr, &stats, sizeof(stats)))
635 case ETHTOOL_GRXCSUM:{
636 struct ethtool_value edata = { ETHTOOL_GRXCSUM };
638 edata.data = adapter->rx_csum;
639 if (copy_to_user(addr, &edata, sizeof(edata)))
643 case ETHTOOL_SRXCSUM:{
644 struct ethtool_value edata;
646 if (copy_from_user(&edata, addr, sizeof(edata)))
648 adapter->rx_csum = edata.data;
649 ixgb_down(adapter, TRUE);
653 case ETHTOOL_GTXCSUM:{
654 struct ethtool_value edata = { ETHTOOL_GTXCSUM };
656 edata.data = (netdev->features & NETIF_F_HW_CSUM) != 0;
657 if (copy_to_user(addr, &edata, sizeof(edata)))
661 case ETHTOOL_STXCSUM:{
662 struct ethtool_value edata;
664 if (copy_from_user(&edata, addr, sizeof(edata)))
668 netdev->features |= NETIF_F_HW_CSUM;
670 netdev->features &= ~NETIF_F_HW_CSUM;
675 struct ethtool_value edata = { ETHTOOL_GSG };
677 edata.data = (netdev->features & NETIF_F_SG) != 0;
678 if (copy_to_user(addr, &edata, sizeof(edata)))
683 struct ethtool_value edata;
685 if (copy_from_user(&edata, addr, sizeof(edata)))
689 netdev->features |= NETIF_F_SG;
691 netdev->features &= ~NETIF_F_SG;
697 struct ethtool_value edata = { ETHTOOL_GTSO };
699 edata.data = (netdev->features & NETIF_F_TSO) != 0;
700 if (copy_to_user(addr, &edata, sizeof(edata)))
705 struct ethtool_value edata;
707 if (copy_from_user(&edata, addr, sizeof(edata)))
711 netdev->features |= NETIF_F_TSO;
713 netdev->features &= ~NETIF_F_TSO;