dl2k: BMSR fixes
[safe/jmp/linux-2.6] / drivers / net / gianfar_ethtool.c
index 765e810..6007147 100644 (file)
  *
  *  Copyright (c) 2003,2004 Freescale Semiconductor, Inc.
  *
- *  This software may be used and distributed according to 
- *  the terms of the GNU Public License, Version 2, incorporated herein 
+ *  This software may be used and distributed according to
+ *  the terms of the GNU Public License, Version 2, incorporated herein
  *  by reference.
  */
 
-#include <linux/config.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/crc32.h>
 #include <asm/types.h>
-#include <asm/uaccess.h>
 #include <linux/ethtool.h>
 #include <linux/mii.h>
 #include <linux/phy.h>
 
 #include "gianfar.h"
 
-#define is_power_of_2(x)        ((x) != 0 && (((x) & ((x) - 1)) == 0))
-
 extern void gfar_start(struct net_device *dev);
 extern int gfar_clean_rx_ring(struct net_device *dev, int rx_work_limit);
 
@@ -144,11 +139,11 @@ static void gfar_fill_stats(struct net_device *dev, struct ethtool_stats *dummy,
        u64 *extra = (u64 *) & priv->extra_stats;
 
        if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_RMON) {
-               u32 *rmon = (u32 *) & priv->regs->rmon;
+               u32 __iomem *rmon = (u32 __iomem *) & priv->regs->rmon;
                struct gfar_stats *stats = (struct gfar_stats *) buf;
 
                for (i = 0; i < GFAR_RMON_LEN; i++)
-                       stats->rmon[i] = (u64) (rmon[i]);
+                       stats->rmon[i] = (u64) gfar_read(&rmon[i]);
 
                for (i = 0; i < GFAR_EXTRA_STATS_LEN; i++)
                        stats->extra[i] = extra[i];
@@ -157,15 +152,19 @@ static void gfar_fill_stats(struct net_device *dev, struct ethtool_stats *dummy,
                        buf[i] = extra[i];
 }
 
-/* Returns the number of stats (and their corresponding strings) */
-static int gfar_stats_count(struct net_device *dev)
+static int gfar_sset_count(struct net_device *dev, int sset)
 {
        struct gfar_private *priv = netdev_priv(dev);
 
-       if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_RMON)
-               return GFAR_STATS_LEN;
-       else
-               return GFAR_EXTRA_STATS_LEN;
+       switch (sset) {
+       case ETH_SS_STATS:
+               if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_RMON)
+                       return GFAR_STATS_LEN;
+               else
+                       return GFAR_EXTRA_STATS_LEN;
+       default:
+               return -EOPNOTSUPP;
+       }
 }
 
 /* Fills in the drvinfo structure with some basic info */
@@ -176,8 +175,6 @@ static void gfar_gdrvinfo(struct net_device *dev, struct
        strncpy(drvinfo->version, gfar_driver_version, GFAR_INFOSTR_LEN);
        strncpy(drvinfo->fw_version, "N/A", GFAR_INFOSTR_LEN);
        strncpy(drvinfo->bus_info, "N/A", GFAR_INFOSTR_LEN);
-       drvinfo->n_stats = GFAR_STATS_LEN;
-       drvinfo->testinfo_len = 0;
        drvinfo->regdump_len = 0;
        drvinfo->eedump_len = 0;
 }
@@ -203,7 +200,7 @@ static int gfar_gsettings(struct net_device *dev, struct ethtool_cmd *cmd)
 
        if (NULL == phydev)
                return -ENODEV;
-       
+
        cmd->maxtxpkt = priv->txcount;
        cmd->maxrxpkt = priv->rxcount;
 
@@ -221,11 +218,11 @@ static void gfar_get_regs(struct net_device *dev, struct ethtool_regs *regs, voi
 {
        int i;
        struct gfar_private *priv = netdev_priv(dev);
-       u32 *theregs = (u32 *) priv->regs;
+       u32 __iomem *theregs = (u32 __iomem *) priv->regs;
        u32 *buf = (u32 *) regbuf;
 
        for (i = 0; i < sizeof (struct gfar) / sizeof (u32); i++)
-               buf[i] = theregs[i];
+               buf[i] = gfar_read(&theregs[i]);
 }
 
 /* Convert microseconds to ethernet clock ticks, which changes
@@ -282,7 +279,7 @@ static unsigned int gfar_ticks2usecs(struct gfar_private *priv, unsigned int tic
 static int gfar_gcoalesce(struct net_device *dev, struct ethtool_coalesce *cvals)
 {
        struct gfar_private *priv = netdev_priv(dev);
-       
+
        if (!(priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_COALESCE))
                return -EOPNOTSUPP;
 
@@ -455,10 +452,14 @@ static int gfar_sringparam(struct net_device *dev, struct ethtool_ringparam *rva
 
                /* Halt TX and RX, and process the frames which
                 * have already been received */
-               spin_lock_irqsave(&priv->lock, flags);
+               spin_lock_irqsave(&priv->txlock, flags);
+               spin_lock(&priv->rxlock);
+
                gfar_halt(dev);
                gfar_clean_rx_ring(dev, priv->rx_ring_size);
-               spin_unlock_irqrestore(&priv->lock, flags);
+
+               spin_unlock(&priv->rxlock);
+               spin_unlock_irqrestore(&priv->txlock, flags);
 
                /* Now we take down the rings to rebuild them */
                stop_gfar(dev);
@@ -488,10 +489,14 @@ static int gfar_set_rx_csum(struct net_device *dev, uint32_t data)
 
                /* Halt TX and RX, and process the frames which
                 * have already been received */
-               spin_lock_irqsave(&priv->lock, flags);
+               spin_lock_irqsave(&priv->txlock, flags);
+               spin_lock(&priv->rxlock);
+
                gfar_halt(dev);
                gfar_clean_rx_ring(dev, priv->rx_ring_size);
-               spin_unlock_irqrestore(&priv->lock, flags);
+
+               spin_unlock(&priv->rxlock);
+               spin_unlock_irqrestore(&priv->txlock, flags);
 
                /* Now we take down the rings to rebuild them */
                stop_gfar(dev);
@@ -523,7 +528,7 @@ static int gfar_set_tx_csum(struct net_device *dev, uint32_t data)
        if (!(priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_CSUM))
                return -EOPNOTSUPP;
 
-       spin_lock_irqsave(&priv->lock, flags);
+       spin_lock_irqsave(&priv->txlock, flags);
        gfar_halt(dev);
 
        if (data)
@@ -532,7 +537,7 @@ static int gfar_set_tx_csum(struct net_device *dev, uint32_t data)
                dev->features &= ~NETIF_F_IP_CSUM;
 
        gfar_start(dev);
-       spin_unlock_irqrestore(&priv->lock, flags);
+       spin_unlock_irqrestore(&priv->txlock, flags);
 
        return 0;
 }
@@ -548,19 +553,19 @@ static uint32_t gfar_get_tx_csum(struct net_device *dev)
 }
 
 static uint32_t gfar_get_msglevel(struct net_device *dev)
-{       
+{
        struct gfar_private *priv = netdev_priv(dev);
        return priv->msg_enable;
-}       
-        
+}
+
 static void gfar_set_msglevel(struct net_device *dev, uint32_t data)
-{       
+{
        struct gfar_private *priv = netdev_priv(dev);
        priv->msg_enable = data;
 }
 
 
-struct ethtool_ops gfar_ethtool_ops = {
+const struct ethtool_ops gfar_ethtool_ops = {
        .get_settings = gfar_gsettings,
        .set_settings = gfar_ssettings,
        .get_drvinfo = gfar_gdrvinfo,
@@ -572,7 +577,7 @@ struct ethtool_ops gfar_ethtool_ops = {
        .get_ringparam = gfar_gringparam,
        .set_ringparam = gfar_sringparam,
        .get_strings = gfar_gstrings,
-       .get_stats_count = gfar_stats_count,
+       .get_sset_count = gfar_sset_count,
        .get_ethtool_stats = gfar_fill_stats,
        .get_rx_csum = gfar_get_rx_csum,
        .get_tx_csum = gfar_get_tx_csum,