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 || in ath_calcrxfilter()
417 (sc->cur_chan->rxfilter & (FIF_OTHER_BSS | FIF_MCAST_ACTION))) { in ath_calcrxfilter()
419 if (sc->sc_ah->hw_version.macVersion <= AR_SREV_VERSION_9160) in ath_calcrxfilter()
424 if (AR_SREV_9550(sc->sc_ah) || AR_SREV_9531(sc->sc_ah) || in ath_calcrxfilter()
425 AR_SREV_9561(sc->sc_ah)) in ath_calcrxfilter()
428 if (AR_SREV_9462(sc->sc_ah) || AR_SREV_9565(sc->sc_ah)) in ath_calcrxfilter()
435 spin_unlock_bh(&sc->chan_lock); in ath_calcrxfilter()
441 void ath_startrecv(struct ath_softc *sc) in ath_startrecv() argument
443 struct ath_hw *ah = sc->sc_ah; in ath_startrecv()
447 ath_edma_start_recv(sc); in ath_startrecv()
451 if (list_empty(&sc->rx.rxbuf)) in ath_startrecv()
454 sc->rx.buf_hold = NULL; in ath_startrecv()
455 sc->rx.rxlink = NULL; in ath_startrecv()
456 list_for_each_entry_safe(bf, tbf, &sc->rx.rxbuf, list) { in ath_startrecv()
457 ath_rx_buf_link(sc, bf, false); in ath_startrecv()
461 if (list_empty(&sc->rx.rxbuf)) in ath_startrecv()
464 bf = list_first_entry(&sc->rx.rxbuf, struct ath_rxbuf, list); in ath_startrecv()
469 ath_opmode_init(sc); in ath_startrecv()
470 ath9k_hw_startpcureceive(ah, sc->cur_chan->offchannel); in ath_startrecv()
473 static void ath_flushrecv(struct ath_softc *sc) in ath_flushrecv() argument
475 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) in ath_flushrecv()
476 ath_rx_tasklet(sc, 1, true); in ath_flushrecv()
477 ath_rx_tasklet(sc, 1, false); in ath_flushrecv()
480 bool ath_stoprecv(struct ath_softc *sc) in ath_stoprecv() argument
482 struct ath_hw *ah = sc->sc_ah; in ath_stoprecv()
489 ath_flushrecv(sc); in ath_stoprecv()
491 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) in ath_stoprecv()
492 ath_edma_stop_recv(sc); in ath_stoprecv()
494 sc->rx.rxlink = NULL; in ath_stoprecv()
498 ath_dbg(ath9k_hw_common(sc->sc_ah), RESET, in ath_stoprecv()
500 RESET_STAT_INC(sc, RESET_RX_DMA_ERROR); in ath_stoprecv()
537 static void ath_rx_ps_beacon(struct ath_softc *sc, struct sk_buff *skb) in ath_rx_ps_beacon() argument
539 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_rx_ps_beacon()
545 sc->ps_flags &= ~PS_WAIT_FOR_BEACON; in ath_rx_ps_beacon()
547 if (sc->ps_flags & PS_BEACON_SYNC) { in ath_rx_ps_beacon()
548 sc->ps_flags &= ~PS_BEACON_SYNC; in ath_rx_ps_beacon()
554 if (sc->cur_chan == &sc->offchannel.chan) in ath_rx_ps_beacon()
560 !(WARN_ON_ONCE(sc->cur_chan->beacon.beacon_interval == 0))) in ath_rx_ps_beacon()
561 ath9k_set_beacon(sc); in ath_rx_ps_beacon()
563 ath9k_p2p_beacon_sync(sc); in ath_rx_ps_beacon()
576 sc->ps_flags |= PS_WAIT_FOR_CAB | PS_WAIT_FOR_BEACON; in ath_rx_ps_beacon()
580 if (sc->ps_flags & PS_WAIT_FOR_CAB) { in ath_rx_ps_beacon()
586 sc->ps_flags &= ~PS_WAIT_FOR_CAB; in ath_rx_ps_beacon()
591 static void ath_rx_ps(struct ath_softc *sc, struct sk_buff *skb, bool mybeacon) in ath_rx_ps() argument
594 struct ath_common *common = ath9k_hw_common(sc->sc_ah); in ath_rx_ps()
599 if (((sc->ps_flags & PS_WAIT_FOR_BEACON) || ath9k_check_auto_sleep(sc)) in ath_rx_ps()
601 ath_rx_ps_beacon(sc, skb); in ath_rx_ps()
602 } else if ((sc->ps_flags & PS_WAIT_FOR_CAB) && in ath_rx_ps()
611 sc->ps_flags &= ~(PS_WAIT_FOR_CAB | PS_WAIT_FOR_BEACON); in ath_rx_ps()
614 } else if ((sc->ps_flags & PS_WAIT_FOR_PSPOLL_DATA) && in ath_rx_ps()
617 sc->ps_flags &= ~PS_WAIT_FOR_PSPOLL_DATA; in ath_rx_ps()
620 sc->ps_flags & (PS_WAIT_FOR_BEACON | in ath_rx_ps()
627 static bool ath_edma_get_buffers(struct ath_softc *sc, in ath_edma_get_buffers() argument
632 struct ath_rx_edma *rx_edma = &sc->rx.rx_edma[qtype]; in ath_edma_get_buffers()
633 struct ath_hw *ah = sc->sc_ah; in ath_edma_get_buffers()
646 dma_sync_single_for_cpu(sc->dev, bf->bf_buf_addr, in ath_edma_get_buffers()
652 dma_sync_single_for_device(sc->dev, bf->bf_buf_addr, in ath_edma_get_buffers()
660 list_add_tail(&bf->list, &sc->rx.rxbuf); in ath_edma_get_buffers()
661 ath_rx_edma_buf_link(sc, qtype); in ath_edma_get_buffers()
669 list_add_tail(&bf->list, &sc->rx.rxbuf); in ath_edma_get_buffers()
670 ath_rx_edma_buf_link(sc, qtype); in ath_edma_get_buffers()
680 static struct ath_rxbuf *ath_edma_get_next_rx_buf(struct ath_softc *sc, in ath_edma_get_next_rx_buf() argument
686 while (ath_edma_get_buffers(sc, qtype, rs, &bf)) { in ath_edma_get_next_rx_buf()
695 static struct ath_rxbuf *ath_get_next_rx_buf(struct ath_softc *sc, in ath_get_next_rx_buf() argument
698 struct ath_hw *ah = sc->sc_ah; in ath_get_next_rx_buf()
704 if (list_empty(&sc->rx.rxbuf)) { in ath_get_next_rx_buf()
705 sc->rx.rxlink = NULL; in ath_get_next_rx_buf()
709 bf = list_first_entry(&sc->rx.rxbuf, struct ath_rxbuf, list); in ath_get_next_rx_buf()
710 if (bf == sc->rx.buf_hold) in ath_get_next_rx_buf()
733 if (list_is_last(&bf->list, &sc->rx.rxbuf)) { in ath_get_next_rx_buf()
734 sc->rx.rxlink = NULL; in ath_get_next_rx_buf()
780 dma_sync_single_for_cpu(sc->dev, bf->bf_buf_addr, in ath_get_next_rx_buf()
808 static int ath9k_rx_skb_preprocess(struct ath_softc *sc, in ath9k_rx_skb_preprocess() argument
814 struct ieee80211_hw *hw = sc->hw; in ath9k_rx_skb_preprocess()
815 struct ath_hw *ah = sc->sc_ah; in ath9k_rx_skb_preprocess()
818 bool discard_current = sc->rx.discard_next; in ath9k_rx_skb_preprocess()
828 sc->rx.discard_next = false; in ath9k_rx_skb_preprocess()
837 RX_STAT_INC(sc, rx_len_err); in ath9k_rx_skb_preprocess()
847 RX_STAT_INC(sc, rx_len_err); in ath9k_rx_skb_preprocess()
868 ath_debug_stat_rx(sc, rx_stats); in ath9k_rx_skb_preprocess()
883 ath9k_dfs_process_phyerr(sc, hdr, rx_stats, in ath9k_rx_skb_preprocess()
885 } else if (sc->spec_priv.spectral_mode != SPECTRAL_DISABLED && in ath9k_rx_skb_preprocess()
886 ath_cmn_process_fft(&sc->spec_priv, hdr, rx_stats, in ath9k_rx_skb_preprocess()
888 RX_STAT_INC(sc, rx_spectral); in ath9k_rx_skb_preprocess()
897 spin_lock_bh(&sc->chan_lock); in ath9k_rx_skb_preprocess()
899 sc->cur_chan->rxfilter)) { in ath9k_rx_skb_preprocess()
900 spin_unlock_bh(&sc->chan_lock); in ath9k_rx_skb_preprocess()
903 spin_unlock_bh(&sc->chan_lock); in ath9k_rx_skb_preprocess()
906 RX_STAT_INC(sc, rx_beacons); in ath9k_rx_skb_preprocess()
923 RX_STAT_INC(sc, rx_rate_err); in ath9k_rx_skb_preprocess()
929 ath_chanctx_beacon_recv_ev(sc, in ath9k_rx_skb_preprocess()
943 sc->rx.num_pkts++; in ath9k_rx_skb_preprocess()
949 sc->rx.discard_next = rx_stats->rs_more; in ath9k_rx_skb_preprocess()
963 static void ath9k_antenna_check(struct ath_softc *sc, in ath9k_antenna_check() argument
966 struct ath_hw *ah = sc->sc_ah; in ath9k_antenna_check()
977 if (sc->rx.defant != rs->rs_antenna) { in ath9k_antenna_check()
978 if (++sc->rx.rxotherant >= 3) in ath9k_antenna_check()
979 ath_setdefantenna(sc, rs->rs_antenna); in ath9k_antenna_check()
981 sc->rx.rxotherant = 0; in ath9k_antenna_check()
986 ath_ant_comb_scan(sc, rs); in ath9k_antenna_check()
988 ath_ant_comb_scan(sc, rs); in ath9k_antenna_check()
992 static void ath9k_apply_ampdu_details(struct ath_softc *sc, in ath9k_apply_ampdu_details() argument
998 rxs->ampdu_reference = sc->rx.ampdu_ref; in ath9k_apply_ampdu_details()
1002 sc->rx.ampdu_ref++; in ath9k_apply_ampdu_details()
1010 static void ath_rx_count_airtime(struct ath_softc *sc, in ath_rx_count_airtime() argument
1015 struct ath_hw *ah = sc->sc_ah; in ath_rx_count_airtime()
1031 sta = ieee80211_find_sta_by_ifaddr(sc->hw, hdr->addr2, NULL); in ath_rx_count_airtime()
1045 airtime += ath_pkt_duration(sc, rxs->rate_idx, len, in ath_rx_count_airtime()
1060 int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp) in ath_rx_tasklet() argument
1065 struct ath_hw *ah = sc->sc_ah; in ath_rx_tasklet()
1067 struct ieee80211_hw *hw = sc->hw; in ath_rx_tasklet()
1093 bf = ath_edma_get_next_rx_buf(sc, &rs, qtype); in ath_rx_tasklet()
1095 bf = ath_get_next_rx_buf(sc, &rs); in ath_rx_tasklet()
1108 if (sc->rx.frag) in ath_rx_tasklet()
1109 hdr_skb = sc->rx.frag; in ath_rx_tasklet()
1116 retval = ath9k_rx_skb_preprocess(sc, hdr_skb, &rs, rxs, in ath_rx_tasklet()
1130 RX_STAT_INC(sc, rx_oom_err); in ath_rx_tasklet()
1135 new_buf_addr = dma_map_single(sc->dev, requeue_skb->data, in ath_rx_tasklet()
1137 if (unlikely(dma_mapping_error(sc->dev, new_buf_addr))) { in ath_rx_tasklet()
1143 dma_unmap_single(sc->dev, bf->bf_buf_addr, in ath_rx_tasklet()
1158 RX_STAT_INC(sc, rx_frags); in ath_rx_tasklet()
1164 if (sc->rx.frag) { in ath_rx_tasklet()
1166 dev_kfree_skb_any(sc->rx.frag); in ath_rx_tasklet()
1168 RX_STAT_INC(sc, rx_too_many_frags_err); in ath_rx_tasklet()
1171 sc->rx.frag = skb; in ath_rx_tasklet()
1175 if (sc->rx.frag) { in ath_rx_tasklet()
1180 RX_STAT_INC(sc, rx_oom_err); in ath_rx_tasklet()
1184 sc->rx.frag = NULL; in ath_rx_tasklet()
1195 spin_lock_irqsave(&sc->sc_pm_lock, flags); in ath_rx_tasklet()
1196 if ((sc->ps_flags & (PS_WAIT_FOR_BEACON | in ath_rx_tasklet()
1199 ath9k_check_auto_sleep(sc)) in ath_rx_tasklet()
1200 ath_rx_ps(sc, skb, rs.is_mybeacon); in ath_rx_tasklet()
1201 spin_unlock_irqrestore(&sc->sc_pm_lock, flags); in ath_rx_tasklet()
1203 ath9k_antenna_check(sc, &rs); in ath_rx_tasklet()
1204 ath9k_apply_ampdu_details(sc, &rs, rxs); in ath_rx_tasklet()
1205 ath_debug_rate_stats(sc, &rs, skb); in ath_rx_tasklet()
1206 ath_rx_count_airtime(sc, &rs, skb); in ath_rx_tasklet()
1210 ath_dynack_sample_ack_ts(sc->sc_ah, skb, rs.rs_tstamp); in ath_rx_tasklet()
1215 if (sc->rx.frag) { in ath_rx_tasklet()
1216 dev_kfree_skb_any(sc->rx.frag); in ath_rx_tasklet()
1217 sc->rx.frag = NULL; in ath_rx_tasklet()
1220 list_add_tail(&bf->list, &sc->rx.rxbuf); in ath_rx_tasklet()
1223 ath_rx_buf_relink(sc, bf, flush); in ath_rx_tasklet()
1227 ath_rx_edma_buf_link(sc, qtype); in ath_rx_tasklet()