Date: Sat, 1 Apr 2000 02:03:42 -0500 (EST)
   From: Donald Becker <[EMAIL PROTECTED]>

   > The model suggested by the ethtool interface is generic enough
   > that it can be made to fit those non-ethernet-MII-like models
   > just fine.  It is based upon link speeds, duplex settings,
   > etc. and the driver can map this to whatever the hardware is
   > really like, be it MII or some odd-ball fddi/atm/whatever
   > transceiver.

   How do you specify "advertise 10baseT (half and full duplex), and
   100baseTx (half duplex)".

It currently allows you to force a specific setting (I originally
created the tool so that users could easily work around switches with
broken 100baseT advertisement), not specify an advertisement matrix.

Adding that capability is simple, just add a "advertise" u32 to the
ethtool_cmd structure, define a set of ADVERTISE_* bits (they can be
the same bits as the SUPPORTED_* ones) and then one can just say:

int don_beckers_example(int ethfd)
{
        struct ethtool_cmd cmd;
        int err;

        memset(&cmd, 0, sizeof(cmd));

        /* Figure out what the card actually supports. */
        cmd.cmd = ETHTOOL_ETH_GSET;
        err = ioctl(ethfd, SIOCETHTOOL, &cmd);
        if (err)
                return err;

        /* Don would like 10half/10full/100half to be advertised,
         * so do each one the card says it is capable of.
         */
        cmd.cmd = ETHTOOL_ETH_SSET;
        cmd.autoneg = 1;
        cmd.advertise = 0;
        if (cmd.supported & SUPPORTED_10baseT_Half)
                cmd.advertise = ADVERTISE_10baseT_Half;
        if (cmd.supported & SUPPORTED_10baseT_Full)
                cmd.advertise = ADVERTISE_10baseT_Full;
        if (cmd.supported & SUPPORTED_100baseT_Half)
                cmd.advertise = ADVERTISE_100baseT_Half;
        err = ioctl(ethfd, SIOCETHTOOL, &cmd);

        return err;
}

There, works.

Compare this with "MII write this funny value", "MII read this other
funny value", "if funny bit constant foo is set, then MII write this
other funny value".  Yes, those values are specified in a standard,
and can be macro'ized cleanly, but the above is much cleaner and
doesn't make it an "MII/ethernet/whatever specific" solution by
design, which is important.

Later,
David S. Miller
[EMAIL PROTECTED]
-
To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to [EMAIL PROTECTED]

Reply via email to