Lines Matching refs:ar

184 static void carl9170_ampdu_gc(struct ar9170 *ar)  in carl9170_ampdu_gc()  argument
190 list_for_each_entry_rcu(tid_info, &ar->tx_ampdu_list, list) { in carl9170_ampdu_gc()
191 spin_lock_bh(&ar->tx_ampdu_list_lock); in carl9170_ampdu_gc()
195 ar->tx_ampdu_list_len--; in carl9170_ampdu_gc()
198 spin_unlock_bh(&ar->tx_ampdu_list_lock); in carl9170_ampdu_gc()
201 rcu_assign_pointer(ar->tx_ampdu_iter, tid_info); in carl9170_ampdu_gc()
212 carl9170_tx_status(ar, skb, false); in carl9170_ampdu_gc()
219 static void carl9170_flush(struct ar9170 *ar, bool drop_queued) in carl9170_flush() argument
229 for (i = 0; i < ar->hw->queues; i++) { in carl9170_flush()
232 while ((skb = skb_dequeue(&ar->tx_pending[i]))) { in carl9170_flush()
237 atomic_dec(&ar->tx_ampdu_upload); in carl9170_flush()
239 carl9170_tx_status(ar, skb, false); in carl9170_flush()
245 if (atomic_read(&ar->tx_total_queued)) in carl9170_flush()
246 WARN_ON(wait_for_completion_timeout(&ar->tx_flush, HZ) == 0); in carl9170_flush()
249 static void carl9170_flush_ba(struct ar9170 *ar) in carl9170_flush_ba() argument
258 spin_lock_bh(&ar->tx_ampdu_list_lock); in carl9170_flush_ba()
259 list_for_each_entry_rcu(tid_info, &ar->tx_ampdu_list, list) { in carl9170_flush_ba()
269 spin_unlock_bh(&ar->tx_ampdu_list_lock); in carl9170_flush_ba()
273 carl9170_tx_status(ar, skb, false); in carl9170_flush_ba()
276 static void carl9170_zap_queues(struct ar9170 *ar) in carl9170_zap_queues() argument
281 carl9170_ampdu_gc(ar); in carl9170_zap_queues()
283 carl9170_flush_ba(ar); in carl9170_zap_queues()
284 carl9170_flush(ar, true); in carl9170_zap_queues()
286 for (i = 0; i < ar->hw->queues; i++) { in carl9170_zap_queues()
287 spin_lock_bh(&ar->tx_status[i].lock); in carl9170_zap_queues()
288 while (!skb_queue_empty(&ar->tx_status[i])) { in carl9170_zap_queues()
291 skb = skb_peek(&ar->tx_status[i]); in carl9170_zap_queues()
293 spin_unlock_bh(&ar->tx_status[i].lock); in carl9170_zap_queues()
294 carl9170_tx_drop(ar, skb); in carl9170_zap_queues()
295 spin_lock_bh(&ar->tx_status[i].lock); in carl9170_zap_queues()
298 spin_unlock_bh(&ar->tx_status[i].lock); in carl9170_zap_queues()
306 memset(&ar->tx_stats, 0, sizeof(ar->tx_stats)); in carl9170_zap_queues()
307 for (i = 0; i < ar->hw->queues; i++) in carl9170_zap_queues()
308 ar->tx_stats[i].limit = CARL9170_NUM_TX_LIMIT_HARD; in carl9170_zap_queues()
310 for (i = 0; i < DIV_ROUND_UP(ar->fw.mem_blocks, BITS_PER_LONG); i++) in carl9170_zap_queues()
311 ar->mem_bitmap[i] = 0; in carl9170_zap_queues()
314 list_for_each_entry_rcu(cvif, &ar->vif_list, list) { in carl9170_zap_queues()
315 spin_lock_bh(&ar->beacon_lock); in carl9170_zap_queues()
318 spin_unlock_bh(&ar->beacon_lock); in carl9170_zap_queues()
322 atomic_set(&ar->tx_ampdu_upload, 0); in carl9170_zap_queues()
323 atomic_set(&ar->tx_ampdu_scheduler, 0); in carl9170_zap_queues()
324 atomic_set(&ar->tx_total_pending, 0); in carl9170_zap_queues()
325 atomic_set(&ar->tx_total_queued, 0); in carl9170_zap_queues()
326 atomic_set(&ar->mem_free_blocks, ar->fw.mem_blocks); in carl9170_zap_queues()
339 struct ar9170 *ar = hw->priv; in carl9170_op_start() local
342 mutex_lock(&ar->mutex); in carl9170_op_start()
344 carl9170_zap_queues(ar); in carl9170_op_start()
347 CARL9170_FILL_QUEUE(ar->edcf[AR9170_TXQ_VO], 2, 3, 7, 47); in carl9170_op_start()
348 CARL9170_FILL_QUEUE(ar->edcf[AR9170_TXQ_VI], 2, 7, 15, 94); in carl9170_op_start()
349 CARL9170_FILL_QUEUE(ar->edcf[AR9170_TXQ_BE], 3, 15, 1023, 0); in carl9170_op_start()
350 CARL9170_FILL_QUEUE(ar->edcf[AR9170_TXQ_BK], 7, 15, 1023, 0); in carl9170_op_start()
351 CARL9170_FILL_QUEUE(ar->edcf[AR9170_TXQ_SPECIAL], 2, 3, 7, 0); in carl9170_op_start()
353 ar->current_factor = ar->current_density = -1; in carl9170_op_start()
355 ar->usedkeys = 1; in carl9170_op_start()
356 ar->filter_state = 0; in carl9170_op_start()
357 ar->ps.last_action = jiffies; in carl9170_op_start()
358 ar->ps.last_slept = jiffies; in carl9170_op_start()
359 ar->erp_mode = CARL9170_ERP_AUTO; in carl9170_op_start()
364 ar->disable_offload = modparam_nohwcrypt | in carl9170_op_start()
365 ar->fw.disable_offload_fw; in carl9170_op_start()
366 ar->rx_software_decryption = ar->disable_offload; in carl9170_op_start()
368 for (i = 0; i < ar->hw->queues; i++) { in carl9170_op_start()
369 ar->queue_stop_timeout[i] = jiffies; in carl9170_op_start()
370 ar->max_queue_stop_timeout[i] = 0; in carl9170_op_start()
373 atomic_set(&ar->mem_allocs, 0); in carl9170_op_start()
375 err = carl9170_usb_open(ar); in carl9170_op_start()
379 err = carl9170_init_mac(ar); in carl9170_op_start()
383 err = carl9170_set_qos(ar); in carl9170_op_start()
387 if (ar->fw.rx_filter) { in carl9170_op_start()
388 err = carl9170_rx_filter(ar, CARL9170_RX_FILTER_OTHER_RA | in carl9170_op_start()
394 err = carl9170_write_reg(ar, AR9170_MAC_REG_DMA_TRIGGER, in carl9170_op_start()
401 err = carl9170_upload_key(ar, i, NULL, AR9170_ENC_ALG_NONE, in carl9170_op_start()
406 err = carl9170_upload_key(ar, i, NULL, AR9170_ENC_ALG_NONE, in carl9170_op_start()
412 err = carl9170_disable_key(ar, i); in carl9170_op_start()
418 carl9170_set_state_when(ar, CARL9170_IDLE, CARL9170_STARTED); in carl9170_op_start()
420 ieee80211_queue_delayed_work(ar->hw, &ar->stat_work, in carl9170_op_start()
423 ieee80211_wake_queues(ar->hw); in carl9170_op_start()
427 mutex_unlock(&ar->mutex); in carl9170_op_start()
431 static void carl9170_cancel_worker(struct ar9170 *ar) in carl9170_cancel_worker() argument
433 cancel_delayed_work_sync(&ar->stat_work); in carl9170_cancel_worker()
434 cancel_delayed_work_sync(&ar->tx_janitor); in carl9170_cancel_worker()
436 cancel_delayed_work_sync(&ar->led_work); in carl9170_cancel_worker()
438 cancel_work_sync(&ar->ps_work); in carl9170_cancel_worker()
439 cancel_work_sync(&ar->ping_work); in carl9170_cancel_worker()
440 cancel_work_sync(&ar->ampdu_work); in carl9170_cancel_worker()
445 struct ar9170 *ar = hw->priv; in carl9170_op_stop() local
447 carl9170_set_state_when(ar, CARL9170_STARTED, CARL9170_IDLE); in carl9170_op_stop()
449 ieee80211_stop_queues(ar->hw); in carl9170_op_stop()
451 mutex_lock(&ar->mutex); in carl9170_op_stop()
452 if (IS_ACCEPTING_CMD(ar)) { in carl9170_op_stop()
453 RCU_INIT_POINTER(ar->beacon_iter, NULL); in carl9170_op_stop()
455 carl9170_led_set_state(ar, 0); in carl9170_op_stop()
458 carl9170_write_reg(ar, AR9170_MAC_REG_DMA_TRIGGER, 0); in carl9170_op_stop()
459 carl9170_usb_stop(ar); in carl9170_op_stop()
462 carl9170_zap_queues(ar); in carl9170_op_stop()
463 mutex_unlock(&ar->mutex); in carl9170_op_stop()
465 carl9170_cancel_worker(ar); in carl9170_op_stop()
470 struct ar9170 *ar = container_of(work, struct ar9170, in carl9170_restart_work() local
474 ar->usedkeys = 0; in carl9170_restart_work()
475 ar->filter_state = 0; in carl9170_restart_work()
476 carl9170_cancel_worker(ar); in carl9170_restart_work()
478 mutex_lock(&ar->mutex); in carl9170_restart_work()
479 if (!ar->force_usb_reset) { in carl9170_restart_work()
480 err = carl9170_usb_restart(ar); in carl9170_restart_work()
483 dev_err(&ar->udev->dev, "Failed to restart device (%d).\n", err); in carl9170_restart_work()
485 dev_info(&ar->udev->dev, "device restarted successfully.\n"); in carl9170_restart_work()
488 carl9170_zap_queues(ar); in carl9170_restart_work()
489 mutex_unlock(&ar->mutex); in carl9170_restart_work()
491 if (!err && !ar->force_usb_reset) { in carl9170_restart_work()
492 ar->restart_counter++; in carl9170_restart_work()
493 atomic_set(&ar->pending_restarts, 0); in carl9170_restart_work()
495 ieee80211_restart_hw(ar->hw); in carl9170_restart_work()
503 carl9170_usb_reset(ar); in carl9170_restart_work()
507 void carl9170_restart(struct ar9170 *ar, const enum carl9170_restart_reasons r) in carl9170_restart() argument
509 carl9170_set_state_when(ar, CARL9170_STARTED, CARL9170_IDLE); in carl9170_restart()
516 if (atomic_inc_return(&ar->pending_restarts) > 1) { in carl9170_restart()
517 dev_dbg(&ar->udev->dev, "ignoring restart (%d)\n", r); in carl9170_restart()
521 ieee80211_stop_queues(ar->hw); in carl9170_restart()
523 dev_err(&ar->udev->dev, "restart device (%d)\n", r); in carl9170_restart()
527 ar->last_reason = r; in carl9170_restart()
529 if (!ar->registered) in carl9170_restart()
532 if (!IS_ACCEPTING_CMD(ar) || ar->needs_full_reset) in carl9170_restart()
533 ar->force_usb_reset = true; in carl9170_restart()
535 ieee80211_queue_work(ar->hw, &ar->restart_work); in carl9170_restart()
546 struct ar9170 *ar = container_of(work, struct ar9170, ping_work); in carl9170_ping_work() local
549 if (!IS_STARTED(ar)) in carl9170_ping_work()
552 mutex_lock(&ar->mutex); in carl9170_ping_work()
553 err = carl9170_echo_test(ar, 0xdeadbeef); in carl9170_ping_work()
555 carl9170_restart(ar, CARL9170_RR_UNRESPONSIVE_DEVICE); in carl9170_ping_work()
556 mutex_unlock(&ar->mutex); in carl9170_ping_work()
559 static int carl9170_init_interface(struct ar9170 *ar, in carl9170_init_interface() argument
562 struct ath_common *common = &ar->common; in carl9170_init_interface()
566 WARN_ON_ONCE(IS_STARTED(ar)); in carl9170_init_interface()
582 ar->disable_offload |= ((vif->type != NL80211_IFTYPE_STATION) && in carl9170_init_interface()
590 ar->disable_offload |= vif->p2p; in carl9170_init_interface()
592 ar->rx_software_decryption = ar->disable_offload; in carl9170_init_interface()
594 err = carl9170_set_operating_mode(ar); in carl9170_init_interface()
603 struct ar9170 *ar = hw->priv; in carl9170_op_add_interface() local
606 mutex_lock(&ar->mutex); in carl9170_op_add_interface()
616 spin_lock_bh(&ar->beacon_lock); in carl9170_op_add_interface()
619 spin_unlock_bh(&ar->beacon_lock); in carl9170_op_add_interface()
633 main_vif = carl9170_get_main_vif(ar); in carl9170_op_add_interface()
663 vif_id = bitmap_find_free_region(&ar->vif_bitmap, ar->fw.vif_num, 0); in carl9170_op_add_interface()
672 BUG_ON(ar->vif_priv[vif_id].id != vif_id); in carl9170_op_add_interface()
677 ar->vifs++; in carl9170_op_add_interface()
683 list_add_rcu(&vif_priv->list, &ar->vif_list); in carl9170_op_add_interface()
688 list_add_tail_rcu(&vif_priv->list, &ar->vif_list); in carl9170_op_add_interface()
690 rcu_assign_pointer(ar->vif_priv[vif_id].vif, vif); in carl9170_op_add_interface()
693 main_vif = carl9170_get_main_vif(ar); in carl9170_op_add_interface()
696 rcu_assign_pointer(ar->beacon_iter, vif_priv); in carl9170_op_add_interface()
707 err = carl9170_mod_virtual_mac(ar, old_main_priv->id, in carl9170_op_add_interface()
713 err = carl9170_init_interface(ar, vif); in carl9170_op_add_interface()
718 err = carl9170_mod_virtual_mac(ar, vif_id, vif->addr); in carl9170_op_add_interface()
724 if (ar->fw.tx_seq_table) { in carl9170_op_add_interface()
725 err = carl9170_write_reg(ar, ar->fw.tx_seq_table + vif_id * 4, in carl9170_op_add_interface()
734 bitmap_release_region(&ar->vif_bitmap, vif_id, 0); in carl9170_op_add_interface()
735 ar->vifs--; in carl9170_op_add_interface()
736 RCU_INIT_POINTER(ar->vif_priv[vif_id].vif, NULL); in carl9170_op_add_interface()
738 mutex_unlock(&ar->mutex); in carl9170_op_add_interface()
741 if (ar->vifs > 1) in carl9170_op_add_interface()
742 ar->ps.off_override |= PS_OFF_VIF; in carl9170_op_add_interface()
744 mutex_unlock(&ar->mutex); in carl9170_op_add_interface()
755 struct ar9170 *ar = hw->priv; in carl9170_op_remove_interface() local
758 mutex_lock(&ar->mutex); in carl9170_op_remove_interface()
763 ar->vifs--; in carl9170_op_remove_interface()
766 main_vif = carl9170_get_main_vif(ar); in carl9170_op_remove_interface()
774 RCU_INIT_POINTER(ar->vif_priv[id].vif, NULL); in carl9170_op_remove_interface()
779 if (ar->vifs) { in carl9170_op_remove_interface()
780 WARN_ON(carl9170_init_interface(ar, in carl9170_op_remove_interface()
781 carl9170_get_main_vif(ar))); in carl9170_op_remove_interface()
783 carl9170_set_operating_mode(ar); in carl9170_op_remove_interface()
788 WARN_ON(carl9170_mod_virtual_mac(ar, id, NULL)); in carl9170_op_remove_interface()
791 carl9170_update_beacon(ar, false); in carl9170_op_remove_interface()
792 carl9170_flush_cab(ar, id); in carl9170_op_remove_interface()
794 spin_lock_bh(&ar->beacon_lock); in carl9170_op_remove_interface()
797 spin_unlock_bh(&ar->beacon_lock); in carl9170_op_remove_interface()
799 bitmap_release_region(&ar->vif_bitmap, id, 0); in carl9170_op_remove_interface()
801 carl9170_set_beacon_timers(ar); in carl9170_op_remove_interface()
803 if (ar->vifs == 1) in carl9170_op_remove_interface()
804 ar->ps.off_override &= ~PS_OFF_VIF; in carl9170_op_remove_interface()
807 mutex_unlock(&ar->mutex); in carl9170_op_remove_interface()
812 void carl9170_ps_check(struct ar9170 *ar) in carl9170_ps_check() argument
814 ieee80211_queue_work(ar->hw, &ar->ps_work); in carl9170_ps_check()
818 static int carl9170_ps_update(struct ar9170 *ar) in carl9170_ps_update() argument
823 if (!ar->ps.off_override) in carl9170_ps_update()
824 ps = (ar->hw->conf.flags & IEEE80211_CONF_PS); in carl9170_ps_update()
826 if (ps != ar->ps.state) { in carl9170_ps_update()
827 err = carl9170_powersave(ar, ps); in carl9170_ps_update()
831 if (ar->ps.state && !ps) { in carl9170_ps_update()
832 ar->ps.sleep_ms = jiffies_to_msecs(jiffies - in carl9170_ps_update()
833 ar->ps.last_action); in carl9170_ps_update()
837 ar->ps.last_slept = jiffies; in carl9170_ps_update()
839 ar->ps.last_action = jiffies; in carl9170_ps_update()
840 ar->ps.state = ps; in carl9170_ps_update()
848 struct ar9170 *ar = container_of(work, struct ar9170, in carl9170_ps_work() local
850 mutex_lock(&ar->mutex); in carl9170_ps_work()
851 if (IS_STARTED(ar)) in carl9170_ps_work()
852 WARN_ON_ONCE(carl9170_ps_update(ar) != 0); in carl9170_ps_work()
853 mutex_unlock(&ar->mutex); in carl9170_ps_work()
856 static int carl9170_update_survey(struct ar9170 *ar, bool flush, bool noise) in carl9170_update_survey() argument
861 err = carl9170_get_noisefloor(ar); in carl9170_update_survey()
866 if (ar->fw.hw_counters) { in carl9170_update_survey()
867 err = carl9170_collect_tally(ar); in carl9170_update_survey()
873 memset(&ar->tally, 0, sizeof(ar->tally)); in carl9170_update_survey()
880 struct ar9170 *ar = container_of(work, struct ar9170, stat_work.work); in carl9170_stat_work() local
883 mutex_lock(&ar->mutex); in carl9170_stat_work()
884 err = carl9170_update_survey(ar, false, true); in carl9170_stat_work()
885 mutex_unlock(&ar->mutex); in carl9170_stat_work()
890 ieee80211_queue_delayed_work(ar->hw, &ar->stat_work, in carl9170_stat_work()
896 struct ar9170 *ar = hw->priv; in carl9170_op_config() local
899 mutex_lock(&ar->mutex); in carl9170_op_config()
906 err = carl9170_ps_update(ar); in carl9170_op_config()
921 err = carl9170_set_slot_time(ar); in carl9170_op_config()
925 err = carl9170_update_survey(ar, true, false); in carl9170_op_config()
929 err = carl9170_set_channel(ar, hw->conf.chandef.chan, in carl9170_op_config()
934 err = carl9170_update_survey(ar, false, true); in carl9170_op_config()
938 err = carl9170_set_dyn_sifs_ack(ar); in carl9170_op_config()
942 err = carl9170_set_rts_cts_rate(ar); in carl9170_op_config()
948 err = carl9170_set_mac_tpc(ar, ar->hw->conf.chandef.chan); in carl9170_op_config()
954 mutex_unlock(&ar->mutex); in carl9170_op_config()
978 struct ar9170 *ar = hw->priv; in carl9170_op_configure_filter() local
981 *new_flags &= FIF_ALLMULTI | ar->rx_filter_caps; in carl9170_op_configure_filter()
983 if (!IS_ACCEPTING_CMD(ar)) in carl9170_op_configure_filter()
986 mutex_lock(&ar->mutex); in carl9170_op_configure_filter()
988 ar->filter_state = *new_flags; in carl9170_op_configure_filter()
997 if (multicast != ar->cur_mc_hash) in carl9170_op_configure_filter()
998 WARN_ON(carl9170_update_multicast(ar, multicast)); in carl9170_op_configure_filter()
1001 ar->sniffer_enabled = !!(*new_flags & FIF_OTHER_BSS); in carl9170_op_configure_filter()
1003 WARN_ON(carl9170_set_operating_mode(ar)); in carl9170_op_configure_filter()
1006 if (ar->fw.rx_filter && changed_flags & ar->rx_filter_caps) { in carl9170_op_configure_filter()
1009 if (!ar->fw.ba_filter) in carl9170_op_configure_filter()
1026 WARN_ON(carl9170_rx_filter(ar, rx_filter)); in carl9170_op_configure_filter()
1029 mutex_unlock(&ar->mutex); in carl9170_op_configure_filter()
1038 struct ar9170 *ar = hw->priv; in carl9170_op_bss_info_changed() local
1039 struct ath_common *common = &ar->common; in carl9170_op_bss_info_changed()
1044 mutex_lock(&ar->mutex); in carl9170_op_bss_info_changed()
1046 main_vif = carl9170_get_main_vif(ar); in carl9170_op_bss_info_changed()
1056 list_for_each_entry_rcu(iter, &ar->vif_list, list) { in carl9170_op_bss_info_changed()
1063 ar->beacon_enabled = i; in carl9170_op_bss_info_changed()
1067 err = carl9170_update_beacon(ar, false); in carl9170_op_bss_info_changed()
1091 err = carl9170_set_beacon_timers(ar); in carl9170_op_bss_info_changed()
1113 err = carl9170_set_operating_mode(ar); in carl9170_op_bss_info_changed()
1119 ar->common.curaid = bss_conf->aid; in carl9170_op_bss_info_changed()
1120 err = carl9170_set_beacon_timers(ar); in carl9170_op_bss_info_changed()
1126 err = carl9170_set_slot_time(ar); in carl9170_op_bss_info_changed()
1132 err = carl9170_set_mac_rates(ar); in carl9170_op_bss_info_changed()
1138 WARN_ON_ONCE(err && IS_STARTED(ar)); in carl9170_op_bss_info_changed()
1139 mutex_unlock(&ar->mutex); in carl9170_op_bss_info_changed()
1145 struct ar9170 *ar = hw->priv; in carl9170_op_get_tsf() local
1149 mutex_lock(&ar->mutex); in carl9170_op_get_tsf()
1150 err = carl9170_exec_cmd(ar, CARL9170_CMD_READ_TSF, in carl9170_op_get_tsf()
1152 mutex_unlock(&ar->mutex); in carl9170_op_get_tsf()
1164 struct ar9170 *ar = hw->priv; in carl9170_op_set_key() local
1168 if (ar->disable_offload || !vif) in carl9170_op_set_key()
1178 if (!is_main_vif(ar, vif)) { in carl9170_op_set_key()
1179 mutex_lock(&ar->mutex); in carl9170_op_set_key()
1211 mutex_lock(&ar->mutex); in carl9170_op_set_key()
1213 if (!IS_STARTED(ar)) { in carl9170_op_set_key()
1224 if (!(ar->usedkeys & BIT(i))) in carl9170_op_set_key()
1232 err = carl9170_upload_key(ar, i, sta ? sta->addr : NULL, in carl9170_op_set_key()
1239 err = carl9170_upload_key(ar, i, sta ? sta->addr : in carl9170_op_set_key()
1253 ar->usedkeys |= BIT(i); in carl9170_op_set_key()
1257 if (!IS_STARTED(ar)) { in carl9170_op_set_key()
1264 ar->usedkeys &= ~BIT(key->hw_key_idx); in carl9170_op_set_key()
1266 err = carl9170_upload_key(ar, key->hw_key_idx, NULL, in carl9170_op_set_key()
1273 err = carl9170_upload_key(ar, key->hw_key_idx, in carl9170_op_set_key()
1283 err = carl9170_disable_key(ar, key->hw_key_idx); in carl9170_op_set_key()
1289 mutex_unlock(&ar->mutex); in carl9170_op_set_key()
1293 if (!ar->rx_software_decryption) { in carl9170_op_set_key()
1294 ar->rx_software_decryption = true; in carl9170_op_set_key()
1295 carl9170_set_operating_mode(ar); in carl9170_op_set_key()
1297 mutex_unlock(&ar->mutex); in carl9170_op_set_key()
1334 struct ar9170 *ar = hw->priv; in carl9170_op_sta_remove() local
1353 spin_lock_bh(&ar->tx_ampdu_list_lock); in carl9170_op_sta_remove()
1356 spin_unlock_bh(&ar->tx_ampdu_list_lock); in carl9170_op_sta_remove()
1362 carl9170_ampdu_gc(ar); in carl9170_op_sta_remove()
1372 struct ar9170 *ar = hw->priv; in carl9170_op_conf_tx() local
1375 mutex_lock(&ar->mutex); in carl9170_op_conf_tx()
1376 memcpy(&ar->edcf[ar9170_qmap(queue)], param, sizeof(*param)); in carl9170_op_conf_tx()
1377 ret = carl9170_set_qos(ar); in carl9170_op_conf_tx()
1378 mutex_unlock(&ar->mutex); in carl9170_op_conf_tx()
1384 struct ar9170 *ar = container_of(work, struct ar9170, in carl9170_ampdu_work() local
1387 if (!IS_STARTED(ar)) in carl9170_ampdu_work()
1390 mutex_lock(&ar->mutex); in carl9170_ampdu_work()
1391 carl9170_ampdu_gc(ar); in carl9170_ampdu_work()
1392 mutex_unlock(&ar->mutex); in carl9170_ampdu_work()
1403 struct ar9170 *ar = hw->priv; in carl9170_op_ampdu_action() local
1432 spin_lock_bh(&ar->tx_ampdu_list_lock); in carl9170_op_ampdu_action()
1433 ar->tx_ampdu_list_len++; in carl9170_op_ampdu_action()
1434 list_add_tail_rcu(&tid_info->list, &ar->tx_ampdu_list); in carl9170_op_ampdu_action()
1436 spin_unlock_bh(&ar->tx_ampdu_list_lock); in carl9170_op_ampdu_action()
1446 spin_lock_bh(&ar->tx_ampdu_list_lock); in carl9170_op_ampdu_action()
1449 spin_unlock_bh(&ar->tx_ampdu_list_lock); in carl9170_op_ampdu_action()
1456 ieee80211_queue_work(ar->hw, &ar->ampdu_work); in carl9170_op_ampdu_action()
1490 static int carl9170_register_wps_button(struct ar9170 *ar) in carl9170_register_wps_button() argument
1495 if (!(ar->features & CARL9170_WPS_BUTTON)) in carl9170_register_wps_button()
1502 snprintf(ar->wps.name, sizeof(ar->wps.name), "%s WPS Button", in carl9170_register_wps_button()
1503 wiphy_name(ar->hw->wiphy)); in carl9170_register_wps_button()
1505 snprintf(ar->wps.phys, sizeof(ar->wps.phys), in carl9170_register_wps_button()
1506 "ieee80211/%s/input0", wiphy_name(ar->hw->wiphy)); in carl9170_register_wps_button()
1508 input->name = ar->wps.name; in carl9170_register_wps_button()
1509 input->phys = ar->wps.phys; in carl9170_register_wps_button()
1511 input->dev.parent = &ar->hw->wiphy->dev; in carl9170_register_wps_button()
1521 ar->wps.pbc = input; in carl9170_register_wps_button()
1527 static int carl9170_rng_get(struct ar9170 *ar) in carl9170_rng_get() argument
1543 if (!IS_ACCEPTING_CMD(ar) || !ar->rng.initialized) in carl9170_rng_get()
1546 count = ARRAY_SIZE(ar->rng.cache); in carl9170_rng_get()
1548 err = carl9170_exec_cmd(ar, CARL9170_CMD_RREG, in carl9170_rng_get()
1556 ar->rng.cache[off + i] = buf[i]; in carl9170_rng_get()
1562 ar->rng.cache_idx = 0; in carl9170_rng_get()
1571 struct ar9170 *ar = (struct ar9170 *)rng->priv; in carl9170_rng_read() local
1574 mutex_lock(&ar->mutex); in carl9170_rng_read()
1575 if (ar->rng.cache_idx >= ARRAY_SIZE(ar->rng.cache)) { in carl9170_rng_read()
1576 ret = carl9170_rng_get(ar); in carl9170_rng_read()
1578 mutex_unlock(&ar->mutex); in carl9170_rng_read()
1583 *data = ar->rng.cache[ar->rng.cache_idx++]; in carl9170_rng_read()
1584 mutex_unlock(&ar->mutex); in carl9170_rng_read()
1589 static void carl9170_unregister_hwrng(struct ar9170 *ar) in carl9170_unregister_hwrng() argument
1591 if (ar->rng.initialized) { in carl9170_unregister_hwrng()
1592 hwrng_unregister(&ar->rng.rng); in carl9170_unregister_hwrng()
1593 ar->rng.initialized = false; in carl9170_unregister_hwrng()
1597 static int carl9170_register_hwrng(struct ar9170 *ar) in carl9170_register_hwrng() argument
1601 snprintf(ar->rng.name, ARRAY_SIZE(ar->rng.name), in carl9170_register_hwrng()
1602 "%s_%s", KBUILD_MODNAME, wiphy_name(ar->hw->wiphy)); in carl9170_register_hwrng()
1603 ar->rng.rng.name = ar->rng.name; in carl9170_register_hwrng()
1604 ar->rng.rng.data_read = carl9170_rng_read; in carl9170_register_hwrng()
1605 ar->rng.rng.priv = (unsigned long)ar; in carl9170_register_hwrng()
1607 if (WARN_ON(ar->rng.initialized)) in carl9170_register_hwrng()
1610 err = hwrng_register(&ar->rng.rng); in carl9170_register_hwrng()
1612 dev_err(&ar->udev->dev, "Failed to register the random " in carl9170_register_hwrng()
1617 ar->rng.initialized = true; in carl9170_register_hwrng()
1619 err = carl9170_rng_get(ar); in carl9170_register_hwrng()
1621 carl9170_unregister_hwrng(ar); in carl9170_register_hwrng()
1632 struct ar9170 *ar = hw->priv; in carl9170_op_get_survey() local
1637 chan = ar->channel; in carl9170_op_get_survey()
1642 mutex_lock(&ar->mutex); in carl9170_op_get_survey()
1643 err = carl9170_update_survey(ar, false, true); in carl9170_op_get_survey()
1644 mutex_unlock(&ar->mutex); in carl9170_op_get_survey()
1650 band = ar->hw->wiphy->bands[b]; in carl9170_op_get_survey()
1665 memcpy(survey, &ar->survey[idx], sizeof(*survey)); in carl9170_op_get_survey()
1670 if (ar->channel == chan) in carl9170_op_get_survey()
1673 if (ar->fw.hw_counters) { in carl9170_op_get_survey()
1686 struct ar9170 *ar = hw->priv; in carl9170_op_flush() local
1689 mutex_lock(&ar->mutex); in carl9170_op_flush()
1690 for_each_set_bit(vid, &ar->vif_bitmap, ar->fw.vif_num) in carl9170_op_flush()
1691 carl9170_flush_cab(ar, vid); in carl9170_op_flush()
1693 carl9170_flush(ar, drop); in carl9170_op_flush()
1694 mutex_unlock(&ar->mutex); in carl9170_op_flush()
1700 struct ar9170 *ar = hw->priv; in carl9170_op_get_stats() local
1703 stats->dot11ACKFailureCount = ar->tx_ack_failures; in carl9170_op_get_stats()
1704 stats->dot11FCSErrorCount = ar->tx_fcs_errors; in carl9170_op_get_stats()
1730 struct ar9170 *ar = hw->priv; in carl9170_tx_frames_pending() local
1732 return !!atomic_read(&ar->tx_total_queued); in carl9170_tx_frames_pending()
1761 struct ar9170 *ar; in carl9170_alloc() local
1779 ar = hw->priv; in carl9170_alloc()
1780 ar->hw = hw; in carl9170_alloc()
1781 ar->rx_failover = skb; in carl9170_alloc()
1783 memset(&ar->rx_plcp, 0, sizeof(struct ar9170_rx_head)); in carl9170_alloc()
1784 ar->rx_has_plcp = false; in carl9170_alloc()
1796 mutex_init(&ar->mutex); in carl9170_alloc()
1797 spin_lock_init(&ar->beacon_lock); in carl9170_alloc()
1798 spin_lock_init(&ar->cmd_lock); in carl9170_alloc()
1799 spin_lock_init(&ar->tx_stats_lock); in carl9170_alloc()
1800 spin_lock_init(&ar->tx_ampdu_list_lock); in carl9170_alloc()
1801 spin_lock_init(&ar->mem_lock); in carl9170_alloc()
1802 spin_lock_init(&ar->state_lock); in carl9170_alloc()
1803 atomic_set(&ar->pending_restarts, 0); in carl9170_alloc()
1804 ar->vifs = 0; in carl9170_alloc()
1805 for (i = 0; i < ar->hw->queues; i++) { in carl9170_alloc()
1806 skb_queue_head_init(&ar->tx_status[i]); in carl9170_alloc()
1807 skb_queue_head_init(&ar->tx_pending[i]); in carl9170_alloc()
1809 INIT_LIST_HEAD(&ar->bar_list[i]); in carl9170_alloc()
1810 spin_lock_init(&ar->bar_list_lock[i]); in carl9170_alloc()
1812 INIT_WORK(&ar->ps_work, carl9170_ps_work); in carl9170_alloc()
1813 INIT_WORK(&ar->ping_work, carl9170_ping_work); in carl9170_alloc()
1814 INIT_WORK(&ar->restart_work, carl9170_restart_work); in carl9170_alloc()
1815 INIT_WORK(&ar->ampdu_work, carl9170_ampdu_work); in carl9170_alloc()
1816 INIT_DELAYED_WORK(&ar->stat_work, carl9170_stat_work); in carl9170_alloc()
1817 INIT_DELAYED_WORK(&ar->tx_janitor, carl9170_tx_janitor); in carl9170_alloc()
1818 INIT_LIST_HEAD(&ar->tx_ampdu_list); in carl9170_alloc()
1819 rcu_assign_pointer(ar->tx_ampdu_iter, in carl9170_alloc()
1820 (struct carl9170_sta_tid *) &ar->tx_ampdu_list); in carl9170_alloc()
1822 bitmap_zero(&ar->vif_bitmap, ar->fw.vif_num); in carl9170_alloc()
1823 INIT_LIST_HEAD(&ar->vif_list); in carl9170_alloc()
1824 init_completion(&ar->tx_flush); in carl9170_alloc()
1854 for (i = 0; i < ARRAY_SIZE(ar->noise); i++) in carl9170_alloc()
1855 ar->noise[i] = -95; /* ATH_DEFAULT_NOISE_FLOOR */ in carl9170_alloc()
1859 return ar; in carl9170_alloc()
1866 static int carl9170_read_eeprom(struct ar9170 *ar) in carl9170_read_eeprom() argument
1870 u8 *eeprom = (void *)&ar->eeprom; in carl9170_read_eeprom()
1874 BUILD_BUG_ON(sizeof(ar->eeprom) & 3); in carl9170_read_eeprom()
1879 BUILD_BUG_ON(sizeof(ar->eeprom) % RB); in carl9170_read_eeprom()
1882 for (i = 0; i < sizeof(ar->eeprom) / RB; i++) { in carl9170_read_eeprom()
1887 err = carl9170_exec_cmd(ar, CARL9170_CMD_RREG, in carl9170_read_eeprom()
1899 static int carl9170_parse_eeprom(struct ar9170 *ar) in carl9170_parse_eeprom() argument
1901 struct ath_regulatory *regulatory = &ar->common.regulatory; in carl9170_parse_eeprom()
1906 if (ar->eeprom.length == cpu_to_le16(0xffff)) in carl9170_parse_eeprom()
1909 rx_streams = hweight8(ar->eeprom.rx_mask); in carl9170_parse_eeprom()
1910 tx_streams = hweight8(ar->eeprom.tx_mask); in carl9170_parse_eeprom()
1925 if (ar->eeprom.operating_flags & AR9170_OPFLAG_2GHZ) { in carl9170_parse_eeprom()
1926 ar->hw->wiphy->bands[NL80211_BAND_2GHZ] = in carl9170_parse_eeprom()
1931 if (ar->eeprom.operating_flags & AR9170_OPFLAG_5GHZ) { in carl9170_parse_eeprom()
1932 ar->hw->wiphy->bands[NL80211_BAND_5GHZ] = in carl9170_parse_eeprom()
1941 ar->survey = kcalloc(chans, sizeof(struct survey_info), GFP_KERNEL); in carl9170_parse_eeprom()
1942 if (!ar->survey) in carl9170_parse_eeprom()
1944 ar->num_channels = chans; in carl9170_parse_eeprom()
1946 regulatory->current_rd = le16_to_cpu(ar->eeprom.reg_domain[0]); in carl9170_parse_eeprom()
1949 SET_IEEE80211_PERM_ADDR(ar->hw, ar->eeprom.mac_address); in carl9170_parse_eeprom()
1958 struct ar9170 *ar = hw->priv; in carl9170_reg_notifier() local
1960 ath_reg_notifier_apply(wiphy, request, &ar->common.regulatory); in carl9170_reg_notifier()
1963 int carl9170_register(struct ar9170 *ar) in carl9170_register() argument
1965 struct ath_regulatory *regulatory = &ar->common.regulatory; in carl9170_register()
1968 if (WARN_ON(ar->mem_bitmap)) in carl9170_register()
1971 ar->mem_bitmap = kcalloc(roundup(ar->fw.mem_blocks, BITS_PER_LONG), in carl9170_register()
1975 if (!ar->mem_bitmap) in carl9170_register()
1979 err = carl9170_read_eeprom(ar); in carl9170_register()
1983 err = carl9170_parse_eeprom(ar); in carl9170_register()
1987 err = ath_regd_init(regulatory, ar->hw->wiphy, in carl9170_register()
1997 for (i = 0; i < ar->fw.vif_num; i++) { in carl9170_register()
1998 ar->vif_priv[i].id = i; in carl9170_register()
1999 ar->vif_priv[i].vif = NULL; in carl9170_register()
2002 err = ieee80211_register_hw(ar->hw); in carl9170_register()
2007 ar->registered = true; in carl9170_register()
2010 regulatory_hint(ar->hw->wiphy, regulatory->alpha2); in carl9170_register()
2013 carl9170_debugfs_register(ar); in carl9170_register()
2016 err = carl9170_led_init(ar); in carl9170_register()
2021 err = carl9170_led_register(ar); in carl9170_register()
2027 err = carl9170_register_wps_button(ar); in carl9170_register()
2033 err = carl9170_register_hwrng(ar); in carl9170_register()
2038 dev_info(&ar->udev->dev, "Atheros AR9170 is registered as '%s'\n", in carl9170_register()
2039 wiphy_name(ar->hw->wiphy)); in carl9170_register()
2044 carl9170_unregister(ar); in carl9170_register()
2048 void carl9170_unregister(struct ar9170 *ar) in carl9170_unregister() argument
2050 if (!ar->registered) in carl9170_unregister()
2053 ar->registered = false; in carl9170_unregister()
2056 carl9170_led_unregister(ar); in carl9170_unregister()
2060 carl9170_debugfs_unregister(ar); in carl9170_unregister()
2064 if (ar->wps.pbc) { in carl9170_unregister()
2065 input_unregister_device(ar->wps.pbc); in carl9170_unregister()
2066 ar->wps.pbc = NULL; in carl9170_unregister()
2071 carl9170_unregister_hwrng(ar); in carl9170_unregister()
2074 carl9170_cancel_worker(ar); in carl9170_unregister()
2075 cancel_work_sync(&ar->restart_work); in carl9170_unregister()
2077 ieee80211_unregister_hw(ar->hw); in carl9170_unregister()
2080 void carl9170_free(struct ar9170 *ar) in carl9170_free() argument
2082 WARN_ON(ar->registered); in carl9170_free()
2083 WARN_ON(IS_INITIALIZED(ar)); in carl9170_free()
2085 kfree_skb(ar->rx_failover); in carl9170_free()
2086 ar->rx_failover = NULL; in carl9170_free()
2088 kfree(ar->mem_bitmap); in carl9170_free()
2089 ar->mem_bitmap = NULL; in carl9170_free()
2091 kfree(ar->survey); in carl9170_free()
2092 ar->survey = NULL; in carl9170_free()
2094 mutex_destroy(&ar->mutex); in carl9170_free()
2096 ieee80211_free_hw(ar->hw); in carl9170_free()