From owner-svn-src-head@freebsd.org Sun Feb 28 06:29:27 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 20527AAE155; Sun, 28 Feb 2016 06:29:27 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EC4CD1E5E; Sun, 28 Feb 2016 06:29:26 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u1S6TPXv004614; Sun, 28 Feb 2016 06:29:25 GMT (envelope-from adrian@FreeBSD.org) Received: (from adrian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u1S6TP0x004612; Sun, 28 Feb 2016 06:29:25 GMT (envelope-from adrian@FreeBSD.org) Message-Id: <201602280629.u1S6TP0x004612@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: adrian set sender to adrian@FreeBSD.org using -f From: Adrian Chadd Date: Sun, 28 Feb 2016 06:29:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r296153 - head/tools/tools/ath/athstats X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Feb 2016 06:29:27 -0000 Author: adrian Date: Sun Feb 28 06:29:25 2016 New Revision: 296153 URL: https://svnweb.freebsd.org/changeset/base/296153 Log: Migrate athstats to use the new stats API. Modified: head/tools/tools/ath/athstats/Makefile head/tools/tools/ath/athstats/athstats.c Modified: head/tools/tools/ath/athstats/Makefile ============================================================================== --- head/tools/tools/ath/athstats/Makefile Sun Feb 28 06:29:07 2016 (r296152) +++ head/tools/tools/ath/athstats/Makefile Sun Feb 28 06:29:25 2016 (r296153) @@ -10,6 +10,10 @@ PROG= athstats SRCS= main.c athstats.c opt_ah.h ah_osdep.h +CFLAGS+= -I${.CURDIR}/../common/ +.PATH.c: ${.CURDIR}/../common/ +SRCS+= ctrl.c + CLEANFILES+= opt_ah.h .include <../Makefile.inc> Modified: head/tools/tools/ath/athstats/athstats.c ============================================================================== --- head/tools/tools/ath/athstats/athstats.c Sun Feb 28 06:29:07 2016 (r296152) +++ head/tools/tools/ath/athstats/athstats.c Sun Feb 28 06:29:25 2016 (r296153) @@ -60,6 +60,8 @@ #include "athstats.h" +#include "ctrl.h" + #ifdef ATH_SUPPORT_ANI #define HAL_EP_RND(x,mul) \ ((((x)%(mul)) >= ((mul)/2)) ? ((x) + ((mul) - 1)) / (mul) : (x)/(mul)) @@ -441,10 +443,9 @@ struct _athstats { struct athstatfoo_p { struct athstatfoo base; - int s; int optstats; + struct ath_driver_req req; #define ATHSTATS_ANI 0x0001 - struct ifreq ifr; struct ath_diag atd; struct _athstats cur; struct _athstats total; @@ -455,7 +456,8 @@ ath_setifname(struct athstatfoo *wf0, co { struct athstatfoo_p *wf = (struct athstatfoo_p *) wf0; - strncpy(wf->ifr.ifr_name, ifname, sizeof (wf->ifr.ifr_name)); + ath_driver_req_close(&wf->req); + (void) ath_driver_req_open(&wf->req, ifname); #ifdef ATH_SUPPORT_ANI strncpy(wf->atd.ad_name, ifname, sizeof (wf->atd.ad_name)); wf->optstats |= ATHSTATS_ANI; @@ -467,30 +469,34 @@ ath_zerostats(struct athstatfoo *wf0) { struct athstatfoo_p *wf = (struct athstatfoo_p *) wf0; - if (ioctl(wf->s, SIOCZATHSTATS, &wf->ifr) < 0) - err(-1, "ioctl: %s", wf->ifr.ifr_name); + if (ath_driver_req_zero_stats(&wf->req) < 0) + exit(-1); } static void ath_collect(struct athstatfoo_p *wf, struct _athstats *stats) { - wf->ifr.ifr_data = (caddr_t) &stats->ath; - if (ioctl(wf->s, SIOCGATHSTATS, &wf->ifr) < 0) - err(1, "ioctl: %s", wf->ifr.ifr_name); + + if (ath_driver_req_fetch_stats(&wf->req, &stats->ath) < 0) + exit(1); #ifdef ATH_SUPPORT_ANI if (wf->optstats & ATHSTATS_ANI) { + + /* XXX TODO: convert */ wf->atd.ad_id = HAL_DIAG_ANI_CURRENT; /* HAL_DIAG_ANI_CURRENT */ wf->atd.ad_out_data = (caddr_t) &stats->ani_state; wf->atd.ad_out_size = sizeof(stats->ani_state); - if (ioctl(wf->s, SIOCGATHDIAG, &wf->atd) < 0) { - warn("ioctl: %s", wf->atd.ad_name); + if (ath_driver_req_fetch_diag(&wf->req, SIOCGATHDIAG, + &wf->atd) < 0) { wf->optstats &= ~ATHSTATS_ANI; } + + /* XXX TODO: convert */ wf->atd.ad_id = HAL_DIAG_ANI_STATS; /* HAL_DIAG_ANI_STATS */ wf->atd.ad_out_data = (caddr_t) &stats->ani_stats; wf->atd.ad_out_size = sizeof(stats->ani_stats); - if (ioctl(wf->s, SIOCGATHDIAG, &wf->atd) < 0) - warn("ioctl: %s", wf->atd.ad_name); + (void) ath_driver_req_fetch_diag(&wf->req, SIOCGATHDIAG, + &wf->atd); } #endif /* ATH_SUPPORT_ANI */ } @@ -1064,6 +1070,7 @@ athstats_new(const char *ifname, const c wf = calloc(1, sizeof(struct athstatfoo_p)); if (wf != NULL) { + ath_driver_req_init(&wf->req); bsdstat_init(&wf->base.base, "athstats", athstats, nitems(athstats)); /* override base methods */ @@ -1083,10 +1090,6 @@ athstats_new(const char *ifname, const c wf->base.setstamac = wlan_setstamac; #endif wf->base.zerostats = ath_zerostats; - wf->s = socket(AF_INET, SOCK_DGRAM, 0); - if (wf->s < 0) - err(1, "socket"); - ath_setifname(&wf->base, ifname); wf->base.setfmt(&wf->base, fmtstring); }