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/ar5212/ar5212desc.h>
35 #include "ar5212_ds.h"
37 #define MS(_v, _f) ( ((_v) & (_f)) >> _f##_S )
38 #define MF(_v, _f) ( !! ((_v) & (_f)))
41 ar5212_decode_txstatus(struct if_ath_alq_payload *a)
43 struct ar5212_desc txs;
45 /* XXX assumes txs is smaller than PAYLOAD_LEN! */
46 memcpy(&txs, &a->payload, sizeof(struct ar5212_desc));
48 printf("[%u.%06u] [%llu] TXSTATUS: TxDone=%d, TS=0x%08x\n\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),
52 MF(txs.u.tx.status1, AR_Done),
53 MS(txs.u.tx.status0, AR_SendTimestamp));
56 printf(" Frmok=%d, xretries=%d, fifounderrun=%d, filt=%d\n",
57 MF(txs.u.tx.status0, AR_FrmXmitOK),
58 MF(txs.u.tx.status0, AR_ExcessiveRetries),
59 MF(txs.u.tx.status0, AR_FIFOUnderrun),
60 MF(txs.u.tx.status0, AR_Filtered));
61 printf(" RTScnt=%d, FailCnt=%d, VCollCnt=%d\n",
62 MS(txs.u.tx.status0, AR_RTSFailCnt),
63 MS(txs.u.tx.status0, AR_DataFailCnt),
64 MS(txs.u.tx.status0, AR_VirtCollCnt));
65 printf(" SndTimestamp=0x%04x\n",
66 MS(txs.u.tx.status0, AR_SendTimestamp));
69 printf(" Done=%d, SeqNum=0x%04x, AckRSSI=%d, FinalTSI=%d\n",
70 MF(txs.u.tx.status1, AR_Done),
71 MS(txs.u.tx.status1, AR_SeqNum),
72 MS(txs.u.tx.status1, AR_AckSigStrength),
73 MS(txs.u.tx.status1, AR_FinalTSIndex));
74 printf(" CompSuccess=%d, XmitAntenna=%d\n",
75 MF(txs.u.tx.status1, AR_CompSuccess),
76 MF(txs.u.tx.status1, AR_XmitAtenna));
78 printf("\n ------\n");
82 ar5212_decode_txdesc(struct if_ath_alq_payload *a)
84 struct ar5212_desc txc;
86 /* XXX assumes txs is smaller than PAYLOAD_LEN! */
87 memcpy(&txc, &a->payload, sizeof(struct ar5212_desc));
89 printf("[%u.%06u] [%llu] TXD\n",
90 (unsigned int) be32toh(a->hdr.tstamp_sec),
91 (unsigned int) be32toh(a->hdr.tstamp_usec),
92 (unsigned long long) be64toh(a->hdr.threadid));
94 printf(" link=0x%08x, data=0x%08x\n",
99 printf(" Frame Len=%d\n", txc.ds_ctl0 & AR_FrameLen);
100 printf(" TX power0=%d, RtsEna=%d, Veol=%d, ClrDstMask=%d AntModeXmit=0x%02x\n",
101 MS(txc.ds_ctl0, AR_XmitPower),
102 MF(txc.ds_ctl0, AR_RTSCTSEnable),
103 MF(txc.ds_ctl0, AR_VEOL),
104 MF(txc.ds_ctl0, AR_ClearDestMask),
105 MF(txc.ds_ctl0, AR_AntModeXmit));
106 printf(" TxIntrReq=%d, DestIdxValid=%d, CtsEnable=%d\n",
107 MF(txc.ds_ctl0, AR_TxInterReq),
108 MF(txc.ds_ctl0, AR_DestIdxValid),
109 MF(txc.ds_ctl0, AR_CTSEnable));
112 printf(" BufLen=%d, TxMore=%d, DestIdx=%d,"
114 txc.ds_ctl1 & AR_BufLen,
115 MF(txc.ds_ctl1, AR_More),
116 MS(txc.ds_ctl1, AR_DestIdx),
117 MS(txc.ds_ctl1, AR_FrmType));
118 printf(" NoAck=%d, CompProc=%d, CompIVLen=%d, CompICVLen=%d\n",
119 MF(txc.ds_ctl1, AR_NoAck),
120 MS(txc.ds_ctl1, AR_CompProc),
121 MS(txc.ds_ctl1, AR_CompIVLen),
122 MS(txc.ds_ctl1, AR_CompICVLen));
125 printf(" DurUpEna=%d, Burstdur=0x%04x\n",
126 MF(txc.ds_ctl2, AR_DurUpdateEna),
127 MS(txc.ds_ctl2, AR_RTSCTSDuration));
128 printf(" Try0=%d, Try1=%d, Try2=%d, Try3=%d\n",
129 MS(txc.ds_ctl2, AR_XmitDataTries0),
130 MS(txc.ds_ctl2, AR_XmitDataTries1),
131 MS(txc.ds_ctl2, AR_XmitDataTries2),
132 MS(txc.ds_ctl2, AR_XmitDataTries3));
135 printf(" rate0=0x%02x, rate1=0x%02x, rate2=0x%02x, rate3=0x%02x\n",
136 MS(txc.ds_ctl3, AR_XmitRate0),
137 MS(txc.ds_ctl3, AR_XmitRate1),
138 MS(txc.ds_ctl3, AR_XmitRate2),
139 MS(txc.ds_ctl3, AR_XmitRate3));
140 printf(" RtsCtsRate=0x%02x\n",
141 MS(txc.ds_ctl3, AR_RTSCTSRate));
143 printf("\n ------ \n");
147 ar5212_decode_rxstatus(struct if_ath_alq_payload *a)
149 struct ar5212_desc rxs;
151 /* XXX assumes rxs is smaller than PAYLOAD_LEN! */
152 memcpy(&rxs, &a->payload, sizeof(struct ar5212_desc));
154 printf("[%u.%06u] [%llu] RXSTATUS: RxOK=%d TS=0x%08x\n",
155 (unsigned int) be32toh(a->hdr.tstamp_sec),
156 (unsigned int) be32toh(a->hdr.tstamp_usec),
157 (unsigned long long) be64toh(a->hdr.threadid),
158 MF(rxs.ds_rxstatus1, AR_Done),
159 MS(rxs.ds_rxstatus1, AR_RcvTimestamp));
161 printf(" link=0x%08x, data=0x%08x, ctl0=0x%08x, ctl2=0x%08x\n",
168 printf(" DataLen=%d, ArMore=%d, DecompCrcError=%d, RcvRate=0x%02x\n",
169 rxs.ds_rxstatus0 & AR_DataLen,
170 MF(rxs.ds_rxstatus0, AR_More),
171 MF(rxs.ds_rxstatus0, AR_DecompCRCErr),
172 MS(rxs.ds_rxstatus0, AR_RcvRate));
173 printf(" RSSI=%d, RcvAntenna=0x%x\n",
174 MS(rxs.ds_rxstatus0, AR_RcvSigStrength),
175 MS(rxs.ds_rxstatus0, AR_RcvAntenna));
178 printf(" RxDone=%d, RxFrameOk=%d, CrcErr=%d, DecryptCrcErr=%d\n",
179 MF(rxs.ds_rxstatus1, AR_Done),
180 MF(rxs.ds_rxstatus1, AR_FrmRcvOK),
181 MF(rxs.ds_rxstatus1, AR_CRCErr),
182 MF(rxs.ds_rxstatus1, AR_DecryptCRCErr));
183 printf(" PhyErr=%d, MichaelErr=%d, KeyIdxValid=%d\n",
184 MF(rxs.ds_rxstatus1, AR_PHYErr),
185 MF(rxs.ds_rxstatus1, AR_MichaelErr),
186 MF(rxs.ds_rxstatus1, AR_KeyIdxValid));
188 /* If PHY error, print that out. Otherwise, the key index */
189 if (MF(rxs.ds_rxstatus1, AR_PHYErr))
190 printf(" PhyErrCode=0x%02x\n",
191 MS(rxs.ds_rxstatus1, AR_PHYErrCode));
193 printf(" KeyIdx=0x%02x\n",
194 MS(rxs.ds_rxstatus1, AR_KeyIdx));
196 printf(" KeyMiss=%d\n",
197 MF(rxs.ds_rxstatus1, AR_KeyCacheMiss));
199 printf(" Timetamp: 0x%05x\n",
200 MS(rxs.ds_rxstatus1, AR_RcvTimestamp));
202 printf("\n ------\n");
206 ar5212_alq_payload(struct if_ath_alq_payload *a)
209 switch (be16toh(a->hdr.op)) {
210 case ATH_ALQ_EDMA_TXSTATUS: /* TXSTATUS */
211 ar5212_decode_txstatus(a);
213 case ATH_ALQ_EDMA_RXSTATUS: /* RXSTATUS */
214 ar5212_decode_rxstatus(a);
216 case ATH_ALQ_EDMA_TXDESC: /* TXDESC */
217 ar5212_decode_txdesc(a);
220 printf("[%d.%06d] [%lld] op: %d; len %d\n",
221 be32toh(a->hdr.tstamp_sec),
222 be32toh(a->hdr.tstamp_usec),
223 be64toh(a->hdr.threadid),
224 be16toh(a->hdr.op), be16toh(a->hdr.len));