Date: Fri, 1 Jul 2011 23:03:15 -0700 From: ss griffon <ssgriffonuser@gmail.com> To: freebsd-wireless@freebsd.org Subject: Patch to move global ath alq register logging to per device Message-ID: <CAFYJ9egpYqwVp-g7g%2B5k_9Ex0JQZQid%2BKiC4DXYL3rCy8qGKPQ@mail.gmail.com>
index | next in thread | raw e-mail
[-- Attachment #1 --]
This enables register logging for each ath device. The default log
path is /tmp/ath_hal<dev_num>.log but can be changed with the sysctl
dev.ath.<dev_num>.hal.alq_logfile. Let me know if there are any
issues.
[-- Attachment #2 --]
Index: ath_hal/ah_decode.h
===================================================================
--- ath_hal/ah_decode.h (revision 223591)
+++ ath_hal/ah_decode.h (working copy)
@@ -21,9 +21,9 @@
/*
* Register tracing support.
*
- * Setting hw.ath.hal.alq=1 enables tracing of all register reads and
- * writes to the file /tmp/ath_hal.log. The file format is a simple
- * fixed-size array of records. When done logging set hw.ath.hal.alq=0
+ * Setting dev.ath.<dev_num>.hal.alq=1 enables tracing of all register reads and
+ * writes to the file /tmp/ath_hal<dev_num>.log. The file format is a simple
+ * fixed-size array of records. When done logging set dev.ath.<dev_num>.hal.alq=0
* and then decode the file with the arcode program (that is part of the
* HAL). If you start+stop tracing the data will be appended to an
* existing file.
Index: ath_hal/ah.h
===================================================================
--- ath_hal/ah.h (revision 223591)
+++ ath_hal/ah.h (working copy)
@@ -765,6 +765,12 @@
int ah_dma_beacon_response_time;/* in TU's */
int ah_sw_beacon_response_time; /* in TU's */
int ah_additional_swba_backoff; /* in TU's */
+
+ struct alq *ah_alq;
+ int ah_alq_emitdev; /* need to emit DEVICE record */
+ u_int ah_alq_lost; /* count of lost records */
+ char ah_logfile[MAXPATHLEN];
+ u_int ah_alq_qsize;
}HAL_OPS_CONFIG;
/*
Index: ah_osdep.c
===================================================================
--- ah_osdep.c (revision 223591)
+++ ah_osdep.c (working copy)
@@ -141,9 +141,9 @@
/*
* ALQ register tracing support.
*
- * Setting hw.ath.hal.alq=1 enables tracing of all register reads and
- * writes to the file /tmp/ath_hal.log. The file format is a simple
- * fixed-size array of records. When done logging set hw.ath.hal.alq=0
+ * Setting dev.ath.<dev_num>.hal.alq=1 enables tracing of all register reads and
+ * writes to the file /tmp/ath_hal<dev_num>.log. The file format is a simple
+ * fixed-size array of records. When done logging set dev.ath.<dev_num>.hal.alq=0
* and then decode the file with the arcode program (that is part of the
* HAL). If you start+stop tracing the data will be appended to an
* existing file.
@@ -155,33 +155,23 @@
#include <sys/pcpu.h>
#include <dev/ath/ath_hal/ah_decode.h>
-static struct alq *ath_hal_alq;
-static int ath_hal_alq_emitdev; /* need to emit DEVICE record */
-static u_int ath_hal_alq_lost; /* count of lost records */
-static char ath_hal_logfile[MAXPATHLEN] = "/tmp/ath_hal.log";
-
-SYSCTL_STRING(_hw_ath_hal, OID_AUTO, alq_logfile, CTLFLAG_RW,
- &ath_hal_logfile, sizeof(kernelname), "Name of ALQ logfile");
-
-static u_int ath_hal_alq_qsize = 64*1024;
-
static int
-ath_hal_setlogging(int enable)
+ath_hal_setlogging(struct ath_hal *ah, int enable)
{
int error;
if (enable) {
- error = alq_open(&ath_hal_alq, ath_hal_logfile,
+ error = alq_open(&ah->ah_config.ah_alq, ah->ah_config.ah_logfile,
curthread->td_ucred, ALQ_DEFAULT_CMODE,
- sizeof (struct athregrec), ath_hal_alq_qsize);
- ath_hal_alq_lost = 0;
- ath_hal_alq_emitdev = 1;
+ sizeof (struct athregrec), ah->ah_config.ah_alq_qsize);
+ ah->ah_config.ah_alq_lost = 0;
+ ah->ah_config.ah_alq_emitdev = 1;
printf("ath_hal: logging to %s enabled\n",
- ath_hal_logfile);
+ ah->ah_config.ah_logfile);
} else {
- if (ath_hal_alq)
- alq_close(ath_hal_alq);
- ath_hal_alq = NULL;
+ if (ah->ah_config.ah_alq)
+ alq_close(ah->ah_config.ah_alq);
+ ah->ah_config.ah_alq = NULL;
printf("ath_hal: logging disabled\n");
error = 0;
}
@@ -192,42 +182,63 @@
sysctl_hw_ath_hal_log(SYSCTL_HANDLER_ARGS)
{
int error, enable;
+ struct ath_hal *ah = arg1;
- enable = (ath_hal_alq != NULL);
+ enable = (ah->ah_config.ah_alq != NULL);
error = sysctl_handle_int(oidp, &enable, 0, req);
if (error || !req->newptr)
return (error);
else
- return (ath_hal_setlogging(enable));
+ return (ath_hal_setlogging(ah, enable));
}
-SYSCTL_PROC(_hw_ath_hal, OID_AUTO, alq, CTLTYPE_INT|CTLFLAG_RW,
- 0, 0, sysctl_hw_ath_hal_log, "I", "Enable HAL register logging");
-SYSCTL_INT(_hw_ath_hal, OID_AUTO, alq_size, CTLFLAG_RW,
- &ath_hal_alq_qsize, 0, "In-memory log size (#records)");
-SYSCTL_INT(_hw_ath_hal, OID_AUTO, alq_lost, CTLFLAG_RW,
- &ath_hal_alq_lost, 0, "Register operations not logged");
+
+void
+ath_sysctl_hal_alq_attach(struct sysctl_ctx_list *ctx,
+ struct sysctl_oid_list *child,
+ struct ath_hal *ah,
+ int device_num)
+{
+ snprintf(ah->ah_config.ah_logfile, MAXPATHLEN,
+ "/tmp/ath_hal%d.log", device_num);
+
+ SYSCTL_ADD_STRING(ctx, child, OID_AUTO, "alq_logfile", CTLFLAG_RW,
+ ah->ah_config.ah_logfile, MAXPATHLEN, "Name of ALQ logfile");
+
+ ah->ah_config.ah_alq_qsize = 64*1024;
+ SYSCTL_ADD_INT(ctx, child, OID_AUTO, "alq_size", CTLFLAG_RW,
+ &ah->ah_config.ah_alq_qsize, 0, "In-memory log size (#records)");
+ SYSCTL_ADD_INT(ctx, child, OID_AUTO, "alq_lost", CTLFLAG_RW,
+ &ah->ah_config.ah_alq_lost, 0, "Register operations not logged");
+
+
+ SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "alq", CTLTYPE_INT|CTLFLAG_RW,
+ ah, 0, sysctl_hw_ath_hal_log, "I", "Enable HAL register logging");
+
+ return;
+}
+
static struct ale *
ath_hal_alq_get(struct ath_hal *ah)
{
struct ale *ale;
- if (ath_hal_alq_emitdev) {
- ale = alq_get(ath_hal_alq, ALQ_NOWAIT);
+ if (ah->ah_config.ah_alq_emitdev) {
+ ale = alq_get(ah->ah_config.ah_alq, ALQ_NOWAIT);
if (ale) {
struct athregrec *r =
(struct athregrec *) ale->ae_data;
r->op = OP_DEVICE;
r->reg = 0;
r->val = ah->ah_devid;
- alq_post(ath_hal_alq, ale);
- ath_hal_alq_emitdev = 0;
+ alq_post(ah->ah_config.ah_alq, ale);
+ ah->ah_config.ah_alq_emitdev = 0;
} else
- ath_hal_alq_lost++;
+ ah->ah_config.ah_alq_lost++;
}
- ale = alq_get(ath_hal_alq, ALQ_NOWAIT);
+ ale = alq_get(ah->ah_config.ah_alq, ALQ_NOWAIT);
if (!ale)
- ath_hal_alq_lost++;
+ ah->ah_config.ah_alq_lost++;
return ale;
}
@@ -237,14 +248,14 @@
bus_space_tag_t tag = BUSTAG(ah);
bus_space_handle_t h = ah->ah_sh;
- if (ath_hal_alq) {
+ if (ah->ah_config.ah_alq) {
struct ale *ale = ath_hal_alq_get(ah);
if (ale) {
struct athregrec *r = (struct athregrec *) ale->ae_data;
r->op = OP_WRITE;
r->reg = reg;
r->val = val;
- alq_post(ath_hal_alq, ale);
+ alq_post(ah->ah_config.ah_alq, ale);
}
}
#if _BYTE_ORDER == _BIG_ENDIAN
@@ -268,14 +279,14 @@
else
#endif
val = bus_space_read_stream_4(tag, h, reg);
- if (ath_hal_alq) {
+ if (ah->ah_config.ah_alq) {
struct ale *ale = ath_hal_alq_get(ah);
if (ale) {
struct athregrec *r = (struct athregrec *) ale->ae_data;
r->op = OP_READ;
r->reg = reg;
r->val = val;
- alq_post(ath_hal_alq, ale);
+ alq_post(ah->ah_config.ah_alq, ale);
}
}
return val;
@@ -284,14 +295,14 @@
void
OS_MARK(struct ath_hal *ah, u_int id, u_int32_t v)
{
- if (ath_hal_alq) {
+ if (ah->ah_config.ah_alq) {
struct ale *ale = ath_hal_alq_get(ah);
if (ale) {
struct athregrec *r = (struct athregrec *) ale->ae_data;
r->op = OP_MARK;
r->reg = id;
r->val = v;
- alq_post(ath_hal_alq, ale);
+ alq_post(ah->ah_config.ah_alq, ale);
}
}
}
Index: ah_osdep.h
===================================================================
--- ah_osdep.h (revision 223591)
+++ ah_osdep.h (working copy)
@@ -35,6 +35,7 @@
*/
#include <sys/cdefs.h>
#include <sys/param.h>
+#include <sys/sysctl.h>
#include <sys/systm.h>
#include <sys/endian.h>
#include <sys/linker_set.h>
@@ -133,6 +134,10 @@
#ifdef AH_DEBUG_ALQ
extern void OS_MARK(struct ath_hal *, u_int id, u_int32_t value);
+extern void ath_sysctl_hal_alq_attach( struct sysctl_ctx_list *ctx,
+ struct sysctl_oid_list *child,
+ struct ath_hal *ah,
+ int device_num);
#else
#define OS_MARK(_ah, _id, _v)
#endif
Index: if_ath_sysctl.c
===================================================================
--- if_ath_sysctl.c (revision 223591)
+++ if_ath_sysctl.c (working copy)
@@ -758,4 +758,10 @@
SYSCTL_ADD_INT(ctx, child, OID_AUTO, "swba_backoff", CTLFLAG_RW,
&sc->sc_ah->ah_config.ah_additional_swba_backoff, 0,
"Atheros HAL additional SWBA backoff time");
+
+#if defined (AH_DEBUG_ALQ)
+ int device_num = device_get_unit(sc->sc_dev);
+ ath_sysctl_hal_alq_attach(ctx, child, sc->sc_ah, device_num);
+#endif /*AH_DEBUG_ALQ*/
+
}
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAFYJ9egpYqwVp-g7g%2B5k_9Ex0JQZQid%2BKiC4DXYL3rCy8qGKPQ>
