2 * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer,
10 * without modification.
11 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
12 * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
13 * redistribution must be conditioned upon including a substantially
14 * similar Disclaimer requirement for further binary redistribution.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
20 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
21 * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
22 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
27 * THE POSSIBILITY OF SUCH DAMAGES.
30 #include <sys/cdefs.h>
36 #include <sys/param.h>
37 #include <sys/systm.h>
38 #include <sys/sysctl.h>
40 #include <sys/malloc.h>
42 #include <sys/mutex.h>
43 #include <sys/kernel.h>
44 #include <sys/socket.h>
45 #include <sys/sockio.h>
46 #include <sys/errno.h>
47 #include <sys/callout.h>
49 #include <sys/endian.h>
50 #include <sys/kthread.h>
51 #include <sys/taskqueue.h>
55 #include <net/if_dl.h>
56 #include <net/if_media.h>
57 #include <net/if_types.h>
58 #include <net/if_arp.h>
59 #include <net/ethernet.h>
60 #include <net/if_llc.h>
62 #include <netproto/802_11/ieee80211_var.h>
63 #include <netproto/802_11/ieee80211_regdomain.h>
64 #ifdef IEEE80211_SUPPORT_SUPERG
65 #include <netproto/802_11/ieee80211_superg.h>
67 #ifdef IEEE80211_SUPPORT_TDMA
68 #include <netproto/802_11/ieee80211_tdma.h>
74 #include <netinet/in.h>
75 #include <netinet/if_ether.h>
78 #include <dev/netif/ath/ath/if_athvar.h>
79 #include <dev/netif/ath/ath_hal/ah_devid.h> /* XXX for softled */
80 #include <dev/netif/ath/ath_hal/ah_diagcodes.h>
83 #include <dev/netif/ath/ath_tx99/ath_tx99.h>
87 #include <dev/netif/ath/ath/if_ath_debug.h>
89 uint64_t ath_debug = 0;
92 SYSCTL_QUAD(_hw_ath, OID_AUTO, debug, CTLFLAG_RW, &ath_debug,
93 0, "control debugging printfs");
94 TUNABLE_QUAD("hw.ath.debug", &ath_debug);
97 ath_printrxbuf(struct ath_softc *sc, const struct ath_buf *bf,
100 const struct ath_rx_status *rs = &bf->bf_status.ds_rxstat;
101 struct ath_hal *ah = sc->sc_ah;
102 const struct ath_desc *ds;
105 for (i = 0, ds = bf->bf_desc; i < bf->bf_nseg; i++, ds++) {
106 kprintf("R[%2u] (DS.V:%p DS.P:%p) L:%08x D:%08x%s\n"
107 " %08x %08x %08x %08x\n",
108 ix, ds, (const struct ath_desc *)bf->bf_daddr + i,
109 ds->ds_link, ds->ds_data,
110 !done ? "" : (rs->rs_status == 0) ? " *" : " !",
111 ds->ds_ctl0, ds->ds_ctl1,
112 ds->ds_hw[0], ds->ds_hw[1]);
113 if (ah->ah_magic == 0x20065416) {
114 kprintf(" %08x %08x %08x %08x %08x %08x %08x\n",
115 ds->ds_hw[2], ds->ds_hw[3], ds->ds_hw[4],
116 ds->ds_hw[5], ds->ds_hw[6], ds->ds_hw[7],
118 } else if (ah->ah_magic == 0x19741014) {
119 kprintf(" %08x %08x %08x %08x %08x %08x %08x\n",
120 ds->ds_hw[2], ds->ds_hw[3], ds->ds_hw[4],
121 ds->ds_hw[5], ds->ds_hw[6], ds->ds_hw[7],
124 kprintf(" %08x %08x %08x %08x %08x %08x %08x\n",
125 ds->ds_hw[9], ds->ds_hw[10], ds->ds_hw[11],
126 ds->ds_hw[12], ds->ds_hw[13], ds->ds_hw[14],
133 ath_printtxbuf_edma(struct ath_softc *sc, const struct ath_buf *first_bf,
134 u_int qnum, u_int ix, int done)
136 const struct ath_tx_status *ts =
137 &first_bf->bf_last->bf_status.ds_txstat;
138 const struct ath_buf *bf = first_bf;
140 const struct ath_desc_txedma *eds;
143 kprintf("Q%u[%3u] (nseg=%d)", qnum, ix, bf->bf_nseg);
146 * XXX For now, assume the txmap size is 4.
150 * Assume the TX map size is 4 for now and only walk
151 * the appropriate number of segments.
153 n = ((bf->bf_nseg - 1) / 4) + 1;
155 for (i = 0, ds = (const char *) bf->bf_desc;
157 i ++, ds += sc->sc_tx_desclen) {
158 eds = (const struct ath_desc_txedma *) ds;
159 kprintf(" (DS.V:%p DS.P:%p) I: %08x L:%08x F:%04x%s\n",
160 eds, (const struct ath_desc *)bf->bf_daddr + i,
161 eds->ds_info, eds->ds_link,
162 bf->bf_state.bfs_txflags,
163 !done ? "" : (ts->ts_status == 0) ? " *" : " !");
164 kprintf(" (D[0] = %08x(%08x), D[1] = %08x(%08x)\n",
165 eds->ds_hw[0], eds->ds_hw[1],
166 eds->ds_hw[2], eds->ds_hw[3]);
167 kprintf(" (D[2] = %08x(%08x), D[3] = %08x(%08x)\n",
168 eds->ds_hw[4], eds->ds_hw[5],
169 eds->ds_hw[6], eds->ds_hw[7]);
170 kprintf(" Seq: %d swtry: %d ADDBAW?: %d DOBAW?: %d\n",
171 bf->bf_state.bfs_seqno,
172 bf->bf_state.bfs_retries,
173 bf->bf_state.bfs_addedbaw,
174 bf->bf_state.bfs_dobaw);
175 kprintf(" %08x %08x %08x %08x %08x %08x\n",
176 eds->ds_hw[8], eds->ds_hw[9],
177 eds->ds_hw[10], eds->ds_hw[11],
178 eds->ds_hw[12], eds->ds_hw[13]);
179 kprintf(" %08x %08x %08x %08x %08x %08x %08x\n",
180 eds->ds_hw[14], eds->ds_hw[15], eds->ds_hw[16],
181 eds->ds_hw[17], eds->ds_hw[18], eds->ds_hw[19],
184 kprintf(" %08x %08x %08x %08x %08x %08x %08x %08x\n",
185 ds->ds_hw[22],ds->ds_hw[23],ds->ds_hw[24],
186 ds->ds_hw[25],ds->ds_hw[26],ds->ds_hw[27],
187 ds->ds_hw[28], ds->ds_hw[29]);
196 ath_printtxbuf_legacy(struct ath_softc *sc, const struct ath_buf *first_bf,
197 u_int qnum, u_int ix, int done)
199 const struct ath_tx_status *ts = &first_bf->bf_status.ds_txstat;
200 const struct ath_buf *bf = first_bf;
201 struct ath_hal *ah = sc->sc_ah;
202 const struct ath_desc *ds;
205 kprintf("Q%u[%3u]", qnum, ix);
207 kprintf(" (bf=%p, lastds=%p)\n", bf, first_bf->bf_lastds);
208 kprintf(" Seq: %d swtry: %d ADDBAW?: %d DOBAW?: %d\n",
209 bf->bf_state.bfs_seqno,
210 bf->bf_state.bfs_retries,
211 bf->bf_state.bfs_addedbaw,
212 bf->bf_state.bfs_dobaw);
213 for (i = 0, ds = bf->bf_desc; i < bf->bf_nseg; i++, ds++) {
214 kprintf(" (DS.V:%p DS.P:%p) L:%08x D:%08x F:%04x%s\n",
215 ds, (const struct ath_desc *)bf->bf_daddr + i,
216 ds->ds_link, ds->ds_data, bf->bf_state.bfs_txflags,
217 !done ? "" : (ts->ts_status == 0) ? " *" : " !");
218 kprintf(" %08x %08x %08x %08x %08x %08x\n",
219 ds->ds_ctl0, ds->ds_ctl1,
220 ds->ds_hw[0], ds->ds_hw[1],
221 ds->ds_hw[2], ds->ds_hw[3]);
222 if (ah->ah_magic == 0x20065416) {
223 kprintf(" %08x %08x %08x %08x %08x %08x %08x %08x\n",
224 ds->ds_hw[4], ds->ds_hw[5], ds->ds_hw[6],
225 ds->ds_hw[7], ds->ds_hw[8], ds->ds_hw[9],
226 ds->ds_hw[10],ds->ds_hw[11]);
227 kprintf(" %08x %08x %08x %08x %08x %08x %08x %08x\n",
228 ds->ds_hw[12],ds->ds_hw[13],ds->ds_hw[14],
229 ds->ds_hw[15],ds->ds_hw[16],ds->ds_hw[17],
230 ds->ds_hw[18], ds->ds_hw[19]);
239 ath_printtxbuf(struct ath_softc *sc, const struct ath_buf *first_bf,
240 u_int qnum, u_int ix, int done)
242 if (sc->sc_ah->ah_magic == 0x19741014)
243 ath_printtxbuf_edma(sc, first_bf, qnum, ix, done);
245 ath_printtxbuf_legacy(sc, first_bf, qnum, ix, done);
249 ath_printtxstatbuf(struct ath_softc *sc, const struct ath_buf *first_bf,
250 const uint32_t *ds, u_int qnum, u_int ix, int done)
253 kprintf("Q%u[%3u] ", qnum, ix);
254 kprintf(" %08x %08x %08x %08x %08x %08x\n",
255 ds[0], ds[1], ds[2], ds[3], ds[4], ds[5]);
256 kprintf(" %08x %08x %08x %08x %08x\n",
257 ds[6], ds[7], ds[8], ds[9], ds[10]);
260 #endif /* ATH_DEBUG */