Bug 491358 - mii-tool is broken
Summary: mii-tool is broken
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: net-tools
Version: 10
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: Jiri Popelka
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2009-03-20 15:44 UTC by Bill Nottingham
Modified: 2009-12-02 03:56 UTC (History)
3 users (show)

Fixed In Version: 1.60-95.fc11
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2009-11-12 01:00:07 UTC
Type: ---


Attachments (Terms of Use)
mii-tool patch (8.14 KB, patch)
2009-10-30 16:08 UTC, Jiri Popelka
no flags Details | Diff

Description Bill Nottingham 2009-03-20 15:44:24 UTC
Description of problem:

[root@apone ~]# mii-tool eth0
SIOCGMIIREG on eth0 failed: Input/output error
eth0: negotiated 100baseTx-FD, link ok

It reports the 'negotiated 100base...' line no matter whether or not something is connected. This breaks the initscripts link check.

I suppose it could also be a kernel issue. Driver is:
[root@apone ~]# ethtool -i eth0
driver: e1000e
version: 0.3.3.3-k6

Also occurs on rawhide.

Version-Release number of selected component (if applicable):

net-tools-1.60-91.fc10.x86_64
kernel-2.6.28-4.fc10.x86_64

Comment 1 Andy Gospodarek 2009-07-02 18:14:09 UTC
when mii-tool checks link status, this code is called (from mii-tool.c):

    200 int show_basic_mii(int sock, int phy_id)
    201 {
    202     char buf[100];
    203     int i, mii_val[32];
    204     int bmcr, bmsr, advert, lkpar;
    205
    206     /* Some bits in the BMSR are latched, but we can't rely on being
    207        the only reader, so only the current values are meaningful */
    208     mdio_read(sock, MII_BMSR);
    209     for (i = 0; i < ((verbose > 1) ? 32 : 8); i++)
    210         mii_val[i] = mdio_read(sock, i);
    211
    212     if (mii_val[MII_BMCR] == 0xffff) {
    213         fprintf(stderr, "  No MII transceiver present!.\n");
    214         return -1;
    215     }

Since 'verbose' is false, we will call the SIOCGMIIREG ioctl with the commands MII_BMSR and then the commands 0-7 will be called.  Those commands are:


#define MII_BMCR            0x00        /* Basic mode control register */
#define MII_BMSR            0x01        /* Basic mode status register  */
#define MII_PHYSID1         0x02        /* PHYS ID 1                   */
#define MII_PHYSID2         0x03        /* PHYS ID 2                   */
#define MII_ADVERTISE       0x04        /* Advertisement control reg   */
#define MII_LPA             0x05        /* Link partner ability reg    */
#define MII_EXPANSION       0x06        /* Expansion register          */
#define MII_CTRL1000        0x09        /* 1000BASE-T control          */

Where is 0x7????

If we look at the sources for e1000e, we can see why -EIO is returned.  From drivers/net/e1000e/netdev.c (e1000_mii_ioctl) in net-next-2.6 upstream tree:

   4347         case SIOCGMIIREG:
   4348                 if (!capable(CAP_NET_ADMIN))
   4349                         return -EPERM;
   4350                 switch (data->reg_num & 0x1F) {
   4351                 case MII_BMCR:
   4352                         data->val_out = adapter->phy_regs.bmcr;
   4353                         break;
   4354                 case MII_BMSR:
   4355                         data->val_out = adapter->phy_regs.bmsr;
   4356                         break;
   4357                 case MII_PHYSID1:
   4358                         data->val_out = (adapter->hw.phy.id >> 16);
   4359                         break;
   4360                 case MII_PHYSID2:
   4361                         data->val_out = (adapter->hw.phy.id & 0xFFFF);
   4362                         break;
   4363                 case MII_ADVERTISE:
   4364                         data->val_out = adapter->phy_regs.advertise;
   4365                         break;
   4366                 case MII_LPA:
   4367                         data->val_out = adapter->phy_regs.lpa;
   4368                         break;
   4369                 case MII_EXPANSION:
   4370                         data->val_out = adapter->phy_regs.expansion;
   4371                         break;
   4372                 case MII_CTRL1000:
   4373                         data->val_out = adapter->phy_regs.ctrl1000;
   4374                         break;
   4375                 case MII_STAT1000:
   4376                         data->val_out = adapter->phy_regs.stat1000;
   4377                         break;
   4378                 case MII_ESTATUS:
   4379                         data->val_out = adapter->phy_regs.estatus;
   4380                         break;
   4381                 default:
   4382                         return -EIO;
   4383                 }
   4384                 break;

The killer is 0x7 -- it seems it should not be checked by mii-tool.

My guess is that this would fail on multiple devices.  Have you tried it with any other interfaces?

Comment 2 Bill Nottingham 2009-07-02 18:17:42 UTC
The only other wired device I have access to ATM is e100 - it doesn't throw an error.

Comment 3 Andy Gospodarek 2009-07-02 18:34:12 UTC
Interesting.  Is mii-tool always called in initscripts or only when ethtool fails.

Comment 4 Bill Nottingham 2009-07-02 19:01:00 UTC
Always, at least until I build http://git.fedorahosted.org/git/?p=initscripts.git;a=commitdiff;h=a1460db13758eb3d9f3a512a4b20cc4c91eb4d8e for rawhide.

Comment 5 Jiri Popelka 2009-10-30 16:08:55 UTC
Created attachment 366821 [details]
mii-tool patch

mii-tool will be checking only generic MII registers defined in <linux/mii.h>
i.e.
#define MII_BMCR            0x00        /* Basic mode control register */
#define MII_BMSR            0x01        /* Basic mode status register  */
#define MII_PHYSID1         0x02        /* PHYS ID 1                   */
#define MII_PHYSID2         0x03        /* PHYS ID 2                   */
#define MII_ADVERTISE       0x04        /* Advertisement control reg   */
#define MII_LPA             0x05        /* Link partner ability reg    */
#define MII_EXPANSION       0x06        /* Expansion register          */
#define MII_CTRL1000        0x09        /* 1000BASE-T control          */
#define MII_STAT1000        0x0a        /* 1000BASE-T status           */
#define MII_ESTATUS	    0x0f	/* Extended Status */
#define MII_DCOUNTER        0x12        /* Disconnect counter          */
#define MII_FCSCOUNTER      0x13        /* False carrier counter       */
#define MII_NWAYTEST        0x14        /* N-way auto-neg test reg     */
#define MII_RERRCOUNTER     0x15        /* Receive error counter       */
#define MII_SREVISION       0x16        /* Silicon revision            */
#define MII_RESV1           0x17        /* Reserved...                 */
#define MII_LBRERROR        0x18        /* Lpback, rx, bypass error    */
#define MII_PHYADDR         0x19        /* PHY address                 */
#define MII_RESV2           0x1a        /* Reserved...                 */
#define MII_TPISTATUS       0x1b        /* TPI status for 10mbps       */
#define MII_NCONFIG         0x1c        /* Network interface config    */

Comment 6 Fedora Update System 2009-11-06 00:08:27 UTC
net-tools-1.60-95.fc11 has been pushed to the Fedora 11 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update net-tools'.  You can provide feedback for this update here: http://admin.fedoraproject.org/updates/F11/FEDORA-2009-11010

Comment 7 Fedora Update System 2009-11-06 09:55:06 UTC
net-tools-1.60-97.fc12 has been submitted as an update for Fedora 12.
http://admin.fedoraproject.org/updates/net-tools-1.60-97.fc12

Comment 8 Fedora Update System 2009-11-11 14:59:03 UTC
net-tools-1.60-98.fc12 has been pushed to the Fedora 12 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update net-tools'.  You can provide feedback for this update here: http://admin.fedoraproject.org/updates/F12/FEDORA-2009-11140

Comment 9 Fedora Update System 2009-11-12 00:59:56 UTC
net-tools-1.60-95.fc11 has been pushed to the Fedora 11 stable repository.  If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.