rpms/net-tools/F-12 net-tools-1.60-mii-refactor.patch, NONE, 1.1 net-tools.spec, 1.102, 1.103

Jiří Popelka jpopelka at fedoraproject.org
Wed Nov 4 13:25:52 UTC 2009


Author: jpopelka

Update of /cvs/pkgs/rpms/net-tools/F-12
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv6788

Modified Files:
	net-tools.spec 
Added Files:
	net-tools-1.60-mii-refactor.patch 
Log Message:
* Wed Nov  4 2009  Jiri Popelka <jpopelka at redhat.com> - 1.60-97
- in mii-tool.c use <linux/mii.h> instead of "mii.h" and fix Bug #491358


net-tools-1.60-mii-refactor.patch:
 mii-tool.c |  101 +++++++++++++++++++++++++++++++++----------------------------
 1 file changed, 56 insertions(+), 45 deletions(-)

--- NEW FILE net-tools-1.60-mii-refactor.patch ---
diff -up net-tools-1.60/mii-tool.c.mii-refactor net-tools-1.60/mii-tool.c
--- net-tools-1.60/mii-tool.c.mii-refactor	2009-10-30 16:25:23.000000000 +0100
+++ net-tools-1.60/mii-tool.c	2009-10-30 16:45:01.000000000 +0100
@@ -50,9 +50,11 @@ static char version[] =
 #include <linux/if_arp.h>
 #include <linux/if_ether.h>
 #endif
-#include "mii.h"
+#include <linux/mii.h>
+#include <linux/sockios.h>
 
 #define MAX_ETH		8		/* Maximum # of interfaces */
+#define LPA_ABILITY_MASK	0x07e0
 
 /* Table of known MII's */
 static struct {
@@ -112,7 +114,7 @@ static struct ifreq ifr;
 
 static int mdio_read(int skfd, int location)
 {
-    struct mii_data *mii = (struct mii_data *)&ifr.ifr_data;
+    struct mii_ioctl_data *mii = (struct mii_ioctl_data *)&ifr.ifr_data;
     mii->reg_num = location;
     if (ioctl(skfd, SIOCGMIIREG, &ifr) < 0) {
 	fprintf(stderr, "SIOCGMIIREG on %s failed: %s\n", ifr.ifr_name,
@@ -124,7 +126,7 @@ static int mdio_read(int skfd, int locat
 
 static void mdio_write(int skfd, int location, int value)
 {
-    struct mii_data *mii = (struct mii_data *)&ifr.ifr_data;
+    struct mii_ioctl_data *mii = (struct mii_ioctl_data *)&ifr.ifr_data;
     mii->reg_num = location;
     mii->val_in = value;
     if (ioctl(skfd, SIOCSMIIREG, &ifr) < 0) {
@@ -140,13 +142,13 @@ const struct {
     u_short	value;
 } media[] = {
     /* The order through 100baseT4 matches bits in the BMSR */
-    { "10baseT-HD",	MII_AN_10BASET_HD },
-    { "10baseT-FD",	MII_AN_10BASET_FD },
-    { "100baseTx-HD",	MII_AN_100BASETX_HD },
-    { "100baseTx-FD",	MII_AN_100BASETX_FD },
-    { "100baseT4",	MII_AN_100BASET4 },
-    { "100baseTx",	MII_AN_100BASETX_FD | MII_AN_100BASETX_HD },
-    { "10baseT",	MII_AN_10BASET_FD | MII_AN_10BASET_HD },
+    { "10baseT-HD",	LPA_10HALF },
+    { "10baseT-FD",	LPA_10FULL },
+    { "100baseTx-HD",	LPA_100HALF },
+    { "100baseTx-FD",	LPA_100FULL },
+    { "100baseT4",	LPA_100BASE4 },
+    { "100baseTx",	LPA_100FULL | LPA_100HALF },
+    { "10baseT",	LPA_10FULL | LPA_10HALF },
 };
 #define NMEDIA (sizeof(media)/sizeof(media[0]))
 	
@@ -157,8 +159,8 @@ static int parse_media(char *arg)
     char *s;
     mask = strtoul(arg, &s, 16);
     if ((*arg != '\0') && (*s == '\0')) {
-	if ((mask & MII_AN_ABILITY_MASK) &&
-	    !(mask & ~MII_AN_ABILITY_MASK))
+	if ((mask & LPA_ABILITY_MASK) &&
+	    !(mask & ~LPA_ABILITY_MASK))
 	    return mask;
 	goto failed;
     } else {
@@ -202,13 +204,22 @@ int show_basic_mii(int sock, int phy_id)
     char buf[100];
     int i, mii_val[32];
     int bmcr, bmsr, advert, lkpar;
-
     /* Some bits in the BMSR are latched, but we can't rely on being
        the only reader, so only the current values are meaningful */
     mdio_read(sock, MII_BMSR);
-    for (i = 0; i < ((verbose > 1) ? 32 : 8); i++)
-	mii_val[i] = mdio_read(sock, i);
-
+    for (i = 0; i < ((verbose > 1) ? 32 : 8); i++) {
+        if ((i == MII_BMCR) || (i == MII_BMSR) || (i == MII_PHYSID1) ||
+            (i == MII_PHYSID2) || (i == MII_ADVERTISE) || (i == MII_LPA) ||
+            (i == MII_EXPANSION) || (i == MII_CTRL1000) || (i == MII_STAT1000) ||
+            (i == MII_ESTATUS) || (i == MII_DCOUNTER) || (i == MII_FCSCOUNTER) ||
+            (i == MII_NWAYTEST) || (i == MII_RERRCOUNTER) ||
+            (i == MII_SREVISION) || (i == MII_RESV1) || (i == MII_LBRERROR) ||
+            (i == MII_PHYADDR) || (i == MII_RESV2) ||
+            (i == MII_TPISTATUS) || (i == MII_NCONFIG))
+            mii_val[i] = mdio_read(sock, i);
+        else
+            mii_val[i] = 0;
+    }
     if (mii_val[MII_BMCR] == 0xffff) {
 	fprintf(stderr, "  No MII transceiver present!.\n");
 	return -1;
@@ -216,28 +227,28 @@ int show_basic_mii(int sock, int phy_id)
 
     /* Descriptive rename. */
     bmcr = mii_val[MII_BMCR]; bmsr = mii_val[MII_BMSR];
-    advert = mii_val[MII_ANAR]; lkpar = mii_val[MII_ANLPAR];
+    advert = mii_val[MII_ADVERTISE]; lkpar = mii_val[MII_LPA];
 
     sprintf(buf, "%s: ", ifr.ifr_name);
-    if (bmcr & MII_BMCR_AN_ENA) {
-	if (bmsr & MII_BMSR_AN_COMPLETE) {
+    if (bmcr & BMCR_ANENABLE) {
+	if (bmsr & BMSR_ANEGCOMPLETE) {
 	    if (advert & lkpar) {
-		strcat(buf, (lkpar & MII_AN_ACK) ?
+		strcat(buf, (lkpar & LPA_LPACK) ?
 		       "negotiated" : "no autonegotiation,");
 		strcat(buf, media_list(advert & lkpar, 1));
 		strcat(buf, ", ");
 	    } else {
 		strcat(buf, "autonegotiation failed, ");
 	    }
-	} else if (bmcr & MII_BMCR_RESTART) {
+	} else if (bmcr & BMCR_ANRESTART) {
 	    strcat(buf, "autonegotiation restarted, ");
 	}
     } else {
 	sprintf(buf+strlen(buf), "%s Mbit, %s duplex, ",
-	       (bmcr & MII_BMCR_100MBIT) ? "100" : "10",
-	       (bmcr & MII_BMCR_DUPLEX) ? "full" : "half");
+	       (bmcr & BMCR_SPEED100) ? "100" : "10",
+	       (bmcr & BMCR_FULLDPLX) ? "full" : "half");
     }
-    strcat(buf, (bmsr & MII_BMSR_LINK_VALID) ? "link ok" : "no link");
+    strcat(buf, (bmsr & BMSR_LSTATUS) ? "link ok" : "no link");
 
     if (opt_watch) {
 	if (opt_log) {
@@ -273,32 +284,32 @@ int show_basic_mii(int sock, int phy_id)
 		   ((mii_val[2]<<6)|(mii_val[3]>>10))&0xff,
 		   (mii_val[3]>>4)&0x3f, mii_val[3]&0x0f);
 	printf("  basic mode:   ");
-	if (bmcr & MII_BMCR_RESET)
+	if (bmcr & BMCR_RESET)
 	    printf("software reset, ");
-	if (bmcr & MII_BMCR_LOOPBACK)
+	if (bmcr & BMCR_LOOPBACK)
 	    printf("loopback, ");
-	if (bmcr & MII_BMCR_ISOLATE)
+	if (bmcr & BMCR_ISOLATE)
 	    printf("isolate, ");
-	if (bmcr & MII_BMCR_COLTEST)
+	if (bmcr & BMCR_CTST)
 	    printf("collision test, ");
-	if (bmcr & MII_BMCR_AN_ENA) {
+	if (bmcr & BMCR_ANENABLE) {
 	    printf("autonegotiation enabled\n");
 	} else {
 	    printf("%s Mbit, %s duplex\n",
-		   (bmcr & MII_BMCR_100MBIT) ? "100" : "10",
-		   (bmcr & MII_BMCR_DUPLEX) ? "full" : "half");
+		   (bmcr & BMCR_SPEED100) ? "100" : "10",
+		   (bmcr & BMCR_FULLDPLX) ? "full" : "half");
 	}
 	printf("  basic status: ");
-	if (bmsr & MII_BMSR_AN_COMPLETE)
+	if (bmsr & BMSR_ANEGCOMPLETE)
 	    printf("autonegotiation complete, ");
-	else if (bmcr & MII_BMCR_RESTART)
+	else if (bmcr & BMCR_ANRESTART)
 	    printf("autonegotiation restarted, ");
-	if (bmsr & MII_BMSR_REMOTE_FAULT)
+	if (bmsr & BMSR_RFAULT)
 	    printf("remote fault, ");
-	printf((bmsr & MII_BMSR_LINK_VALID) ? "link ok" : "no link");
+	printf((bmsr & BMSR_LSTATUS) ? "link ok" : "no link");
 	printf("\n  capabilities:%s", media_list(bmsr >> 6, 0));
 	printf("\n  advertising: %s", media_list(advert, 0));
-	if (lkpar & MII_AN_ABILITY_MASK)
+	if (lkpar & LPA_ABILITY_MASK)
 	    printf("\n  link partner:%s", media_list(lkpar, 0));
 	printf("\n");
     }
@@ -310,7 +321,7 @@ int show_basic_mii(int sock, int phy_id)
 
 static int do_one_xcvr(int skfd, char *ifname, int maybe)
 {
-    struct mii_data *mii = (struct mii_data *)&ifr.ifr_data;
+    struct mii_ioctl_data *mii = (struct mii_ioctl_data *)&ifr.ifr_data;
 
     /* Get the vitals from the interface. */
     strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
@@ -328,23 +339,23 @@ static int do_one_xcvr(int skfd, char *i
 
     if (opt_reset) {
 	printf("resetting the transceiver...\n");
-	mdio_write(skfd, MII_BMCR, MII_BMCR_RESET);
+	mdio_write(skfd, MII_BMCR, BMCR_RESET);
     }
     if (nway_advertise) {
-	mdio_write(skfd, MII_ANAR, nway_advertise | 1);
+	mdio_write(skfd, MII_ADVERTISE, nway_advertise | 1);
 	opt_restart = 1;
     }
     if (opt_restart) {
 	printf("restarting autonegotiation...\n");
 	mdio_write(skfd, MII_BMCR, 0x0000);
-	mdio_write(skfd, MII_BMCR, MII_BMCR_AN_ENA|MII_BMCR_RESTART);
+	mdio_write(skfd, MII_BMCR, BMCR_ANENABLE|BMCR_ANRESTART);
     }
     if (fixed_speed) {
 	int bmcr = 0;
-	if (fixed_speed & (MII_AN_100BASETX_FD|MII_AN_100BASETX_HD))
-	    bmcr |= MII_BMCR_100MBIT;
-	if (fixed_speed & (MII_AN_100BASETX_FD|MII_AN_10BASET_FD))
-	    bmcr |= MII_BMCR_DUPLEX;
+	if (fixed_speed & (LPA_100FULL|LPA_100HALF))
+	    bmcr |= BMCR_SPEED100;
+	if (fixed_speed & (LPA_100FULL|LPA_10FULL))
+	    bmcr |= BMCR_FULLDPLX;
 	mdio_write(skfd, MII_BMCR, bmcr);
     }
 
@@ -358,7 +369,7 @@ static int do_one_xcvr(int skfd, char *i
 
 static void watch_one_xcvr(int skfd, char *ifname, int index)
 {
-    struct mii_data *mii = (struct mii_data *)&ifr.ifr_data;
+    struct mii_ioctl_data *mii = (struct mii_ioctl_data *)&ifr.ifr_data;
     static int status[MAX_ETH] = { 0, /* ... */ };
     int now;
 


Index: net-tools.spec
===================================================================
RCS file: /cvs/pkgs/rpms/net-tools/F-12/net-tools.spec,v
retrieving revision 1.102
retrieving revision 1.103
diff -u -p -r1.102 -r1.103
--- net-tools.spec	29 Oct 2009 11:28:17 -0000	1.102
+++ net-tools.spec	4 Nov 2009 13:25:52 -0000	1.103
@@ -3,7 +3,7 @@
 Summary: Basic networking tools
 Name: net-tools
 Version: 1.60
-Release: 96%{?dist}
+Release: 97%{?dist}
 License: GPL+
 Group: System Environment/Base
 URL: http://net-tools.berlios.de/
@@ -106,6 +106,9 @@ Patch77: net-tools-1.60-man-obsolete.pat
 # Bug 531702: make "hostname -s" display host name cut at the first dot (no matter if the host name resolves or not)
 Patch78: net-tools-1.60-hostname-short.patch
 
+# use <linux/mii.h> instead of "mii.h" and fix Bug #491358
+Patch79: net-tools-1.60-mii-refactor.patch
+
 Requires(post): /sbin/chkconfig
 Requires(preun): /sbin/chkconfig
 Requires(preun): /sbin/service
@@ -194,6 +197,7 @@ Most of them are obsolete. For replaceme
 %patch76 -p1 -b .ib-warning
 %patch77 -p1 -b .man-obsolete
 %patch78 -p1 -b .hostname-short
+%patch79 -p1 -b .mii-refactor
 
 cp %SOURCE2 ./config.h
 cp %SOURCE3 ./config.make
@@ -315,6 +319,9 @@ exit 0
 %{_sysconfdir}/rc.d/init.d/netplugd
 
 %changelog
+* Wed Nov  4 2009  Jiri Popelka <jpopelka at redhat.com> - 1.60-97
+- in mii-tool.c use <linux/mii.h> instead of "mii.h" and fix Bug #491358
+
 * Thu Oct 29 2009  Jiri Popelka <jpopelka at redhat.com> - 1.60-96
 - Make "hostname -s" display host name cut at the first dot (no
   matter if the host name resolves or not) (bug #531702)




More information about the fedora-extras-commits mailing list