Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 30 Nov 2004 01:11:45 GMT
From:      Sam Leffler <sam@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 66079 for review
Message-ID:  <200411300111.iAU1BjPa048947@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=66079

Change 66079 by sam@sam_ebb on 2004/11/30 01:10:49

	now that SIOCGATHSTATS returns in+out packet counts there's
	no need to read kmem

Affected files ...

.. //depot/projects/wifi/tools/tools/ath/Makefile#4 edit
.. //depot/projects/wifi/tools/tools/ath/athstats.c#4 edit

Differences ...

==== //depot/projects/wifi/tools/tools/ath/Makefile#4 (text+ko) ====

@@ -31,7 +31,7 @@
 all:	${ALL}
 
 athstats: athstats.c
-	${CC} -o athstats athstats.c -lkvm
+	${CC} -o athstats athstats.c
 athdebug: athdebug.c
 	${CC} -o athdebug athdebug.c
 80211stats: 80211stats.c
@@ -41,7 +41,7 @@
 80211debug: 80211debug.c
 	${CC} -o 80211debug 80211debug.c
 install: ${ALL}
-	install -g kmem -m 2755 athstats ${DESTDIR}${BINDIR}
+	install athstats ${DESTDIR}${BINDIR}
 	install 80211stats ${DESTDIR}${BINDIR}
 	install 80211watch ${DESTDIR}${BINDIR}
 	install 80211debug ${DESTDIR}${BINDIR}

==== //depot/projects/wifi/tools/tools/ath/athstats.c#4 (text+ko) ====

@@ -55,8 +55,6 @@
 
 #include <stdio.h>
 #include <signal.h>
-#include <kvm.h>
-#include <nlist.h>
 
 #include "../../../sys/contrib/dev/ath/ah_desc.h"
 #include "../../../sys/net80211/ieee80211_ioctl.h"
@@ -215,78 +213,6 @@
 #undef N
 }
 
-static kvm_t *kvmd;
-static char *nlistf = NULL;
-static char *memf = NULL;
-
-static struct nlist nl[] = {
-#define	N_IFNET	0
-	{ "_ifnet" },
-};
-
-/*
- * Read kernel memory, return 0 on success.
- */
-static int
-kread(u_long addr, void *buf, int size)
-{
-	if (kvmd == 0) {
-		/*
-		 * XXX.
-		 */
-		kvmd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY, buf);
-		setgid(getgid());
-		if (kvmd != NULL) {
-			if (kvm_nlist(kvmd, nl) < 0) {
-				if(nlistf)
-					errx(1, "%s: kvm_nlist: %s", nlistf,
-					     kvm_geterr(kvmd));
-				else
-					errx(1, "kvm_nlist: %s", kvm_geterr(kvmd));
-			}
-
-			if (nl[0].n_type == 0) {
-				if(nlistf)
-					errx(1, "%s: no namelist", nlistf);
-				else
-					errx(1, "no namelist");
-			}
-		} else {
-			warnx("kvm not available");
-			return(-1);
-		}
-	}
-	if (!buf)
-		return (0);
-	if (kvm_read(kvmd, addr, buf, size) != size) {
-		warnx("%s", kvm_geterr(kvmd));
-		return (-1);
-	}
-	return (0);
-}
-
-static u_long
-ifnetsetup(const char *interface, u_long off)
-{
-	struct ifnet ifnet;
-	u_long firstifnet;
-	struct ifnethead ifnethead;
-
-	if (kread(off, (char *)&ifnethead, sizeof ifnethead))
-		return;
-	firstifnet = (u_long)TAILQ_FIRST(&ifnethead);
-	for (off = firstifnet; off;) {
-		char name[IFNAMSIZ];
-
-		if (kread(off, (char *)&ifnet, sizeof ifnet))
-			break;
-		if (interface && strcmp(ifnet.if_xname, interface) == 0)
-			return off;
-		off = (u_long)TAILQ_NEXT(&ifnet, if_link);
-	}
-	return 0;
-}
-
 static int signalled;
 
 static void
@@ -316,14 +242,9 @@
 		strncpy(ifr.ifr_name, "ath0", sizeof (ifr.ifr_name));
 	if (argc > 1) {
 		u_long interval = strtoul(argv[1], NULL, 0);
-		u_long off;
 		int line, omask;
 		u_int rate = getifrate(s, ifr.ifr_name);
 		struct ath_stats cur, total;
-		struct ifnet ifcur, iftot;
-
-		kread(0, 0, 0);
-		off = ifnetsetup(ifr.ifr_name, nl[N_IFNET].n_value);
 
 		if (interval < 1)
 			interval = 1;
@@ -353,11 +274,9 @@
 			if (ioctl(s, SIOCGATHSTATS, &ifr) < 0)
 				err(1, ifr.ifr_name);
 			rate = getifrate(s, ifr.ifr_name);
-			if (kread(off, &ifcur, sizeof(ifcur)))
-				err(1, ifr.ifr_name);
 			printf("%8u %8u %7u %7u %7u %6u %6u %5u %7u %4u %3uM\n"
-				, ifcur.if_ipackets - iftot.if_ipackets
-				, ifcur.if_opackets - iftot.if_opackets
+				, cur.ast_rx_packets - total.ast_rx_packets
+				, cur.ast_tx_packets - total.ast_tx_packets
 				, cur.ast_tx_altrate - total.ast_tx_altrate
 				, cur.ast_tx_shortretry - total.ast_tx_shortretry
 				, cur.ast_tx_longretry - total.ast_tx_longretry
@@ -369,17 +288,14 @@
 				, rate
 			);
 			total = cur;
-			iftot = ifcur;
 		} else {
 			ifr.ifr_data = (caddr_t) &total;
 			if (ioctl(s, SIOCGATHSTATS, &ifr) < 0)
 				err(1, ifr.ifr_name);
 			rate = getifrate(s, ifr.ifr_name);
-			if (kread(off, &iftot, sizeof(iftot)))
-				err(1, ifr.ifr_name);
 			printf("%8u %8u %7u %7u %7u %6u %6u %5u %7u %4u %3uM\n"
-				, iftot.if_ipackets
-				, iftot.if_opackets
+				, total.ast_rx_packets
+				, total.ast_tx_packets
 				, total.ast_tx_altrate
 				, total.ast_tx_shortretry
 				, total.ast_tx_longretry



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200411300111.iAU1BjPa048947>