-
- case ETHTOOL_GSET: {
- struct ethtool_cmd cmd = { ETHTOOL_GSET };
- if (np->phy_media) {
- /* fiber device */
- cmd.supported = SUPPORTED_Autoneg |
- SUPPORTED_FIBRE;
- cmd.advertising= ADVERTISED_Autoneg |
- ADVERTISED_FIBRE;
- cmd.port = PORT_FIBRE;
- cmd.transceiver = XCVR_INTERNAL;
- } else {
- /* copper device */
- cmd.supported = SUPPORTED_10baseT_Half |
- SUPPORTED_10baseT_Full | SUPPORTED_100baseT_Half
- | SUPPORTED_100baseT_Full | SUPPORTED_1000baseT_Full |
- SUPPORTED_Autoneg | SUPPORTED_MII;
- cmd.advertising = ADVERTISED_10baseT_Half |
- ADVERTISED_10baseT_Full | ADVERTISED_100baseT_Half |
- ADVERTISED_100baseT_Full | ADVERTISED_1000baseT_Full|
- ADVERTISED_Autoneg | ADVERTISED_MII;
- cmd.port = PORT_MII;
- cmd.transceiver = XCVR_INTERNAL;
- }
- if ( np->link_status ) {
- cmd.speed = np->speed;
- cmd.duplex = np->full_duplex ?
- DUPLEX_FULL : DUPLEX_HALF;
- } else {
- cmd.speed = -1;
- cmd.duplex = -1;
- }
- if ( np->an_enable)
- cmd.autoneg = AUTONEG_ENABLE;
- else
- cmd.autoneg = AUTONEG_DISABLE;
-
- cmd.phy_address = np->phy_addr;
-
- if (copy_to_user(useraddr, &cmd,
- sizeof(cmd)))
- return -EFAULT;
- return 0;
- }
- case ETHTOOL_SSET: {
- struct ethtool_cmd cmd;
- if (copy_from_user(&cmd, useraddr, sizeof(cmd)))
- return -EFAULT;
- netif_carrier_off(dev);
- if (cmd.autoneg == AUTONEG_ENABLE) {
- if (np->an_enable)
- return 0;
- else {
- np->an_enable = 1;
- mii_set_media(dev);
- return 0;
- }
- } else {
- np->an_enable = 0;
- if (np->speed == 1000){
- cmd.speed = SPEED_100;
- cmd.duplex = DUPLEX_FULL;
- printk("Warning!! Can't disable Auto negotiation in 1000Mbps, change to Manul 100Mbps, Full duplex.\n");
- }
- switch(cmd.speed + cmd.duplex){
-
- case SPEED_10 + DUPLEX_HALF:
- np->speed = 10;
- np->full_duplex = 0;
- break;
-
- case SPEED_10 + DUPLEX_FULL:
- np->speed = 10;
- np->full_duplex = 1;
- break;
- case SPEED_100 + DUPLEX_HALF:
- np->speed = 100;
- np->full_duplex = 0;
- break;
- case SPEED_100 + DUPLEX_FULL:
- np->speed = 100;
- np->full_duplex = 1;
- break;
- case SPEED_1000 + DUPLEX_HALF:/* not supported */
- case SPEED_1000 + DUPLEX_FULL:/* not supported */
- default:
- return -EINVAL;
- }
- mii_set_media(dev);
- }
- return 0;