Lines Matching refs:sc

23 static inline bool ath9k_check_auto_sleep(struct ath_softc *sc)  in ath9k_check_auto_sleep()  argument
25 return sc->ps_enabled && in ath9k_check_auto_sleep()
26 (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_AUTOSLEEP); in ath9k_check_auto_sleep()
37 static void ath_rx_buf_link(struct ath_softc *sc, struct ath_rxbuf *bf, in ath_rx_buf_link() argument
40 struct ath_hw *ah = sc->sc_ah; in ath_rx_buf_link()
63 if (sc->rx.rxlink) in ath_rx_buf_link()
64 *sc->rx.rxlink = bf->bf_daddr; in ath_rx_buf_link()
68 sc->rx.rxlink = &ds->ds_link; in ath_rx_buf_link()
71 static void ath_rx_buf_relink(struct ath_softc *sc, struct ath_rxbuf *bf, in ath_rx_buf_relink() argument
74 if (sc->rx.buf_hold) in ath_rx_buf_relink()
75 ath_rx_buf_link(sc, sc->rx.buf_hold, flush); in ath_rx_buf_relink()
77 sc->rx.buf_hold = bf; in ath_rx_buf_relink()
80 static void ath_setdefantenna(struct ath_softc *sc, u32 antenna) in ath_setdefantenna() argument
83 ath9k_hw_setantenna(sc->sc_ah, antenna); in ath_setdefantenna()
84 sc->rx.defant = antenna; in ath_setdefantenna()
85 sc->rx.rxotherant = 0; in ath_setdefantenna()
88 static void ath_opmode_init(struct ath_softc *sc) in ath_opmode_init() argument
90 struct ath_hw *ah = sc->sc_ah; in ath_opmode_init()
96 rfilt = ath_calcrxfilter(sc); in ath_opmode_init()
110 static bool ath_rx_edma_buf_link(struct ath_softc *sc, in ath_rx_edma_buf_link() argument
113 struct ath_hw *ah = sc->sc_ah; in ath_rx_edma_buf_link()
118 rx_edma = &sc->rx.rx_edma[qtype]; in ath_rx_edma_buf_link()
122 bf = list_first_entry(&sc->rx.rxbuf, struct ath_rxbuf, list); in ath_rx_edma_buf_link()
128 dma_sync_single_for_device(sc->dev, bf->bf_buf_addr, in ath_rx_edma_buf_link()
138 static void ath_rx_addbuffer_edma(struct ath_softc *sc, in ath_rx_addbuffer_edma() argument
141 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_rx_addbuffer_edma()
144 if (list_empty(&sc->rx.rxbuf)) { in ath_rx_addbuffer_edma()
149 list_for_each_entry_safe(bf, tbf, &sc->rx.rxbuf, list) in ath_rx_addbuffer_edma()
150 if (!ath_rx_edma_buf_link(sc, qtype)) in ath_rx_addbuffer_edma()
155 static void ath_rx_remove_buffer(struct ath_softc *sc, in ath_rx_remove_buffer() argument
162 rx_edma = &sc->rx.rx_edma[qtype]; in ath_rx_remove_buffer()
167 list_add_tail(&bf->list, &sc->rx.rxbuf); in ath_rx_remove_buffer()
171 static void ath_rx_edma_cleanup(struct ath_softc *sc) in ath_rx_edma_cleanup() argument
173 struct ath_hw *ah = sc->sc_ah; in ath_rx_edma_cleanup()
177 ath_rx_remove_buffer(sc, ATH9K_RX_QUEUE_LP); in ath_rx_edma_cleanup()
178 ath_rx_remove_buffer(sc, ATH9K_RX_QUEUE_HP); in ath_rx_edma_cleanup()
180 list_for_each_entry(bf, &sc->rx.rxbuf, list) { in ath_rx_edma_cleanup()
182 dma_unmap_single(sc->dev, bf->bf_buf_addr, in ath_rx_edma_cleanup()
198 static int ath_rx_edma_init(struct ath_softc *sc, int nbufs) in ath_rx_edma_init() argument
200 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_rx_edma_init()
201 struct ath_hw *ah = sc->sc_ah; in ath_rx_edma_init()
210 ath_rx_edma_init_queue(&sc->rx.rx_edma[ATH9K_RX_QUEUE_LP], in ath_rx_edma_init()
212 ath_rx_edma_init_queue(&sc->rx.rx_edma[ATH9K_RX_QUEUE_HP], in ath_rx_edma_init()
216 bf = devm_kzalloc(sc->dev, size, GFP_KERNEL); in ath_rx_edma_init()
220 INIT_LIST_HEAD(&sc->rx.rxbuf); in ath_rx_edma_init()
232 bf->bf_buf_addr = dma_map_single(sc->dev, skb->data, in ath_rx_edma_init()
235 if (unlikely(dma_mapping_error(sc->dev, in ath_rx_edma_init()
246 list_add_tail(&bf->list, &sc->rx.rxbuf); in ath_rx_edma_init()
252 ath_rx_edma_cleanup(sc); in ath_rx_edma_init()
256 static void ath_edma_start_recv(struct ath_softc *sc) in ath_edma_start_recv() argument
258 ath9k_hw_rxena(sc->sc_ah); in ath_edma_start_recv()
259 ath_rx_addbuffer_edma(sc, ATH9K_RX_QUEUE_HP); in ath_edma_start_recv()
260 ath_rx_addbuffer_edma(sc, ATH9K_RX_QUEUE_LP); in ath_edma_start_recv()
261 ath_opmode_init(sc); in ath_edma_start_recv()
262 ath9k_hw_startpcureceive(sc->sc_ah, sc->cur_chan->offchannel); in ath_edma_start_recv()
265 static void ath_edma_stop_recv(struct ath_softc *sc) in ath_edma_stop_recv() argument
267 ath_rx_remove_buffer(sc, ATH9K_RX_QUEUE_HP); in ath_edma_stop_recv()
268 ath_rx_remove_buffer(sc, ATH9K_RX_QUEUE_LP); in ath_edma_stop_recv()
271 int ath_rx_init(struct ath_softc *sc, int nbufs) in ath_rx_init() argument
273 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_rx_init()
278 spin_lock_init(&sc->sc_pcu_lock); in ath_rx_init()
281 sc->sc_ah->caps.rx_status_len; in ath_rx_init()
283 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) in ath_rx_init()
284 return ath_rx_edma_init(sc, nbufs); in ath_rx_init()
291 error = ath_descdma_setup(sc, &sc->rx.rxdma, &sc->rx.rxbuf, in ath_rx_init()
300 list_for_each_entry(bf, &sc->rx.rxbuf, list) { in ath_rx_init()
309 bf->bf_buf_addr = dma_map_single(sc->dev, skb->data, in ath_rx_init()
312 if (unlikely(dma_mapping_error(sc->dev, in ath_rx_init()
323 sc->rx.rxlink = NULL; in ath_rx_init()
326 ath_rx_cleanup(sc); in ath_rx_init()
331 void ath_rx_cleanup(struct ath_softc *sc) in ath_rx_cleanup() argument
333 struct ath_hw *ah = sc->sc_ah; in ath_rx_cleanup()
338 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) { in ath_rx_cleanup()
339 ath_rx_edma_cleanup(sc); in ath_rx_cleanup()
343 list_for_each_entry(bf, &sc->rx.rxbuf, list) { in ath_rx_cleanup()
346 dma_unmap_single(sc->dev, bf->bf_buf_addr, in ath_rx_cleanup()
375 u32 ath_calcrxfilter(struct ath_softc *sc) in ath_calcrxfilter() argument
377 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_calcrxfilter()
387 if (sc->hw->conf.radar_enabled) in ath_calcrxfilter()
390 spin_lock_bh(&sc->chan_lock); in ath_calcrxfilter()
392 if (sc->cur_chan->rxfilter & FIF_PROBE_REQ) in ath_calcrxfilter()
400 if (sc->sc_ah->is_monitoring) in ath_calcrxfilter()
403 if ((sc->cur_chan->rxfilter & FIF_CONTROL) || in ath_calcrxfilter()
404 sc->sc_ah->dynack.enabled) in ath_calcrxfilter()
407 if ((sc->sc_ah->opmode == NL80211_IFTYPE_STATION) && in ath_calcrxfilter()
408 (sc->cur_chan->nvifs <= 1) && in ath_calcrxfilter()
409 !(sc->cur_chan->rxfilter & FIF_BCN_PRBRESP_PROMISC)) in ath_calcrxfilter()
414 if ((sc->sc_ah->opmode == NL80211_IFTYPE_AP) || in ath_calcrxfilter()
415 (sc->cur_chan->rxfilter & FIF_PSPOLL)) in ath_calcrxfilter()
418 if (sc->cur_chandef.width != NL80211_CHAN_WIDTH_20_NOHT) in ath_calcrxfilter()
421 if (sc->cur_chan->nvifs > 1 || (sc->cur_chan->rxfilter & FIF_OTHER_BSS)) { in ath_calcrxfilter()
423 if (sc->sc_ah->hw_version.macVersion <= AR_SREV_VERSION_9160) in ath_calcrxfilter()
428 if (AR_SREV_9550(sc->sc_ah) || AR_SREV_9531(sc->sc_ah) || in ath_calcrxfilter()
429 AR_SREV_9561(sc->sc_ah)) in ath_calcrxfilter()
436 spin_unlock_bh(&sc->chan_lock); in ath_calcrxfilter()
442 void ath_startrecv(struct ath_softc *sc) in ath_startrecv() argument
444 struct ath_hw *ah = sc->sc_ah; in ath_startrecv()
448 ath_edma_start_recv(sc); in ath_startrecv()
452 if (list_empty(&sc->rx.rxbuf)) in ath_startrecv()
455 sc->rx.buf_hold = NULL; in ath_startrecv()
456 sc->rx.rxlink = NULL; in ath_startrecv()
457 list_for_each_entry_safe(bf, tbf, &sc->rx.rxbuf, list) { in ath_startrecv()
458 ath_rx_buf_link(sc, bf, false); in ath_startrecv()
462 if (list_empty(&sc->rx.rxbuf)) in ath_startrecv()
465 bf = list_first_entry(&sc->rx.rxbuf, struct ath_rxbuf, list); in ath_startrecv()
470 ath_opmode_init(sc); in ath_startrecv()
471 ath9k_hw_startpcureceive(ah, sc->cur_chan->offchannel); in ath_startrecv()
474 static void ath_flushrecv(struct ath_softc *sc) in ath_flushrecv() argument
476 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) in ath_flushrecv()
477 ath_rx_tasklet(sc, 1, true); in ath_flushrecv()
478 ath_rx_tasklet(sc, 1, false); in ath_flushrecv()
481 bool ath_stoprecv(struct ath_softc *sc) in ath_stoprecv() argument
483 struct ath_hw *ah = sc->sc_ah; in ath_stoprecv()
490 ath_flushrecv(sc); in ath_stoprecv()
492 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) in ath_stoprecv()
493 ath_edma_stop_recv(sc); in ath_stoprecv()
495 sc->rx.rxlink = NULL; in ath_stoprecv()
499 ath_err(ath9k_hw_common(sc->sc_ah), in ath_stoprecv()
539 static void ath_rx_ps_beacon(struct ath_softc *sc, struct sk_buff *skb) in ath_rx_ps_beacon() argument
541 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_rx_ps_beacon()
547 sc->ps_flags &= ~PS_WAIT_FOR_BEACON; in ath_rx_ps_beacon()
549 if (sc->ps_flags & PS_BEACON_SYNC) { in ath_rx_ps_beacon()
550 sc->ps_flags &= ~PS_BEACON_SYNC; in ath_rx_ps_beacon()
556 if (sc->cur_chan == &sc->offchannel.chan) in ath_rx_ps_beacon()
562 !(WARN_ON_ONCE(sc->cur_chan->beacon.beacon_interval == 0))) in ath_rx_ps_beacon()
563 ath9k_set_beacon(sc); in ath_rx_ps_beacon()
565 ath9k_p2p_beacon_sync(sc); in ath_rx_ps_beacon()
578 sc->ps_flags |= PS_WAIT_FOR_CAB | PS_WAIT_FOR_BEACON; in ath_rx_ps_beacon()
582 if (sc->ps_flags & PS_WAIT_FOR_CAB) { in ath_rx_ps_beacon()
588 sc->ps_flags &= ~PS_WAIT_FOR_CAB; in ath_rx_ps_beacon()
593 static void ath_rx_ps(struct ath_softc *sc, struct sk_buff *skb, bool mybeacon) in ath_rx_ps() argument
596 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_rx_ps()
601 if (((sc->ps_flags & PS_WAIT_FOR_BEACON) || ath9k_check_auto_sleep(sc)) in ath_rx_ps()
603 ath_rx_ps_beacon(sc, skb); in ath_rx_ps()
604 } else if ((sc->ps_flags & PS_WAIT_FOR_CAB) && in ath_rx_ps()
613 sc->ps_flags &= ~(PS_WAIT_FOR_CAB | PS_WAIT_FOR_BEACON); in ath_rx_ps()
616 } else if ((sc->ps_flags & PS_WAIT_FOR_PSPOLL_DATA) && in ath_rx_ps()
619 sc->ps_flags &= ~PS_WAIT_FOR_PSPOLL_DATA; in ath_rx_ps()
622 sc->ps_flags & (PS_WAIT_FOR_BEACON | in ath_rx_ps()
629 static bool ath_edma_get_buffers(struct ath_softc *sc, in ath_edma_get_buffers() argument
634 struct ath_rx_edma *rx_edma = &sc->rx.rx_edma[qtype]; in ath_edma_get_buffers()
635 struct ath_hw *ah = sc->sc_ah; in ath_edma_get_buffers()
648 dma_sync_single_for_cpu(sc->dev, bf->bf_buf_addr, in ath_edma_get_buffers()
654 dma_sync_single_for_device(sc->dev, bf->bf_buf_addr, in ath_edma_get_buffers()
662 list_add_tail(&bf->list, &sc->rx.rxbuf); in ath_edma_get_buffers()
663 ath_rx_edma_buf_link(sc, qtype); in ath_edma_get_buffers()
671 list_add_tail(&bf->list, &sc->rx.rxbuf); in ath_edma_get_buffers()
672 ath_rx_edma_buf_link(sc, qtype); in ath_edma_get_buffers()
682 static struct ath_rxbuf *ath_edma_get_next_rx_buf(struct ath_softc *sc, in ath_edma_get_next_rx_buf() argument
688 while (ath_edma_get_buffers(sc, qtype, rs, &bf)) { in ath_edma_get_next_rx_buf()
697 static struct ath_rxbuf *ath_get_next_rx_buf(struct ath_softc *sc, in ath_get_next_rx_buf() argument
700 struct ath_hw *ah = sc->sc_ah; in ath_get_next_rx_buf()
706 if (list_empty(&sc->rx.rxbuf)) { in ath_get_next_rx_buf()
707 sc->rx.rxlink = NULL; in ath_get_next_rx_buf()
711 bf = list_first_entry(&sc->rx.rxbuf, struct ath_rxbuf, list); in ath_get_next_rx_buf()
712 if (bf == sc->rx.buf_hold) in ath_get_next_rx_buf()
735 if (list_is_last(&bf->list, &sc->rx.rxbuf)) { in ath_get_next_rx_buf()
736 sc->rx.rxlink = NULL; in ath_get_next_rx_buf()
782 dma_sync_single_for_cpu(sc->dev, bf->bf_buf_addr, in ath_get_next_rx_buf()
810 static int ath9k_rx_skb_preprocess(struct ath_softc *sc, in ath9k_rx_skb_preprocess() argument
816 struct ieee80211_hw *hw = sc->hw; in ath9k_rx_skb_preprocess()
817 struct ath_hw *ah = sc->sc_ah; in ath9k_rx_skb_preprocess()
820 bool discard_current = sc->rx.discard_next; in ath9k_rx_skb_preprocess()
829 sc->rx.discard_next = false; in ath9k_rx_skb_preprocess()
866 ath_debug_stat_rx(sc, rx_stats); in ath9k_rx_skb_preprocess()
873 ath9k_dfs_process_phyerr(sc, hdr, rx_stats, rx_status->mactime); in ath9k_rx_skb_preprocess()
874 if (ath_cmn_process_fft(&sc->spec_priv, hdr, rx_stats, rx_status->mactime)) in ath9k_rx_skb_preprocess()
884 spin_lock_bh(&sc->chan_lock); in ath9k_rx_skb_preprocess()
886 sc->cur_chan->rxfilter)) { in ath9k_rx_skb_preprocess()
887 spin_unlock_bh(&sc->chan_lock); in ath9k_rx_skb_preprocess()
890 spin_unlock_bh(&sc->chan_lock); in ath9k_rx_skb_preprocess()
916 ath_chanctx_beacon_recv_ev(sc, in ath9k_rx_skb_preprocess()
930 sc->rx.num_pkts++; in ath9k_rx_skb_preprocess()
936 sc->rx.discard_next = rx_stats->rs_more; in ath9k_rx_skb_preprocess()
950 static void ath9k_antenna_check(struct ath_softc *sc, in ath9k_antenna_check() argument
953 struct ath_hw *ah = sc->sc_ah; in ath9k_antenna_check()
964 if (sc->rx.defant != rs->rs_antenna) { in ath9k_antenna_check()
965 if (++sc->rx.rxotherant >= 3) in ath9k_antenna_check()
966 ath_setdefantenna(sc, rs->rs_antenna); in ath9k_antenna_check()
968 sc->rx.rxotherant = 0; in ath9k_antenna_check()
973 ath_ant_comb_scan(sc, rs); in ath9k_antenna_check()
975 ath_ant_comb_scan(sc, rs); in ath9k_antenna_check()
979 static void ath9k_apply_ampdu_details(struct ath_softc *sc, in ath9k_apply_ampdu_details() argument
985 rxs->ampdu_reference = sc->rx.ampdu_ref; in ath9k_apply_ampdu_details()
989 sc->rx.ampdu_ref++; in ath9k_apply_ampdu_details()
997 int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp) in ath_rx_tasklet() argument
1002 struct ath_hw *ah = sc->sc_ah; in ath_rx_tasklet()
1004 struct ieee80211_hw *hw = sc->hw; in ath_rx_tasklet()
1030 bf = ath_edma_get_next_rx_buf(sc, &rs, qtype); in ath_rx_tasklet()
1032 bf = ath_get_next_rx_buf(sc, &rs); in ath_rx_tasklet()
1045 if (sc->rx.frag) in ath_rx_tasklet()
1046 hdr_skb = sc->rx.frag; in ath_rx_tasklet()
1053 retval = ath9k_rx_skb_preprocess(sc, hdr_skb, &rs, rxs, in ath_rx_tasklet()
1072 new_buf_addr = dma_map_single(sc->dev, requeue_skb->data, in ath_rx_tasklet()
1074 if (unlikely(dma_mapping_error(sc->dev, new_buf_addr))) { in ath_rx_tasklet()
1080 dma_unmap_single(sc->dev, bf->bf_buf_addr, in ath_rx_tasklet()
1101 if (sc->rx.frag) { in ath_rx_tasklet()
1103 dev_kfree_skb_any(sc->rx.frag); in ath_rx_tasklet()
1108 sc->rx.frag = skb; in ath_rx_tasklet()
1112 if (sc->rx.frag) { in ath_rx_tasklet()
1121 sc->rx.frag = NULL; in ath_rx_tasklet()
1132 spin_lock_irqsave(&sc->sc_pm_lock, flags); in ath_rx_tasklet()
1133 if ((sc->ps_flags & (PS_WAIT_FOR_BEACON | in ath_rx_tasklet()
1136 ath9k_check_auto_sleep(sc)) in ath_rx_tasklet()
1137 ath_rx_ps(sc, skb, rs.is_mybeacon); in ath_rx_tasklet()
1138 spin_unlock_irqrestore(&sc->sc_pm_lock, flags); in ath_rx_tasklet()
1140 ath9k_antenna_check(sc, &rs); in ath_rx_tasklet()
1141 ath9k_apply_ampdu_details(sc, &rs, rxs); in ath_rx_tasklet()
1142 ath_debug_rate_stats(sc, &rs, skb); in ath_rx_tasklet()
1146 ath_dynack_sample_ack_ts(sc->sc_ah, skb, rs.rs_tstamp); in ath_rx_tasklet()
1151 if (sc->rx.frag) { in ath_rx_tasklet()
1152 dev_kfree_skb_any(sc->rx.frag); in ath_rx_tasklet()
1153 sc->rx.frag = NULL; in ath_rx_tasklet()
1156 list_add_tail(&bf->list, &sc->rx.rxbuf); in ath_rx_tasklet()
1159 ath_rx_buf_relink(sc, bf, flush); in ath_rx_tasklet()
1163 ath_rx_edma_buf_link(sc, qtype); in ath_rx_tasklet()