From owner-p4-projects@FreeBSD.ORG Tue Nov 30 01:11:46 2004 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id E232F16A4D0; Tue, 30 Nov 2004 01:11:45 +0000 (GMT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A842C16A4CE for ; Tue, 30 Nov 2004 01:11:45 +0000 (GMT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 83BD443D46 for ; Tue, 30 Nov 2004 01:11:45 +0000 (GMT) (envelope-from sam@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id iAU1BjS3048950 for ; Tue, 30 Nov 2004 01:11:45 GMT (envelope-from sam@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id iAU1BjPa048947 for perforce@freebsd.org; Tue, 30 Nov 2004 01:11:45 GMT (envelope-from sam@freebsd.org) Date: Tue, 30 Nov 2004 01:11:45 GMT Message-Id: <200411300111.iAU1BjPa048947@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to sam@freebsd.org using -f From: Sam Leffler To: Perforce Change Reviews Subject: PERFORCE change 66079 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Nov 2004 01:11:46 -0000 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 #include -#include -#include #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