]> nv-tegra.nvidia Code Review - linux-2.6.git/blobdiff - drivers/net/stmmac/stmmac_ethtool.c
stmmac: do vlan cleanup
[linux-2.6.git] / drivers / net / stmmac / stmmac_ethtool.c
index b32c16ae55c6717b915e4ca73795c914d889655f..7ed8fb6c2117250e7c55ceb6eef9a009e3223dae 100644 (file)
 
 #include <linux/etherdevice.h>
 #include <linux/ethtool.h>
+#include <linux/interrupt.h>
 #include <linux/mii.h>
 #include <linux/phy.h>
+#include <asm/io.h>
 
 #include "stmmac.h"
 #include "dwmac_dma.h"
@@ -89,12 +91,12 @@ static const struct  stmmac_stats stmmac_gstrings_stats[] = {
 };
 #define STMMAC_STATS_LEN ARRAY_SIZE(stmmac_gstrings_stats)
 
-void stmmac_ethtool_getdrvinfo(struct net_device *dev,
-                              struct ethtool_drvinfo *info)
+static void stmmac_ethtool_getdrvinfo(struct net_device *dev,
+                                     struct ethtool_drvinfo *info)
 {
        struct stmmac_priv *priv = netdev_priv(dev);
 
-       if (!priv->is_gmac)
+       if (!priv->plat->has_gmac)
                strcpy(info->driver, MAC100_ETHTOOL_NAME);
        else
                strcpy(info->driver, GMAC_ETHTOOL_NAME);
@@ -104,7 +106,8 @@ void stmmac_ethtool_getdrvinfo(struct net_device *dev,
        info->n_stats = STMMAC_STATS_LEN;
 }
 
-int stmmac_ethtool_getsettings(struct net_device *dev, struct ethtool_cmd *cmd)
+static int stmmac_ethtool_getsettings(struct net_device *dev,
+                                     struct ethtool_cmd *cmd)
 {
        struct stmmac_priv *priv = netdev_priv(dev);
        struct phy_device *phy = priv->phydev;
@@ -126,7 +129,8 @@ int stmmac_ethtool_getsettings(struct net_device *dev, struct ethtool_cmd *cmd)
        return rc;
 }
 
-int stmmac_ethtool_setsettings(struct net_device *dev, struct ethtool_cmd *cmd)
+static int stmmac_ethtool_setsettings(struct net_device *dev,
+                                     struct ethtool_cmd *cmd)
 {
        struct stmmac_priv *priv = netdev_priv(dev);
        struct phy_device *phy = priv->phydev;
@@ -139,32 +143,32 @@ int stmmac_ethtool_setsettings(struct net_device *dev, struct ethtool_cmd *cmd)
        return rc;
 }
 
-u32 stmmac_ethtool_getmsglevel(struct net_device *dev)
+static u32 stmmac_ethtool_getmsglevel(struct net_device *dev)
 {
        struct stmmac_priv *priv = netdev_priv(dev);
        return priv->msg_enable;
 }
 
-void stmmac_ethtool_setmsglevel(struct net_device *dev, u32 level)
+static void stmmac_ethtool_setmsglevel(struct net_device *dev, u32 level)
 {
        struct stmmac_priv *priv = netdev_priv(dev);
        priv->msg_enable = level;
 
 }
 
-int stmmac_check_if_running(struct net_device *dev)
+static int stmmac_check_if_running(struct net_device *dev)
 {
        if (!netif_running(dev))
                return -EBUSY;
        return 0;
 }
 
-int stmmac_ethtool_get_regs_len(struct net_device *dev)
+static int stmmac_ethtool_get_regs_len(struct net_device *dev)
 {
        return REG_SPACE_SIZE;
 }
 
-void stmmac_ethtool_gregs(struct net_device *dev,
+static void stmmac_ethtool_gregs(struct net_device *dev,
                          struct ethtool_regs *regs, void *space)
 {
        int i;
@@ -174,7 +178,7 @@ void stmmac_ethtool_gregs(struct net_device *dev,
 
        memset(reg_space, 0x0, REG_SPACE_SIZE);
 
-       if (!priv->is_gmac) {
+       if (!priv->plat->has_gmac) {
                /* MAC registers */
                for (i = 0; i < 12; i++)
                        reg_space[i] = readl(priv->ioaddr + (i * 4));
@@ -195,23 +199,6 @@ void stmmac_ethtool_gregs(struct net_device *dev,
        }
 }
 
-int stmmac_ethtool_set_tx_csum(struct net_device *netdev, u32 data)
-{
-       if (data)
-               netdev->features |= NETIF_F_HW_CSUM;
-       else
-               netdev->features &= ~NETIF_F_HW_CSUM;
-
-       return 0;
-}
-
-u32 stmmac_ethtool_get_rx_csum(struct net_device *dev)
-{
-       struct stmmac_priv *priv = netdev_priv(dev);
-
-       return priv->rx_coe;
-}
-
 static void
 stmmac_get_pauseparam(struct net_device *netdev,
                      struct ethtool_pauseparam *pause)
@@ -249,20 +236,11 @@ stmmac_set_pauseparam(struct net_device *netdev,
                new_pause |= FLOW_TX;
 
        priv->flow_ctrl = new_pause;
+       phy->autoneg = pause->autoneg;
 
        if (phy->autoneg) {
-               if (netif_running(netdev)) {
-                       struct ethtool_cmd cmd;
-                       /* auto-negotiation automatically restarted */
-                       cmd.cmd = ETHTOOL_NWAY_RST;
-                       cmd.supported = phy->supported;
-                       cmd.advertising = phy->advertising;
-                       cmd.autoneg = phy->autoneg;
-                       cmd.speed = phy->speed;
-                       cmd.duplex = phy->duplex;
-                       cmd.phy_address = phy->addr;
-                       ret = phy_ethtool_sset(phy, &cmd);
-               }
+               if (netif_running(netdev))
+                       ret = phy_start_aneg(phy);
        } else
                priv->hw->mac->flow_ctrl(priv->ioaddr, phy->duplex,
                                         priv->flow_ctrl, priv->pause);
@@ -322,8 +300,8 @@ static void stmmac_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
        struct stmmac_priv *priv = netdev_priv(dev);
 
        spin_lock_irq(&priv->lock);
-       if (priv->wolenabled == PMT_SUPPORTED) {
-               wol->supported = WAKE_MAGIC;
+       if (device_can_wakeup(priv->device)) {
+               wol->supported = WAKE_MAGIC | WAKE_UCAST;
                wol->wolopts = priv->wolopts;
        }
        spin_unlock_irq(&priv->lock);
@@ -332,18 +310,22 @@ static void stmmac_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
 static int stmmac_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
 {
        struct stmmac_priv *priv = netdev_priv(dev);
-       u32 support = WAKE_MAGIC;
+       u32 support = WAKE_MAGIC | WAKE_UCAST;
 
-       if (priv->wolenabled == PMT_NOT_SUPPORTED)
+       if (!device_can_wakeup(priv->device))
                return -EINVAL;
 
        if (wol->wolopts & ~support)
                return -EINVAL;
 
-       if (wol->wolopts == 0)
-               device_set_wakeup_enable(priv->device, 0);
-       else
+       if (wol->wolopts) {
+               pr_info("stmmac: wakeup enable\n");
                device_set_wakeup_enable(priv->device, 1);
+               enable_irq_wake(dev->irq);
+       } else {
+               device_set_wakeup_enable(priv->device, 0);
+               disable_irq_wake(dev->irq);
+       }
 
        spin_lock_irq(&priv->lock);
        priv->wolopts = wol->wolopts;
@@ -362,11 +344,6 @@ static struct ethtool_ops stmmac_ethtool_ops = {
        .get_regs = stmmac_ethtool_gregs,
        .get_regs_len = stmmac_ethtool_get_regs_len,
        .get_link = ethtool_op_get_link,
-       .get_rx_csum = stmmac_ethtool_get_rx_csum,
-       .get_tx_csum = ethtool_op_get_tx_csum,
-       .set_tx_csum = stmmac_ethtool_set_tx_csum,
-       .get_sg = ethtool_op_get_sg,
-       .set_sg = ethtool_op_set_sg,
        .get_pauseparam = stmmac_get_pauseparam,
        .set_pauseparam = stmmac_set_pauseparam,
        .get_ethtool_stats = stmmac_get_ethtool_stats,
@@ -374,10 +351,6 @@ static struct ethtool_ops stmmac_ethtool_ops = {
        .get_wol = stmmac_get_wol,
        .set_wol = stmmac_set_wol,
        .get_sset_count = stmmac_get_sset_count,
-#ifdef NETIF_F_TSO
-       .get_tso = ethtool_op_get_tso,
-       .set_tso = ethtool_op_set_tso,
-#endif
 };
 
 void stmmac_set_ethtool_ops(struct net_device *netdev)