2 * Copyright (c) 2012 Adrian Chadd <adrian@FreeBSD.org>
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 #include <sys/cdefs.h>
19 __FBSDID("$FreeBSD$");
28 #include <sys/types.h>
30 #include <sys/endian.h>
32 #include <dev/ath/if_ath_alq.h>
33 #include <dev/ath/ath_hal/ar5211/ar5211desc.h>
35 #include "ar5211_ds.h"
37 #define MS(_v, _f) ( ((_v) & (_f)) >> _f##_S )
38 #define MF(_v, _f) ( !! ((_v) & (_f)))
41 ar5211_decode_txstatus(struct if_ath_alq_payload *a)
43 struct ar5211_desc txs;
45 /* XXX assumes txs is smaller than PAYLOAD_LEN! */
46 memcpy(&txs, &a->payload, sizeof(struct ar5211_desc));
48 printf("[%u.%06u] [%llu] TXSTATUS\n",
49 (unsigned int) be32toh(a->hdr.tstamp_sec),
50 (unsigned int) be32toh(a->hdr.tstamp_usec),
51 (unsigned long long) be64toh(a->hdr.threadid));
54 printf(" Frmok=%d, xretries=%d, fifounderrun=%d, filt=%d\n",
55 MF(txs.ds_status0, AR_FrmXmitOK),
56 MF(txs.ds_status0, AR_ExcessiveRetries),
57 MF(txs.ds_status0, AR_FIFOUnderrun),
58 MF(txs.ds_status0, AR_Filtered));
59 printf(" LongRetryCnt=%d, ShortRetryCnt=%d, VCollCnt=%d\n",
60 MS(txs.ds_status0, AR_LongRetryCnt),
61 MS(txs.ds_status0, AR_ShortRetryCnt),
62 MS(txs.ds_status0, AR_VirtCollCnt));
63 printf(" SndTimestamp=0x%04x\n",
64 MS(txs.ds_status0, AR_SendTimestamp));
67 printf(" Done=%d, SeqNum=0x%04x, AckRSSI=%d\n",
68 MF(txs.ds_status1, AR_Done),
69 MS(txs.ds_status1, AR_SeqNum),
70 MS(txs.ds_status1, AR_AckSigStrength));
72 printf("\n ------\n");
76 ar5211_decode_txdesc(struct if_ath_alq_payload *a)
78 struct ar5211_desc txc;
80 /* XXX assumes txs is smaller than PAYLOAD_LEN! */
81 memcpy(&txc, &a->payload, sizeof(struct ar5211_desc));
83 printf("[%u.%06u] [%llu] TXD\n",
84 (unsigned int) be32toh(a->hdr.tstamp_sec),
85 (unsigned int) be32toh(a->hdr.tstamp_usec),
86 (unsigned long long) be64toh(a->hdr.threadid));
88 printf(" link=0x%08x, data=0x%08x\n",
93 printf(" Frame Len=%d\n", txc.ds_ctl0 & AR_FrameLen);
94 printf(" TX Rate=0x%02x, RtsEna=%d, Veol=%d, ClrDstMask=%d AntModeXmit=0x%02x\n",
95 MS(txc.ds_ctl0, AR_XmitRate),
96 MF(txc.ds_ctl0, AR_RTSCTSEnable),
97 MF(txc.ds_ctl0, AR_VEOL),
98 MF(txc.ds_ctl0, AR_ClearDestMask),
99 MF(txc.ds_ctl0, AR_AntModeXmit));
100 printf(" TxIntrReq=%d\n",
101 MF(txc.ds_ctl0, AR_TxInterReq));
104 printf(" BufLen=%d, TxMore=%d, EncryptKeyIdx=%d,FrType=0x%x\n",
105 txc.ds_ctl1 & AR_BufLen,
106 MF(txc.ds_ctl1, AR_More),
107 MS(txc.ds_ctl1, AR_EncryptKeyIdx),
108 MS(txc.ds_ctl1, AR_FrmType));
109 printf(" NoAck=%d\n", MF(txc.ds_ctl1, AR_NoAck));
111 printf("\n ------ \n");
115 ar5211_decode_rxstatus(struct if_ath_alq_payload *a)
117 struct ar5211_desc rxs;
119 /* XXX assumes rxs is smaller than PAYLOAD_LEN! */
120 memcpy(&rxs, &a->payload, sizeof(struct ar5211_desc));
122 printf("[%u.%06u] [%llu] RXSTATUS\n",
123 (unsigned int) be32toh(a->hdr.tstamp_sec),
124 (unsigned int) be32toh(a->hdr.tstamp_usec),
125 (unsigned long long) be64toh(a->hdr.threadid));
127 printf(" link=0x%08x, data=0x%08x\n",
132 printf(" DataLen=%d, ArMore=%d, RSSI=%d, RcvAntenna=0x%x\n",
133 rxs.ds_status0 & AR_DataLen,
134 MF(rxs.ds_status0, AR_More),
135 MS(rxs.ds_status0, AR_RcvSigStrength),
136 MS(rxs.ds_status0, AR_RcvAntenna));
139 printf(" RxDone=%d, RxFrameOk=%d, CrcErr=%d, DecryptCrcErr=%d\n",
140 MF(rxs.ds_status1, AR_Done),
141 MF(rxs.ds_status1, AR_FrmRcvOK),
142 MF(rxs.ds_status1, AR_CRCErr),
143 MF(rxs.ds_status1, AR_DecryptCRCErr));
144 printf(" KeyIdxValid=%d\n",
145 MF(rxs.ds_status1, AR_KeyIdxValid));
147 printf(" PhyErrCode=0x%02x\n",
148 MS(rxs.ds_status1, AR_PHYErr));
150 printf(" KeyMiss=%d\n",
151 MF(rxs.ds_status1, AR_KeyCacheMiss));
153 printf(" Timetamp: 0x%05x\n",
154 MS(rxs.ds_status1, AR_RcvTimestamp));
156 printf("\n ------\n");
160 ar5211_alq_payload(struct if_ath_alq_payload *a)
163 switch (be16toh(a->hdr.op)) {
164 case ATH_ALQ_EDMA_TXSTATUS: /* TXSTATUS */
165 ar5211_decode_txstatus(a);
167 case ATH_ALQ_EDMA_RXSTATUS: /* RXSTATUS */
168 ar5211_decode_rxstatus(a);
170 case ATH_ALQ_EDMA_TXDESC: /* TXDESC */
171 ar5211_decode_txdesc(a);
174 printf("[%d.%06d] [%lld] op: %d; len %d\n",
175 be32toh(a->hdr.tstamp_sec),
176 be32toh(a->hdr.tstamp_usec),
177 be64toh(a->hdr.threadid),
178 be16toh(a->hdr.op), be16toh(a->hdr.len));