upgrade to linux 2.6.10-1.12_FC2
[linux-2.6.git] / drivers / net / ixgb / ixgb_ethtool.c
1 /*******************************************************************************
2
3   
4   Copyright(c) 1999 - 2004 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   Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26
27 *******************************************************************************/
28
29 /* ethtool support for ixgb */
30
31 #include "ixgb.h"
32
33 #include <asm/uaccess.h>
34
35 extern char ixgb_driver_name[];
36 extern char ixgb_driver_version[];
37
38 extern int ixgb_up(struct ixgb_adapter *adapter);
39 extern void ixgb_down(struct ixgb_adapter *adapter, boolean_t kill_watchdog);
40
41 struct ixgb_stats {
42         char stat_string[ETH_GSTRING_LEN];
43         int sizeof_stat;
44         int stat_offset;
45 };
46
47 #define IXGB_STAT(m) sizeof(((struct ixgb_adapter *)0)->m), \
48                       offsetof(struct ixgb_adapter, m)
49 static struct ixgb_stats ixgb_gstrings_stats[] = {
50         {"rx_packets", IXGB_STAT(net_stats.rx_packets)},
51         {"tx_packets", IXGB_STAT(net_stats.tx_packets)},
52         {"rx_bytes", IXGB_STAT(net_stats.rx_bytes)},
53         {"tx_bytes", IXGB_STAT(net_stats.tx_bytes)},
54         {"rx_errors", IXGB_STAT(net_stats.rx_errors)},
55         {"tx_errors", IXGB_STAT(net_stats.tx_errors)},
56         {"rx_dropped", IXGB_STAT(net_stats.rx_dropped)},
57         {"tx_dropped", IXGB_STAT(net_stats.tx_dropped)},
58         {"multicast", IXGB_STAT(net_stats.multicast)},
59         {"collisions", IXGB_STAT(net_stats.collisions)},
60 /*      { "rx_length_errors", IXGB_STAT(net_stats.rx_length_errors) },  */
61         {"rx_over_errors", IXGB_STAT(net_stats.rx_over_errors)},
62         {"rx_crc_errors", IXGB_STAT(net_stats.rx_crc_errors)},
63         {"rx_frame_errors", IXGB_STAT(net_stats.rx_frame_errors)},
64         {"rx_fifo_errors", IXGB_STAT(net_stats.rx_fifo_errors)},
65         {"rx_missed_errors", IXGB_STAT(net_stats.rx_missed_errors)},
66         {"tx_aborted_errors", IXGB_STAT(net_stats.tx_aborted_errors)},
67         {"tx_carrier_errors", IXGB_STAT(net_stats.tx_carrier_errors)},
68         {"tx_fifo_errors", IXGB_STAT(net_stats.tx_fifo_errors)},
69         {"tx_heartbeat_errors", IXGB_STAT(net_stats.tx_heartbeat_errors)},
70         {"tx_window_errors", IXGB_STAT(net_stats.tx_window_errors)},
71         {"tx_deferred_ok", IXGB_STAT(stats.dc)},
72         {"rx_long_length_errors", IXGB_STAT(stats.roc)},
73         {"rx_short_length_errors", IXGB_STAT(stats.ruc)},
74 #ifdef NETIF_F_TSO
75         {"tx_tcp_seg_good", IXGB_STAT(stats.tsctc)},
76         {"tx_tcp_seg_failed", IXGB_STAT(stats.tsctfc)},
77 #endif
78         {"rx_flow_control_xon", IXGB_STAT(stats.xonrxc)},
79         {"rx_flow_control_xoff", IXGB_STAT(stats.xoffrxc)},
80         {"tx_flow_control_xon", IXGB_STAT(stats.xontxc)},
81         {"tx_flow_control_xoff", IXGB_STAT(stats.xofftxc)},
82         {"rx_csum_offload_good", IXGB_STAT(hw_csum_rx_good)},
83         {"rx_csum_offload_errors", IXGB_STAT(hw_csum_rx_error)},
84         {"tx_csum_offload_good", IXGB_STAT(hw_csum_tx_good)},
85         {"tx_csum_offload_errors", IXGB_STAT(hw_csum_tx_error)}
86 };
87
88 #define IXGB_STATS_LEN  \
89         sizeof(ixgb_gstrings_stats) / sizeof(struct ixgb_stats)
90
91 static int
92 ixgb_ethtool_gset(struct net_device *netdev, struct ethtool_cmd *ecmd)
93 {
94         struct ixgb_adapter *adapter = netdev->priv;
95         ecmd->supported = (SUPPORTED_10000baseT_Full | SUPPORTED_FIBRE);
96         ecmd->advertising = (SUPPORTED_10000baseT_Full | SUPPORTED_FIBRE);
97         ecmd->port = PORT_FIBRE;
98         ecmd->transceiver = XCVR_EXTERNAL;
99
100         if (netif_carrier_ok(adapter->netdev)) {
101                 ecmd->speed = SPEED_10000;
102                 ecmd->duplex = DUPLEX_FULL;
103         } else {
104                 ecmd->speed = -1;
105                 ecmd->duplex = -1;
106         }
107
108         ecmd->autoneg = AUTONEG_DISABLE;
109         return 0;
110 }
111
112 static int
113 ixgb_ethtool_sset(struct net_device *netdev, struct ethtool_cmd *ecmd)
114 {
115         struct ixgb_adapter *adapter = netdev->priv;
116         if (ecmd->autoneg == AUTONEG_ENABLE ||
117             ecmd->speed + ecmd->duplex != SPEED_10000 + DUPLEX_FULL)
118                 return -EINVAL;
119         else {
120                 ixgb_down(adapter, TRUE);
121                 ixgb_up(adapter);
122         }
123         return 0;
124 }
125
126 static void
127 ixgb_ethtool_gpause(struct net_device *dev,
128                     struct ethtool_pauseparam *epause)
129 {
130         struct ixgb_adapter *adapter = dev->priv;
131         struct ixgb_hw *hw = &adapter->hw;
132
133         epause->autoneg = AUTONEG_DISABLE;
134
135         if (hw->fc.type == ixgb_fc_rx_pause)
136                 epause->rx_pause = 1;
137         else if (hw->fc.type == ixgb_fc_tx_pause)
138                 epause->tx_pause = 1;
139         else if (hw->fc.type == ixgb_fc_full) {
140                 epause->rx_pause = 1;
141                 epause->tx_pause = 1;
142         }
143 }
144
145 static int
146 ixgb_ethtool_spause(struct net_device *dev,
147                     struct ethtool_pauseparam *epause)
148 {
149         struct ixgb_adapter *adapter = dev->priv;
150         struct ixgb_hw *hw = &adapter->hw;
151
152         if (epause->autoneg == AUTONEG_ENABLE)
153                 return -EINVAL;
154
155         if (epause->rx_pause && epause->tx_pause)
156                 hw->fc.type = ixgb_fc_full;
157         else if (epause->rx_pause && !epause->tx_pause)
158                 hw->fc.type = ixgb_fc_rx_pause;
159         else if (!epause->rx_pause && epause->tx_pause)
160                 hw->fc.type = ixgb_fc_tx_pause;
161         else if (!epause->rx_pause && !epause->tx_pause)
162                 hw->fc.type = ixgb_fc_none;
163
164         ixgb_down(adapter, TRUE);
165         ixgb_up(adapter);
166
167         return 0;
168 }
169
170 static void
171 ixgb_ethtool_gdrvinfo(struct net_device *netdev,
172                       struct ethtool_drvinfo *drvinfo)
173 {
174         struct ixgb_adapter *adapter = netdev->priv;
175         strncpy(drvinfo->driver, ixgb_driver_name, 32);
176         strncpy(drvinfo->version, ixgb_driver_version, 32);
177         strncpy(drvinfo->fw_version, "N/A", 32);
178         strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 32);
179 }
180
181 #define IXGB_GET_STAT(_A_, _R_) _A_->stats._R_
182 static void
183 ixgb_ethtool_gregs(struct net_device *dev, struct ethtool_regs *regs, void *buf)
184 {
185         struct ixgb_adapter *adapter = dev->priv;
186         struct ixgb_hw *hw = &adapter->hw;
187         uint32_t *reg = buf;
188         uint32_t *reg_start = reg;
189         uint8_t i;
190
191         regs->version =
192             (adapter->hw.device_id << 16) | adapter->hw.subsystem_id;
193
194         /* General Registers */
195         *reg++ = IXGB_READ_REG(hw, CTRL0);      /*   0 */
196         *reg++ = IXGB_READ_REG(hw, CTRL1);      /*   1 */
197         *reg++ = IXGB_READ_REG(hw, STATUS);     /*   2 */
198         *reg++ = IXGB_READ_REG(hw, EECD);       /*   3 */
199         *reg++ = IXGB_READ_REG(hw, MFS);        /*   4 */
200
201         /* Interrupt */
202         *reg++ = IXGB_READ_REG(hw, ICR);        /*   5 */
203         *reg++ = IXGB_READ_REG(hw, ICS);        /*   6 */
204         *reg++ = IXGB_READ_REG(hw, IMS);        /*   7 */
205         *reg++ = IXGB_READ_REG(hw, IMC);        /*   8 */
206
207         /* Receive */
208         *reg++ = IXGB_READ_REG(hw, RCTL);       /*   9 */
209         *reg++ = IXGB_READ_REG(hw, FCRTL);      /*  10 */
210         *reg++ = IXGB_READ_REG(hw, FCRTH);      /*  11 */
211         *reg++ = IXGB_READ_REG(hw, RDBAL);      /*  12 */
212         *reg++ = IXGB_READ_REG(hw, RDBAH);      /*  13 */
213         *reg++ = IXGB_READ_REG(hw, RDLEN);      /*  14 */
214         *reg++ = IXGB_READ_REG(hw, RDH);        /*  15 */
215         *reg++ = IXGB_READ_REG(hw, RDT);        /*  16 */
216         *reg++ = IXGB_READ_REG(hw, RDTR);       /*  17 */
217         *reg++ = IXGB_READ_REG(hw, RXDCTL);     /*  18 */
218         *reg++ = IXGB_READ_REG(hw, RAIDC);      /*  19 */
219         *reg++ = IXGB_READ_REG(hw, RXCSUM);     /*  20 */
220
221         for (i = 0; i < IXGB_RAR_ENTRIES; i++) {
222                 *reg++ = IXGB_READ_REG_ARRAY(hw, RAL, (i << 1));        /*21,...,51 */
223                 *reg++ = IXGB_READ_REG_ARRAY(hw, RAH, (i << 1));        /*22,...,52 */
224         }
225
226         /* Transmit */
227         *reg++ = IXGB_READ_REG(hw, TCTL);       /*  53 */
228         *reg++ = IXGB_READ_REG(hw, TDBAL);      /*  54 */
229         *reg++ = IXGB_READ_REG(hw, TDBAH);      /*  55 */
230         *reg++ = IXGB_READ_REG(hw, TDLEN);      /*  56 */
231         *reg++ = IXGB_READ_REG(hw, TDH);        /*  57 */
232         *reg++ = IXGB_READ_REG(hw, TDT);        /*  58 */
233         *reg++ = IXGB_READ_REG(hw, TIDV);       /*  59 */
234         *reg++ = IXGB_READ_REG(hw, TXDCTL);     /*  60 */
235         *reg++ = IXGB_READ_REG(hw, TSPMT);      /*  61 */
236         *reg++ = IXGB_READ_REG(hw, PAP);        /*  62 */
237
238         /* Physical */
239         *reg++ = IXGB_READ_REG(hw, PCSC1);      /*  63 */
240         *reg++ = IXGB_READ_REG(hw, PCSC2);      /*  64 */
241         *reg++ = IXGB_READ_REG(hw, PCSS1);      /*  65 */
242         *reg++ = IXGB_READ_REG(hw, PCSS2);      /*  66 */
243         *reg++ = IXGB_READ_REG(hw, XPCSS);      /*  67 */
244         *reg++ = IXGB_READ_REG(hw, UCCR);       /*  68 */
245         *reg++ = IXGB_READ_REG(hw, XPCSTC);     /*  69 */
246         *reg++ = IXGB_READ_REG(hw, MACA);       /*  70 */
247         *reg++ = IXGB_READ_REG(hw, APAE);       /*  71 */
248         *reg++ = IXGB_READ_REG(hw, ARD);        /*  72 */
249         *reg++ = IXGB_READ_REG(hw, AIS);        /*  73 */
250         *reg++ = IXGB_READ_REG(hw, MSCA);       /*  74 */
251         *reg++ = IXGB_READ_REG(hw, MSRWD);      /*  75 */
252
253         /* Statistics */
254         *reg++ = IXGB_GET_STAT(adapter, tprl);  /*  76 */
255         *reg++ = IXGB_GET_STAT(adapter, tprh);  /*  77 */
256         *reg++ = IXGB_GET_STAT(adapter, gprcl); /*  78 */
257         *reg++ = IXGB_GET_STAT(adapter, gprch); /*  79 */
258         *reg++ = IXGB_GET_STAT(adapter, bprcl); /*  80 */
259         *reg++ = IXGB_GET_STAT(adapter, bprch); /*  81 */
260         *reg++ = IXGB_GET_STAT(adapter, mprcl); /*  82 */
261         *reg++ = IXGB_GET_STAT(adapter, mprch); /*  83 */
262         *reg++ = IXGB_GET_STAT(adapter, uprcl); /*  84 */
263         *reg++ = IXGB_GET_STAT(adapter, uprch); /*  85 */
264         *reg++ = IXGB_GET_STAT(adapter, vprcl); /*  86 */
265         *reg++ = IXGB_GET_STAT(adapter, vprch); /*  87 */
266         *reg++ = IXGB_GET_STAT(adapter, jprcl); /*  88 */
267         *reg++ = IXGB_GET_STAT(adapter, jprch); /*  89 */
268         *reg++ = IXGB_GET_STAT(adapter, gorcl); /*  90 */
269         *reg++ = IXGB_GET_STAT(adapter, gorch); /*  91 */
270         *reg++ = IXGB_GET_STAT(adapter, torl);  /*  92 */
271         *reg++ = IXGB_GET_STAT(adapter, torh);  /*  93 */
272         *reg++ = IXGB_GET_STAT(adapter, rnbc);  /*  94 */
273         *reg++ = IXGB_GET_STAT(adapter, ruc);   /*  95 */
274         *reg++ = IXGB_GET_STAT(adapter, roc);   /*  96 */
275         *reg++ = IXGB_GET_STAT(adapter, rlec);  /*  97 */
276         *reg++ = IXGB_GET_STAT(adapter, crcerrs);       /*  98 */
277         *reg++ = IXGB_GET_STAT(adapter, icbc);  /*  99 */
278         *reg++ = IXGB_GET_STAT(adapter, ecbc);  /* 100 */
279         *reg++ = IXGB_GET_STAT(adapter, mpc);   /* 101 */
280         *reg++ = IXGB_GET_STAT(adapter, tptl);  /* 102 */
281         *reg++ = IXGB_GET_STAT(adapter, tpth);  /* 103 */
282         *reg++ = IXGB_GET_STAT(adapter, gptcl); /* 104 */
283         *reg++ = IXGB_GET_STAT(adapter, gptch); /* 105 */
284         *reg++ = IXGB_GET_STAT(adapter, bptcl); /* 106 */
285         *reg++ = IXGB_GET_STAT(adapter, bptch); /* 107 */
286         *reg++ = IXGB_GET_STAT(adapter, mptcl); /* 108 */
287         *reg++ = IXGB_GET_STAT(adapter, mptch); /* 109 */
288         *reg++ = IXGB_GET_STAT(adapter, uptcl); /* 110 */
289         *reg++ = IXGB_GET_STAT(adapter, uptch); /* 111 */
290         *reg++ = IXGB_GET_STAT(adapter, vptcl); /* 112 */
291         *reg++ = IXGB_GET_STAT(adapter, vptch); /* 113 */
292         *reg++ = IXGB_GET_STAT(adapter, jptcl); /* 114 */
293         *reg++ = IXGB_GET_STAT(adapter, jptch); /* 115 */
294         *reg++ = IXGB_GET_STAT(adapter, gotcl); /* 116 */
295         *reg++ = IXGB_GET_STAT(adapter, gotch); /* 117 */
296         *reg++ = IXGB_GET_STAT(adapter, totl);  /* 118 */
297         *reg++ = IXGB_GET_STAT(adapter, toth);  /* 119 */
298         *reg++ = IXGB_GET_STAT(adapter, dc);    /* 120 */
299         *reg++ = IXGB_GET_STAT(adapter, plt64c);        /* 121 */
300         *reg++ = IXGB_GET_STAT(adapter, tsctc); /* 122 */
301         *reg++ = IXGB_GET_STAT(adapter, tsctfc);        /* 123 */
302         *reg++ = IXGB_GET_STAT(adapter, ibic);  /* 124 */
303         *reg++ = IXGB_GET_STAT(adapter, rfc);   /* 125 */
304         *reg++ = IXGB_GET_STAT(adapter, lfc);   /* 126 */
305         *reg++ = IXGB_GET_STAT(adapter, pfrc);  /* 127 */
306         *reg++ = IXGB_GET_STAT(adapter, pftc);  /* 128 */
307         *reg++ = IXGB_GET_STAT(adapter, mcfrc); /* 129 */
308         *reg++ = IXGB_GET_STAT(adapter, mcftc); /* 130 */
309         *reg++ = IXGB_GET_STAT(adapter, xonrxc);        /* 131 */
310         *reg++ = IXGB_GET_STAT(adapter, xontxc);        /* 132 */
311         *reg++ = IXGB_GET_STAT(adapter, xoffrxc);       /* 133 */
312         *reg++ = IXGB_GET_STAT(adapter, xofftxc);       /* 134 */
313         *reg++ = IXGB_GET_STAT(adapter, rjc);   /* 135 */
314
315         regs->len = (reg - reg_start) * sizeof(uint32_t);
316 }
317
318 static int
319 ixgb_ethtool_geeprom(struct net_device *dev,
320                      struct ethtool_eeprom *eeprom, u8 *data)
321 {
322         struct ixgb_adapter *adapter = dev->priv;
323         struct ixgb_hw *hw = &adapter->hw;
324
325         eeprom->magic = hw->vendor_id | (hw->device_id << 16);
326
327         /* use our function to read the eeprom and update our cache */
328         ixgb_get_eeprom_data(hw);
329         memcpy(data, (char *)hw->eeprom + eeprom->offset, eeprom->len);
330         return 0;
331 }
332
333 static int
334 ixgb_ethtool_seeprom(struct net_device *dev,
335                      struct ethtool_eeprom *eeprom, u8 *data)
336 {
337         struct ixgb_adapter *adapter = dev->priv;
338         struct ixgb_hw *hw = &adapter->hw;
339         /* We are under rtnl, so static is OK */
340         static uint16_t eeprom_buff[IXGB_EEPROM_SIZE];
341         int i, first_word, last_word;
342         char *ptr;
343
344         if (eeprom->magic != (hw->vendor_id | (hw->device_id << 16)))
345                 return -EFAULT;
346
347         first_word = eeprom->offset >> 1;
348         last_word = (eeprom->offset + eeprom->len - 1) >> 1;
349         ptr = (char *)eeprom_buff;
350
351         if (eeprom->offset & 1) {
352                 /* need read/modify/write of first changed EEPROM word */
353                 /* only the second byte of the word is being modified */
354                 eeprom_buff[0] = ixgb_read_eeprom(hw, first_word);
355                 ptr++;
356         }
357         if ((eeprom->offset + eeprom->len) & 1) {
358                 /* need read/modify/write of last changed EEPROM word */
359                 /* only the first byte of the word is being modified */
360                 eeprom_buff[last_word - first_word]
361                     = ixgb_read_eeprom(hw, last_word);
362         }
363         memcpy(ptr, data, eeprom->len);
364
365         for (i = 0; i <= (last_word - first_word); i++)
366                 ixgb_write_eeprom(hw, first_word + i, eeprom_buff[i]);
367
368         /* Update the checksum over the first part of the EEPROM if needed */
369         if (first_word <= EEPROM_CHECKSUM_REG)
370                 ixgb_update_eeprom_checksum(hw);
371
372         return 0;
373 }
374
375 /* toggle LED 4 times per second = 2 "blinks" per second */
376 #define IXGB_ID_INTERVAL        (HZ/4)
377
378 /* bit defines for adapter->led_status */
379 #define IXGB_LED_ON             0
380
381 static void ixgb_led_blink_callback(unsigned long data)
382 {
383         struct ixgb_adapter *adapter = (struct ixgb_adapter *)data;
384
385         if (test_and_change_bit(IXGB_LED_ON, &adapter->led_status))
386                 ixgb_led_off(&adapter->hw);
387         else
388                 ixgb_led_on(&adapter->hw);
389
390         mod_timer(&adapter->blink_timer, jiffies + IXGB_ID_INTERVAL);
391 }
392
393 static int
394 ixgb_ethtool_led_blink(struct net_device *netdev, u32 data)
395 {
396         struct ixgb_adapter *adapter = netdev->priv;
397         if (!adapter->blink_timer.function) {
398                 init_timer(&adapter->blink_timer);
399                 adapter->blink_timer.function = ixgb_led_blink_callback;
400                 adapter->blink_timer.data = (unsigned long)adapter;
401         }
402
403         mod_timer(&adapter->blink_timer, jiffies);
404
405         set_current_state(TASK_INTERRUPTIBLE);
406         if (data)
407                 schedule_timeout(data * HZ);
408         else
409                 schedule_timeout(MAX_SCHEDULE_TIMEOUT);
410
411         del_timer_sync(&adapter->blink_timer);
412         ixgb_led_off(&adapter->hw);
413         clear_bit(IXGB_LED_ON, &adapter->led_status);
414
415         return 0;
416 }
417
418 static int ixgb_nway_reset(struct net_device *netdev)
419 {
420         if (netif_running(netdev)) {
421                 struct ixgb_adapter *adapter = netdev->priv;
422                 ixgb_down(adapter, TRUE);
423                 ixgb_up(adapter);
424         }
425         return 0;
426 }
427
428 static int ixgb_get_stats_count(struct net_device *dev)
429 {
430         return IXGB_STATS_LEN;
431 }
432
433 static void ixgb_get_strings(struct net_device *dev, u32 stringset, u8 *data)
434 {
435         int i;
436         for (i = 0; i < IXGB_STATS_LEN; i++) {
437                 memcpy(data + i * ETH_GSTRING_LEN,
438                        ixgb_gstrings_stats[i].stat_string,
439                        ETH_GSTRING_LEN);
440         }
441 }
442
443 static int ixgb_get_regs_len(struct net_device *dev)
444 {
445         return 136*sizeof(uint32_t);
446 }
447
448 static int ixgb_get_eeprom_len(struct net_device *dev)
449 {
450         /* return size in bytes */
451         return (IXGB_EEPROM_SIZE << 1);
452 }
453
454 static void get_ethtool_stats(struct net_device *dev,
455                 struct ethtool_stats *stats, u64 *data)
456 {
457         struct ixgb_adapter *adapter = dev->priv;
458         int i;
459
460         for (i = 0; i < IXGB_STATS_LEN; i++) {
461                 void *p = (char *)adapter + ixgb_gstrings_stats[i].stat_offset;
462                 stats->data[i] =
463                     (ixgb_gstrings_stats[i].sizeof_stat == sizeof(uint64_t))
464                     ? *(uint64_t *) p
465                     : *(uint32_t *) p;
466         }
467 }
468
469 static u32 ixgb_get_rx_csum(struct net_device *dev)
470 {
471         struct ixgb_adapter *adapter = dev->priv;
472         return adapter->rx_csum;
473 }
474
475 static int ixgb_set_rx_csum(struct net_device *dev, u32 sum)
476 {
477         struct ixgb_adapter *adapter = dev->priv;
478         adapter->rx_csum = sum;
479         ixgb_down(adapter, TRUE);
480         ixgb_up(adapter);
481         return 0;
482 }
483
484 static u32 ixgb_get_tx_csum(struct net_device *dev)
485 {
486         return (dev->features & NETIF_F_HW_CSUM) != 0;
487 }
488
489 static int ixgb_set_tx_csum(struct net_device *dev, u32 sum)
490 {
491         if (sum)
492                 dev->features |= NETIF_F_HW_CSUM;
493         else
494                 dev->features &= ~NETIF_F_HW_CSUM;
495         return 0;
496 }
497
498 static u32 ixgb_get_sg(struct net_device *dev)
499 {
500         return (dev->features & NETIF_F_SG) != 0;
501 }
502
503 static int ixgb_set_sg(struct net_device *dev, u32 sum)
504 {
505         if (sum)
506                 dev->features |= NETIF_F_SG;
507         else
508                 dev->features &= ~NETIF_F_SG;
509         return 0;
510 }
511
512 #ifdef NETIF_F_TSO
513 static u32 ixgb_get_tso(struct net_device *dev)
514 {
515         return (dev->features & NETIF_F_TSO) != 0;
516 }
517
518 static int ixgb_set_tso(struct net_device *dev, u32 sum)
519 {
520         if (sum)
521                 dev->features |= NETIF_F_TSO;
522         else
523                 dev->features &= ~NETIF_F_TSO;
524         return 0;
525 }
526 #endif
527
528 struct ethtool_ops ixgb_ethtool_ops = {
529         .get_settings = ixgb_ethtool_gset,
530         .set_settings = ixgb_ethtool_sset,
531         .get_drvinfo = ixgb_ethtool_gdrvinfo,
532         .nway_reset = ixgb_nway_reset,
533         .get_link = ethtool_op_get_link,
534         .phys_id = ixgb_ethtool_led_blink,
535         .get_strings = ixgb_get_strings,
536         .get_stats_count = ixgb_get_stats_count,
537         .get_regs = ixgb_ethtool_gregs,
538         .get_regs_len = ixgb_get_regs_len,
539         .get_eeprom_len = ixgb_get_eeprom_len,
540         .get_eeprom = ixgb_ethtool_geeprom,
541         .set_eeprom = ixgb_ethtool_seeprom,
542         .get_pauseparam = ixgb_ethtool_gpause,
543         .set_pauseparam = ixgb_ethtool_spause,
544         .get_ethtool_stats = get_ethtool_stats,
545         .get_rx_csum = ixgb_get_rx_csum,
546         .set_rx_csum = ixgb_set_rx_csum,
547         .get_tx_csum = ixgb_get_tx_csum,
548         .set_tx_csum = ixgb_set_tx_csum,
549         .get_sg = ixgb_get_sg,
550         .set_sg = ixgb_set_sg,
551 #ifdef NETIF_F_TSO
552         .get_tso = ixgb_get_tso,
553         .set_tso = ixgb_set_tso,
554 #endif
555 };