Migrate athregs over to use the new stats API.

This commit is contained in:
Adrian Chadd 2016-02-28 06:30:39 +00:00
parent 4f0edd39f8
commit f0ea23b254
2 changed files with 24 additions and 6 deletions

View File

@ -2,9 +2,12 @@
PROG= athregs PROG= athregs
CFLAGS+= -I${.CURDIR}/../common/
.PATH.c: ${.CURDIR}/../common .PATH.c: ${.CURDIR}/../common
SRCS= dumpregs.c SRCS= dumpregs.c
SRCS+= ctrl.c
SRCS+= dumpregs_5210.c SRCS+= dumpregs_5210.c
SRCS+= dumpregs_5211.c SRCS+= dumpregs_5211.c
SRCS+= dumpregs_5212.c SRCS+= dumpregs_5212.c

View File

@ -43,6 +43,8 @@
#include <ctype.h> #include <ctype.h>
#include <err.h> #include <err.h>
#include "ctrl.h"
typedef struct { typedef struct {
HAL_REVS revs; HAL_REVS revs;
u_int32_t regdata[0xffff / sizeof(u_int32_t)]; u_int32_t regdata[0xffff / sizeof(u_int32_t)];
@ -93,11 +95,11 @@ main(int argc, char *argv[])
const char *ifname; const char *ifname;
u_int32_t *data; u_int32_t *data;
u_int32_t *dp, *ep; u_int32_t *dp, *ep;
int what, c, s, i; int what, c, i;
struct ath_driver_req req;
ath_driver_req_init(&req);
s = socket(AF_INET, SOCK_DGRAM, 0);
if (s < 0)
err(1, "socket");
ifname = getenv("ATH"); ifname = getenv("ATH");
if (!ifname) if (!ifname)
ifname = ATH_DEFAULT; ifname = ATH_DEFAULT;
@ -144,6 +146,16 @@ main(int argc, char *argv[])
usage(); usage();
/*NOTREACHED*/ /*NOTREACHED*/
} }
/* Initialise the driver interface */
if (ath_driver_req_open(&req, ifname) < 0) {
exit(127);
}
/*
* Whilst we're doing the ath_diag pieces, we have to set this
* ourselves.
*/
strncpy(atd.ad_name, ifname, sizeof (atd.ad_name)); strncpy(atd.ad_name, ifname, sizeof (atd.ad_name));
argc -= optind; argc -= optind;
@ -154,7 +166,8 @@ main(int argc, char *argv[])
atd.ad_id = HAL_DIAG_REVS; atd.ad_id = HAL_DIAG_REVS;
atd.ad_out_data = (caddr_t) &state.revs; atd.ad_out_data = (caddr_t) &state.revs;
atd.ad_out_size = sizeof(state.revs); atd.ad_out_size = sizeof(state.revs);
if (ioctl(s, SIOCGATHDIAG, &atd) < 0)
if (ath_driver_req_fetch_diag(&req, SIOCGATHDIAG, &atd) < 0)
err(1, "%s", atd.ad_name); err(1, "%s", atd.ad_name);
if (ath_hal_setupregs(&atd, what) == 0) if (ath_hal_setupregs(&atd, what) == 0)
@ -172,7 +185,8 @@ main(int argc, char *argv[])
exit(-1); exit(-1);
} }
atd.ad_id = HAL_DIAG_REGS | ATH_DIAG_IN | ATH_DIAG_DYN; atd.ad_id = HAL_DIAG_REGS | ATH_DIAG_IN | ATH_DIAG_DYN;
if (ioctl(s, SIOCGATHDIAG, &atd) < 0)
if (ath_driver_req_fetch_diag(&req, SIOCGATHDIAG, &atd) < 0)
err(1, "%s", atd.ad_name); err(1, "%s", atd.ad_name);
/* /*
@ -238,6 +252,7 @@ main(int argc, char *argv[])
fprintf(stdout, "\n"); fprintf(stdout, "\n");
ath_hal_dumpbb(stdout, what); ath_hal_dumpbb(stdout, what);
} }
ath_driver_req_close(&req);
return 0; return 0;
} }