Lines Matching +full:main +full:- +full:eeprom
25 * Copyright (c) 2007-2008 Atheros Communications, Inc.
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()
192 if (tid_info->state == CARL9170_TID_STATE_SHUTDOWN) { in carl9170_ampdu_gc()
193 tid_info->state = CARL9170_TID_STATE_KILLED; in carl9170_ampdu_gc()
194 list_del_rcu(&tid_info->list); in carl9170_ampdu_gc()
195 ar->tx_ampdu_list_len--; in carl9170_ampdu_gc()
196 list_add_tail(&tid_info->tmp_list, &tid_gc); 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()
211 while ((skb = __skb_dequeue(&tid_info->queue))) in carl9170_ampdu_gc()
214 list_del_init(&tid_info->tmp_list); in carl9170_ampdu_gc()
229 for (i = 0; i < ar->hw->queues; i++) { in carl9170_flush()
232 while ((skb = skb_dequeue(&ar->tx_pending[i]))) { in carl9170_flush()
236 if (info->flags & IEEE80211_TX_CTL_AMPDU) in carl9170_flush()
237 atomic_dec(&ar->tx_ampdu_upload); 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()
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()
260 if (tid_info->state > CARL9170_TID_STATE_SUSPEND) { in carl9170_flush_ba()
261 tid_info->state = CARL9170_TID_STATE_SUSPEND; in carl9170_flush_ba()
263 spin_lock(&tid_info->lock); in carl9170_flush_ba()
264 while ((skb = __skb_dequeue(&tid_info->queue))) in carl9170_flush_ba()
266 spin_unlock(&tid_info->lock); in carl9170_flush_ba()
269 spin_unlock_bh(&ar->tx_ampdu_list_lock); in carl9170_flush_ba()
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()
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 bitmap_zero(ar->mem_bitmap, ar->fw.mem_blocks); in carl9170_zap_queues()
313 list_for_each_entry_rcu(cvif, &ar->vif_list, list) { in carl9170_zap_queues()
314 spin_lock_bh(&ar->beacon_lock); in carl9170_zap_queues()
315 dev_kfree_skb_any(cvif->beacon); in carl9170_zap_queues()
316 cvif->beacon = NULL; in carl9170_zap_queues()
317 spin_unlock_bh(&ar->beacon_lock); in carl9170_zap_queues()
321 atomic_set(&ar->tx_ampdu_upload, 0); in carl9170_zap_queues()
322 atomic_set(&ar->tx_ampdu_scheduler, 0); in carl9170_zap_queues()
323 atomic_set(&ar->tx_total_pending, 0); in carl9170_zap_queues()
324 atomic_set(&ar->tx_total_queued, 0); in carl9170_zap_queues()
325 atomic_set(&ar->mem_free_blocks, ar->fw.mem_blocks); in carl9170_zap_queues()
338 struct ar9170 *ar = hw->priv; in carl9170_op_start()
341 mutex_lock(&ar->mutex); in carl9170_op_start()
346 CARL9170_FILL_QUEUE(ar->edcf[AR9170_TXQ_VO], 2, 3, 7, 47); in carl9170_op_start()
347 CARL9170_FILL_QUEUE(ar->edcf[AR9170_TXQ_VI], 2, 7, 15, 94); in carl9170_op_start()
348 CARL9170_FILL_QUEUE(ar->edcf[AR9170_TXQ_BE], 3, 15, 1023, 0); in carl9170_op_start()
349 CARL9170_FILL_QUEUE(ar->edcf[AR9170_TXQ_BK], 7, 15, 1023, 0); in carl9170_op_start()
350 CARL9170_FILL_QUEUE(ar->edcf[AR9170_TXQ_SPECIAL], 2, 3, 7, 0); in carl9170_op_start()
352 ar->current_factor = ar->current_density = -1; in carl9170_op_start()
354 ar->usedkeys = 1; in carl9170_op_start()
355 ar->filter_state = 0; in carl9170_op_start()
356 ar->ps.last_action = jiffies; in carl9170_op_start()
357 ar->ps.last_slept = jiffies; in carl9170_op_start()
358 ar->erp_mode = CARL9170_ERP_AUTO; in carl9170_op_start()
363 ar->disable_offload = modparam_nohwcrypt | in carl9170_op_start()
364 ar->fw.disable_offload_fw; in carl9170_op_start()
365 ar->rx_software_decryption = ar->disable_offload; in carl9170_op_start()
367 for (i = 0; i < ar->hw->queues; i++) { in carl9170_op_start()
368 ar->queue_stop_timeout[i] = jiffies; in carl9170_op_start()
369 ar->max_queue_stop_timeout[i] = 0; in carl9170_op_start()
372 atomic_set(&ar->mem_allocs, 0); in carl9170_op_start()
386 if (ar->fw.rx_filter) { in carl9170_op_start()
398 /* Clear key-cache */ in carl9170_op_start()
419 ieee80211_queue_delayed_work(ar->hw, &ar->stat_work, in carl9170_op_start()
422 ieee80211_wake_queues(ar->hw); in carl9170_op_start()
426 mutex_unlock(&ar->mutex); in carl9170_op_start()
432 cancel_delayed_work_sync(&ar->stat_work); in carl9170_cancel_worker()
433 cancel_delayed_work_sync(&ar->tx_janitor); in carl9170_cancel_worker()
435 cancel_delayed_work_sync(&ar->led_work); in carl9170_cancel_worker()
437 cancel_work_sync(&ar->ps_work); in carl9170_cancel_worker()
438 cancel_work_sync(&ar->ping_work); in carl9170_cancel_worker()
439 cancel_work_sync(&ar->ampdu_work); in carl9170_cancel_worker()
444 struct ar9170 *ar = hw->priv; in carl9170_op_stop()
448 ieee80211_stop_queues(ar->hw); in carl9170_op_stop()
450 mutex_lock(&ar->mutex); in carl9170_op_stop()
452 RCU_INIT_POINTER(ar->beacon_iter, NULL); in carl9170_op_stop()
462 mutex_unlock(&ar->mutex); in carl9170_op_stop()
471 int err = -EIO; in carl9170_restart_work()
473 ar->usedkeys = 0; in carl9170_restart_work()
474 ar->filter_state = 0; in carl9170_restart_work()
477 mutex_lock(&ar->mutex); in carl9170_restart_work()
478 if (!ar->force_usb_reset) { in carl9170_restart_work()
482 dev_err(&ar->udev->dev, "Failed to restart device (%d).\n", err); in carl9170_restart_work()
484 dev_info(&ar->udev->dev, "device restarted successfully.\n"); in carl9170_restart_work()
488 mutex_unlock(&ar->mutex); in carl9170_restart_work()
490 if (!err && !ar->force_usb_reset) { in carl9170_restart_work()
491 ar->restart_counter++; in carl9170_restart_work()
492 atomic_set(&ar->pending_restarts, 0); in carl9170_restart_work()
494 ieee80211_restart_hw(ar->hw); in carl9170_restart_work()
498 * be dead. But there's still one option: a low-level in carl9170_restart_work()
515 if (atomic_inc_return(&ar->pending_restarts) > 1) { in carl9170_restart()
516 dev_dbg(&ar->udev->dev, "ignoring restart (%d)\n", r); in carl9170_restart()
520 ieee80211_stop_queues(ar->hw); in carl9170_restart()
522 dev_err(&ar->udev->dev, "restart device (%d)\n", r); in carl9170_restart()
526 ar->last_reason = r; in carl9170_restart()
528 if (!ar->registered) in carl9170_restart()
531 if (!IS_ACCEPTING_CMD(ar) || ar->needs_full_reset) in carl9170_restart()
532 ar->force_usb_reset = true; in carl9170_restart()
534 ieee80211_queue_work(ar->hw, &ar->restart_work); in carl9170_restart()
551 mutex_lock(&ar->mutex); in carl9170_ping_work()
555 mutex_unlock(&ar->mutex); in carl9170_ping_work()
561 struct ath_common *common = &ar->common; in carl9170_init_interface()
569 memcpy(common->macaddr, vif->addr, ETH_ALEN); in carl9170_init_interface()
575 * NOTE: If the previous main interface has already in carl9170_init_interface()
581 ar->disable_offload |= ((vif->type != NL80211_IFTYPE_STATION) && in carl9170_init_interface()
582 (vif->type != NL80211_IFTYPE_AP)); in carl9170_init_interface()
589 ar->disable_offload |= vif->p2p; in carl9170_init_interface()
591 ar->rx_software_decryption = ar->disable_offload; in carl9170_init_interface()
600 struct carl9170_vif_info *vif_priv = (void *) vif->drv_priv; in carl9170_op_add_interface()
602 struct ar9170 *ar = hw->priv; in carl9170_op_add_interface()
603 int vif_id = -1, err = 0; in carl9170_op_add_interface()
605 mutex_lock(&ar->mutex); in carl9170_op_add_interface()
607 if (vif_priv->active) { in carl9170_op_add_interface()
612 vif_id = vif_priv->id; in carl9170_op_add_interface()
613 vif_priv->enable_beacon = false; in carl9170_op_add_interface()
615 spin_lock_bh(&ar->beacon_lock); in carl9170_op_add_interface()
616 dev_kfree_skb_any(vif_priv->beacon); in carl9170_op_add_interface()
617 vif_priv->beacon = NULL; in carl9170_op_add_interface()
618 spin_unlock_bh(&ar->beacon_lock); in carl9170_op_add_interface()
625 * We have to select ONE main interface [main mode of HW], but we in carl9170_op_add_interface()
626 * can have multiple slaves [AKA: entry in the ACK-table]. in carl9170_op_add_interface()
628 * The first (from HEAD/TOP) interface in the ar->vif_list is in carl9170_op_add_interface()
629 * always the main intf. All following intfs in this list in carl9170_op_add_interface()
635 switch (main_vif->type) { in carl9170_op_add_interface()
637 if (vif->type == NL80211_IFTYPE_STATION) in carl9170_op_add_interface()
640 err = -EBUSY; in carl9170_op_add_interface()
647 if ((vif->type == NL80211_IFTYPE_STATION) || in carl9170_op_add_interface()
648 (vif->type == NL80211_IFTYPE_AP) || in carl9170_op_add_interface()
649 (vif->type == NL80211_IFTYPE_MESH_POINT)) in carl9170_op_add_interface()
652 err = -EBUSY; in carl9170_op_add_interface()
662 vif_id = bitmap_find_free_region(&ar->vif_bitmap, ar->fw.vif_num, 0); in carl9170_op_add_interface()
667 err = -ENOSPC; in carl9170_op_add_interface()
671 BUG_ON(ar->vif_priv[vif_id].id != vif_id); in carl9170_op_add_interface()
673 vif_priv->active = true; in carl9170_op_add_interface()
674 vif_priv->id = vif_id; in carl9170_op_add_interface()
675 vif_priv->enable_beacon = false; in carl9170_op_add_interface()
676 ar->vifs++; in carl9170_op_add_interface()
678 /* We end up in here, if the main interface is being replaced. in carl9170_op_add_interface()
679 * Put the new main interface at the HEAD of the list and the in carl9170_op_add_interface()
682 list_add_rcu(&vif_priv->list, &ar->vif_list); in carl9170_op_add_interface()
685 * main inteface, otherwise it will be slave. in carl9170_op_add_interface()
687 list_add_tail_rcu(&vif_priv->list, &ar->vif_list); in carl9170_op_add_interface()
689 rcu_assign_pointer(ar->vif_priv[vif_id].vif, vif); in carl9170_op_add_interface()
695 rcu_assign_pointer(ar->beacon_iter, vif_priv); in carl9170_op_add_interface()
700 (void *) old_main->drv_priv; in carl9170_op_add_interface()
701 /* downgrade old main intf to slave intf. in carl9170_op_add_interface()
703 * But we are still holding ar->mutex, so the in carl9170_op_add_interface()
706 err = carl9170_mod_virtual_mac(ar, old_main_priv->id, in carl9170_op_add_interface()
707 old_main->addr); in carl9170_op_add_interface()
717 err = carl9170_mod_virtual_mac(ar, vif_id, vif->addr); in carl9170_op_add_interface()
723 if (ar->fw.tx_seq_table) { in carl9170_op_add_interface()
724 err = carl9170_write_reg(ar, ar->fw.tx_seq_table + vif_id * 4, in carl9170_op_add_interface()
732 vif_priv->active = false; in carl9170_op_add_interface()
733 bitmap_release_region(&ar->vif_bitmap, vif_id, 0); in carl9170_op_add_interface()
734 ar->vifs--; in carl9170_op_add_interface()
735 RCU_INIT_POINTER(ar->vif_priv[vif_id].vif, NULL); in carl9170_op_add_interface()
736 list_del_rcu(&vif_priv->list); in carl9170_op_add_interface()
737 mutex_unlock(&ar->mutex); in carl9170_op_add_interface()
740 if (ar->vifs > 1) in carl9170_op_add_interface()
741 ar->ps.off_override |= PS_OFF_VIF; in carl9170_op_add_interface()
743 mutex_unlock(&ar->mutex); in carl9170_op_add_interface()
752 struct carl9170_vif_info *vif_priv = (void *) vif->drv_priv; in carl9170_op_remove_interface()
754 struct ar9170 *ar = hw->priv; in carl9170_op_remove_interface()
757 mutex_lock(&ar->mutex); in carl9170_op_remove_interface()
759 if (WARN_ON_ONCE(!vif_priv->active)) in carl9170_op_remove_interface()
762 ar->vifs--; in carl9170_op_remove_interface()
767 id = vif_priv->id; in carl9170_op_remove_interface()
769 vif_priv->active = false; in carl9170_op_remove_interface()
770 WARN_ON(vif_priv->enable_beacon); in carl9170_op_remove_interface()
771 vif_priv->enable_beacon = false; in carl9170_op_remove_interface()
772 list_del_rcu(&vif_priv->list); in carl9170_op_remove_interface()
773 RCU_INIT_POINTER(ar->vif_priv[id].vif, NULL); in carl9170_op_remove_interface()
778 if (ar->vifs) { in carl9170_op_remove_interface()
793 spin_lock_bh(&ar->beacon_lock); in carl9170_op_remove_interface()
794 dev_kfree_skb_any(vif_priv->beacon); in carl9170_op_remove_interface()
795 vif_priv->beacon = NULL; in carl9170_op_remove_interface()
796 spin_unlock_bh(&ar->beacon_lock); in carl9170_op_remove_interface()
798 bitmap_release_region(&ar->vif_bitmap, id, 0); in carl9170_op_remove_interface()
802 if (ar->vifs == 1) in carl9170_op_remove_interface()
803 ar->ps.off_override &= ~PS_OFF_VIF; in carl9170_op_remove_interface()
806 mutex_unlock(&ar->mutex); in carl9170_op_remove_interface()
813 ieee80211_queue_work(ar->hw, &ar->ps_work); in carl9170_ps_check()
816 /* caller must hold ar->mutex */
822 if (!ar->ps.off_override) in carl9170_ps_update()
823 ps = (ar->hw->conf.flags & IEEE80211_CONF_PS); in carl9170_ps_update()
825 if (ps != ar->ps.state) { in carl9170_ps_update()
830 if (ar->ps.state && !ps) { in carl9170_ps_update()
831 ar->ps.sleep_ms = jiffies_to_msecs(jiffies - in carl9170_ps_update()
832 ar->ps.last_action); in carl9170_ps_update()
836 ar->ps.last_slept = jiffies; in carl9170_ps_update()
838 ar->ps.last_action = jiffies; in carl9170_ps_update()
839 ar->ps.state = ps; in carl9170_ps_update()
849 mutex_lock(&ar->mutex); in carl9170_ps_work()
852 mutex_unlock(&ar->mutex); in carl9170_ps_work()
865 if (ar->fw.hw_counters) { in carl9170_update_survey()
872 memset(&ar->tally, 0, sizeof(ar->tally)); in carl9170_update_survey()
882 mutex_lock(&ar->mutex); in carl9170_stat_work()
884 mutex_unlock(&ar->mutex); in carl9170_stat_work()
889 ieee80211_queue_delayed_work(ar->hw, &ar->stat_work, in carl9170_stat_work()
895 struct ar9170 *ar = hw->priv; in carl9170_op_config()
898 mutex_lock(&ar->mutex); in carl9170_op_config()
917 cfg80211_get_chandef_type(&hw->conf.chandef); in carl9170_op_config()
928 err = carl9170_set_channel(ar, hw->conf.chandef.chan, in carl9170_op_config()
947 err = carl9170_set_mac_tpc(ar, ar->hw->conf.chandef.chan); in carl9170_op_config()
953 mutex_unlock(&ar->mutex); in carl9170_op_config()
967 mchash |= 1ULL << (ha->addr[5] >> 2); in carl9170_op_prepare_multicast()
977 struct ar9170 *ar = hw->priv; in carl9170_op_configure_filter()
980 *new_flags &= FIF_ALLMULTI | ar->rx_filter_caps; in carl9170_op_configure_filter()
985 mutex_lock(&ar->mutex); in carl9170_op_configure_filter()
987 ar->filter_state = *new_flags; in carl9170_op_configure_filter()
996 if (multicast != ar->cur_mc_hash) in carl9170_op_configure_filter()
1000 ar->sniffer_enabled = !!(*new_flags & FIF_OTHER_BSS); in carl9170_op_configure_filter()
1005 if (ar->fw.rx_filter && changed_flags & ar->rx_filter_caps) { in carl9170_op_configure_filter()
1008 if (!ar->fw.ba_filter) in carl9170_op_configure_filter()
1028 mutex_unlock(&ar->mutex); in carl9170_op_configure_filter()
1037 struct ar9170 *ar = hw->priv; in carl9170_op_bss_info_changed()
1038 struct ath_common *common = &ar->common; in carl9170_op_bss_info_changed()
1043 mutex_lock(&ar->mutex); in carl9170_op_bss_info_changed()
1044 vif_priv = (void *) vif->drv_priv; in carl9170_op_bss_info_changed()
1053 vif_priv->enable_beacon = bss_conf->enable_beacon; in carl9170_op_bss_info_changed()
1055 list_for_each_entry_rcu(iter, &ar->vif_list, list) { in carl9170_op_bss_info_changed()
1056 if (iter->active && iter->enable_beacon) in carl9170_op_bss_info_changed()
1062 ar->beacon_enabled = i; in carl9170_op_bss_info_changed()
1075 bss_conf->beacon_int = main_vif->bss_conf.beacon_int; in carl9170_op_bss_info_changed()
1076 bss_conf->dtim_period = main_vif->bss_conf.dtim_period; in carl9170_op_bss_info_changed()
1083 if (vif->type != NL80211_IFTYPE_STATION && in carl9170_op_bss_info_changed()
1084 (bss_conf->beacon_int * bss_conf->dtim_period >= in carl9170_op_bss_info_changed()
1086 err = -EINVAL; in carl9170_op_bss_info_changed()
1111 memcpy(common->curbssid, bss_conf->bssid, ETH_ALEN); in carl9170_op_bss_info_changed()
1118 ar->common.curaid = vif->cfg.aid; in carl9170_op_bss_info_changed()
1138 mutex_unlock(&ar->mutex); in carl9170_op_bss_info_changed()
1144 struct ar9170 *ar = hw->priv; in carl9170_op_get_tsf()
1148 mutex_lock(&ar->mutex); in carl9170_op_get_tsf()
1151 mutex_unlock(&ar->mutex); in carl9170_op_get_tsf()
1163 struct ar9170 *ar = hw->priv; in carl9170_op_set_key()
1167 if (ar->disable_offload || !vif) in carl9170_op_set_key()
1168 return -EOPNOTSUPP; in carl9170_op_set_key()
1178 mutex_lock(&ar->mutex); in carl9170_op_set_key()
1183 * While the hardware supports *catch-all* key, for offloading in carl9170_op_set_key()
1184 * group-key en-/de-cryption. The way of how the hardware in carl9170_op_set_key()
1187 if ((vif->type != NL80211_IFTYPE_STATION && in carl9170_op_set_key()
1188 vif->type != NL80211_IFTYPE_ADHOC) && in carl9170_op_set_key()
1189 !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) in carl9170_op_set_key()
1190 return -EOPNOTSUPP; in carl9170_op_set_key()
1192 switch (key->cipher) { in carl9170_op_set_key()
1204 key->flags |= IEEE80211_KEY_FLAG_SW_MGMT_TX; in carl9170_op_set_key()
1207 return -EOPNOTSUPP; in carl9170_op_set_key()
1210 mutex_lock(&ar->mutex); in carl9170_op_set_key()
1213 err = -EOPNOTSUPP; in carl9170_op_set_key()
1217 if (!(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) { in carl9170_op_set_key()
1220 i = 64 + key->keyidx; in carl9170_op_set_key()
1223 if (!(ar->usedkeys & BIT(i))) in carl9170_op_set_key()
1229 key->hw_key_idx = i; in carl9170_op_set_key()
1231 err = carl9170_upload_key(ar, i, sta ? sta->addr : NULL, in carl9170_op_set_key()
1232 ktype, 0, key->key, in carl9170_op_set_key()
1233 min_t(u8, 16, key->keylen)); in carl9170_op_set_key()
1237 if (key->cipher == WLAN_CIPHER_SUITE_TKIP) { in carl9170_op_set_key()
1238 err = carl9170_upload_key(ar, i, sta ? sta->addr : in carl9170_op_set_key()
1240 key->key + 16, 16); in carl9170_op_set_key()
1248 key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC; in carl9170_op_set_key()
1252 ar->usedkeys |= BIT(i); in carl9170_op_set_key()
1254 key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; in carl9170_op_set_key()
1257 /* The device is gone... together with the key ;-) */ in carl9170_op_set_key()
1262 if (key->hw_key_idx < 64) { in carl9170_op_set_key()
1263 ar->usedkeys &= ~BIT(key->hw_key_idx); in carl9170_op_set_key()
1265 err = carl9170_upload_key(ar, key->hw_key_idx, NULL, in carl9170_op_set_key()
1271 if (key->cipher == WLAN_CIPHER_SUITE_TKIP) { in carl9170_op_set_key()
1272 err = carl9170_upload_key(ar, key->hw_key_idx, in carl9170_op_set_key()
1282 err = carl9170_disable_key(ar, key->hw_key_idx); in carl9170_op_set_key()
1288 mutex_unlock(&ar->mutex); in carl9170_op_set_key()
1292 if (!ar->rx_software_decryption) { in carl9170_op_set_key()
1293 ar->rx_software_decryption = true; in carl9170_op_set_key()
1296 mutex_unlock(&ar->mutex); in carl9170_op_set_key()
1297 return -ENOSPC; in carl9170_op_set_key()
1304 struct carl9170_sta_info *sta_info = (void *) sta->drv_priv; in carl9170_op_sta_add()
1307 atomic_set(&sta_info->pending_frames, 0); in carl9170_op_sta_add()
1309 if (sta->deflink.ht_cap.ht_supported) { in carl9170_op_sta_add()
1310 if (sta->deflink.ht_cap.ampdu_density > 6) { in carl9170_op_sta_add()
1313 * No HT-Xmit for station. in carl9170_op_sta_add()
1319 for (i = 0; i < ARRAY_SIZE(sta_info->agg); i++) in carl9170_op_sta_add()
1320 RCU_INIT_POINTER(sta_info->agg[i], NULL); in carl9170_op_sta_add()
1322 sta_info->ampdu_max_len = 1 << (3 + sta->deflink.ht_cap.ampdu_factor); in carl9170_op_sta_add()
1323 sta_info->ht_sta = true; in carl9170_op_sta_add()
1333 struct ar9170 *ar = hw->priv; in carl9170_op_sta_remove()
1334 struct carl9170_sta_info *sta_info = (void *) sta->drv_priv; in carl9170_op_sta_remove()
1338 if (sta->deflink.ht_cap.ht_supported) { in carl9170_op_sta_remove()
1340 sta_info->ht_sta = false; in carl9170_op_sta_remove()
1343 for (i = 0; i < ARRAY_SIZE(sta_info->agg); i++) { in carl9170_op_sta_remove()
1346 tid_info = rcu_dereference(sta_info->agg[i]); in carl9170_op_sta_remove()
1347 RCU_INIT_POINTER(sta_info->agg[i], NULL); in carl9170_op_sta_remove()
1352 spin_lock_bh(&ar->tx_ampdu_list_lock); in carl9170_op_sta_remove()
1353 if (tid_info->state > CARL9170_TID_STATE_SHUTDOWN) in carl9170_op_sta_remove()
1354 tid_info->state = CARL9170_TID_STATE_SHUTDOWN; in carl9170_op_sta_remove()
1355 spin_unlock_bh(&ar->tx_ampdu_list_lock); in carl9170_op_sta_remove()
1372 struct ar9170 *ar = hw->priv; in carl9170_op_conf_tx()
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()
1378 mutex_unlock(&ar->mutex); in carl9170_op_conf_tx()
1390 mutex_lock(&ar->mutex); in carl9170_ampdu_work()
1392 mutex_unlock(&ar->mutex); in carl9170_ampdu_work()
1399 struct ieee80211_sta *sta = params->sta; in carl9170_op_ampdu_action()
1400 enum ieee80211_ampdu_mlme_action action = params->action; in carl9170_op_ampdu_action()
1401 u16 tid = params->tid; in carl9170_op_ampdu_action()
1402 u16 *ssn = ¶ms->ssn; in carl9170_op_ampdu_action()
1403 struct ar9170 *ar = hw->priv; in carl9170_op_ampdu_action()
1404 struct carl9170_sta_info *sta_info = (void *) sta->drv_priv; in carl9170_op_ampdu_action()
1408 return -EOPNOTSUPP; in carl9170_op_ampdu_action()
1412 if (!sta_info->ht_sta) in carl9170_op_ampdu_action()
1413 return -EOPNOTSUPP; in carl9170_op_ampdu_action()
1418 return -ENOMEM; in carl9170_op_ampdu_action()
1420 tid_info->hsn = tid_info->bsn = tid_info->snx = (*ssn); in carl9170_op_ampdu_action()
1421 tid_info->state = CARL9170_TID_STATE_PROGRESS; in carl9170_op_ampdu_action()
1422 tid_info->tid = tid; in carl9170_op_ampdu_action()
1423 tid_info->max = sta_info->ampdu_max_len; in carl9170_op_ampdu_action()
1424 tid_info->sta = sta; in carl9170_op_ampdu_action()
1425 tid_info->vif = vif; in carl9170_op_ampdu_action()
1427 INIT_LIST_HEAD(&tid_info->list); in carl9170_op_ampdu_action()
1428 INIT_LIST_HEAD(&tid_info->tmp_list); in carl9170_op_ampdu_action()
1429 skb_queue_head_init(&tid_info->queue); in carl9170_op_ampdu_action()
1430 spin_lock_init(&tid_info->lock); in carl9170_op_ampdu_action()
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()
1435 rcu_assign_pointer(sta_info->agg[tid], tid_info); in carl9170_op_ampdu_action()
1436 spin_unlock_bh(&ar->tx_ampdu_list_lock); in carl9170_op_ampdu_action()
1444 tid_info = rcu_dereference(sta_info->agg[tid]); in carl9170_op_ampdu_action()
1446 spin_lock_bh(&ar->tx_ampdu_list_lock); in carl9170_op_ampdu_action()
1447 if (tid_info->state > CARL9170_TID_STATE_SHUTDOWN) in carl9170_op_ampdu_action()
1448 tid_info->state = CARL9170_TID_STATE_SHUTDOWN; in carl9170_op_ampdu_action()
1449 spin_unlock_bh(&ar->tx_ampdu_list_lock); in carl9170_op_ampdu_action()
1452 RCU_INIT_POINTER(sta_info->agg[tid], NULL); in carl9170_op_ampdu_action()
1455 ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid); in carl9170_op_ampdu_action()
1456 ieee80211_queue_work(ar->hw, &ar->ampdu_work); in carl9170_op_ampdu_action()
1461 tid_info = rcu_dereference(sta_info->agg[tid]); in carl9170_op_ampdu_action()
1463 sta_info->stats[tid].clear = true; in carl9170_op_ampdu_action()
1464 sta_info->stats[tid].req = false; in carl9170_op_ampdu_action()
1467 bitmap_zero(tid_info->bitmap, CARL9170_BAW_SIZE); in carl9170_op_ampdu_action()
1468 tid_info->state = CARL9170_TID_STATE_IDLE; in carl9170_op_ampdu_action()
1473 return -EFAULT; in carl9170_op_ampdu_action()
1483 return -EOPNOTSUPP; in carl9170_op_ampdu_action()
1495 if (!(ar->features & CARL9170_WPS_BUTTON)) in carl9170_register_wps_button()
1498 input = devm_input_allocate_device(&ar->udev->dev); in carl9170_register_wps_button()
1500 return -ENOMEM; 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()
1510 input->id.bustype = BUS_USB; in carl9170_register_wps_button()
1511 input->dev.parent = &ar->hw->wiphy->dev; in carl9170_register_wps_button()
1519 ar->wps.pbc = input; in carl9170_register_wps_button()
1532 [0 ... (RW - 1)] = cpu_to_le32(AR9170_RAND_REG_NUM)}; in carl9170_rng_get()
1542 return -EAGAIN; in carl9170_rng_get()
1544 count = ARRAY_SIZE(ar->rng.cache); in carl9170_rng_get()
1554 ar->rng.cache[off + i] = buf[i]; in carl9170_rng_get()
1557 count -= transfer; in carl9170_rng_get()
1560 ar->rng.cache_idx = 0; in carl9170_rng_get()
1569 struct ar9170 *ar = (struct ar9170 *)rng->priv; in carl9170_rng_read()
1570 int ret = -EIO; in carl9170_rng_read()
1572 mutex_lock(&ar->mutex); in carl9170_rng_read()
1573 if (ar->rng.cache_idx >= ARRAY_SIZE(ar->rng.cache)) { in carl9170_rng_read()
1576 mutex_unlock(&ar->mutex); in carl9170_rng_read()
1581 *data = ar->rng.cache[ar->rng.cache_idx++]; in carl9170_rng_read()
1582 mutex_unlock(&ar->mutex); in carl9170_rng_read()
1591 snprintf(ar->rng.name, ARRAY_SIZE(ar->rng.name), in carl9170_register_hwrng()
1592 "%s_%s", KBUILD_MODNAME, wiphy_name(ar->hw->wiphy)); in carl9170_register_hwrng()
1593 ar->rng.rng.name = ar->rng.name; in carl9170_register_hwrng()
1594 ar->rng.rng.data_read = carl9170_rng_read; in carl9170_register_hwrng()
1595 ar->rng.rng.priv = (unsigned long)ar; in carl9170_register_hwrng()
1597 err = devm_hwrng_register(&ar->udev->dev, &ar->rng.rng); in carl9170_register_hwrng()
1599 dev_err(&ar->udev->dev, "Failed to register the random " in carl9170_register_hwrng()
1611 struct ar9170 *ar = hw->priv; in carl9170_op_get_survey()
1616 chan = ar->channel; in carl9170_op_get_survey()
1618 return -ENODEV; in carl9170_op_get_survey()
1620 if (idx == chan->hw_value) { in carl9170_op_get_survey()
1621 mutex_lock(&ar->mutex); in carl9170_op_get_survey()
1623 mutex_unlock(&ar->mutex); in carl9170_op_get_survey()
1629 band = ar->hw->wiphy->bands[b]; in carl9170_op_get_survey()
1634 for (i = 0; i < band->n_channels; i++) { in carl9170_op_get_survey()
1635 if (band->channels[i].hw_value == idx) { in carl9170_op_get_survey()
1636 chan = &band->channels[i]; in carl9170_op_get_survey()
1641 return -ENOENT; in carl9170_op_get_survey()
1644 memcpy(survey, &ar->survey[idx], sizeof(*survey)); in carl9170_op_get_survey()
1646 survey->channel = chan; in carl9170_op_get_survey()
1647 survey->filled = SURVEY_INFO_NOISE_DBM; in carl9170_op_get_survey()
1649 if (ar->channel == chan) in carl9170_op_get_survey()
1650 survey->filled |= SURVEY_INFO_IN_USE; in carl9170_op_get_survey()
1652 if (ar->fw.hw_counters) { in carl9170_op_get_survey()
1653 survey->filled |= SURVEY_INFO_TIME | in carl9170_op_get_survey()
1665 struct ar9170 *ar = hw->priv; in carl9170_op_flush()
1668 mutex_lock(&ar->mutex); in carl9170_op_flush()
1669 for_each_set_bit(vid, &ar->vif_bitmap, ar->fw.vif_num) in carl9170_op_flush()
1673 mutex_unlock(&ar->mutex); in carl9170_op_flush()
1679 struct ar9170 *ar = hw->priv; in carl9170_op_get_stats()
1682 stats->dot11ACKFailureCount = ar->tx_ack_failures; in carl9170_op_get_stats()
1683 stats->dot11FCSErrorCount = ar->tx_fcs_errors; in carl9170_op_get_stats()
1692 struct carl9170_sta_info *sta_info = (void *) sta->drv_priv; in carl9170_op_sta_notify()
1696 sta_info->sleeping = true; in carl9170_op_sta_notify()
1697 if (atomic_read(&sta_info->pending_frames)) in carl9170_op_sta_notify()
1702 sta_info->sleeping = false; in carl9170_op_sta_notify()
1709 struct ar9170 *ar = hw->priv; in carl9170_tx_frames_pending()
1711 return !!atomic_read(&ar->tx_total_queued); in carl9170_tx_frames_pending()
1763 ar = hw->priv; in carl9170_alloc()
1764 ar->hw = hw; in carl9170_alloc()
1765 ar->rx_failover = skb; in carl9170_alloc()
1767 memset(&ar->rx_plcp, 0, sizeof(struct ar9170_rx_head)); in carl9170_alloc()
1768 ar->rx_has_plcp = false; in carl9170_alloc()
1778 hw->queues = __AR9170_NUM_TXQ; in carl9170_alloc()
1780 mutex_init(&ar->mutex); in carl9170_alloc()
1781 spin_lock_init(&ar->beacon_lock); in carl9170_alloc()
1782 spin_lock_init(&ar->cmd_lock); in carl9170_alloc()
1783 spin_lock_init(&ar->tx_stats_lock); in carl9170_alloc()
1784 spin_lock_init(&ar->tx_ampdu_list_lock); in carl9170_alloc()
1785 spin_lock_init(&ar->mem_lock); in carl9170_alloc()
1786 spin_lock_init(&ar->state_lock); in carl9170_alloc()
1787 atomic_set(&ar->pending_restarts, 0); in carl9170_alloc()
1788 ar->vifs = 0; in carl9170_alloc()
1789 for (i = 0; i < ar->hw->queues; i++) { in carl9170_alloc()
1790 skb_queue_head_init(&ar->tx_status[i]); in carl9170_alloc()
1791 skb_queue_head_init(&ar->tx_pending[i]); in carl9170_alloc()
1793 INIT_LIST_HEAD(&ar->bar_list[i]); in carl9170_alloc()
1794 spin_lock_init(&ar->bar_list_lock[i]); in carl9170_alloc()
1796 INIT_WORK(&ar->ps_work, carl9170_ps_work); in carl9170_alloc()
1797 INIT_WORK(&ar->ping_work, carl9170_ping_work); in carl9170_alloc()
1798 INIT_WORK(&ar->restart_work, carl9170_restart_work); in carl9170_alloc()
1799 INIT_WORK(&ar->ampdu_work, carl9170_ampdu_work); in carl9170_alloc()
1800 INIT_DELAYED_WORK(&ar->stat_work, carl9170_stat_work); in carl9170_alloc()
1801 INIT_DELAYED_WORK(&ar->tx_janitor, carl9170_tx_janitor); in carl9170_alloc()
1802 INIT_LIST_HEAD(&ar->tx_ampdu_list); in carl9170_alloc()
1803 rcu_assign_pointer(ar->tx_ampdu_iter, in carl9170_alloc()
1804 (struct carl9170_sta_tid *) &ar->tx_ampdu_list); in carl9170_alloc()
1806 bitmap_zero(&ar->vif_bitmap, ar->fw.vif_num); in carl9170_alloc()
1807 INIT_LIST_HEAD(&ar->vif_list); in carl9170_alloc()
1808 init_completion(&ar->tx_flush); in carl9170_alloc()
1811 hw->wiphy->interface_modes = 0; in carl9170_alloc()
1831 hw->extra_tx_headroom = sizeof(struct _carl9170_tx_superframe); in carl9170_alloc()
1832 hw->sta_data_size = sizeof(struct carl9170_sta_info); in carl9170_alloc()
1833 hw->vif_data_size = sizeof(struct carl9170_vif_info); in carl9170_alloc()
1835 hw->max_rates = CARL9170_TX_MAX_RATES; in carl9170_alloc()
1836 hw->max_rate_tries = CARL9170_TX_USER_RATE_TRIES; in carl9170_alloc()
1838 for (i = 0; i < ARRAY_SIZE(ar->noise); i++) in carl9170_alloc()
1839 ar->noise[i] = -95; /* ATH_DEFAULT_NOISE_FLOOR */ in carl9170_alloc()
1841 wiphy_ext_feature_set(hw->wiphy, NL80211_EXT_FEATURE_CQM_RSSI_LIST); in carl9170_alloc()
1847 return ERR_PTR(-ENOMEM); in carl9170_alloc()
1854 u8 *eeprom = (void *)&ar->eeprom; in carl9170_read_eeprom() local
1858 BUILD_BUG_ON(sizeof(ar->eeprom) & 3); in carl9170_read_eeprom()
1860 BUILD_BUG_ON(RB > CARL9170_MAX_CMD_LEN - 4); in carl9170_read_eeprom()
1863 BUILD_BUG_ON(sizeof(ar->eeprom) % RB); in carl9170_read_eeprom()
1866 for (i = 0; i < sizeof(ar->eeprom) / RB; i++) { in carl9170_read_eeprom()
1873 RB, eeprom + RB * i); in carl9170_read_eeprom()
1885 struct ath_regulatory *regulatory = &ar->common.regulatory; in carl9170_parse_eeprom()
1890 if (ar->eeprom.length == cpu_to_le16(0xffff)) in carl9170_parse_eeprom()
1891 return -ENODATA; in carl9170_parse_eeprom()
1893 rx_streams = hweight8(ar->eeprom.rx_mask); in carl9170_parse_eeprom()
1894 tx_streams = hweight8(ar->eeprom.tx_mask); in carl9170_parse_eeprom()
1902 tx_params |= (tx_streams - 1) << in carl9170_parse_eeprom()
1909 if (ar->eeprom.operating_flags & AR9170_OPFLAG_2GHZ) { in carl9170_parse_eeprom()
1910 ar->hw->wiphy->bands[NL80211_BAND_2GHZ] = in carl9170_parse_eeprom()
1915 if (ar->eeprom.operating_flags & AR9170_OPFLAG_5GHZ) { in carl9170_parse_eeprom()
1916 ar->hw->wiphy->bands[NL80211_BAND_5GHZ] = in carl9170_parse_eeprom()
1923 return -EINVAL; in carl9170_parse_eeprom()
1925 ar->survey = devm_kcalloc(&ar->udev->dev, chans, in carl9170_parse_eeprom()
1927 if (!ar->survey) in carl9170_parse_eeprom()
1928 return -ENOMEM; in carl9170_parse_eeprom()
1929 ar->num_channels = chans; in carl9170_parse_eeprom()
1931 regulatory->current_rd = le16_to_cpu(ar->eeprom.reg_domain[0]); in carl9170_parse_eeprom()
1934 SET_IEEE80211_PERM_ADDR(ar->hw, ar->eeprom.mac_address); in carl9170_parse_eeprom()
1943 struct ar9170 *ar = hw->priv; in carl9170_reg_notifier()
1945 ath_reg_notifier_apply(wiphy, request, &ar->common.regulatory); in carl9170_reg_notifier()
1950 struct ath_regulatory *regulatory = &ar->common.regulatory; in carl9170_register()
1953 ar->mem_bitmap = devm_bitmap_zalloc(&ar->udev->dev, ar->fw.mem_blocks, GFP_KERNEL); in carl9170_register()
1954 if (!ar->mem_bitmap) in carl9170_register()
1955 return -ENOMEM; in carl9170_register()
1957 /* try to read EEPROM, init MAC addr */ in carl9170_register()
1966 err = ath_regd_init(regulatory, ar->hw->wiphy, in carl9170_register()
1976 for (i = 0; i < ar->fw.vif_num; i++) { in carl9170_register()
1977 ar->vif_priv[i].id = i; in carl9170_register()
1978 ar->vif_priv[i].vif = NULL; in carl9170_register()
1981 err = ieee80211_register_hw(ar->hw); in carl9170_register()
1986 ar->registered = true; in carl9170_register()
1989 regulatory_hint(ar->hw->wiphy, regulatory->alpha2); in carl9170_register()
2017 dev_info(&ar->udev->dev, "Atheros AR9170 is registered as '%s'\n", in carl9170_register()
2018 wiphy_name(ar->hw->wiphy)); in carl9170_register()
2029 if (!ar->registered) in carl9170_unregister()
2032 ar->registered = false; in carl9170_unregister()
2043 cancel_work_sync(&ar->restart_work); in carl9170_unregister()
2045 ieee80211_unregister_hw(ar->hw); in carl9170_unregister()
2050 WARN_ON(ar->registered); in carl9170_free()
2053 kfree_skb(ar->rx_failover); in carl9170_free()
2054 ar->rx_failover = NULL; in carl9170_free()
2056 mutex_destroy(&ar->mutex); in carl9170_free()
2058 ieee80211_free_hw(ar->hw); in carl9170_free()