- pegasus = net->priv;
- if (get_user(cmd, (int __user *) uaddr))
- return -EFAULT;
- switch (cmd) {
- case ETHTOOL_GDRVINFO:{
- struct ethtool_drvinfo info;
- memset (&info, 0, sizeof (info));
- info.cmd = ETHTOOL_GDRVINFO;
- strncpy(info.driver, driver_name,
- sizeof (info.driver) - 1);
- strncpy(info.version, DRIVER_VERSION,
- sizeof (info.version) - 1);
- usb_make_path(pegasus->usb, info.bus_info,
- sizeof (info.bus_info));
- if (copy_to_user(uaddr, &info, sizeof (info)))
- return -EFAULT;
- return 0;
- }
- case ETHTOOL_GSET:{
- struct ethtool_cmd ecmd;
- short lpa, bmcr;
- u8 port;
-
- memset(&ecmd, 0, sizeof (ecmd));
- ecmd.supported = (SUPPORTED_10baseT_Half |
- SUPPORTED_10baseT_Full |
- SUPPORTED_100baseT_Half |
- SUPPORTED_100baseT_Full |
- SUPPORTED_Autoneg |
- SUPPORTED_TP | SUPPORTED_MII);
- get_registers(pegasus, Reg7b, 1, &port);
- if (port == 0)
- ecmd.port = PORT_MII;
- else
- ecmd.port = PORT_TP;
- ecmd.transceiver = XCVR_INTERNAL;
- ecmd.phy_address = pegasus->phy;
- read_mii_word(pegasus, pegasus->phy, MII_BMCR, &bmcr);
- read_mii_word(pegasus, pegasus->phy, MII_LPA, &lpa);
- if (bmcr & BMCR_ANENABLE) {
- ecmd.autoneg = AUTONEG_ENABLE;
- ecmd.speed = lpa & (LPA_100HALF | LPA_100FULL) ?
- SPEED_100 : SPEED_10;
- if (ecmd.speed == SPEED_100)
- ecmd.duplex = lpa & LPA_100FULL ?
- DUPLEX_FULL : DUPLEX_HALF;
- else
- ecmd.duplex = lpa & LPA_10FULL ?
- DUPLEX_FULL : DUPLEX_HALF;
- } else {
- ecmd.autoneg = AUTONEG_DISABLE;
- ecmd.speed = bmcr & BMCR_SPEED100 ?
- SPEED_100 : SPEED_10;
- ecmd.duplex = bmcr & BMCR_FULLDPLX ?
- DUPLEX_FULL : DUPLEX_HALF;
- }
- if (copy_to_user(uaddr, &ecmd, sizeof (ecmd)))
- return -EFAULT;
-
- return 0;
- }
- case ETHTOOL_SSET:{
- return -EOPNOTSUPP;
- }
- case ETHTOOL_GLINK:{
- struct ethtool_value edata = { ETHTOOL_GLINK };
- edata.data = netif_carrier_ok(net);
- if (copy_to_user(uaddr, &edata, sizeof (edata)))
- return -EFAULT;
- return 0;
- }
- default:
- return -EOPNOTSUPP;
- }