Commit 5cb6eed7 authored by Jeff Garzik's avatar Jeff Garzik

[netdrvr pcmcia] ethtool_ops for 3c574, 3c589, axnet

parent e032fa3f
...@@ -253,6 +253,7 @@ static int el3_rx(struct net_device *dev, int worklimit); ...@@ -253,6 +253,7 @@ static int el3_rx(struct net_device *dev, int worklimit);
static int el3_close(struct net_device *dev); static int el3_close(struct net_device *dev);
static void el3_tx_timeout(struct net_device *dev); static void el3_tx_timeout(struct net_device *dev);
static int el3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); static int el3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
static struct ethtool_ops netdev_ethtool_ops;
static void set_rx_mode(struct net_device *dev); static void set_rx_mode(struct net_device *dev);
static dev_info_t dev_info = "3c574_cs"; static dev_info_t dev_info = "3c574_cs";
...@@ -319,6 +320,7 @@ static dev_link_t *tc574_attach(void) ...@@ -319,6 +320,7 @@ static dev_link_t *tc574_attach(void)
dev->hard_start_xmit = &el3_start_xmit; dev->hard_start_xmit = &el3_start_xmit;
dev->get_stats = &el3_get_stats; dev->get_stats = &el3_get_stats;
dev->do_ioctl = &el3_ioctl; dev->do_ioctl = &el3_ioctl;
SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
dev->set_multicast_list = &set_rx_mode; dev->set_multicast_list = &set_rx_mode;
dev->open = &el3_open; dev->open = &el3_open;
dev->stop = &el3_close; dev->stop = &el3_close;
...@@ -1202,26 +1204,16 @@ static int el3_rx(struct net_device *dev, int worklimit) ...@@ -1202,26 +1204,16 @@ static int el3_rx(struct net_device *dev, int worklimit)
return worklimit; return worklimit;
} }
static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr) static void netdev_get_drvinfo(struct net_device *dev,
struct ethtool_drvinfo *info)
{ {
u32 ethcmd; strcpy(info->driver, "3c574_cs");
if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
return -EFAULT;
switch (ethcmd) {
case ETHTOOL_GDRVINFO: {
struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
strncpy(info.driver, "3c574_cs", sizeof(info.driver)-1);
if (copy_to_user(useraddr, &info, sizeof(info)))
return -EFAULT;
return 0;
}
}
return -EOPNOTSUPP;
} }
static struct ethtool_ops netdev_ethtool_ops = {
.get_drvinfo = netdev_get_drvinfo,
};
/* Provide ioctl() calls to examine the MII xcvr state. */ /* Provide ioctl() calls to examine the MII xcvr state. */
static int el3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) static int el3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
{ {
...@@ -1235,8 +1227,6 @@ static int el3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) ...@@ -1235,8 +1227,6 @@ static int el3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
data[0], data[1], data[2], data[3]); data[0], data[1], data[2], data[3]);
switch(cmd) { switch(cmd) {
case SIOCETHTOOL:
return netdev_ethtool_ioctl(dev, (void *)rq->ifr_data);
case SIOCDEVPRIVATE: /* Get the address of the PHY in use. */ case SIOCDEVPRIVATE: /* Get the address of the PHY in use. */
data[0] = phy; data[0] = phy;
case SIOCDEVPRIVATE+1: /* Read the specified MII register. */ case SIOCDEVPRIVATE+1: /* Read the specified MII register. */
......
...@@ -165,7 +165,7 @@ static int el3_rx(struct net_device *dev); ...@@ -165,7 +165,7 @@ static int el3_rx(struct net_device *dev);
static int el3_close(struct net_device *dev); static int el3_close(struct net_device *dev);
static void el3_tx_timeout(struct net_device *dev); static void el3_tx_timeout(struct net_device *dev);
static void set_multicast_list(struct net_device *dev); static void set_multicast_list(struct net_device *dev);
static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd); static struct ethtool_ops netdev_ethtool_ops;
static dev_info_t dev_info = "3c589_cs"; static dev_info_t dev_info = "3c589_cs";
...@@ -249,7 +249,7 @@ static dev_link_t *tc589_attach(void) ...@@ -249,7 +249,7 @@ static dev_link_t *tc589_attach(void)
dev->tx_timeout = el3_tx_timeout; dev->tx_timeout = el3_tx_timeout;
dev->watchdog_timeo = TX_TIMEOUT; dev->watchdog_timeo = TX_TIMEOUT;
#endif #endif
dev->do_ioctl = netdev_ioctl; SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
/* Register with Card Services */ /* Register with Card Services */
link->next = dev_list; link->next = dev_list;
...@@ -639,70 +639,33 @@ static void tc589_reset(struct net_device *dev) ...@@ -639,70 +639,33 @@ static void tc589_reset(struct net_device *dev)
| AdapterFailure, ioaddr + EL3_CMD); | AdapterFailure, ioaddr + EL3_CMD);
} }
static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr) static void netdev_get_drvinfo(struct net_device *dev,
struct ethtool_drvinfo *info)
{ {
u32 ethcmd; strcpy(info->driver, DRV_NAME);
strcpy(info->version, DRV_VERSION);
/* dev_ioctl() in ../../net/core/dev.c has already checked sprintf(info->bus_info, "PCMCIA 0x%lx", dev->base_addr);
capable(CAP_NET_ADMIN), so don't bother with that here. */ }
if (get_user(ethcmd, (u32 *)useraddr))
return -EFAULT;
switch (ethcmd) {
case ETHTOOL_GDRVINFO: {
struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
strcpy (info.driver, DRV_NAME);
strcpy (info.version, DRV_VERSION);
sprintf(info.bus_info, "PCMCIA 0x%lx", dev->base_addr);
if (copy_to_user (useraddr, &info, sizeof (info)))
return -EFAULT;
return 0;
}
#ifdef PCMCIA_DEBUG #ifdef PCMCIA_DEBUG
/* get message-level */ static u32 netdev_get_msglevel(struct net_device *dev)
case ETHTOOL_GMSGLVL: { {
struct ethtool_value edata = {ETHTOOL_GMSGLVL}; return pc_debug;
edata.data = pc_debug;
if (copy_to_user(useraddr, &edata, sizeof(edata)))
return -EFAULT;
return 0;
}
/* set message-level */
case ETHTOOL_SMSGLVL: {
struct ethtool_value edata;
if (copy_from_user(&edata, useraddr, sizeof(edata)))
return -EFAULT;
pc_debug = edata.data;
return 0;
}
#endif
default:
break;
}
return -EOPNOTSUPP;
} }
static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd) static void netdev_set_msglevel(struct net_device *dev, u32 level)
{ {
int rc; pc_debug = level;
switch (cmd) {
case SIOCETHTOOL:
rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
break;
default:
rc = -EOPNOTSUPP;
break;
}
return rc;
} }
#endif /* PCMCIA_DEBUG */
static struct ethtool_ops netdev_ethtool_ops = {
.get_drvinfo = netdev_get_drvinfo,
#ifdef PCMCIA_DEBUG
.get_msglevel = netdev_get_msglevel,
.set_msglevel = netdev_set_msglevel,
#endif /* PCMCIA_DEBUG */
};
static int el3_config(struct net_device *dev, struct ifmap *map) static int el3_config(struct net_device *dev, struct ifmap *map)
{ {
......
...@@ -98,6 +98,7 @@ static int axnet_event(event_t event, int priority, ...@@ -98,6 +98,7 @@ static int axnet_event(event_t event, int priority,
static int axnet_open(struct net_device *dev); static int axnet_open(struct net_device *dev);
static int axnet_close(struct net_device *dev); static int axnet_close(struct net_device *dev);
static int axnet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); static int axnet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
static struct ethtool_ops netdev_ethtool_ops;
static irqreturn_t ei_irq_wrapper(int irq, void *dev_id, struct pt_regs *regs); static irqreturn_t ei_irq_wrapper(int irq, void *dev_id, struct pt_regs *regs);
static void ei_watchdog(u_long arg); static void ei_watchdog(u_long arg);
static void axnet_reset_8390(struct net_device *dev); static void axnet_reset_8390(struct net_device *dev);
...@@ -209,6 +210,7 @@ static dev_link_t *axnet_attach(void) ...@@ -209,6 +210,7 @@ static dev_link_t *axnet_attach(void)
dev->open = &axnet_open; dev->open = &axnet_open;
dev->stop = &axnet_close; dev->stop = &axnet_close;
dev->do_ioctl = &axnet_ioctl; dev->do_ioctl = &axnet_ioctl;
SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
/* Register with Card Services */ /* Register with Card Services */
link->next = dev_list; link->next = dev_list;
...@@ -807,26 +809,16 @@ static void ei_watchdog(u_long arg) ...@@ -807,26 +809,16 @@ static void ei_watchdog(u_long arg)
add_timer(&info->watchdog); add_timer(&info->watchdog);
} }
static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr) static void netdev_get_drvinfo(struct net_device *dev,
struct ethtool_drvinfo *info)
{ {
u32 ethcmd; strcpy(info->driver, "axnet_cs");
if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
return -EFAULT;
switch (ethcmd) {
case ETHTOOL_GDRVINFO: {
struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
strncpy(info.driver, "axnet_cs", sizeof(info.driver)-1);
if (copy_to_user(useraddr, &info, sizeof(info)))
return -EFAULT;
return 0;
}
}
return -EOPNOTSUPP;
} }
static struct ethtool_ops netdev_ethtool_ops = {
.get_drvinfo = netdev_get_drvinfo,
};
/*====================================================================*/ /*====================================================================*/
static int axnet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) static int axnet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
...@@ -835,8 +827,6 @@ static int axnet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) ...@@ -835,8 +827,6 @@ static int axnet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
u16 *data = (u16 *)&rq->ifr_data; u16 *data = (u16 *)&rq->ifr_data;
ioaddr_t mii_addr = dev->base_addr + AXNET_MII_EEP; ioaddr_t mii_addr = dev->base_addr + AXNET_MII_EEP;
switch (cmd) { switch (cmd) {
case SIOCETHTOOL:
return netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
case SIOCDEVPRIVATE: case SIOCDEVPRIVATE:
data[0] = info->phy_id; data[0] = info->phy_id;
case SIOCDEVPRIVATE+1: case SIOCDEVPRIVATE+1:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment