patch-2_6_7-vs1_9_1_12
[linux-2.6.git] / drivers / net / ixgb / ixgb_ethtool.c
index 78469e9..605a687 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   
-  Copyright(c) 1999 - 2003 Intel Corporation. All rights reserved.
+  Copyright(c) 1999 - 2004 Intel Corporation. All rights reserved.
   
   This program is free software; you can redistribute it and/or modify it 
   under the terms of the GNU General Public License as published by the Free 
@@ -23,6 +23,7 @@
   Contact Information:
   Linux NICS <linux.nics@intel.com>
   Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+
 *******************************************************************************/
 
 /* ethtool support for ixgb */
@@ -35,22 +36,63 @@ extern char ixgb_driver_name[];
 extern char ixgb_driver_version[];
 
 extern int ixgb_up(struct ixgb_adapter *adapter);
-extern int ixgb_down(struct ixgb_adapter *adapter);
-
-/**
- * ixgb_ethtool_ioctl - Ethtool Ioctl Support
- * @netdev: net device structure
- * @ifr: interface request structure
- **/
+extern void ixgb_down(struct ixgb_adapter *adapter, boolean_t kill_watchdog);
 
-static inline int
-ixgb_eeprom_size(struct ixgb_hw *hw)
+static inline int ixgb_eeprom_size(struct ixgb_hw *hw)
 {
        /* return size in bytes */
        return (IXGB_EEPROM_SIZE << 1);
 }
 
-#define SPEED_10000 10000
+struct ixgb_stats {
+       char stat_string[ETH_GSTRING_LEN];
+       int sizeof_stat;
+       int stat_offset;
+};
+
+#define IXGB_STAT(m) sizeof(((struct ixgb_adapter *)0)->m), \
+                     offsetof(struct ixgb_adapter, m)
+static struct ixgb_stats ixgb_gstrings_stats[] = {
+       {"rx_packets", IXGB_STAT(net_stats.rx_packets)},
+       {"tx_packets", IXGB_STAT(net_stats.tx_packets)},
+       {"rx_bytes", IXGB_STAT(net_stats.rx_bytes)},
+       {"tx_bytes", IXGB_STAT(net_stats.tx_bytes)},
+       {"rx_errors", IXGB_STAT(net_stats.rx_errors)},
+       {"tx_errors", IXGB_STAT(net_stats.tx_errors)},
+       {"rx_dropped", IXGB_STAT(net_stats.rx_dropped)},
+       {"tx_dropped", IXGB_STAT(net_stats.tx_dropped)},
+       {"multicast", IXGB_STAT(net_stats.multicast)},
+       {"collisions", IXGB_STAT(net_stats.collisions)},
+/*     { "rx_length_errors", IXGB_STAT(net_stats.rx_length_errors) },  */
+       {"rx_over_errors", IXGB_STAT(net_stats.rx_over_errors)},
+       {"rx_crc_errors", IXGB_STAT(net_stats.rx_crc_errors)},
+       {"rx_frame_errors", IXGB_STAT(net_stats.rx_frame_errors)},
+       {"rx_fifo_errors", IXGB_STAT(net_stats.rx_fifo_errors)},
+       {"rx_missed_errors", IXGB_STAT(net_stats.rx_missed_errors)},
+       {"tx_aborted_errors", IXGB_STAT(net_stats.tx_aborted_errors)},
+       {"tx_carrier_errors", IXGB_STAT(net_stats.tx_carrier_errors)},
+       {"tx_fifo_errors", IXGB_STAT(net_stats.tx_fifo_errors)},
+       {"tx_heartbeat_errors", IXGB_STAT(net_stats.tx_heartbeat_errors)},
+       {"tx_window_errors", IXGB_STAT(net_stats.tx_window_errors)},
+       {"tx_deferred_ok", IXGB_STAT(stats.dc)},
+       {"rx_long_length_errors", IXGB_STAT(stats.roc)},
+       {"rx_short_length_errors", IXGB_STAT(stats.ruc)},
+#ifdef NETIF_F_TSO
+       {"tx_tcp_seg_good", IXGB_STAT(stats.tsctc)},
+       {"tx_tcp_seg_failed", IXGB_STAT(stats.tsctfc)},
+#endif
+       {"rx_flow_control_xon", IXGB_STAT(stats.xonrxc)},
+       {"rx_flow_control_xoff", IXGB_STAT(stats.xoffrxc)},
+       {"tx_flow_control_xon", IXGB_STAT(stats.xontxc)},
+       {"tx_flow_control_xoff", IXGB_STAT(stats.xofftxc)},
+       {"rx_csum_offload_good", IXGB_STAT(hw_csum_rx_good)},
+       {"rx_csum_offload_errors", IXGB_STAT(hw_csum_rx_error)},
+       {"tx_csum_offload_good", IXGB_STAT(hw_csum_tx_good)},
+       {"tx_csum_offload_errors", IXGB_STAT(hw_csum_tx_error)}
+};
+
+#define IXGB_STATS_LEN \
+       sizeof(ixgb_gstrings_stats) / sizeof(struct ixgb_stats)
 
 static void
 ixgb_ethtool_gset(struct ixgb_adapter *adapter, struct ethtool_cmd *ecmd)
@@ -61,7 +103,7 @@ ixgb_ethtool_gset(struct ixgb_adapter *adapter, struct ethtool_cmd *ecmd)
        ecmd->transceiver = XCVR_EXTERNAL;
 
        if (netif_carrier_ok(adapter->netdev)) {
-               ecmd->speed = 10000;
+               ecmd->speed = SPEED_10000;
                ecmd->duplex = DUPLEX_FULL;
        } else {
                ecmd->speed = -1;
@@ -78,64 +120,80 @@ ixgb_ethtool_sset(struct ixgb_adapter *adapter, struct ethtool_cmd *ecmd)
            ecmd->speed + ecmd->duplex != SPEED_10000 + DUPLEX_FULL)
                return -EINVAL;
        else {
-               ixgb_down(adapter);
+               ixgb_down(adapter, TRUE);
                ixgb_up(adapter);
        }
 
        return 0;
 }
 
-#if 0
 static int
-ixgb_ethtool_promiscuous(struct ixgb_adapter *adapter,
-                        struct ethtool_pmode *pmode)
+ixgb_ethtool_gpause(struct ixgb_adapter *adapter,
+                   struct ethtool_pauseparam *epause)
 {
-       u32 rctl = IXGB_READ_REG(&adapter->hw, RCTL);
+       struct ixgb_hw *hw = &adapter->hw;
 
-       pmode->rctl_old = rctl;
-       if (pmode->upe)
-               rctl |= IXGB_RCTL_UPE;
-       else
-               rctl &= ~IXGB_RCTL_UPE;
+       epause->autoneg = AUTONEG_DISABLE;
 
-       if (pmode->mpe)
-               rctl |= IXGB_RCTL_MPE;
-       else
-               rctl &= ~IXGB_RCTL_MPE;
+       if (hw->fc.type == ixgb_fc_rx_pause)
+               epause->rx_pause = 1;
+       else if (hw->fc.type == ixgb_fc_tx_pause)
+               epause->tx_pause = 1;
+       else if (hw->fc.type == ixgb_fc_full) {
+               epause->rx_pause = 1;
+               epause->tx_pause = 1;
+       }
+
+       return 0;
+}
+
+static int
+ixgb_ethtool_spause(struct ixgb_adapter *adapter,
+                   struct ethtool_pauseparam *epause)
+{
+       struct ixgb_hw *hw = &adapter->hw;
+
+       if (epause->autoneg == AUTONEG_ENABLE)
+               return -EINVAL;
 
-       IXGB_WRITE_REG(&adapter->hw, RCTL, rctl);
+       if (epause->rx_pause && epause->tx_pause)
+               hw->fc.type = ixgb_fc_full;
+       else if (epause->rx_pause && !epause->tx_pause)
+               hw->fc.type = ixgb_fc_rx_pause;
+       else if (!epause->rx_pause && epause->tx_pause)
+               hw->fc.type = ixgb_fc_tx_pause;
+       else if (!epause->rx_pause && !epause->tx_pause)
+               hw->fc.type = ixgb_fc_none;
 
-       pmode->rctl_new = IXGB_READ_REG(&adapter->hw, RCTL);
+       ixgb_down(adapter, TRUE);
+       ixgb_up(adapter);
 
        return 0;
 }
-#endif
 
-#define IXGB_REG_DUMP_LEN  136*sizeof(u32)
 static void
 ixgb_ethtool_gdrvinfo(struct ixgb_adapter *adapter,
                      struct ethtool_drvinfo *drvinfo)
 {
        strncpy(drvinfo->driver, ixgb_driver_name, 32);
        strncpy(drvinfo->version, ixgb_driver_version, 32);
-       strncpy(drvinfo->fw_version, "", 32);
+       strncpy(drvinfo->fw_version, "N/A", 32);
        strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 32);
-#ifdef ETHTOOL_GREGS
+       drvinfo->n_stats = IXGB_STATS_LEN;
+#define IXGB_REG_DUMP_LEN  136*sizeof(uint32_t)
        drvinfo->regdump_len = IXGB_REG_DUMP_LEN;
-#endif                         /* ETHTOOL_GREGS */
        drvinfo->eedump_len = ixgb_eeprom_size(&adapter->hw);
 }
 
-#ifdef  ETHTOOL_GREGS
 #define IXGB_GET_STAT(_A_, _R_) _A_->stats._R_
 static void
 ixgb_ethtool_gregs(struct ixgb_adapter *adapter,
-                  struct ethtool_regs *regs, u8 * regs_buff)
+                  struct ethtool_regs *regs, uint32_t * regs_buff)
 {
        struct ixgb_hw *hw = &adapter->hw;
-       u32 *reg = (u32 *) regs_buff;
-       u32 *reg_start = reg;
-       u8 i;
+       uint32_t *reg = regs_buff;
+       uint32_t *reg_start = reg;
+       uint8_t i;
 
        regs->version =
            (adapter->hw.device_id << 16) | adapter->hw.subsystem_id;
@@ -199,15 +257,6 @@ ixgb_ethtool_gregs(struct ixgb_adapter *adapter,
        *reg++ = IXGB_READ_REG(hw, MSCA);       /*  74 */
        *reg++ = IXGB_READ_REG(hw, MSRWD);      /*  75 */
 
-#if 0
-       /* Wake-up */
-       reg[IXGB_WUFC] = IXGB_READ_REG(hw, WUFC);
-       reg[IXGB_WUS] = IXGB_READ_REG(hw, WUS);
-       reg[IXGB_FFLT] = IXGB_READ_REG(hw, FFLT);
-       reg[IXGB_FFMT] = IXGB_READ_REG(hw, FFMT);
-       reg[IXGB_FTVT] = IXGB_READ_REG(hw, FTVT);
-#endif
-
        /* Statistics */
        *reg++ = IXGB_GET_STAT(adapter, tprl);  /*  76 */
        *reg++ = IXGB_GET_STAT(adapter, tprh);  /*  77 */
@@ -270,22 +319,21 @@ ixgb_ethtool_gregs(struct ixgb_adapter *adapter,
        *reg++ = IXGB_GET_STAT(adapter, xofftxc);       /* 134 */
        *reg++ = IXGB_GET_STAT(adapter, rjc);   /* 135 */
 
-#if 0
-#endif
-       regs->len = (reg - reg_start) * sizeof (u32);
+       regs->len = (reg - reg_start) * sizeof(uint32_t);
 }
-#endif                         /* ETHTOOL_GREGS */
 
 static int
 ixgb_ethtool_geeprom(struct ixgb_adapter *adapter,
-                    struct ethtool_eeprom *eeprom, u16 * eeprom_buff)
+                    struct ethtool_eeprom *eeprom, uint16_t * eeprom_buff)
 {
        struct ixgb_hw *hw = &adapter->hw;
        int i, max_len, first_word, last_word;
-       IXGB_DBG("ixgb_ethtool_geeprom\n");
+       int ret_val = 0;
 
-       if (eeprom->len == 0)
-               return -EINVAL;
+       if (eeprom->len == 0) {
+               ret_val = -EINVAL;
+               goto geeprom_error;
+       }
 
        eeprom->magic = hw->vendor_id | (hw->device_id << 16);
 
@@ -294,8 +342,10 @@ ixgb_ethtool_geeprom(struct ixgb_adapter *adapter,
        /* use our function to read the eeprom and update our cache */
        ixgb_get_eeprom_data(hw);
 
-       if (eeprom->offset > eeprom->offset + eeprom->len)
-               return -EINVAL;
+       if (eeprom->offset > eeprom->offset + eeprom->len) {
+               ret_val = -EINVAL;
+               goto geeprom_error;
+       }
 
        if ((eeprom->offset + eeprom->len) > max_len)
                eeprom->len = (max_len - eeprom->offset);
@@ -306,15 +356,16 @@ ixgb_ethtool_geeprom(struct ixgb_adapter *adapter,
        for (i = 0; i <= (last_word - first_word); i++) {
                eeprom_buff[i] = hw->eeprom[first_word + i];
        }
-
-       return 0;
+      geeprom_error:
+       return ret_val;
 }
+
 static int
 ixgb_ethtool_seeprom(struct ixgb_adapter *adapter,
-                    struct ethtool_eeprom *eeprom, void *user_data)
+                    struct ethtool_eeprom *eeprom, void __user *user_data)
 {
        struct ixgb_hw *hw = &adapter->hw;
-       u16 eeprom_buff[256];
+       uint16_t eeprom_buff[256];
        int i, max_len, first_word, last_word;
        void *ptr;
 
@@ -334,7 +385,7 @@ ixgb_ethtool_seeprom(struct ixgb_adapter *adapter,
 
        first_word = eeprom->offset >> 1;
        last_word = (eeprom->offset + eeprom->len - 1) >> 1;
-       ptr = (void *) eeprom_buff;
+       ptr = (void *)eeprom_buff;
 
        if (eeprom->offset & 1) {
                /* need read/modify/write of first changed EEPROM word */
@@ -361,18 +412,15 @@ ixgb_ethtool_seeprom(struct ixgb_adapter *adapter,
        return 0;
 }
 
-#ifdef  ETHTOOL_PHYS_ID
-
 /* toggle LED 4 times per second = 2 "blinks" per second */
-#define IXGB_ID_INTERVAL    (HZ/4)
+#define IXGB_ID_INTERVAL       (HZ/4)
 
 /* bit defines for adapter->led_status */
-#define IXGB_LED_ON     0
+#define IXGB_LED_ON            0
 
-static void
-ixgb_led_blink_callback(unsigned long data)
+static void ixgb_led_blink_callback(unsigned long data)
 {
-       struct ixgb_adapter *adapter = (struct ixgb_adapter *) data;
+       struct ixgb_adapter *adapter = (struct ixgb_adapter *)data;
 
        if (test_and_change_bit(IXGB_LED_ON, &adapter->led_status))
                ixgb_led_off(&adapter->hw);
@@ -388,7 +436,7 @@ ixgb_ethtool_led_blink(struct ixgb_adapter *adapter, struct ethtool_value *id)
        if (!adapter->blink_timer.function) {
                init_timer(&adapter->blink_timer);
                adapter->blink_timer.function = ixgb_led_blink_callback;
-               adapter->blink_timer.data = (unsigned long) adapter;
+               adapter->blink_timer.data = (unsigned long)adapter;
        }
 
        mod_timer(&adapter->blink_timer, jiffies);
@@ -405,114 +453,121 @@ ixgb_ethtool_led_blink(struct ixgb_adapter *adapter, struct ethtool_value *id)
 
        return 0;
 }
-#endif                         /* ETHTOOL_PHYS_ID */
 
-int
-ixgb_ethtool_ioctl(struct net_device *netdev, struct ifreq *ifr)
+int ixgb_ethtool_ioctl(struct net_device *netdev, struct ifreq *ifr)
 {
        struct ixgb_adapter *adapter = netdev->priv;
-       void *addr = ifr->ifr_data;
-       u32 cmd;
+       void __user *addr = ifr->ifr_data;
+       uint32_t cmd;
 
-       if (get_user(cmd, (u32 *) addr))
+       if (get_user(cmd, (uint32_t __user *) addr))
                return -EFAULT;
 
        switch (cmd) {
-#if 0
-       case ETHTOOL_PROMISCUOUS:{
-                       struct ethtool_pmode pmode;
-
-                       if (copy_from_user(&pmode, addr, sizeof (pmode)))
-                               return -EFAULT;
-
-                       ixgb_ethtool_promiscuous(adapter, &pmode);
-
-                       if (copy_to_user(addr, &pmode, sizeof (pmode)))
-                               return -EFAULT;
-
-                       return 0;
-               }
-       case ETHTOOL_DOWN_UP:
-               ixgb_down(netdev->priv);
-               ixgb_up(netdev->priv);
-               return 0;
-#endif
        case ETHTOOL_GSET:{
                        struct ethtool_cmd ecmd = { ETHTOOL_GSET };
-
                        ixgb_ethtool_gset(adapter, &ecmd);
-                       if (copy_to_user(addr, &ecmd, sizeof (ecmd)))
+                       if (copy_to_user(addr, &ecmd, sizeof(ecmd)))
                                return -EFAULT;
                        return 0;
                }
        case ETHTOOL_SSET:{
                        struct ethtool_cmd ecmd;
-
-                       if (copy_from_user(&ecmd, addr, sizeof (ecmd)))
+                       if (copy_from_user(&ecmd, addr, sizeof(ecmd)))
                                return -EFAULT;
                        return ixgb_ethtool_sset(adapter, &ecmd);
                }
-       case ETHTOOL_GDRVINFO:
-               {
+       case ETHTOOL_GDRVINFO:{
                        struct ethtool_drvinfo drvinfo = { ETHTOOL_GDRVINFO };
-
                        ixgb_ethtool_gdrvinfo(adapter, &drvinfo);
-                       if (copy_to_user(addr, &drvinfo, sizeof (drvinfo)))
+                       if (copy_to_user(addr, &drvinfo, sizeof(drvinfo)))
                                return -EFAULT;
                        return 0;
                }
-#if defined(ETHTOOL_GREGS) && defined(ETHTOOL_GEEPROM)
+       case ETHTOOL_GSTRINGS:{
+                       struct ethtool_gstrings gstrings = { ETHTOOL_GSTRINGS };
+                       char *strings = NULL;
+                       int err = 0;
+
+                       if (copy_from_user(&gstrings, addr, sizeof(gstrings)))
+                               return -EFAULT;
+                       switch (gstrings.string_set) {
+                       case ETH_SS_STATS:{
+                                       int i;
+                                       gstrings.len = IXGB_STATS_LEN;
+                                       strings =
+                                           kmalloc(IXGB_STATS_LEN *
+                                                   ETH_GSTRING_LEN,
+                                                   GFP_KERNEL);
+                                       if (!strings)
+                                               return -ENOMEM;
+                                       for (i = 0; i < IXGB_STATS_LEN; i++) {
+                                               memcpy(&strings
+                                                      [i * ETH_GSTRING_LEN],
+                                                      ixgb_gstrings_stats[i].
+                                                      stat_string,
+                                                      ETH_GSTRING_LEN);
+                                       }
+                                       break;
+                               }
+                       default:
+                               return -EOPNOTSUPP;
+                       }
+                       if (copy_to_user(addr, &gstrings, sizeof(gstrings)))
+                               err = -EFAULT;
+                       addr += offsetof(struct ethtool_gstrings, data);
+                       if (!err && copy_to_user(addr, strings,
+                                                gstrings.len *
+                                                ETH_GSTRING_LEN))
+                               err = -EFAULT;
+
+                       kfree(strings);
+                       return err;
+               }
        case ETHTOOL_GREGS:{
                        struct ethtool_regs regs = { ETHTOOL_GREGS };
-                       u8 regs_buff[IXGB_REG_DUMP_LEN];
+                       uint32_t regs_buff[IXGB_REG_DUMP_LEN];
 
+                       if (copy_from_user(&regs, addr, sizeof(regs)))
+                               return -EFAULT;
                        ixgb_ethtool_gregs(adapter, &regs, regs_buff);
-
-                       if (copy_to_user(addr, &regs, sizeof (regs)))
+                       if (copy_to_user(addr, &regs, sizeof(regs)))
                                return -EFAULT;
 
                        addr += offsetof(struct ethtool_regs, data);
-
                        if (copy_to_user(addr, regs_buff, regs.len))
                                return -EFAULT;
+
                        return 0;
                }
-#endif                         /* ETHTOOL_GREGS */
        case ETHTOOL_NWAY_RST:{
-                       IXGB_DBG("ETHTOOL_NWAY_RST\n");
-                       ixgb_down(adapter);
-                       ixgb_up(adapter);
-
+                       if (netif_running(netdev)) {
+                               ixgb_down(adapter, TRUE);
+                               ixgb_up(adapter);
+                       }
                        return 0;
                }
-#ifdef  ETHTOOL_PHYS_ID
        case ETHTOOL_PHYS_ID:{
                        struct ethtool_value id;
-
-                       IXGB_DBG("ETHTOOL_PHYS_ID\n");
-                       if (copy_from_user(&id, addr, sizeof (id)))
+                       if (copy_from_user(&id, addr, sizeof(id)))
                                return -EFAULT;
                        return ixgb_ethtool_led_blink(adapter, &id);
                }
-#endif                         /* ETHTOOL_PHYS_ID */
        case ETHTOOL_GLINK:{
                        struct ethtool_value link = { ETHTOOL_GLINK };
-
-                       IXGB_DBG("ETHTOOL_GLINK\n");
                        link.data = netif_carrier_ok(netdev);
-                       if (copy_to_user(addr, &link, sizeof (link)))
+                       if (copy_to_user(addr, &link, sizeof(link)))
                                return -EFAULT;
                        return 0;
                }
 
        case ETHTOOL_GEEPROM:{
                        struct ethtool_eeprom eeprom = { ETHTOOL_GEEPROM };
-                       u16 eeprom_buff[IXGB_EEPROM_SIZE];
+                       uint16_t eeprom_buff[IXGB_EEPROM_SIZE];
                        void *ptr;
-                       int err;
+                       int err = 0;
 
-                       IXGB_DBG("ETHTOOL_GEEPROM\n");
-                       if (copy_from_user(&eeprom, addr, sizeof (eeprom)))
+                       if (copy_from_user(&eeprom, addr, sizeof(eeprom)))
                                return -EFAULT;
 
                        if ((err =
@@ -520,12 +575,12 @@ ixgb_ethtool_ioctl(struct net_device *netdev, struct ifreq *ifr)
                                                  eeprom_buff)) < 0)
                                return err;
 
-                       if (copy_to_user(addr, &eeprom, sizeof (eeprom)))
+                       if (copy_to_user(addr, &eeprom, sizeof(eeprom)))
                                return -EFAULT;
 
                        addr += offsetof(struct ethtool_eeprom, data);
+                       ptr = ((void *)eeprom_buff) + (eeprom.offset & 1);
 
-                       ptr = ((void *) eeprom_buff) + (eeprom.offset & 1);
                        if (copy_to_user(addr, ptr, eeprom.len))
                                return -EFAULT;
                        return 0;
@@ -533,13 +588,133 @@ ixgb_ethtool_ioctl(struct net_device *netdev, struct ifreq *ifr)
        case ETHTOOL_SEEPROM:{
                        struct ethtool_eeprom eeprom;
 
-                       IXGB_DBG("ETHTOOL_SEEPROM\n");
-                       if (copy_from_user(&eeprom, addr, sizeof (eeprom)))
+                       if (copy_from_user(&eeprom, addr, sizeof(eeprom)))
                                return -EFAULT;
 
                        addr += offsetof(struct ethtool_eeprom, data);
                        return ixgb_ethtool_seeprom(adapter, &eeprom, addr);
                }
+       case ETHTOOL_GPAUSEPARAM:{
+                       struct ethtool_pauseparam epause =
+                           { ETHTOOL_GPAUSEPARAM };
+                       ixgb_ethtool_gpause(adapter, &epause);
+                       if (copy_to_user(addr, &epause, sizeof(epause)))
+                               return -EFAULT;
+                       return 0;
+               }
+       case ETHTOOL_SPAUSEPARAM:{
+                       struct ethtool_pauseparam epause;
+                       if (copy_from_user(&epause, addr, sizeof(epause)))
+                               return -EFAULT;
+                       return ixgb_ethtool_spause(adapter, &epause);
+               }
+       case ETHTOOL_GSTATS:{
+                       struct {
+                               struct ethtool_stats eth_stats;
+                               uint64_t data[IXGB_STATS_LEN];
+                       } stats = { {
+                       ETHTOOL_GSTATS, IXGB_STATS_LEN}};
+                       int i;
+
+                       for (i = 0; i < IXGB_STATS_LEN; i++)
+                               stats.data[i] =
+                                   (ixgb_gstrings_stats[i].sizeof_stat ==
+                                    sizeof(uint64_t)) ? *(uint64_t *) ((char *)
+                                                                       adapter
+                                                                       +
+                                                                       ixgb_gstrings_stats
+                                                                       [i].
+                                                                       stat_offset)
+                                   : *(uint32_t *) ((char *)adapter +
+                                                    ixgb_gstrings_stats[i].
+                                                    stat_offset);
+                       if (copy_to_user(addr, &stats, sizeof(stats)))
+                               return -EFAULT;
+                       return 0;
+               }
+       case ETHTOOL_GRXCSUM:{
+                       struct ethtool_value edata = { ETHTOOL_GRXCSUM };
+
+                       edata.data = adapter->rx_csum;
+                       if (copy_to_user(addr, &edata, sizeof(edata)))
+                               return -EFAULT;
+                       return 0;
+               }
+       case ETHTOOL_SRXCSUM:{
+                       struct ethtool_value edata;
+
+                       if (copy_from_user(&edata, addr, sizeof(edata)))
+                               return -EFAULT;
+                       adapter->rx_csum = edata.data;
+                       ixgb_down(adapter, TRUE);
+                       ixgb_up(adapter);
+                       return 0;
+               }
+       case ETHTOOL_GTXCSUM:{
+                       struct ethtool_value edata = { ETHTOOL_GTXCSUM };
+
+                       edata.data = (netdev->features & NETIF_F_HW_CSUM) != 0;
+                       if (copy_to_user(addr, &edata, sizeof(edata)))
+                               return -EFAULT;
+                       return 0;
+               }
+       case ETHTOOL_STXCSUM:{
+                       struct ethtool_value edata;
+
+                       if (copy_from_user(&edata, addr, sizeof(edata)))
+                               return -EFAULT;
+
+                       if (edata.data)
+                               netdev->features |= NETIF_F_HW_CSUM;
+                       else
+                               netdev->features &= ~NETIF_F_HW_CSUM;
+
+                       return 0;
+               }
+       case ETHTOOL_GSG:{
+                       struct ethtool_value edata = { ETHTOOL_GSG };
+
+                       edata.data = (netdev->features & NETIF_F_SG) != 0;
+                       if (copy_to_user(addr, &edata, sizeof(edata)))
+                               return -EFAULT;
+                       return 0;
+               }
+       case ETHTOOL_SSG:{
+                       struct ethtool_value edata;
+
+                       if (copy_from_user(&edata, addr, sizeof(edata)))
+                               return -EFAULT;
+
+                       if (edata.data)
+                               netdev->features |= NETIF_F_SG;
+                       else
+                               netdev->features &= ~NETIF_F_SG;
+
+                       return 0;
+               }
+#ifdef NETIF_F_TSO
+       case ETHTOOL_GTSO:{
+                       struct ethtool_value edata = { ETHTOOL_GTSO };
+
+                       edata.data = (netdev->features & NETIF_F_TSO) != 0;
+                       if (copy_to_user(addr, &edata, sizeof(edata)))
+                               return -EFAULT;
+                       return 0;
+               }
+       case ETHTOOL_STSO:{
+                       struct ethtool_value edata;
+
+                       if (copy_from_user(&edata, addr, sizeof(edata)))
+                               return -EFAULT;
+
+                       if (edata.data)
+                               netdev->features |= NETIF_F_TSO;
+                       else
+                               netdev->features &= ~NETIF_F_TSO;
+
+                       return 0;
+               }
+#endif
        default:
                return -EOPNOTSUPP;
        }