Cureington, Tony wrote:
/* Yes, the mii is overlaid on the ifreq.ifr_ifru */
mii = (struct mii_ioctl_data *)&ifr.ifr_data;
if (ioctl(dev, &ifr, SIOCGMIIPHY) != 0) {
return MII_LINK_READY; /* can't tell */
}
mii->reg_num = 1;
if (ioctl(dev, &ifr, SIOCGMIIREG) == 0) {
/*
* mii->val_out contains MII reg 1, BMSR
* 0x0004 means link established
*/
return mii->val_out;
}
Speaking of bonding, I wonder about the above code -- why do you return
mii->val_out directly? AFAICS you should test BMSR_LSTATUS (a.k.a.
0x0004) and return MII_LINK_READY or zero -- not a bunch of random bits.
The status word can certainly be non-zero even when link is absent.
Also, a further question: do you have access to the slave struct
net_device? If so, just test netif_carrier_ok(slave_dev) and avoid all
that ioctl calling if it returns non-zero.
Jeff
|