2002-12-02 16:04:41

by David Ashley

[permalink] [raw]
Subject: Linux 2.4.18 8139too.c driver fix for mii-tool

mii-tool doesn't work with the 8139too.c driver (RTL8139 based network cards).
Internally the driver uses phy ID #'s 32+, but when ioctls are used to
access the phy registers, the ID is masked down to 0-0x1f, so none of them
work properly, and mii-tool fails.

The fix is to change the masking done in the top of netdev_ioctl:
if (cmd != SIOCETHTOOL) {
/* With SIOCETHTOOL, this would corrupt the pointer. */
data->phy_id &= 0x3f; // was 0x1f (DA) 20021202
data->reg_num &= 0x1f;
}

-Dave


2002-12-02 16:16:27

by Jeff Garzik

[permalink] [raw]
Subject: Re: Linux 2.4.18 8139too.c driver fix for mii-tool

David Ashley wrote:
> mii-tool doesn't work with the 8139too.c driver (RTL8139 based network cards).
> Internally the driver uses phy ID #'s 32+, but when ioctls are used to
> access the phy registers, the ID is masked down to 0-0x1f, so none of them
> work properly, and mii-tool fails.
>
> The fix is to change the masking done in the top of netdev_ioctl:
> if (cmd != SIOCETHTOOL) {
> /* With SIOCETHTOOL, this would corrupt the pointer. */
> data->phy_id &= 0x3f; // was 0x1f (DA) 20021202
> data->reg_num &= 0x1f;
> }


Already fixed in the latest stable kernel, 2.4.20.

But thanks for testing though!

2002-12-02 16:18:19

by Felipe W Damasio

[permalink] [raw]
Subject: Re:Linux 2.4.18 8139too.c driver fix for mii-tool

---------- Cabe?alho inicial -----------

De: [email protected]
Para: [email protected]
C?pia:
Data: Mon, 02 Dec 2002 08:11:52 -0800
Assunto: Linux 2.4.18 8139too.c driver fix for mii-tool

> The fix is to change the masking done in the top of netdev_ioctl:
> if (cmd != SIOCETHTOOL) {
> /* With SIOCETHTOOL, this would corrupt the pointer. */
> data->phy_id &= 0x3f; // was 0x1f (DA) 20021202
> data->reg_num &= 0x1f;
> }

In 2.4.20, the non-ethtool ioctls on 8139too (and 8139cp, for that
matter) are handled by mii.c::generic_mii_ioctl, which already have
this fix (in a more generic way):

mii_data->phy_id &= mii_if->phy_id_mask;
mii_data->reg_num &= mii_if->reg_num_mask;

You can check

http://www.kernel.org/diff/diffview.cgi?css=%2Fdiff%2Fdiff.css;file=%2Fpub%2Flinux%2Fkernel%2Fv2.4%2Fpatch-2.4.20.gz;z=1765

For more details.

Kind Regards,

Felipe