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()
395 if (sc->sc_ah->is_monitoring) in ath_calcrxfilter()
398 if ((sc->cur_chan->rxfilter & FIF_CONTROL) || in ath_calcrxfilter()
399 sc->sc_ah->dynack.enabled) in ath_calcrxfilter()
402 if ((sc->sc_ah->opmode == NL80211_IFTYPE_STATION) && in ath_calcrxfilter()
403 (sc->cur_chan->nvifs <= 1) && in ath_calcrxfilter()
404 !(sc->cur_chan->rxfilter & FIF_BCN_PRBRESP_PROMISC)) in ath_calcrxfilter()
406 else if (sc->sc_ah->opmode != NL80211_IFTYPE_OCB) in ath_calcrxfilter()
409 if ((sc->sc_ah->opmode == NL80211_IFTYPE_AP) || in ath_calcrxfilter()
410 (sc->cur_chan->rxfilter & FIF_PSPOLL)) in ath_calcrxfilter()
413 if (sc->cur_chandef.width != NL80211_CHAN_WIDTH_20_NOHT) in ath_calcrxfilter()
416 if (sc->cur_chan->nvifs > 1 || (sc->cur_chan->rxfilter & FIF_OTHER_BSS)) { in ath_calcrxfilter()
418 if (sc->sc_ah->hw_version.macVersion <= AR_SREV_VERSION_9160) in ath_calcrxfilter()
423 if (AR_SREV_9550(sc->sc_ah) || AR_SREV_9531(sc->sc_ah) || in ath_calcrxfilter()
424 AR_SREV_9561(sc->sc_ah)) in ath_calcrxfilter()
427 if (AR_SREV_9462(sc->sc_ah) || AR_SREV_9565(sc->sc_ah)) in ath_calcrxfilter()
434 spin_unlock_bh(&sc->chan_lock); in ath_calcrxfilter()
440 void ath_startrecv(struct ath_softc *sc) in ath_startrecv() argument
442 struct ath_hw *ah = sc->sc_ah; in ath_startrecv()
446 ath_edma_start_recv(sc); in ath_startrecv()
450 if (list_empty(&sc->rx.rxbuf)) in ath_startrecv()
453 sc->rx.buf_hold = NULL; in ath_startrecv()
454 sc->rx.rxlink = NULL; in ath_startrecv()
455 list_for_each_entry_safe(bf, tbf, &sc->rx.rxbuf, list) { in ath_startrecv()
456 ath_rx_buf_link(sc, bf, false); in ath_startrecv()
460 if (list_empty(&sc->rx.rxbuf)) in ath_startrecv()
463 bf = list_first_entry(&sc->rx.rxbuf, struct ath_rxbuf, list); in ath_startrecv()
468 ath_opmode_init(sc); in ath_startrecv()
469 ath9k_hw_startpcureceive(ah, sc->cur_chan->offchannel); in ath_startrecv()
472 static void ath_flushrecv(struct ath_softc *sc) in ath_flushrecv() argument
474 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) in ath_flushrecv()
475 ath_rx_tasklet(sc, 1, true); in ath_flushrecv()
476 ath_rx_tasklet(sc, 1, false); in ath_flushrecv()
479 bool ath_stoprecv(struct ath_softc *sc) in ath_stoprecv() argument
481 struct ath_hw *ah = sc->sc_ah; in ath_stoprecv()
488 ath_flushrecv(sc); in ath_stoprecv()
490 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) in ath_stoprecv()
491 ath_edma_stop_recv(sc); in ath_stoprecv()
493 sc->rx.rxlink = NULL; in ath_stoprecv()
497 ath_dbg(ath9k_hw_common(sc->sc_ah), RESET, in ath_stoprecv()
499 RESET_STAT_INC(sc, RESET_RX_DMA_ERROR); in ath_stoprecv()
536 static void ath_rx_ps_beacon(struct ath_softc *sc, struct sk_buff *skb) in ath_rx_ps_beacon() argument
538 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_rx_ps_beacon()
544 sc->ps_flags &= ~PS_WAIT_FOR_BEACON; in ath_rx_ps_beacon()
546 if (sc->ps_flags & PS_BEACON_SYNC) { in ath_rx_ps_beacon()
547 sc->ps_flags &= ~PS_BEACON_SYNC; in ath_rx_ps_beacon()
553 if (sc->cur_chan == &sc->offchannel.chan) in ath_rx_ps_beacon()
559 !(WARN_ON_ONCE(sc->cur_chan->beacon.beacon_interval == 0))) in ath_rx_ps_beacon()
560 ath9k_set_beacon(sc); in ath_rx_ps_beacon()
562 ath9k_p2p_beacon_sync(sc); in ath_rx_ps_beacon()
575 sc->ps_flags |= PS_WAIT_FOR_CAB | PS_WAIT_FOR_BEACON; in ath_rx_ps_beacon()
579 if (sc->ps_flags & PS_WAIT_FOR_CAB) { in ath_rx_ps_beacon()
585 sc->ps_flags &= ~PS_WAIT_FOR_CAB; in ath_rx_ps_beacon()
590 static void ath_rx_ps(struct ath_softc *sc, struct sk_buff *skb, bool mybeacon) in ath_rx_ps() argument
593 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_rx_ps()
598 if (((sc->ps_flags & PS_WAIT_FOR_BEACON) || ath9k_check_auto_sleep(sc)) in ath_rx_ps()
600 ath_rx_ps_beacon(sc, skb); in ath_rx_ps()
601 } else if ((sc->ps_flags & PS_WAIT_FOR_CAB) && in ath_rx_ps()
610 sc->ps_flags &= ~(PS_WAIT_FOR_CAB | PS_WAIT_FOR_BEACON); in ath_rx_ps()
613 } else if ((sc->ps_flags & PS_WAIT_FOR_PSPOLL_DATA) && in ath_rx_ps()
616 sc->ps_flags &= ~PS_WAIT_FOR_PSPOLL_DATA; in ath_rx_ps()
619 sc->ps_flags & (PS_WAIT_FOR_BEACON | in ath_rx_ps()
626 static bool ath_edma_get_buffers(struct ath_softc *sc, in ath_edma_get_buffers() argument
631 struct ath_rx_edma *rx_edma = &sc->rx.rx_edma[qtype]; in ath_edma_get_buffers()
632 struct ath_hw *ah = sc->sc_ah; in ath_edma_get_buffers()
645 dma_sync_single_for_cpu(sc->dev, bf->bf_buf_addr, in ath_edma_get_buffers()
651 dma_sync_single_for_device(sc->dev, bf->bf_buf_addr, in ath_edma_get_buffers()
659 list_add_tail(&bf->list, &sc->rx.rxbuf); in ath_edma_get_buffers()
660 ath_rx_edma_buf_link(sc, qtype); in ath_edma_get_buffers()
668 list_add_tail(&bf->list, &sc->rx.rxbuf); in ath_edma_get_buffers()
669 ath_rx_edma_buf_link(sc, qtype); in ath_edma_get_buffers()
679 static struct ath_rxbuf *ath_edma_get_next_rx_buf(struct ath_softc *sc, in ath_edma_get_next_rx_buf() argument
685 while (ath_edma_get_buffers(sc, qtype, rs, &bf)) { in ath_edma_get_next_rx_buf()
694 static struct ath_rxbuf *ath_get_next_rx_buf(struct ath_softc *sc, in ath_get_next_rx_buf() argument
697 struct ath_hw *ah = sc->sc_ah; in ath_get_next_rx_buf()
703 if (list_empty(&sc->rx.rxbuf)) { in ath_get_next_rx_buf()
704 sc->rx.rxlink = NULL; in ath_get_next_rx_buf()
708 bf = list_first_entry(&sc->rx.rxbuf, struct ath_rxbuf, list); in ath_get_next_rx_buf()
709 if (bf == sc->rx.buf_hold) in ath_get_next_rx_buf()
732 if (list_is_last(&bf->list, &sc->rx.rxbuf)) { in ath_get_next_rx_buf()
733 sc->rx.rxlink = NULL; in ath_get_next_rx_buf()
779 dma_sync_single_for_cpu(sc->dev, bf->bf_buf_addr, in ath_get_next_rx_buf()
807 static int ath9k_rx_skb_preprocess(struct ath_softc *sc, in ath9k_rx_skb_preprocess() argument
813 struct ieee80211_hw *hw = sc->hw; in ath9k_rx_skb_preprocess()
814 struct ath_hw *ah = sc->sc_ah; in ath9k_rx_skb_preprocess()
817 bool discard_current = sc->rx.discard_next; in ath9k_rx_skb_preprocess()
826 sc->rx.discard_next = false; in ath9k_rx_skb_preprocess()
863 ath_debug_stat_rx(sc, rx_stats); in ath9k_rx_skb_preprocess()
878 ath9k_dfs_process_phyerr(sc, hdr, rx_stats, in ath9k_rx_skb_preprocess()
880 } else if (sc->spec_priv.spectral_mode != SPECTRAL_DISABLED && in ath9k_rx_skb_preprocess()
881 ath_cmn_process_fft(&sc->spec_priv, hdr, rx_stats, in ath9k_rx_skb_preprocess()
892 spin_lock_bh(&sc->chan_lock); in ath9k_rx_skb_preprocess()
894 sc->cur_chan->rxfilter)) { in ath9k_rx_skb_preprocess()
895 spin_unlock_bh(&sc->chan_lock); in ath9k_rx_skb_preprocess()
898 spin_unlock_bh(&sc->chan_lock); in ath9k_rx_skb_preprocess()
924 ath_chanctx_beacon_recv_ev(sc, in ath9k_rx_skb_preprocess()
938 sc->rx.num_pkts++; in ath9k_rx_skb_preprocess()
944 sc->rx.discard_next = rx_stats->rs_more; in ath9k_rx_skb_preprocess()
958 static void ath9k_antenna_check(struct ath_softc *sc, in ath9k_antenna_check() argument
961 struct ath_hw *ah = sc->sc_ah; in ath9k_antenna_check()
972 if (sc->rx.defant != rs->rs_antenna) { in ath9k_antenna_check()
973 if (++sc->rx.rxotherant >= 3) in ath9k_antenna_check()
974 ath_setdefantenna(sc, rs->rs_antenna); in ath9k_antenna_check()
976 sc->rx.rxotherant = 0; in ath9k_antenna_check()
981 ath_ant_comb_scan(sc, rs); in ath9k_antenna_check()
983 ath_ant_comb_scan(sc, rs); in ath9k_antenna_check()
987 static void ath9k_apply_ampdu_details(struct ath_softc *sc, in ath9k_apply_ampdu_details() argument
993 rxs->ampdu_reference = sc->rx.ampdu_ref; in ath9k_apply_ampdu_details()
997 sc->rx.ampdu_ref++; in ath9k_apply_ampdu_details()
1005 static void ath_rx_count_airtime(struct ath_softc *sc, in ath_rx_count_airtime() argument
1013 struct ath_hw *ah = sc->sc_ah; in ath_rx_count_airtime()
1029 sta = ieee80211_find_sta_by_ifaddr(sc->hw, hdr->addr2, NULL); in ath_rx_count_airtime()
1047 airtime += ath_pkt_duration(sc, rxs->rate_idx, len, in ath_rx_count_airtime()
1057 if (!!(sc->airtime_flags & AIRTIME_USE_RX)) { in ath_rx_count_airtime()
1061 __ath_tx_queue_tid(sc, ATH_AN_2_TID(an, tidno)); in ath_rx_count_airtime()
1064 ath_debug_airtime(sc, an, airtime, 0); in ath_rx_count_airtime()
1069 int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp) in ath_rx_tasklet() argument
1074 struct ath_hw *ah = sc->sc_ah; in ath_rx_tasklet()
1076 struct ieee80211_hw *hw = sc->hw; in ath_rx_tasklet()
1102 bf = ath_edma_get_next_rx_buf(sc, &rs, qtype); in ath_rx_tasklet()
1104 bf = ath_get_next_rx_buf(sc, &rs); in ath_rx_tasklet()
1117 if (sc->rx.frag) in ath_rx_tasklet()
1118 hdr_skb = sc->rx.frag; in ath_rx_tasklet()
1125 retval = ath9k_rx_skb_preprocess(sc, hdr_skb, &rs, rxs, in ath_rx_tasklet()
1144 new_buf_addr = dma_map_single(sc->dev, requeue_skb->data, in ath_rx_tasklet()
1146 if (unlikely(dma_mapping_error(sc->dev, new_buf_addr))) { in ath_rx_tasklet()
1152 dma_unmap_single(sc->dev, bf->bf_buf_addr, in ath_rx_tasklet()
1173 if (sc->rx.frag) { in ath_rx_tasklet()
1175 dev_kfree_skb_any(sc->rx.frag); in ath_rx_tasklet()
1180 sc->rx.frag = skb; in ath_rx_tasklet()
1184 if (sc->rx.frag) { in ath_rx_tasklet()
1193 sc->rx.frag = NULL; in ath_rx_tasklet()
1204 spin_lock_irqsave(&sc->sc_pm_lock, flags); in ath_rx_tasklet()
1205 if ((sc->ps_flags & (PS_WAIT_FOR_BEACON | in ath_rx_tasklet()
1208 ath9k_check_auto_sleep(sc)) in ath_rx_tasklet()
1209 ath_rx_ps(sc, skb, rs.is_mybeacon); in ath_rx_tasklet()
1210 spin_unlock_irqrestore(&sc->sc_pm_lock, flags); in ath_rx_tasklet()
1212 ath9k_antenna_check(sc, &rs); in ath_rx_tasklet()
1213 ath9k_apply_ampdu_details(sc, &rs, rxs); in ath_rx_tasklet()
1214 ath_debug_rate_stats(sc, &rs, skb); in ath_rx_tasklet()
1215 ath_rx_count_airtime(sc, &rs, skb); in ath_rx_tasklet()
1219 ath_dynack_sample_ack_ts(sc->sc_ah, skb, rs.rs_tstamp); in ath_rx_tasklet()
1224 if (sc->rx.frag) { in ath_rx_tasklet()
1225 dev_kfree_skb_any(sc->rx.frag); in ath_rx_tasklet()
1226 sc->rx.frag = NULL; in ath_rx_tasklet()
1229 list_add_tail(&bf->list, &sc->rx.rxbuf); in ath_rx_tasklet()
1232 ath_rx_buf_relink(sc, bf, flush); in ath_rx_tasklet()
1236 ath_rx_edma_buf_link(sc, qtype); in ath_rx_tasklet()