summaryrefslogtreecommitdiffstats
path: root/drivers/net/tsi108_eth.c
diff options
context:
space:
mode:
authorAlex Bounine <alex.bou9@gmail.com>2008-02-11 14:36:37 -0500
committerJeff Garzik <jeff@garzik.org>2008-02-11 14:47:29 -0500
commit9dde447a09ec8fc0ba8375a16fe6bed2470f0d14 (patch)
treebc75ced62ba07340d088bf9a2380db99a3122587 /drivers/net/tsi108_eth.c
parentb1aefe58c21de4265223b563ae923b50f4c4be08 (diff)
downloadop-kernel-dev-9dde447a09ec8fc0ba8375a16fe6bed2470f0d14.zip
op-kernel-dev-9dde447a09ec8fc0ba8375a16fe6bed2470f0d14.tar.gz
Tsi108_eth: Add ethtool support
Add ethtool support to tsi108_eth network driver. Signed-off-by: Alexandre Bounine <alexandreb@tundra.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/tsi108_eth.c')
-rw-r--r--drivers/net/tsi108_eth.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/drivers/net/tsi108_eth.c b/drivers/net/tsi108_eth.c
index bc38489..6f33f84 100644
--- a/drivers/net/tsi108_eth.c
+++ b/drivers/net/tsi108_eth.c
@@ -36,6 +36,7 @@
#include <linux/net.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
+#include <linux/ethtool.h>
#include <linux/skbuff.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
@@ -1519,12 +1520,46 @@ static void tsi108_init_mac(struct net_device *dev)
TSI_WRITE(TSI108_EC_INTMASK, ~0);
}
+static int tsi108_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
+{
+ struct tsi108_prv_data *data = netdev_priv(dev);
+ unsigned long flags;
+ int rc;
+
+ spin_lock_irqsave(&data->txlock, flags);
+ rc = mii_ethtool_gset(&data->mii_if, cmd);
+ spin_unlock_irqrestore(&data->txlock, flags);
+
+ return rc;
+}
+
+static int tsi108_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
+{
+ struct tsi108_prv_data *data = netdev_priv(dev);
+ unsigned long flags;
+ int rc;
+
+ spin_lock_irqsave(&data->txlock, flags);
+ rc = mii_ethtool_sset(&data->mii_if, cmd);
+ spin_unlock_irqrestore(&data->txlock, flags);
+
+ return rc;
+}
+
static int tsi108_do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
{
struct tsi108_prv_data *data = netdev_priv(dev);
+ if (!netif_running(dev))
+ return -EINVAL;
return generic_mii_ioctl(&data->mii_if, if_mii(rq), cmd, NULL);
}
+static const struct ethtool_ops tsi108_ethtool_ops = {
+ .get_link = ethtool_op_get_link,
+ .get_settings = tsi108_get_settings,
+ .set_settings = tsi108_set_settings,
+};
+
static int
tsi108_init_one(struct platform_device *pdev)
{
@@ -1589,6 +1624,7 @@ tsi108_init_one(struct platform_device *pdev)
dev->get_stats = tsi108_get_stats;
netif_napi_add(dev, &data->napi, tsi108_poll, 64);
dev->do_ioctl = tsi108_do_ioctl;
+ dev->ethtool_ops = &tsi108_ethtool_ops;
/* Apparently, the Linux networking code won't use scatter-gather
* if the hardware doesn't do checksums. However, it's faster
OpenPOWER on IntegriCloud