1*572ff6f6SMatthew Dillon /*
2*572ff6f6SMatthew Dillon * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting
3*572ff6f6SMatthew Dillon * Copyright (c) 2002-2008 Atheros Communications, Inc.
4*572ff6f6SMatthew Dillon *
5*572ff6f6SMatthew Dillon * Permission to use, copy, modify, and/or distribute this software for any
6*572ff6f6SMatthew Dillon * purpose with or without fee is hereby granted, provided that the above
7*572ff6f6SMatthew Dillon * copyright notice and this permission notice appear in all copies.
8*572ff6f6SMatthew Dillon *
9*572ff6f6SMatthew Dillon * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10*572ff6f6SMatthew Dillon * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11*572ff6f6SMatthew Dillon * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12*572ff6f6SMatthew Dillon * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13*572ff6f6SMatthew Dillon * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14*572ff6f6SMatthew Dillon * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15*572ff6f6SMatthew Dillon * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16*572ff6f6SMatthew Dillon *
17*572ff6f6SMatthew Dillon * $FreeBSD$
18*572ff6f6SMatthew Dillon */
19*572ff6f6SMatthew Dillon #include "opt_ah.h"
20*572ff6f6SMatthew Dillon
21*572ff6f6SMatthew Dillon #include "ah.h"
22*572ff6f6SMatthew Dillon #include "ah_internal.h"
23*572ff6f6SMatthew Dillon #include "ah_desc.h"
24*572ff6f6SMatthew Dillon
25*572ff6f6SMatthew Dillon #include "ar5212/ar5212.h"
26*572ff6f6SMatthew Dillon #include "ar5212/ar5212reg.h"
27*572ff6f6SMatthew Dillon #include "ar5212/ar5212desc.h"
28*572ff6f6SMatthew Dillon
29*572ff6f6SMatthew Dillon /*
30*572ff6f6SMatthew Dillon * Get the RXDP.
31*572ff6f6SMatthew Dillon */
32*572ff6f6SMatthew Dillon uint32_t
ar5212GetRxDP(struct ath_hal * ath,HAL_RX_QUEUE qtype)33*572ff6f6SMatthew Dillon ar5212GetRxDP(struct ath_hal *ath, HAL_RX_QUEUE qtype)
34*572ff6f6SMatthew Dillon {
35*572ff6f6SMatthew Dillon
36*572ff6f6SMatthew Dillon HALASSERT(qtype == HAL_RX_QUEUE_HP);
37*572ff6f6SMatthew Dillon return OS_REG_READ(ath, AR_RXDP);
38*572ff6f6SMatthew Dillon }
39*572ff6f6SMatthew Dillon
40*572ff6f6SMatthew Dillon /*
41*572ff6f6SMatthew Dillon * Set the RxDP.
42*572ff6f6SMatthew Dillon */
43*572ff6f6SMatthew Dillon void
ar5212SetRxDP(struct ath_hal * ah,uint32_t rxdp,HAL_RX_QUEUE qtype)44*572ff6f6SMatthew Dillon ar5212SetRxDP(struct ath_hal *ah, uint32_t rxdp, HAL_RX_QUEUE qtype)
45*572ff6f6SMatthew Dillon {
46*572ff6f6SMatthew Dillon
47*572ff6f6SMatthew Dillon HALASSERT(qtype == HAL_RX_QUEUE_HP);
48*572ff6f6SMatthew Dillon OS_REG_WRITE(ah, AR_RXDP, rxdp);
49*572ff6f6SMatthew Dillon HALASSERT(OS_REG_READ(ah, AR_RXDP) == rxdp);
50*572ff6f6SMatthew Dillon }
51*572ff6f6SMatthew Dillon
52*572ff6f6SMatthew Dillon /*
53*572ff6f6SMatthew Dillon * Set Receive Enable bits.
54*572ff6f6SMatthew Dillon */
55*572ff6f6SMatthew Dillon void
ar5212EnableReceive(struct ath_hal * ah)56*572ff6f6SMatthew Dillon ar5212EnableReceive(struct ath_hal *ah)
57*572ff6f6SMatthew Dillon {
58*572ff6f6SMatthew Dillon OS_REG_WRITE(ah, AR_CR, AR_CR_RXE);
59*572ff6f6SMatthew Dillon }
60*572ff6f6SMatthew Dillon
61*572ff6f6SMatthew Dillon /*
62*572ff6f6SMatthew Dillon * Stop Receive at the DMA engine
63*572ff6f6SMatthew Dillon */
64*572ff6f6SMatthew Dillon HAL_BOOL
ar5212StopDmaReceive(struct ath_hal * ah)65*572ff6f6SMatthew Dillon ar5212StopDmaReceive(struct ath_hal *ah)
66*572ff6f6SMatthew Dillon {
67*572ff6f6SMatthew Dillon OS_MARK(ah, AH_MARK_RX_CTL, AH_MARK_RX_CTL_DMA_STOP);
68*572ff6f6SMatthew Dillon OS_REG_WRITE(ah, AR_CR, AR_CR_RXD); /* Set receive disable bit */
69*572ff6f6SMatthew Dillon if (!ath_hal_wait(ah, AR_CR, AR_CR_RXE, 0)) {
70*572ff6f6SMatthew Dillon OS_MARK(ah, AH_MARK_RX_CTL, AH_MARK_RX_CTL_DMA_STOP_ERR);
71*572ff6f6SMatthew Dillon #ifdef AH_DEBUG
72*572ff6f6SMatthew Dillon ath_hal_printf(ah, "%s: dma failed to stop in 10ms\n"
73*572ff6f6SMatthew Dillon "AR_CR=0x%08x\nAR_DIAG_SW=0x%08x\n",
74*572ff6f6SMatthew Dillon __func__,
75*572ff6f6SMatthew Dillon OS_REG_READ(ah, AR_CR),
76*572ff6f6SMatthew Dillon OS_REG_READ(ah, AR_DIAG_SW));
77*572ff6f6SMatthew Dillon #endif
78*572ff6f6SMatthew Dillon return AH_FALSE;
79*572ff6f6SMatthew Dillon } else {
80*572ff6f6SMatthew Dillon return AH_TRUE;
81*572ff6f6SMatthew Dillon }
82*572ff6f6SMatthew Dillon }
83*572ff6f6SMatthew Dillon
84*572ff6f6SMatthew Dillon /*
85*572ff6f6SMatthew Dillon * Start Transmit at the PCU engine (unpause receive)
86*572ff6f6SMatthew Dillon */
87*572ff6f6SMatthew Dillon void
ar5212StartPcuReceive(struct ath_hal * ah)88*572ff6f6SMatthew Dillon ar5212StartPcuReceive(struct ath_hal *ah)
89*572ff6f6SMatthew Dillon {
90*572ff6f6SMatthew Dillon struct ath_hal_private *ahp = AH_PRIVATE(ah);
91*572ff6f6SMatthew Dillon
92*572ff6f6SMatthew Dillon OS_MARK(ah, AH_MARK_RX_CTL, AH_MARK_RX_CTL_PCU_START);
93*572ff6f6SMatthew Dillon OS_REG_WRITE(ah, AR_DIAG_SW,
94*572ff6f6SMatthew Dillon OS_REG_READ(ah, AR_DIAG_SW) &~ AR_DIAG_RX_DIS);
95*572ff6f6SMatthew Dillon ar5212EnableMibCounters(ah);
96*572ff6f6SMatthew Dillon /* NB: restore current settings */
97*572ff6f6SMatthew Dillon ar5212AniReset(ah, ahp->ah_curchan, ahp->ah_opmode, AH_TRUE);
98*572ff6f6SMatthew Dillon }
99*572ff6f6SMatthew Dillon
100*572ff6f6SMatthew Dillon /*
101*572ff6f6SMatthew Dillon * Stop Transmit at the PCU engine (pause receive)
102*572ff6f6SMatthew Dillon */
103*572ff6f6SMatthew Dillon void
ar5212StopPcuReceive(struct ath_hal * ah)104*572ff6f6SMatthew Dillon ar5212StopPcuReceive(struct ath_hal *ah)
105*572ff6f6SMatthew Dillon {
106*572ff6f6SMatthew Dillon OS_MARK(ah, AH_MARK_RX_CTL, AH_MARK_RX_CTL_PCU_STOP);
107*572ff6f6SMatthew Dillon OS_REG_WRITE(ah, AR_DIAG_SW,
108*572ff6f6SMatthew Dillon OS_REG_READ(ah, AR_DIAG_SW) | AR_DIAG_RX_DIS);
109*572ff6f6SMatthew Dillon ar5212DisableMibCounters(ah);
110*572ff6f6SMatthew Dillon }
111*572ff6f6SMatthew Dillon
112*572ff6f6SMatthew Dillon /*
113*572ff6f6SMatthew Dillon * Set multicast filter 0 (lower 32-bits)
114*572ff6f6SMatthew Dillon * filter 1 (upper 32-bits)
115*572ff6f6SMatthew Dillon */
116*572ff6f6SMatthew Dillon void
ar5212SetMulticastFilter(struct ath_hal * ah,uint32_t filter0,uint32_t filter1)117*572ff6f6SMatthew Dillon ar5212SetMulticastFilter(struct ath_hal *ah, uint32_t filter0, uint32_t filter1)
118*572ff6f6SMatthew Dillon {
119*572ff6f6SMatthew Dillon OS_REG_WRITE(ah, AR_MCAST_FIL0, filter0);
120*572ff6f6SMatthew Dillon OS_REG_WRITE(ah, AR_MCAST_FIL1, filter1);
121*572ff6f6SMatthew Dillon }
122*572ff6f6SMatthew Dillon
123*572ff6f6SMatthew Dillon /*
124*572ff6f6SMatthew Dillon * Clear multicast filter by index
125*572ff6f6SMatthew Dillon */
126*572ff6f6SMatthew Dillon HAL_BOOL
ar5212ClrMulticastFilterIndex(struct ath_hal * ah,uint32_t ix)127*572ff6f6SMatthew Dillon ar5212ClrMulticastFilterIndex(struct ath_hal *ah, uint32_t ix)
128*572ff6f6SMatthew Dillon {
129*572ff6f6SMatthew Dillon uint32_t val;
130*572ff6f6SMatthew Dillon
131*572ff6f6SMatthew Dillon if (ix >= 64)
132*572ff6f6SMatthew Dillon return AH_FALSE;
133*572ff6f6SMatthew Dillon if (ix >= 32) {
134*572ff6f6SMatthew Dillon val = OS_REG_READ(ah, AR_MCAST_FIL1);
135*572ff6f6SMatthew Dillon OS_REG_WRITE(ah, AR_MCAST_FIL1, (val &~ (1<<(ix-32))));
136*572ff6f6SMatthew Dillon } else {
137*572ff6f6SMatthew Dillon val = OS_REG_READ(ah, AR_MCAST_FIL0);
138*572ff6f6SMatthew Dillon OS_REG_WRITE(ah, AR_MCAST_FIL0, (val &~ (1<<ix)));
139*572ff6f6SMatthew Dillon }
140*572ff6f6SMatthew Dillon return AH_TRUE;
141*572ff6f6SMatthew Dillon }
142*572ff6f6SMatthew Dillon
143*572ff6f6SMatthew Dillon /*
144*572ff6f6SMatthew Dillon * Set multicast filter by index
145*572ff6f6SMatthew Dillon */
146*572ff6f6SMatthew Dillon HAL_BOOL
ar5212SetMulticastFilterIndex(struct ath_hal * ah,uint32_t ix)147*572ff6f6SMatthew Dillon ar5212SetMulticastFilterIndex(struct ath_hal *ah, uint32_t ix)
148*572ff6f6SMatthew Dillon {
149*572ff6f6SMatthew Dillon uint32_t val;
150*572ff6f6SMatthew Dillon
151*572ff6f6SMatthew Dillon if (ix >= 64)
152*572ff6f6SMatthew Dillon return AH_FALSE;
153*572ff6f6SMatthew Dillon if (ix >= 32) {
154*572ff6f6SMatthew Dillon val = OS_REG_READ(ah, AR_MCAST_FIL1);
155*572ff6f6SMatthew Dillon OS_REG_WRITE(ah, AR_MCAST_FIL1, (val | (1<<(ix-32))));
156*572ff6f6SMatthew Dillon } else {
157*572ff6f6SMatthew Dillon val = OS_REG_READ(ah, AR_MCAST_FIL0);
158*572ff6f6SMatthew Dillon OS_REG_WRITE(ah, AR_MCAST_FIL0, (val | (1<<ix)));
159*572ff6f6SMatthew Dillon }
160*572ff6f6SMatthew Dillon return AH_TRUE;
161*572ff6f6SMatthew Dillon }
162*572ff6f6SMatthew Dillon
163*572ff6f6SMatthew Dillon /*
164*572ff6f6SMatthew Dillon * Get the receive filter.
165*572ff6f6SMatthew Dillon */
166*572ff6f6SMatthew Dillon uint32_t
ar5212GetRxFilter(struct ath_hal * ah)167*572ff6f6SMatthew Dillon ar5212GetRxFilter(struct ath_hal *ah)
168*572ff6f6SMatthew Dillon {
169*572ff6f6SMatthew Dillon uint32_t bits = OS_REG_READ(ah, AR_RX_FILTER);
170*572ff6f6SMatthew Dillon uint32_t phybits = OS_REG_READ(ah, AR_PHY_ERR);
171*572ff6f6SMatthew Dillon if (phybits & AR_PHY_ERR_RADAR)
172*572ff6f6SMatthew Dillon bits |= HAL_RX_FILTER_PHYRADAR;
173*572ff6f6SMatthew Dillon if (phybits & (AR_PHY_ERR_OFDM_TIMING|AR_PHY_ERR_CCK_TIMING))
174*572ff6f6SMatthew Dillon bits |= HAL_RX_FILTER_PHYERR;
175*572ff6f6SMatthew Dillon if (AH_PRIVATE(ah)->ah_caps.halBssidMatchSupport &&
176*572ff6f6SMatthew Dillon (AH5212(ah)->ah_miscMode & AR_MISC_MODE_BSSID_MATCH_FORCE))
177*572ff6f6SMatthew Dillon bits |= HAL_RX_FILTER_BSSID;
178*572ff6f6SMatthew Dillon return bits;
179*572ff6f6SMatthew Dillon }
180*572ff6f6SMatthew Dillon
181*572ff6f6SMatthew Dillon /*
182*572ff6f6SMatthew Dillon * Set the receive filter.
183*572ff6f6SMatthew Dillon */
184*572ff6f6SMatthew Dillon void
ar5212SetRxFilter(struct ath_hal * ah,uint32_t bits)185*572ff6f6SMatthew Dillon ar5212SetRxFilter(struct ath_hal *ah, uint32_t bits)
186*572ff6f6SMatthew Dillon {
187*572ff6f6SMatthew Dillon struct ath_hal_5212 *ahp = AH5212(ah);
188*572ff6f6SMatthew Dillon uint32_t phybits;
189*572ff6f6SMatthew Dillon
190*572ff6f6SMatthew Dillon OS_REG_WRITE(ah, AR_RX_FILTER,
191*572ff6f6SMatthew Dillon bits &~ (HAL_RX_FILTER_PHYRADAR|HAL_RX_FILTER_PHYERR|
192*572ff6f6SMatthew Dillon HAL_RX_FILTER_BSSID));
193*572ff6f6SMatthew Dillon phybits = 0;
194*572ff6f6SMatthew Dillon if (bits & HAL_RX_FILTER_PHYRADAR)
195*572ff6f6SMatthew Dillon phybits |= AR_PHY_ERR_RADAR;
196*572ff6f6SMatthew Dillon if (bits & HAL_RX_FILTER_PHYERR)
197*572ff6f6SMatthew Dillon phybits |= AR_PHY_ERR_OFDM_TIMING | AR_PHY_ERR_CCK_TIMING;
198*572ff6f6SMatthew Dillon OS_REG_WRITE(ah, AR_PHY_ERR, phybits);
199*572ff6f6SMatthew Dillon if (phybits) {
200*572ff6f6SMatthew Dillon OS_REG_WRITE(ah, AR_RXCFG,
201*572ff6f6SMatthew Dillon OS_REG_READ(ah, AR_RXCFG) | AR_RXCFG_ZLFDMA);
202*572ff6f6SMatthew Dillon } else {
203*572ff6f6SMatthew Dillon OS_REG_WRITE(ah, AR_RXCFG,
204*572ff6f6SMatthew Dillon OS_REG_READ(ah, AR_RXCFG) &~ AR_RXCFG_ZLFDMA);
205*572ff6f6SMatthew Dillon }
206*572ff6f6SMatthew Dillon if (AH_PRIVATE(ah)->ah_caps.halBssidMatchSupport) {
207*572ff6f6SMatthew Dillon if (bits & HAL_RX_FILTER_BSSID)
208*572ff6f6SMatthew Dillon ahp->ah_miscMode |= AR_MISC_MODE_BSSID_MATCH_FORCE;
209*572ff6f6SMatthew Dillon else
210*572ff6f6SMatthew Dillon ahp->ah_miscMode &= ~AR_MISC_MODE_BSSID_MATCH_FORCE;
211*572ff6f6SMatthew Dillon OS_REG_WRITE(ah, AR_MISC_MODE, OS_REG_READ(ah, AR_MISC_MODE) | ahp->ah_miscMode);
212*572ff6f6SMatthew Dillon }
213*572ff6f6SMatthew Dillon }
214*572ff6f6SMatthew Dillon
215*572ff6f6SMatthew Dillon /*
216*572ff6f6SMatthew Dillon * Initialize RX descriptor, by clearing the status and setting
217*572ff6f6SMatthew Dillon * the size (and any other flags).
218*572ff6f6SMatthew Dillon */
219*572ff6f6SMatthew Dillon HAL_BOOL
ar5212SetupRxDesc(struct ath_hal * ah,struct ath_desc * ds,uint32_t size,u_int flags)220*572ff6f6SMatthew Dillon ar5212SetupRxDesc(struct ath_hal *ah, struct ath_desc *ds,
221*572ff6f6SMatthew Dillon uint32_t size, u_int flags)
222*572ff6f6SMatthew Dillon {
223*572ff6f6SMatthew Dillon struct ar5212_desc *ads = AR5212DESC(ds);
224*572ff6f6SMatthew Dillon
225*572ff6f6SMatthew Dillon HALASSERT((size &~ AR_BufLen) == 0);
226*572ff6f6SMatthew Dillon
227*572ff6f6SMatthew Dillon ads->ds_ctl0 = 0;
228*572ff6f6SMatthew Dillon ads->ds_ctl1 = size & AR_BufLen;
229*572ff6f6SMatthew Dillon
230*572ff6f6SMatthew Dillon if (flags & HAL_RXDESC_INTREQ)
231*572ff6f6SMatthew Dillon ads->ds_ctl1 |= AR_RxInterReq;
232*572ff6f6SMatthew Dillon ads->ds_rxstatus0 = ads->ds_rxstatus1 = 0;
233*572ff6f6SMatthew Dillon
234*572ff6f6SMatthew Dillon return AH_TRUE;
235*572ff6f6SMatthew Dillon }
236*572ff6f6SMatthew Dillon
237*572ff6f6SMatthew Dillon /*
238*572ff6f6SMatthew Dillon * Process an RX descriptor, and return the status to the caller.
239*572ff6f6SMatthew Dillon * Copy some hardware specific items into the software portion
240*572ff6f6SMatthew Dillon * of the descriptor.
241*572ff6f6SMatthew Dillon *
242*572ff6f6SMatthew Dillon * NB: the caller is responsible for validating the memory contents
243*572ff6f6SMatthew Dillon * of the descriptor (e.g. flushing any cached copy).
244*572ff6f6SMatthew Dillon */
245*572ff6f6SMatthew Dillon HAL_STATUS
ar5212ProcRxDesc(struct ath_hal * ah,struct ath_desc * ds,uint32_t pa,struct ath_desc * nds,uint64_t tsf,struct ath_rx_status * rs)246*572ff6f6SMatthew Dillon ar5212ProcRxDesc(struct ath_hal *ah, struct ath_desc *ds,
247*572ff6f6SMatthew Dillon uint32_t pa, struct ath_desc *nds, uint64_t tsf,
248*572ff6f6SMatthew Dillon struct ath_rx_status *rs)
249*572ff6f6SMatthew Dillon {
250*572ff6f6SMatthew Dillon struct ar5212_desc *ads = AR5212DESC(ds);
251*572ff6f6SMatthew Dillon struct ar5212_desc *ands = AR5212DESC(nds);
252*572ff6f6SMatthew Dillon
253*572ff6f6SMatthew Dillon if ((ads->ds_rxstatus1 & AR_Done) == 0)
254*572ff6f6SMatthew Dillon return HAL_EINPROGRESS;
255*572ff6f6SMatthew Dillon /*
256*572ff6f6SMatthew Dillon * Given the use of a self-linked tail be very sure that the hw is
257*572ff6f6SMatthew Dillon * done with this descriptor; the hw may have done this descriptor
258*572ff6f6SMatthew Dillon * once and picked it up again...make sure the hw has moved on.
259*572ff6f6SMatthew Dillon */
260*572ff6f6SMatthew Dillon if ((ands->ds_rxstatus1&AR_Done) == 0 && OS_REG_READ(ah, AR_RXDP) == pa)
261*572ff6f6SMatthew Dillon return HAL_EINPROGRESS;
262*572ff6f6SMatthew Dillon
263*572ff6f6SMatthew Dillon rs->rs_datalen = ads->ds_rxstatus0 & AR_DataLen;
264*572ff6f6SMatthew Dillon rs->rs_tstamp = MS(ads->ds_rxstatus1, AR_RcvTimestamp);
265*572ff6f6SMatthew Dillon rs->rs_status = 0;
266*572ff6f6SMatthew Dillon /* XXX what about KeyCacheMiss? */
267*572ff6f6SMatthew Dillon rs->rs_rssi = MS(ads->ds_rxstatus0, AR_RcvSigStrength);
268*572ff6f6SMatthew Dillon /* discard invalid h/w rssi data */
269*572ff6f6SMatthew Dillon if (rs->rs_rssi == -128)
270*572ff6f6SMatthew Dillon rs->rs_rssi = 0;
271*572ff6f6SMatthew Dillon if (ads->ds_rxstatus1 & AR_KeyIdxValid)
272*572ff6f6SMatthew Dillon rs->rs_keyix = MS(ads->ds_rxstatus1, AR_KeyIdx);
273*572ff6f6SMatthew Dillon else
274*572ff6f6SMatthew Dillon rs->rs_keyix = HAL_RXKEYIX_INVALID;
275*572ff6f6SMatthew Dillon /* NB: caller expected to do rate table mapping */
276*572ff6f6SMatthew Dillon rs->rs_rate = MS(ads->ds_rxstatus0, AR_RcvRate);
277*572ff6f6SMatthew Dillon rs->rs_antenna = MS(ads->ds_rxstatus0, AR_RcvAntenna);
278*572ff6f6SMatthew Dillon rs->rs_more = (ads->ds_rxstatus0 & AR_More) ? 1 : 0;
279*572ff6f6SMatthew Dillon
280*572ff6f6SMatthew Dillon /*
281*572ff6f6SMatthew Dillon * The AR5413 (at least) sometimes sets both AR_CRCErr and
282*572ff6f6SMatthew Dillon * AR_PHYErr when reporting radar pulses. In this instance
283*572ff6f6SMatthew Dillon * set HAL_RXERR_PHY as well as HAL_RXERR_CRC and
284*572ff6f6SMatthew Dillon * let the driver layer figure out what to do.
285*572ff6f6SMatthew Dillon *
286*572ff6f6SMatthew Dillon * See PR kern/169362.
287*572ff6f6SMatthew Dillon */
288*572ff6f6SMatthew Dillon if ((ads->ds_rxstatus1 & AR_FrmRcvOK) == 0) {
289*572ff6f6SMatthew Dillon /*
290*572ff6f6SMatthew Dillon * These four bits should not be set together. The
291*572ff6f6SMatthew Dillon * 5212 spec states a Michael error can only occur if
292*572ff6f6SMatthew Dillon * DecryptCRCErr not set (and TKIP is used). Experience
293*572ff6f6SMatthew Dillon * indicates however that you can also get Michael errors
294*572ff6f6SMatthew Dillon * when a CRC error is detected, but these are specious.
295*572ff6f6SMatthew Dillon * Consequently we filter them out here so we don't
296*572ff6f6SMatthew Dillon * confuse and/or complicate drivers.
297*572ff6f6SMatthew Dillon */
298*572ff6f6SMatthew Dillon if (ads->ds_rxstatus1 & AR_PHYErr) {
299*572ff6f6SMatthew Dillon u_int phyerr;
300*572ff6f6SMatthew Dillon
301*572ff6f6SMatthew Dillon rs->rs_status |= HAL_RXERR_PHY;
302*572ff6f6SMatthew Dillon phyerr = MS(ads->ds_rxstatus1, AR_PHYErrCode);
303*572ff6f6SMatthew Dillon rs->rs_phyerr = phyerr;
304*572ff6f6SMatthew Dillon if (!AH5212(ah)->ah_hasHwPhyCounters &&
305*572ff6f6SMatthew Dillon phyerr != HAL_PHYERR_RADAR)
306*572ff6f6SMatthew Dillon ar5212AniPhyErrReport(ah, rs);
307*572ff6f6SMatthew Dillon }
308*572ff6f6SMatthew Dillon
309*572ff6f6SMatthew Dillon if (ads->ds_rxstatus1 & AR_CRCErr)
310*572ff6f6SMatthew Dillon rs->rs_status |= HAL_RXERR_CRC;
311*572ff6f6SMatthew Dillon else if (ads->ds_rxstatus1 & AR_DecryptCRCErr)
312*572ff6f6SMatthew Dillon rs->rs_status |= HAL_RXERR_DECRYPT;
313*572ff6f6SMatthew Dillon else if (ads->ds_rxstatus1 & AR_MichaelErr)
314*572ff6f6SMatthew Dillon rs->rs_status |= HAL_RXERR_MIC;
315*572ff6f6SMatthew Dillon }
316*572ff6f6SMatthew Dillon return HAL_OK;
317*572ff6f6SMatthew Dillon }
318