diff options
author | Daniele Venzano <webvenza@libero.it> | 2005-05-12 20:13:14 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@pobox.com> | 2005-05-12 20:13:14 -0400 |
commit | da369b01d49b34803265096eb92a2d6da61cf0d0 (patch) | |
tree | 6967b8292fa142e8e83f9bbaa788dacbfcfd3a8d /drivers | |
parent | 88d7bd8cb9eb8d64bf7997600b0d64f7834047c5 (diff) |
[PATCH] More ethtool support for sis900 and warning fix
Add support to sis900 for the following ethtool ops:
- get_link
- get_settings
- set_settings
- nway_reset
Signed-off-by: Daniele Venzano <webvenza@libero.it>
Signed-off-by: Jeff Garzik <jgarzik@pobox.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/sis900.c | 52 |
1 files changed, 49 insertions, 3 deletions
diff --git a/drivers/net/sis900.c b/drivers/net/sis900.c index 3e9d9aab0588..3107aed0fb51 100644 --- a/drivers/net/sis900.c +++ b/drivers/net/sis900.c | |||
@@ -162,6 +162,7 @@ struct sis900_private { | |||
162 | struct mii_phy * mii; | 162 | struct mii_phy * mii; |
163 | struct mii_phy * first_mii; /* record the first mii structure */ | 163 | struct mii_phy * first_mii; /* record the first mii structure */ |
164 | unsigned int cur_phy; | 164 | unsigned int cur_phy; |
165 | struct mii_if_info mii_info; | ||
165 | 166 | ||
166 | struct timer_list timer; /* Link status detection timer. */ | 167 | struct timer_list timer; /* Link status detection timer. */ |
167 | u8 autong_complete; /* 1: auto-negotiate complete */ | 168 | u8 autong_complete; /* 1: auto-negotiate complete */ |
@@ -203,7 +204,7 @@ static int sis900_open(struct net_device *net_dev); | |||
203 | static int sis900_mii_probe (struct net_device * net_dev); | 204 | static int sis900_mii_probe (struct net_device * net_dev); |
204 | static void sis900_init_rxfilter (struct net_device * net_dev); | 205 | static void sis900_init_rxfilter (struct net_device * net_dev); |
205 | static u16 read_eeprom(long ioaddr, int location); | 206 | static u16 read_eeprom(long ioaddr, int location); |
206 | static u16 mdio_read(struct net_device *net_dev, int phy_id, int location); | 207 | static int mdio_read(struct net_device *net_dev, int phy_id, int location); |
207 | static void mdio_write(struct net_device *net_dev, int phy_id, int location, int val); | 208 | static void mdio_write(struct net_device *net_dev, int phy_id, int location, int val); |
208 | static void sis900_timer(unsigned long data); | 209 | static void sis900_timer(unsigned long data); |
209 | static void sis900_check_mode (struct net_device *net_dev, struct mii_phy *mii_phy); | 210 | static void sis900_check_mode (struct net_device *net_dev, struct mii_phy *mii_phy); |
@@ -478,7 +479,13 @@ static int __devinit sis900_probe(struct pci_dev *pci_dev, | |||
478 | sis_priv->msg_enable = sis900_debug; | 479 | sis_priv->msg_enable = sis900_debug; |
479 | else | 480 | else |
480 | sis_priv->msg_enable = SIS900_DEF_MSG; | 481 | sis_priv->msg_enable = SIS900_DEF_MSG; |
481 | 482 | ||
483 | sis_priv->mii_info.dev = net_dev; | ||
484 | sis_priv->mii_info.mdio_read = mdio_read; | ||
485 | sis_priv->mii_info.mdio_write = mdio_write; | ||
486 | sis_priv->mii_info.phy_id_mask = 0x1f; | ||
487 | sis_priv->mii_info.reg_num_mask = 0x1f; | ||
488 | |||
482 | /* Get Mac address according to the chip revision */ | 489 | /* Get Mac address according to the chip revision */ |
483 | pci_read_config_byte(pci_dev, PCI_CLASS_REVISION, &(sis_priv->chipset_rev)); | 490 | pci_read_config_byte(pci_dev, PCI_CLASS_REVISION, &(sis_priv->chipset_rev)); |
484 | if(netif_msg_probe(sis_priv)) | 491 | if(netif_msg_probe(sis_priv)) |
@@ -725,6 +732,8 @@ static u16 sis900_default_phy(struct net_device * net_dev) | |||
725 | pci_name(sis_priv->pci_dev), sis_priv->cur_phy); | 732 | pci_name(sis_priv->pci_dev), sis_priv->cur_phy); |
726 | } | 733 | } |
727 | 734 | ||
735 | sis_priv->mii_info.phy_id = sis_priv->cur_phy; | ||
736 | |||
728 | status = mdio_read(net_dev, sis_priv->cur_phy, MII_CONTROL); | 737 | status = mdio_read(net_dev, sis_priv->cur_phy, MII_CONTROL); |
729 | status &= (~MII_CNTL_ISOLATE); | 738 | status &= (~MII_CNTL_ISOLATE); |
730 | 739 | ||
@@ -852,7 +861,7 @@ static void mdio_reset(long mdio_addr) | |||
852 | * Please see SiS7014 or ICS spec | 861 | * Please see SiS7014 or ICS spec |
853 | */ | 862 | */ |
854 | 863 | ||
855 | static u16 mdio_read(struct net_device *net_dev, int phy_id, int location) | 864 | static int mdio_read(struct net_device *net_dev, int phy_id, int location) |
856 | { | 865 | { |
857 | long mdio_addr = net_dev->base_addr + mear; | 866 | long mdio_addr = net_dev->base_addr + mear; |
858 | int mii_cmd = MIIread|(phy_id<<MIIpmdShift)|(location<<MIIregShift); | 867 | int mii_cmd = MIIread|(phy_id<<MIIpmdShift)|(location<<MIIregShift); |
@@ -1966,10 +1975,47 @@ static void sis900_set_msglevel(struct net_device *net_dev, u32 value) | |||
1966 | sis_priv->msg_enable = value; | 1975 | sis_priv->msg_enable = value; |
1967 | } | 1976 | } |
1968 | 1977 | ||
1978 | static u32 sis900_get_link(struct net_device *net_dev) | ||
1979 | { | ||
1980 | struct sis900_private *sis_priv = net_dev->priv; | ||
1981 | return mii_link_ok(&sis_priv->mii_info); | ||
1982 | } | ||
1983 | |||
1984 | static int sis900_get_settings(struct net_device *net_dev, | ||
1985 | struct ethtool_cmd *cmd) | ||
1986 | { | ||
1987 | struct sis900_private *sis_priv = net_dev->priv; | ||
1988 | spin_lock_irq(&sis_priv->lock); | ||
1989 | mii_ethtool_gset(&sis_priv->mii_info, cmd); | ||
1990 | spin_unlock_irq(&sis_priv->lock); | ||
1991 | return 0; | ||
1992 | } | ||
1993 | |||
1994 | static int sis900_set_settings(struct net_device *net_dev, | ||
1995 | struct ethtool_cmd *cmd) | ||
1996 | { | ||
1997 | struct sis900_private *sis_priv = net_dev->priv; | ||
1998 | int rt; | ||
1999 | spin_lock_irq(&sis_priv->lock); | ||
2000 | rt = mii_ethtool_sset(&sis_priv->mii_info, cmd); | ||
2001 | spin_unlock_irq(&sis_priv->lock); | ||
2002 | return rt; | ||
2003 | } | ||
2004 | |||
2005 | static int sis900_nway_reset(struct net_device *net_dev) | ||
2006 | { | ||
2007 | struct sis900_private *sis_priv = net_dev->priv; | ||
2008 | return mii_nway_restart(&sis_priv->mii_info); | ||
2009 | } | ||
2010 | |||
1969 | static struct ethtool_ops sis900_ethtool_ops = { | 2011 | static struct ethtool_ops sis900_ethtool_ops = { |
1970 | .get_drvinfo = sis900_get_drvinfo, | 2012 | .get_drvinfo = sis900_get_drvinfo, |
1971 | .get_msglevel = sis900_get_msglevel, | 2013 | .get_msglevel = sis900_get_msglevel, |
1972 | .set_msglevel = sis900_set_msglevel, | 2014 | .set_msglevel = sis900_set_msglevel, |
2015 | .get_link = sis900_get_link, | ||
2016 | .get_settings = sis900_get_settings, | ||
2017 | .set_settings = sis900_set_settings, | ||
2018 | .nway_reset = sis900_nway_reset, | ||
1973 | }; | 2019 | }; |
1974 | 2020 | ||
1975 | /** | 2021 | /** |