Remove, bug #195228
authorRaúl Porcel <armin76@gentoo.org>
Mon, 25 Feb 2008 10:44:35 +0000 (10:44 +0000)
committerRaúl Porcel <armin76@gentoo.org>
Mon, 25 Feb 2008 10:44:35 +0000 (10:44 +0000)
sys-apps/mii-diag/ChangeLog [deleted file]
sys-apps/mii-diag/Manifest [deleted file]
sys-apps/mii-diag/files/libmii.c-2.10 [deleted file]
sys-apps/mii-diag/files/libmii.c-2.11 [deleted file]
sys-apps/mii-diag/files/mii-diag.8-2.11 [deleted file]
sys-apps/mii-diag/files/mii-diag.c-2.09 [deleted file]
sys-apps/mii-diag/files/mii-diag.c-2.09-gcc33.patch [deleted file]
sys-apps/mii-diag/files/mii-diag.c-2.11 [deleted file]
sys-apps/mii-diag/metadata.xml [deleted file]
sys-apps/mii-diag/mii-diag-2.09.ebuild [deleted file]
sys-apps/mii-diag/mii-diag-2.11.ebuild [deleted file]

diff --git a/sys-apps/mii-diag/ChangeLog b/sys-apps/mii-diag/ChangeLog
deleted file mode 100644 (file)
index e5d14d3..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-# ChangeLog for sys-apps/mii-diag
-# Copyright 1999-2007 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/sys-apps/mii-diag/ChangeLog,v 1.13 2007/02/22 01:14:03 jokey Exp $
-
-  22 Feb 2007; Markus Ullmann <jokey@gentoo.org> ChangeLog:
-  Redigest for Manifest2
-
-  29 Nov 2005; Jeroen Roovers <jer@gentoo.org> mii-diag-2.07.ebuild,
-  mii-diag-2.09.ebuild, mii-diag-2.11.ebuild:
-  Marking ~hppa wrt bug 109178.
-
-  05 Oct 2005; Gustavo Zacarias <gustavoz@gentoo.org> mii-diag-2.09.ebuild:
-  Stable on sparc
-
-*mii-diag-2.11 (12 Jun 2005)
-
-  12 Jun 2005; Mike Frysinger <vapier@gentoo.org> +files/libmii.c-2.11,
-  +files/mii-diag.8-2.11, +files/mii-diag.c-2.11, +mii-diag-2.11.ebuild:
-  Version bump.
-
-  26 Apr 2005; Stephanie Lockwood-Childs <wormo@gentoo.org>
-  mii-diag-2.09.ebuild:
-  mark ~ppc
-
-  12 Feb 2005; Robin H. Johnson <robbat2@gentoo.org> mii-diag-2.09.ebuild:
-  Tag as ~mips for my XXS1500.
-
-  24 Dec 2004; Jason Wever <weeve@gentoo.org> mii-diag-2.09.ebuild:
-  Added ~sparc keyword.
-
-  27 Apr 2004; Aron Griffis <agriffis@gentoo.org> mii-diag-2.07.ebuild,
-  mii-diag-2.09.ebuild:
-  Add inherit eutils
-
-*mii-diag-2.09 (19 Sep 2003)
-
-  19 Sep 2003; Aron Griffis <agriffis@gentoo.org> mii-diag-2.07.ebuild,
-  mii-diag-2.09.ebuild:
-  Fix building with gcc-3.3.1, mark stable on alpha, and add some error-checking
-  to the ebuild (bug 29165). Also add version 2.09.
-
-*mii-diag-2.07 (23 Nov 2002)
-
-  23 Nov 2002; Aron Griffis <agriffis@gentoo.org> mii-diag-2.07.ebuild:
-  Initial import.
diff --git a/sys-apps/mii-diag/Manifest b/sys-apps/mii-diag/Manifest
deleted file mode 100644 (file)
index 12f597e..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-AUX libmii.c-2.10 21508 RMD160 e62a949b9dc750323da499b29ab54f58d09c6c06 SHA1 f8865aa50fe143ad1333f7ee4160a3c34d3849ad SHA256 631388fe7e4e149bceaff2a9560a392a82909704623f3a01c4d98d29cb57972f
-AUX libmii.c-2.11 21592 RMD160 b4b2e3ccfca71b903110bb43ae4be86c2687014f SHA1 a04a7702f7a719f23a881b3d1f34c3fccebb8306 SHA256 2ba2a92952dbccbbb0251d44544e526072d26175adef0eab33c34eeefee5be45
-AUX mii-diag.8-2.11 5033 RMD160 a5f59c169904ad155f5afccaebbac19a66d0ca27 SHA1 409117caa68282497b0774271835df89232aba5e SHA256 d0d9749cbb2fb3fb34883828e1b10e94dd063ced4597a1a63242fced6b316267
-AUX mii-diag.c-2.09 20169 RMD160 246ae85d85d4534d09eca71ebd2e3e728d970a2c SHA1 8dca5670a79cac37c8f035d99a654ab8cedd44fa SHA256 829f38639377d8e743de2006612800172664165cd2f2ce776ceedb5ba0f69252
-AUX mii-diag.c-2.09-gcc33.patch 5037 RMD160 759e2b428115153633c315e4e6c3713c4ee47dbe SHA1 b08f5cdb2a7b0be2527e95fdc858bb818c72bbee SHA256 1ba182cb1de3327e0e3d748a3559a808424251e946303b2e1c078118518fa8f2
-AUX mii-diag.c-2.11 20252 RMD160 2194d658ddad7cb1f5de9616ffb2fff58885ea75 SHA1 b1299d8fafd91af0ae6b9357b847466257a8f2a4 SHA256 77d5c050d5ee4a6344389ba5aad83e023b0e6003da227009830bd1be9be8f208
-EBUILD mii-diag-2.09.ebuild 1211 RMD160 c5cfb4ff47db54e26fdcaec9cffea8e69ee9b875 SHA1 a7bd97239a4bd6a4b749484f76724694ed90fa21 SHA256 74e641c34c1042317e812b5d402e0740a18d7c4ae1ad45deb6c3f73ede7e3087
-EBUILD mii-diag-2.11.ebuild 1244 RMD160 73e95864d250854dffef02efa5254f6f59e8ebba SHA1 9e8e24f1bcc6e2e7cae8884e1bad480d08eba857 SHA256 1785b0161cc406d1367945bd84a777693b6569053211372822cb2fd997df8ad2
-MISC ChangeLog 1523 RMD160 10bcc30e98da06a0a3b0c197cb8e41d9167b28f8 SHA1 7662842a9ce92848b4c952def2fcd0bc1bf252fb SHA256 3c1bd7c0ae22a8f6de3a37f7f64f08927511bf7f4a283ea1034b484874bff406
-MISC metadata.xml 164 RMD160 f43cbec30b7074319087c9acffdb9354b17b0db3 SHA1 9c213f5803676c56439df3716be07d6692588856 SHA256 f5f2891f2a4791cd31350bb2bb572131ad7235cd0eeb124c9912c187ac10ce92
diff --git a/sys-apps/mii-diag/files/libmii.c-2.10 b/sys-apps/mii-diag/files/libmii.c-2.10
deleted file mode 100644 (file)
index 9ccc3b5..0000000
+++ /dev/null
@@ -1,626 +0,0 @@
-/* libmii.c: MII diagnostic and setup library.
-
-       Copyright 1997-2003 by Donald Becker.
-       This version released under the Gnu General Public License,
-       incorporated herein by reference.
-       This source code may be distributed without modification using the
-       existing notice.  Any modification to this source code must include a
-       full notice as described in the GPL
-       Contact the author for use under other terms.
-
-       The author may be reached as becker@scyld.com, or C/O
-        Scyld Computing Corporation
-        410 Severn Ave., Suite 210
-        Annapolis MD 21403
-
-   References
-       http://www.scyld.com/expert/NWay.html
-       http://www.national.com/pf/DP/DP83840A.html
-*/
-
-static const char version_msg[] =
-"libmii.c:v2.10 4/22/2003  Donald Becker (becker@scyld.com)\n"
-" http://www.scyld.com/diag/index.html\n";
-
-/* This library exports the following functions:
-    IOADDR: A token passed to the mdio_read() function.
-    PHY_ID: The MII transceiver address, passed uninterpreted to mdio_read().
-*/
-void show_mii_details(long ioaddr, int phy_id);
-int monitor_mii(long ioaddr, int phy_id);
-
-/* This library expects to be able to call the following functions: */
-extern int mdio_read(long ioaddr, int phy_id, int mii_reg_num);
-
-#include <unistd.h>
-#include <stdio.h>
-#include <time.h>
-#include <sys/time.h>
-
-typedef unsigned short u16;
-
-static const char *media_names[] = {
-       "10baseT", "10baseT-FD", "100baseTx", "100baseTx-FD", "100baseT4",
-       "Flow-control", 0,
-};
-
-static void ns83843(long ioaddr, int phy_id);
-static void qs6612(long ioaddr, int phy_id);
-static void smsc83c180(long ioaddr, int phy_id);
-static void tdk78q2120(long ioaddr, int phy_id);
-static void davicom_dm9101(long ioaddr, int phy_id);
-static void intel_i553(long ioaddr, int phy_id);
-static void enablesemi(long ioaddr, int phy_id);
-static void amd_pna(long ioaddr, int phy_id);
-static void amd_tx(long ioaddr, int phy_id);
-static void admtek(long ioaddr, int phy_id);
-static void lu3x31(long ioaddr, int phy_id);
-static void myson981(long ioaddr, int phy_id);
-static void via_tahoe(long ioaddr, int phy_id);
-static void via_vt6103(long ioaddr, int phy_id);
-static void via_vt6105(long ioaddr, int phy_id);
-static void intel(long ioaddr, int phy_id);
-
-struct mii_partnum {
-       const char *vendor;                             /* Vendor name. */
-       u16      phy_id0;                               /* Vendor ID (alternate ver. of ieee_oui[]) */
-       u16      phy_id1;                               /* Vendor ID (alternate ver. of ieee_oui[]) */
-       unsigned char ieee_oui[3];      /* IEEE-assigned organizationally unique ID */
-       char flags;
-       void (*(func))(long xcvr_if, int phy_id);/* Function to emit more info. */
-} static oui_map[] = {
-       {"Unknown transceiver type", 0x0000, 0x0000, {0,}, 0, NULL,},
-       {"National Semiconductor 83840A", 0x2000, 0x5c01, {0,}, 0, NULL,},
-       {"National Semiconductor 83843",  0x2000, 0x5c10, {0,}, 0, ns83843, },
-       {"Level One LXT970", 0x7810, 0x0000, {0,}, 0, NULL, },
-       {"Level One LXT971", 0x7810, 0x0001, {0,}, 0, NULL, },
-       {"Level One LXT971A",0x7810, 0x0003, {0,}, 0, NULL, },
-       {"Level One (unknown type)", 0, 0, {0x1e,0x04,0x00}, 0, NULL, },
-       {"Davicom DM9101", 0x0181, 0xB800, {0,}, 0, davicom_dm9101, },
-       {"Davicom (unknown type)", 0, 0, {0x00, 0x60, 0x6e}, 0, davicom_dm9101, },
-       {"Quality Semiconductor QS6612", 0x0181, 0x4410, {0,}, 0, qs6612},
-       {"Quality Semiconductor (unknown type)", 0,0, {0x00, 0x60, 0x51}, 0, NULL},
-       {"SMSC 83c180", 0x0282, 0x1C51, {0}, 0, smsc83c180, },
-       {"TDK Semi 78Q2120 rev. 2", 0x0300, 0xE542, {0,}, 0, tdk78q2120, },
-       {"TDK Semi 78Q2120 rev. 3", 0x0300, 0xE543, {0,}, 0, tdk78q2120, },
-       {"TDK Semi 78Q2120 rev. 11", 0x0300, 0xE54B, {0,}, 0, tdk78q2120, },
-       {"TDK transceiver (unknown type)", 0,0, {0x00, 0xc0, 0x39}, 0, tdk78q2120},
-       {"Intel (unknown type)", 0,0, {0x00, 0xf8, 0x00}, 0, intel_i553},
-       {"Enable Semiconductor EL40-331", 0x0043, 0x7411, {0,}, 0, enablesemi},
-       {"AMD 79c901A.1 HomePNA", 0x0000, 0x6B91, {0,}, 0, amd_pna},
-       {"AMD 79c901A.2 HomePNA", 0x0000, 0x6B92, {0,}, 0, amd_pna},
-       {"AMD 79c901A.3 HomePNA", 0x0000, 0x6B93, {0,}, 0, amd_pna},
-       {"AMD 79c901A.3 10baseT", 0x0000, 0x6B71, {0,}, 0, amd_tx},
-       {"AdHoc Technology AH101LF", 0x0022, 0x561B, {0,}, 0, tdk78q2120},
-       {"Altimata Communications AC101LF", 0x0022, 0x5523, {0,}, 0, tdk78q2120},
-       {"Altimata Comm (unknown type)", 0, 0, {0x00,0x10,0xA9}, 0, tdk78q2120},
-       {"ASIX (unknown type)", 0, 0, {0x00,0xC0,0xB4}, 0, tdk78q2120},
-       {"ADMtek AN983 Comet", 0x0022, 0x5410, {0,}, 0, admtek},
-       {"ADMtek AN985 Comet", 0x0022, 0x5513, {0,}, 0, admtek},
-       {"ADMtek (unknown type)", 0, 0, {0x00,0xe0,0x92}, 0, admtek},
-       {"Lucent LU6612", 0x0180, 0x7641, {0,}, 0, qs6612},
-       {"Lucent LU3X31", 0x0043, 0x7411, {0,}, 0, lu3x31},
-       {"LSI Logic (Seeq) 80225", 0, 0, {0x00,0xA0,0x7D}, 0, NULL},
-       {"Myson MTD981", 0x0302, 0xD000, {0,}, 0, myson981},
-       {"Myson (unknown type)", 0, 0, {0x00,0xC0,0xB4,}, 0, myson981},
-       {"Alta/Kendin Sundance", 0x0022, 0x1720, {0,}, 0, NULL},
-       {"Alta/Kendin Sundance", 0, 0, {0x00,0x08,0x85}, 0, NULL},
-       {"VIA Tahoe VT6103", 0x0101, 0x8f20, {0,}, 0, via_vt6103},
-       {"VIA Tahoe VT6104", 0x0101, 0x8f30, {0,}, 0, via_tahoe},
-       {"VIA Rhine VT6105", 0x0101, 0x8f22, {0,}, 0, via_vt6105},
-       {"Intel 82557 series", 0x02a8, 0x0150, {0,}, 0, intel},
-       {"Intel 82555 rev 1", 0x02a8, 0x0151, {0,}, 0, intel},
-       {"Intel 82559 transceiver", 0x02a8, 0x0154, {0,}, 0, intel},
-       {"Intel 82555 series transceiver", 0,0, {0x00,0xaa,0x00}, 0, intel},
-       {0, },
-};
-
-static u16 mii_val[32];
-
-void show_mii_details(long ioaddr, int phy_id)
-{
-       int mii_reg, i, vendor = 0;
-       u16 bmcr, bmsr, new_bmsr;
-
-       /* This may not be omitted from the output. */
-       printf("%s", version_msg);
-       printf(" MII PHY #%d transceiver registers:", phy_id);
-       for (mii_reg = 0; mii_reg < 32; mii_reg++) {
-               mii_val[mii_reg] = mdio_read(ioaddr, phy_id, mii_reg);
-               printf("%s %4.4x", (mii_reg % 8) == 0 ? "\n  " : "",
-                          mii_val[mii_reg]);
-       }
-       printf(".\n");
-       if (mii_val[0] == 0xffff) {
-               printf("  No MII transceiver present!.\n");
-               return;
-       }
-       bmcr = mii_val[0];
-       bmsr = mii_val[1];
-       printf(" Basic mode control register 0x%4.4x:", bmcr);
-       if (bmcr & 0x1000)
-               printf(" Auto-negotiation enabled.\n");
-       else
-               printf(" Auto-negotiation disabled!\n"
-                          "   Speed fixed at 10%s mbps, %s-duplex.\n",
-                          bmcr & 0x2000 ? "0" : "",
-                          bmcr & 0x0100 ? "full":"half");
-       if (bmcr & 0x8000)
-               printf("  Transceiver currently being reset!\n");
-       if (bmcr & 0x4000)
-               printf("  Transceiver in loopback mode!\n");
-       if (bmcr & 0x0800)
-               printf("  Transceiver powered down!\n");
-       if (bmcr & 0x0400)
-               printf("  Transceiver isolated from the MII!\n");
-       if (bmcr & 0x0200)
-               printf("  Restarted auto-negotiation in progress!\n");
-       if (bmcr & 0x0080)
-               printf("  Internal Collision-Test enabled!\n");
-       
-       new_bmsr = mdio_read(ioaddr, phy_id, 1);
-       printf(" Basic mode status register 0x%4.4x ... %4.4x.\n"
-                  "   Link status: %sestablished.\n"
-                  "   Capable of ",
-                  bmsr, new_bmsr,
-                  bmsr & 0x0004 ? "" :
-                   (new_bmsr & 0x0004) ? "previously broken, but now re" : "not ");
-       if (bmsr & 0xF800) {
-               for (i = 15; i >= 11; i--)
-                       if (bmsr & (1<<i))
-                               printf(" %s", media_names[i-11]);
-       } else
-               printf("<Warning! No media capabilities>");
-
-       printf(".\n"
-                  "   %s to perform Auto-negotiation, negotiation %scomplete.\n",
-                  bmsr & 0x0008 ? "Able" : "Unable",
-                  bmsr & 0x0020 ? "" : "not ");
-
-       if (bmsr & 0x0010)
-               printf(" Remote fault detected!\n");
-       if (bmsr & 0x0002)
-               printf("   *** Link Jabber! ***\n");
-
-       if (mii_val[2] ^ mii_val[3]) {          /* Eliminate 0x0000 and 0xffff IDs. */
-               unsigned char oui_0 = mii_val[2] >> 10;
-               unsigned char oui_1 = mii_val[2] >> 2;
-               unsigned char oui_2 = (mii_val[2] << 6) | (mii_val[3] >> 10);
-
-               printf(" Vendor ID is %2.2x:%2.2x:%2.2x:--:--:--, model %d rev. %d.\n",
-                          oui_0, oui_1, oui_2,
-                          ((mii_val[3] >> 4) & 0x3f), mii_val[3] & 0x0f);
-               for ( i = 0; oui_map[i].vendor; i++)
-                       /* We match either the Phy ID or the IEEE OUI. */
-                       if ((oui_map[i].phy_id0 == mii_val[2] &&
-                                oui_map[i].phy_id1 == mii_val[3]) ||
-                               (oui_map[i].ieee_oui[0] == oui_0 &&
-                                oui_map[i].ieee_oui[1] == oui_1 &&
-                                oui_map[i].ieee_oui[2] == oui_2)) {
-                               printf("   Vendor/Part: %s.\n", oui_map[i].vendor);
-                               vendor = i;
-                               break;
-                       }
-               if (oui_map[i].vendor == NULL)
-                       printf("   No specific information is known about this transceiver"
-                                  " type.\n");
-       } else
-               printf(" This transceiver has no vendor identification.\n");
-
-       {
-               int nway_advert = mii_val[4];
-               int lkpar = mii_val[5];
-               printf(" I'm advertising %4.4x:", nway_advert);
-               for (i = 10; i >= 5; i--)
-                       if (nway_advert & (1<<i))
-                               printf(" %s", media_names[i-5]);
-               printf("\n   Advertising %sadditional info pages.\n",
-                          nway_advert & 0x8000 ? "" : "no ");
-               if ((nway_advert & 31) == 1)
-                       printf("   IEEE 802.3 CSMA/CD protocol.\n");
-               else
-                       printf("   Using an unknown (non 802.3) encapsulation.\n");
-               printf(" Link partner capability is %4.4x:",
-                          lkpar);
-               for (i = 10; i >= 5; i--)
-                       if (lkpar & (1<<i))
-                               printf(" %s", media_names[i-5]);
-               printf(".\n   Negotiation %s.\n",
-                          lkpar & 0x4000 ? " completed" : "did not complete");
-       }
-       if (oui_map[vendor].func)
-               oui_map[vendor].func(ioaddr, phy_id);
-
-}
-
-int monitor_mii(long ioaddr, int phy_id)
-{
-       int i, last_event = 0;
-       unsigned short new_1, baseline_1 = mdio_read(ioaddr, phy_id, 1);
-       struct timeval tv, sleepval;
-       time_t cur_time;
-       char timebuf[12];
-
-       if (baseline_1 == 0xffff) {
-               fprintf(stderr, "No MII transceiver present to monitor.\n");
-               return -1;
-       }
-
-       gettimeofday(&tv, NULL);
-       cur_time = tv.tv_sec;
-       strftime(timebuf, sizeof(timebuf), "%H:%M:%S", localtime(&cur_time));
-
-       printf("Monitoring the MII transceiver status.\n"
-                  "%s.%03d  Baseline value of MII BMSR (basic mode status register)"
-                  " is %4.4x.\n", timebuf, (int)tv.tv_usec/1000, baseline_1);
-       while (1) {
-               new_1 = mdio_read(ioaddr, phy_id, 1);
-               if (new_1 == 0xffff) {
-                       fprintf(stderr, "The MII transceiver is no longer accessable!\n");
-                       return -1;
-               }
-               if (new_1 != baseline_1) {
-                       gettimeofday(&tv, NULL);
-                       cur_time = tv.tv_sec;
-                       strftime(timebuf, sizeof(timebuf), "%H:%M:%S",
-                                        localtime(&cur_time));
-                       printf("%s.%03d  MII BMSR now %4.4x: %4s link, NWay %s, "
-                                  "%3sJabber%s (%4.4x).\n",
-                                  timebuf, (int)tv.tv_usec/1000, new_1,
-                                  new_1 & 0x04 ? "Good" : "no",
-                                  new_1 & 0x20 ? "done" : "busy",
-                                  new_1 & 0x02 ? "" : "No ",
-                                  new_1 & 0x10 ? ", remote fault" : "",
-                                  mdio_read(ioaddr, phy_id, 5)
-                                  );
-                       if (!(baseline_1 & 0x20)  && (new_1 & 0x20)) {
-                               int lkpar = mdio_read(ioaddr, phy_id, 5);
-                               printf("   New link partner capability is %4.4x %4.4x:",
-                                          lkpar, mdio_read(ioaddr, phy_id, 6));
-                               switch (lkpar) {
-                               case 0x45e1: printf(" 10/100 switch w/ flow control"); break;
-                               case 0x41e1: printf(" 10/100 HD+FD switch"); break;
-                               case 0x40a1: printf(" 10/100 bridged repeater"); break;
-                               case 0x4081: printf(" 100baseTx repeater w/autonegotation");
-                                       break;
-                               case 0x0081: printf(" 100baseTx (no autonegotation)"); break;
-                               case 0x4021: printf(" 10baseT repeater w/autonegotation");
-                                       break;
-                               case 0x0021: printf(" 10baseT (no autonegotation)"); break;
-                               default:
-                                       for (i = 9; i >= 5; i--)
-                                               if (lkpar & (1<<i))
-                                                       printf(" %s", media_names[i-5]);
-                               }
-                               printf(".\n");
-                       }
-                       baseline_1 = new_1;
-                       last_event = 0;
-               }
-               sleepval.tv_sec = 0;
-               sleepval.tv_usec = last_event++ > 30 ? 200000 : 1000;
-               select(0, 0, 0, 0, &sleepval);                  /* Or just sleep(1); */
-       }
-       printf("  Value of MII BMSR (basic mode status register) is %4.4x.\n",
-                  mdio_read(ioaddr, phy_id, 1));
-       return 0;
-}
-\f
-/* Emit transceiver-specific info. */
-
-struct msg_tbl { int bitmask;  char *msg; };
-
-static void msg_if_set(const int val, const struct msg_tbl msg_tbl[])
-{
-       int i;
-       for (i = 0; msg_tbl[i].bitmask; i++)
-               if (msg_tbl[i].bitmask & val)
-                       printf(" %s\n", msg_tbl[i].msg);
-}
-
-static void msg_if_set_fmt(const int val, const struct msg_tbl msg_tbl[],
-                                                  const char *fmt)
-{
-       int i;
-       for (i = 0; msg_tbl[i].bitmask; i++)
-               if (msg_tbl[i].bitmask & val)
-                       printf(fmt, msg_tbl[i].msg);
-}
-
-static void qs6612(long ioaddr, int phy_id)
-{
-       printf("  QS6612 extra registers: Mode %4.4x.\n"
-                  "    Interrupt source %4.4x, mask %4.4x.\n"
-                  "    PHY control %4.4x.\n",
-                  mii_val[17], mii_val[29], mii_val[30], mii_val[31]);
-       return;
-}
-
-static void ns83843(long ioaddr, int phy_id)
-{
-       printf("  NatSemi 83843 extra registers:\n"
-                  "    PHY status %4.4x\n"
-                  "    %s link, %d Mb/sec %s duplex\n"
-                  "    MII interrupts %sabled, %s pending.\n"
-                  "    Events since last read\n"
-                  "     Link disconnects %d\n"
-                  "     False carriers %d\n"
-                  "     Receive errors %d\n"
-                  "    Link beat is currently %sstable\n",
-                  mii_val[0x10],
-                  mii_val[10] & 0x0001 ? "Valid" : "Invalid",
-                  mii_val[10] & 0x0002 ? 10 : 100, 
-                  mii_val[10] & 0x0004 ? "full" : "half", 
-                  mii_val[0x11] & 0x0002 ? "en":"dis",
-                  mii_val[0x10] & 0x0100 ? "interrupt": "none",
-                  mii_val[0x13], mii_val[0x14], mii_val[0x15],
-                  mii_val[0x16] & 0x0010 ? "UN" : "");
-       return;
-}
-static void smsc83c180(long ioaddr, int phy_id)
-{
-       int mii_reg25 = mii_val[25];
-       printf("  SMSC 83c180 extra registers:\n"
-                  "    Auto-negotiation status 0x%4.4x.\n"
-                  "      10baseT polarity is %s.\n"
-                  "      PHY address is %d.\n"
-                  "      Auto-negotiation %scomplete, 1%s0Mbps %s duplex.\n"
-                  "    Rx symbol errors since last read %d.\n",
-                  mii_reg25,
-                  mii_reg25 & 0x2000 ? "normal" : "reversed",
-                  (mii_reg25>>8) & 0x1F,
-                  mii_reg25 & 0x0080 ? "did not " : "",
-                  mii_reg25 & 0x0020 ? "0" : "",
-                  mii_reg25 & 0x0040 ? "full" : "half",
-                  mdio_read(ioaddr, phy_id, 26));
-       return;
-}
-
-static const char *tdk_events[8] = {
-       "Jabber", "Rx error", "Negotiation page received", "Link detection fault",
-       "Link partner acknowledge", "Link status change", "Remote partner fault",
-       "Auto-Negotiation complete"};
-
-static const struct msg_tbl tdk_reg16[] = {
-       {0x8000, " Transceiver is in repeater mode!"},
-       {0x4000, " Interrupt pin set to active high."},
-       {0x2000, " Reserved bit 12 is unexpectedly set."},
-       {0x1000, " Transmit pins are internally disconnected."},
-       {0x0800, " 10baseT signal quality test is disabled."},
-       {0x0400, " 10baseT loopback mode."},
-       {0, 0},
-};
-
-static void tdk78q2120(long ioaddr, int phy_id)
-{
-       int mii_reg16 = mii_val[16];
-       int mii_reg17 = mii_val[17];
-       int mii_reg18 = mii_val[18];
-       int i;
-       printf("  TDK format vendor-specific registers 16..18 are "
-                  "0x%4.4x 0x%4.4x 0x%4.4x\n", mii_reg16, mii_reg17, mii_reg18);
-       printf("      Link polarity is %s %s.\n"
-                  "%s%s"
-                  "      Auto-negotiation %s, 1%s0Mbps %s duplex.\n"
-                  "      Rx link in %s state, PLL %s.\n",
-                  mii_reg16 & 0x0020 ? "OVERRIDDEN to" : "detected as",
-                  mii_reg16 & 0x0010 ? "reversed" : "normal",
-                  mii_reg16 & 0x0002 ?
-                  "     100baseTx Coding and scrambling is disabled!\n":"",
-                  mii_reg16 & 0x0001 ? "     Rx_CLK power-save mode is enabled!\n":"",
-                  mii_reg18 & 0x1000 ? "had no common media" : "complete",
-                  mii_reg18 & 0x0400 ? "0" : "",
-                  mii_reg18 & 0x0800 ? "full" : "half",
-                  mii_reg18 & 0x0200 ? "pass" : "fail",
-                  mii_reg18 & 0x0100 ? "slipped since last read" : "locked");
-
-       msg_if_set(mii_reg16, tdk_reg16);
-       if (mii_reg17 & 0x00ff) {
-               printf("      Events since last read:");
-               for (i = 0; i < 8; i++)
-                       if (mii_reg17 & (1 << i))
-                               printf("  %s", tdk_events[i]);
-       } else
-               printf("      No new link status events.");
-
-       if (mii_reg17 & 0xff00) {
-               printf("\n      Events that will raise an interrupt:");
-               for (i = 0; i < 8; i++)
-                       if (mii_reg17 & (0x100 << i))
-                               printf("  %s", tdk_events[i]);
-       }
-       printf("\n");
-       return;
-}
-
-static void davicom_dm9101(long ioaddr, int phy_id)
-{
-       printf("  Davicom vendor specific registers: 0x%4.4x 0x%4.4x 0x%4.4x.\n",
-                  mii_val[16], mii_val[17], mii_val[18]);
-}
-static void intel_i553(long ioaddr, int phy_id)
-{
-       printf("  This transceiver is 100baseT4 only!  Register 16 is %4.4x.\n",
-                  mii_val[16]);
-}
-/* http://www.enablesemi.com/cgi-bin/byteserve/Products/Docs/3VCardBus.pdf */
-static void enablesemi(long ioaddr, int phy_id)
-{
-       printf("  Isolated %d times, %d false carrier events, %d Rx errors.\n",
-                  mii_val[18], mii_val[19], mii_val[21]);
-       printf("  Cable polarity is %s, 100Mb PLL is %slocked.\n",
-                  mii_val[28]&0x8000 ? "reversed" : "normal",
-                  mii_val[27]&0x2000 ? "" : "un");
-}
-/* The amd79c901 contains both PNA and 10/100 management registers.
-   http://www.amd.com/products/npd/techdocs/22304.pdf
-*/
-static void amd_pna(long ioaddr, int phy_id)
-{
-       printf("  HomePNA transceiver in %s speed, %s power mode.\n",
-                  mii_val[16] & 4 ? "high" : "low",
-                  mii_val[16] & 2 ? "high" : "low");
-       printf("  HomePNA noise level %d, peak power %d..\n",
-                  mii_val[25] >> 8, mii_val[25] & 0xff);
-}
-static void amd_tx(long ioaddr, int phy_id)
-{
-       int mii_reg25 = mii_val[25];
-       printf("  AMD vendor specific registers: 0x%4.4x 0x%4.4x 0x%4.4x.\n",
-                  mii_val[16], mii_val[17], mii_val[18]);
-       printf("  The link is %s in 10%s %s duplex mode, autonegotiation state "
-                  "has%s changed.\n",
-                  mii_reg25 & 8 ? "up" : "down",
-                  mii_reg25 & 1 ? "0baseTx" : "baseT",
-                  mii_reg25 & 4 ? "full" : "half",
-                  mii_reg25 & 2 ? "" : " not");
-}
-
-static const struct msg_tbl admtek_reg21[] = {
-       {0x4000, " Link test diabled: Ignoring lack of 10baseT link beat."},
-       {0x2000, " Link forced up."},
-       {0x1000, " Tx jabber check disabled."},
-       {0x0080, " Transmitting 'Far End Fault'!"},
-       {0x0040, " Rx error count full."},
-       {0x0008, " Remote loop back enabled."},
-       {0, 0},
-};
-
-static void admtek(long ioaddr, int phy_id)
-{
-
-       printf("  ADMtek vendor specific registers information:\n"
-                  "   Cable length is approximately %d meters.\n"
-                  "   The receiver has lost lock %d times since last check and "
-                  "had %d error events.\n",
-                  ((mii_val[20] & 0x00f0) >> 4)*10,
-                  mii_val[23], mii_val[23]);
-       msg_if_set(mii_val[21], admtek_reg21);
-       tdk78q2120(ioaddr, phy_id);
-}
-
-static void lu3x31(long ioaddr, int phy_id)
-{
-       printf("  Lucent vendor specific registers 17: 0x%4.4x"
-                  " 29: 0x%4.4x 30: 0x%4.4x 31: 0x%4.4x.\n",
-                  mii_val[17], mii_val[29], mii_val[30], mii_val[31]);
-}
-
-static const struct msg_tbl myson_reg16[] = {
-       {0x0080, " Far end fault enabled."},
-       {0x0040, " Transformer ratio 1.25:1."},
-       {0x0020, " Polarity correction diabled."},
-       {0x0010, " Link is forced up regardless of link beat."},
-       {0x0004, " Bypass Jabber check."},
-       {0x0001, " 100baseFx mode selected."},
-       {0, 0},
-};
-
-static void myson981(long ioaddr, int phy_id)
-{
-       int i, mii_reg17 = mii_val[17];
-
-       printf("  Myson mtd981 extra registers: %4.4x %4.4x %4.4x %4.4x.\n",
-                  mii_val[16], mii_val[17], mii_val[18], mii_val[19]);
-       msg_if_set(mii_val[16] & 0xC800, tdk_reg16);
-       msg_if_set(mii_val[16], myson_reg16);
-
-       if (mii_reg17 & 0x00ff) {
-               printf("      Events since last read:");
-               for (i = 0; i < 8; i++)
-                       if (mii_reg17 & (1 << i))
-                               printf("  %s", tdk_events[i]);
-       } else
-               printf("      No new link status events.");
-       if (mii_reg17 & 0xff00) {
-               printf("\n      Events that will raise an interrupt:");
-               for (i = 0; i < 8; i++)
-                       if (mii_reg17 & (0x100 << i))
-                               printf("  %s", tdk_events[i]);
-       }
-       printf("\n");
-
-       return;
-}
-
-/* These are much like the TDK events in reversed order. */
-static const struct msg_tbl via_reg17[] = {
-       {0x0001, "Auto-Negotiation complete"},
-       {0x0002, "Remote fault detected"},
-       {0x0004, "Link failure detected"},
-       {0x0008, "Bad Start Stream detected"},
-       {0x0010, "Parallel detection fault"},
-       {0x0020, "Extended negotiation page received"},
-       {0x0040, "5B/4B code error detected"},
-       {0x0080, "Jabber detected"},
-       {0, 0},
-};
-
-static void via_tahoe(long ioaddr, int phy_id)
-{
-       int mii_reg16 = mii_val[16];
-       int mii_reg17 = mii_val[17];
-       int mii_reg18 = mii_val[18];
-
-       printf("  VIA Tahoe extended registers: 16 %4.4x  #17 %4.4x  #18 %4.4x.\n",
-                  mii_reg16, mii_reg17, mii_reg18);
-       msg_if_set_fmt(mii_reg17, via_reg17, "   %s\n");
-       printf("   Link %s 10%s Mbps %s duplex\n",
-                  mii_reg18 & 0x2000 ? "up" : "down",
-                  mii_reg18 & 0x0400 ? "0" : "",
-                  mii_reg18 & 0x0800 ? "full" : "half");
-}
-
-/* Information from
-   http://www.via.com.tw/en/datasheet/DS6103110.pdf
-*/
-   
-static void via_vt6103(long ioaddr, int phy_id)
-{
-       printf("  VIA vt6103 error counts since the last check:\n"
-                  "   The link has failed %d times.\n"
-                  "   The receiver has lost lock %d times.\n"
-                  "   There have been %d false carrier/SQE error.\n",
-                  mii_val[21], mii_val[22], mii_val[23]);
-}
-
-/* Information from
-   http://www.via.com.tw/en/Networking/DS6105LOM100.pdf
-*/
-
-static void via_vt6105(long ioaddr, int phy_id)
-{
-       printf("  VIA vt6105 PHY status:\n"
-                  "   Duplex %s  speed %s\n",
-                  mii_val[20] & 0x0001 ? "full" : "half",
-                  mii_val[20] & 0x0002 ? "100" : "10");
-}
-
-/* Information from
-   http://www.via.com.tw/en/Networking/DS6105LOM100.pdf
-*/
-static void intel(long ioaddr, int phy_id)
-{
-       printf("  Intel 8255* PHY #%d extended management registers:\n"
-                  "    Error counts, cleared when read:\n"
-                  "     False carriers %d\n"
-                  "     Link disconnects %d\n"
-                  "     Receive errors %d\n"
-                  "     Rx symbol errors %d.\n"
-                  "     Rx 10Mbps Early End-Of-Frame errors %d.\n"
-                  "     Rx 100Mbps Early End-Of-Frame errors %d.\n"
-                  "     Tx jabber errors %d.\n",
-                  mii_val[18],
-                  mii_val[19], mii_val[20], mii_val[21], mii_val[22], mii_val[23],
-                  mii_val[24], mii_val[25]);
-}
-
-\f
-/*
- * Local variables:
- *  compile-command: "cc -O -Wall -c libmii.c"
- *  c-indent-level: 4
- *  c-basic-offset: 4
- *  tab-width: 4
- * End:
- */
diff --git a/sys-apps/mii-diag/files/libmii.c-2.11 b/sys-apps/mii-diag/files/libmii.c-2.11
deleted file mode 100644 (file)
index 96f0060..0000000
+++ /dev/null
@@ -1,630 +0,0 @@
-/* libmii.c: MII diagnostic and setup library.
-
-       Copyright 1997-2003 by Donald Becker.
-       This version released under the Gnu General Public License,
-       incorporated herein by reference.
-       This source code may be distributed without modification using the
-       existing notice.  Any modification to this source code must include a
-       full notice as described in the GPL
-       Contact the author for use under other terms.
-
-       The author may be reached as becker@scyld.com, or C/O
-        Scyld Computing Corporation
-        914 Bay Ridge Road, Suite 220
-        Annapolis MD 21403
-
-   References
-       http://www.scyld.com/expert/NWay.html
-       http://www.national.com/pf/DP/DP83840A.html
-*/
-
-static const char version_msg[] =
-"libmii.c:v2.11 2/28/2005  Donald Becker (becker@scyld.com)\n"
-" http://www.scyld.com/diag/index.html\n";
-
-/* This library exports the following functions:
-    IOADDR: A token passed to the mdio_read() function.
-    PHY_ID: The MII transceiver address, passed uninterpreted to mdio_read().
-*/
-void show_mii_details(long ioaddr, int phy_id);
-int monitor_mii(long ioaddr, int phy_id);
-
-/* This library expects to be able to call the following functions: */
-extern int mdio_read(long ioaddr, int phy_id, int mii_reg_num);
-
-#include <unistd.h>
-#include <stdio.h>
-#include <time.h>
-#include <sys/time.h>
-
-#include <sys/types.h>
-typedef u_int32_t u32;
-typedef u_int16_t u16;
-typedef u_int8_t u8;
-
-static const char *media_names[] = {
-       "10baseT", "10baseT-FD", "100baseTx", "100baseTx-FD", "100baseT4",
-       "Flow-control", 0,
-};
-
-static void ns83843(long ioaddr, int phy_id);
-static void qs6612(long ioaddr, int phy_id);
-static void smsc83c180(long ioaddr, int phy_id);
-static void tdk78q2120(long ioaddr, int phy_id);
-static void davicom_dm9101(long ioaddr, int phy_id);
-static void intel_i553(long ioaddr, int phy_id);
-static void enablesemi(long ioaddr, int phy_id);
-static void amd_pna(long ioaddr, int phy_id);
-static void amd_tx(long ioaddr, int phy_id);
-static void admtek(long ioaddr, int phy_id);
-static void lu3x31(long ioaddr, int phy_id);
-static void myson981(long ioaddr, int phy_id);
-static void via_tahoe(long ioaddr, int phy_id);
-static void via_vt6103(long ioaddr, int phy_id);
-static void via_vt6105(long ioaddr, int phy_id);
-static void intel(long ioaddr, int phy_id);
-
-struct mii_partnum {
-       const char *vendor;                             /* Vendor name. */
-       u16      phy_id0;                               /* Vendor ID (alternate ver. of ieee_oui[]) */
-       u16      phy_id1;                               /* Vendor ID (alternate ver. of ieee_oui[]) */
-       unsigned char ieee_oui[3];      /* IEEE-assigned organizationally unique ID */
-       char flags;
-       void (*(func))(long xcvr_if, int phy_id);/* Function to emit more info. */
-} static oui_map[] = {
-       {"Unknown transceiver type", 0x0000, 0x0000, {0,}, 0, NULL,},
-       {"National Semiconductor 83840A", 0x2000, 0x5c01, {0,}, 0, NULL,},
-       {"National Semiconductor 83843",  0x2000, 0x5c10, {0,}, 0, ns83843, },
-       {"Level One LXT970", 0x7810, 0x0000, {0,}, 0, NULL, },
-       {"Level One LXT971", 0x7810, 0x0001, {0,}, 0, NULL, },
-       {"Level One LXT971A",0x7810, 0x0003, {0,}, 0, NULL, },
-       {"Level One (unknown type)", 0, 0, {0x1e,0x04,0x00}, 0, NULL, },
-       {"Davicom DM9101", 0x0181, 0xB800, {0,}, 0, davicom_dm9101, },
-       {"Davicom (unknown type)", 0, 0, {0x00, 0x60, 0x6e}, 0, davicom_dm9101, },
-       {"Quality Semiconductor QS6612", 0x0181, 0x4410, {0,}, 0, qs6612},
-       {"Quality Semiconductor (unknown type)", 0,0, {0x00, 0x60, 0x51}, 0, NULL},
-       {"SMSC 83c180", 0x0282, 0x1C51, {0}, 0, smsc83c180, },
-       {"TDK Semi 78Q2120 rev. 2", 0x0300, 0xE542, {0,}, 0, tdk78q2120, },
-       {"TDK Semi 78Q2120 rev. 3", 0x0300, 0xE543, {0,}, 0, tdk78q2120, },
-       {"TDK Semi 78Q2120 rev. 11", 0x0300, 0xE54B, {0,}, 0, tdk78q2120, },
-       {"TDK transceiver (unknown type)", 0,0, {0x00, 0xc0, 0x39}, 0, tdk78q2120},
-       {"Intel (unknown type)", 0,0, {0x00, 0xf8, 0x00}, 0, intel_i553},
-       {"Enable Semiconductor EL40-331", 0x0043, 0x7411, {0,}, 0, enablesemi},
-       {"AMD 79c901A.1 HomePNA", 0x0000, 0x6B91, {0,}, 0, amd_pna},
-       {"AMD 79c901A.2 HomePNA", 0x0000, 0x6B92, {0,}, 0, amd_pna},
-       {"AMD 79c901A.3 HomePNA", 0x0000, 0x6B93, {0,}, 0, amd_pna},
-       {"AMD 79c901A.3 10baseT", 0x0000, 0x6B71, {0,}, 0, amd_tx},
-       {"AdHoc Technology AH101LF", 0x0022, 0x561B, {0,}, 0, tdk78q2120},
-       {"Altimata Communications AC101LF", 0x0022, 0x5523, {0,}, 0, tdk78q2120},
-       {"Altimata Comm (unknown type)", 0, 0, {0x00,0x10,0xA9}, 0, tdk78q2120},
-       {"ASIX (unknown type)", 0, 0, {0x00,0xC0,0xB4}, 0, tdk78q2120},
-       {"ADMtek AN983 Comet", 0x0022, 0x5410, {0,}, 0, admtek},
-       {"ADMtek AN985 Comet", 0x0022, 0x5513, {0,}, 0, admtek},
-       {"ADMtek (unknown type)", 0, 0, {0x00,0xe0,0x92}, 0, admtek},
-       {"Lucent LU6612", 0x0180, 0x7641, {0,}, 0, qs6612},
-       {"Lucent LU3X31", 0x0043, 0x7411, {0,}, 0, lu3x31},
-       {"LSI Logic (Seeq) 80225", 0, 0, {0x00,0xA0,0x7D}, 0, NULL},
-       {"Myson MTD981", 0x0302, 0xD000, {0,}, 0, myson981},
-       {"Myson (unknown type)", 0, 0, {0x00,0xC0,0xB4,}, 0, myson981},
-       {"Alta/Kendin Sundance", 0x0022, 0x1720, {0,}, 0, NULL},
-       {"Alta/Kendin Sundance", 0, 0, {0x00,0x08,0x85}, 0, NULL},
-       {"VIA Tahoe VT6103", 0x0101, 0x8f20, {0,}, 0, via_vt6103},
-       {"VIA Tahoe VT6104", 0x0101, 0x8f30, {0,}, 0, via_tahoe},
-       {"VIA Rhine VT6105", 0x0101, 0x8f22, {0,}, 0, via_vt6105},
-       {"Intel 82557 series", 0x02a8, 0x0150, {0,}, 0, intel},
-       {"Intel 82555 rev 1", 0x02a8, 0x0151, {0,}, 0, intel},
-       {"Intel 82559 transceiver", 0x02a8, 0x0154, {0,}, 0, intel},
-       {"Intel 82555 series transceiver", 0,0, {0x00,0xaa,0x00}, 0, intel},
-       {0, },
-};
-
-static u16 mii_val[32];
-
-void show_mii_details(long ioaddr, int phy_id)
-{
-       int mii_reg, i, vendor = 0;
-       u16 bmcr, bmsr, new_bmsr;
-
-       /* This may not be omitted from the output. */
-       printf("%s", version_msg);
-       printf(" MII PHY #%d transceiver registers:", phy_id);
-       for (mii_reg = 0; mii_reg < 32; mii_reg++) {
-               mii_val[mii_reg] = mdio_read(ioaddr, phy_id, mii_reg);
-               printf("%s %4.4x", (mii_reg % 8) == 0 ? "\n  " : "",
-                          mii_val[mii_reg]);
-       }
-       printf(".\n");
-       if (mii_val[0] == 0xffff) {
-               printf("  No MII transceiver present!.\n");
-               return;
-       }
-       bmcr = mii_val[0];
-       bmsr = mii_val[1];
-       printf(" Basic mode control register 0x%4.4x:", bmcr);
-       if (bmcr & 0x1000)
-               printf(" Auto-negotiation enabled.\n");
-       else
-               printf(" Auto-negotiation disabled!\n"
-                          "   Speed fixed at 10%s mbps, %s-duplex.\n",
-                          bmcr & 0x2000 ? "0" : "",
-                          bmcr & 0x0100 ? "full":"half");
-       if (bmcr & 0x8000)
-               printf("  Transceiver currently being reset!\n");
-       if (bmcr & 0x4000)
-               printf("  Transceiver in loopback mode!\n");
-       if (bmcr & 0x0800)
-               printf("  Transceiver powered down!\n");
-       if (bmcr & 0x0400)
-               printf("  Transceiver isolated from the MII!\n");
-       if (bmcr & 0x0200)
-               printf("  Restarted auto-negotiation in progress!\n");
-       if (bmcr & 0x0080)
-               printf("  Internal Collision-Test enabled!\n");
-       
-       new_bmsr = mdio_read(ioaddr, phy_id, 1);
-       printf(" Basic mode status register 0x%4.4x ... %4.4x.\n"
-                  "   Link status: %sestablished.\n"
-                  "   Capable of ",
-                  bmsr, new_bmsr,
-                  bmsr & 0x0004 ? "" :
-                   (new_bmsr & 0x0004) ? "previously broken, but now re" : "not ");
-       if (bmsr & 0xF800) {
-               for (i = 15; i >= 11; i--)
-                       if (bmsr & (1<<i))
-                               printf(" %s", media_names[i-11]);
-       } else
-               printf("<Warning! No media capabilities>");
-
-       printf(".\n"
-                  "   %s to perform Auto-negotiation, negotiation %scomplete.\n",
-                  bmsr & 0x0008 ? "Able" : "Unable",
-                  bmsr & 0x0020 ? "" : "not ");
-
-       if (bmsr & 0x0010)
-               printf(" Remote fault detected!\n");
-       if (bmsr & 0x0002)
-               printf("   *** Link Jabber! ***\n");
-
-       if (mii_val[2] ^ mii_val[3]) {          /* Eliminate 0x0000 and 0xffff IDs. */
-               unsigned char oui_0 = mii_val[2] >> 10;
-               unsigned char oui_1 = mii_val[2] >> 2;
-               unsigned char oui_2 = (mii_val[2] << 6) | (mii_val[3] >> 10);
-
-               printf(" Vendor ID is %2.2x:%2.2x:%2.2x:--:--:--, model %d rev. %d.\n",
-                          oui_0, oui_1, oui_2,
-                          ((mii_val[3] >> 4) & 0x3f), mii_val[3] & 0x0f);
-               for ( i = 0; oui_map[i].vendor; i++)
-                       /* We match either the Phy ID or the IEEE OUI. */
-                       if ((oui_map[i].phy_id0 == mii_val[2] &&
-                                oui_map[i].phy_id1 == mii_val[3]) ||
-                               (oui_map[i].ieee_oui[0] == oui_0 &&
-                                oui_map[i].ieee_oui[1] == oui_1 &&
-                                oui_map[i].ieee_oui[2] == oui_2)) {
-                               printf("   Vendor/Part: %s.\n", oui_map[i].vendor);
-                               vendor = i;
-                               break;
-                       }
-               if (oui_map[i].vendor == NULL)
-                       printf("   No specific information is known about this transceiver"
-                                  " type.\n");
-       } else
-               printf(" This transceiver has no vendor identification.\n");
-
-       {
-               int nway_advert = mii_val[4];
-               int lkpar = mii_val[5];
-               printf(" I'm advertising %4.4x:", nway_advert);
-               for (i = 10; i >= 5; i--)
-                       if (nway_advert & (1<<i))
-                               printf(" %s", media_names[i-5]);
-               printf("\n   Advertising %sadditional info pages.\n",
-                          nway_advert & 0x8000 ? "" : "no ");
-               if ((nway_advert & 31) == 1)
-                       printf("   IEEE 802.3 CSMA/CD protocol.\n");
-               else
-                       printf("   Using an unknown (non 802.3) encapsulation.\n");
-               printf(" Link partner capability is %4.4x:",
-                          lkpar);
-               for (i = 10; i >= 5; i--)
-                       if (lkpar & (1<<i))
-                               printf(" %s", media_names[i-5]);
-               printf(".\n   Negotiation %s.\n",
-                          lkpar & 0x4000 ? " completed" : "did not complete");
-       }
-       if (oui_map[vendor].func)
-               oui_map[vendor].func(ioaddr, phy_id);
-
-}
-
-int monitor_mii(long ioaddr, int phy_id)
-{
-       int i, last_event = 0;
-       unsigned short new_1, baseline_1 = mdio_read(ioaddr, phy_id, 1);
-       struct timeval tv, sleepval;
-       time_t cur_time;
-       char timebuf[12];
-
-       if (baseline_1 == 0xffff) {
-               fprintf(stderr, "No MII transceiver present to monitor.\n");
-               return -1;
-       }
-
-       gettimeofday(&tv, NULL);
-       cur_time = tv.tv_sec;
-       strftime(timebuf, sizeof(timebuf), "%H:%M:%S", localtime(&cur_time));
-
-       printf("Monitoring the MII transceiver status.\n"
-                  "%s.%03d  Baseline value of MII BMSR (basic mode status register)"
-                  " is %4.4x.\n", timebuf, (int)tv.tv_usec/1000, baseline_1);
-       while (1) {
-               new_1 = mdio_read(ioaddr, phy_id, 1);
-               if (new_1 == 0xffff) {
-                       fprintf(stderr, "The MII transceiver is no longer accessable!\n");
-                       return -1;
-               }
-               if (new_1 != baseline_1) {
-                       gettimeofday(&tv, NULL);
-                       cur_time = tv.tv_sec;
-                       strftime(timebuf, sizeof(timebuf), "%H:%M:%S",
-                                        localtime(&cur_time));
-                       printf("%s.%03d  MII BMSR now %4.4x: %4s link, NWay %s, "
-                                  "%3sJabber%s (%4.4x).\n",
-                                  timebuf, (int)tv.tv_usec/1000, new_1,
-                                  new_1 & 0x04 ? "Good" : "no",
-                                  new_1 & 0x20 ? "done" : "busy",
-                                  new_1 & 0x02 ? "" : "No ",
-                                  new_1 & 0x10 ? ", remote fault" : "",
-                                  mdio_read(ioaddr, phy_id, 5)
-                                  );
-                       if (!(baseline_1 & 0x20)  && (new_1 & 0x20)) {
-                               int lkpar = mdio_read(ioaddr, phy_id, 5);
-                               printf("   New link partner capability is %4.4x %4.4x:",
-                                          lkpar, mdio_read(ioaddr, phy_id, 6));
-                               switch (lkpar) {
-                               case 0x45e1: printf(" 10/100 switch w/ flow control"); break;
-                               case 0x41e1: printf(" 10/100 HD+FD switch"); break;
-                               case 0x40a1: printf(" 10/100 bridged repeater"); break;
-                               case 0x4081: printf(" 100baseTx repeater w/autonegotation");
-                                       break;
-                               case 0x0081: printf(" 100baseTx (no autonegotation)"); break;
-                               case 0x4021: printf(" 10baseT repeater w/autonegotation");
-                                       break;
-                               case 0x0021: printf(" 10baseT (no autonegotation)"); break;
-                               default:
-                                       for (i = 9; i >= 5; i--)
-                                               if (lkpar & (1<<i))
-                                                       printf(" %s", media_names[i-5]);
-                               }
-                               printf(".\n");
-                       }
-                       fflush(stdout);
-                       baseline_1 = new_1;
-                       last_event = 0;
-               }
-               sleepval.tv_sec = 0;
-               sleepval.tv_usec = last_event++ > 30 ? 200000 : 1000;
-               select(0, 0, 0, 0, &sleepval);                  /* Or just sleep(1); */
-       }
-       printf("  Value of MII BMSR (basic mode status register) is %4.4x.\n",
-                  mdio_read(ioaddr, phy_id, 1));
-       return 0;
-}
-\f
-/* Emit transceiver-specific info. */
-
-struct msg_tbl { int bitmask;  char *msg; };
-
-static void msg_if_set(const int val, const struct msg_tbl msg_tbl[])
-{
-       int i;
-       for (i = 0; msg_tbl[i].bitmask; i++)
-               if (msg_tbl[i].bitmask & val)
-                       printf(" %s\n", msg_tbl[i].msg);
-}
-
-static void msg_if_set_fmt(const int val, const struct msg_tbl msg_tbl[],
-                                                  const char *fmt)
-{
-       int i;
-       for (i = 0; msg_tbl[i].bitmask; i++)
-               if (msg_tbl[i].bitmask & val)
-                       printf(fmt, msg_tbl[i].msg);
-}
-
-static void qs6612(long ioaddr, int phy_id)
-{
-       printf("  QS6612 extra registers: Mode %4.4x.\n"
-                  "    Interrupt source %4.4x, mask %4.4x.\n"
-                  "    PHY control %4.4x.\n",
-                  mii_val[17], mii_val[29], mii_val[30], mii_val[31]);
-       return;
-}
-
-static void ns83843(long ioaddr, int phy_id)
-{
-       printf("  NatSemi 83843 extra registers:\n"
-                  "    PHY status %4.4x\n"
-                  "    %s link, %d Mb/sec %s duplex\n"
-                  "    MII interrupts %sabled, %s pending.\n"
-                  "    Events since last read\n"
-                  "     Link disconnects %d\n"
-                  "     False carriers %d\n"
-                  "     Receive errors %d\n"
-                  "    Link beat is currently %sstable\n",
-                  mii_val[0x10],
-                  mii_val[10] & 0x0001 ? "Valid" : "Invalid",
-                  mii_val[10] & 0x0002 ? 10 : 100, 
-                  mii_val[10] & 0x0004 ? "full" : "half", 
-                  mii_val[0x11] & 0x0002 ? "en":"dis",
-                  mii_val[0x10] & 0x0100 ? "interrupt": "none",
-                  mii_val[0x13], mii_val[0x14], mii_val[0x15],
-                  mii_val[0x16] & 0x0010 ? "UN" : "");
-       return;
-}
-static void smsc83c180(long ioaddr, int phy_id)
-{
-       int mii_reg25 = mii_val[25];
-       printf("  SMSC 83c180 extra registers:\n"
-                  "    Auto-negotiation status 0x%4.4x.\n"
-                  "      10baseT polarity is %s.\n"
-                  "      PHY address is %d.\n"
-                  "      Auto-negotiation %scomplete, 1%s0Mbps %s duplex.\n"
-                  "    Rx symbol errors since last read %d.\n",
-                  mii_reg25,
-                  mii_reg25 & 0x2000 ? "normal" : "reversed",
-                  (mii_reg25>>8) & 0x1F,
-                  mii_reg25 & 0x0080 ? "did not " : "",
-                  mii_reg25 & 0x0020 ? "0" : "",
-                  mii_reg25 & 0x0040 ? "full" : "half",
-                  mdio_read(ioaddr, phy_id, 26));
-       return;
-}
-
-static const char *tdk_events[8] = {
-       "Jabber", "Rx error", "Negotiation page received", "Link detection fault",
-       "Link partner acknowledge", "Link status change", "Remote partner fault",
-       "Auto-Negotiation complete"};
-
-static const struct msg_tbl tdk_reg16[] = {
-       {0x8000, " Transceiver is in repeater mode!"},
-       {0x4000, " Interrupt pin set to active high."},
-       {0x2000, " Reserved bit 12 is unexpectedly set."},
-       {0x1000, " Transmit pins are internally disconnected."},
-       {0x0800, " 10baseT signal quality test is disabled."},
-       {0x0400, " 10baseT loopback mode."},
-       {0, 0},
-};
-
-static void tdk78q2120(long ioaddr, int phy_id)
-{
-       int mii_reg16 = mii_val[16];
-       int mii_reg17 = mii_val[17];
-       int mii_reg18 = mii_val[18];
-       int i;
-       printf("  TDK format vendor-specific registers 16..18 are "
-                  "0x%4.4x 0x%4.4x 0x%4.4x\n", mii_reg16, mii_reg17, mii_reg18);
-       printf("      Link polarity is %s %s.\n"
-                  "%s%s"
-                  "      Auto-negotiation %s, 1%s0Mbps %s duplex.\n"
-                  "      Rx link in %s state, PLL %s.\n",
-                  mii_reg16 & 0x0020 ? "OVERRIDDEN to" : "detected as",
-                  mii_reg16 & 0x0010 ? "reversed" : "normal",
-                  mii_reg16 & 0x0002 ?
-                  "     100baseTx Coding and scrambling is disabled!\n":"",
-                  mii_reg16 & 0x0001 ? "     Rx_CLK power-save mode is enabled!\n":"",
-                  mii_reg18 & 0x1000 ? "had no common media" : "complete",
-                  mii_reg18 & 0x0400 ? "0" : "",
-                  mii_reg18 & 0x0800 ? "full" : "half",
-                  mii_reg18 & 0x0200 ? "pass" : "fail",
-                  mii_reg18 & 0x0100 ? "slipped since last read" : "locked");
-
-       msg_if_set(mii_reg16, tdk_reg16);
-       if (mii_reg17 & 0x00ff) {
-               printf("      Events since last read:");
-               for (i = 0; i < 8; i++)
-                       if (mii_reg17 & (1 << i))
-                               printf("  %s", tdk_events[i]);
-       } else
-               printf("      No new link status events.");
-
-       if (mii_reg17 & 0xff00) {
-               printf("\n      Events that will raise an interrupt:");
-               for (i = 0; i < 8; i++)
-                       if (mii_reg17 & (0x100 << i))
-                               printf("  %s", tdk_events[i]);
-       }
-       printf("\n");
-       return;
-}
-
-static void davicom_dm9101(long ioaddr, int phy_id)
-{
-       printf("  Davicom vendor specific registers: 0x%4.4x 0x%4.4x 0x%4.4x.\n",
-                  mii_val[16], mii_val[17], mii_val[18]);
-}
-static void intel_i553(long ioaddr, int phy_id)
-{
-       printf("  This transceiver is 100baseT4 only!  Register 16 is %4.4x.\n",
-                  mii_val[16]);
-}
-/* http://www.enablesemi.com/cgi-bin/byteserve/Products/Docs/3VCardBus.pdf */
-static void enablesemi(long ioaddr, int phy_id)
-{
-       printf("  Isolated %d times, %d false carrier events, %d Rx errors.\n",
-                  mii_val[18], mii_val[19], mii_val[21]);
-       printf("  Cable polarity is %s, 100Mb PLL is %slocked.\n",
-                  mii_val[28]&0x8000 ? "reversed" : "normal",
-                  mii_val[27]&0x2000 ? "" : "un");
-}
-/* The amd79c901 contains both PNA and 10/100 management registers.
-   http://www.amd.com/products/npd/techdocs/22304.pdf
-*/
-static void amd_pna(long ioaddr, int phy_id)
-{
-       printf("  HomePNA transceiver in %s speed, %s power mode.\n",
-                  mii_val[16] & 4 ? "high" : "low",
-                  mii_val[16] & 2 ? "high" : "low");
-       printf("  HomePNA noise level %d, peak power %d..\n",
-                  mii_val[25] >> 8, mii_val[25] & 0xff);
-}
-static void amd_tx(long ioaddr, int phy_id)
-{
-       int mii_reg25 = mii_val[25];
-       printf("  AMD vendor specific registers: 0x%4.4x 0x%4.4x 0x%4.4x.\n",
-                  mii_val[16], mii_val[17], mii_val[18]);
-       printf("  The link is %s in 10%s %s duplex mode, autonegotiation state "
-                  "has%s changed.\n",
-                  mii_reg25 & 8 ? "up" : "down",
-                  mii_reg25 & 1 ? "0baseTx" : "baseT",
-                  mii_reg25 & 4 ? "full" : "half",
-                  mii_reg25 & 2 ? "" : " not");
-}
-
-static const struct msg_tbl admtek_reg21[] = {
-       {0x4000, " Link test diabled: Ignoring lack of 10baseT link beat."},
-       {0x2000, " Link forced up."},
-       {0x1000, " Tx jabber check disabled."},
-       {0x0080, " Transmitting 'Far End Fault'!"},
-       {0x0040, " Rx error count full."},
-       {0x0008, " Remote loop back enabled."},
-       {0, 0},
-};
-
-static void admtek(long ioaddr, int phy_id)
-{
-
-       printf("  ADMtek vendor specific registers information:\n"
-                  "   Cable length is approximately %d meters.\n"
-                  "   The receiver has lost lock %d times since last check and "
-                  "had %d error events.\n",
-                  ((mii_val[20] & 0x00f0) >> 4)*10,
-                  mii_val[23], mii_val[23]);
-       msg_if_set(mii_val[21], admtek_reg21);
-       tdk78q2120(ioaddr, phy_id);
-}
-
-static void lu3x31(long ioaddr, int phy_id)
-{
-       printf("  Lucent vendor specific registers 17: 0x%4.4x"
-                  " 29: 0x%4.4x 30: 0x%4.4x 31: 0x%4.4x.\n",
-                  mii_val[17], mii_val[29], mii_val[30], mii_val[31]);
-}
-
-static const struct msg_tbl myson_reg16[] = {
-       {0x0080, " Far end fault enabled."},
-       {0x0040, " Transformer ratio 1.25:1."},
-       {0x0020, " Polarity correction diabled."},
-       {0x0010, " Link is forced up regardless of link beat."},
-       {0x0004, " Bypass Jabber check."},
-       {0x0001, " 100baseFx mode selected."},
-       {0, 0},
-};
-
-static void myson981(long ioaddr, int phy_id)
-{
-       int i, mii_reg17 = mii_val[17];
-
-       printf("  Myson mtd981 extra registers: %4.4x %4.4x %4.4x %4.4x.\n",
-                  mii_val[16], mii_val[17], mii_val[18], mii_val[19]);
-       msg_if_set(mii_val[16] & 0xC800, tdk_reg16);
-       msg_if_set(mii_val[16], myson_reg16);
-
-       if (mii_reg17 & 0x00ff) {
-               printf("      Events since last read:");
-               for (i = 0; i < 8; i++)
-                       if (mii_reg17 & (1 << i))
-                               printf("  %s", tdk_events[i]);
-       } else
-               printf("      No new link status events.");
-       if (mii_reg17 & 0xff00) {
-               printf("\n      Events that will raise an interrupt:");
-               for (i = 0; i < 8; i++)
-                       if (mii_reg17 & (0x100 << i))
-                               printf("  %s", tdk_events[i]);
-       }
-       printf("\n");
-
-       return;
-}
-
-/* These are much like the TDK events in reversed order. */
-static const struct msg_tbl via_reg17[] = {
-       {0x0001, "Auto-Negotiation complete"},
-       {0x0002, "Remote fault detected"},
-       {0x0004, "Link failure detected"},
-       {0x0008, "Bad Start Stream detected"},
-       {0x0010, "Parallel detection fault"},
-       {0x0020, "Extended negotiation page received"},
-       {0x0040, "5B/4B code error detected"},
-       {0x0080, "Jabber detected"},
-       {0, 0},
-};
-
-static void via_tahoe(long ioaddr, int phy_id)
-{
-       int mii_reg16 = mii_val[16];
-       int mii_reg17 = mii_val[17];
-       int mii_reg18 = mii_val[18];
-
-       printf("  VIA Tahoe extended registers: 16 %4.4x  #17 %4.4x  #18 %4.4x.\n",
-                  mii_reg16, mii_reg17, mii_reg18);
-       msg_if_set_fmt(mii_reg17, via_reg17, "   %s\n");
-       printf("   Link %s 10%s Mbps %s duplex\n",
-                  mii_reg18 & 0x2000 ? "up" : "down",
-                  mii_reg18 & 0x0400 ? "0" : "",
-                  mii_reg18 & 0x0800 ? "full" : "half");
-}
-
-/* Information from
-   http://www.via.com.tw/en/datasheet/DS6103110.pdf
-*/
-   
-static void via_vt6103(long ioaddr, int phy_id)
-{
-       printf("  VIA vt6103 error counts since the last check:\n"
-                  "   The link has failed %d times.\n"
-                  "   The receiver has lost lock %d times.\n"
-                  "   There have been %d false carrier/SQE error.\n",
-                  mii_val[21], mii_val[22], mii_val[23]);
-}
-
-/* Information from
-   http://www.via.com.tw/en/Networking/DS6105LOM100.pdf
-*/
-
-static void via_vt6105(long ioaddr, int phy_id)
-{
-       printf("  VIA vt6105 PHY status:\n"
-                  "   Duplex %s  speed %s\n",
-                  mii_val[20] & 0x0001 ? "full" : "half",
-                  mii_val[20] & 0x0002 ? "100" : "10");
-}
-
-/* Information from
-   http://www.via.com.tw/en/Networking/DS6105LOM100.pdf
-*/
-static void intel(long ioaddr, int phy_id)
-{
-       printf("  Intel 8255* PHY #%d extended management registers:\n"
-                  "    Error counts, cleared when read:\n"
-                  "     False carriers %d\n"
-                  "     Link disconnects %d\n"
-                  "     Receive errors %d\n"
-                  "     Rx symbol errors %d.\n"
-                  "     Rx 10Mbps Early End-Of-Frame errors %d.\n"
-                  "     Rx 100Mbps Early End-Of-Frame errors %d.\n"
-                  "     Tx jabber errors %d.\n",
-                  mii_val[18],
-                  mii_val[19], mii_val[20], mii_val[21], mii_val[22], mii_val[23],
-                  mii_val[24], mii_val[25]);
-}
-
-\f
-/*
- * Local variables:
- *  compile-command: "cc -O -Wall -c libmii.c"
- *  c-indent-level: 4
- *  c-basic-offset: 4
- *  tab-width: 4
- * End:
- */
diff --git a/sys-apps/mii-diag/files/mii-diag.8-2.11 b/sys-apps/mii-diag/files/mii-diag.8-2.11
deleted file mode 100644 (file)
index 30f4d59..0000000
+++ /dev/null
@@ -1,160 +0,0 @@
-.\"                                      Hey, EMACS: -*- nroff -*-
-.\" $Revision: 1.1 $ $Date: 2005/06/12 20:34:36 $
-.\" First parameter, NAME, should be all caps
-.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
-.\" other parameters are allowed: see man(7), man(1)
-.TH MII-DIAG 8 "September 9, 2003" "Scyld Beowulf\*(Tm"
-.\" Please adjust this date whenever revising the manpage.
-.\"
-.\" Some roff macros, for reference:
-.\" .nh        disable hyphenation
-.\" .hy        enable hyphenation
-.\" .ad l      left justify
-.\" .ad b      justify to both left and right margins
-.\" .nf        disable filling
-.\" .fi        enable filling
-.\" .br        insert line break
-.\" .sp <n>    insert n+1 empty lines
-.\" for manpage-specific macros, see man(7)
-.SH NAME
-mii-diag \- Network adapter control and monitoring
-.SH SYNOPSIS
-.B mii-diag
-.RI [ options ] <interface>
-.SH DESCRIPTION
-This manual page documents briefly the
-.B mii-diag
-network adapter control and monitoring command.
-Addition documentation is available from http://scyld.com/diag/index.html.
-
-.\" TeX users may be more comfortable with the \fB<whatever>\fP and
-.\" \fI<whatever>\fP escape sequences to invoke bold face and italics, 
-.\" respectively.
-.PP
-This \fBmii-diag\fP command configures, controls and monitors the
-transceiver management registers for network interfaces, and configures
-driver operational parameters.  For transceiver control \fBmii-diag\fP
-uses the Media Independent Interface (MII) standard (thus the command name).
-It also has additional Linux-specific controls to communicate parameters
-such as message enable settings and buffer sizes to the underlying device
-driver.
-.PP
-The MII standard defines registers that control and report network
-transceiver capabilities, link settings and errors.  Examples are link
-speed, duplex, capabilities advertised to the link partner, status LED
-indications and link error counters.
-
-.SH OPTIONS
-The \fBmii-diag\fP command supports both single character and long
-option names.  Short options use a single dash (´-´) in front of the option
-character.  For options without parameters, multiple options may be
-concatenated after a single dash.  Long options are prefixed by two
-dashes (´--´), and may be abbreviated with a unique prefix.
-A long option may take a parameter of the form --arg=param or --arg param.
-
-.PP
-A summary of options is as follows.
-
-.TP
-.B \-A, --advertise <speed|setting>
-.BR
-.B \-F, --fixed-speed <speed|setting>
-
-Speed is one of: 100baseT4, 100baseTx, 100baseTx-FD, 100baseTx-HD, 10baseT,
-10baseT-FD, 10baseT-HD.  For more precise control an explict numeric
-register setting is also allowed.
-
-
-.TP
-.B \-a, \--all-interfaces
-Show the status of all interfaces.  This option is not recommended with
-any other option, especially ones that change settings.
-
-.TP
-.B \-s,\--status
-Return exit status 2 if there is no link beat.
-
-.TP
-.B \-D
-Increase the debugging level.  This may be used to understand the
-actions the command is taking.
-
-.TP
-.B \-g, \--read-parameters
-Show driver-specific parameters.
-
-.TP
-.B \-G, \--set-parameters value[,value...]
-Set driver-specific parameters.
-Set a adapter-specific parameters.
-Parameters are comma separated, with missing elements retaining the
-existing value.
-
-.TP
-.B \-v
-Increase the verbosity level.  Additional "-v" options increase the
-level further.
-
-.TP
-.B \-V
-Show the program version information.
-
-.TP
-.B \-w, \--watch
-Continuously monitor the transceiver and report changes.
-
-.TP
-.B \-?
-Emit usage information.
-
-.SH DESCRIPTION
-
-.PP
-Calling the command with just the interface name (which defaults to
-'eth0' if missing) produces extensive output describing the transceiver
-capabilities, configuration and current status.
-
-.PP
-The '--monitor' option allows scripting link beat changes.
-.PP
-This option is similar to --watch, but with lower overhead and simplifed
-output.  It polls the interface only once a second and the output format
-is a single line per link change with three fixed words
-  <unknown|down||negotiating|up> <STATUS> <PARTNER-CAP>
-.PP
-Example output:  mii-diag --monitor eth0
-   down         0x7809 0x0000
-   negotiating  0x7829 0x45e1
-   up           0x782d 0x45e1
-   down         0x7809 0x0000
-
-.PP
-This may be used as
-  mii-diag --monitor eth0 |
-    while read linkstatus bmsr linkpar; do
-     case $linkstatus in
-        up)   ifup eth0 ;;
-        down) ifdown eth0 ;;
-     esac
-    done
-
-.PP
-It may be useful to shorten the DHCP client daemon timeout if it does
-not receive an address by adding the following setting to
-/etc/sysconfig/network:
-DHCPCDARGS="-t 3"
-
-.SH SEE ALSO
-.BR ether-wake (8), net-diag (8), mii-tool (8).
-.br
-Addition documentation is available from http://scyld.com/diag/index.html.
-
-.SH KNOWN BUGS
-The --all-interfaces option is quirky.  There are very few settings that
-are usefully applied to all interfaces.
-
-.SH AUTHOR
-The manual pages, diagnostic commands, and many of the underlying Linux
-network drivers were written by Donald Becker for the Scyld
-Beowulf(\*(Tm) cluster system.
-
diff --git a/sys-apps/mii-diag/files/mii-diag.c-2.09 b/sys-apps/mii-diag/files/mii-diag.c-2.09
deleted file mode 100644 (file)
index 0f05a5f..0000000
+++ /dev/null
@@ -1,650 +0,0 @@
-/* Mode: C;
- * mii-diag.c: Examine and set the MII registers of a network interfaces.
-
-       Usage:  mii-diag [-vw] interface.
-
-       This program reads and writes the Media Independent Interface (MII)
-       management registers on network transceivers.  The registers control
-       and report network link settings and errors.  Examples are link speed,
-       duplex, capabilities advertised to the link partner, status LED
-       indications and link error counters.
-
-       Notes:
-       The compile-command is at the end of this source file.
-       This program works with drivers that implement MII ioctl() calls.
-
-       Written/copyright 1997-2003 by Donald Becker <becker@scyld.com>
-
-       This program is free software; you can redistribute it
-       and/or modify it under the terms of the GNU General Public
-       License as published by the Free Software Foundation.
-
-       The author may be reached as becker@scyld.com, or C/O
-        Scyld Computing Corporation
-        914 Bay Ridge Road, Suite 220
-        Annapolis MD 21403
-
-       References
-       http://scyld.com/expert/mii-status.html
-       http://scyld.com/expert/NWay.html
-       http://www.national.com/pf/DP/DP83840.html
-*/
-
-static char version[] =
-"mii-diag.c:v2.09 9/06/2003 Donald Becker (becker@scyld.com)\n"
-" http://www.scyld.com/diag/index.html\n";
-
-static const char usage_msg[] =
-"Usage: %s [--help] [-aDfrRvVw] [-AF <speed+duplex>] [--watch] <interface>.\n";
-static const char long_usage_msg[] =
-"Usage: %s [-aDfrRvVw] [-AF <speed+duplex>] [--watch] <interface>.
-
-  This program configures and monitors the transceiver management registers
-  for network interfaces.  It uses the Media Independent Interface (MII)
-  standard with additional Linux-specific controls to communicate with the
-  underlying device driver.  The MII registers control and report network
-  link settings and errors.  Examples are link speed, duplex, capabilities
-  advertised to the link partner, status LED indications and link error
-  counters.
-
-   The common usage is
-      mii-diag eth0
-
-   The default interface is \"eth0\".
- Frequently used options are
-   -A  --advertise <speed|setting>
-   -F  --fixed-speed <speed>
-       Speed is one of: 100baseT4, 100baseTx, 100baseTx-FD, 100baseTx-HD,
-                        10baseT, 10baseT-FD, 10baseT-HD
-   -s  --status     Return exit status 2 if there is no link beat.
-
- Less frequently used options are
-   -a  --all-interfaces  Show the status all interfaces
-              (Not recommended with options that change settings.)
-   -D  --debug
-   -g  --read-parameters       Get driver-specific parameters.
-   -G  --set-parameters PARMS  Set driver-specific parameters.
-       Parameters are comma separated, missing elements retain existing value.
-   -M  --msg-level LEVEL       Set the driver message bit map.
-   -p  --phy ADDR              Set the PHY (MII address) to report.
-   -r  --restart       Restart the link autonegotiation.
-   -R  --reset         Reset the transceiver.
-   -v  --verbose       Report each action taken.
-   -V  --version       Emit version information.
-   -w  --watch         Continuously monitor the transceiver and report changes.
-
-   This command returns success (zero) if the interface information can be
-   read.  If the --status option is passed, a zero return means that the
-   interface has link beat.
-";
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <getopt.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <net/if.h>
-#ifdef use_linux_libc5
-#include <linux/if_arp.h>
-#include <linux/if_ether.h>
-#endif
-
-typedef unsigned short u16;
-typedef unsigned int u32;
-
-#if defined(SIOCGPARAMS)  && SIOCGPARAMS != SIOCDEVPRIVATE+3
-#error Changed definition for SIOCGPARAMS
-#else
-#define SIOCGPARAMS (SIOCDEVPRIVATE+3)                 /* Read operational parameters. */
-#define SIOCSPARAMS (SIOCDEVPRIVATE+4)                 /* Set operational parameters. */
-#endif
-
-const char shortopts[] = "aA:C:DfF:gG:hmM:p:rRsvVw?";
-struct option longopts[] = {
- /* { name  has_arg  *flag  val } */
-    {"all-interfaces", 0, 0, 'a'},     /* Show all interfaces. */
-       {"advertise",   1, 0, 'A'},             /* Change the capabilities advertised. */
-       {"BMCR",                1, 0, 'C'},             /* Set the control register. */
-    {"debug",       0, 0, 'D'},                /* Increase the debug level. */
-    {"force",       0, 0, 'f'},                /* Force the operation. */
-    {"fixed-speed", 1, 0, 'F'},                /* Fixed speed name. */
-    {"read-parameters", 0, 0, 'g'}, /* Show general settings values. */
-    {"set-parameters",  1, 0, 'G'},    /* Write general settings values. */
-    {"help",           0, 0, 'h'},             /* Print a long usage message. */
-    {"monitor",                0, 0, 'm'},             /* Monitor status register. */
-    {"msg-level",      1, 0, 'M'},             /* Set the driver message level. */
-    {"phy",                    1, 0, 'p'},             /* Set the PHY (MII address) to report. */
-    {"restart",                0, 0, 'r'},             /* Restart the link negotiation */
-    {"reset",          0, 0, 'R'},             /* Reset the transceiver. */
-    {"status",         0, 0, 's'},             /* Non-zero exit status w/ no link beat. */
-    {"verbose",        0, 0, 'v'},             /* Report each action taken.  */
-    {"version",        0, 0, 'V'},             /* Emit version information.  */
-    {"watch",          0, 0, 'w'},             /* Constantly monitor the port.  */
-    {"error",          0, 0, '?'},             /* Return the error message. */
-    { 0, 0, 0, 0 }
-};
-
-/* Usually in libmii.c, but trivial substitions are below. */
-extern int  show_mii_details(long ioaddr, int phy_id);
-extern void monitor_mii(long ioaddr, int phy_id);
-
-/* Command-line flags. */
-unsigned int opt_a = 0,                                        /* Show-all-interfaces flag. */
-       opt_f = 0,                                      /* Force the operation. */
-       opt_g = 0,
-       opt_G = 0,
-       verbose = 0,                            /* Verbose flag. */
-       debug = 0,
-       opt_version = 0,
-       opt_restart = 0,
-       opt_reset = 0,
-       opt_status = 0,
-       opt_watch = 0;
-static int msg_level = -1;
-static int set_BMCR = -1;
-static int nway_advertise = 0;
-static int fixed_speed = -1;
-static int override_phy = -1;
-char *opt_G_string = NULL;
-
-/* Internal values. */
-int new_ioctl_nums;
-int skfd = -1;                                 /* AF_INET socket for ioctl() calls.    */
-struct ifreq ifr;
-
-int do_one_xcvr(int skfd);
-int show_basic_mii(long ioaddr, int phy_id);
-int mdio_read(int skfd, int phy_id, int location);
-void mdio_write(int skfd, int phy_id, int location, int value);
-static int parse_advertise(const char *capabilities);
-static void monitor_status(long ioaddr, int phy_id);
-
-
-int
-main(int argc, char **argv)
-{
-       int c, errflag = 0;
-       char **spp, *ifname;
-    char *progname = rindex(argv[0], '/') ? rindex(argv[0], '/')+1 : argv[0];
-
-       while ((c = getopt_long(argc, argv, shortopts, longopts, 0)) != EOF)
-               switch (c) {
-               case 'a': opt_a++; break;
-               case 'A': nway_advertise |= parse_advertise(optarg);
-                       if (nway_advertise == -1) errflag++;
-                       break;
-               case 'C': set_BMCR = strtoul(optarg, NULL, 16); break;
-               case 'D': debug++;                      break;
-               case 'f': opt_f++; break;
-               case 'F': fixed_speed = parse_advertise(optarg);
-                       if (fixed_speed == -1) errflag++;
-                       break;
-               case 'g': opt_g++; break;
-               case 'G': opt_G++; opt_G_string = strdup(optarg); break;
-               case 'm': opt_watch++; opt_status++; break;
-               case 'M': msg_level = strtoul(optarg, NULL, 0); break;
-               case 'h': fprintf(stderr, long_usage_msg, progname); return 0;
-               case 'p': override_phy = atoi(optarg); break;
-               case 'r': opt_restart++;        break;
-               case 'R': opt_reset++;          break;
-               case 's': opt_status++;         break;
-               case 'v': verbose++;            break;
-               case 'V': opt_version++;        break;
-               case 'w': opt_watch++;          break;
-               case '?': errflag++;            break;
-               }
-       if (errflag) {
-               fprintf(stderr, usage_msg, progname);
-               return 2;
-       }
-
-       if (verbose || opt_version)
-               printf(version);
-
-       /* Open a basic socket. */
-       if ((skfd = socket(AF_INET, SOCK_DGRAM,0)) < 0) {
-               perror("socket");
-               return 1;
-       }
-
-       if (debug)
-               fprintf(stderr, "DEBUG: argc=%d, optind=%d and argv[optind] is %s.\n",
-                               argc, optind, argv[optind]);
-
-       /* No remaining args means show all interfaces. */
-       if (optind == argc) {
-               ifname = "eth0";
-               fprintf(stderr, "Using the default interface 'eth0'.\n");
-       } else {
-               /* Copy the interface name. */
-               spp = argv + optind;
-               ifname = *spp++;
-       }
-
-       if (ifname == NULL) {
-               ifname = "eth0";
-               fprintf(stderr, "Using the default interface 'eth0'.\n");
-       }
-
-       /* Verify that the interface supports the ioctl(), and if
-          it is using the new or old SIOCGMIIPHY value (grrr...).
-        */
-       {
-               u16 *data = (u16 *)(&ifr.ifr_data);
-
-               strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
-               data[0] = 0;
-
-               if (ioctl(skfd, 0x8947, &ifr) >= 0) {
-                       new_ioctl_nums = 1;
-               } else if (ioctl(skfd, SIOCDEVPRIVATE, &ifr) >= 0) {
-                       new_ioctl_nums = 0;
-               } else {
-                       fprintf(stderr, "SIOCGMIIPHY on %s failed: %s\n", ifname,
-                                       strerror(errno));
-                       (void) close(skfd);
-                       return 1;
-               }
-               if (verbose)
-                       printf("  Using the %s SIOCGMIIPHY value on PHY %d "
-                                  "(BMCR 0x%4.4x).\n",
-                                  new_ioctl_nums ? "new" : "old", data[0], data[3]);
-       }
-
-       do_one_xcvr(skfd);
-
-       (void) close(skfd);
-       return 0;
-}
-
-int do_one_xcvr(int skfd)
-{
-       u16 *data = (u16 *)(&ifr.ifr_data);
-       u32 *data32 = (u32 *)(&ifr.ifr_data);
-       unsigned phy_id = data[0];
-
-       if (override_phy >= 0) {
-               printf("Using the specified MII PHY index %d.\n", override_phy);
-               phy_id = override_phy;
-       }
-
-       if (opt_g || opt_G || msg_level >= 0) {
-               if (ioctl(skfd, SIOCGPARAMS, &ifr) < 0) {
-                       fprintf(stderr, "SIOCGPARAMS on %s failed: %s\n", ifr.ifr_name,
-                                       strerror(errno));
-                       return -1;
-               }
-       }
-       if (opt_g) {
-               int i;
-               printf("Driver general parameter settings:");
-               for (i = 0; i*sizeof(u32) < sizeof(ifr.ifr_ifru); i++) {
-                       printf(" %d", data32[i]);
-               }
-               printf(".\n");
-       }
-       if (opt_G) {
-               /* Set up to four arbitrary driver parameters from the -G parameter.
-                  The format is comma separated integers, with a missing element
-                  retaining the previous value.
-               */
-               char *str = opt_G_string;
-               int i;
-               for (i = 0; str && i < 4; i++) {
-                       char *endstr;
-                       u32 newval = strtol(str, &endstr, 0);
-                       if (debug)
-                               printf(" parse string '%s'  value %d end '%s'.\n",
-                                          str, newval, endstr);
-                       if (str == endstr) {
-                               if (endstr[0] == ',') /* No parameter */
-                                       str = endstr+1;
-                               else {
-                                       fprintf(stderr, "Invalid driver parameter '%s'.\n", str);
-                                       str = index(str, ',');
-                               }
-                       } else if (endstr[0] == ',') {
-                               data32[i] = newval;
-                               str = endstr + 1;
-                       } else if (endstr[0] == 0) {
-                               data32[i] = newval;
-                               break;
-                       }
-               }
-               printf("Setting new driver general parameters:");
-               for (i = 0; i*sizeof(u32) < sizeof(ifr.ifr_ifru); i++) {
-                       printf(" %d", data32[i]);
-               }
-               printf(".\n");
-               if (ioctl(skfd, SIOCSPARAMS, &ifr) < 0) {
-                       fprintf(stderr, "SIOCSPARAMS on %s failed: %s\n", ifr.ifr_name,
-                                       strerror(errno));
-                       return -1;
-               }
-       }
-       if (msg_level >= 0) {
-               data32[0] = msg_level;
-               if (ioctl(skfd, SIOCSPARAMS, &ifr) < 0) {
-                       fprintf(stderr, "SIOCSPARAMS on %s failed: %s\n", ifr.ifr_name,
-                                       strerror(errno));
-                       return -1;
-               }
-       }
-
-       if (opt_reset) {
-               printf("Resetting the transceiver...\n");
-               mdio_write(skfd, phy_id, 0, 0x8000);
-       }
-       /* Note: PHY addresses > 32 are pseudo-MII devices, usually built-in. */
-       if (phy_id < 64  &&  nway_advertise > 0) {
-               printf(" Setting the media capability advertisement register of "
-                          "PHY #%d to 0x%4.4x.\n", phy_id, nway_advertise | 1);
-               mdio_write(skfd, phy_id, 4, nway_advertise | 1);
-               mdio_write(skfd, phy_id, 0, 0x1000);
-       }
-
-       if (opt_restart) {
-               printf("Restarting negotiation...\n");
-               mdio_write(skfd, phy_id, 0, 0x0000);
-               mdio_write(skfd, phy_id, 0, 0x1200);
-       }
-       /* To force 100baseTx-HD do  mdio_write(skfd, phy_id, 0, 0x2000); */
-       if (fixed_speed >= 0) {
-               int reg0_val = 0;
-               if (fixed_speed & 0x0180)               /* 100mpbs */
-                       reg0_val |=  0x2000;
-               if ((fixed_speed & 0x0140) &&           /* A full duplex type and */
-                       ! (fixed_speed & 0x0820))               /* no half duplex types. */
-                       reg0_val |= 0x0100;
-               printf("Setting the speed to \"fixed\", Control register %4.4x.\n",
-                          reg0_val);
-               mdio_write(skfd, phy_id, 0, reg0_val);
-       }
-       if (set_BMCR >= 0) {
-               printf("Setting the Basic Mode Control Register to 0x%4.4x.\n",
-                          set_BMCR);
-               mdio_write(skfd, phy_id, 0, set_BMCR);
-       }
-
-       if (opt_watch && opt_status)
-               monitor_status(skfd, phy_id);
-
-       show_basic_mii(skfd, phy_id);
-#ifdef LIBMII
-       if (verbose)
-               show_mii_details(skfd, phy_id);
-#else
-       if (verbose || debug) {
-               int mii_reg, mii_val;
-               printf(" MII PHY #%d transceiver registers:", phy_id);
-               for (mii_reg = 0; mii_reg < 32; mii_reg++) {
-                       mii_val = mdio_read(skfd, phy_id, mii_reg);
-                       printf("%s %4.4x", (mii_reg % 8) == 0 ? "\n  " : "",
-                                  mii_val);
-               }
-               printf("\n");
-       }
-#endif
-
-       if (opt_watch)
-               monitor_mii(skfd, phy_id);
-       if (opt_status &&
-               (mdio_read(skfd, phy_id, 1) & 0x0004) == 0)
-               exit(2);
-       return 0;
-}
-
-int mdio_read(int skfd, int phy_id, int location)
-{
-       u16 *data = (u16 *)(&ifr.ifr_data);
-
-       data[0] = phy_id;
-       data[1] = location;
-
-       if (ioctl(skfd, new_ioctl_nums ? 0x8948 : SIOCDEVPRIVATE+1, &ifr) < 0) {
-               fprintf(stderr, "SIOCGMIIREG on %s failed: %s\n", ifr.ifr_name,
-                               strerror(errno));
-               return -1;
-       }
-       return data[3];
-}
-
-void mdio_write(int skfd, int phy_id, int location, int value)
-{
-       u16 *data = (u16 *)(&ifr.ifr_data);
-
-       data[0] = phy_id;
-       data[1] = location;
-       data[2] = value;
-
-       if (ioctl(skfd, new_ioctl_nums ? 0x8949 : SIOCDEVPRIVATE+2, &ifr) < 0) {
-               fprintf(stderr, "SIOCSMIIREG on %s failed: %s\n", ifr.ifr_name,
-                               strerror(errno));
-       }
-}
-
-/* Parse the command line argument for advertised capabilities. */
-static int parse_advertise(const char *capabilities)
-{
-       const char *mtypes[] = {
-               "100baseT4", "100baseTx", "100baseTx-FD", "100baseTx-HD",
-               "10baseT", "10baseT-FD", "10baseT-HD", 0,
-       };
-       char *endptr;
-       int cap_map[] = { 0x0200, 0x0180, 0x0100, 0x0080, 0x0060, 0x0040, 0x0020,};
-       int i;
-       if ( ! capabilities) {
-               fprintf(stderr, "You passed -A 'NULL'.  You must provide a media"
-                               " list to advertise!\n");
-               return -1;
-       }
-       if (debug)
-               fprintf(stderr, "Advertise string is '%s'.\n", capabilities);
-       for (i = 0; mtypes[i]; i++)
-               if (strcasecmp(mtypes[i], capabilities) == 0)
-                       return cap_map[i];
-       if ((i = strtol(capabilities, &endptr, 16)) <= 0xffff  &&  endptr[0] == 0)
-               return i;
-       fprintf(stderr, "Invalid media advertisement value '%s'.\n"
-                       "  Either pass a numeric value or one of the following names:\n",
-                       capabilities);
-       for (i = 0; mtypes[i]; i++)
-               fprintf(stderr, "   %-14s %3.3x\n", mtypes[i], cap_map[i]);
-       return -1;
-}
-
-/* Trivial versions if we don't link against libmii.c */
-static const char *media_names[] = {
-       "10baseT", "10baseT-FD", "100baseTx", "100baseTx-FD", "100baseT4",
-       "Flow-control", 0,
-};
-/* Various non-good bits in the command register. */
-static const char *bmcr_bits[] = {
-       "  Internal Collision-Test enabled!\n", "",             /* 0x0080,0x0100 */
-       "  Restarted auto-negotiation in progress!\n",
-       "  Transceiver isolated from the MII!\n",
-       "  Transceiver powered down!\n", "", "",
-       "  Transceiver in loopback mode!\n",
-       "  Transceiver currently being reset!\n",
-};
-
-int show_basic_mii(long ioaddr, int phy_id)
-{
-       int mii_reg, i;
-       u16 mii_val[32];
-       u16 bmcr, bmsr, new_bmsr, nway_advert, lkpar;
-
-       for (mii_reg = 0; mii_reg < 8; mii_reg++)
-               mii_val[mii_reg] = mdio_read(ioaddr, phy_id, mii_reg);
-       if ( ! verbose) {
-               printf("Basic registers of MII PHY #%d: ", phy_id);
-               for (mii_reg = 0; mii_reg < 8; mii_reg++)
-                       printf(" %4.4x", mii_val[mii_reg]);
-               printf(".\n");
-       }
-
-       if (mii_val[0] == 0xffff  ||  mii_val[1] == 0x0000) {
-               printf("  No MII transceiver present!.\n");
-               if (! opt_f) {
-                       printf("  Use '--force' to view the information anyway.\n");
-                       return -1;
-               }
-       }
-       /* Descriptive rename. */
-       bmcr = mii_val[0];
-       bmsr = mii_val[1];
-       nway_advert = mii_val[4];
-       lkpar = mii_val[5];
-
-       if (lkpar & 0x4000) {
-               int negotiated = nway_advert & lkpar & 0x3e0;
-               int max_capability = 0;
-               /* Scan for the highest negotiated capability, highest priority
-                  (100baseTx-FDX) to lowest (10baseT-HDX). */
-               int media_priority[] = {8, 9, 7, 6, 5};         /* media_names[i-5] */
-               printf(" The autonegotiated capability is %4.4x.\n", negotiated);
-               for (i = 0; media_priority[i]; i++)
-                       if (negotiated & (1 << media_priority[i])) {
-                               max_capability = media_priority[i];
-                               break;
-                       }
-               if (max_capability)
-                       printf("The autonegotiated media type is %s.\n",
-                                  media_names[max_capability - 5]);
-               else
-                       printf("No common media type was autonegotiated!\n"
-                                  "This is extremely unusual and typically indicates a "
-                                  "configuration error.\n" "Perhaps the advertised "
-                                  "capability set was intentionally limited.\n");
-       }
-       printf(" Basic mode control register 0x%4.4x:", bmcr);
-       if (bmcr & 0x1000)
-               printf(" Auto-negotiation enabled.\n");
-       else
-               printf(" Auto-negotiation disabled, with\n"
-                          " Speed fixed at 10%s mbps, %s-duplex.\n",
-                          bmcr & 0x2000 ? "0" : "",
-                          bmcr & 0x0100 ? "full":"half");
-       for (i = 0; i < 9; i++)
-               if (bmcr & (0x0080<<i))
-                       printf(bmcr_bits[i]);
-
-       new_bmsr = mdio_read(ioaddr, phy_id, 1);
-       if ((bmsr & 0x0016) == 0x0004)
-               printf( " You have link beat, and everything is working OK.\n");
-       else
-               printf(" Basic mode status register 0x%4.4x ... %4.4x.\n"
-                          "   Link status: %sestablished.\n",
-                          bmsr, new_bmsr,
-                          bmsr & 0x0004 ? "" :
-                          (new_bmsr & 0x0004) ? "previously broken, but now re" : "not ");
-       if (verbose) {
-               printf("   This transceiver is capable of ");
-               if (bmsr & 0xF800) {
-                       for (i = 15; i >= 11; i--)
-                               if (bmsr & (1<<i))
-                                       printf(" %s", media_names[i-11]);
-               } else
-                       printf("<Warning! No media capabilities>");
-               printf(".\n");
-               printf("   %s to perform Auto-negotiation, negotiation %scomplete.\n",
-                          bmsr & 0x0008 ? "Able" : "Unable",
-                          bmsr & 0x0020 ? "" : "not ");
-       }
-
-       if (bmsr & 0x0010)
-               printf(" Remote fault detected!\n");
-       if (bmsr & 0x0002)
-               printf("   *** Link Jabber! ***\n");
-
-       if (lkpar & 0x4000) {
-               printf(" Your link partner advertised %4.4x:",
-                          lkpar);
-               for (i = 5; i >= 0; i--)
-                       if (lkpar & (0x20<<i))
-                               printf(" %s", media_names[i]);
-               printf("%s.\n", lkpar & 0x0400 ? ", w/ 802.3X flow control" : "");
-       } else if (lkpar & 0x00A0)
-               printf(" Your link partner is generating %s link beat  (no"
-                          " autonegotiation).\n",
-                          lkpar & 0x0080 ? "100baseTx" : "10baseT");
-       else if ( ! (bmcr & 0x1000))
-               printf(" Link partner information is not exchanged when in"
-                          " fixed speed mode.\n");
-       else if ( ! (new_bmsr & 0x004))
-                                                       ;       /* If no partner, do not report status. */
-       else if (lkpar == 0x0001  ||  lkpar == 0x0000) {
-               printf(" Your link partner does not do autonegotiation, and this "
-                          "transceiver type\n  does not report the sensed link "
-                          "speed.\n");
-       } else
-               printf(" Your link partner is strange, status %4.4x.\n", lkpar);
-
-       printf("   End of basic transceiver information.\n\n");
-       return 0;
-}
-
-static void monitor_status(long ioaddr, int phy_id)
-{
-       unsigned int baseline_1 = 0x55555555;   /* Always show initial status. */
-
-       while (1) {
-               unsigned int new_1 = mdio_read(ioaddr, phy_id, 1);
-               if (new_1 != baseline_1) {
-                       printf("%-12s 0x%4.4x 0x%4.4x\n",
-                                  new_1 & 0x04 ? (new_1==0xffff ? "unknown" : "up") :
-                                  new_1 & 0x20 ? "negotiating" : "down",
-                                  new_1, mdio_read(ioaddr, phy_id, 5));
-                       fflush(stdout);
-                       baseline_1 = new_1;
-               }
-               sleep(1);
-       }
-}
-
-/* These functions are not used if we are linked with libmii. */
-
-int  show_mii_details(long ioaddr, int phy_id) __attribute__((weak));
-void monitor_mii(long ioaddr, int phy_id) __attribute__((weak));
-
-int  show_mii_details(long ioaddr, int phy_id)
-{
-       int mii_reg, mii_val;
-       printf(" MII PHY #%d transceiver registers:", phy_id);
-       for (mii_reg = 0; mii_reg < 32; mii_reg++) {
-               mii_val = mdio_read(skfd, phy_id, mii_reg);
-               printf("%s %4.4x", (mii_reg % 8) == 0 ? "\n  " : "",
-                          mii_val);
-       }
-       printf("\nThis version of 'mii-diag' has not been linked with "
-                       "the libmii.c library.\n"
-                       "  That library provides extended transceiver status reports.\n");
-       return 0;
-}
-
-void monitor_mii(long ioaddr, int phy_id)
-{
-       fprintf(stderr, "\nThis version of 'mii-diag' has not been linked with "
-                       "the libmii.c library \n"
-                       "  required for the media monitor option.\n");
-}
-
-
-\f
-/*
- * Local variables:
- *  version-control: t
- *  kept-new-versions: 5
- *  c-indent-level: 4
- *  c-basic-offset: 4
- *  tab-width: 4
- *  compile-command: "gcc -Wall -Wstrict-prototypes -O mii-diag.c -DLIBMII libmii.c -o mii-diag"
- *  simple-compile-command: "gcc mii-diag.c -o mii-diag"
- * End:
- */
diff --git a/sys-apps/mii-diag/files/mii-diag.c-2.09-gcc33.patch b/sys-apps/mii-diag/files/mii-diag.c-2.09-gcc33.patch
deleted file mode 100644 (file)
index 65351a5..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
---- mii-diag.c-2.09    2003-09-19 23:06:24.000000000 -0400
-+++ mii-diag.c 2003-09-19 23:05:34.000000000 -0400
-@@ -37,45 +37,45 @@
- static const char usage_msg[] =
- "Usage: %s [--help] [-aDfrRvVw] [-AF <speed+duplex>] [--watch] <interface>.\n";
- static const char long_usage_msg[] =
--"Usage: %s [-aDfrRvVw] [-AF <speed+duplex>] [--watch] <interface>.
--
--  This program configures and monitors the transceiver management registers
--  for network interfaces.  It uses the Media Independent Interface (MII)
--  standard with additional Linux-specific controls to communicate with the
--  underlying device driver.  The MII registers control and report network
--  link settings and errors.  Examples are link speed, duplex, capabilities
--  advertised to the link partner, status LED indications and link error
--  counters.
--
--   The common usage is
--      mii-diag eth0
--
--   The default interface is \"eth0\".
-- Frequently used options are
--   -A  --advertise <speed|setting>
--   -F  --fixed-speed <speed>
--      Speed is one of: 100baseT4, 100baseTx, 100baseTx-FD, 100baseTx-HD,
--                       10baseT, 10baseT-FD, 10baseT-HD
--   -s  --status     Return exit status 2 if there is no link beat.
--
-- Less frequently used options are
--   -a  --all-interfaces  Show the status all interfaces
--              (Not recommended with options that change settings.)
--   -D  --debug
--   -g  --read-parameters      Get driver-specific parameters.
--   -G  --set-parameters PARMS Set driver-specific parameters.
--       Parameters are comma separated, missing elements retain existing value.
--   -M  --msg-level LEVEL      Set the driver message bit map.
--   -p  --phy ADDR             Set the PHY (MII address) to report.
--   -r  --restart      Restart the link autonegotiation.
--   -R  --reset                Reset the transceiver.
--   -v  --verbose      Report each action taken.
--   -V  --version      Emit version information.
--   -w  --watch                Continuously monitor the transceiver and report changes.
--
--   This command returns success (zero) if the interface information can be
--   read.  If the --status option is passed, a zero return means that the
--   interface has link beat.
-+"Usage: %s [-aDfrRvVw] [-AF <speed+duplex>] [--watch] <interface>.\n\
-+\n\
-+  This program configures and monitors the transceiver management registers\n\
-+  for network interfaces.  It uses the Media Independent Interface (MII)\n\
-+  standard with additional Linux-specific controls to communicate with the\n\
-+  underlying device driver.  The MII registers control and report network\n\
-+  link settings and errors.  Examples are link speed, duplex, capabilities\n\
-+  advertised to the link partner, status LED indications and link error\n\
-+  counters.\n\
-+\n\
-+   The common usage is\n\
-+      mii-diag eth0\n\
-+\n\
-+   The default interface is \"eth0\".\n\
-+ Frequently used options are\n\
-+   -A  --advertise <speed|setting>\n\
-+   -F  --fixed-speed <speed>\n\
-+      Speed is one of: 100baseT4, 100baseTx, 100baseTx-FD, 100baseTx-HD,\n\
-+                       10baseT, 10baseT-FD, 10baseT-HD\n\
-+   -s  --status     Return exit status 2 if there is no link beat.\n\
-+\n\
-+ Less frequently used options are\n\
-+   -a  --all-interfaces  Show the status all interfaces\n\
-+              (Not recommended with options that change settings.)\n\
-+   -D  --debug\n\
-+   -g  --read-parameters      Get driver-specific parameters.\n\
-+   -G  --set-parameters PARMS Set driver-specific parameters.\n\
-+       Parameters are comma separated, missing elements retain existing value.\n\
-+   -M  --msg-level LEVEL      Set the driver message bit map.\n\
-+   -p  --phy ADDR             Set the PHY (MII address) to report.\n\
-+   -r  --restart      Restart the link autonegotiation.\n\
-+   -R  --reset                Reset the transceiver.\n\
-+   -v  --verbose      Report each action taken.\n\
-+   -V  --version      Emit version information.\n\
-+   -w  --watch                Continuously monitor the transceiver and report changes.\n\
-+\n\
-+   This command returns success (zero) if the interface information can be\n\
-+   read.  If the --status option is passed, a zero return means that the\n\
-+   interface has link beat.\n\
- ";
- 
- #include <unistd.h>
-@@ -608,33 +608,6 @@
-       }
- }
- 
--/* These functions are not used if we are linked with libmii. */
--
--int  show_mii_details(long ioaddr, int phy_id) __attribute__((weak));
--void monitor_mii(long ioaddr, int phy_id) __attribute__((weak));
--
--int  show_mii_details(long ioaddr, int phy_id)
--{
--      int mii_reg, mii_val;
--      printf(" MII PHY #%d transceiver registers:", phy_id);
--      for (mii_reg = 0; mii_reg < 32; mii_reg++) {
--              mii_val = mdio_read(skfd, phy_id, mii_reg);
--              printf("%s %4.4x", (mii_reg % 8) == 0 ? "\n  " : "",
--                         mii_val);
--      }
--      printf("\nThis version of 'mii-diag' has not been linked with "
--                      "the libmii.c library.\n"
--                      "  That library provides extended transceiver status reports.\n");
--      return 0;
--}
--
--void monitor_mii(long ioaddr, int phy_id)
--{
--      fprintf(stderr, "\nThis version of 'mii-diag' has not been linked with "
--                      "the libmii.c library \n"
--                      "  required for the media monitor option.\n");
--}
--
- 
- \f
- /*
diff --git a/sys-apps/mii-diag/files/mii-diag.c-2.11 b/sys-apps/mii-diag/files/mii-diag.c-2.11
deleted file mode 100644 (file)
index 17d8bef..0000000
+++ /dev/null
@@ -1,650 +0,0 @@
-/* Mode: C;
- * mii-diag.c: Examine and set the MII registers of a network interfaces.
-
-       Usage:  mii-diag [-vw] interface.
-
-       This program reads and writes the Media Independent Interface (MII)
-       management registers on network transceivers.  The registers control
-       and report network link settings and errors.  Examples are link speed,
-       duplex, capabilities advertised to the link partner, status LED
-       indications and link error counters.
-
-       Notes:
-       The compile-command is at the end of this source file.
-       This program works with drivers that implement MII ioctl() calls.
-
-       Written/copyright 1997-2003 by Donald Becker <becker@scyld.com>
-
-       This program is free software; you can redistribute it
-       and/or modify it under the terms of the GNU General Public
-       License as published by the Free Software Foundation.
-
-       The author may be reached as becker@scyld.com, or C/O
-        Scyld Computing Corporation
-        914 Bay Ridge Road, Suite 220
-        Annapolis MD 21403
-
-       References
-       http://scyld.com/expert/mii-status.html
-       http://scyld.com/expert/NWay.html
-       http://www.national.com/pf/DP/DP83840.html
-*/
-
-static char version[] =
-"mii-diag.c:v2.11 3/21/2005 Donald Becker (becker@scyld.com)\n"
-" http://www.scyld.com/diag/index.html\n";
-
-static const char usage_msg[] =
-"Usage: %s [--help] [-aDfrRvVw] [-AF <speed+duplex>] [--watch] <interface>.\n";
-static const char long_usage_msg[] =
-"Usage: %s [-aDfrRvVw] [-AF <speed+duplex>] [--watch] <interface>.\n\
-\n\
-  This program configures and monitors the transceiver management registers\n\
-  for network interfaces.  It uses the Media Independent Interface (MII)\n\
-  standard with additional Linux-specific controls to communicate with the\n\
-  underlying device driver.  The MII registers control and report network\n\
-  link settings and errors.  Examples are link speed, duplex, capabilities\n\
-  advertised to the link partner, status LED indications and link error\n\
-  counters.\n\
-\n\
-   The common usage is\n\
-      mii-diag eth0\n\
-\n\
-   The default interface is \"eth0\".\n\
- Frequently used options are\n\
-   -A  --advertise <speed|setting>\n\
-   -F  --fixed-speed <speed>\n\
-       Speed is one of: 100baseT4, 100baseTx, 100baseTx-FD, 100baseTx-HD,\n\
-                        10baseT, 10baseT-FD, 10baseT-HD\n\
-   -s  --status     Return exit status 2 if there is no link beat.\n\
-\n\
- Less frequently used options are\n\
-   -a  --all-interfaces  Show the status all interfaces\n\
-              (Not recommended with options that change settings.)\n\
-   -D  --debug\n\
-   -g  --read-parameters       Get driver-specific parameters.\n\
-   -G  --set-parameters PARMS  Set driver-specific parameters.\n\
-       Parameters are comma separated, missing parameters retain\n\
-       their previous values.\n\
-   -M  --msg-level LEVEL       Set the driver message bit map.\n\
-   -p  --phy ADDR              Set the PHY (MII address) to report.\n\
-   -r  --restart       Restart the link autonegotiation.\n\
-   -R  --reset         Reset the transceiver.\n\
-   -v  --verbose       Report each action taken.\n\
-   -V  --version       Emit version information.\n\
-   -w  --watch         Continuously monitor the transceiver and report changes.\n\
-\n\
-   This command returns success (zero) if the interface information can be\n\
-   read.  If the --status option is passed, a zero return means that the\n\
-   interface has link beat.\n\
-";
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <getopt.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <net/if.h>
-#ifdef use_linux_libc5
-#include <linux/if_arp.h>
-#include <linux/if_ether.h>
-#endif
-
-typedef u_int32_t u32;
-typedef u_int16_t u16;
-typedef u_int8_t u8;
-
-#if defined(SIOCGPARAMS)  && SIOCGPARAMS != SIOCDEVPRIVATE+3
-#error Changed definition for SIOCGPARAMS
-#else
-#define SIOCGPARAMS (SIOCDEVPRIVATE+3)                 /* Read operational parameters. */
-#define SIOCSPARAMS (SIOCDEVPRIVATE+4)                 /* Set operational parameters. */
-#endif
-
-const char shortopts[] = "aA:C:DfF:gG:hmM:p:rRsvVw?";
-struct option longopts[] = {
- /* { name  has_arg  *flag  val } */
-    {"all-interfaces", 0, 0, 'a'},     /* Show all interfaces. */
-       {"advertise",   1, 0, 'A'},             /* Change the capabilities advertised. */
-       {"BMCR",                1, 0, 'C'},             /* Set the control register. */
-    {"debug",       0, 0, 'D'},                /* Increase the debug level. */
-    {"force",       0, 0, 'f'},                /* Force the operation. */
-    {"fixed-speed", 1, 0, 'F'},                /* Fixed speed name. */
-    {"read-parameters", 0, 0, 'g'}, /* Show general settings values. */
-    {"set-parameters",  1, 0, 'G'},    /* Write general settings values. */
-    {"help",           0, 0, 'h'},             /* Print a long usage message. */
-    {"monitor",                0, 0, 'm'},             /* Monitor status register. */
-    {"msg-level",      1, 0, 'M'},             /* Set the driver message level. */
-    {"phy",                    1, 0, 'p'},             /* Set the PHY (MII address) to report. */
-    {"restart",                0, 0, 'r'},             /* Restart the link negotiation */
-    {"reset",          0, 0, 'R'},             /* Reset the transceiver. */
-    {"status",         0, 0, 's'},             /* Non-zero exit status w/ no link beat. */
-    {"verbose",        0, 0, 'v'},             /* Report each action taken.  */
-    {"version",        0, 0, 'V'},             /* Emit version information.  */
-    {"watch",          0, 0, 'w'},             /* Constantly monitor the port.  */
-    {"error",          0, 0, '?'},             /* Return the error message. */
-    { 0, 0, 0, 0 }
-};
-
-/* Usually in libmii.c, but trivial substitions are below. */
-extern int  show_mii_details(long ioaddr, int phy_id);
-extern void monitor_mii(long ioaddr, int phy_id);
-int  show_mii_details(long ioaddr, int phy_id) __attribute__((weak));
-void monitor_mii(long ioaddr, int phy_id) __attribute__((weak));
-
-
-/* Command-line flags. */
-unsigned int opt_a = 0,                                        /* Show-all-interfaces flag. */
-       opt_f = 0,                                      /* Force the operation. */
-       opt_g = 0,
-       opt_G = 0,
-       verbose = 0,                            /* Verbose flag. */
-       debug = 0,
-       opt_version = 0,
-       opt_restart = 0,
-       opt_reset = 0,
-       opt_status = 0,
-       opt_watch = 0;
-static int msg_level = -1;
-static int set_BMCR = -1;
-static int nway_advertise = 0;
-static int fixed_speed = -1;
-static int override_phy = -1;
-char *opt_G_string = NULL;
-
-/* Internal values. */
-int new_ioctl_nums;
-int skfd = -1;                                 /* AF_INET socket for ioctl() calls.    */
-struct ifreq ifr;
-
-int do_one_xcvr(int skfd);
-int show_basic_mii(long ioaddr, int phy_id);
-int mdio_read(int skfd, int phy_id, int location);
-void mdio_write(int skfd, int phy_id, int location, int value);
-static int parse_advertise(const char *capabilities);
-static void monitor_status(long ioaddr, int phy_id);
-
-
-int
-main(int argc, char **argv)
-{
-       int c, errflag = 0;
-       char **spp, *ifname;
-    char *progname = rindex(argv[0], '/') ? rindex(argv[0], '/')+1 : argv[0];
-
-       while ((c = getopt_long(argc, argv, shortopts, longopts, 0)) != EOF)
-               switch (c) {
-               case 'a': opt_a++; break;
-               case 'A': nway_advertise |= parse_advertise(optarg);
-                       if (nway_advertise == -1) errflag++;
-                       break;
-               case 'C': set_BMCR = strtoul(optarg, NULL, 16); break;
-               case 'D': debug++;                      break;
-               case 'f': opt_f++; break;
-               case 'F': fixed_speed = parse_advertise(optarg);
-                       if (fixed_speed == -1) errflag++;
-                       break;
-               case 'g': opt_g++; break;
-               case 'G': opt_G++; opt_G_string = strdup(optarg); break;
-               case 'm': opt_watch++; opt_status++; break;
-               case 'M': msg_level = strtoul(optarg, NULL, 0); break;
-               case 'h': fprintf(stderr, long_usage_msg, progname); return 0;
-               case 'p': override_phy = atoi(optarg); break;
-               case 'r': opt_restart++;        break;
-               case 'R': opt_reset++;          break;
-               case 's': opt_status++;         break;
-               case 'v': verbose++;            break;
-               case 'V': opt_version++;        break;
-               case 'w': opt_watch++;          break;
-               case '?': errflag++;            break;
-               }
-       if (errflag) {
-               fprintf(stderr, usage_msg, progname);
-               return 2;
-       }
-
-       if (verbose || opt_version)
-               printf(version);
-
-       /* Open a basic socket. */
-       if ((skfd = socket(AF_INET, SOCK_DGRAM,0)) < 0) {
-               perror("socket");
-               return 1;
-       }
-
-       if (debug)
-               fprintf(stderr, "DEBUG: argc=%d, optind=%d and argv[optind] is %s.\n",
-                               argc, optind, argv[optind]);
-
-       /* No remaining args means show all interfaces. */
-       if (optind == argc) {
-               ifname = "eth0";
-               fprintf(stderr, "Using the default interface 'eth0'.\n");
-       } else {
-               /* Copy the interface name. */
-               spp = argv + optind;
-               ifname = *spp++;
-       }
-
-       if (ifname == NULL) {
-               ifname = "eth0";
-               fprintf(stderr, "Using the default interface 'eth0'.\n");
-       }
-
-       /* Verify that the interface supports the ioctl(), and if
-          it is using the new or old SIOCGMIIPHY value (grrr...).
-        */
-       {
-               u16 *data = (u16 *)(&ifr.ifr_data);
-
-               strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
-               data[0] = 0;
-
-               if (ioctl(skfd, 0x8947, &ifr) >= 0) {
-                       new_ioctl_nums = 1;
-               } else if (ioctl(skfd, SIOCDEVPRIVATE, &ifr) >= 0) {
-                       new_ioctl_nums = 0;
-               } else {
-                       fprintf(stderr, "SIOCGMIIPHY on %s failed: %s\n", ifname,
-                                       strerror(errno));
-                       (void) close(skfd);
-                       return 1;
-               }
-               if (verbose)
-                       printf("  Using the %s SIOCGMIIPHY value on PHY %d "
-                                  "(BMCR 0x%4.4x).\n",
-                                  new_ioctl_nums ? "new" : "old", data[0], data[3]);
-       }
-
-       do_one_xcvr(skfd);
-
-       (void) close(skfd);
-       return 0;
-}
-
-int do_one_xcvr(int skfd)
-{
-       u16 *data = (u16 *)(&ifr.ifr_data);
-       u32 *data32 = (u32 *)(&ifr.ifr_data);
-       unsigned phy_id = data[0];
-
-       if (override_phy >= 0) {
-               printf("Using the specified MII PHY index %d.\n", override_phy);
-               phy_id = override_phy;
-       }
-
-       if (opt_g || opt_G || msg_level >= 0) {
-               if (ioctl(skfd, SIOCGPARAMS, &ifr) < 0) {
-                       fprintf(stderr, "SIOCGPARAMS on %s failed: %s\n", ifr.ifr_name,
-                                       strerror(errno));
-                       return -1;
-               }
-       }
-       if (opt_g) {
-               int i;
-               printf("Driver general parameter settings:");
-               for (i = 0; i*sizeof(u32) < sizeof(ifr.ifr_ifru); i++) {
-                       printf(" %d", data32[i]);
-               }
-               printf(".\n");
-       }
-       if (opt_G) {
-               /* Set up to four arbitrary driver parameters from the -G parameter.
-                  The format is comma separated integers, with a missing element
-                  retaining the previous value.
-               */
-               char *str = opt_G_string;
-               int i;
-               for (i = 0; str && i < 4; i++) {
-                       char *endstr;
-                       u32 newval = strtol(str, &endstr, 0);
-                       if (debug)
-                               printf(" parse string '%s'  value %d end '%s'.\n",
-                                          str, newval, endstr);
-                       if (str == endstr) {
-                               if (endstr[0] == ',') /* No parameter */
-                                       str = endstr+1;
-                               else {
-                                       fprintf(stderr, "Invalid driver parameter '%s'.\n", str);
-                                       str = index(str, ',');
-                               }
-                       } else if (endstr[0] == ',') {
-                               data32[i] = newval;
-                               str = endstr + 1;
-                       } else if (endstr[0] == 0) {
-                               data32[i] = newval;
-                               break;
-                       }
-               }
-               printf("Setting new driver general parameters:");
-               for (i = 0; i*sizeof(u32) < sizeof(ifr.ifr_ifru); i++) {
-                       printf(" %d", data32[i]);
-               }
-               printf(".\n");
-               if (ioctl(skfd, SIOCSPARAMS, &ifr) < 0) {
-                       fprintf(stderr, "SIOCSPARAMS on %s failed: %s\n", ifr.ifr_name,
-                                       strerror(errno));
-                       return -1;
-               }
-       }
-       if (msg_level >= 0) {
-               data32[0] = msg_level;
-               if (ioctl(skfd, SIOCSPARAMS, &ifr) < 0) {
-                       fprintf(stderr, "SIOCSPARAMS on %s failed: %s\n", ifr.ifr_name,
-                                       strerror(errno));
-                       return -1;
-               }
-       }
-
-       if (opt_reset) {
-               printf("Resetting the transceiver...\n");
-               mdio_write(skfd, phy_id, 0, 0x8000);
-       }
-       /* Note: PHY addresses > 32 are pseudo-MII devices, usually built-in. */
-       if (phy_id < 64  &&  nway_advertise > 0) {
-               printf(" Setting the media capability advertisement register of "
-                          "PHY #%d to 0x%4.4x.\n", phy_id, nway_advertise | 1);
-               mdio_write(skfd, phy_id, 4, nway_advertise | 1);
-               mdio_write(skfd, phy_id, 0, 0x1000);
-       }
-
-       if (opt_restart) {
-               printf("Restarting negotiation...\n");
-               mdio_write(skfd, phy_id, 0, 0x0000);
-               mdio_write(skfd, phy_id, 0, 0x1200);
-       }
-       /* To force 100baseTx-HD do  mdio_write(skfd, phy_id, 0, 0x2000); */
-       if (fixed_speed >= 0) {
-               int reg0_val = 0;
-               if (fixed_speed & 0x0180)               /* 100mpbs */
-                       reg0_val |=  0x2000;
-               if ((fixed_speed & 0x0140) &&           /* A full duplex type and */
-                       ! (fixed_speed & 0x0820))               /* no half duplex types. */
-                       reg0_val |= 0x0100;
-               printf("Setting the speed to \"fixed\", Control register %4.4x.\n",
-                          reg0_val);
-               mdio_write(skfd, phy_id, 0, reg0_val);
-       }
-       if (set_BMCR >= 0) {
-               printf("Setting the Basic Mode Control Register to 0x%4.4x.\n",
-                          set_BMCR);
-               mdio_write(skfd, phy_id, 0, set_BMCR);
-       }
-
-       if (opt_watch && opt_status)
-               monitor_status(skfd, phy_id);
-
-       show_basic_mii(skfd, phy_id);
-#ifdef LIBMII
-       if (verbose)
-               show_mii_details(skfd, phy_id);
-#else
-       if (verbose || debug) {
-               int mii_reg, mii_val;
-               printf(" MII PHY #%d transceiver registers:", phy_id);
-               for (mii_reg = 0; mii_reg < 32; mii_reg++) {
-                       mii_val = mdio_read(skfd, phy_id, mii_reg);
-                       printf("%s %4.4x", (mii_reg % 8) == 0 ? "\n  " : "",
-                                  mii_val);
-               }
-               printf("\n");
-       }
-#endif
-
-       if (opt_watch)
-               monitor_mii(skfd, phy_id);
-       if (opt_status &&
-               (mdio_read(skfd, phy_id, 1) & 0x0004) == 0)
-               exit(2);
-       return 0;
-}
-
-int mdio_read(int skfd, int phy_id, int location)
-{
-       u16 *data = (u16 *)(&ifr.ifr_data);
-
-       data[0] = phy_id;
-       data[1] = location;
-
-       if (ioctl(skfd, new_ioctl_nums ? 0x8948 : SIOCDEVPRIVATE+1, &ifr) < 0) {
-               fprintf(stderr, "SIOCGMIIREG on %s failed: %s\n", ifr.ifr_name,
-                               strerror(errno));
-               return -1;
-       }
-       return data[3];
-}
-
-void mdio_write(int skfd, int phy_id, int location, int value)
-{
-       u16 *data = (u16 *)(&ifr.ifr_data);
-
-       data[0] = phy_id;
-       data[1] = location;
-       data[2] = value;
-
-       if (ioctl(skfd, new_ioctl_nums ? 0x8949 : SIOCDEVPRIVATE+2, &ifr) < 0) {
-               fprintf(stderr, "SIOCSMIIREG on %s failed: %s\n", ifr.ifr_name,
-                               strerror(errno));
-       }
-}
-
-/* Parse the command line argument for advertised capabilities. */
-static int parse_advertise(const char *capabilities)
-{
-       const char *mtypes[] = {
-               "100baseT4", "100baseTx", "100baseTx-FD", "100baseTx-HD",
-               "10baseT", "10baseT-FD", "10baseT-HD", 0,
-       };
-       char *endptr;
-       int cap_map[] = { 0x0200, 0x0180, 0x0100, 0x0080, 0x0060, 0x0040, 0x0020,};
-       int i;
-       if ( ! capabilities) {
-               fprintf(stderr, "You passed -A 'NULL'.  You must provide a media"
-                               " list to advertise!\n");
-               return -1;
-       }
-       if (debug)
-               fprintf(stderr, "Advertise string is '%s'.\n", capabilities);
-       for (i = 0; mtypes[i]; i++)
-               if (strcasecmp(mtypes[i], capabilities) == 0)
-                       return cap_map[i];
-       if ((i = strtol(capabilities, &endptr, 16)) <= 0xffff  &&  endptr[0] == 0)
-               return i;
-       fprintf(stderr, "Invalid media advertisement value '%s'.\n"
-                       "  Either pass a numeric value or one of the following names:\n",
-                       capabilities);
-       for (i = 0; mtypes[i]; i++)
-               fprintf(stderr, "   %-14s %3.3x\n", mtypes[i], cap_map[i]);
-       return -1;
-}
-
-/* Trivial versions if we don't link against libmii.c */
-static const char *media_names[] = {
-       "10baseT", "10baseT-FD", "100baseTx", "100baseTx-FD", "100baseT4",
-       "Flow-control", 0,
-};
-/* Various non-good bits in the command register. */
-static const char *bmcr_bits[] = {
-       "  Internal Collision-Test enabled!\n", "",             /* 0x0080,0x0100 */
-       "  Restarted auto-negotiation in progress!\n",
-       "  Transceiver isolated from the MII!\n",
-       "  Transceiver powered down!\n", "", "",
-       "  Transceiver in loopback mode!\n",
-       "  Transceiver currently being reset!\n",
-};
-
-int show_basic_mii(long ioaddr, int phy_id)
-{
-       int mii_reg, i;
-       u16 mii_val[32];
-       u16 bmcr, bmsr, new_bmsr, nway_advert, lkpar;
-
-       for (mii_reg = 0; mii_reg < 8; mii_reg++)
-               mii_val[mii_reg] = mdio_read(ioaddr, phy_id, mii_reg);
-       if ( ! verbose) {
-               printf("Basic registers of MII PHY #%d: ", phy_id);
-               for (mii_reg = 0; mii_reg < 8; mii_reg++)
-                       printf(" %4.4x", mii_val[mii_reg]);
-               printf(".\n");
-       }
-
-       if (mii_val[0] == 0xffff  ||  mii_val[1] == 0x0000) {
-               printf("  No MII transceiver present!.\n");
-               if (! opt_f) {
-                       printf("  Use '--force' to view the information anyway.\n");
-                       return -1;
-               }
-       }
-       /* Descriptive rename. */
-       bmcr = mii_val[0];
-       bmsr = mii_val[1];
-       nway_advert = mii_val[4];
-       lkpar = mii_val[5];
-
-       if (lkpar & 0x4000) {
-               int negotiated = nway_advert & lkpar & 0x3e0;
-               int max_capability = 0;
-               /* Scan for the highest negotiated capability, highest priority
-                  (100baseTx-FDX) to lowest (10baseT-HDX). */
-               int media_priority[] = {8, 9, 7, 6, 5};         /* media_names[i-5] */
-               printf(" The autonegotiated capability is %4.4x.\n", negotiated);
-               for (i = 0; media_priority[i]; i++)
-                       if (negotiated & (1 << media_priority[i])) {
-                               max_capability = media_priority[i];
-                               break;
-                       }
-               if (max_capability)
-                       printf("The autonegotiated media type is %s.\n",
-                                  media_names[max_capability - 5]);
-               else
-                       printf("No common media type was autonegotiated!\n"
-                                  "This is extremely unusual and typically indicates a "
-                                  "configuration error.\n" "Perhaps the advertised "
-                                  "capability set was intentionally limited.\n");
-       }
-       printf(" Basic mode control register 0x%4.4x:", bmcr);
-       if (bmcr & 0x1000)
-               printf(" Auto-negotiation enabled.\n");
-       else
-               printf(" Auto-negotiation disabled, with\n"
-                          " Speed fixed at 10%s mbps, %s-duplex.\n",
-                          bmcr & 0x2000 ? "0" : "",
-                          bmcr & 0x0100 ? "full":"half");
-       for (i = 0; i < 9; i++)
-               if (bmcr & (0x0080<<i))
-                       printf(bmcr_bits[i]);
-
-       new_bmsr = mdio_read(ioaddr, phy_id, 1);
-       if ((bmsr & 0x0016) == 0x0004)
-               printf( " You have link beat, and everything is working OK.\n");
-       else
-               printf(" Basic mode status register 0x%4.4x ... %4.4x.\n"
-                          "   Link status: %sestablished.\n",
-                          bmsr, new_bmsr,
-                          bmsr & 0x0004 ? "" :
-                          (new_bmsr & 0x0004) ? "previously broken, but now re" : "not ");
-       if (verbose) {
-               printf("   This transceiver is capable of ");
-               if (bmsr & 0xF800) {
-                       for (i = 15; i >= 11; i--)
-                               if (bmsr & (1<<i))
-                                       printf(" %s", media_names[i-11]);
-               } else
-                       printf("<Warning! No media capabilities>");
-               printf(".\n");
-               printf("   %s to perform Auto-negotiation, negotiation %scomplete.\n",
-                          bmsr & 0x0008 ? "Able" : "Unable",
-                          bmsr & 0x0020 ? "" : "not ");
-       }
-
-       if (bmsr & 0x0010)
-               printf(" Remote fault detected!\n");
-       if (bmsr & 0x0002)
-               printf("   *** Link Jabber! ***\n");
-
-       if (lkpar & 0x4000) {
-               printf(" Your link partner advertised %4.4x:",
-                          lkpar);
-               for (i = 5; i >= 0; i--)
-                       if (lkpar & (0x20<<i))
-                               printf(" %s", media_names[i]);
-               printf("%s.\n", lkpar & 0x0400 ? ", w/ 802.3X flow control" : "");
-       } else if (lkpar & 0x00A0)
-               printf(" Your link partner is generating %s link beat  (no"
-                          " autonegotiation).\n",
-                          lkpar & 0x0080 ? "100baseTx" : "10baseT");
-       else if ( ! (bmcr & 0x1000))
-               printf(" Link partner information is not exchanged when in"
-                          " fixed speed mode.\n");
-       else if ( ! (new_bmsr & 0x004))
-                                                       ;       /* If no partner, do not report status. */
-       else if (lkpar == 0x0001  ||  lkpar == 0x0000) {
-               printf(" Your link partner does not do autonegotiation, and this "
-                          "transceiver type\n  does not report the sensed link "
-                          "speed.\n");
-       } else
-               printf(" Your link partner is strange, status %4.4x.\n", lkpar);
-
-       printf("   End of basic transceiver information.\n\n");
-       return 0;
-}
-
-static void monitor_status(long ioaddr, int phy_id)
-{
-       unsigned int baseline_1 = 0x55555555;   /* Always show initial status. */
-
-       while (1) {
-               unsigned int new_1 = mdio_read(ioaddr, phy_id, 1);
-               if (new_1 != baseline_1) {
-                       printf("%-12s 0x%4.4x 0x%4.4x\n",
-                                  new_1 & 0x04 ? (new_1==0xffff ? "unknown" : "up") :
-                                  new_1 & 0x20 ? "negotiating" : "down",
-                                  new_1, mdio_read(ioaddr, phy_id, 5));
-                       fflush(stdout);
-                       baseline_1 = new_1;
-               }
-               sleep(1);
-       }
-}
-
-int  show_mii_details(long ioaddr, int phy_id)
-{
-       int mii_reg, mii_val;
-       printf(" MII PHY #%d transceiver registers:", phy_id);
-       for (mii_reg = 0; mii_reg < 32; mii_reg++) {
-               mii_val = mdio_read(skfd, phy_id, mii_reg);
-               printf("%s %4.4x", (mii_reg % 8) == 0 ? "\n  " : "",
-                          mii_val);
-       }
-       printf("\nThis version of 'mii-diag' has not been linked with "
-                       "the libmii.c library.\n"
-                       "  That library provides extended transceiver status reports.\n");
-       return 0;
-}
-
-void monitor_mii(long ioaddr, int phy_id)
-{
-       fprintf(stderr, "\nThis version of 'mii-diag' has not been linked with "
-                       "the libmii.c library \n"
-                       "  required for the media monitor option.\n");
-}
-
-
-\f
-/*
- * Local variables:
- *  version-control: t
- *  kept-new-versions: 5
- *  c-indent-level: 4
- *  c-basic-offset: 4
- *  tab-width: 4
- *  compile-command: "gcc -Wall -Wstrict-prototypes -O mii-diag.c -DLIBMII libmii.c -o mii-diag"
- *  simple-compile-command: "gcc mii-diag.c -o mii-diag"
- * End:
- */
diff --git a/sys-apps/mii-diag/metadata.xml b/sys-apps/mii-diag/metadata.xml
deleted file mode 100644 (file)
index 96a2d58..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
-<pkgmetadata>
-<herd>base-system</herd>
-</pkgmetadata>
diff --git a/sys-apps/mii-diag/mii-diag-2.09.ebuild b/sys-apps/mii-diag/mii-diag-2.09.ebuild
deleted file mode 100644 (file)
index 84334ed..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-# Copyright 1999-2005 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/sys-apps/mii-diag/mii-diag-2.09.ebuild,v 1.10 2005/11/29 03:35:21 jer Exp $
-
-inherit eutils toolchain-funcs
-
-MIIVER=${PV}
-LIBVER=2.10
-
-DESCRIPTION="MII link status report and diagnostics"
-HOMEPAGE="http://www.scyld.com/ethercard_diag.html"
-# Files below are small and unversioned so I put them in the files dir
-# with version suffixes.
-SRC_URI=""     # ftp://ftp.scyld.com/pub/diag/mii-diag.c
-                       # ftp://ftp.scyld.com/pub/diag/libmii.c
-
-LICENSE="GPL-2"
-SLOT="0"
-KEYWORDS="alpha amd64 ~hppa ~mips ~ppc sparc x86"
-IUSE=""
-
-DEPEND=""
-
-S=${WORKDIR}
-
-src_unpack() {
-       cp "${FILESDIR}"/mii-diag.c-${MIIVER} mii-diag.c || die "mii-diag.c"
-       cp "${FILESDIR}"/libmii.c-${LIBVER} libmii.c || die "libmii.c"
-       epatch "${FILESDIR}"/mii-diag.c-${PV}-gcc33.patch
-}
-
-src_compile() {
-       # Don't change -O below, it is a requirement for building these
-       # programs.  See http://www.scyld.com/ethercard_diag.html#compiling
-       $(tc-getCC) -O ${LDFLAGS} -c libmii.c || die
-       $(tc-getCC) -O ${LDFLAGS} -DLIBMII mii-diag.c libmii.o -o mii-diag || die
-}
-
-src_install() {
-       into /
-       dosbin mii-diag || die
-}
diff --git a/sys-apps/mii-diag/mii-diag-2.11.ebuild b/sys-apps/mii-diag/mii-diag-2.11.ebuild
deleted file mode 100644 (file)
index e62320c..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-# Copyright 1999-2005 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/sys-apps/mii-diag/mii-diag-2.11.ebuild,v 1.2 2005/11/29 03:35:21 jer Exp $
-
-inherit toolchain-funcs
-
-MIIVER=${PV}
-LIBVER=2.11
-
-DESCRIPTION="MII link status report and diagnostics"
-HOMEPAGE="http://www.scyld.com/ethercard_diag.html"
-# Files below are small and unversioned so I put them in the files dir
-# with version suffixes.
-SRC_URI=""     # ftp://ftp.scyld.com/pub/diag/mii-diag.c
-                       # ftp://ftp.scyld.com/pub/diag/libmii.c
-
-LICENSE="GPL-2"
-SLOT="0"
-KEYWORDS="~alpha ~amd64 ~hppa ~mips ~ppc ~sparc ~x86"
-IUSE=""
-
-DEPEND=""
-
-S=${WORKDIR}
-
-src_unpack() {
-       cp "${FILESDIR}"/mii-diag.c-${MIIVER} mii-diag.c || die "mii-diag.c"
-       cp "${FILESDIR}"/mii-diag.8-${MIIVER} mii-diag.8 || die "mii-diag.8"
-       cp "${FILESDIR}"/libmii.c-${LIBVER} libmii.c || die "libmii.c"
-}
-
-src_compile() {
-       # Don't change -O below, it is a requirement for building these
-       # programs.  See http://www.scyld.com/ethercard_diag.html#compiling
-       $(tc-getCC) -O ${LDFLAGS} -c libmii.c || die
-       $(tc-getCC) -O ${LDFLAGS} -DLIBMII mii-diag.c libmii.o -o mii-diag || die
-}
-
-src_install() {
-       into /
-       dosbin mii-diag || die
-       doman mii-diag.8
-}