diff options
author | adrian <adrian@FreeBSD.org> | 2012-11-17 02:14:50 +0000 |
---|---|---|
committer | adrian <adrian@FreeBSD.org> | 2012-11-17 02:14:50 +0000 |
commit | 3865e7424abe7562c50deeb55149d8284fee6d1a (patch) | |
tree | fb6d083a45fcf13c0b6a6c47fde74fe27dbca482 | |
parent | 1628ff4ffa03b7ffb63432bc4ae2d03f95e0e4ca (diff) | |
download | FreeBSD-src-3865e7424abe7562c50deeb55149d8284fee6d1a.zip FreeBSD-src-3865e7424abe7562c50deeb55149d8284fee6d1a.tar.gz |
Add AR5211 descriptor decoding support.
-rw-r--r-- | tools/tools/ath/athalq/Makefile | 2 | ||||
-rw-r--r-- | tools/tools/ath/athalq/ar5211_ds.c | 176 | ||||
-rw-r--r-- | tools/tools/ath/athalq/ar5211_ds.h | 24 | ||||
-rw-r--r-- | tools/tools/ath/athalq/main.c | 5 |
4 files changed, 205 insertions, 2 deletions
diff --git a/tools/tools/ath/athalq/Makefile b/tools/tools/ath/athalq/Makefile index edc97d8..6c7b494 100644 --- a/tools/tools/ath/athalq/Makefile +++ b/tools/tools/ath/athalq/Makefile @@ -3,7 +3,7 @@ PROG= athalq NOMAN= yes -SRCS= main.c ar5212_ds.c ar5416_ds.c +SRCS= main.c ar5211_ds.c ar5212_ds.c ar5416_ds.c # SRCS+= ar9300_ds.c .include <../Makefile.inc> diff --git a/tools/tools/ath/athalq/ar5211_ds.c b/tools/tools/ath/athalq/ar5211_ds.c new file mode 100644 index 0000000..0f0984f --- /dev/null +++ b/tools/tools/ath/athalq/ar5211_ds.c @@ -0,0 +1,176 @@ +/* + * Copyright (c) 2012 Adrian Chadd <adrian@FreeBSD.org> + * All Rights Reserved. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <fcntl.h> +#include <errno.h> +#include <string.h> + +#include <sys/types.h> +#include <sys/alq.h> +#include <sys/endian.h> + +#include <dev/ath/if_ath_alq.h> +#include <dev/ath/ath_hal/ar5211/ar5211desc.h> + +#include "ar5211_ds.h" + +#define MS(_v, _f) ( ((_v) & (_f)) >> _f##_S ) +#define MF(_v, _f) ( !! ((_v) & (_f))) + +static void +ar5211_decode_txstatus(struct if_ath_alq_payload *a) +{ + struct ar5211_desc txs; + + /* XXX assumes txs is smaller than PAYLOAD_LEN! */ + memcpy(&txs, &a->payload, sizeof(struct ar5211_desc)); + + printf("[%u] [%llu] TXSTATUS\n", + (unsigned int) be32toh(a->hdr.tstamp), + (unsigned long long) be64toh(a->hdr.threadid)); + + /* ds_txstatus0 */ + printf(" Frmok=%d, xretries=%d, fifounderrun=%d, filt=%d\n", + MF(txs.ds_status0, AR_FrmXmitOK), + MF(txs.ds_status0, AR_ExcessiveRetries), + MF(txs.ds_status0, AR_FIFOUnderrun), + MF(txs.ds_status0, AR_Filtered)); + printf(" LongRetryCnt=%d, ShortRetryCnt=%d, VCollCnt=%d\n", + MS(txs.ds_status0, AR_LongRetryCnt), + MS(txs.ds_status0, AR_ShortRetryCnt), + MS(txs.ds_status0, AR_VirtCollCnt)); + printf(" SndTimestamp=0x%04x\n", + MS(txs.ds_status0, AR_SendTimestamp)); + + /* ds_txstatus1 */ + printf(" Done=%d, SeqNum=0x%04x, AckRSSI=%d\n", + MF(txs.ds_status1, AR_Done), + MS(txs.ds_status1, AR_SeqNum), + MS(txs.ds_status1, AR_AckSigStrength)); + + printf("\n ------\n"); +} + +static void +ar5211_decode_txdesc(struct if_ath_alq_payload *a) +{ + struct ar5211_desc txc; + + /* XXX assumes txs is smaller than PAYLOAD_LEN! */ + memcpy(&txc, &a->payload, sizeof(struct ar5211_desc)); + + printf("[%u] [%llu] TXD\n", + (unsigned int) be32toh(a->hdr.tstamp), + (unsigned long long) be64toh(a->hdr.threadid)); + + printf(" link=0x%08x, data=0x%08x\n", + txc.ds_link, + txc.ds_data); + + /* ds_ctl0 */ + printf(" Frame Len=%d\n", txc.ds_ctl0 & AR_FrameLen); + printf(" TX Rate=0x%02x, RtsEna=%d, Veol=%d, ClrDstMask=%d AntModeXmit=0x%02x\n", + MS(txc.ds_ctl0, AR_XmitRate), + MF(txc.ds_ctl0, AR_RTSCTSEnable), + MF(txc.ds_ctl0, AR_VEOL), + MF(txc.ds_ctl0, AR_ClearDestMask), + MF(txc.ds_ctl0, AR_AntModeXmit)); + printf(" TxIntrReq=%d\n", + MF(txc.ds_ctl0, AR_TxInterReq)); + + /* ds_ctl1 */ + printf(" BufLen=%d, TxMore=%d, EncryptKeyIdx=%d,FrType=0x%x\n", + txc.ds_ctl1 & AR_BufLen, + MF(txc.ds_ctl1, AR_More), + MS(txc.ds_ctl1, AR_EncryptKeyIdx), + MS(txc.ds_ctl1, AR_FrmType)); + printf(" NoAck=%d\n", MF(txc.ds_ctl1, AR_NoAck)); + + printf("\n ------ \n"); +} + +static void +ar5211_decode_rxstatus(struct if_ath_alq_payload *a) +{ + struct ar5211_desc rxs; + + /* XXX assumes rxs is smaller than PAYLOAD_LEN! */ + memcpy(&rxs, &a->payload, sizeof(struct ar5211_desc)); + + printf("[%u] [%llu] RXSTATUS\n", + (unsigned int) be32toh(a->hdr.tstamp), + (unsigned long long) be64toh(a->hdr.threadid)); + + printf(" link=0x%08x, data=0x%08x\n", + rxs.ds_link, + rxs.ds_data); + + /* ds_rxstatus0 */ + printf(" DataLen=%d, ArMore=%d, RSSI=%d, RcvAntenna=0x%x\n", + rxs.ds_status0 & AR_DataLen, + MF(rxs.ds_status0, AR_More), + MS(rxs.ds_status0, AR_RcvSigStrength), + MS(rxs.ds_status0, AR_RcvAntenna)); + + /* ds_rxstatus1 */ + printf(" RxDone=%d, RxFrameOk=%d, CrcErr=%d, DecryptCrcErr=%d\n", + MF(rxs.ds_status1, AR_Done), + MF(rxs.ds_status1, AR_FrmRcvOK), + MF(rxs.ds_status1, AR_CRCErr), + MF(rxs.ds_status1, AR_DecryptCRCErr)); + printf(" KeyIdxValid=%d\n", + MF(rxs.ds_status1, AR_KeyIdxValid)); + + printf(" PhyErrCode=0x%02x\n", + MS(rxs.ds_status1, AR_PHYErr)); + + printf(" KeyMiss=%d\n", + MF(rxs.ds_status1, AR_KeyCacheMiss)); + + printf(" Timetamp: 0x%05x\n", + MS(rxs.ds_status1, AR_RcvTimestamp)); + + printf("\n ------\n"); +} + +void +ar5211_alq_payload(struct if_ath_alq_payload *a) +{ + + switch (be16toh(a->hdr.op)) { + case ATH_ALQ_EDMA_TXSTATUS: /* TXSTATUS */ + ar5211_decode_txstatus(a); + break; + case ATH_ALQ_EDMA_RXSTATUS: /* RXSTATUS */ + ar5211_decode_rxstatus(a); + break; + case ATH_ALQ_EDMA_TXDESC: /* TXDESC */ + ar5211_decode_txdesc(a); + break; + default: + printf("[%d] [%lld] op: %d; len %d\n", + be32toh(a->hdr.tstamp), + be64toh(a->hdr.threadid), + be16toh(a->hdr.op), be16toh(a->hdr.len)); + } +} diff --git a/tools/tools/ath/athalq/ar5211_ds.h b/tools/tools/ath/athalq/ar5211_ds.h new file mode 100644 index 0000000..96d22ac --- /dev/null +++ b/tools/tools/ath/athalq/ar5211_ds.h @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2012 Adrian Chadd <adrian@FreeBSD.org> + * All Rights Reserved. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * $FreeBSD$ + */ +#ifndef __AR5211_DS_H__ +#define __AR5211_DS_H__ + +extern void ar5211_alq_payload(struct if_ath_alq_payload *a); + +#endif /* __AR5211_DS_H__ */ diff --git a/tools/tools/ath/athalq/main.c b/tools/tools/ath/athalq/main.c index 9ce0644..9facbca 100644 --- a/tools/tools/ath/athalq/main.c +++ b/tools/tools/ath/athalq/main.c @@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$"); #if 0 #include "ar9300_ds.h" #endif +#include "ar5211_ds.h" #include "ar5212_ds.h" #include "ar5416_ds.h" @@ -111,7 +112,9 @@ main(int argc, const char *argv[]) ath_alq_print_hdr(&hdr); break; default: - if (be32toh(hdr.sc_hal_magic) == AR5212_MAGIC) + if (be32toh(hdr.sc_hal_magic) == AR5211_MAGIC) + ar5211_alq_payload(a); + else if (be32toh(hdr.sc_hal_magic) == AR5212_MAGIC) ar5212_alq_payload(a); else if (be32toh(hdr.sc_hal_magic) == AR5416_MAGIC) ar5416_alq_payload(a); |