2 * Copyright (c) 2012 Adrian Chadd <adrian@FreeBSD.org>
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 #include <sys/cdefs.h>
18 __FBSDID("$FreeBSD$");
27 #include <sys/types.h>
29 #include <sys/endian.h>
31 #include <dev/ath/if_ath_alq.h>
32 #include <dev/ath/ath_hal/ar9300/ar9300desc.h>
34 #include "ar9300_ds.h"
36 /* XXX should break this out into if_athvar.h */
38 #define MS(_v, _f) ( ((_v) & (_f)) >> _f##_S )
39 #define MF(_v, _f) ( !! ((_v) & (_f)))
42 ar9300_decode_txstatus(struct if_ath_alq_payload *a)
44 struct ar9300_txs txs;
46 /* XXX assumes txs is smaller than PAYLOAD_LEN! */
47 memcpy(&txs, &a->payload, sizeof(struct ar9300_txs));
49 printf("[%u.%06u] [%llu] TXSTATUS\n",
50 (unsigned int) be32toh(a->hdr.tstamp_sec),
51 (unsigned int) be32toh(a->hdr.tstamp_usec),
52 (unsigned long long) be64toh(a->hdr.threadid));
53 printf(" DescId=0x%08x\n", txs.status1);
55 printf(" DescLen=%d, TxQcuNum=%d, CtrlStat=%d, DescId=0x%04x\n",
57 MS(txs.ds_info, AR_tx_qcu_num),
58 MS(txs.ds_info, AR_ctrl_stat),
59 MS(txs.ds_info, AR_desc_id));
61 printf(" TxTimestamp=0x%08x\n", txs.status4);
63 printf(" TxDone=%d, SeqNo=%d, TxOpExceed=%d, TXBFStatus=%d\n",
64 MF(txs.status8, AR_tx_done),
65 MS(txs.status8, AR_seq_num),
66 MF(txs.status8, AR_tx_op_exceeded),
67 MS(txs.status8, AR_TXBFStatus));
69 printf(" TXBfMismatch=%d, BFStreamMiss=%d, FinalTxIdx=%d\n",
70 MF(txs.status8, AR_tx_bf_bw_mismatch),
71 MF(txs.status8, AR_tx_bf_stream_miss),
72 MS(txs.status8, AR_final_tx_idx));
74 printf(" TxBfDestMiss=%d, TxBfExpired=%d, PwrMgmt=%d, Tid=%d,"
76 MF(txs.status8, AR_tx_bf_dest_miss),
77 MF(txs.status8, AR_tx_bf_expired),
78 MF(txs.status8, AR_power_mgmt),
79 MS(txs.status8, AR_tx_tid),
80 MF(txs.status8, AR_tx_fast_ts));
82 printf(" Frmok=%d, xretries=%d, fifounderrun=%d, filt=%d\n",
83 MF(txs.status3, AR_frm_xmit_ok),
84 MF(txs.status3, AR_excessive_retries),
85 MF(txs.status3, AR_fifounderrun),
86 MF(txs.status3, AR_filtered));
87 printf(" DelimUnderrun=%d, DataUnderun=%d, DescCfgErr=%d,"
88 " TxTimerExceeded=%d\n",
89 MF(txs.status3, AR_tx_delim_underrun),
90 MF(txs.status3, AR_tx_data_underrun),
91 MF(txs.status3, AR_desc_cfg_err),
92 MF(txs.status3, AR_tx_timer_expired));
94 printf(" RTScnt=%d, FailCnt=%d, VRetryCnt=%d\n",
95 MS(txs.status3, AR_rts_fail_cnt),
96 MS(txs.status3, AR_data_fail_cnt),
97 MS(txs.status3, AR_virt_retry_cnt));
101 printf(" RX RSSI 0 [%d %d %d]\n",
102 MS(txs.status2, AR_tx_rssi_ant00),
103 MS(txs.status2, AR_tx_rssi_ant01),
104 MS(txs.status2, AR_tx_rssi_ant02));
106 printf(" RX RSSI 1 [%d %d %d] Comb=%d\n",
107 MS(txs.status7, AR_tx_rssi_ant10),
108 MS(txs.status7, AR_tx_rssi_ant11),
109 MS(txs.status7, AR_tx_rssi_ant12),
110 MS(txs.status7, AR_tx_rssi_combined));
112 printf(" BA Valid=%d\n",
113 MF(txs.status2, AR_tx_ba_status));
115 printf(" BALow=0x%08x\n", txs.status5);
116 printf(" BAHigh=0x%08x\n", txs.status6);
118 printf("\n ------ \n");
122 * Note - these are rounded up to 128 bytes; but we
123 * only use 96 bytes from it.
126 ar9300_decode_txdesc(struct if_ath_alq_payload *a)
128 struct ar9300_txc txc;
130 /* XXX assumes txs is smaller than PAYLOAD_LEN! */
131 memcpy(&txc, &a->payload, 96);
133 printf("[%u.%06u] [%llu] TXD\n",
134 (unsigned int) be32toh(a->hdr.tstamp_sec),
135 (unsigned int) be32toh(a->hdr.tstamp_usec),
136 (unsigned long long) be64toh(a->hdr.threadid));
138 printf(" DescLen=%d, TxQcuNum=%d, CtrlStat=%d, DescId=0x%04x\n",
140 MS(txc.ds_info, AR_tx_qcu_num),
141 MS(txc.ds_info, AR_ctrl_stat),
142 MS(txc.ds_info, AR_desc_id));
145 printf(" Link 0x%08x\n", txc.ds_link);
148 printf(" Data0 0x%08x Len %d\n",
150 MS(txc.ds_ctl3, AR_buf_len));
153 printf(" Data1 0x%08x Len %d\n",
155 MS(txc.ds_ctl5, AR_buf_len));
158 printf(" Data2 0x%08x Len %d\n",
160 MS(txc.ds_ctl7, AR_buf_len));
163 printf(" Data3 0x%08x Len %d\n",
165 MS(txc.ds_ctl9, AR_buf_len));
169 printf(" Desc ID=0x%04x, Chksum=0x%04x (ctl10=0x%08x)\n",
170 MS(txc.ds_ctl10, AR_tx_desc_id),
171 txc.ds_ctl10 & AR_tx_ptr_chk_sum,
175 printf(" Frame Len=%d, VMF=%d, LowRxChain=%d, TxClrRetry=%d\n",
176 txc.ds_ctl11 & AR_frame_len,
177 MF(txc.ds_ctl11, AR_virt_more_frag),
178 MF(txc.ds_ctl11, AR_low_rx_chain),
179 MF(txc.ds_ctl11, AR_tx_clear_retry));
180 printf(" TX power 0 = %d, RtsEna=%d, Veol=%d, ClrDstMask=%d\n",
181 MS(txc.ds_ctl11, AR_xmit_power0),
182 MF(txc.ds_ctl11, AR_rts_enable),
183 MF(txc.ds_ctl11, AR_veol),
184 MF(txc.ds_ctl11, AR_clr_dest_mask));
185 printf(" TxIntrReq=%d, DestIdxValid=%d, CtsEnable=%d\n",
186 MF(txc.ds_ctl11, AR_tx_intr_req),
187 MF(txc.ds_ctl11, AR_dest_idx_valid),
188 MF(txc.ds_ctl11, AR_cts_enable));
191 printf(" Paprd Chain Mask=0x%x, TxMore=%d, DestIdx=%d,"
193 MS(txc.ds_ctl12, AR_paprd_chain_mask),
194 MF(txc.ds_ctl12, AR_tx_more),
195 MS(txc.ds_ctl12, AR_dest_idx),
196 MS(txc.ds_ctl12, AR_frame_type));
197 printf(" NoAck=%d, InsertTs=%d, CorruptFcs=%d, ExtOnly=%d,"
199 MF(txc.ds_ctl12, AR_no_ack),
200 MF(txc.ds_ctl12, AR_insert_ts),
201 MF(txc.ds_ctl12, AR_corrupt_fcs),
202 MF(txc.ds_ctl12, AR_ext_only),
203 MF(txc.ds_ctl12, AR_ext_and_ctl));
204 printf(" IsAggr=%d, MoreRifs=%d, LocMode=%d\n",
205 MF(txc.ds_ctl12, AR_is_aggr),
206 MF(txc.ds_ctl12, AR_more_rifs),
207 MF(txc.ds_ctl12, AR_loc_mode));
211 printf(" DurUpEna=%d, Burstdur=0x%04x\n",
212 MF(txc.ds_ctl13, AR_dur_update_ena),
213 MS(txc.ds_ctl13, AR_burst_dur));
214 printf(" Try0=%d, Try1=%d, Try2=%d, Try3=%d\n",
215 MS(txc.ds_ctl13, AR_xmit_data_tries0),
216 MS(txc.ds_ctl13, AR_xmit_data_tries1),
217 MS(txc.ds_ctl13, AR_xmit_data_tries2),
218 MS(txc.ds_ctl13, AR_xmit_data_tries3));
221 printf(" rate0=0x%02x, rate1=0x%02x, rate2=0x%02x, rate3=0x%02x\n",
222 MS(txc.ds_ctl14, AR_xmit_rate0),
223 MS(txc.ds_ctl14, AR_xmit_rate1),
224 MS(txc.ds_ctl14, AR_xmit_rate2),
225 MS(txc.ds_ctl14, AR_xmit_rate3));
228 printf(" try 0: PktDur=%d, RTS/CTS ena=%d\n",
229 MS(txc.ds_ctl15, AR_packet_dur0),
230 MF(txc.ds_ctl15, AR_rts_cts_qual0));
231 printf(" try 1: PktDur=%d, RTS/CTS ena=%d\n",
232 MS(txc.ds_ctl15, AR_packet_dur1),
233 MF(txc.ds_ctl15, AR_rts_cts_qual1));
236 printf(" try 2: PktDur=%d, RTS/CTS ena=%d\n",
237 MS(txc.ds_ctl16, AR_packet_dur2),
238 MF(txc.ds_ctl16, AR_rts_cts_qual2));
239 printf(" try 3: PktDur=%d, RTS/CTS ena=%d\n",
240 MS(txc.ds_ctl16, AR_packet_dur3),
241 MF(txc.ds_ctl16, AR_rts_cts_qual3));
244 printf(" AggrLen=%d, PadDelim=%d, EncrType=%d, TxDcApStaSel=%d\n",
245 MS(txc.ds_ctl17, AR_aggr_len),
246 MS(txc.ds_ctl17, AR_pad_delim),
247 MS(txc.ds_ctl17, AR_encr_type),
248 MF(txc.ds_ctl17, AR_tx_dc_ap_sta_sel));
249 printf(" Calib=%d LDPC=%d\n",
250 MF(txc.ds_ctl17, AR_calibrating),
251 MF(txc.ds_ctl17, AR_ldpc));
254 printf(" try 0: chainMask=0x%x, GI=%d, 2040=%d, STBC=%d\n",
255 MS(txc.ds_ctl18, AR_chain_sel0),
256 MF(txc.ds_ctl18, AR_gi0),
257 MF(txc.ds_ctl18, AR_2040_0),
258 MF(txc.ds_ctl18, AR_stbc0));
259 printf(" try 1: chainMask=0x%x, GI=%d, 2040=%d, STBC=%d\n",
260 MS(txc.ds_ctl18, AR_chain_sel1),
261 MF(txc.ds_ctl18, AR_gi1),
262 MF(txc.ds_ctl18, AR_2040_1),
263 MF(txc.ds_ctl18, AR_stbc1));
264 printf(" try 2: chainMask=0x%x, GI=%d, 2040=%d, STBC=%d\n",
265 MS(txc.ds_ctl18, AR_chain_sel2),
266 MF(txc.ds_ctl18, AR_gi2),
267 MF(txc.ds_ctl18, AR_2040_2),
268 MF(txc.ds_ctl18, AR_stbc2));
269 printf(" try 3: chainMask=0x%x, GI=%d, 2040=%d, STBC=%d\n",
270 MS(txc.ds_ctl18, AR_chain_sel3),
271 MF(txc.ds_ctl18, AR_gi3),
272 MF(txc.ds_ctl18, AR_2040_3),
273 MF(txc.ds_ctl18, AR_stbc3));
276 printf(" NotSounding=%d\n",
277 MF(txc.ds_ctl19, AR_not_sounding));
279 printf(" try 0: ant=0x%08x, antsel=%d, ness=%d\n",
280 txc.ds_ctl19 & AR_tx_ant0,
281 MF(txc.ds_ctl19, AR_tx_ant_sel0),
282 MS(txc.ds_ctl19, AR_ness));
285 printf(" try 1: TxPower=%d, ant=0x%08x, antsel=%d, ness=%d\n",
286 MS(txc.ds_ctl20, AR_xmit_power1),
287 txc.ds_ctl20 & AR_tx_ant1,
288 MF(txc.ds_ctl20, AR_tx_ant_sel1),
289 MS(txc.ds_ctl20, AR_ness1));
292 printf(" try 2: TxPower=%d, ant=0x%08x, antsel=%d, ness=%d\n",
293 MS(txc.ds_ctl21, AR_xmit_power2),
294 txc.ds_ctl21 & AR_tx_ant2,
295 MF(txc.ds_ctl21, AR_tx_ant_sel2),
296 MS(txc.ds_ctl21, AR_ness2));
299 printf(" try 3: TxPower=%d, ant=0x%08x, antsel=%d, ness=%d\n",
300 MS(txc.ds_ctl22, AR_xmit_power3),
301 txc.ds_ctl22 & AR_tx_ant3,
302 MF(txc.ds_ctl22, AR_tx_ant_sel3),
303 MS(txc.ds_ctl22, AR_ness3));
305 printf("\n ------ \n");
309 ar9300_decode_rxstatus(struct if_ath_alq_payload *a)
311 struct ar9300_rxs rxs;
313 /* XXX assumes rxs is smaller than PAYLOAD_LEN! */
314 memcpy(&rxs, &a->payload, sizeof(struct ar9300_rxs));
316 printf("[%u.%06u] [%llu] RXSTATUS\n",
317 (unsigned int) be32toh(a->hdr.tstamp_sec),
318 (unsigned int) be32toh(a->hdr.tstamp_usec),
319 (unsigned long long) be64toh(a->hdr.threadid));
323 ar9300_alq_payload(struct if_ath_alq_payload *a)
326 switch (be16toh(a->hdr.op)) {
327 case ATH_ALQ_EDMA_TXSTATUS: /* TXSTATUS */
328 ar9300_decode_txstatus(a);
330 case ATH_ALQ_EDMA_RXSTATUS: /* RXSTATUS */
331 ar9300_decode_rxstatus(a);
333 case ATH_ALQ_EDMA_TXDESC: /* TXDESC */
334 ar9300_decode_txdesc(a);
337 printf("[%d.%06d] [%lld] op: %d; len %d\n",
338 be32toh(a->hdr.tstamp_sec),
339 be32toh(a->hdr.tstamp_usec),
340 be64toh(a->hdr.threadid),
341 be16toh(a->hdr.op), be16toh(a->hdr.len));