aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/net/usbnet.c
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2006-10-08 18:08:01 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2006-10-17 17:46:32 -0400
commitc41286fd42f3545513f8de9f61028120b6d38e89 (patch)
tree2dddcf5c7423c0db62a1f8752c002cf62080287b /drivers/usb/net/usbnet.c
parent2a36d7083438ccb607055abae633f39495a99947 (diff)
usbnet: improve generic ethtool support
This adds generic support for the ethtool commands get_settings, set_settings, get_link and nway_reset to usbnet. These are now implemented using mii functions when a low-level driver supports mdio_read/mdio_write and does not override the usbnet ethtool commands with its own. Currently, this applies to the asix and the mcs7830 drivers. I have tested it on mcs7830. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Acked-by: David Hollis <dhollis@davehollis.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/net/usbnet.c')
-rw-r--r--drivers/usb/net/usbnet.c52
1 files changed, 51 insertions, 1 deletions
diff --git a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c
index af6d061dc79b..decc1b179246 100644
--- a/drivers/usb/net/usbnet.c
+++ b/drivers/usb/net/usbnet.c
@@ -669,6 +669,37 @@ done:
669 * they'll probably want to use this base set. 669 * they'll probably want to use this base set.
670 */ 670 */
671 671
672int usbnet_get_settings (struct net_device *net, struct ethtool_cmd *cmd)
673{
674 struct usbnet *dev = netdev_priv(net);
675
676 if (!dev->mii.mdio_read)
677 return -EOPNOTSUPP;
678
679 return mii_ethtool_gset(&dev->mii, cmd);
680}
681EXPORT_SYMBOL_GPL(usbnet_get_settings);
682
683int usbnet_set_settings (struct net_device *net, struct ethtool_cmd *cmd)
684{
685 struct usbnet *dev = netdev_priv(net);
686 int retval;
687
688 if (!dev->mii.mdio_write)
689 return -EOPNOTSUPP;
690
691 retval = mii_ethtool_sset(&dev->mii, cmd);
692
693 /* link speed/duplex might have changed */
694 if (dev->driver_info->link_reset)
695 dev->driver_info->link_reset(dev);
696
697 return retval;
698
699}
700EXPORT_SYMBOL_GPL(usbnet_set_settings);
701
702
672void usbnet_get_drvinfo (struct net_device *net, struct ethtool_drvinfo *info) 703void usbnet_get_drvinfo (struct net_device *net, struct ethtool_drvinfo *info)
673{ 704{
674 struct usbnet *dev = netdev_priv(net); 705 struct usbnet *dev = netdev_priv(net);
@@ -682,7 +713,7 @@ void usbnet_get_drvinfo (struct net_device *net, struct ethtool_drvinfo *info)
682} 713}
683EXPORT_SYMBOL_GPL(usbnet_get_drvinfo); 714EXPORT_SYMBOL_GPL(usbnet_get_drvinfo);
684 715
685static u32 usbnet_get_link (struct net_device *net) 716u32 usbnet_get_link (struct net_device *net)
686{ 717{
687 struct usbnet *dev = netdev_priv(net); 718 struct usbnet *dev = netdev_priv(net);
688 719
@@ -690,9 +721,14 @@ static u32 usbnet_get_link (struct net_device *net)
690 if (dev->driver_info->check_connect) 721 if (dev->driver_info->check_connect)
691 return dev->driver_info->check_connect (dev) == 0; 722 return dev->driver_info->check_connect (dev) == 0;
692 723
724 /* if the device has mii operations, use those */
725 if (dev->mii.mdio_read)
726 return mii_link_ok(&dev->mii);
727
693 /* Otherwise, say we're up (to avoid breaking scripts) */ 728 /* Otherwise, say we're up (to avoid breaking scripts) */
694 return 1; 729 return 1;
695} 730}
731EXPORT_SYMBOL_GPL(usbnet_get_link);
696 732
697u32 usbnet_get_msglevel (struct net_device *net) 733u32 usbnet_get_msglevel (struct net_device *net)
698{ 734{
@@ -710,10 +746,24 @@ void usbnet_set_msglevel (struct net_device *net, u32 level)
710} 746}
711EXPORT_SYMBOL_GPL(usbnet_set_msglevel); 747EXPORT_SYMBOL_GPL(usbnet_set_msglevel);
712 748
749int usbnet_nway_reset(struct net_device *net)
750{
751 struct usbnet *dev = netdev_priv(net);
752
753 if (!dev->mii.mdio_write)
754 return -EOPNOTSUPP;
755
756 return mii_nway_restart(&dev->mii);
757}
758EXPORT_SYMBOL_GPL(usbnet_nway_reset);
759
713/* drivers may override default ethtool_ops in their bind() routine */ 760/* drivers may override default ethtool_ops in their bind() routine */
714static struct ethtool_ops usbnet_ethtool_ops = { 761static struct ethtool_ops usbnet_ethtool_ops = {
762 .get_settings = usbnet_get_settings,
763 .set_settings = usbnet_set_settings,
715 .get_drvinfo = usbnet_get_drvinfo, 764 .get_drvinfo = usbnet_get_drvinfo,
716 .get_link = usbnet_get_link, 765 .get_link = usbnet_get_link,
766 .nway_reset = usbnet_nway_reset,
717 .get_msglevel = usbnet_get_msglevel, 767 .get_msglevel = usbnet_get_msglevel,
718 .set_msglevel = usbnet_set_msglevel, 768 .set_msglevel = usbnet_set_msglevel,
719}; 769};