summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authoradrian <adrian@FreeBSD.org>2016-02-28 06:29:25 +0000
committeradrian <adrian@FreeBSD.org>2016-02-28 06:29:25 +0000
commit48d73dc7387196163174f4b853ee95a5ac5fe166 (patch)
treeb7c9a160521831ee6f8d7dc5987b4c18147bb91a /tools
parenta351ccac7b4fdc59bdb1eeb098f622c6ea99781a (diff)
downloadFreeBSD-src-48d73dc7387196163174f4b853ee95a5ac5fe166.zip
FreeBSD-src-48d73dc7387196163174f4b853ee95a5ac5fe166.tar.gz
Migrate athstats to use the new stats API.
Diffstat (limited to 'tools')
-rw-r--r--tools/tools/ath/athstats/Makefile4
-rw-r--r--tools/tools/ath/athstats/athstats.c35
2 files changed, 23 insertions, 16 deletions
diff --git a/tools/tools/ath/athstats/Makefile b/tools/tools/ath/athstats/Makefile
index 93f98ae..95b01fd 100644
--- a/tools/tools/ath/athstats/Makefile
+++ b/tools/tools/ath/athstats/Makefile
@@ -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>
diff --git a/tools/tools/ath/athstats/athstats.c b/tools/tools/ath/athstats/athstats.c
index bffc512..9115267 100644
--- a/tools/tools/ath/athstats/athstats.c
+++ b/tools/tools/ath/athstats/athstats.c
@@ -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, const char *ifname)
{
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 char *fmtstring)
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 char *fmtstring)
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);
}
OpenPOWER on IntegriCloud