Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux-2.6
[pandora-kernel.git] / drivers / net / ixgb / ixgb_ethtool.c
index 75f3a68..288ee1d 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel PRO/10GbE Linux driver
-  Copyright(c) 1999 - 2006 Intel Corporation.
+  Copyright(c) 1999 - 2008 Intel Corporation.
 
   This program is free software; you can redistribute it and/or modify it
   under the terms and conditions of the GNU General Public License,
 
 #include <asm/uaccess.h>
 
-extern int ixgb_up(struct ixgb_adapter *adapter);
-extern void ixgb_down(struct ixgb_adapter *adapter, boolean_t kill_watchdog);
-extern void ixgb_reset(struct ixgb_adapter *adapter);
-extern int ixgb_setup_rx_resources(struct ixgb_adapter *adapter);
-extern int ixgb_setup_tx_resources(struct ixgb_adapter *adapter);
-extern void ixgb_free_rx_resources(struct ixgb_adapter *adapter);
-extern void ixgb_free_tx_resources(struct ixgb_adapter *adapter);
-extern void ixgb_update_stats(struct ixgb_adapter *adapter);
-
 #define IXGB_ALL_RAR_ENTRIES 16
 
 struct ixgb_stats {
@@ -104,7 +95,7 @@ ixgb_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
        ecmd->port = PORT_FIBRE;
        ecmd->transceiver = XCVR_EXTERNAL;
 
-       if(netif_carrier_ok(adapter->netdev)) {
+       if (netif_carrier_ok(adapter->netdev)) {
                ecmd->speed = SPEED_10000;
                ecmd->duplex = DUPLEX_FULL;
        } else {
@@ -131,12 +122,12 @@ ixgb_set_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
 {
        struct ixgb_adapter *adapter = netdev_priv(netdev);
 
-       if(ecmd->autoneg == AUTONEG_ENABLE ||
+       if (ecmd->autoneg == AUTONEG_ENABLE ||
           ecmd->speed + ecmd->duplex != SPEED_10000 + DUPLEX_FULL)
                return -EINVAL;
-       
-       if(netif_running(adapter->netdev)) {
-               ixgb_down(adapter, TRUE);
+
+       if (netif_running(adapter->netdev)) {
+               ixgb_down(adapter, true);
                ixgb_reset(adapter);
                ixgb_up(adapter);
                ixgb_set_speed_duplex(netdev);
@@ -152,14 +143,14 @@ ixgb_get_pauseparam(struct net_device *netdev,
 {
        struct ixgb_adapter *adapter = netdev_priv(netdev);
        struct ixgb_hw *hw = &adapter->hw;
-       
+
        pause->autoneg = AUTONEG_DISABLE;
-               
-       if(hw->fc.type == ixgb_fc_rx_pause)
+
+       if (hw->fc.type == ixgb_fc_rx_pause)
                pause->rx_pause = 1;
-       else if(hw->fc.type == ixgb_fc_tx_pause)
+       else if (hw->fc.type == ixgb_fc_tx_pause)
                pause->tx_pause = 1;
-       else if(hw->fc.type == ixgb_fc_full) {
+       else if (hw->fc.type == ixgb_fc_full) {
                pause->rx_pause = 1;
                pause->tx_pause = 1;
        }
@@ -171,30 +162,30 @@ ixgb_set_pauseparam(struct net_device *netdev,
 {
        struct ixgb_adapter *adapter = netdev_priv(netdev);
        struct ixgb_hw *hw = &adapter->hw;
-       
-       if(pause->autoneg == AUTONEG_ENABLE)
+
+       if (pause->autoneg == AUTONEG_ENABLE)
                return -EINVAL;
 
-       if(pause->rx_pause && pause->tx_pause)
+       if (pause->rx_pause && pause->tx_pause)
                hw->fc.type = ixgb_fc_full;
-       else if(pause->rx_pause && !pause->tx_pause)
+       else if (pause->rx_pause && !pause->tx_pause)
                hw->fc.type = ixgb_fc_rx_pause;
-       else if(!pause->rx_pause && pause->tx_pause)
+       else if (!pause->rx_pause && pause->tx_pause)
                hw->fc.type = ixgb_fc_tx_pause;
-       else if(!pause->rx_pause && !pause->tx_pause)
+       else if (!pause->rx_pause && !pause->tx_pause)
                hw->fc.type = ixgb_fc_none;
 
-       if(netif_running(adapter->netdev)) {
-               ixgb_down(adapter, TRUE);
+       if (netif_running(adapter->netdev)) {
+               ixgb_down(adapter, true);
                ixgb_up(adapter);
                ixgb_set_speed_duplex(netdev);
        } else
                ixgb_reset(adapter);
-               
+
        return 0;
 }
 
-static uint32_t
+static u32
 ixgb_get_rx_csum(struct net_device *netdev)
 {
        struct ixgb_adapter *adapter = netdev_priv(netdev);
@@ -203,29 +194,29 @@ ixgb_get_rx_csum(struct net_device *netdev)
 }
 
 static int
-ixgb_set_rx_csum(struct net_device *netdev, uint32_t data)
+ixgb_set_rx_csum(struct net_device *netdev, u32 data)
 {
        struct ixgb_adapter *adapter = netdev_priv(netdev);
 
        adapter->rx_csum = data;
 
-       if(netif_running(netdev)) {
-               ixgb_down(adapter,TRUE);
+       if (netif_running(netdev)) {
+               ixgb_down(adapter, true);
                ixgb_up(adapter);
                ixgb_set_speed_duplex(netdev);
        } else
                ixgb_reset(adapter);
        return 0;
 }
-       
-static uint32_t
+
+static u32
 ixgb_get_tx_csum(struct net_device *netdev)
 {
        return (netdev->features & NETIF_F_HW_CSUM) != 0;
 }
 
 static int
-ixgb_set_tx_csum(struct net_device *netdev, uint32_t data)
+ixgb_set_tx_csum(struct net_device *netdev, u32 data)
 {
        if (data)
                netdev->features |= NETIF_F_HW_CSUM;
@@ -236,16 +227,16 @@ ixgb_set_tx_csum(struct net_device *netdev, uint32_t data)
 }
 
 static int
-ixgb_set_tso(struct net_device *netdev, uint32_t data)
+ixgb_set_tso(struct net_device *netdev, u32 data)
 {
-       if(data)
+       if (data)
                netdev->features |= NETIF_F_TSO;
        else
                netdev->features &= ~NETIF_F_TSO;
        return 0;
-} 
+}
 
-static uint32_t
+static u32
 ixgb_get_msglevel(struct net_device *netdev)
 {
        struct ixgb_adapter *adapter = netdev_priv(netdev);
@@ -253,17 +244,17 @@ ixgb_get_msglevel(struct net_device *netdev)
 }
 
 static void
-ixgb_set_msglevel(struct net_device *netdev, uint32_t data)
+ixgb_set_msglevel(struct net_device *netdev, u32 data)
 {
        struct ixgb_adapter *adapter = netdev_priv(netdev);
        adapter->msg_enable = data;
 }
 #define IXGB_GET_STAT(_A_, _R_) _A_->stats._R_
 
-static int 
+static int
 ixgb_get_regs_len(struct net_device *netdev)
 {
-#define IXGB_REG_DUMP_LEN  136*sizeof(uint32_t)
+#define IXGB_REG_DUMP_LEN  136*sizeof(u32)
        return IXGB_REG_DUMP_LEN;
 }
 
@@ -273,9 +264,9 @@ ixgb_get_regs(struct net_device *netdev,
 {
        struct ixgb_adapter *adapter = netdev_priv(netdev);
        struct ixgb_hw *hw = &adapter->hw;
-       uint32_t *reg = p;
-       uint32_t *reg_start = reg;
-       uint8_t i;
+       u32 *reg = p;
+       u32 *reg_start = reg;
+       u8 i;
 
        /* the 1 (one) below indicates an attempt at versioning, if the
         * interface in ethtool or the driver changes, this 1 should be
@@ -310,7 +301,7 @@ ixgb_get_regs(struct net_device *netdev,
        *reg++ = IXGB_READ_REG(hw, RXCSUM);     /*  20 */
 
        /* there are 16 RAR entries in hardware, we only use 3 */
-       for(i = 0; i < IXGB_ALL_RAR_ENTRIES; i++) {
+       for (i = 0; i < IXGB_ALL_RAR_ENTRIES; i++) {
                *reg++ = IXGB_READ_REG_ARRAY(hw, RAL, (i << 1)); /*21,...,51 */
                *reg++ = IXGB_READ_REG_ARRAY(hw, RAH, (i << 1)); /*22,...,52 */
        }
@@ -404,7 +395,7 @@ ixgb_get_regs(struct net_device *netdev,
        *reg++ = IXGB_GET_STAT(adapter, xofftxc);       /* 134 */
        *reg++ = IXGB_GET_STAT(adapter, rjc);   /* 135 */
 
-       regs->len = (reg - reg_start) * sizeof(uint32_t);
+       regs->len = (reg - reg_start) * sizeof(u32);
 }
 
 static int
@@ -416,7 +407,7 @@ ixgb_get_eeprom_len(struct net_device *netdev)
 
 static int
 ixgb_get_eeprom(struct net_device *netdev,
-                 struct ethtool_eeprom *eeprom, uint8_t *bytes)
+                 struct ethtool_eeprom *eeprom, u8 *bytes)
 {
        struct ixgb_adapter *adapter = netdev_priv(netdev);
        struct ixgb_hw *hw = &adapter->hw;
@@ -424,7 +415,7 @@ ixgb_get_eeprom(struct net_device *netdev,
        int i, max_len, first_word, last_word;
        int ret_val = 0;
 
-       if(eeprom->len == 0) {
+       if (eeprom->len == 0) {
                ret_val = -EINVAL;
                goto geeprom_error;
        }
@@ -433,12 +424,12 @@ ixgb_get_eeprom(struct net_device *netdev,
 
        max_len = ixgb_get_eeprom_len(netdev);
 
-       if(eeprom->offset > eeprom->offset + eeprom->len) {
+       if (eeprom->offset > eeprom->offset + eeprom->len) {
                ret_val = -EINVAL;
                goto geeprom_error;
        }
 
-       if((eeprom->offset + eeprom->len) > max_len)
+       if ((eeprom->offset + eeprom->len) > max_len)
                eeprom->len = (max_len - eeprom->offset);
 
        first_word = eeprom->offset >> 1;
@@ -446,16 +437,14 @@ ixgb_get_eeprom(struct net_device *netdev,
 
        eeprom_buff = kmalloc(sizeof(__le16) *
                        (last_word - first_word + 1), GFP_KERNEL);
-       if(!eeprom_buff)
+       if (!eeprom_buff)
                return -ENOMEM;
 
        /* note the eeprom was good because the driver loaded */
-       for(i = 0; i <= (last_word - first_word); i++) {
+       for (i = 0; i <= (last_word - first_word); i++)
                eeprom_buff[i] = ixgb_get_eeprom_word(hw, (first_word + i));
-       }
 
-       memcpy(bytes, (uint8_t *)eeprom_buff + (eeprom->offset & 1),
-                       eeprom->len);
+       memcpy(bytes, (u8 *)eeprom_buff + (eeprom->offset & 1), eeprom->len);
        kfree(eeprom_buff);
 
 geeprom_error:
@@ -464,56 +453,56 @@ geeprom_error:
 
 static int
 ixgb_set_eeprom(struct net_device *netdev,
-                 struct ethtool_eeprom *eeprom, uint8_t *bytes)
+                 struct ethtool_eeprom *eeprom, u8 *bytes)
 {
        struct ixgb_adapter *adapter = netdev_priv(netdev);
        struct ixgb_hw *hw = &adapter->hw;
-       uint16_t *eeprom_buff;
+       u16 *eeprom_buff;
        void *ptr;
        int max_len, first_word, last_word;
-       uint16_t i;
+       u16 i;
 
-       if(eeprom->len == 0)
+       if (eeprom->len == 0)
                return -EINVAL;
 
-       if(eeprom->magic != (hw->vendor_id | (hw->device_id << 16)))
+       if (eeprom->magic != (hw->vendor_id | (hw->device_id << 16)))
                return -EFAULT;
 
        max_len = ixgb_get_eeprom_len(netdev);
 
-       if(eeprom->offset > eeprom->offset + eeprom->len)
+       if (eeprom->offset > eeprom->offset + eeprom->len)
                return -EINVAL;
 
-       if((eeprom->offset + eeprom->len) > max_len)
+       if ((eeprom->offset + eeprom->len) > max_len)
                eeprom->len = (max_len - eeprom->offset);
 
        first_word = eeprom->offset >> 1;
        last_word = (eeprom->offset + eeprom->len - 1) >> 1;
        eeprom_buff = kmalloc(max_len, GFP_KERNEL);
-       if(!eeprom_buff)
+       if (!eeprom_buff)
                return -ENOMEM;
 
        ptr = (void *)eeprom_buff;
 
-       if(eeprom->offset & 1) {
+       if (eeprom->offset & 1) {
                /* need read/modify/write of first changed EEPROM word */
                /* only the second byte of the word is being modified */
                eeprom_buff[0] = ixgb_read_eeprom(hw, first_word);
                ptr++;
        }
-       if((eeprom->offset + eeprom->len) & 1) {
+       if ((eeprom->offset + eeprom->len) & 1) {
                /* need read/modify/write of last changed EEPROM word */
                /* only the first byte of the word is being modified */
-               eeprom_buff[last_word - first_word] 
+               eeprom_buff[last_word - first_word]
                        = ixgb_read_eeprom(hw, last_word);
        }
 
        memcpy(ptr, bytes, eeprom->len);
-       for(i = 0; i <= (last_word - first_word); i++)
+       for (i = 0; i <= (last_word - first_word); i++)
                ixgb_write_eeprom(hw, first_word + i, eeprom_buff[i]);
 
        /* Update the checksum over the first part of the EEPROM if needed */
-       if(first_word <= EEPROM_CHECKSUM_REG)
+       if (first_word <= EEPROM_CHECKSUM_REG)
                ixgb_update_eeprom_checksum(hw);
 
        kfree(eeprom_buff);
@@ -543,7 +532,7 @@ ixgb_get_ringparam(struct net_device *netdev,
        struct ixgb_desc_ring *txdr = &adapter->tx_ring;
        struct ixgb_desc_ring *rxdr = &adapter->rx_ring;
 
-       ring->rx_max_pending = MAX_RXD; 
+       ring->rx_max_pending = MAX_RXD;
        ring->tx_max_pending = MAX_TXD;
        ring->rx_mini_max_pending = 0;
        ring->rx_jumbo_max_pending = 0;
@@ -553,7 +542,7 @@ ixgb_get_ringparam(struct net_device *netdev,
        ring->rx_jumbo_pending = 0;
 }
 
-static int 
+static int
 ixgb_set_ringparam(struct net_device *netdev,
                struct ethtool_ringparam *ring)
 {
@@ -566,25 +555,25 @@ ixgb_set_ringparam(struct net_device *netdev,
        tx_old = adapter->tx_ring;
        rx_old = adapter->rx_ring;
 
-       if((ring->rx_mini_pending) || (ring->rx_jumbo_pending)) 
+       if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending))
                return -EINVAL;
 
-       if(netif_running(adapter->netdev))
-               ixgb_down(adapter,TRUE);
+       if (netif_running(adapter->netdev))
+               ixgb_down(adapter, true);
 
-       rxdr->count = max(ring->rx_pending,(uint32_t)MIN_RXD);
-       rxdr->count = min(rxdr->count,(uint32_t)MAX_RXD);
+       rxdr->count = max(ring->rx_pending,(u32)MIN_RXD);
+       rxdr->count = min(rxdr->count,(u32)MAX_RXD);
        rxdr->count = ALIGN(rxdr->count, IXGB_REQ_RX_DESCRIPTOR_MULTIPLE);
 
-       txdr->count = max(ring->tx_pending,(uint32_t)MIN_TXD);
-       txdr->count = min(txdr->count,(uint32_t)MAX_TXD);
+       txdr->count = max(ring->tx_pending,(u32)MIN_TXD);
+       txdr->count = min(txdr->count,(u32)MAX_TXD);
        txdr->count = ALIGN(txdr->count, IXGB_REQ_TX_DESCRIPTOR_MULTIPLE);
 
-       if(netif_running(adapter->netdev)) {
+       if (netif_running(adapter->netdev)) {
                /* Try to get new resources before deleting old */
-               if((err = ixgb_setup_rx_resources(adapter)))
+               if ((err = ixgb_setup_rx_resources(adapter)))
                        goto err_setup_rx;
-               if((err = ixgb_setup_tx_resources(adapter)))
+               if ((err = ixgb_setup_tx_resources(adapter)))
                        goto err_setup_tx;
 
                /* save the new, restore the old in order to free it,
@@ -598,7 +587,7 @@ ixgb_set_ringparam(struct net_device *netdev,
                ixgb_free_tx_resources(adapter);
                adapter->rx_ring = rx_new;
                adapter->tx_ring = tx_new;
-               if((err = ixgb_up(adapter)))
+               if ((err = ixgb_up(adapter)))
                        return err;
                ixgb_set_speed_duplex(netdev);
        }
@@ -624,7 +613,7 @@ ixgb_led_blink_callback(unsigned long data)
 {
        struct ixgb_adapter *adapter = (struct ixgb_adapter *)data;
 
-       if(test_and_change_bit(IXGB_LED_ON, &adapter->led_status))
+       if (test_and_change_bit(IXGB_LED_ON, &adapter->led_status))
                ixgb_led_off(&adapter->hw);
        else
                ixgb_led_on(&adapter->hw);
@@ -633,14 +622,14 @@ ixgb_led_blink_callback(unsigned long data)
 }
 
 static int
-ixgb_phys_id(struct net_device *netdev, uint32_t data)
+ixgb_phys_id(struct net_device *netdev, u32 data)
 {
        struct ixgb_adapter *adapter = netdev_priv(netdev);
 
        if (!data)
                data = INT_MAX;
 
-       if(!adapter->blink_timer.function) {
+       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;
@@ -656,7 +645,7 @@ ixgb_phys_id(struct net_device *netdev, uint32_t data)
        return 0;
 }
 
-static int 
+static int
 ixgb_get_sset_count(struct net_device *netdev, int sset)
 {
        switch (sset) {
@@ -667,30 +656,30 @@ ixgb_get_sset_count(struct net_device *netdev, int sset)
        }
 }
 
-static void 
-ixgb_get_ethtool_stats(struct net_device *netdev, 
-               struct ethtool_stats *stats, uint64_t *data)
+static void
+ixgb_get_ethtool_stats(struct net_device *netdev,
+               struct ethtool_stats *stats, u64 *data)
 {
        struct ixgb_adapter *adapter = netdev_priv(netdev);
        int i;
 
        ixgb_update_stats(adapter);
-       for(i = 0; i < IXGB_STATS_LEN; i++) {
-               char *p = (char *)adapter+ixgb_gstrings_stats[i].stat_offset;   
-               data[i] = (ixgb_gstrings_stats[i].sizeof_stat == 
-                       sizeof(uint64_t)) ? *(uint64_t *)p : *(uint32_t *)p;
+       for (i = 0; i < IXGB_STATS_LEN; i++) {
+               char *p = (char *)adapter+ixgb_gstrings_stats[i].stat_offset;
+               data[i] = (ixgb_gstrings_stats[i].sizeof_stat ==
+                       sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
        }
 }
 
-static void 
-ixgb_get_strings(struct net_device *netdev, uint32_t stringset, uint8_t *data)
+static void
+ixgb_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
 {
        int i;
 
        switch(stringset) {
        case ETH_SS_STATS:
-               for(i=0; i < IXGB_STATS_LEN; i++) {
-                       memcpy(data + i * ETH_GSTRING_LEN, 
+               for (i = 0; i < IXGB_STATS_LEN; i++) {
+                       memcpy(data + i * ETH_GSTRING_LEN,
                        ixgb_gstrings_stats[i].stat_string,
                        ETH_GSTRING_LEN);
                }