--- a/drivers/usb/net/usbnet.c 2003-09-18 23:17:47.034477496 -0400 +++ b/drivers/usb/net/usbnet.c 2003-09-18 23:18:05.760630688 -0400 @@ -301,6 +301,7 @@ /*-------------------------------------------------------------------------*/ static struct ethtool_ops usbnet_ethtool_ops; +static void usbnet_get_drvinfo (struct net_device *, struct ethtool_drvinfo *); /* mostly for PDA style devices, which are always connected if present */ static int always_connected (struct usbnet *dev) @@ -398,6 +399,8 @@ #define AX_CMD_READ_MII_REG 0x07 #define AX_CMD_WRITE_MII_REG 0x08 #define AX_CMD_SET_HW_MII 0x0a +#define AX_CMD_READ_EEPROM 0x0b +#define AX_CMD_WRITE_EEPROM 0x0c #define AX_CMD_WRITE_RX_CTL 0x10 #define AX_CMD_READ_IPG012 0x11 #define AX_CMD_WRITE_IPG0 0x12 @@ -407,8 +410,15 @@ #define AX_CMD_READ_NODE_ID 0x17 #define AX_CMD_READ_PHY_ID 0x19 #define AX_CMD_WRITE_MEDIUM_MODE 0x1b +#define AX_CMD_READ_MONITOR_MODE 0x1c +#define AX_CMD_WRITE_MONITOR_MODE 0x1d #define AX_CMD_WRITE_GPIOS 0x1f +#define AX_MONITOR_MODE 0x01 +#define AX_MONITOR_LINK 0x02 +#define AX_MONITOR_MAGIC 0x04 +#define AX_MONITOR_HSFS 0x10 + #define AX_MCAST_FILTER_SIZE 8 #define AX_MAX_MCAST 64 @@ -537,7 +547,7 @@ { struct usbnet *dev = netdev->priv; u16 res; - u8 buf[4]; + u8 buf[1]; ax8817x_write_cmd(dev, AX_CMD_SET_SW_MII, 0, 0, 0, &buf); ax8817x_read_cmd(dev, AX_CMD_READ_MII_REG, phy_id, (__u16)loc, 2, (u16 *)&res); @@ -550,13 +560,83 @@ { struct usbnet *dev = netdev->priv; u16 res = val; - u8 buf[4]; + u8 buf[1]; ax8817x_write_cmd(dev, AX_CMD_SET_SW_MII, 0, 0, 0, &buf); ax8817x_write_cmd(dev, AX_CMD_WRITE_MII_REG, phy_id, (__u16)loc, 2, (u16 *)&res); ax8817x_write_cmd(dev, AX_CMD_SET_HW_MII, 0, 0, 0, &buf); } +void ax8817x_get_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo) +{ + struct usbnet *dev = (struct usbnet *)net->priv; + u8 opt; + + if (ax8817x_read_cmd(dev, AX_CMD_READ_MONITOR_MODE, 0, 0, 1, &opt) < 0) { + wolinfo->supported = 0; + wolinfo->wolopts = 0; + return; + } + wolinfo->supported = WAKE_PHY | WAKE_MAGIC; + wolinfo->wolopts = 0; + if (opt & AX_MONITOR_MODE) { + if (opt & AX_MONITOR_LINK) + wolinfo->wolopts |= WAKE_PHY; + if (opt & AX_MONITOR_MAGIC) + wolinfo->wolopts |= WAKE_MAGIC; + } +} + +int ax8817x_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo) +{ + struct usbnet *dev = (struct usbnet *)net->priv; + u8 opt = 0; + u8 buf[1]; + + if (wolinfo->wolopts & WAKE_PHY) + opt |= AX_MONITOR_LINK; + if (wolinfo->wolopts & WAKE_MAGIC) + opt |= AX_MONITOR_MAGIC; + if (opt != 0) + opt |= AX_MONITOR_MODE; + + if (ax8817x_write_cmd(dev, AX_CMD_WRITE_MONITOR_MODE, + opt, 0, 0, &buf) < 0) + return -EINVAL; + + return 0; +} + +int ax8817x_get_eeprom(struct net_device *net, + struct ethtool_eeprom *eeprom, u8 *data) +{ + struct usbnet *dev = (struct usbnet *)net->priv; + u16 *ebuf = (u16 *)data; + int i; + + /* Crude hack to ensure that we don't overwrite memory + * if an odd length is supplied + */ + if (eeprom->len % 2) + return -EINVAL; + + /* ax8817x returns 2 bytes from eeprom on read */ + for (i=0; i < eeprom->len / 2; i++) { + if (ax8817x_read_cmd(dev, AX_CMD_READ_EEPROM, + eeprom->offset + i, 0, 2, &ebuf[i]) < 0) + return -EINVAL; + } + return i * 2; +} + +static void ax8817x_get_drvinfo (struct net_device *net, + struct ethtool_drvinfo *info) +{ + /* Inherit standard device info */ + usbnet_get_drvinfo(net, info); + info->eedump_len = 0x3e; +} + static int ax8817x_bind(struct usbnet *dev, struct usb_interface *intf) { int ret; @@ -654,6 +734,11 @@ dev->net->set_multicast_list = ax8817x_set_multicast; + usbnet_ethtool_ops.get_drvinfo = &ax8817x_get_drvinfo; + usbnet_ethtool_ops.get_wol = &ax8817x_get_wol; + usbnet_ethtool_ops.set_wol = &ax8817x_set_wol; + usbnet_ethtool_ops.get_eeprom = &ax8817x_get_eeprom; + return 0; }
------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ [EMAIL PROTECTED] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel