2 * carl9170 firmware - used by the ar9170 wireless device
4 * Interface to the WLAN part of the chip
6 * Copyright (c) 2000-2005 ZyDAS Technology Corporation
7 * Copyright (c) 2007-2009 Atheros Communications, Inc.
8 * Copyright 2009 Johannes Berg <johannes@sipsolutions.net>
9 * Copyright 2009-2011 Christian Lamparter <chunkeey@googlemail.com>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 #include "shared/phy.h"
33 #include "linux/ieee80211.h"
35 static void wlan_txunstuck(unsigned int queue)
37 set_wlan_txq_dma_addr(queue, ((uint32_t) fw.wlan.tx_queue[queue].head) | 1);
40 #ifdef CONFIG_CARL9170FW_DMA_QUEUE_BUMP
41 static void wlan_txupdate(unsigned int queue)
43 set_wlan_txq_dma_addr(queue, ((uint32_t) fw.wlan.tx_queue[queue].head));
46 static void wlan_dma_bump(unsigned int qidx)
48 unsigned int offset = qidx;
49 uint32_t status, trigger;
51 status = get(AR9170_MAC_REG_DMA_STATUS) >> 12;
52 trigger = get(AR9170_MAC_REG_DMA_TRIGGER) >> 12;
63 if ((trigger == 0xa) && (status == 0x8)) {
71 #endif /* CONFIG_CARL9170FW_DMA_QUEUE_BUMP */
73 #ifdef CONFIG_CARL9170FW_DEBUG
74 static void wlan_dump_queue(unsigned int qidx)
77 struct dma_desc *desc;
78 struct carl9170_tx_superframe *super;
81 __for_each_desc(desc, &fw.wlan.tx_queue[qidx]) {
82 super = get_super(desc);
83 DBG("%d: %p s:%x c:%x tl:%x ds:%x n:%p l:%p ", entries, desc,
84 desc->status, desc->ctrl, desc->totalLen,
85 desc->dataSize, desc->nextAddr, desc->lastAddr);
87 DBG("c:%x tr:%d ri:%d l:%x m:%x p:%x fc:%x",
88 super->s.cookie, super->s.cnt, super->s.rix,
89 super->f.hdr.length, super->f.hdr.mac.set,
90 (unsigned int) le32_to_cpu(super->f.hdr.phy.set),
91 super->f.data.i3e.frame_control);
96 desc = get_wlan_txq_addr(qidx);
98 DBG("Queue: %d: te:%d td:%d h:%p c:%p t:%p",
99 qidx, entries, queue_len(&fw.wlan.tx_queue[qidx]),
100 fw.wlan.tx_queue[qidx].head,
101 desc, fw.wlan.tx_queue[qidx].terminator);
103 DBG("HW: t:%x s:%x ac:%x c:%x",
104 (unsigned int) get(AR9170_MAC_REG_DMA_TRIGGER),
105 (unsigned int) get(AR9170_MAC_REG_DMA_STATUS),
106 (unsigned int) get(AR9170_MAC_REG_AMPDU_COUNT),
107 (unsigned int) get(AR9170_MAC_REG_DMA_TXQX_ADDR_CURR));
109 #endif /* CONFIG_CARL9170FW_DEBUG */
111 static void wlan_send_buffered_tx_status(void)
115 while (fw.wlan.tx_status_pending) {
116 len = min((unsigned int)fw.wlan.tx_status_pending,
117 CARL9170_RSP_TX_STATUS_NUM);
118 len = min(len, CARL9170_TX_STATUS_NUM - fw.wlan.tx_status_head_idx);
121 * rather than memcpy each individual request into a large buffer,
122 * we _splice_ them all together.
124 * The only downside is however that we have to be careful around
125 * the edges of the tx_status_cache.
128 * Each tx_status is about 2 bytes. However every command package
129 * must have a size which is a multiple of 4.
132 send_cmd_to_host((len * sizeof(struct carl9170_tx_status) + 3) & ~3,
133 CARL9170_RSP_TXCOMP, len, (void *)
134 &fw.wlan.tx_status_cache[fw.wlan.tx_status_head_idx]);
136 fw.wlan.tx_status_pending -= len;
137 fw.wlan.tx_status_head_idx += len;
138 fw.wlan.tx_status_head_idx %= CARL9170_TX_STATUS_NUM;
142 static struct carl9170_tx_status *wlan_get_tx_status_buffer(void)
144 struct carl9170_tx_status *tmp;
146 tmp = &fw.wlan.tx_status_cache[fw.wlan.tx_status_tail_idx++];
147 fw.wlan.tx_status_tail_idx %= CARL9170_TX_STATUS_NUM;
149 if (fw.wlan.tx_status_pending == CARL9170_TX_STATUS_NUM)
150 wlan_send_buffered_tx_status();
152 fw.wlan.tx_status_pending++;
157 /* generate _aggregated_ tx_status for the host */
158 void wlan_tx_complete(struct carl9170_tx_superframe *super,
161 struct carl9170_tx_status *status;
163 status = wlan_get_tx_status_buffer();
166 * The *unique* cookie and AC_ID is used by the driver for
169 status->cookie = super->s.cookie;
170 status->queue = super->s.queue;
174 * This field holds the number of tries of the rate in
175 * the rate index field (rix).
177 status->rix = super->s.rix;
178 status->tries = super->s.cnt;
179 status->success = (txs) ? 1 : 0;
182 static bool wlan_tx_consume_retry(struct carl9170_tx_superframe *super)
184 /* check if this was the last possible retry with this rate */
185 if (unlikely(super->s.cnt >= super->s.ri[super->s.rix].tries)) {
186 /* end of the road - indicate tx failure */
187 if (unlikely(super->s.rix == CARL9170_TX_MAX_RETRY_RATES))
190 /* check if there are alternative rates available */
191 if (!super->s.rr[super->s.rix].set)
194 /* try next retry rate */
195 super->f.hdr.phy.set = super->s.rr[super->s.rix].set;
197 /* finally - mark the old rate as USED */
200 /* update MAC flags */
201 super->f.hdr.mac.erp_prot = super->s.ri[super->s.rix].erp_prot;
202 super->f.hdr.mac.ampdu = super->s.ri[super->s.rix].ampdu;
204 /* reinitialize try counter */
207 /* just increase retry counter */
214 static inline u16 get_tid(struct ieee80211_hdr *hdr)
216 return (ieee80211_get_qos_ctl(hdr))[0] & IEEE80211_QOS_CTL_TID_MASK;
219 /* This function will only work on uint32_t-aligned pointers! */
220 static inline bool compare_ether_address(const void *_d0, const void *_d1)
222 const uint32_t *d0 = _d0;
223 const uint32_t *d1 = _d1;
225 /* BUG_ON((unsigned long)d0 & 3 || (unsigned long)d1 & 3)) */
226 return !((d0[0] ^ d1[0]) | (unsigned short)(d0[1] ^ d1[1]));
229 /* This function will only work on uint32_t-aligned pointers! */
230 static bool same_hdr(const void *_d0, const void *_d1)
232 const uint32_t *d0 = _d0;
233 const uint32_t *d1 = _d1;
235 /* BUG_ON((unsigned long)d0 & 3 || (unsigned long)d1 & 3)) */
236 return !((d0[0] ^ d1[0]) | /* FC + DU */
237 (d0[1] ^ d1[1]) | /* addr1 */
238 (d0[2] ^ d1[2]) | (d0[3] ^ d1[3]) | /* addr2 + addr3 */
239 (d0[4] ^ d1[4])); /* addr3 */
242 static inline bool same_aggr(struct ieee80211_hdr *a, struct ieee80211_hdr *b)
244 return (get_tid(a) == get_tid(b)) || same_hdr(a, b);
247 static void wlan_tx_ampdu_end(unsigned int qidx)
249 struct carl9170_tx_superframe *ht_prev = fw.wlan.ampdu_prev[qidx];
251 fw.wlan.ampdu_prev[qidx] = NULL;
253 ht_prev->f.hdr.mac.ba_end = 1;
256 static void wlan_tx_ampdu(struct carl9170_tx_superframe *super)
258 unsigned int qidx = super->s.queue;
259 struct carl9170_tx_superframe *ht_prev = fw.wlan.ampdu_prev[qidx];
261 if (!super->f.hdr.mac.ampdu) {
262 wlan_tx_ampdu_end(qidx);
264 fw.wlan.ampdu_prev[qidx] = super;
267 !same_aggr(&super->f.data.i3e, &ht_prev->f.data.i3e))
268 ht_prev->f.hdr.mac.ba_end = 1;
270 super->f.hdr.mac.ba_end = 0;
275 static void __wlan_tx(struct dma_desc *desc)
277 struct carl9170_tx_superframe *super = get_super(desc);
279 if (unlikely(super->s.fill_in_tsf)) {
280 struct ieee80211_mgmt *mgmt = (void *) &super->f.data.i3e;
281 uint32_t *tsf = (uint32_t *) &mgmt->u.probe_resp.timestamp;
284 * Truth be told: this is a hack.
286 * The *real* TSF is definitely going to be higher/older.
287 * But this hardware emulation code is head and shoulders
288 * above anything a driver can possibly do.
290 * (even, if it's got an accurate atomic clock source).
296 wlan_tx_ampdu(super);
298 #if (defined CONFIG_CARL9170FW_LOOPBACK) || (defined CONFIG_CARL9170FW_DISCARD)
299 wlan_tx_complete(super, true);
301 # ifdef CONFIG_CARL9170FW_LOOPBACK
302 dma_put(&fw.pta.up_queue, desc);
304 # elif CONFIG_CARL9170FW_DISCARD
305 dma_reclaim(&fw.pta.down_queue, desc);
308 #else /* CONFIG_CARL9170FW_LOOPBACK */
310 # ifdef CONFIG_CARL9170FW_DEBUG
311 BUG_ON(fw.phy.psm.state != CARL9170_PSM_WAKE);
312 # endif /* CONFIG_CARL9170FW_DEBUG */
314 /* insert desc into the right queue */
315 dma_put(&fw.wlan.tx_queue[super->s.queue], desc);
316 #endif /* CONFIG_CARL9170FW_LOOPBACK */
319 static void wlan_assign_seq(struct ieee80211_hdr *hdr, unsigned int vif)
321 hdr->seq_ctrl &= cpu_to_le16(~IEEE80211_SCTL_SEQ);
322 hdr->seq_ctrl |= cpu_to_le16(fw.wlan.sequence[vif]);
324 if (!(hdr->seq_ctrl & cpu_to_le16(IEEE80211_SCTL_FRAG)))
325 fw.wlan.sequence[vif] += 0x10;
328 /* prepares frame for the first transmission */
329 static void _wlan_tx(struct dma_desc *desc)
331 struct carl9170_tx_superframe *super = get_super(desc);
333 if (unlikely(super->s.assign_seq))
334 wlan_assign_seq(&super->f.data.i3e, super->s.vif_id);
336 if (unlikely(super->s.ampdu_commit_density)) {
337 set(AR9170_MAC_REG_AMPDU_DENSITY,
338 MOD_VAL(AR9170_MAC_AMPDU_DENSITY,
339 get(AR9170_MAC_REG_AMPDU_DENSITY),
340 super->s.ampdu_density));
343 if (unlikely(super->s.ampdu_commit_factor)) {
344 set(AR9170_MAC_REG_AMPDU_FACTOR,
345 MOD_VAL(AR9170_MAC_AMPDU_FACTOR,
346 get(AR9170_MAC_REG_AMPDU_FACTOR),
347 8 << super->s.ampdu_factor));
353 /* propagate transmission status back to the driver */
354 static bool wlan_tx_status(struct dma_queue *queue,
355 struct dma_desc *desc)
357 struct carl9170_tx_superframe *super = get_super(desc);
358 unsigned int qidx = super->s.queue;
359 bool txfail = false, success;
363 /* update hangcheck */
364 fw.wlan.last_super_num[qidx] = 0;
366 if (!!(desc->ctrl & AR9170_CTRL_FAIL)) {
367 txfail = !!(desc->ctrl & AR9170_CTRL_TXFAIL);
369 /* reset retry indicator flags */
370 desc->ctrl &= ~(AR9170_CTRL_TXFAIL | AR9170_CTRL_BAFAIL);
372 if (wlan_tx_consume_retry(super)) {
374 * retry for simple and aggregated 802.11 frames.
376 * Note: We must not mess up the original frame
380 if (!super->f.hdr.mac.ampdu) {
382 * 802.11 - 7.1.3.1.5.
383 * set "Retry Field" for consecutive attempts
385 * Note: For AMPDU see:
386 * 802.11n 9.9.1.6 "Retransmit Procedures"
388 super->f.data.i3e.frame_control |=
389 cpu_to_le16(IEEE80211_FCTL_RETRY);
393 /* Normal TX Failure */
395 /* demise descriptor ownership back to the hardware */
399 * And this will get the queue going again.
400 * To understand why: you have to get the HW
401 * specs... But sadly I never saw them.
403 wlan_txunstuck(qidx);
405 /* abort cycle - this is necessary due to HW design */
408 /* (HT-) BlockACK failure */
411 * Unlink the failed attempt and put it into
412 * the retry queue. The caller routine must
413 * be aware of this so the frames don't get lost.
416 dma_unlink_head(queue);
417 dma_put(&fw.wlan.tx_retry, desc);
421 /* out of frame attempts - discard frame */
426 dma_unlink_head(queue);
429 * Issue the queue bump,
430 * We need to do this in case this was the frame's last
431 * possible retry attempt and it unfortunately: it failed.
434 wlan_txunstuck(qidx);
439 if (unlikely(super == fw.wlan.fw_desc_data)) {
440 fw.wlan.fw_desc = desc;
441 fw.wlan.fw_desc_available = 1;
443 if (fw.wlan.fw_desc_callback)
444 fw.wlan.fw_desc_callback(super, success);
449 #ifdef CONFIG_CARL9170FW_CAB_QUEUE
450 if (unlikely(super->s.cab))
451 fw.wlan.cab_queue_len[super->s.vif_id]--;
452 #endif /* CONFIG_CARL9170FW_CAB_QUEUE */
454 wlan_tx_complete(super, success);
456 /* recycle freed descriptors */
457 dma_reclaim(&fw.pta.down_queue, desc);
462 static void handle_tx_completion(void)
464 struct dma_desc *desc;
467 for (i = AR9170_TXQ_SPECIAL; i >= AR9170_TXQ0; i--) {
468 __while_desc_bits(desc, &fw.wlan.tx_queue[i], AR9170_OWN_BITS_SW) {
469 if (!wlan_tx_status(&fw.wlan.tx_queue[i], desc)) {
470 /* termination requested. */
475 for_each_desc(desc, &fw.wlan.tx_retry)
478 wlan_tx_ampdu_end(i);
479 if (!queue_empty(&fw.wlan.tx_queue[i]))
480 wlan_trigger(BIT(i));
484 void __hot wlan_tx(struct dma_desc *desc)
486 struct carl9170_tx_superframe *super = DESC_PAYLOAD(desc);
488 /* initialize rate control struct */
493 #ifdef CONFIG_CARL9170FW_CAB_QUEUE
494 if (unlikely(super->s.cab)) {
495 fw.wlan.cab_queue_len[super->s.vif_id]++;
496 dma_put(&fw.wlan.cab_queue[super->s.vif_id], desc);
499 #endif /* CONFIG_CARL9170FW_CAB_QUEUE */
502 wlan_trigger(BIT(super->s.queue));
505 static void wlan_tx_fw(struct carl9170_tx_superdesc *super, fw_desc_callback_t cb)
507 if (!fw.wlan.fw_desc_available)
510 fw.wlan.fw_desc_available = 0;
512 /* Format BlockAck */
513 fw.wlan.fw_desc->ctrl = AR9170_CTRL_FS_BIT | AR9170_CTRL_LS_BIT;
514 fw.wlan.fw_desc->status = AR9170_OWN_BITS_SW;
516 fw.wlan.fw_desc->totalLen = fw.wlan.fw_desc->dataSize = super->len;
517 fw.wlan.fw_desc_data = fw.wlan.fw_desc->dataAddr = super;
518 fw.wlan.fw_desc->nextAddr = fw.wlan.fw_desc->lastAddr =
520 fw.wlan.fw_desc_callback = cb;
521 wlan_tx(fw.wlan.fw_desc);
524 static void wlan_send_buffered_ba(void)
526 struct carl9170_tx_ba_superframe *baf = &dma_mem.reserved.ba.ba;
527 struct ieee80211_ba *ba = (struct ieee80211_ba *) &baf->f.ba;
528 struct carl9170_bar_ctx *ctx;
530 if (likely(fw.wlan.ba_head_idx == fw.wlan.ba_tail_idx))
533 /* there's no point to continue when the ba_desc is not available. */
534 if (!fw.wlan.fw_desc_available)
537 ctx = &fw.wlan.ba_cache[fw.wlan.ba_head_idx];
538 fw.wlan.ba_head_idx++;
539 fw.wlan.ba_head_idx %= CONFIG_CARL9170FW_BACK_REQS_NUM;
541 baf->s.len = sizeof(struct carl9170_tx_superdesc) +
542 sizeof(struct ar9170_tx_hwdesc) +
543 sizeof(struct ieee80211_ba);
544 baf->s.ri[0].tries = 1;
546 baf->s.queue = AR9170_TXQ_VO;
547 baf->f.hdr.length = sizeof(struct ieee80211_ba) + FCS_LEN;
549 /* HW Duration / Backoff */
550 baf->f.hdr.mac.backoff = 1;
551 baf->f.hdr.mac.hw_duration = 1;
553 /* take the TX rate from the RX'd BAR */
554 baf->f.hdr.phy.set = ctx->phy;
555 baf->f.hdr.phy.tx_power = 29; /* 14.5 dBm */
557 /* format outgoing BA */
558 ba->frame_control = cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_NULLFUNC);
559 ba->duration = cpu_to_le16(0);
560 memcpy(ba->ta, ctx->ta, 6);
561 memcpy(ba->ra, ctx->ra, 6);
564 * Unfortunately, we cannot look into the hardware's scoreboard.
565 * Therefore we have to proceed as described in 802.11n 9.10.7.5
566 * and send a null BlockAck.
568 memset(ba->bitmap, 0x0, sizeof(ba->bitmap));
572 * not entirely sure if this is 100% correct?!
574 ba->control = ctx->control | cpu_to_le16(1);
575 ba->start_seq_num = ctx->start_seq_num;
576 wlan_tx_fw(&baf->s, NULL);
579 static struct carl9170_bar_ctx *wlan_get_bar_cache_buffer(void)
581 struct carl9170_bar_ctx *tmp;
583 tmp = &fw.wlan.ba_cache[fw.wlan.ba_tail_idx];
584 fw.wlan.ba_tail_idx++;
585 fw.wlan.ba_tail_idx %= CONFIG_CARL9170FW_BACK_REQS_NUM;
590 static void handle_bar(struct dma_desc *desc, struct ieee80211_hdr *hdr,
591 unsigned int len, unsigned int mac_err)
593 struct ieee80211_bar *bar;
594 struct carl9170_bar_ctx *ctx;
596 if (unlikely(mac_err)) {
598 * This check does a number of things:
599 * 1. checks if the frame is in good nick
600 * 2. checks if the RA (MAC) matches
605 if (unlikely(len < (sizeof(struct ieee80211_bar) + FCS_LEN))) {
607 * Sneaky, corrupted BARs... but not with us!
615 if ((bar->control & cpu_to_le16(IEEE80211_BAR_CTRL_MULTI_TID)) ||
616 !(bar->control & cpu_to_le16(IEEE80211_BAR_CTRL_CBMTID_COMPRESSED_BA))) {
617 /* not implemented yet */
622 ctx = wlan_get_bar_cache_buffer();
624 /* Brilliant! The BAR provides all necessary MACs! */
625 memcpy(ctx->ra, bar->ta, 6);
626 memcpy(ctx->ta, bar->ra, 6);
630 * not entirely sure if this is 100% correct to force the
631 * imm ack bit or not...
633 ctx->control = bar->control | cpu_to_le16(1);
634 ctx->start_seq_num = bar->start_seq_num;
635 ctx->phy = ar9170_rx_to_phy(desc);
636 if (unlikely(!ctx->phy)) {
637 /* provide a backup, in case ar9170_rx_to_phy fails */
638 ctx->phy = cpu_to_le32(0x2cc301);
642 static void wlan_check_rx_overrun(void)
644 uint32_t overruns, total;
646 fw.tally.rx_total += total = get(AR9170_MAC_REG_RX_TOTAL);
647 fw.tally.rx_overrun += overruns = get(AR9170_MAC_REG_RX_OVERRUN);
648 if (unlikely(overruns)) {
649 if (overruns == total) {
654 wlan_trigger(AR9170_DMA_TRIGGER_RXQ);
658 #ifdef CONFIG_CARL9170FW_WOL
659 void wlan_prepare_wol(void)
662 memcpy((void *)AR9170_MAC_REG_MAC_ADDR_L, fw.wlan.wol.cmd.mac, 6);
663 memcpy((void *)AR9170_MAC_REG_BSSID_L, fw.wlan.wol.cmd.bssid, 6);
664 set(AR9170_MAC_REG_RX_CONTROL, AR9170_MAC_RX_CTRL_DEAGG);
666 /* set filter policy to: discard everything */
667 fw.wlan.rx_filter = CARL9170_RX_FILTER_EVERYTHING;
669 /* reenable rx dma */
670 wlan_trigger(AR9170_DMA_TRIGGER_RXQ);
672 /* initialize the last_beacon timer */
673 fw.wlan.wol.last_null = fw.wlan.wol.last_beacon = get_clock_counter();
676 #ifdef CONFIG_CARL9170FW_WOL_NL80211_TRIGGERS
677 static bool wlan_rx_wol_magic_packet(struct ieee80211_hdr *hdr, unsigned int len)
679 const unsigned char *data, *end, *mac;
680 unsigned int found = 0;
684 * We can only scan the first AR9170_BLOCK_SIZE [=~320] bytes
685 * for MAGIC patterns!
688 mac = (const unsigned char *) AR9170_MAC_REG_MAC_ADDR_L;
690 data = (u8 *)((unsigned long)hdr + ieee80211_hdrlen(hdr->frame_control));
691 end = (u8 *)((unsigned long)hdr + len);
694 * scan for standard WOL Magic frame
696 * "A physical WakeOnLAN (Magic Packet) will look like this:
697 * ---------------------------------------------------------------
698 * | Synchronization Stream | Target MAC | Password (optional) |
699 * | 6 octets | 96 octets | 0, 4 or 6 |
700 * ---------------------------------------------------------------
702 * The Synchronization Stream is defined as 6 bytes of FFh.
703 * The Target MAC block contains 16 duplications of the IEEEaddress
704 * of the target, with no breaks or interruptions.
706 * The Password field is optional, but if present, contains either
707 * 4 bytes or 6 bytes. The WakeOnLAN dissector was implemented to
708 * dissect the password, if present, according to the command-line
709 * format that ether-wake uses, therefore, if a 4-byte password is
710 * present, it will be dissected as an IPv4 address and if a 6-byte
711 * password is present, it will be dissected as an Ethernet address.
713 * <http://wiki.wireshark.org/WakeOnLAN>
718 if (*data == mac[found % 6])
724 /* previous check might reset found counter */
732 if (found == (6 + 16 * 6))
741 static void wlan_wol_connect_callback(void __unused *dummy, bool success)
744 fw.wlan.wol.lost_null = 0;
746 fw.wlan.wol.lost_null++;
749 static void wlan_wol_connection_monitor(void)
751 struct carl9170_tx_null_superframe *nullf = &dma_mem.reserved.cmd.null;
752 struct ieee80211_hdr *null = (struct ieee80211_hdr *) &nullf->f.null;
754 if (!fw.wlan.fw_desc_available)
757 memset(nullf, 0, sizeof(*nullf));
759 nullf->s.len = sizeof(struct carl9170_tx_superdesc) +
760 sizeof(struct ar9170_tx_hwdesc) +
761 sizeof(struct ieee80211_hdr);
762 nullf->s.ri[0].tries = 3;
763 nullf->s.assign_seq = true;
764 nullf->s.queue = AR9170_TXQ_VO;
765 nullf->f.hdr.length = sizeof(struct ieee80211_hdr) + FCS_LEN;
767 nullf->f.hdr.mac.backoff = 1;
768 nullf->f.hdr.mac.hw_duration = 1;
769 nullf->f.hdr.mac.erp_prot = AR9170_TX_MAC_PROT_RTS;
771 nullf->f.hdr.phy.modulation = AR9170_TX_PHY_MOD_OFDM;
772 nullf->f.hdr.phy.bandwidth = AR9170_TX_PHY_BW_20MHZ;
773 nullf->f.hdr.phy.chains = AR9170_TX_PHY_TXCHAIN_2;
774 nullf->f.hdr.phy.tx_power = 29; /* 14.5 dBm */
775 nullf->f.hdr.phy.mcs = AR9170_TXRX_PHY_RATE_OFDM_6M;
777 /* format outgoing nullfunc */
778 null->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA |
779 IEEE80211_STYPE_NULLFUNC | IEEE80211_FCTL_TODS);
781 memcpy(null->addr1, fw.wlan.wol.cmd.bssid, 6);
782 memcpy(null->addr2, fw.wlan.wol.cmd.mac, 6);
783 memcpy(null->addr3, fw.wlan.wol.cmd.bssid, 6);
785 wlan_tx_fw(&nullf->s, wlan_wol_connect_callback);
788 static bool wlan_rx_wol_disconnect(const unsigned int rx_filter,
789 struct ieee80211_hdr *hdr,
790 unsigned int __unused len)
792 const unsigned char *bssid;
793 bssid = (const unsigned char *) AR9170_MAC_REG_BSSID_L;
795 /* should catch both broadcast and unicast MLMEs */
796 if (!(rx_filter & CARL9170_RX_FILTER_OTHER_RA)) {
797 if (ieee80211_is_deauth(hdr->frame_control) ||
798 ieee80211_is_disassoc(hdr->frame_control))
802 if (ieee80211_is_beacon(hdr->frame_control) &&
803 compare_ether_address(hdr->addr3, bssid)) {
804 fw.wlan.wol.last_beacon = get_clock_counter();
810 #endif /* CARL9170FW_WOL_NL80211_TRIGGERS */
812 #ifdef CONFIG_CARL9170FW_WOL_PROBE_REQUEST
815 * Note: CONFIG_CARL9170FW_WOL_PROBE_REQUEST_SSID is not a real
816 * string. We have to be careful not to add a \0 at the end.
818 static const struct {
821 u8 ssid[sizeof(CONFIG_CARL9170FW_WOL_PROBE_REQUEST_SSID) - 1];
822 } __packed probe_req = {
823 .ssid_ie = WLAN_EID_SSID,
824 .ssid_len = sizeof(CONFIG_CARL9170FW_WOL_PROBE_REQUEST_SSID) - 1,
825 .ssid = CONFIG_CARL9170FW_WOL_PROBE_REQUEST_SSID,
828 static bool wlan_rx_wol_probe_ssid(struct ieee80211_hdr *hdr, unsigned int len)
830 const unsigned char *data, *end, *scan = (void *) &probe_req;
833 * IEEE 802.11-2007 7.3.2.1 specifies that the SSID is no
834 * longer than 32 octets.
836 BUILD_BUG_ON((sizeof(CONFIG_CARL9170FW_WOL_PROBE_REQUEST_SSID) - 1) > 32);
838 if (ieee80211_is_probe_req(hdr->frame_control)) {
840 end = (u8 *)((unsigned long)hdr + len);
843 * The position of the SSID information element inside
844 * a probe request frame is more or less "fixed".
846 data = (u8 *)((struct ieee80211_mgmt *)hdr)->u.probe_req.variable;
847 for (i = 0; i < (unsigned int)(probe_req.ssid_len + 1); i++) {
848 if (data > end || scan[i] != data[i])
857 #endif /* CONFIG_CARL9170FW_WOL_PROBE_REQUEST */
859 static void wlan_rx_wol(unsigned int rx_filter __unused, struct ieee80211_hdr *hdr __unused, unsigned int len __unused)
861 #ifdef CONFIG_CARL9170FW_WOL_NL80211_TRIGGERS
862 /* Disconnect is always enabled */
863 if (fw.wlan.wol.cmd.flags & CARL9170_WOL_DISCONNECT &&
864 rx_filter & CARL9170_RX_FILTER_MGMT)
865 fw.wlan.wol.wake_up |= wlan_rx_wol_disconnect(rx_filter, hdr, len);
867 if (fw.wlan.wol.cmd.flags & CARL9170_WOL_MAGIC_PKT &&
868 rx_filter & CARL9170_RX_FILTER_DATA)
869 fw.wlan.wol.wake_up |= wlan_rx_wol_magic_packet(hdr, len);
870 #endif /* CONFIG_CARL9170FW_WOL_NL80211_TRIGGERS */
872 #ifdef CONFIG_CARL9170FW_WOL_PROBE_REQUEST
873 if (rx_filter & CARL9170_RX_FILTER_MGMT)
874 fw.wlan.wol.wake_up |= wlan_rx_wol_probe_ssid(hdr, len);
875 #endif /* CONFIG_CARL9170FW_WOL_PROBE_REQUEST */
878 static void wlan_wol_janitor(void)
880 if (unlikely(fw.suspend_mode == CARL9170_HOST_SUSPENDED)) {
881 if (fw.wlan.wol.cmd.flags & CARL9170_WOL_DISCONNECT) {
883 * connection lost after 10sec without receiving
886 if (is_after_msecs(fw.wlan.wol.last_beacon, 10000))
887 fw.wlan.wol.wake_up |= true;
889 if (fw.wlan.wol.cmd.null_interval &&
890 is_after_msecs(fw.wlan.wol.last_null, fw.wlan.wol.cmd.null_interval))
891 wlan_wol_connection_monitor();
893 if (fw.wlan.wol.lost_null >= 5)
894 fw.wlan.wol.wake_up |= true;
897 if (fw.wlan.wol.wake_up) {
898 fw.suspend_mode = CARL9170_AWAKE_HOST;
899 set(AR9170_USB_REG_WAKE_UP, AR9170_USB_WAKE_UP_WAKE);
903 #endif /* CONFIG_CARL9170FW_WOL */
905 static unsigned int wlan_rx_filter(struct dma_desc *desc)
907 struct ieee80211_hdr *hdr;
908 unsigned int data_len;
909 unsigned int rx_filter;
910 unsigned int mac_err;
912 data_len = ar9170_get_rx_mpdu_len(desc);
913 mac_err = ar9170_get_rx_macstatus_error(desc);
915 #define AR9170_RX_ERROR_BAD (AR9170_RX_ERROR_FCS | AR9170_RX_ERROR_PLCP)
917 if (unlikely(data_len < (4 + 6 + FCS_LEN) ||
918 desc->totalLen > CONFIG_CARL9170FW_RX_FRAME_LEN) ||
919 mac_err & AR9170_RX_ERROR_BAD) {
921 * This frame is too damaged to do anything
925 return CARL9170_RX_FILTER_BAD;
929 if (mac_err & AR9170_RX_ERROR_WRONG_RA)
930 rx_filter |= CARL9170_RX_FILTER_OTHER_RA;
932 if (mac_err & AR9170_RX_ERROR_DECRYPT)
933 rx_filter |= CARL9170_RX_FILTER_DECRY_FAIL;
935 hdr = ar9170_get_rx_i3e(desc);
936 if (likely(ieee80211_is_data(hdr->frame_control))) {
937 rx_filter |= CARL9170_RX_FILTER_DATA;
938 } else if (ieee80211_is_ctl(hdr->frame_control)) {
939 switch (le16_to_cpu(hdr->frame_control) & IEEE80211_FCTL_STYPE) {
940 case IEEE80211_STYPE_BACK_REQ:
941 handle_bar(desc, hdr, data_len, mac_err);
943 rx_filter |= CARL9170_RX_FILTER_CTL_BACKR;
945 case IEEE80211_STYPE_PSPOLL:
946 rx_filter |= CARL9170_RX_FILTER_CTL_PSPOLL;
949 rx_filter |= CARL9170_RX_FILTER_CTL_OTHER;
953 /* ieee80211_is_mgmt */
954 rx_filter |= CARL9170_RX_FILTER_MGMT;
957 #ifdef CONFIG_CARL9170FW_WOL
958 if (unlikely(fw.suspend_mode == CARL9170_HOST_SUSPENDED)) {
959 wlan_rx_wol(rx_filter, hdr, min(data_len,
960 (unsigned int)AR9170_BLOCK_SIZE));
962 #endif /* CONFIG_CARL9170FW_WOL */
964 #undef AR9170_RX_ERROR_BAD
969 static void handle_rx(void)
971 struct dma_desc *desc;
973 for_each_desc_not_bits(desc, &fw.wlan.rx_queue, AR9170_OWN_BITS_HW) {
974 if (!(wlan_rx_filter(desc) & fw.wlan.rx_filter)) {
975 dma_put(&fw.pta.up_queue, desc);
978 dma_reclaim(&fw.wlan.rx_queue, desc);
979 wlan_trigger(AR9170_DMA_TRIGGER_RXQ);
984 #ifdef CONFIG_CARL9170FW_CAB_QUEUE
985 void wlan_cab_flush_queue(const unsigned int vif)
987 struct dma_queue *cab_queue = &fw.wlan.cab_queue[vif];
988 struct dma_desc *desc;
990 /* move queued frames into the main tx queues */
991 for_each_desc(desc, cab_queue) {
992 struct carl9170_tx_superframe *super = get_super(desc);
993 if (!queue_empty(cab_queue)) {
995 * Set MOREDATA flag for all,
996 * but the last queued frame.
997 * see: 802.11-2007 11.2.1.5 f)
999 * This is actually the reason to why
1000 * we need to prevent the reentry.
1003 super->f.data.i3e.frame_control |=
1004 cpu_to_le16(IEEE80211_FCTL_MOREDATA);
1006 super->f.data.i3e.frame_control &=
1007 cpu_to_le16(~IEEE80211_FCTL_MOREDATA);
1010 /* ready to roll! */
1012 wlan_trigger(BIT(super->s.queue));
1016 static uint8_t *beacon_find_ie(uint8_t ie, void *addr,
1017 const unsigned int len)
1019 struct ieee80211_mgmt *mgmt = addr;
1022 pos = mgmt->u.beacon.variable;
1023 end = (uint8_t *) ((unsigned long)mgmt + (len - FCS_LEN));
1025 if (pos + 2 + pos[1] > end)
1037 void wlan_modify_beacon(const unsigned int vif,
1038 const unsigned int addr, const unsigned int len)
1041 struct ieee80211_tim_ie *ie;
1043 _ie = beacon_find_ie(WLAN_EID_TIM, (void *)addr, len);
1045 ie = (struct ieee80211_tim_ie *) &_ie[2];
1047 if (!queue_empty(&fw.wlan.cab_queue[vif]) && (ie->dtim_count == 0)) {
1048 /* schedule DTIM transfer */
1049 fw.wlan.cab_flush_trigger[vif] = CARL9170_CAB_TRIGGER_ARMED;
1050 } else if ((fw.wlan.cab_queue_len[vif] == 0) && (fw.wlan.cab_flush_trigger[vif])) {
1051 /* undo all chances to the beacon structure */
1052 ie->bitmap_ctrl &= ~0x1;
1053 fw.wlan.cab_flush_trigger[vif] = CARL9170_CAB_TRIGGER_EMPTY;
1056 /* Triggered by CARL9170_CAB_TRIGGER_ARMED || CARL9170_CAB_TRIGGER_DEFER */
1057 if (fw.wlan.cab_flush_trigger[vif]) {
1058 /* Set the almighty Multicast Traffic Indication Bit. */
1059 ie->bitmap_ctrl |= 0x1;
1064 * Ideally, the sequence number should be assigned by the TX arbiter
1065 * hardware. But AFAIK that's not possible, so we have to go for the
1066 * next best thing and write it into the beacon fifo during the open
1067 * beacon update window.
1070 wlan_assign_seq((struct ieee80211_hdr *)addr, vif);
1073 static void wlan_send_buffered_cab(void)
1077 for (i = 0; i < CARL9170_INTF_NUM; i++) {
1078 if (unlikely(fw.wlan.cab_flush_trigger[i] == CARL9170_CAB_TRIGGER_ARMED)) {
1080 * This is hardcoded into carl9170usb driver.
1082 * The driver must set the PRETBTT event to beacon_interval -
1083 * CARL9170_PRETBTT_KUS (usually 6) Kus.
1085 * But still, we can only do so much about 802.11-2007 9.3.2.1 &
1086 * 11.2.1.6. Let's hope the current solution is adequate enough.
1089 if (is_after_msecs(fw.wlan.cab_flush_time, (CARL9170_TBTT_DELTA))) {
1090 wlan_cab_flush_queue(i);
1093 * This prevents the code from sending new BC/MC frames
1094 * which were queued after the previous buffered traffic
1095 * has been sent out... They will have to wait until the
1096 * next DTIM beacon comes along.
1098 fw.wlan.cab_flush_trigger[i] = CARL9170_CAB_TRIGGER_DEFER;
1104 #endif /* CONFIG_CARL9170FW_CAB_QUEUE */
1106 static void handle_beacon_config(void)
1110 bcn_count = get(AR9170_MAC_REG_BCN_COUNT);
1111 send_cmd_to_host(4, CARL9170_RSP_BEACON_CONFIG, 0x00,
1112 (uint8_t *) &bcn_count);
1115 static void handle_pretbtt(void)
1117 #ifdef CONFIG_CARL9170FW_CAB_QUEUE
1118 fw.wlan.cab_flush_time = get_clock_counter();
1119 #endif /* CONFIG_CARL9170FW_CAB_QUEUE */
1121 #ifdef CONFIG_CARL9170FW_RADIO_FUNCTIONS
1124 send_cmd_to_host(4, CARL9170_RSP_PRETBTT, 0x00,
1125 (uint8_t *) &fw.phy.psm.state);
1126 #endif /* CONFIG_CARL9170FW_RADIO_FUNCTIONS */
1129 static void handle_atim(void)
1131 send_cmd_to_host(0, CARL9170_RSP_ATIM, 0x00, NULL);
1134 #ifdef CONFIG_CARL9170FW_DEBUG
1135 static void handle_qos(void)
1138 * What is the QoS Bit used for?
1139 * Is it only an indicator for TXOP & Burst, or
1140 * should we do something here?
1144 static void handle_radar(void)
1146 send_cmd_to_host(0, CARL9170_RSP_RADAR, 0x00, NULL);
1148 #endif /* CONFIG_CARL9170FW_DEBUG */
1150 static void wlan_janitor(void)
1152 #ifdef CONFIG_CARL9170FW_CAB_QUEUE
1153 wlan_send_buffered_cab();
1154 #endif /* CONFIG_CARL9170FW_CAB_QUEUE */
1156 wlan_send_buffered_tx_status();
1158 wlan_send_buffered_ba();
1160 #ifdef CONFIG_CARL9170FW_WOL
1162 #endif /* CONFIG_CARL9170FW_WOL */
1165 void handle_wlan(void)
1169 intr = get(AR9170_MAC_REG_INT_CTRL);
1171 set(AR9170_MAC_REG_INT_CTRL, intr);
1173 #define HANDLER(intr, flag, func) \
1175 if ((intr & flag) != 0) { \
1180 intr |= fw.wlan.soft_int;
1181 fw.wlan.soft_int = 0;
1183 HANDLER(intr, AR9170_MAC_INT_PRETBTT, handle_pretbtt);
1185 HANDLER(intr, AR9170_MAC_INT_ATIM, handle_atim);
1187 HANDLER(intr, AR9170_MAC_INT_RXC, handle_rx);
1189 HANDLER(intr, (AR9170_MAC_INT_TXC | AR9170_MAC_INT_RETRY_FAIL),
1190 handle_tx_completion);
1192 #ifdef CONFIG_CARL9170FW_DEBUG
1193 HANDLER(intr, AR9170_MAC_INT_QOS, handle_qos);
1195 HANDLER(intr, AR9170_MAC_INT_RADAR, handle_radar);
1196 #endif /* CONFIG_CARL9170FW_DEBUG */
1198 HANDLER(intr, AR9170_MAC_INT_CFG_BCN, handle_beacon_config);
1201 DBG("Unhandled Interrupt %x\n", (unsigned int) intr);
1209 CARL9170FW_TX_MAC_BUMP = 4,
1210 CARL9170FW_TX_MAC_DEBUG = 6,
1211 CARL9170FW_TX_MAC_RESET = 7,
1214 static void wlan_check_hang(void)
1216 struct dma_desc *desc;
1219 for (i = AR9170_TXQ_SPECIAL; i >= AR9170_TXQ0; i--) {
1220 if (queue_empty(&fw.wlan.tx_queue[i])) {
1221 /* Nothing to do here... move along */
1225 /* fetch the current DMA queue position */
1226 desc = (struct dma_desc *)get_wlan_txq_addr(i);
1228 /* Stuck frame detection */
1229 if (unlikely(DESC_PAYLOAD(desc) == fw.wlan.last_super[i])) {
1230 fw.wlan.last_super_num[i]++;
1232 if (unlikely(fw.wlan.last_super_num[i] >= CARL9170FW_TX_MAC_RESET)) {
1234 * schedule MAC reset (aka OFF/ON => dead)
1236 * This will almost certainly kill
1237 * the device for good, but it's the
1238 * recommended thing to do...
1241 fw.wlan.mac_reset++;
1244 #ifdef CONFIG_CARL9170FW_DEBUG
1245 if (unlikely(fw.wlan.last_super_num[i] >= CARL9170FW_TX_MAC_DEBUG)) {
1247 * Sigh, the queue is almost certainly
1248 * dead. Dump the queue content to the
1249 * user, maybe we find out why it got
1255 #endif /* CONFIG_CARL9170FW_DEBUG */
1257 #ifdef CONFIG_CARL9170FW_DMA_QUEUE_BUMP
1258 if (unlikely(fw.wlan.last_super_num[i] >= CARL9170FW_TX_MAC_BUMP)) {
1260 * Hrrm, bump the queue a bit.
1261 * maybe this will get it going again.
1265 wlan_trigger(BIT(i));
1267 #endif /* CONFIG_CARL9170FW_DMA_QUEUE_BUMP */
1270 fw.wlan.last_super[i] = DESC_PAYLOAD(desc);
1271 fw.wlan.last_super_num[i] = 0;
1276 #ifdef CONFIG_CARL9170FW_FW_MAC_RESET
1278 * NB: Resetting the MAC is a two-edged sword.
1279 * On most occasions, it does what it is supposed to do.
1280 * But there is a chance that this will make it
1281 * even worse and the radio dies silently.
1283 static void wlan_mac_reset(void)
1286 uint32_t agg_wait_counter;
1287 uint32_t agg_density;
1288 uint32_t bcn_start_addr;
1289 uint32_t rctl, rcth;
1292 uint32_t rts_cts_tpc;
1293 uint32_t rts_cts_rate;
1296 #ifdef CONFIG_CARL9170FW_RADIO_FUNCTIONS
1298 #endif /* CONFIG_CARL9170FW_RADIO_FUNCTIONS */
1300 #ifdef CONFIG_CARL9170FW_NOISY_MAC_RESET
1302 #endif /* CONFIG_CARL9170FW_NOISY_MAC_RESET */
1304 /* Save aggregation parameters */
1305 agg_wait_counter = get(AR9170_MAC_REG_AMPDU_FACTOR);
1306 agg_density = get(AR9170_MAC_REG_AMPDU_DENSITY);
1308 bcn_start_addr = get(AR9170_MAC_REG_BCN_ADDR);
1310 cam_mode = get(AR9170_MAC_REG_CAM_MODE);
1311 rctl = get(AR9170_MAC_REG_CAM_ROLL_CALL_TBL_L);
1312 rcth = get(AR9170_MAC_REG_CAM_ROLL_CALL_TBL_H);
1314 ack_power = get(AR9170_MAC_REG_ACK_TPC);
1315 rts_cts_tpc = get(AR9170_MAC_REG_RTS_CTS_TPC);
1316 rts_cts_rate = get(AR9170_MAC_REG_RTS_CTS_RATE);
1318 #ifdef CONFIG_CARL9170FW_RADIO_FUNCTIONS
1319 /* 0x1c8960 write only */
1320 rx_BB = get(AR9170_PHY_REG_SWITCH_CHAIN_0);
1321 #endif /* CONFIG_CARL9170FW_RADIO_FUNCTIONS */
1323 /* TX/RX must be stopped by now */
1324 val = get(AR9170_MAC_REG_POWER_STATE_CTRL);
1326 val |= AR9170_MAC_POWER_STATE_CTRL_RESET;
1329 * Manipulate CCA threshold to stop transmission
1331 * set(AR9170_PHY_REG_CCA_THRESHOLD, 0x300);
1335 * check Rx state in 0(idle) 9(disable)
1337 * chState = (get(AR9170_MAC_REG_MISC_684) >> 16) & 0xf;
1338 * while( (chState != 0) && (chState != 9)) {
1339 * chState = (get(AR9170_MAC_REG_MISC_684) >> 16) & 0xf;
1343 set(AR9170_MAC_REG_POWER_STATE_CTRL, val);
1347 /* Restore aggregation parameters */
1348 set(AR9170_MAC_REG_AMPDU_FACTOR, agg_wait_counter);
1349 set(AR9170_MAC_REG_AMPDU_DENSITY, agg_density);
1351 set(AR9170_MAC_REG_BCN_ADDR, bcn_start_addr);
1352 set(AR9170_MAC_REG_CAM_MODE, cam_mode);
1353 set(AR9170_MAC_REG_CAM_ROLL_CALL_TBL_L, rctl);
1354 set(AR9170_MAC_REG_CAM_ROLL_CALL_TBL_H, rcth);
1356 set(AR9170_MAC_REG_RTS_CTS_TPC, rts_cts_tpc);
1357 set(AR9170_MAC_REG_ACK_TPC, ack_power);
1358 set(AR9170_MAC_REG_RTS_CTS_RATE, rts_cts_rate);
1360 #ifdef CONFIG_CARL9170FW_RADIO_FUNCTIONS
1361 set(AR9170_PHY_REG_SWITCH_CHAIN_2, rx_BB);
1362 #endif /* CONFIG_CARL9170FW_RADIO_FUNCTIONS */
1365 * Manipulate CCA threshold to resume transmission
1367 * set(AR9170_PHY_REG_CCA_THRESHOLD, 0x0);
1370 val = AR9170_DMA_TRIGGER_RXQ;
1371 /* Reinitialize all WLAN TX DMA queues. */
1372 for (i = AR9170_TXQ_SPECIAL; i >= AR9170_TXQ0; i--) {
1373 struct dma_desc *iter;
1375 __for_each_desc_bits(iter, &fw.wlan.tx_queue[i], AR9170_OWN_BITS_SW);
1377 /* kill the stuck frame */
1378 if (!is_terminator(&fw.wlan.tx_queue[i], iter) &&
1379 fw.wlan.last_super_num[i] >= CARL9170FW_TX_MAC_RESET &&
1380 fw.wlan.last_super[i] == DESC_PAYLOAD(iter)) {
1381 struct carl9170_tx_superframe *super = get_super(iter);
1383 iter->status = AR9170_OWN_BITS_SW;
1385 * Mark the frame as failed.
1386 * The BAFAIL flag allows the frame to sail through
1387 * wlan_tx_status without much "unstuck" trouble.
1389 iter->ctrl &= ~(AR9170_CTRL_FAIL);
1390 iter->ctrl |= AR9170_CTRL_BAFAIL;
1392 super->s.cnt = CARL9170_TX_MAX_RATE_TRIES;
1393 super->s.rix = CARL9170_TX_MAX_RETRY_RATES;
1395 fw.wlan.last_super_num[i] = 0;
1396 fw.wlan.last_super[i] = NULL;
1397 iter = iter->lastAddr->nextAddr;
1400 set_wlan_txq_dma_addr(i, (uint32_t) iter);
1401 if (!is_terminator(&fw.wlan.tx_queue[i], iter))
1404 DBG("Q:%d l:%d h:%p t:%p cu:%p it:%p ct:%x st:%x\n", i, queue_len(&fw.wlan.tx_queue[i]),
1405 fw.wlan.tx_queue[i].head, fw.wlan.tx_queue[i].terminator,
1406 get_wlan_txq_addr(i), iter, iter->ctrl, iter->status);
1409 fw.wlan.soft_int |= AR9170_MAC_INT_RXC | AR9170_MAC_INT_TXC |
1410 AR9170_MAC_INT_RETRY_FAIL;
1412 set(AR9170_MAC_REG_DMA_RXQ_ADDR, (uint32_t) fw.wlan.rx_queue.head);
1416 static void wlan_mac_reset(void)
1418 /* The driver takes care of reinitializing the device */
1421 #endif /* CONFIG_CARL9170FW_FW_MAC_RESET */
1423 void __cold wlan_timer(void)
1425 unsigned int cached_mac_reset;
1427 cached_mac_reset = fw.wlan.mac_reset;
1429 /* TX Queue Hang check */
1432 /* RX Overrun check */
1433 wlan_check_rx_overrun();
1435 if (unlikely(fw.wlan.mac_reset >= CARL9170_MAC_RESET_RESET)) {
1437 fw.wlan.mac_reset = CARL9170_MAC_RESET_OFF;
1439 if (fw.wlan.mac_reset && cached_mac_reset == fw.wlan.mac_reset)
1440 fw.wlan.mac_reset--;