Lines Matching refs:ah
96 static int ath5k_reset(struct ath5k_hw *ah, struct ieee80211_channel *chan,
200 static inline u64 ath5k_extend_tsf(struct ath5k_hw *ah, u32 rstamp) in ath5k_extend_tsf() argument
202 u64 tsf = ath5k_hw_get_tsf64(ah); in ath5k_extend_tsf()
233 struct ath5k_hw *ah = (struct ath5k_hw *) hw_priv; in ath5k_ioread32() local
234 return ath5k_hw_reg_read(ah, reg_offset); in ath5k_ioread32()
239 struct ath5k_hw *ah = (struct ath5k_hw *) hw_priv; in ath5k_iowrite32() local
240 ath5k_hw_reg_write(ah, val, reg_offset); in ath5k_iowrite32()
256 struct ath5k_hw *ah = hw->priv; in ath5k_reg_notifier() local
257 struct ath_regulatory *regulatory = ath5k_hw_regulatory(ah); in ath5k_reg_notifier()
295 ath5k_setup_channels(struct ath5k_hw *ah, struct ieee80211_channel *channels, in ath5k_setup_channels() argument
313 ATH5K_WARN(ah, "bad mode, not copying channels\n"); in ath5k_setup_channels()
330 if (!ath5k_channel_ok(ah, &channels[count])) in ath5k_setup_channels()
343 ath5k_setup_rate_idx(struct ath5k_hw *ah, struct ieee80211_supported_band *b) in ath5k_setup_rate_idx() argument
348 ah->rate_idx[b->band][i] = -1; in ath5k_setup_rate_idx()
351 ah->rate_idx[b->band][b->bitrates[i].hw_value] = i; in ath5k_setup_rate_idx()
353 ah->rate_idx[b->band][b->bitrates[i].hw_value_short] = i; in ath5k_setup_rate_idx()
360 struct ath5k_hw *ah = hw->priv; in ath5k_setup_bands() local
365 BUILD_BUG_ON(ARRAY_SIZE(ah->sbands) < NUM_NL80211_BANDS); in ath5k_setup_bands()
366 max_c = ARRAY_SIZE(ah->channels); in ath5k_setup_bands()
369 sband = &ah->sbands[NL80211_BAND_2GHZ]; in ath5k_setup_bands()
371 sband->bitrates = &ah->rates[NL80211_BAND_2GHZ][0]; in ath5k_setup_bands()
373 if (test_bit(AR5K_MODE_11G, ah->ah_capabilities.cap_mode)) { in ath5k_setup_bands()
379 sband->channels = ah->channels; in ath5k_setup_bands()
380 sband->n_channels = ath5k_setup_channels(ah, sband->channels, in ath5k_setup_bands()
386 } else if (test_bit(AR5K_MODE_11B, ah->ah_capabilities.cap_mode)) { in ath5k_setup_bands()
396 if (ah->ah_version == AR5K_AR5211) { in ath5k_setup_bands()
405 sband->channels = ah->channels; in ath5k_setup_bands()
406 sband->n_channels = ath5k_setup_channels(ah, sband->channels, in ath5k_setup_bands()
413 ath5k_setup_rate_idx(ah, sband); in ath5k_setup_bands()
416 if (test_bit(AR5K_MODE_11A, ah->ah_capabilities.cap_mode)) { in ath5k_setup_bands()
417 sband = &ah->sbands[NL80211_BAND_5GHZ]; in ath5k_setup_bands()
419 sband->bitrates = &ah->rates[NL80211_BAND_5GHZ][0]; in ath5k_setup_bands()
425 sband->channels = &ah->channels[count_c]; in ath5k_setup_bands()
426 sband->n_channels = ath5k_setup_channels(ah, sband->channels, in ath5k_setup_bands()
431 ath5k_setup_rate_idx(ah, sband); in ath5k_setup_bands()
433 ath5k_debug_dump_bands(ah); in ath5k_setup_bands()
446 ath5k_chan_set(struct ath5k_hw *ah, struct cfg80211_chan_def *chandef) in ath5k_chan_set() argument
448 ATH5K_DBG(ah, ATH5K_DEBUG_RESET, in ath5k_chan_set()
450 ah->curchan->center_freq, chandef->chan->center_freq); in ath5k_chan_set()
455 ah->ah_bwmode = AR5K_BWMODE_DEFAULT; in ath5k_chan_set()
458 ah->ah_bwmode = AR5K_BWMODE_5MHZ; in ath5k_chan_set()
461 ah->ah_bwmode = AR5K_BWMODE_10MHZ; in ath5k_chan_set()
474 return ath5k_reset(ah, chandef->chan, true); in ath5k_chan_set()
518 ath5k_update_bssid_mask_and_opmode(struct ath5k_hw *ah, in ath5k_update_bssid_mask_and_opmode() argument
521 struct ath_common *common = ath5k_hw_common(ah); in ath5k_update_bssid_mask_and_opmode()
541 ah->hw, IEEE80211_IFACE_ITER_RESUME_ALL, in ath5k_update_bssid_mask_and_opmode()
543 memcpy(ah->bssidmask, iter_data.mask, ETH_ALEN); in ath5k_update_bssid_mask_and_opmode()
545 ah->opmode = iter_data.opmode; in ath5k_update_bssid_mask_and_opmode()
546 if (ah->opmode == NL80211_IFTYPE_UNSPECIFIED) in ath5k_update_bssid_mask_and_opmode()
548 ah->opmode = NL80211_IFTYPE_STATION; in ath5k_update_bssid_mask_and_opmode()
550 ath5k_hw_set_opmode(ah, ah->opmode); in ath5k_update_bssid_mask_and_opmode()
551 ATH5K_DBG(ah, ATH5K_DEBUG_MODE, "mode setup opmode %d (%s)\n", in ath5k_update_bssid_mask_and_opmode()
552 ah->opmode, ath_opmode_to_string(ah->opmode)); in ath5k_update_bssid_mask_and_opmode()
555 ath5k_hw_set_lladdr(ah, iter_data.active_mac); in ath5k_update_bssid_mask_and_opmode()
557 if (ath5k_hw_hasbssidmask(ah)) in ath5k_update_bssid_mask_and_opmode()
558 ath5k_hw_set_bssid_mask(ah, ah->bssidmask); in ath5k_update_bssid_mask_and_opmode()
566 ah->filter_flags |= AR5K_RX_FILTER_PROM; in ath5k_update_bssid_mask_and_opmode()
569 rfilt = ah->filter_flags; in ath5k_update_bssid_mask_and_opmode()
570 ath5k_hw_set_rx_filter(ah, rfilt); in ath5k_update_bssid_mask_and_opmode()
571 ATH5K_DBG(ah, ATH5K_DEBUG_MODE, "RX filter 0x%x\n", rfilt); in ath5k_update_bssid_mask_and_opmode()
575 ath5k_hw_to_driver_rix(struct ath5k_hw *ah, int hw_rix) in ath5k_hw_to_driver_rix() argument
584 rix = ah->rate_idx[ah->curchan->band][hw_rix]; in ath5k_hw_to_driver_rix()
596 struct sk_buff *ath5k_rx_skb_alloc(struct ath5k_hw *ah, dma_addr_t *skb_addr) in ath5k_rx_skb_alloc() argument
598 struct ath_common *common = ath5k_hw_common(ah); in ath5k_rx_skb_alloc()
610 ATH5K_ERR(ah, "can't alloc skbuff of size %u\n", in ath5k_rx_skb_alloc()
615 *skb_addr = dma_map_single(ah->dev, in ath5k_rx_skb_alloc()
619 if (unlikely(dma_mapping_error(ah->dev, *skb_addr))) { in ath5k_rx_skb_alloc()
620 ATH5K_ERR(ah, "%s: DMA mapping failed\n", __func__); in ath5k_rx_skb_alloc()
628 ath5k_rxbuf_setup(struct ath5k_hw *ah, struct ath5k_buf *bf) in ath5k_rxbuf_setup() argument
635 skb = ath5k_rx_skb_alloc(ah, &bf->skbaddr); in ath5k_rxbuf_setup()
659 ret = ath5k_hw_setup_rx_desc(ah, ds, ah->common.rx_bufsize, 0); in ath5k_rxbuf_setup()
661 ATH5K_ERR(ah, "%s: could not setup RX desc\n", __func__); in ath5k_rxbuf_setup()
665 if (ah->rxlink != NULL) in ath5k_rxbuf_setup()
666 *ah->rxlink = bf->daddr; in ath5k_rxbuf_setup()
667 ah->rxlink = &ds->ds_link; in ath5k_rxbuf_setup()
768 ath5k_txbuf_setup(struct ath5k_hw *ah, struct ath5k_buf *bf, in ath5k_txbuf_setup() argument
788 bf->skbaddr = dma_map_single(ah->dev, skb->data, skb->len, in ath5k_txbuf_setup()
791 if (dma_mapping_error(ah->dev, bf->skbaddr)) in ath5k_txbuf_setup()
805 rate = ath5k_get_rate(ah->hw, info, bf, 0); in ath5k_txbuf_setup()
817 hw_rate = ath5k_get_rate_hw_value(ah->hw, info, bf, 0); in ath5k_txbuf_setup()
830 cts_rate = ieee80211_get_rts_cts_rate(ah->hw, info)->hw_value; in ath5k_txbuf_setup()
831 duration = le16_to_cpu(ieee80211_rts_duration(ah->hw, in ath5k_txbuf_setup()
836 cts_rate = ieee80211_get_rts_cts_rate(ah->hw, info)->hw_value; in ath5k_txbuf_setup()
837 duration = le16_to_cpu(ieee80211_ctstoself_duration(ah->hw, in ath5k_txbuf_setup()
841 ret = ah->ah_setup_tx_desc(ah, ds, pktlen, in ath5k_txbuf_setup()
844 (ah->ah_txpower.txp_requested * 2), in ath5k_txbuf_setup()
846 bf->rates[0].count, keyidx, ah->ah_tx_ant, flags, in ath5k_txbuf_setup()
852 if (ah->ah_capabilities.cap_has_mrr_support) { in ath5k_txbuf_setup()
858 rate = ath5k_get_rate(ah->hw, info, bf, i); in ath5k_txbuf_setup()
862 mrr_rate[i] = ath5k_get_rate_hw_value(ah->hw, info, bf, i); in ath5k_txbuf_setup()
866 ath5k_hw_setup_mrr_tx_desc(ah, ds, in ath5k_txbuf_setup()
879 ath5k_hw_set_txdp(ah, txq->qnum, bf->daddr); in ath5k_txbuf_setup()
884 ath5k_hw_start_tx_dma(ah, txq->qnum); in ath5k_txbuf_setup()
889 dma_unmap_single(ah->dev, bf->skbaddr, skb->len, DMA_TO_DEVICE); in ath5k_txbuf_setup()
898 ath5k_desc_alloc(struct ath5k_hw *ah) in ath5k_desc_alloc() argument
907 ah->desc_len = sizeof(struct ath5k_desc) * in ath5k_desc_alloc()
910 ah->desc = dma_alloc_coherent(ah->dev, ah->desc_len, in ath5k_desc_alloc()
911 &ah->desc_daddr, GFP_KERNEL); in ath5k_desc_alloc()
912 if (ah->desc == NULL) { in ath5k_desc_alloc()
913 ATH5K_ERR(ah, "can't allocate descriptors\n"); in ath5k_desc_alloc()
917 ds = ah->desc; in ath5k_desc_alloc()
918 da = ah->desc_daddr; in ath5k_desc_alloc()
919 ATH5K_DBG(ah, ATH5K_DEBUG_ANY, "DMA map: %p (%zu) -> %llx\n", in ath5k_desc_alloc()
920 ds, ah->desc_len, (unsigned long long)ah->desc_daddr); in ath5k_desc_alloc()
925 ATH5K_ERR(ah, "can't allocate bufptr\n"); in ath5k_desc_alloc()
929 ah->bufptr = bf; in ath5k_desc_alloc()
931 INIT_LIST_HEAD(&ah->rxbuf); in ath5k_desc_alloc()
935 list_add_tail(&bf->list, &ah->rxbuf); in ath5k_desc_alloc()
938 INIT_LIST_HEAD(&ah->txbuf); in ath5k_desc_alloc()
939 ah->txbuf_len = ATH_TXBUF; in ath5k_desc_alloc()
943 list_add_tail(&bf->list, &ah->txbuf); in ath5k_desc_alloc()
947 INIT_LIST_HEAD(&ah->bcbuf); in ath5k_desc_alloc()
951 list_add_tail(&bf->list, &ah->bcbuf); in ath5k_desc_alloc()
956 dma_free_coherent(ah->dev, ah->desc_len, ah->desc, ah->desc_daddr); in ath5k_desc_alloc()
958 ah->desc = NULL; in ath5k_desc_alloc()
963 ath5k_txbuf_free_skb(struct ath5k_hw *ah, struct ath5k_buf *bf) in ath5k_txbuf_free_skb() argument
968 dma_unmap_single(ah->dev, bf->skbaddr, bf->skb->len, in ath5k_txbuf_free_skb()
970 ieee80211_free_txskb(ah->hw, bf->skb); in ath5k_txbuf_free_skb()
977 ath5k_rxbuf_free_skb(struct ath5k_hw *ah, struct ath5k_buf *bf) in ath5k_rxbuf_free_skb() argument
979 struct ath_common *common = ath5k_hw_common(ah); in ath5k_rxbuf_free_skb()
984 dma_unmap_single(ah->dev, bf->skbaddr, common->rx_bufsize, in ath5k_rxbuf_free_skb()
993 ath5k_desc_free(struct ath5k_hw *ah) in ath5k_desc_free() argument
997 list_for_each_entry(bf, &ah->txbuf, list) in ath5k_desc_free()
998 ath5k_txbuf_free_skb(ah, bf); in ath5k_desc_free()
999 list_for_each_entry(bf, &ah->rxbuf, list) in ath5k_desc_free()
1000 ath5k_rxbuf_free_skb(ah, bf); in ath5k_desc_free()
1001 list_for_each_entry(bf, &ah->bcbuf, list) in ath5k_desc_free()
1002 ath5k_txbuf_free_skb(ah, bf); in ath5k_desc_free()
1005 dma_free_coherent(ah->dev, ah->desc_len, ah->desc, ah->desc_daddr); in ath5k_desc_free()
1006 ah->desc = NULL; in ath5k_desc_free()
1007 ah->desc_daddr = 0; in ath5k_desc_free()
1009 kfree(ah->bufptr); in ath5k_desc_free()
1010 ah->bufptr = NULL; in ath5k_desc_free()
1019 ath5k_txq_setup(struct ath5k_hw *ah, in ath5k_txq_setup() argument
1047 qnum = ath5k_hw_setup_tx_queue(ah, qtype, &qi); in ath5k_txq_setup()
1055 txq = &ah->txqs[qnum]; in ath5k_txq_setup()
1067 return &ah->txqs[qnum]; in ath5k_txq_setup()
1071 ath5k_beaconq_setup(struct ath5k_hw *ah) in ath5k_beaconq_setup() argument
1083 return ath5k_hw_setup_tx_queue(ah, AR5K_TX_QUEUE_BEACON, &qi); in ath5k_beaconq_setup()
1087 ath5k_beaconq_config(struct ath5k_hw *ah) in ath5k_beaconq_config() argument
1092 ret = ath5k_hw_get_tx_queueprops(ah, ah->bhalq, &qi); in ath5k_beaconq_config()
1096 if (ah->opmode == NL80211_IFTYPE_AP || in ath5k_beaconq_config()
1097 ah->opmode == NL80211_IFTYPE_MESH_POINT) { in ath5k_beaconq_config()
1105 } else if (ah->opmode == NL80211_IFTYPE_ADHOC) { in ath5k_beaconq_config()
1114 ATH5K_DBG(ah, ATH5K_DEBUG_BEACON, in ath5k_beaconq_config()
1118 ret = ath5k_hw_set_tx_queueprops(ah, ah->bhalq, &qi); in ath5k_beaconq_config()
1120 ATH5K_ERR(ah, "%s: unable to update parameters for beacon " in ath5k_beaconq_config()
1124 ret = ath5k_hw_reset_tx_queue(ah, ah->bhalq); /* push to h/w */ in ath5k_beaconq_config()
1129 ret = ath5k_hw_get_tx_queueprops(ah, AR5K_TX_QUEUE_ID_CAB, &qi); in ath5k_beaconq_config()
1133 qi.tqi_ready_time = (ah->bintval * 80) / 100; in ath5k_beaconq_config()
1134 ret = ath5k_hw_set_tx_queueprops(ah, AR5K_TX_QUEUE_ID_CAB, &qi); in ath5k_beaconq_config()
1138 ret = ath5k_hw_reset_tx_queue(ah, AR5K_TX_QUEUE_ID_CAB); in ath5k_beaconq_config()
1155 ath5k_drain_tx_buffs(struct ath5k_hw *ah) in ath5k_drain_tx_buffs() argument
1161 for (i = 0; i < ARRAY_SIZE(ah->txqs); i++) { in ath5k_drain_tx_buffs()
1162 if (ah->txqs[i].setup) { in ath5k_drain_tx_buffs()
1163 txq = &ah->txqs[i]; in ath5k_drain_tx_buffs()
1166 ath5k_debug_printtxbuf(ah, bf); in ath5k_drain_tx_buffs()
1168 ath5k_txbuf_free_skb(ah, bf); in ath5k_drain_tx_buffs()
1170 spin_lock(&ah->txbuflock); in ath5k_drain_tx_buffs()
1171 list_move_tail(&bf->list, &ah->txbuf); in ath5k_drain_tx_buffs()
1172 ah->txbuf_len++; in ath5k_drain_tx_buffs()
1174 spin_unlock(&ah->txbuflock); in ath5k_drain_tx_buffs()
1184 ath5k_txq_release(struct ath5k_hw *ah) in ath5k_txq_release() argument
1186 struct ath5k_txq *txq = ah->txqs; in ath5k_txq_release()
1189 for (i = 0; i < ARRAY_SIZE(ah->txqs); i++, txq++) in ath5k_txq_release()
1191 ath5k_hw_release_tx_queue(ah, txq->qnum); in ath5k_txq_release()
1205 ath5k_rx_start(struct ath5k_hw *ah) in ath5k_rx_start() argument
1207 struct ath_common *common = ath5k_hw_common(ah); in ath5k_rx_start()
1213 ATH5K_DBG(ah, ATH5K_DEBUG_RESET, "cachelsz %u rx_bufsize %u\n", in ath5k_rx_start()
1216 spin_lock_bh(&ah->rxbuflock); in ath5k_rx_start()
1217 ah->rxlink = NULL; in ath5k_rx_start()
1218 list_for_each_entry(bf, &ah->rxbuf, list) { in ath5k_rx_start()
1219 ret = ath5k_rxbuf_setup(ah, bf); in ath5k_rx_start()
1221 spin_unlock_bh(&ah->rxbuflock); in ath5k_rx_start()
1225 bf = list_first_entry(&ah->rxbuf, struct ath5k_buf, list); in ath5k_rx_start()
1226 ath5k_hw_set_rxdp(ah, bf->daddr); in ath5k_rx_start()
1227 spin_unlock_bh(&ah->rxbuflock); in ath5k_rx_start()
1229 ath5k_hw_start_rx_dma(ah); /* enable recv descriptors */ in ath5k_rx_start()
1230 ath5k_update_bssid_mask_and_opmode(ah, NULL); /* set filters, etc. */ in ath5k_rx_start()
1231 ath5k_hw_start_rx_pcu(ah); /* re-enable PCU/DMA engine */ in ath5k_rx_start()
1246 ath5k_rx_stop(struct ath5k_hw *ah) in ath5k_rx_stop() argument
1249 ath5k_hw_set_rx_filter(ah, 0); /* clear recv filter */ in ath5k_rx_stop()
1250 ath5k_hw_stop_rx_pcu(ah); /* disable PCU */ in ath5k_rx_stop()
1252 ath5k_debug_printrxbuffs(ah); in ath5k_rx_stop()
1256 ath5k_rx_decrypted(struct ath5k_hw *ah, struct sk_buff *skb, in ath5k_rx_decrypted() argument
1259 struct ath_common *common = ath5k_hw_common(ah); in ath5k_rx_decrypted()
1285 ath5k_check_ibss_tsf(struct ath5k_hw *ah, struct sk_buff *skb, in ath5k_check_ibss_tsf() argument
1298 tsf = ath5k_hw_get_tsf64(ah); in ath5k_check_ibss_tsf()
1302 ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_BEACON, in ath5k_check_ibss_tsf()
1321 ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_BEACON, in ath5k_check_ibss_tsf()
1334 if (hw_tu >= ah->nexttbtt) in ath5k_check_ibss_tsf()
1335 ath5k_beacon_update_timers(ah, bc_tstamp); in ath5k_check_ibss_tsf()
1340 if (!ath5k_hw_check_beacon_timers(ah, ah->bintval)) { in ath5k_check_ibss_tsf()
1341 ath5k_beacon_update_timers(ah, bc_tstamp); in ath5k_check_ibss_tsf()
1342 ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_BEACON, in ath5k_check_ibss_tsf()
1416 ath5k_receive_frame(struct ath5k_hw *ah, struct sk_buff *skb, in ath5k_receive_frame() argument
1420 struct ath_common *common = ath5k_hw_common(ah); in ath5k_receive_frame()
1442 rxs->mactime = ath5k_extend_tsf(ah, rs->rs_tstamp); in ath5k_receive_frame()
1445 rxs->freq = ah->curchan->center_freq; in ath5k_receive_frame()
1446 rxs->band = ah->curchan->band; in ath5k_receive_frame()
1448 rxs->signal = ah->ah_noise_floor + rs->rs_rssi; in ath5k_receive_frame()
1453 ah->stats.antenna_rx[rs->rs_antenna]++; in ath5k_receive_frame()
1455 ah->stats.antenna_rx[0]++; /* invalid */ in ath5k_receive_frame()
1457 rxs->rate_idx = ath5k_hw_to_driver_rix(ah, rs->rs_rate); in ath5k_receive_frame()
1458 rxs->flag |= ath5k_rx_decrypted(ah, skb, rs); in ath5k_receive_frame()
1459 switch (ah->ah_bwmode) { in ath5k_receive_frame()
1471 ah->sbands[ah->curchan->band].bitrates[rxs->rate_idx].hw_value_short) in ath5k_receive_frame()
1474 trace_ath5k_rx(ah, skb); in ath5k_receive_frame()
1477 ewma_beacon_rssi_add(&ah->ah_beacon_rssi_avg, rs->rs_rssi); in ath5k_receive_frame()
1480 if (ah->opmode == NL80211_IFTYPE_ADHOC) in ath5k_receive_frame()
1481 ath5k_check_ibss_tsf(ah, skb, rxs); in ath5k_receive_frame()
1484 ieee80211_rx(ah->hw, skb); in ath5k_receive_frame()
1493 ath5k_receive_frame_ok(struct ath5k_hw *ah, struct ath5k_rx_status *rs) in ath5k_receive_frame_ok() argument
1495 ah->stats.rx_all_count++; in ath5k_receive_frame_ok()
1496 ah->stats.rx_bytes_count += rs->rs_datalen; in ath5k_receive_frame_ok()
1502 ah->stats.rxerr_crc++; in ath5k_receive_frame_ok()
1504 ah->stats.rxerr_fifo++; in ath5k_receive_frame_ok()
1506 ah->stats.rxerr_phy++; in ath5k_receive_frame_ok()
1508 ah->stats.rxerr_phy_code[rs->rs_phyerr]++; in ath5k_receive_frame_ok()
1535 ah->stats.rxerr_decrypt++; in ath5k_receive_frame_ok()
1541 ah->stats.rxerr_mic++; in ath5k_receive_frame_ok()
1550 if (ah->fif_filter_flags & FIF_FCSFAIL) in ath5k_receive_frame_ok()
1558 ah->stats.rxerr_jumbo++; in ath5k_receive_frame_ok()
1565 ath5k_set_current_imask(struct ath5k_hw *ah) in ath5k_set_current_imask() argument
1570 if (test_bit(ATH_STAT_RESET, ah->status)) in ath5k_set_current_imask()
1573 spin_lock_irqsave(&ah->irqlock, flags); in ath5k_set_current_imask()
1574 imask = ah->imask; in ath5k_set_current_imask()
1575 if (ah->rx_pending) in ath5k_set_current_imask()
1577 if (ah->tx_pending) in ath5k_set_current_imask()
1579 ath5k_hw_set_imr(ah, imask); in ath5k_set_current_imask()
1580 spin_unlock_irqrestore(&ah->irqlock, flags); in ath5k_set_current_imask()
1589 struct ath5k_hw *ah = from_tasklet(ah, t, rxtq); in ath5k_tasklet_rx() local
1590 struct ath_common *common = ath5k_hw_common(ah); in ath5k_tasklet_rx()
1595 spin_lock(&ah->rxbuflock); in ath5k_tasklet_rx()
1596 if (list_empty(&ah->rxbuf)) { in ath5k_tasklet_rx()
1597 ATH5K_WARN(ah, "empty rx buf pool\n"); in ath5k_tasklet_rx()
1601 bf = list_first_entry(&ah->rxbuf, struct ath5k_buf, list); in ath5k_tasklet_rx()
1607 if (ath5k_hw_get_rxdp(ah) == bf->daddr) in ath5k_tasklet_rx()
1610 ret = ah->ah_proc_rx_desc(ah, ds, &rs); in ath5k_tasklet_rx()
1614 ATH5K_ERR(ah, "error in processing rx descriptor\n"); in ath5k_tasklet_rx()
1615 ah->stats.rxerr_proc++; in ath5k_tasklet_rx()
1619 if (ath5k_receive_frame_ok(ah, &rs)) { in ath5k_tasklet_rx()
1620 next_skb = ath5k_rx_skb_alloc(ah, &next_skb_addr); in ath5k_tasklet_rx()
1629 dma_unmap_single(ah->dev, bf->skbaddr, in ath5k_tasklet_rx()
1635 ath5k_receive_frame(ah, skb, &rs); in ath5k_tasklet_rx()
1641 list_move_tail(&bf->list, &ah->rxbuf); in ath5k_tasklet_rx()
1642 } while (ath5k_rxbuf_setup(ah, bf) == 0); in ath5k_tasklet_rx()
1644 spin_unlock(&ah->rxbuflock); in ath5k_tasklet_rx()
1645 ah->rx_pending = false; in ath5k_tasklet_rx()
1646 ath5k_set_current_imask(ah); in ath5k_tasklet_rx()
1658 struct ath5k_hw *ah = hw->priv; in ath5k_tx_queue() local
1663 trace_ath5k_tx(ah, skb, txq); in ath5k_tx_queue()
1671 ATH5K_ERR(ah, "tx hdrlen not %%4: not enough" in ath5k_tx_queue()
1680 spin_lock_irqsave(&ah->txbuflock, flags); in ath5k_tx_queue()
1681 if (list_empty(&ah->txbuf)) { in ath5k_tx_queue()
1682 ATH5K_ERR(ah, "no further txbuf available, dropping packet\n"); in ath5k_tx_queue()
1683 spin_unlock_irqrestore(&ah->txbuflock, flags); in ath5k_tx_queue()
1687 bf = list_first_entry(&ah->txbuf, struct ath5k_buf, list); in ath5k_tx_queue()
1689 ah->txbuf_len--; in ath5k_tx_queue()
1690 if (list_empty(&ah->txbuf)) in ath5k_tx_queue()
1692 spin_unlock_irqrestore(&ah->txbuflock, flags); in ath5k_tx_queue()
1696 if (ath5k_txbuf_setup(ah, bf, txq, padsize, control)) { in ath5k_tx_queue()
1698 spin_lock_irqsave(&ah->txbuflock, flags); in ath5k_tx_queue()
1699 list_add_tail(&bf->list, &ah->txbuf); in ath5k_tx_queue()
1700 ah->txbuf_len++; in ath5k_tx_queue()
1701 spin_unlock_irqrestore(&ah->txbuflock, flags); in ath5k_tx_queue()
1711 ath5k_tx_frame_completed(struct ath5k_hw *ah, struct sk_buff *skb, in ath5k_tx_frame_completed() argument
1720 ah->stats.tx_all_count++; in ath5k_tx_frame_completed()
1721 ah->stats.tx_bytes_count += skb->len; in ath5k_tx_frame_completed()
1744 ah->stats.ack_fail++; in ath5k_tx_frame_completed()
1747 ah->stats.txerr_filt++; in ath5k_tx_frame_completed()
1750 ah->stats.txerr_retry++; in ath5k_tx_frame_completed()
1752 ah->stats.txerr_fifo++; in ath5k_tx_frame_completed()
1768 ah->stats.antenna_tx[ts->ts_antenna]++; in ath5k_tx_frame_completed()
1770 ah->stats.antenna_tx[0]++; /* invalid */ in ath5k_tx_frame_completed()
1772 trace_ath5k_tx_complete(ah, skb, txq, ts); in ath5k_tx_frame_completed()
1773 ieee80211_tx_status(ah->hw, skb); in ath5k_tx_frame_completed()
1777 ath5k_tx_processq(struct ath5k_hw *ah, struct ath5k_txq *txq) in ath5k_tx_processq() argument
1794 ret = ah->ah_proc_tx_desc(ah, ds, &ts); in ath5k_tx_processq()
1798 ATH5K_ERR(ah, in ath5k_tx_processq()
1807 dma_unmap_single(ah->dev, bf->skbaddr, skb->len, in ath5k_tx_processq()
1809 ath5k_tx_frame_completed(ah, skb, txq, &ts, bf); in ath5k_tx_processq()
1818 if (ath5k_hw_get_txdp(ah, txq->qnum) != bf->daddr) { in ath5k_tx_processq()
1819 spin_lock(&ah->txbuflock); in ath5k_tx_processq()
1820 list_move_tail(&bf->list, &ah->txbuf); in ath5k_tx_processq()
1821 ah->txbuf_len++; in ath5k_tx_processq()
1823 spin_unlock(&ah->txbuflock); in ath5k_tx_processq()
1828 ieee80211_wake_queue(ah->hw, txq->qnum); in ath5k_tx_processq()
1835 struct ath5k_hw *ah = from_tasklet(ah, t, txtq); in ath5k_tasklet_tx() local
1838 if (ah->txqs[i].setup && (ah->ah_txq_isr_txok_all & BIT(i))) in ath5k_tasklet_tx()
1839 ath5k_tx_processq(ah, &ah->txqs[i]); in ath5k_tasklet_tx()
1841 ah->tx_pending = false; in ath5k_tasklet_tx()
1842 ath5k_set_current_imask(ah); in ath5k_tasklet_tx()
1854 ath5k_beacon_setup(struct ath5k_hw *ah, struct ath5k_buf *bf) in ath5k_beacon_setup() argument
1864 bf->skbaddr = dma_map_single(ah->dev, skb->data, skb->len, in ath5k_beacon_setup()
1866 ATH5K_DBG(ah, ATH5K_DEBUG_BEACON, "skb %p [data %p len %u] " in ath5k_beacon_setup()
1870 if (dma_mapping_error(ah->dev, bf->skbaddr)) { in ath5k_beacon_setup()
1871 ATH5K_ERR(ah, "beacon DMA mapping failed\n"); in ath5k_beacon_setup()
1878 antenna = ah->ah_tx_ant; in ath5k_beacon_setup()
1881 if (ah->opmode == NL80211_IFTYPE_ADHOC && ath5k_hw_hasveol(ah)) { in ath5k_beacon_setup()
1905 if (ah->ah_ant_mode == AR5K_ANTMODE_SECTOR_AP) in ath5k_beacon_setup()
1906 antenna = ah->bsent & 4 ? 2 : 1; in ath5k_beacon_setup()
1913 ret = ah->ah_setup_tx_desc(ah, ds, skb->len, in ath5k_beacon_setup()
1916 (ah->ah_txpower.txp_requested * 2), in ath5k_beacon_setup()
1917 ieee80211_get_tx_rate(ah->hw, info)->hw_value, in ath5k_beacon_setup()
1925 dma_unmap_single(ah->dev, bf->skbaddr, skb->len, DMA_TO_DEVICE); in ath5k_beacon_setup()
1940 struct ath5k_hw *ah = hw->priv; in ath5k_beacon_update() local
1957 ath5k_txbuf_free_skb(ah, avf->bbuf); in ath5k_beacon_update()
1959 ret = ath5k_beacon_setup(ah, avf->bbuf); in ath5k_beacon_update()
1973 ath5k_beacon_send(struct ath5k_hw *ah) in ath5k_beacon_send() argument
1981 ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_BEACON, "in beacon_send\n"); in ath5k_beacon_send()
1990 if (unlikely(ath5k_hw_num_tx_pending(ah, ah->bhalq) != 0)) { in ath5k_beacon_send()
1991 ah->bmisscount++; in ath5k_beacon_send()
1992 ATH5K_DBG(ah, ATH5K_DEBUG_BEACON, in ath5k_beacon_send()
1993 "missed %u consecutive beacons\n", ah->bmisscount); in ath5k_beacon_send()
1994 if (ah->bmisscount > 10) { /* NB: 10 is a guess */ in ath5k_beacon_send()
1995 ATH5K_DBG(ah, ATH5K_DEBUG_BEACON, in ath5k_beacon_send()
1997 ah->bmisscount); in ath5k_beacon_send()
1998 ATH5K_DBG(ah, ATH5K_DEBUG_RESET, in ath5k_beacon_send()
2000 ieee80211_queue_work(ah->hw, &ah->reset_work); in ath5k_beacon_send()
2004 if (unlikely(ah->bmisscount != 0)) { in ath5k_beacon_send()
2005 ATH5K_DBG(ah, ATH5K_DEBUG_BEACON, in ath5k_beacon_send()
2007 ah->bmisscount); in ath5k_beacon_send()
2008 ah->bmisscount = 0; in ath5k_beacon_send()
2011 if ((ah->opmode == NL80211_IFTYPE_AP && ah->num_ap_vifs + in ath5k_beacon_send()
2012 ah->num_mesh_vifs > 1) || in ath5k_beacon_send()
2013 ah->opmode == NL80211_IFTYPE_MESH_POINT) { in ath5k_beacon_send()
2014 u64 tsf = ath5k_hw_get_tsf64(ah); in ath5k_beacon_send()
2016 int slot = ((tsftu % ah->bintval) * ATH_BCBUF) / ah->bintval; in ath5k_beacon_send()
2017 vif = ah->bslot[(slot + 1) % ATH_BCBUF]; in ath5k_beacon_send()
2018 ATH5K_DBG(ah, ATH5K_DEBUG_BEACON, in ath5k_beacon_send()
2020 (unsigned long long)tsf, tsftu, ah->bintval, slot, vif); in ath5k_beacon_send()
2022 vif = ah->bslot[0]; in ath5k_beacon_send()
2035 if (unlikely(ath5k_hw_stop_beacon_queue(ah, ah->bhalq))) { in ath5k_beacon_send()
2036 ATH5K_WARN(ah, "beacon queue %u didn't start/stop ?\n", ah->bhalq); in ath5k_beacon_send()
2041 if (ah->opmode == NL80211_IFTYPE_AP || in ath5k_beacon_send()
2042 ah->opmode == NL80211_IFTYPE_MESH_POINT) { in ath5k_beacon_send()
2043 err = ath5k_beacon_update(ah->hw, vif); in ath5k_beacon_send()
2048 if (unlikely(bf->skb == NULL || ah->opmode == NL80211_IFTYPE_STATION || in ath5k_beacon_send()
2049 ah->opmode == NL80211_IFTYPE_MONITOR)) { in ath5k_beacon_send()
2050 ATH5K_WARN(ah, "bf=%p bf_skb=%p\n", bf, bf->skb); in ath5k_beacon_send()
2054 trace_ath5k_tx(ah, bf->skb, &ah->txqs[ah->bhalq]); in ath5k_beacon_send()
2056 ath5k_hw_set_txdp(ah, ah->bhalq, bf->daddr); in ath5k_beacon_send()
2057 ath5k_hw_start_tx_dma(ah, ah->bhalq); in ath5k_beacon_send()
2058 ATH5K_DBG(ah, ATH5K_DEBUG_BEACON, "TXDP[%u] = %llx (%p)\n", in ath5k_beacon_send()
2059 ah->bhalq, (unsigned long long)bf->daddr, bf->desc); in ath5k_beacon_send()
2061 skb = ieee80211_get_buffered_bc(ah->hw, vif); in ath5k_beacon_send()
2063 ath5k_tx_queue(ah->hw, skb, ah->cabq, NULL); in ath5k_beacon_send()
2065 if (ah->cabq->txq_len >= ah->cabq->txq_max) in ath5k_beacon_send()
2068 skb = ieee80211_get_buffered_bc(ah->hw, vif); in ath5k_beacon_send()
2071 ah->bsent++; in ath5k_beacon_send()
2091 ath5k_beacon_update_timers(struct ath5k_hw *ah, u64 bc_tsf) in ath5k_beacon_update_timers() argument
2096 intval = ah->bintval & AR5K_BEACON_PERIOD; in ath5k_beacon_update_timers()
2097 if (ah->opmode == NL80211_IFTYPE_AP && ah->num_ap_vifs in ath5k_beacon_update_timers()
2098 + ah->num_mesh_vifs > 1) { in ath5k_beacon_update_timers()
2101 ATH5K_WARN(ah, "intval %u is too low, min 15\n", in ath5k_beacon_update_timers()
2111 hw_tsf = ath5k_hw_get_tsf64(ah); in ath5k_beacon_update_timers()
2140 ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_BEACON, in ath5k_beacon_update_timers()
2155 ah->nexttbtt = nexttbtt; in ath5k_beacon_update_timers()
2158 ath5k_hw_init_beacon_timers(ah, nexttbtt, intval); in ath5k_beacon_update_timers()
2165 ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_BEACON, in ath5k_beacon_update_timers()
2168 ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_BEACON, in ath5k_beacon_update_timers()
2171 ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_BEACON, in ath5k_beacon_update_timers()
2174 ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_BEACON, in ath5k_beacon_update_timers()
2178 ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_BEACON, "intval %u %s %s\n", in ath5k_beacon_update_timers()
2193 ath5k_beacon_config(struct ath5k_hw *ah) in ath5k_beacon_config() argument
2195 spin_lock_bh(&ah->block); in ath5k_beacon_config()
2196 ah->bmisscount = 0; in ath5k_beacon_config()
2197 ah->imask &= ~(AR5K_INT_BMISS | AR5K_INT_SWBA); in ath5k_beacon_config()
2199 if (ah->enable_beacon) { in ath5k_beacon_config()
2207 ath5k_beaconq_config(ah); in ath5k_beacon_config()
2209 ah->imask |= AR5K_INT_SWBA; in ath5k_beacon_config()
2211 if (ah->opmode == NL80211_IFTYPE_ADHOC) { in ath5k_beacon_config()
2212 if (ath5k_hw_hasveol(ah)) in ath5k_beacon_config()
2213 ath5k_beacon_send(ah); in ath5k_beacon_config()
2215 ath5k_beacon_update_timers(ah, -1); in ath5k_beacon_config()
2217 ath5k_hw_stop_beacon_queue(ah, ah->bhalq); in ath5k_beacon_config()
2220 ath5k_hw_set_imr(ah, ah->imask); in ath5k_beacon_config()
2221 spin_unlock_bh(&ah->block); in ath5k_beacon_config()
2226 struct ath5k_hw *ah = from_tasklet(ah, t, beacontq); in ath5k_tasklet_beacon() local
2236 if (ah->opmode == NL80211_IFTYPE_ADHOC) { in ath5k_tasklet_beacon()
2238 u64 tsf = ath5k_hw_get_tsf64(ah); in ath5k_tasklet_beacon()
2239 ah->nexttbtt += ah->bintval; in ath5k_tasklet_beacon()
2240 ATH5K_DBG(ah, ATH5K_DEBUG_BEACON, in ath5k_tasklet_beacon()
2243 ah->nexttbtt, in ath5k_tasklet_beacon()
2247 spin_lock(&ah->block); in ath5k_tasklet_beacon()
2248 ath5k_beacon_send(ah); in ath5k_tasklet_beacon()
2249 spin_unlock(&ah->block); in ath5k_tasklet_beacon()
2259 ath5k_intr_calibration_poll(struct ath5k_hw *ah) in ath5k_intr_calibration_poll() argument
2261 if (time_is_before_eq_jiffies(ah->ah_cal_next_ani) && in ath5k_intr_calibration_poll()
2262 !(ah->ah_cal_mask & AR5K_CALIBRATION_FULL) && in ath5k_intr_calibration_poll()
2263 !(ah->ah_cal_mask & AR5K_CALIBRATION_SHORT)) { in ath5k_intr_calibration_poll()
2267 ah->ah_cal_next_ani = jiffies + in ath5k_intr_calibration_poll()
2269 tasklet_schedule(&ah->ani_tasklet); in ath5k_intr_calibration_poll()
2271 } else if (time_is_before_eq_jiffies(ah->ah_cal_next_short) && in ath5k_intr_calibration_poll()
2272 !(ah->ah_cal_mask & AR5K_CALIBRATION_FULL) && in ath5k_intr_calibration_poll()
2273 !(ah->ah_cal_mask & AR5K_CALIBRATION_SHORT)) { in ath5k_intr_calibration_poll()
2282 ah->ah_cal_next_short = jiffies + in ath5k_intr_calibration_poll()
2284 ieee80211_queue_work(ah->hw, &ah->calib_work); in ath5k_intr_calibration_poll()
2292 ath5k_schedule_rx(struct ath5k_hw *ah) in ath5k_schedule_rx() argument
2294 ah->rx_pending = true; in ath5k_schedule_rx()
2295 tasklet_schedule(&ah->rxtq); in ath5k_schedule_rx()
2299 ath5k_schedule_tx(struct ath5k_hw *ah) in ath5k_schedule_tx() argument
2301 ah->tx_pending = true; in ath5k_schedule_tx()
2302 tasklet_schedule(&ah->txtq); in ath5k_schedule_tx()
2308 struct ath5k_hw *ah = dev_id; in ath5k_intr() local
2323 if (unlikely(test_bit(ATH_STAT_INVALID, ah->status) || in ath5k_intr()
2324 ((ath5k_get_bus_type(ah) != ATH_AHB) && in ath5k_intr()
2325 !ath5k_hw_is_intr_pending(ah)))) in ath5k_intr()
2330 ath5k_hw_get_isr(ah, &status); /* NB: clears IRQ too */ in ath5k_intr()
2332 ATH5K_DBG(ah, ATH5K_DEBUG_INTR, "status 0x%x/0x%x\n", in ath5k_intr()
2333 status, ah->imask); in ath5k_intr()
2344 ATH5K_DBG(ah, ATH5K_DEBUG_RESET, in ath5k_intr()
2346 ieee80211_queue_work(ah->hw, &ah->reset_work); in ath5k_intr()
2363 ah->stats.rxorn_intr++; in ath5k_intr()
2365 if (ah->ah_mac_srev < AR5K_SREV_AR5212) { in ath5k_intr()
2366 ATH5K_DBG(ah, ATH5K_DEBUG_RESET, in ath5k_intr()
2368 ieee80211_queue_work(ah->hw, &ah->reset_work); in ath5k_intr()
2370 ath5k_schedule_rx(ah); in ath5k_intr()
2376 tasklet_hi_schedule(&ah->beacontq); in ath5k_intr()
2386 ah->stats.rxeol_intr++; in ath5k_intr()
2391 ath5k_hw_update_tx_triglevel(ah, true); in ath5k_intr()
2395 ath5k_schedule_rx(ah); in ath5k_intr()
2402 ath5k_schedule_tx(ah); in ath5k_intr()
2410 ah->stats.mib_intr++; in ath5k_intr()
2411 ath5k_hw_update_mib_counters(ah); in ath5k_intr()
2412 ath5k_ani_mib_intr(ah); in ath5k_intr()
2417 tasklet_schedule(&ah->rf_kill.toggleq); in ath5k_intr()
2421 if (ath5k_get_bus_type(ah) == ATH_AHB) in ath5k_intr()
2424 } while (ath5k_hw_is_intr_pending(ah) && --counter > 0); in ath5k_intr()
2432 if (ah->rx_pending || ah->tx_pending) in ath5k_intr()
2433 ath5k_set_current_imask(ah); in ath5k_intr()
2436 ATH5K_WARN(ah, "too many interrupts, giving up for now\n"); in ath5k_intr()
2439 ath5k_intr_calibration_poll(ah); in ath5k_intr()
2451 struct ath5k_hw *ah = container_of(work, struct ath5k_hw, in ath5k_calibrate_work() local
2455 if (time_is_before_eq_jiffies(ah->ah_cal_next_full)) { in ath5k_calibrate_work()
2457 ah->ah_cal_next_full = jiffies + in ath5k_calibrate_work()
2459 ah->ah_cal_mask |= AR5K_CALIBRATION_FULL; in ath5k_calibrate_work()
2461 ATH5K_DBG(ah, ATH5K_DEBUG_CALIBRATE, in ath5k_calibrate_work()
2464 if (ath5k_hw_gainf_calibrate(ah) == AR5K_RFGAIN_NEED_CHANGE) { in ath5k_calibrate_work()
2469 ATH5K_DBG(ah, ATH5K_DEBUG_RESET, in ath5k_calibrate_work()
2471 ieee80211_queue_work(ah->hw, &ah->reset_work); in ath5k_calibrate_work()
2474 ah->ah_cal_mask |= AR5K_CALIBRATION_SHORT; in ath5k_calibrate_work()
2477 ATH5K_DBG(ah, ATH5K_DEBUG_CALIBRATE, "channel %u/%x\n", in ath5k_calibrate_work()
2478 ieee80211_frequency_to_channel(ah->curchan->center_freq), in ath5k_calibrate_work()
2479 ah->curchan->hw_value); in ath5k_calibrate_work()
2481 if (ath5k_hw_phy_calibrate(ah, ah->curchan)) in ath5k_calibrate_work()
2482 ATH5K_ERR(ah, "calibration of channel %u failed\n", in ath5k_calibrate_work()
2484 ah->curchan->center_freq)); in ath5k_calibrate_work()
2487 if (ah->ah_cal_mask & AR5K_CALIBRATION_FULL) in ath5k_calibrate_work()
2488 ah->ah_cal_mask &= ~AR5K_CALIBRATION_FULL; in ath5k_calibrate_work()
2489 else if (ah->ah_cal_mask & AR5K_CALIBRATION_SHORT) in ath5k_calibrate_work()
2490 ah->ah_cal_mask &= ~AR5K_CALIBRATION_SHORT; in ath5k_calibrate_work()
2497 struct ath5k_hw *ah = from_tasklet(ah, t, ani_tasklet); in ath5k_tasklet_ani() local
2499 ah->ah_cal_mask |= AR5K_CALIBRATION_ANI; in ath5k_tasklet_ani()
2500 ath5k_ani_calibration(ah); in ath5k_tasklet_ani()
2501 ah->ah_cal_mask &= ~AR5K_CALIBRATION_ANI; in ath5k_tasklet_ani()
2508 struct ath5k_hw *ah = container_of(work, struct ath5k_hw, in ath5k_tx_complete_poll_work() local
2514 if (!test_bit(ATH_STAT_STARTED, ah->status)) in ath5k_tx_complete_poll_work()
2517 mutex_lock(&ah->lock); in ath5k_tx_complete_poll_work()
2519 for (i = 0; i < ARRAY_SIZE(ah->txqs); i++) { in ath5k_tx_complete_poll_work()
2520 if (ah->txqs[i].setup) { in ath5k_tx_complete_poll_work()
2521 txq = &ah->txqs[i]; in ath5k_tx_complete_poll_work()
2525 ATH5K_DBG(ah, ATH5K_DEBUG_XMIT, in ath5k_tx_complete_poll_work()
2541 ATH5K_DBG(ah, ATH5K_DEBUG_RESET, in ath5k_tx_complete_poll_work()
2543 ath5k_reset(ah, NULL, true); in ath5k_tx_complete_poll_work()
2546 mutex_unlock(&ah->lock); in ath5k_tx_complete_poll_work()
2548 ieee80211_queue_delayed_work(ah->hw, &ah->tx_complete_work, in ath5k_tx_complete_poll_work()
2574 ath5k_init_ah(struct ath5k_hw *ah, const struct ath_bus_ops *bus_ops) in ath5k_init_ah() argument
2576 struct ieee80211_hw *hw = ah->hw; in ath5k_init_ah()
2582 SET_IEEE80211_DEV(hw, ah->dev); in ath5k_init_ah()
2616 __set_bit(ATH_STAT_INVALID, ah->status); in ath5k_init_ah()
2618 ah->opmode = NL80211_IFTYPE_STATION; in ath5k_init_ah()
2619 ah->bintval = 1000; in ath5k_init_ah()
2620 mutex_init(&ah->lock); in ath5k_init_ah()
2621 spin_lock_init(&ah->rxbuflock); in ath5k_init_ah()
2622 spin_lock_init(&ah->txbuflock); in ath5k_init_ah()
2623 spin_lock_init(&ah->block); in ath5k_init_ah()
2624 spin_lock_init(&ah->irqlock); in ath5k_init_ah()
2627 ret = request_irq(ah->irq, ath5k_intr, IRQF_SHARED, "ath", ah); in ath5k_init_ah()
2629 ATH5K_ERR(ah, "request_irq failed\n"); in ath5k_init_ah()
2633 common = ath5k_hw_common(ah); in ath5k_init_ah()
2636 common->ah = ah; in ath5k_init_ah()
2638 common->priv = ah; in ath5k_init_ah()
2651 ret = ath5k_hw_init(ah); in ath5k_init_ah()
2656 if (ah->ah_capabilities.cap_has_mrr_support) { in ath5k_init_ah()
2669 ATH5K_INFO(ah, "Atheros AR%s chip found (MAC: 0x%x, PHY: 0x%x)\n", in ath5k_init_ah()
2670 ath5k_chip_name(AR5K_VERSION_MAC, ah->ah_mac_srev), in ath5k_init_ah()
2671 ah->ah_mac_srev, in ath5k_init_ah()
2672 ah->ah_phy_revision); in ath5k_init_ah()
2674 if (!ah->ah_single_chip) { in ath5k_init_ah()
2676 if (ah->ah_radio_5ghz_revision && in ath5k_init_ah()
2677 !ah->ah_radio_2ghz_revision) { in ath5k_init_ah()
2680 ah->ah_capabilities.cap_mode)) { in ath5k_init_ah()
2681 ATH5K_INFO(ah, "RF%s 2GHz radio found (0x%x)\n", in ath5k_init_ah()
2683 ah->ah_radio_5ghz_revision), in ath5k_init_ah()
2684 ah->ah_radio_5ghz_revision); in ath5k_init_ah()
2688 ah->ah_capabilities.cap_mode)) { in ath5k_init_ah()
2689 ATH5K_INFO(ah, "RF%s 5GHz radio found (0x%x)\n", in ath5k_init_ah()
2691 ah->ah_radio_5ghz_revision), in ath5k_init_ah()
2692 ah->ah_radio_5ghz_revision); in ath5k_init_ah()
2695 ATH5K_INFO(ah, "RF%s multiband radio found" in ath5k_init_ah()
2698 ah->ah_radio_5ghz_revision), in ath5k_init_ah()
2699 ah->ah_radio_5ghz_revision); in ath5k_init_ah()
2704 else if (ah->ah_radio_5ghz_revision && in ath5k_init_ah()
2705 ah->ah_radio_2ghz_revision) { in ath5k_init_ah()
2706 ATH5K_INFO(ah, "RF%s 5GHz radio found (0x%x)\n", in ath5k_init_ah()
2708 ah->ah_radio_5ghz_revision), in ath5k_init_ah()
2709 ah->ah_radio_5ghz_revision); in ath5k_init_ah()
2710 ATH5K_INFO(ah, "RF%s 2GHz radio found (0x%x)\n", in ath5k_init_ah()
2712 ah->ah_radio_2ghz_revision), in ath5k_init_ah()
2713 ah->ah_radio_2ghz_revision); in ath5k_init_ah()
2717 ath5k_debug_init_device(ah); in ath5k_init_ah()
2720 __clear_bit(ATH_STAT_INVALID, ah->status); in ath5k_init_ah()
2724 ath5k_hw_deinit(ah); in ath5k_init_ah()
2726 free_irq(ah->irq, ah); in ath5k_init_ah()
2732 ath5k_stop_locked(struct ath5k_hw *ah) in ath5k_stop_locked() argument
2735 ATH5K_DBG(ah, ATH5K_DEBUG_RESET, "invalid %u\n", in ath5k_stop_locked()
2736 test_bit(ATH_STAT_INVALID, ah->status)); in ath5k_stop_locked()
2753 ieee80211_stop_queues(ah->hw); in ath5k_stop_locked()
2755 if (!test_bit(ATH_STAT_INVALID, ah->status)) { in ath5k_stop_locked()
2756 ath5k_led_off(ah); in ath5k_stop_locked()
2757 ath5k_hw_set_imr(ah, 0); in ath5k_stop_locked()
2758 synchronize_irq(ah->irq); in ath5k_stop_locked()
2759 ath5k_rx_stop(ah); in ath5k_stop_locked()
2760 ath5k_hw_dma_stop(ah); in ath5k_stop_locked()
2761 ath5k_drain_tx_buffs(ah); in ath5k_stop_locked()
2762 ath5k_hw_phy_disable(ah); in ath5k_stop_locked()
2770 struct ath5k_hw *ah = hw->priv; in ath5k_start() local
2771 struct ath_common *common = ath5k_hw_common(ah); in ath5k_start()
2774 mutex_lock(&ah->lock); in ath5k_start()
2776 ATH5K_DBG(ah, ATH5K_DEBUG_RESET, "mode %d\n", ah->opmode); in ath5k_start()
2782 ath5k_stop_locked(ah); in ath5k_start()
2791 ah->curchan = ah->hw->conf.chandef.chan; in ath5k_start()
2792 ah->imask = AR5K_INT_RXOK in ath5k_start()
2802 ret = ath5k_reset(ah, NULL, false); in ath5k_start()
2807 ath5k_rfkill_hw_start(ah); in ath5k_start()
2818 ah->ah_ack_bitrate_high = true; in ath5k_start()
2820 for (i = 0; i < ARRAY_SIZE(ah->bslot); i++) in ath5k_start()
2821 ah->bslot[i] = NULL; in ath5k_start()
2825 mutex_unlock(&ah->lock); in ath5k_start()
2827 set_bit(ATH_STAT_STARTED, ah->status); in ath5k_start()
2828 ieee80211_queue_delayed_work(ah->hw, &ah->tx_complete_work, in ath5k_start()
2834 static void ath5k_stop_tasklets(struct ath5k_hw *ah) in ath5k_stop_tasklets() argument
2836 ah->rx_pending = false; in ath5k_stop_tasklets()
2837 ah->tx_pending = false; in ath5k_stop_tasklets()
2838 tasklet_kill(&ah->rxtq); in ath5k_stop_tasklets()
2839 tasklet_kill(&ah->txtq); in ath5k_stop_tasklets()
2840 tasklet_kill(&ah->beacontq); in ath5k_stop_tasklets()
2841 tasklet_kill(&ah->ani_tasklet); in ath5k_stop_tasklets()
2852 struct ath5k_hw *ah = hw->priv; in ath5k_stop() local
2855 mutex_lock(&ah->lock); in ath5k_stop()
2856 ret = ath5k_stop_locked(ah); in ath5k_stop()
2857 if (ret == 0 && !test_bit(ATH_STAT_INVALID, ah->status)) { in ath5k_stop()
2878 ret = ath5k_hw_on_hold(ah); in ath5k_stop()
2880 ATH5K_DBG(ah, ATH5K_DEBUG_RESET, in ath5k_stop()
2884 mutex_unlock(&ah->lock); in ath5k_stop()
2886 ath5k_stop_tasklets(ah); in ath5k_stop()
2888 clear_bit(ATH_STAT_STARTED, ah->status); in ath5k_stop()
2889 cancel_delayed_work_sync(&ah->tx_complete_work); in ath5k_stop()
2892 ath5k_rfkill_hw_stop(ah); in ath5k_stop()
2902 ath5k_reset(struct ath5k_hw *ah, struct ieee80211_channel *chan, in ath5k_reset() argument
2905 struct ath_common *common = ath5k_hw_common(ah); in ath5k_reset()
2909 ATH5K_DBG(ah, ATH5K_DEBUG_RESET, "resetting\n"); in ath5k_reset()
2911 __set_bit(ATH_STAT_RESET, ah->status); in ath5k_reset()
2913 ath5k_hw_set_imr(ah, 0); in ath5k_reset()
2914 synchronize_irq(ah->irq); in ath5k_reset()
2915 ath5k_stop_tasklets(ah); in ath5k_reset()
2920 ani_mode = ah->ani_state.ani_mode; in ath5k_reset()
2921 ath5k_ani_init(ah, ATH5K_ANI_MODE_OFF); in ath5k_reset()
2926 ath5k_drain_tx_buffs(ah); in ath5k_reset()
2929 ath5k_hw_stop_rx_pcu(ah); in ath5k_reset()
2936 ret = ath5k_hw_dma_stop(ah); in ath5k_reset()
2942 ATH5K_DBG(ah, ATH5K_DEBUG_RESET, in ath5k_reset()
2948 ah->curchan = chan; in ath5k_reset()
2950 ret = ath5k_hw_reset(ah, ah->opmode, ah->curchan, fast, skip_pcu); in ath5k_reset()
2952 ATH5K_ERR(ah, "can't reset hardware (%d)\n", ret); in ath5k_reset()
2956 ret = ath5k_rx_start(ah); in ath5k_reset()
2958 ATH5K_ERR(ah, "can't start recv logic\n"); in ath5k_reset()
2962 ath5k_ani_init(ah, ani_mode); in ath5k_reset()
2975 ah->ah_cal_next_full = jiffies + in ath5k_reset()
2977 ah->ah_cal_next_ani = jiffies + in ath5k_reset()
2979 ah->ah_cal_next_short = jiffies + in ath5k_reset()
2982 ewma_beacon_rssi_init(&ah->ah_beacon_rssi_avg); in ath5k_reset()
2985 memset(&ah->survey, 0, sizeof(ah->survey)); in ath5k_reset()
3003 __clear_bit(ATH_STAT_RESET, ah->status); in ath5k_reset()
3005 ath5k_beacon_config(ah); in ath5k_reset()
3008 ieee80211_wake_queues(ah->hw); in ath5k_reset()
3017 struct ath5k_hw *ah = container_of(work, struct ath5k_hw, in ath5k_reset_work() local
3020 mutex_lock(&ah->lock); in ath5k_reset_work()
3021 ath5k_reset(ah, NULL, true); in ath5k_reset_work()
3022 mutex_unlock(&ah->lock); in ath5k_reset_work()
3029 struct ath5k_hw *ah = hw->priv; in ath5k_init() local
3030 struct ath_regulatory *regulatory = ath5k_hw_regulatory(ah); in ath5k_init()
3044 ATH5K_ERR(ah, "can't get channels\n"); in ath5k_init()
3051 ret = ath5k_desc_alloc(ah); in ath5k_init()
3053 ATH5K_ERR(ah, "can't allocate descriptors\n"); in ath5k_init()
3063 ret = ath5k_beaconq_setup(ah); in ath5k_init()
3065 ATH5K_ERR(ah, "can't setup a beacon xmit queue\n"); in ath5k_init()
3068 ah->bhalq = ret; in ath5k_init()
3069 ah->cabq = ath5k_txq_setup(ah, AR5K_TX_QUEUE_CAB, 0); in ath5k_init()
3070 if (IS_ERR(ah->cabq)) { in ath5k_init()
3071 ATH5K_ERR(ah, "can't setup cab queue\n"); in ath5k_init()
3072 ret = PTR_ERR(ah->cabq); in ath5k_init()
3078 if (ah->ah_capabilities.cap_queues.q_tx_num >= 6) { in ath5k_init()
3081 txq = ath5k_txq_setup(ah, AR5K_TX_QUEUE_DATA, AR5K_WME_AC_VO); in ath5k_init()
3083 ATH5K_ERR(ah, "can't setup xmit queue\n"); in ath5k_init()
3087 txq = ath5k_txq_setup(ah, AR5K_TX_QUEUE_DATA, AR5K_WME_AC_VI); in ath5k_init()
3089 ATH5K_ERR(ah, "can't setup xmit queue\n"); in ath5k_init()
3093 txq = ath5k_txq_setup(ah, AR5K_TX_QUEUE_DATA, AR5K_WME_AC_BE); in ath5k_init()
3095 ATH5K_ERR(ah, "can't setup xmit queue\n"); in ath5k_init()
3099 txq = ath5k_txq_setup(ah, AR5K_TX_QUEUE_DATA, AR5K_WME_AC_BK); in ath5k_init()
3101 ATH5K_ERR(ah, "can't setup xmit queue\n"); in ath5k_init()
3108 txq = ath5k_txq_setup(ah, AR5K_TX_QUEUE_DATA, AR5K_WME_AC_BE); in ath5k_init()
3110 ATH5K_ERR(ah, "can't setup xmit queue\n"); in ath5k_init()
3117 tasklet_setup(&ah->rxtq, ath5k_tasklet_rx); in ath5k_init()
3118 tasklet_setup(&ah->txtq, ath5k_tasklet_tx); in ath5k_init()
3119 tasklet_setup(&ah->beacontq, ath5k_tasklet_beacon); in ath5k_init()
3120 tasklet_setup(&ah->ani_tasklet, ath5k_tasklet_ani); in ath5k_init()
3122 INIT_WORK(&ah->reset_work, ath5k_reset_work); in ath5k_init()
3123 INIT_WORK(&ah->calib_work, ath5k_calibrate_work); in ath5k_init()
3124 INIT_DELAYED_WORK(&ah->tx_complete_work, ath5k_tx_complete_poll_work); in ath5k_init()
3126 ret = ath5k_hw_common(ah)->bus_ops->eeprom_read_mac(ah, mac); in ath5k_init()
3128 ATH5K_ERR(ah, "unable to read address from EEPROM\n"); in ath5k_init()
3134 ath5k_update_bssid_mask_and_opmode(ah, NULL); in ath5k_init()
3136 regulatory->current_rd = ah->ah_capabilities.cap_eeprom.ee_regdomain; in ath5k_init()
3139 ATH5K_ERR(ah, "can't initialize regulatory system\n"); in ath5k_init()
3145 ATH5K_ERR(ah, "can't register ieee80211 hw\n"); in ath5k_init()
3152 ath5k_init_leds(ah); in ath5k_init()
3154 ath5k_sysfs_register(ah); in ath5k_init()
3158 ath5k_txq_release(ah); in ath5k_init()
3160 ath5k_hw_release_tx_queue(ah, ah->bhalq); in ath5k_init()
3162 ath5k_desc_free(ah); in ath5k_init()
3168 ath5k_deinit_ah(struct ath5k_hw *ah) in ath5k_deinit_ah() argument
3170 struct ieee80211_hw *hw = ah->hw; in ath5k_deinit_ah()
3186 ath5k_desc_free(ah); in ath5k_deinit_ah()
3187 ath5k_txq_release(ah); in ath5k_deinit_ah()
3188 ath5k_hw_release_tx_queue(ah, ah->bhalq); in ath5k_deinit_ah()
3189 ath5k_unregister_leds(ah); in ath5k_deinit_ah()
3191 ath5k_sysfs_unregister(ah); in ath5k_deinit_ah()
3197 ath5k_hw_deinit(ah); in ath5k_deinit_ah()
3198 free_irq(ah->irq, ah); in ath5k_deinit_ah()
3202 ath5k_any_vif_assoc(struct ath5k_hw *ah) in ath5k_any_vif_assoc() argument
3211 ah->hw, IEEE80211_IFACE_ITER_RESUME_ALL, in ath5k_any_vif_assoc()
3219 struct ath5k_hw *ah = hw->priv; in ath5k_set_beacon_filter() local
3221 rfilt = ath5k_hw_get_rx_filter(ah); in ath5k_set_beacon_filter()
3226 ath5k_hw_set_rx_filter(ah, rfilt); in ath5k_set_beacon_filter()
3227 ah->filter_flags = rfilt; in ath5k_set_beacon_filter()
3230 void _ath5k_printk(const struct ath5k_hw *ah, const char *level, in _ath5k_printk() argument
3241 if (ah && ah->hw) in _ath5k_printk()
3243 level, wiphy_name(ah->hw->wiphy), &vaf); in _ath5k_printk()