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);
337 if (unlikely(super->s.ampdu_commit_density)) {
338 set(AR9170_MAC_REG_AMPDU_DENSITY,
339 MOD_VAL(AR9170_MAC_AMPDU_DENSITY,
340 get(AR9170_MAC_REG_AMPDU_DENSITY),
341 super->s.ampdu_density));
344 if (unlikely(super->s.ampdu_commit_factor)) {
345 set(AR9170_MAC_REG_AMPDU_FACTOR,
346 MOD_VAL(AR9170_MAC_AMPDU_FACTOR,
347 get(AR9170_MAC_REG_AMPDU_FACTOR),
348 8 << super->s.ampdu_factor));
354 /* propagate transmission status back to the driver */
355 static bool wlan_tx_status(struct dma_queue *queue,
356 struct dma_desc *desc)
358 struct carl9170_tx_superframe *super = get_super(desc);
359 unsigned int qidx = super->s.queue;
360 bool txfail = false, success;
364 /* update hangcheck */
365 fw.wlan.last_super_num[qidx] = 0;
367 if (!!(desc->ctrl & AR9170_CTRL_FAIL)) {
368 txfail = !!(desc->ctrl & AR9170_CTRL_TXFAIL);
370 /* reset retry indicator flags */
371 desc->ctrl &= ~(AR9170_CTRL_TXFAIL | AR9170_CTRL_BAFAIL);
373 if (wlan_tx_consume_retry(super)) {
375 * retry for simple and aggregated 802.11 frames.
377 * Note: We must not mess up the original frame
381 if (!super->f.hdr.mac.ampdu) {
383 * 802.11 - 7.1.3.1.5.
384 * set "Retry Field" for consecutive attempts
386 * Note: For AMPDU see:
387 * 802.11n 9.9.1.6 "Retransmit Procedures"
389 super->f.data.i3e.frame_control |=
390 cpu_to_le16(IEEE80211_FCTL_RETRY);
394 /* Normal TX Failure */
396 /* demise descriptor ownership back to the hardware */
400 * And this will get the queue going again.
401 * To understand why: you have to get the HW
402 * specs... But sadly I never saw them.
404 wlan_txunstuck(qidx);
406 /* abort cycle - this is necessary due to HW design */
409 /* (HT-) BlockACK failure */
412 * Unlink the failed attempt and put it into
413 * the retry queue. The caller routine must
414 * be aware of this so the frames don't get lost.
417 dma_unlink_head(queue);
418 dma_put(&fw.wlan.tx_retry, desc);
422 /* out of frame attempts - discard frame */
427 dma_unlink_head(queue);
430 * Issue the queue bump,
431 * We need to do this in case this was the frame's last
432 * possible retry attempt and it unfortunately: it failed.
435 wlan_txunstuck(qidx);
440 if (unlikely(super == fw.wlan.fw_desc_data)) {
441 fw.wlan.fw_desc = desc;
442 fw.wlan.fw_desc_available = 1;
444 if (fw.wlan.fw_desc_callback)
445 fw.wlan.fw_desc_callback(super, success);
450 #ifdef CONFIG_CARL9170FW_CAB_QUEUE
451 if (unlikely(super->s.cab))
452 fw.wlan.cab_queue_len[super->s.vif_id]--;
453 #endif /* CONFIG_CARL9170FW_CAB_QUEUE */
455 wlan_tx_complete(super, success);
457 /* recycle freed descriptors */
458 dma_reclaim(&fw.pta.down_queue, desc);
463 static void handle_tx_completion(void)
465 struct dma_desc *desc;
468 for (i = AR9170_TXQ_SPECIAL; i >= AR9170_TXQ0; i--) {
469 __while_desc_bits(desc, &fw.wlan.tx_queue[i], AR9170_OWN_BITS_SW) {
470 if (!wlan_tx_status(&fw.wlan.tx_queue[i], desc)) {
471 /* termination requested. */
476 for_each_desc(desc, &fw.wlan.tx_retry)
479 wlan_tx_ampdu_end(i);
480 if (!queue_empty(&fw.wlan.tx_queue[i]))
481 wlan_trigger(BIT(i));
485 void __hot wlan_tx(struct dma_desc *desc)
487 struct carl9170_tx_superframe *super = DESC_PAYLOAD(desc);
489 /* initialize rate control struct */
494 #ifdef CONFIG_CARL9170FW_CAB_QUEUE
495 if (unlikely(super->s.cab)) {
496 fw.wlan.cab_queue_len[super->s.vif_id]++;
497 dma_put(&fw.wlan.cab_queue[super->s.vif_id], desc);
500 #endif /* CONFIG_CARL9170FW_CAB_QUEUE */
503 wlan_trigger(BIT(super->s.queue));
506 static void wlan_tx_fw(struct carl9170_tx_superdesc *super, fw_desc_callback_t cb)
508 if (!fw.wlan.fw_desc_available)
511 fw.wlan.fw_desc_available = 0;
513 /* Format BlockAck */
514 fw.wlan.fw_desc->ctrl = AR9170_CTRL_FS_BIT | AR9170_CTRL_LS_BIT;
515 fw.wlan.fw_desc->status = AR9170_OWN_BITS_SW;
517 fw.wlan.fw_desc->totalLen = fw.wlan.fw_desc->dataSize = super->len;
518 fw.wlan.fw_desc_data = fw.wlan.fw_desc->dataAddr = super;
519 fw.wlan.fw_desc->nextAddr = fw.wlan.fw_desc->lastAddr =
521 fw.wlan.fw_desc_callback = cb;
522 wlan_tx(fw.wlan.fw_desc);
525 static void wlan_send_buffered_ba(void)
527 struct carl9170_tx_ba_superframe *baf = &dma_mem.reserved.ba.ba;
528 struct ieee80211_ba *ba = (struct ieee80211_ba *) &baf->f.ba;
529 struct carl9170_bar_ctx *ctx;
531 if (likely(fw.wlan.ba_head_idx == fw.wlan.ba_tail_idx))
534 /* there's no point to continue when the ba_desc is not available. */
535 if (!fw.wlan.fw_desc_available)
538 ctx = &fw.wlan.ba_cache[fw.wlan.ba_head_idx];
539 fw.wlan.ba_head_idx++;
540 fw.wlan.ba_head_idx %= CONFIG_CARL9170FW_BACK_REQS_NUM;
542 baf->s.len = sizeof(struct carl9170_tx_superdesc) +
543 sizeof(struct ar9170_tx_hwdesc) +
544 sizeof(struct ieee80211_ba);
545 baf->s.ri[0].tries = 1;
547 baf->s.queue = AR9170_TXQ_VO;
548 baf->f.hdr.length = sizeof(struct ieee80211_ba) + FCS_LEN;
550 /* HW Duration / Backoff */
551 baf->f.hdr.mac.backoff = 1;
552 baf->f.hdr.mac.hw_duration = 1;
554 /* take the TX rate from the RX'd BAR */
555 baf->f.hdr.phy.set = ctx->phy;
556 baf->f.hdr.phy.tx_power = 29; /* 14.5 dBm */
558 /* format outgoing BA */
559 ba->frame_control = cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_NULLFUNC);
560 ba->duration = cpu_to_le16(0);
561 memcpy(ba->ta, ctx->ta, 6);
562 memcpy(ba->ra, ctx->ra, 6);
565 * Unfortunately, we cannot look into the hardware's scoreboard.
566 * Therefore we have to proceed as described in 802.11n 9.10.7.5
567 * and send a null BlockAck.
569 memset(ba->bitmap, 0x0, sizeof(ba->bitmap));
573 * not entirely sure if this is 100% correct?!
575 ba->control = ctx->control | cpu_to_le16(1);
576 ba->start_seq_num = ctx->start_seq_num;
577 wlan_tx_fw(&baf->s, NULL);
580 static struct carl9170_bar_ctx *wlan_get_bar_cache_buffer(void)
582 struct carl9170_bar_ctx *tmp;
584 tmp = &fw.wlan.ba_cache[fw.wlan.ba_tail_idx];
585 fw.wlan.ba_tail_idx++;
586 fw.wlan.ba_tail_idx %= CONFIG_CARL9170FW_BACK_REQS_NUM;
591 static void handle_bar(struct dma_desc *desc, struct ieee80211_hdr *hdr,
592 unsigned int len, unsigned int mac_err)
594 struct ieee80211_bar *bar;
595 struct carl9170_bar_ctx *ctx;
597 if (unlikely(mac_err)) {
599 * This check does a number of things:
600 * 1. checks if the frame is in good nick
601 * 2. checks if the RA (MAC) matches
606 if (unlikely(len < (sizeof(struct ieee80211_bar) + FCS_LEN))) {
608 * Sneaky, corrupted BARs... but not with us!
616 if ((bar->control & cpu_to_le16(IEEE80211_BAR_CTRL_MULTI_TID)) ||
617 !(bar->control & cpu_to_le16(IEEE80211_BAR_CTRL_CBMTID_COMPRESSED_BA))) {
618 /* not implemented yet */
623 ctx = wlan_get_bar_cache_buffer();
625 /* Brilliant! The BAR provides all necessary MACs! */
626 memcpy(ctx->ra, bar->ta, 6);
627 memcpy(ctx->ta, bar->ra, 6);
631 * not entirely sure if this is 100% correct to force the
632 * imm ack bit or not...
634 ctx->control = bar->control | cpu_to_le16(1);
635 ctx->start_seq_num = bar->start_seq_num;
636 ctx->phy = ar9170_rx_to_phy(desc);
637 if (unlikely(!ctx->phy)) {
638 /* provide a backup, in case ar9170_rx_to_phy fails */
639 ctx->phy = cpu_to_le32(0x2cc301);
643 static void wlan_check_rx_overrun(void)
645 uint32_t overruns, total;
647 fw.tally.rx_total += total = get(AR9170_MAC_REG_RX_TOTAL);
648 fw.tally.rx_overrun += overruns = get(AR9170_MAC_REG_RX_OVERRUN);
649 if (unlikely(overruns)) {
650 if (overruns == total) {
655 wlan_trigger(AR9170_DMA_TRIGGER_RXQ);
659 #ifdef CONFIG_CARL9170FW_WOL
660 void wlan_prepare_wol(void)
663 memcpy((void *)AR9170_MAC_REG_MAC_ADDR_L, fw.wlan.wol.cmd.mac, 6);
664 memcpy((void *)AR9170_MAC_REG_BSSID_L, fw.wlan.wol.cmd.bssid, 6);
665 set(AR9170_MAC_REG_RX_CONTROL, AR9170_MAC_RX_CTRL_DEAGG);
667 /* set filter policy to: discard everything */
668 fw.wlan.rx_filter = CARL9170_RX_FILTER_EVERYTHING;
670 /* reenable rx dma */
671 wlan_trigger(AR9170_DMA_TRIGGER_RXQ);
673 /* initialize the last_beacon timer */
674 fw.wlan.wol.last_null = fw.wlan.wol.last_beacon = get_clock_counter();
677 #ifdef CONFIG_CARL9170FW_WOL_NL80211_TRIGGERS
678 static bool wlan_rx_wol_magic_packet(struct ieee80211_hdr *hdr, unsigned int len)
680 const unsigned char *data, *end, *mac;
681 unsigned int found = 0;
685 * We can only scan the first AR9170_BLOCK_SIZE [=~320] bytes
686 * for MAGIC patterns!
689 mac = (const unsigned char *) AR9170_MAC_REG_MAC_ADDR_L;
691 data = (u8 *)((unsigned long)hdr + ieee80211_hdrlen(hdr->frame_control));
692 end = (u8 *)((unsigned long)hdr + len);
695 * scan for standard WOL Magic frame
697 * "A physical WakeOnLAN (Magic Packet) will look like this:
698 * ---------------------------------------------------------------
699 * | Synchronization Stream | Target MAC | Password (optional) |
700 * | 6 octets | 96 octets | 0, 4 or 6 |
701 * ---------------------------------------------------------------
703 * The Synchronization Stream is defined as 6 bytes of FFh.
704 * The Target MAC block contains 16 duplications of the IEEEaddress
705 * of the target, with no breaks or interruptions.
707 * The Password field is optional, but if present, contains either
708 * 4 bytes or 6 bytes. The WakeOnLAN dissector was implemented to
709 * dissect the password, if present, according to the command-line
710 * format that ether-wake uses, therefore, if a 4-byte password is
711 * present, it will be dissected as an IPv4 address and if a 6-byte
712 * password is present, it will be dissected as an Ethernet address.
714 * <http://wiki.wireshark.org/WakeOnLAN>
719 if (*data == mac[found % 6])
725 /* previous check might reset found counter */
733 if (found == (6 + 16 * 6)) {
743 static void wlan_wol_connect_callback(void __unused *dummy, bool success)
746 fw.wlan.wol.lost_null = 0;
748 fw.wlan.wol.lost_null++;
751 static void wlan_wol_connection_monitor(void)
753 struct carl9170_tx_null_superframe *nullf = &dma_mem.reserved.cmd.null;
754 struct ieee80211_hdr *null = (struct ieee80211_hdr *) &nullf->f.null;
756 if (!fw.wlan.fw_desc_available)
759 memset(nullf, 0, sizeof(*nullf));
761 nullf->s.len = sizeof(struct carl9170_tx_superdesc) +
762 sizeof(struct ar9170_tx_hwdesc) +
763 sizeof(struct ieee80211_hdr);
764 nullf->s.ri[0].tries = 3;
765 nullf->s.assign_seq = true;
766 nullf->s.queue = AR9170_TXQ_VO;
767 nullf->f.hdr.length = sizeof(struct ieee80211_hdr) + FCS_LEN;
769 nullf->f.hdr.mac.backoff = 1;
770 nullf->f.hdr.mac.hw_duration = 1;
771 nullf->f.hdr.mac.erp_prot = AR9170_TX_MAC_PROT_RTS;
773 nullf->f.hdr.phy.modulation = AR9170_TX_PHY_MOD_OFDM;
774 nullf->f.hdr.phy.bandwidth = AR9170_TX_PHY_BW_20MHZ;
775 nullf->f.hdr.phy.chains = AR9170_TX_PHY_TXCHAIN_2;
776 nullf->f.hdr.phy.tx_power = 29; /* 14.5 dBm */
777 nullf->f.hdr.phy.mcs = AR9170_TXRX_PHY_RATE_OFDM_6M;
779 /* format outgoing nullfunc */
780 null->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA |
781 IEEE80211_STYPE_NULLFUNC | IEEE80211_FCTL_TODS);
783 memcpy(null->addr1, fw.wlan.wol.cmd.bssid, 6);
784 memcpy(null->addr2, fw.wlan.wol.cmd.mac, 6);
785 memcpy(null->addr3, fw.wlan.wol.cmd.bssid, 6);
787 wlan_tx_fw(&nullf->s, wlan_wol_connect_callback);
790 static bool wlan_rx_wol_disconnect(const unsigned int rx_filter,
791 struct ieee80211_hdr *hdr,
792 unsigned int __unused len)
794 const unsigned char *bssid;
795 bssid = (const unsigned char *) AR9170_MAC_REG_BSSID_L;
797 /* should catch both broadcast and unicast MLMEs */
798 if (!(rx_filter & CARL9170_RX_FILTER_OTHER_RA)) {
799 if (ieee80211_is_deauth(hdr->frame_control) ||
800 ieee80211_is_disassoc(hdr->frame_control))
804 if (ieee80211_is_beacon(hdr->frame_control) &&
805 compare_ether_address(hdr->addr3, bssid)) {
806 fw.wlan.wol.last_beacon = get_clock_counter();
812 #endif /* CARL9170FW_WOL_NL80211_TRIGGERS */
814 #ifdef CONFIG_CARL9170FW_WOL_PROBE_REQUEST
817 * Note: CONFIG_CARL9170FW_WOL_PROBE_REQUEST_SSID is not a real
818 * string. We have to be careful not to add a \0 at the end.
820 static const struct {
823 u8 ssid[sizeof(CONFIG_CARL9170FW_WOL_PROBE_REQUEST_SSID) - 1];
824 } __packed probe_req = {
825 .ssid_ie = WLAN_EID_SSID,
826 .ssid_len = sizeof(CONFIG_CARL9170FW_WOL_PROBE_REQUEST_SSID) - 1,
827 .ssid = CONFIG_CARL9170FW_WOL_PROBE_REQUEST_SSID,
830 static bool wlan_rx_wol_probe_ssid(struct ieee80211_hdr *hdr, unsigned int len)
832 const unsigned char *data, *end, *scan = (void *) &probe_req;
835 * IEEE 802.11-2007 7.3.2.1 specifies that the SSID is no
836 * longer than 32 octets.
838 BUILD_BUG_ON((sizeof(CONFIG_CARL9170FW_WOL_PROBE_REQUEST_SSID) - 1) > 32);
840 if (ieee80211_is_probe_req(hdr->frame_control)) {
842 end = (u8 *)((unsigned long)hdr + len);
845 * The position of the SSID information element inside
846 * a probe request frame is more or less "fixed".
848 data = (u8 *)((struct ieee80211_mgmt *)hdr)->u.probe_req.variable;
849 for (i = 0; i < (unsigned int)(probe_req.ssid_len + 1); i++) {
850 if (scan[i] != data[i])
859 #endif /* CONFIG_CARL9170FW_WOL_PROBE_REQUEST */
861 static void wlan_rx_wol(unsigned int rx_filter __unused, struct ieee80211_hdr *hdr __unused, unsigned int len __unused)
863 #ifdef CONFIG_CARL9170FW_WOL_NL80211_TRIGGERS
864 /* Disconnect is always enabled */
865 if (fw.wlan.wol.cmd.flags & CARL9170_WOL_DISCONNECT &&
866 rx_filter & CARL9170_RX_FILTER_MGMT)
867 fw.wlan.wol.wake_up |= wlan_rx_wol_disconnect(rx_filter, hdr, len);
869 if (fw.wlan.wol.cmd.flags & CARL9170_WOL_MAGIC_PKT &&
870 rx_filter & CARL9170_RX_FILTER_DATA)
871 fw.wlan.wol.wake_up |= wlan_rx_wol_magic_packet(hdr, len);
872 #endif /* CONFIG_CARL9170FW_WOL_NL80211_TRIGGERS */
874 #ifdef CONFIG_CARL9170FW_WOL_PROBE_REQUEST
875 if (rx_filter & CARL9170_RX_FILTER_MGMT)
876 fw.wlan.wol.wake_up |= wlan_rx_wol_probe_ssid(hdr, len);
877 #endif /* CONFIG_CARL9170FW_WOL_PROBE_REQUEST */
880 static void wlan_wol_janitor(void)
882 if (unlikely(fw.suspend_mode == CARL9170_HOST_SUSPENDED)) {
883 if (fw.wlan.wol.cmd.flags & CARL9170_WOL_DISCONNECT) {
885 * connection lost after 10sec without receiving
888 if (is_after_msecs(fw.wlan.wol.last_beacon, 10000))
889 fw.wlan.wol.wake_up |= true;
891 if (fw.wlan.wol.cmd.null_interval &&
892 is_after_msecs(fw.wlan.wol.last_null, fw.wlan.wol.cmd.null_interval))
893 wlan_wol_connection_monitor();
895 if (fw.wlan.wol.lost_null >= 5)
896 fw.wlan.wol.wake_up |= true;
899 if (fw.wlan.wol.wake_up) {
900 fw.suspend_mode = CARL9170_AWAKE_HOST;
901 set(AR9170_USB_REG_WAKE_UP, AR9170_USB_WAKE_UP_WAKE);
905 #endif /* CONFIG_CARL9170FW_WOL */
907 static unsigned int wlan_rx_filter(struct dma_desc *desc)
909 struct ieee80211_hdr *hdr;
910 unsigned int data_len;
911 unsigned int rx_filter;
912 unsigned int mac_err;
914 data_len = ar9170_get_rx_mpdu_len(desc);
915 mac_err = ar9170_get_rx_macstatus_error(desc);
917 #define AR9170_RX_ERROR_BAD (AR9170_RX_ERROR_FCS | AR9170_RX_ERROR_PLCP)
919 if (unlikely(data_len < (4 + 6 + FCS_LEN) ||
920 desc->totalLen > CONFIG_CARL9170FW_RX_FRAME_LEN) ||
921 mac_err & AR9170_RX_ERROR_BAD) {
923 * This frame is too damaged to do anything
927 return CARL9170_RX_FILTER_BAD;
931 if (mac_err & AR9170_RX_ERROR_WRONG_RA)
932 rx_filter |= CARL9170_RX_FILTER_OTHER_RA;
934 if (mac_err & AR9170_RX_ERROR_DECRYPT)
935 rx_filter |= CARL9170_RX_FILTER_DECRY_FAIL;
937 hdr = ar9170_get_rx_i3e(desc);
938 if (likely(ieee80211_is_data(hdr->frame_control))) {
939 rx_filter |= CARL9170_RX_FILTER_DATA;
940 } else if (ieee80211_is_ctl(hdr->frame_control)) {
941 switch (le16_to_cpu(hdr->frame_control) & IEEE80211_FCTL_STYPE) {
942 case IEEE80211_STYPE_BACK_REQ:
943 handle_bar(desc, hdr, data_len, mac_err);
945 rx_filter |= CARL9170_RX_FILTER_CTL_BACKR;
947 case IEEE80211_STYPE_PSPOLL:
948 rx_filter |= CARL9170_RX_FILTER_CTL_PSPOLL;
951 rx_filter |= CARL9170_RX_FILTER_CTL_OTHER;
955 /* ieee80211_is_mgmt */
956 rx_filter |= CARL9170_RX_FILTER_MGMT;
959 #ifdef CONFIG_CARL9170FW_WOL
960 if (unlikely(fw.suspend_mode == CARL9170_HOST_SUSPENDED)) {
961 wlan_rx_wol(rx_filter, hdr, min(data_len,
962 (unsigned int)AR9170_BLOCK_SIZE));
964 #endif /* CONFIG_CARL9170FW_WOL */
966 #undef AR9170_RX_ERROR_BAD
971 static void handle_rx(void)
973 struct dma_desc *desc;
975 for_each_desc_not_bits(desc, &fw.wlan.rx_queue, AR9170_OWN_BITS_HW) {
976 if (!(wlan_rx_filter(desc) & fw.wlan.rx_filter)) {
977 dma_put(&fw.pta.up_queue, desc);
980 dma_reclaim(&fw.wlan.rx_queue, desc);
981 wlan_trigger(AR9170_DMA_TRIGGER_RXQ);
986 #ifdef CONFIG_CARL9170FW_CAB_QUEUE
987 void wlan_cab_flush_queue(const unsigned int vif)
989 struct dma_queue *cab_queue = &fw.wlan.cab_queue[vif];
990 struct dma_desc *desc;
992 /* move queued frames into the main tx queues */
993 for_each_desc(desc, cab_queue) {
994 struct carl9170_tx_superframe *super = get_super(desc);
995 if (!queue_empty(cab_queue)) {
997 * Set MOREDATA flag for all,
998 * but the last queued frame.
999 * see: 802.11-2007 11.2.1.5 f)
1001 * This is actually the reason to why
1002 * we need to prevent the reentry.
1005 super->f.data.i3e.frame_control |=
1006 cpu_to_le16(IEEE80211_FCTL_MOREDATA);
1008 super->f.data.i3e.frame_control &=
1009 cpu_to_le16(~IEEE80211_FCTL_MOREDATA);
1012 /* ready to roll! */
1014 wlan_trigger(BIT(super->s.queue));
1018 static uint8_t *beacon_find_ie(uint8_t ie, void *addr,
1019 const unsigned int len)
1021 struct ieee80211_mgmt *mgmt = addr;
1024 pos = mgmt->u.beacon.variable;
1025 end = (uint8_t *) ((unsigned long)mgmt + (len - FCS_LEN));
1027 if (pos + 2 + pos[1] > end)
1039 void wlan_modify_beacon(const unsigned int vif,
1040 const unsigned int addr, const unsigned int len)
1043 struct ieee80211_tim_ie *ie;
1045 _ie = beacon_find_ie(WLAN_EID_TIM, (void *)addr, len);
1047 ie = (struct ieee80211_tim_ie *) &_ie[2];
1049 if (!queue_empty(&fw.wlan.cab_queue[vif]) && (ie->dtim_count == 0)) {
1050 /* schedule DTIM transfer */
1051 fw.wlan.cab_flush_trigger[vif] = CARL9170_CAB_TRIGGER_ARMED;
1052 } else if ((fw.wlan.cab_queue_len[vif] == 0) && (fw.wlan.cab_flush_trigger[vif])) {
1053 /* undo all chances to the beacon structure */
1054 ie->bitmap_ctrl &= ~0x1;
1055 fw.wlan.cab_flush_trigger[vif] = CARL9170_CAB_TRIGGER_EMPTY;
1058 /* Triggered by CARL9170_CAB_TRIGGER_ARMED || CARL9170_CAB_TRIGGER_DEFER */
1059 if (fw.wlan.cab_flush_trigger[vif]) {
1060 /* Set the almighty Multicast Traffic Indication Bit. */
1061 ie->bitmap_ctrl |= 0x1;
1066 * Ideally, the sequence number should be assigned by the TX arbiter
1067 * hardware. But AFAIK that's not possible, so we have to go for the
1068 * next best thing and write it into the beacon fifo during the open
1069 * beacon update window.
1072 wlan_assign_seq((struct ieee80211_hdr *)addr, vif);
1075 static void wlan_send_buffered_cab(void)
1079 for (i = 0; i < CARL9170_INTF_NUM; i++) {
1080 if (unlikely(fw.wlan.cab_flush_trigger[i] == CARL9170_CAB_TRIGGER_ARMED)) {
1082 * This is hardcoded into carl9170usb driver.
1084 * The driver must set the PRETBTT event to beacon_interval -
1085 * CARL9170_PRETBTT_KUS (usually 6) Kus.
1087 * But still, we can only do so much about 802.11-2007 9.3.2.1 &
1088 * 11.2.1.6. Let's hope the current solution is adequate enough.
1091 if (is_after_msecs(fw.wlan.cab_flush_time, (CARL9170_TBTT_DELTA))) {
1092 wlan_cab_flush_queue(i);
1095 * This prevents the code from sending new BC/MC frames
1096 * which were queued after the previous buffered traffic
1097 * has been sent out... They will have to wait until the
1098 * next DTIM beacon comes along.
1100 fw.wlan.cab_flush_trigger[i] = CARL9170_CAB_TRIGGER_DEFER;
1106 #endif /* CONFIG_CARL9170FW_CAB_QUEUE */
1108 static void handle_beacon_config(void)
1112 bcn_count = get(AR9170_MAC_REG_BCN_COUNT);
1113 send_cmd_to_host(4, CARL9170_RSP_BEACON_CONFIG, 0x00,
1114 (uint8_t *) &bcn_count);
1117 static void handle_pretbtt(void)
1119 #ifdef CONFIG_CARL9170FW_CAB_QUEUE
1120 fw.wlan.cab_flush_time = get_clock_counter();
1121 #endif /* CONFIG_CARL9170FW_CAB_QUEUE */
1123 #ifdef CONFIG_CARL9170FW_RADIO_FUNCTIONS
1126 send_cmd_to_host(4, CARL9170_RSP_PRETBTT, 0x00,
1127 (uint8_t *) &fw.phy.psm.state);
1128 #endif /* CONFIG_CARL9170FW_RADIO_FUNCTIONS */
1131 static void handle_atim(void)
1133 send_cmd_to_host(0, CARL9170_RSP_ATIM, 0x00, NULL);
1136 #ifdef CONFIG_CARL9170FW_DEBUG
1137 static void handle_qos(void)
1140 * What is the QoS Bit used for?
1141 * Is it only an indicator for TXOP & Burst, or
1142 * should we do something here?
1146 static void handle_radar(void)
1148 send_cmd_to_host(0, CARL9170_RSP_RADAR, 0x00, NULL);
1150 #endif /* CONFIG_CARL9170FW_DEBUG */
1152 static void wlan_janitor(void)
1154 #ifdef CONFIG_CARL9170FW_CAB_QUEUE
1155 wlan_send_buffered_cab();
1156 #endif /* CONFIG_CARL9170FW_CAB_QUEUE */
1158 wlan_send_buffered_tx_status();
1160 wlan_send_buffered_ba();
1162 #ifdef CONFIG_CARL9170FW_WOL
1164 #endif /* CONFIG_CARL9170FW_WOL */
1167 void handle_wlan(void)
1171 intr = get(AR9170_MAC_REG_INT_CTRL);
1173 set(AR9170_MAC_REG_INT_CTRL, intr);
1175 #define HANDLER(intr, flag, func) \
1177 if ((intr & flag) != 0) { \
1182 intr |= fw.wlan.soft_int;
1183 fw.wlan.soft_int = 0;
1185 HANDLER(intr, AR9170_MAC_INT_PRETBTT, handle_pretbtt);
1187 HANDLER(intr, AR9170_MAC_INT_ATIM, handle_atim);
1189 HANDLER(intr, AR9170_MAC_INT_RXC, handle_rx);
1191 HANDLER(intr, (AR9170_MAC_INT_TXC | AR9170_MAC_INT_RETRY_FAIL),
1192 handle_tx_completion);
1194 #ifdef CONFIG_CARL9170FW_DEBUG
1195 HANDLER(intr, AR9170_MAC_INT_QOS, handle_qos);
1197 HANDLER(intr, AR9170_MAC_INT_RADAR, handle_radar);
1198 #endif /* CONFIG_CARL9170FW_DEBUG */
1200 HANDLER(intr, AR9170_MAC_INT_CFG_BCN, handle_beacon_config);
1203 DBG("Unhandled Interrupt %x\n", (unsigned int) intr);
1211 CARL9170FW_TX_MAC_BUMP = 4,
1212 CARL9170FW_TX_MAC_DEBUG = 6,
1213 CARL9170FW_TX_MAC_RESET = 7,
1216 static void wlan_check_hang(void)
1218 struct dma_desc *desc;
1221 for (i = AR9170_TXQ_SPECIAL; i >= AR9170_TXQ0; i--) {
1222 if (queue_empty(&fw.wlan.tx_queue[i])) {
1223 /* Nothing to do here... move along */
1227 /* fetch the current DMA queue position */
1228 desc = (struct dma_desc *)get_wlan_txq_addr(i);
1230 /* Stuck frame detection */
1231 if (unlikely(DESC_PAYLOAD(desc) == fw.wlan.last_super[i])) {
1232 fw.wlan.last_super_num[i]++;
1234 if (unlikely(fw.wlan.last_super_num[i] >= CARL9170FW_TX_MAC_RESET)) {
1236 * schedule MAC reset (aka OFF/ON => dead)
1238 * This will almost certainly kill
1239 * the device for good, but it's the
1240 * recommended thing to do...
1243 fw.wlan.mac_reset++;
1246 #ifdef CONFIG_CARL9170FW_DEBUG
1247 if (unlikely(fw.wlan.last_super_num[i] >= CARL9170FW_TX_MAC_DEBUG)) {
1249 * Sigh, the queue is almost certainly
1250 * dead. Dump the queue content to the
1251 * user, maybe we find out why it got
1257 #endif /* CONFIG_CARL9170FW_DEBUG */
1259 #ifdef CONFIG_CARL9170FW_DMA_QUEUE_BUMP
1260 if (unlikely(fw.wlan.last_super_num[i] >= CARL9170FW_TX_MAC_BUMP)) {
1262 * Hrrm, bump the queue a bit.
1263 * maybe this will get it going again.
1267 wlan_trigger(BIT(i));
1269 #endif /* CONFIG_CARL9170FW_DMA_QUEUE_BUMP */
1272 fw.wlan.last_super[i] = DESC_PAYLOAD(desc);
1273 fw.wlan.last_super_num[i] = 0;
1278 #ifdef CONFIG_CARL9170FW_FW_MAC_RESET
1280 * NB: Resetting the MAC is a two-edged sword.
1281 * On most occasions, it does what it is supposed to do.
1282 * But there is a chance that this will make it
1283 * even worse and the radio dies silently.
1285 static void wlan_mac_reset(void)
1288 uint32_t agg_wait_counter;
1289 uint32_t agg_density;
1290 uint32_t bcn_start_addr;
1291 uint32_t rctl, rcth;
1294 uint32_t rts_cts_tpc;
1295 uint32_t rts_cts_rate;
1298 #ifdef CONFIG_CARL9170FW_RADIO_FUNCTIONS
1300 #endif /* CONFIG_CARL9170FW_RADIO_FUNCTIONS */
1302 #ifdef CONFIG_CARL9170FW_NOISY_MAC_RESET
1304 #endif /* CONFIG_CARL9170FW_NOISY_MAC_RESET */
1306 /* Save aggregation parameters */
1307 agg_wait_counter = get(AR9170_MAC_REG_AMPDU_FACTOR);
1308 agg_density = get(AR9170_MAC_REG_AMPDU_DENSITY);
1310 bcn_start_addr = get(AR9170_MAC_REG_BCN_ADDR);
1312 cam_mode = get(AR9170_MAC_REG_CAM_MODE);
1313 rctl = get(AR9170_MAC_REG_CAM_ROLL_CALL_TBL_L);
1314 rcth = get(AR9170_MAC_REG_CAM_ROLL_CALL_TBL_H);
1316 ack_power = get(AR9170_MAC_REG_ACK_TPC);
1317 rts_cts_tpc = get(AR9170_MAC_REG_RTS_CTS_TPC);
1318 rts_cts_rate = get(AR9170_MAC_REG_RTS_CTS_RATE);
1320 #ifdef CONFIG_CARL9170FW_RADIO_FUNCTIONS
1321 /* 0x1c8960 write only */
1322 rx_BB = get(AR9170_PHY_REG_SWITCH_CHAIN_0);
1323 #endif /* CONFIG_CARL9170FW_RADIO_FUNCTIONS */
1325 /* TX/RX must be stopped by now */
1326 val = get(AR9170_MAC_REG_POWER_STATE_CTRL);
1328 val |= AR9170_MAC_POWER_STATE_CTRL_RESET;
1331 * Manipulate CCA threshold to stop transmission
1333 * set(AR9170_PHY_REG_CCA_THRESHOLD, 0x300);
1337 * check Rx state in 0(idle) 9(disable)
1339 * chState = (get(AR9170_MAC_REG_MISC_684) >> 16) & 0xf;
1340 * while( (chState != 0) && (chState != 9)) {
1341 * chState = (get(AR9170_MAC_REG_MISC_684) >> 16) & 0xf;
1345 set(AR9170_MAC_REG_POWER_STATE_CTRL, val);
1349 /* Restore aggregation parameters */
1350 set(AR9170_MAC_REG_AMPDU_FACTOR, agg_wait_counter);
1351 set(AR9170_MAC_REG_AMPDU_DENSITY, agg_density);
1353 set(AR9170_MAC_REG_BCN_ADDR, bcn_start_addr);
1354 set(AR9170_MAC_REG_CAM_MODE, cam_mode);
1355 set(AR9170_MAC_REG_CAM_ROLL_CALL_TBL_L, rctl);
1356 set(AR9170_MAC_REG_CAM_ROLL_CALL_TBL_H, rcth);
1358 set(AR9170_MAC_REG_RTS_CTS_TPC, rts_cts_tpc);
1359 set(AR9170_MAC_REG_ACK_TPC, ack_power);
1360 set(AR9170_MAC_REG_RTS_CTS_RATE, rts_cts_rate);
1362 #ifdef CONFIG_CARL9170FW_RADIO_FUNCTIONS
1363 set(AR9170_PHY_REG_SWITCH_CHAIN_2, rx_BB);
1364 #endif /* CONFIG_CARL9170FW_RADIO_FUNCTIONS */
1367 * Manipulate CCA threshold to resume transmission
1369 * set(AR9170_PHY_REG_CCA_THRESHOLD, 0x0);
1372 val = AR9170_DMA_TRIGGER_RXQ;
1373 /* Reinitialize all WLAN TX DMA queues. */
1374 for (i = AR9170_TXQ_SPECIAL; i >= AR9170_TXQ0; i--) {
1375 struct dma_desc *iter;
1377 __for_each_desc_bits(iter, &fw.wlan.tx_queue[i], AR9170_OWN_BITS_SW);
1379 /* kill the stuck frame */
1380 if (!is_terminator(&fw.wlan.tx_queue[i], iter) &&
1381 fw.wlan.last_super_num[i] >= CARL9170FW_TX_MAC_RESET &&
1382 fw.wlan.last_super[i] == DESC_PAYLOAD(iter)) {
1383 struct carl9170_tx_superframe *super = get_super(iter);
1385 iter->status = AR9170_OWN_BITS_SW;
1387 * Mark the frame as failed.
1388 * The BAFAIL flag allows the frame to sail through
1389 * wlan_tx_status without much "unstuck" trouble.
1391 iter->ctrl &= ~(AR9170_CTRL_FAIL);
1392 iter->ctrl |= AR9170_CTRL_BAFAIL;
1394 super->s.cnt = CARL9170_TX_MAX_RATE_TRIES;
1395 super->s.rix = CARL9170_TX_MAX_RETRY_RATES;
1397 fw.wlan.last_super_num[i] = 0;
1398 fw.wlan.last_super[i] = NULL;
1399 iter = iter->lastAddr->nextAddr;
1402 set_wlan_txq_dma_addr(i, (uint32_t) iter);
1403 if (!is_terminator(&fw.wlan.tx_queue[i], iter))
1406 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]),
1407 fw.wlan.tx_queue[i].head, fw.wlan.tx_queue[i].terminator,
1408 get_wlan_txq_addr(i), iter, iter->ctrl, iter->status);
1411 fw.wlan.soft_int |= AR9170_MAC_INT_RXC | AR9170_MAC_INT_TXC |
1412 AR9170_MAC_INT_RETRY_FAIL;
1414 set(AR9170_MAC_REG_DMA_RXQ_ADDR, (uint32_t) fw.wlan.rx_queue.head);
1418 static void wlan_mac_reset(void)
1420 /* The driver takes care of reinitializing the device */
1423 #endif /* CONFIG_CARL9170FW_FW_MAC_RESET */
1425 void __cold wlan_timer(void)
1427 unsigned int cached_mac_reset;
1429 cached_mac_reset = fw.wlan.mac_reset;
1431 /* TX Queue Hang check */
1434 /* RX Overrun check */
1435 wlan_check_rx_overrun();
1437 if (unlikely(fw.wlan.mac_reset >= CARL9170_MAC_RESET_RESET)) {
1439 fw.wlan.mac_reset = CARL9170_MAC_RESET_OFF;
1441 if (fw.wlan.mac_reset && cached_mac_reset == fw.wlan.mac_reset)
1442 fw.wlan.mac_reset--;