Lines Matching refs:sta

81 			     struct sta_info *sta)  in sta_info_hash_del()  argument
83 return rhltable_remove(&local->sta_hash, &sta->hash_node, in sta_info_hash_del()
87 static void __cleanup_single_sta(struct sta_info *sta) in __cleanup_single_sta() argument
91 struct ieee80211_sub_if_data *sdata = sta->sdata; in __cleanup_single_sta()
96 if (test_sta_flag(sta, WLAN_STA_PS_STA) || in __cleanup_single_sta()
97 test_sta_flag(sta, WLAN_STA_PS_DRIVER) || in __cleanup_single_sta()
98 test_sta_flag(sta, WLAN_STA_PS_DELIVER)) { in __cleanup_single_sta()
99 if (sta->sdata->vif.type == NL80211_IFTYPE_AP || in __cleanup_single_sta()
100 sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN) in __cleanup_single_sta()
107 clear_sta_flag(sta, WLAN_STA_PS_STA); in __cleanup_single_sta()
108 clear_sta_flag(sta, WLAN_STA_PS_DRIVER); in __cleanup_single_sta()
109 clear_sta_flag(sta, WLAN_STA_PS_DELIVER); in __cleanup_single_sta()
114 if (sta->sta.txq[0]) { in __cleanup_single_sta()
115 for (i = 0; i < ARRAY_SIZE(sta->sta.txq); i++) { in __cleanup_single_sta()
116 struct txq_info *txqi = to_txq_info(sta->sta.txq[i]); in __cleanup_single_sta()
125 local->total_ps_buffered -= skb_queue_len(&sta->ps_tx_buf[ac]); in __cleanup_single_sta()
126 ieee80211_purge_tx_queue(&local->hw, &sta->ps_tx_buf[ac]); in __cleanup_single_sta()
127 ieee80211_purge_tx_queue(&local->hw, &sta->tx_filtered[ac]); in __cleanup_single_sta()
131 mesh_sta_cleanup(sta); in __cleanup_single_sta()
133 cancel_work_sync(&sta->drv_deliver_wk); in __cleanup_single_sta()
142 kfree(sta->ampdu_mlme.tid_start_tx[i]); in __cleanup_single_sta()
143 tid_tx = rcu_dereference_raw(sta->ampdu_mlme.tid_tx[i]); in __cleanup_single_sta()
151 static void cleanup_single_sta(struct sta_info *sta) in cleanup_single_sta() argument
153 struct ieee80211_sub_if_data *sdata = sta->sdata; in cleanup_single_sta()
156 __cleanup_single_sta(sta); in cleanup_single_sta()
157 sta_info_free(local, sta); in cleanup_single_sta()
172 struct sta_info *sta; in sta_info_get() local
175 for_each_sta_info(local, addr, sta, tmp) { in sta_info_get()
176 if (sta->sdata == sdata) { in sta_info_get()
181 return sta; in sta_info_get()
197 struct sta_info *sta; in sta_info_get_bss() local
200 for_each_sta_info(local, addr, sta, tmp) { in sta_info_get_bss()
201 if (sta->sdata == sdata || in sta_info_get_bss()
202 (sta->sdata->bss && sta->sdata->bss == sdata->bss)) { in sta_info_get_bss()
207 return sta; in sta_info_get_bss()
218 struct sta_info *sta; in sta_info_get_by_idx() local
221 list_for_each_entry_rcu(sta, &local->sta_list, list) { in sta_info_get_by_idx()
222 if (sdata != sta->sdata) in sta_info_get_by_idx()
228 return sta; in sta_info_get_by_idx()
245 void sta_info_free(struct ieee80211_local *local, struct sta_info *sta) in sta_info_free() argument
247 if (sta->rate_ctrl) in sta_info_free()
248 rate_control_free_sta(sta); in sta_info_free()
250 sta_dbg(sta->sdata, "Destroyed STA %pM\n", sta->sta.addr); in sta_info_free()
252 if (sta->sta.txq[0]) in sta_info_free()
253 kfree(to_txq_info(sta->sta.txq[0])); in sta_info_free()
254 kfree(rcu_dereference_raw(sta->sta.rates)); in sta_info_free()
256 kfree(sta->mesh); in sta_info_free()
258 free_percpu(sta->pcpu_rx_stats); in sta_info_free()
259 kfree(sta); in sta_info_free()
264 struct sta_info *sta) in sta_info_hash_add() argument
266 return rhltable_insert(&local->sta_hash, &sta->hash_node, in sta_info_hash_add()
272 struct sta_info *sta; in sta_deliver_ps_frames() local
274 sta = container_of(wk, struct sta_info, drv_deliver_wk); in sta_deliver_ps_frames()
276 if (sta->dead) in sta_deliver_ps_frames()
280 if (!test_sta_flag(sta, WLAN_STA_PS_STA)) in sta_deliver_ps_frames()
281 ieee80211_sta_ps_deliver_wakeup(sta); in sta_deliver_ps_frames()
282 else if (test_and_clear_sta_flag(sta, WLAN_STA_PSPOLL)) in sta_deliver_ps_frames()
283 ieee80211_sta_ps_deliver_poll_response(sta); in sta_deliver_ps_frames()
284 else if (test_and_clear_sta_flag(sta, WLAN_STA_UAPSD)) in sta_deliver_ps_frames()
285 ieee80211_sta_ps_deliver_uapsd(sta); in sta_deliver_ps_frames()
290 struct sta_info *sta, gfp_t gfp) in sta_prepare_rate_control() argument
295 sta->rate_ctrl = local->rate_ctrl; in sta_prepare_rate_control()
296 sta->rate_ctrl_priv = rate_control_alloc_sta(sta->rate_ctrl, in sta_prepare_rate_control()
297 sta, gfp); in sta_prepare_rate_control()
298 if (!sta->rate_ctrl_priv) in sta_prepare_rate_control()
309 struct sta_info *sta; in sta_info_alloc() local
312 sta = kzalloc(sizeof(*sta) + hw->sta_data_size, gfp); in sta_info_alloc()
313 if (!sta) in sta_info_alloc()
317 sta->pcpu_rx_stats = in sta_info_alloc()
319 if (!sta->pcpu_rx_stats) in sta_info_alloc()
323 spin_lock_init(&sta->lock); in sta_info_alloc()
324 spin_lock_init(&sta->ps_lock); in sta_info_alloc()
325 INIT_WORK(&sta->drv_deliver_wk, sta_deliver_ps_frames); in sta_info_alloc()
326 INIT_WORK(&sta->ampdu_mlme.work, ieee80211_ba_session_work); in sta_info_alloc()
327 mutex_init(&sta->ampdu_mlme.mtx); in sta_info_alloc()
330 sta->mesh = kzalloc(sizeof(*sta->mesh), gfp); in sta_info_alloc()
331 if (!sta->mesh) in sta_info_alloc()
333 sta->mesh->plink_sta = sta; in sta_info_alloc()
334 spin_lock_init(&sta->mesh->plink_lock); in sta_info_alloc()
337 timer_setup(&sta->mesh->plink_timer, mesh_plink_timer, in sta_info_alloc()
339 sta->mesh->nonpeer_pm = NL80211_MESH_POWER_ACTIVE; in sta_info_alloc()
343 memcpy(sta->addr, addr, ETH_ALEN); in sta_info_alloc()
344 memcpy(sta->sta.addr, addr, ETH_ALEN); in sta_info_alloc()
345 sta->sta.max_rx_aggregation_subframes = in sta_info_alloc()
348 sta->local = local; in sta_info_alloc()
349 sta->sdata = sdata; in sta_info_alloc()
350 sta->rx_stats.last_rx = jiffies; in sta_info_alloc()
352 u64_stats_init(&sta->rx_stats.syncp); in sta_info_alloc()
354 sta->sta_state = IEEE80211_STA_NONE; in sta_info_alloc()
357 sta->reserved_tid = IEEE80211_TID_UNRESERVED; in sta_info_alloc()
359 sta->last_connected = ktime_get_seconds(); in sta_info_alloc()
360 ewma_signal_init(&sta->rx_stats_avg.signal); in sta_info_alloc()
361 ewma_avg_signal_init(&sta->status_stats.avg_ack_signal); in sta_info_alloc()
362 for (i = 0; i < ARRAY_SIZE(sta->rx_stats_avg.chain_signal); i++) in sta_info_alloc()
363 ewma_signal_init(&sta->rx_stats_avg.chain_signal[i]); in sta_info_alloc()
370 txq_data = kcalloc(ARRAY_SIZE(sta->sta.txq), size, gfp); in sta_info_alloc()
374 for (i = 0; i < ARRAY_SIZE(sta->sta.txq); i++) { in sta_info_alloc()
377 ieee80211_txq_init(sdata, sta, txq, i); in sta_info_alloc()
381 if (sta_prepare_rate_control(local, sta, gfp)) in sta_info_alloc()
385 skb_queue_head_init(&sta->ps_tx_buf[i]); in sta_info_alloc()
386 skb_queue_head_init(&sta->tx_filtered[i]); in sta_info_alloc()
390 sta->last_seq_ctrl[i] = cpu_to_le16(USHRT_MAX); in sta_info_alloc()
392 sta->sta.smps_mode = IEEE80211_SMPS_OFF; in sta_info_alloc()
410 sta->known_smps_mode = IEEE80211_SMPS_OFF; in sta_info_alloc()
413 sta->known_smps_mode = IEEE80211_SMPS_STATIC; in sta_info_alloc()
416 sta->known_smps_mode = IEEE80211_SMPS_DYNAMIC; in sta_info_alloc()
423 sta->sta.max_rc_amsdu_len = IEEE80211_MAX_MPDU_LEN_HT_BA; in sta_info_alloc()
425 sta->cparams.ce_threshold = CODEL_DISABLED_THRESHOLD; in sta_info_alloc()
426 sta->cparams.target = MS2TIME(20); in sta_info_alloc()
427 sta->cparams.interval = MS2TIME(100); in sta_info_alloc()
428 sta->cparams.ecn = true; in sta_info_alloc()
430 sta_dbg(sdata, "Allocated STA %pM\n", sta->sta.addr); in sta_info_alloc()
432 return sta; in sta_info_alloc()
435 if (sta->sta.txq[0]) in sta_info_alloc()
436 kfree(to_txq_info(sta->sta.txq[0])); in sta_info_alloc()
438 free_percpu(sta->pcpu_rx_stats); in sta_info_alloc()
440 kfree(sta->mesh); in sta_info_alloc()
442 kfree(sta); in sta_info_alloc()
446 static int sta_info_insert_check(struct sta_info *sta) in sta_info_insert_check() argument
448 struct ieee80211_sub_if_data *sdata = sta->sdata; in sta_info_insert_check()
458 if (WARN_ON(ether_addr_equal(sta->sta.addr, sdata->vif.addr) || in sta_info_insert_check()
459 is_multicast_ether_addr(sta->sta.addr))) in sta_info_insert_check()
469 ieee80211_find_sta_by_ifaddr(&sdata->local->hw, sta->addr, NULL)) { in sta_info_insert_check()
480 struct sta_info *sta) in sta_info_insert_drv_state() argument
485 for (state = IEEE80211_STA_NOTEXIST; state < sta->sta_state; state++) { in sta_info_insert_drv_state()
486 err = drv_sta_state(local, sdata, sta, state, state + 1); in sta_info_insert_drv_state()
497 sta->uploaded = true; in sta_info_insert_drv_state()
504 sta->sta.addr, state + 1, err); in sta_info_insert_drv_state()
510 WARN_ON(drv_sta_state(local, sdata, sta, state, state - 1)); in sta_info_insert_drv_state()
520 struct sta_info *sta; in ieee80211_recalc_p2p_go_ps_allowed() local
523 list_for_each_entry_rcu(sta, &local->sta_list, list) { in ieee80211_recalc_p2p_go_ps_allowed()
524 if (sdata != sta->sdata || in ieee80211_recalc_p2p_go_ps_allowed()
525 !test_sta_flag(sta, WLAN_STA_ASSOC)) in ieee80211_recalc_p2p_go_ps_allowed()
527 if (!sta->sta.support_p2p_ps) { in ieee80211_recalc_p2p_go_ps_allowed()
545 static int sta_info_insert_finish(struct sta_info *sta) __acquires(RCU) in sta_info_insert_finish() argument
547 struct ieee80211_local *local = sta->local; in sta_info_insert_finish()
548 struct ieee80211_sub_if_data *sdata = sta->sdata; in sta_info_insert_finish()
555 if (sta_info_get_bss(sdata, sta->sta.addr)) { in sta_info_insert_finish()
571 set_sta_flag(sta, WLAN_STA_BLOCK_BA); in sta_info_insert_finish()
574 err = sta_info_hash_add(local, sta); in sta_info_insert_finish()
578 list_add_tail_rcu(&sta->list, &local->sta_list); in sta_info_insert_finish()
581 err = sta_info_insert_drv_state(local, sdata, sta); in sta_info_insert_finish()
585 set_sta_flag(sta, WLAN_STA_INSERTED); in sta_info_insert_finish()
587 if (sta->sta_state >= IEEE80211_STA_ASSOC) { in sta_info_insert_finish()
588 ieee80211_recalc_min_chandef(sta->sdata); in sta_info_insert_finish()
589 if (!sta->sta.support_p2p_ps) in sta_info_insert_finish()
590 ieee80211_recalc_p2p_go_ps_allowed(sta->sdata); in sta_info_insert_finish()
594 clear_sta_flag(sta, WLAN_STA_BLOCK_BA); in sta_info_insert_finish()
596 ieee80211_sta_debugfs_add(sta); in sta_info_insert_finish()
597 rate_control_add_sta_debugfs(sta); in sta_info_insert_finish()
600 cfg80211_new_sta(sdata->dev, sta->sta.addr, sinfo, GFP_KERNEL); in sta_info_insert_finish()
603 sta_dbg(sdata, "Inserted STA %pM\n", sta->sta.addr); in sta_info_insert_finish()
614 sta_info_hash_del(local, sta); in sta_info_insert_finish()
615 list_del_rcu(&sta->list); in sta_info_insert_finish()
619 __cleanup_single_sta(sta); in sta_info_insert_finish()
627 int sta_info_insert_rcu(struct sta_info *sta) __acquires(RCU) in sta_info_insert_rcu() argument
629 struct ieee80211_local *local = sta->local; in sta_info_insert_rcu()
636 err = sta_info_insert_check(sta); in sta_info_insert_rcu()
643 err = sta_info_insert_finish(sta); in sta_info_insert_rcu()
649 sta_info_free(local, sta); in sta_info_insert_rcu()
653 int sta_info_insert(struct sta_info *sta) in sta_info_insert() argument
655 int err = sta_info_insert_rcu(sta); in sta_info_insert()
707 static void __sta_info_recalc_tim(struct sta_info *sta, bool ignore_pending) in __sta_info_recalc_tim() argument
709 struct ieee80211_local *local = sta->local; in __sta_info_recalc_tim()
712 u8 ignore_for_tim = sta->sta.uapsd_queues; in __sta_info_recalc_tim()
714 u16 id = sta->sta.aid; in __sta_info_recalc_tim()
716 if (sta->sdata->vif.type == NL80211_IFTYPE_AP || in __sta_info_recalc_tim()
717 sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN) { in __sta_info_recalc_tim()
718 if (WARN_ON_ONCE(!sta->sdata->bss)) in __sta_info_recalc_tim()
721 ps = &sta->sdata->bss->ps; in __sta_info_recalc_tim()
723 } else if (ieee80211_vif_is_mesh(&sta->sdata->vif)) { in __sta_info_recalc_tim()
724 ps = &sta->sdata->u.mesh.ps; in __sta_info_recalc_tim()
734 if (sta->dead) in __sta_info_recalc_tim()
755 indicate_tim |= !skb_queue_empty(&sta->tx_filtered[ac]) || in __sta_info_recalc_tim()
756 !skb_queue_empty(&sta->ps_tx_buf[ac]); in __sta_info_recalc_tim()
763 sta->driver_buffered_tids & tids; in __sta_info_recalc_tim()
765 sta->txq_buffered_tids & tids; in __sta_info_recalc_tim()
779 if (local->ops->set_tim && !WARN_ON(sta->dead)) { in __sta_info_recalc_tim()
781 drv_set_tim(local, &sta->sta, indicate_tim); in __sta_info_recalc_tim()
789 void sta_info_recalc_tim(struct sta_info *sta) in sta_info_recalc_tim() argument
791 __sta_info_recalc_tim(sta, false); in sta_info_recalc_tim()
794 static bool sta_info_buffer_expired(struct sta_info *sta, struct sk_buff *skb) in sta_info_buffer_expired() argument
805 timeout = (sta->listen_interval * in sta_info_buffer_expired()
806 sta->sdata->vif.bss_conf.beacon_int * in sta_info_buffer_expired()
815 struct sta_info *sta, int ac) in sta_info_cleanup_expire_buffered_ac() argument
828 spin_lock_irqsave(&sta->tx_filtered[ac].lock, flags); in sta_info_cleanup_expire_buffered_ac()
829 skb = skb_peek(&sta->tx_filtered[ac]); in sta_info_cleanup_expire_buffered_ac()
830 if (sta_info_buffer_expired(sta, skb)) in sta_info_cleanup_expire_buffered_ac()
831 skb = __skb_dequeue(&sta->tx_filtered[ac]); in sta_info_cleanup_expire_buffered_ac()
834 spin_unlock_irqrestore(&sta->tx_filtered[ac].lock, flags); in sta_info_cleanup_expire_buffered_ac()
854 spin_lock_irqsave(&sta->ps_tx_buf[ac].lock, flags); in sta_info_cleanup_expire_buffered_ac()
855 skb = skb_peek(&sta->ps_tx_buf[ac]); in sta_info_cleanup_expire_buffered_ac()
856 if (sta_info_buffer_expired(sta, skb)) in sta_info_cleanup_expire_buffered_ac()
857 skb = __skb_dequeue(&sta->ps_tx_buf[ac]); in sta_info_cleanup_expire_buffered_ac()
860 spin_unlock_irqrestore(&sta->ps_tx_buf[ac].lock, flags); in sta_info_cleanup_expire_buffered_ac()
871 ps_dbg(sta->sdata, "Buffered frame expired (STA %pM)\n", in sta_info_cleanup_expire_buffered_ac()
872 sta->sta.addr); in sta_info_cleanup_expire_buffered_ac()
881 sta_info_recalc_tim(sta); in sta_info_cleanup_expire_buffered_ac()
888 return !(skb_queue_empty(&sta->ps_tx_buf[ac]) && in sta_info_cleanup_expire_buffered_ac()
889 skb_queue_empty(&sta->tx_filtered[ac])); in sta_info_cleanup_expire_buffered_ac()
893 struct sta_info *sta) in sta_info_cleanup_expire_buffered() argument
899 if (!sta->sdata->bss && in sta_info_cleanup_expire_buffered()
900 !ieee80211_vif_is_mesh(&sta->sdata->vif)) in sta_info_cleanup_expire_buffered()
905 sta_info_cleanup_expire_buffered_ac(local, sta, ac); in sta_info_cleanup_expire_buffered()
910 static int __must_check __sta_info_destroy_part1(struct sta_info *sta) in __sta_info_destroy_part1() argument
918 if (!sta) in __sta_info_destroy_part1()
921 local = sta->local; in __sta_info_destroy_part1()
922 sdata = sta->sdata; in __sta_info_destroy_part1()
932 set_sta_flag(sta, WLAN_STA_BLOCK_BA); in __sta_info_destroy_part1()
933 ieee80211_sta_tear_down_BA_sessions(sta, AGG_STOP_DESTROY_STA); in __sta_info_destroy_part1()
940 drv_sync_rx_queues(local, sta); in __sta_info_destroy_part1()
942 ret = sta_info_hash_del(local, sta); in __sta_info_destroy_part1()
950 if (test_sta_flag(sta, WLAN_STA_TDLS_OFF_CHANNEL)) { in __sta_info_destroy_part1()
951 drv_tdls_cancel_channel_switch(local, sdata, &sta->sta); in __sta_info_destroy_part1()
952 clear_sta_flag(sta, WLAN_STA_TDLS_OFF_CHANNEL); in __sta_info_destroy_part1()
955 list_del_rcu(&sta->list); in __sta_info_destroy_part1()
956 sta->removed = true; in __sta_info_destroy_part1()
958 drv_sta_pre_rcu_remove(local, sta->sdata, sta); in __sta_info_destroy_part1()
961 rcu_access_pointer(sdata->u.vlan.sta) == sta) in __sta_info_destroy_part1()
962 RCU_INIT_POINTER(sdata->u.vlan.sta, NULL); in __sta_info_destroy_part1()
967 static void __sta_info_destroy_part2(struct sta_info *sta) in __sta_info_destroy_part2() argument
969 struct ieee80211_local *local = sta->local; in __sta_info_destroy_part2()
970 struct ieee80211_sub_if_data *sdata = sta->sdata; in __sta_info_destroy_part2()
983 ieee80211_free_sta_keys(local, sta); in __sta_info_destroy_part2()
986 __sta_info_recalc_tim(sta, true); in __sta_info_destroy_part2()
988 sta->dead = true; in __sta_info_destroy_part2()
993 while (sta->sta_state > IEEE80211_STA_NONE) { in __sta_info_destroy_part2()
994 ret = sta_info_move_state(sta, sta->sta_state - 1); in __sta_info_destroy_part2()
1001 if (sta->uploaded) { in __sta_info_destroy_part2()
1002 ret = drv_sta_state(local, sdata, sta, IEEE80211_STA_NONE, in __sta_info_destroy_part2()
1007 sta_dbg(sdata, "Removed STA %pM\n", sta->sta.addr); in __sta_info_destroy_part2()
1011 sta_set_sinfo(sta, sinfo, true); in __sta_info_destroy_part2()
1012 cfg80211_del_sta_sinfo(sdata->dev, sta->sta.addr, sinfo, GFP_KERNEL); in __sta_info_destroy_part2()
1015 rate_control_remove_sta_debugfs(sta); in __sta_info_destroy_part2()
1016 ieee80211_sta_debugfs_remove(sta); in __sta_info_destroy_part2()
1018 cleanup_single_sta(sta); in __sta_info_destroy_part2()
1021 int __must_check __sta_info_destroy(struct sta_info *sta) in __sta_info_destroy() argument
1023 int err = __sta_info_destroy_part1(sta); in __sta_info_destroy()
1030 __sta_info_destroy_part2(sta); in __sta_info_destroy()
1037 struct sta_info *sta; in sta_info_destroy_addr() local
1041 sta = sta_info_get(sdata, addr); in sta_info_destroy_addr()
1042 ret = __sta_info_destroy(sta); in sta_info_destroy_addr()
1051 struct sta_info *sta; in sta_info_destroy_addr_bss() local
1055 sta = sta_info_get_bss(sdata, addr); in sta_info_destroy_addr_bss()
1056 ret = __sta_info_destroy(sta); in sta_info_destroy_addr_bss()
1065 struct sta_info *sta; in sta_info_cleanup() local
1069 list_for_each_entry_rcu(sta, &local->sta_list, list) in sta_info_cleanup()
1070 if (sta_info_cleanup_expire_buffered(local, sta)) in sta_info_cleanup()
1110 struct sta_info *sta, *tmp; in __sta_info_flush() local
1120 list_for_each_entry_safe(sta, tmp, &local->sta_list, list) { in __sta_info_flush()
1121 if (sdata == sta->sdata || in __sta_info_flush()
1122 (vlans && sdata->bss == sta->sdata->bss)) { in __sta_info_flush()
1123 if (!WARN_ON(__sta_info_destroy_part1(sta))) in __sta_info_flush()
1124 list_add(&sta->free_list, &free_list); in __sta_info_flush()
1131 list_for_each_entry_safe(sta, tmp, &free_list, free_list) in __sta_info_flush()
1132 __sta_info_destroy_part2(sta); in __sta_info_flush()
1143 struct sta_info *sta, *tmp; in ieee80211_sta_expire() local
1147 list_for_each_entry_safe(sta, tmp, &local->sta_list, list) { in ieee80211_sta_expire()
1148 unsigned long last_active = ieee80211_sta_last_active(sta); in ieee80211_sta_expire()
1150 if (sdata != sta->sdata) in ieee80211_sta_expire()
1154 sta_dbg(sta->sdata, "expiring inactive STA %pM\n", in ieee80211_sta_expire()
1155 sta->sta.addr); in ieee80211_sta_expire()
1158 test_sta_flag(sta, WLAN_STA_PS_STA)) in ieee80211_sta_expire()
1161 WARN_ON(__sta_info_destroy(sta)); in ieee80211_sta_expire()
1174 struct sta_info *sta; in ieee80211_find_sta_by_ifaddr() local
1180 for_each_sta_info(local, addr, sta, tmp) { in ieee80211_find_sta_by_ifaddr()
1182 !ether_addr_equal(sta->sdata->vif.addr, localaddr)) in ieee80211_find_sta_by_ifaddr()
1184 if (!sta->uploaded) in ieee80211_find_sta_by_ifaddr()
1186 return &sta->sta; in ieee80211_find_sta_by_ifaddr()
1196 struct sta_info *sta; in ieee80211_find_sta() local
1201 sta = sta_info_get_bss(vif_to_sdata(vif), addr); in ieee80211_find_sta()
1202 if (!sta) in ieee80211_find_sta()
1205 if (!sta->uploaded) in ieee80211_find_sta()
1208 return &sta->sta; in ieee80211_find_sta()
1213 void ieee80211_sta_ps_deliver_wakeup(struct sta_info *sta) in ieee80211_sta_ps_deliver_wakeup() argument
1215 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_sta_ps_deliver_wakeup()
1233 clear_sta_flag(sta, WLAN_STA_SP); in ieee80211_sta_ps_deliver_wakeup()
1236 sta->driver_buffered_tids = 0; in ieee80211_sta_ps_deliver_wakeup()
1237 sta->txq_buffered_tids = 0; in ieee80211_sta_ps_deliver_wakeup()
1240 drv_sta_notify(local, sdata, STA_NOTIFY_AWAKE, &sta->sta); in ieee80211_sta_ps_deliver_wakeup()
1242 if (sta->sta.txq[0]) { in ieee80211_sta_ps_deliver_wakeup()
1243 for (i = 0; i < ARRAY_SIZE(sta->sta.txq); i++) { in ieee80211_sta_ps_deliver_wakeup()
1244 if (!txq_has_queue(sta->sta.txq[i])) in ieee80211_sta_ps_deliver_wakeup()
1247 drv_wake_tx_queue(local, to_txq_info(sta->sta.txq[i])); in ieee80211_sta_ps_deliver_wakeup()
1254 spin_lock(&sta->ps_lock); in ieee80211_sta_ps_deliver_wakeup()
1259 spin_lock_irqsave(&sta->tx_filtered[ac].lock, flags); in ieee80211_sta_ps_deliver_wakeup()
1260 skb_queue_splice_tail_init(&sta->tx_filtered[ac], &pending); in ieee80211_sta_ps_deliver_wakeup()
1261 spin_unlock_irqrestore(&sta->tx_filtered[ac].lock, flags); in ieee80211_sta_ps_deliver_wakeup()
1266 spin_lock_irqsave(&sta->ps_tx_buf[ac].lock, flags); in ieee80211_sta_ps_deliver_wakeup()
1267 skb_queue_splice_tail_init(&sta->ps_tx_buf[ac], &pending); in ieee80211_sta_ps_deliver_wakeup()
1268 spin_unlock_irqrestore(&sta->ps_tx_buf[ac].lock, flags); in ieee80211_sta_ps_deliver_wakeup()
1276 clear_sta_flag(sta, WLAN_STA_PS_DELIVER); in ieee80211_sta_ps_deliver_wakeup()
1281 clear_sta_flag(sta, WLAN_STA_PSPOLL); in ieee80211_sta_ps_deliver_wakeup()
1282 clear_sta_flag(sta, WLAN_STA_UAPSD); in ieee80211_sta_ps_deliver_wakeup()
1283 spin_unlock(&sta->ps_lock); in ieee80211_sta_ps_deliver_wakeup()
1289 !ieee80211_smps_is_restrictive(sta->known_smps_mode, in ieee80211_sta_ps_deliver_wakeup()
1291 sta->known_smps_mode != sdata->bss->req_smps && in ieee80211_sta_ps_deliver_wakeup()
1292 sta_info_tx_streams(sta) != 1) { in ieee80211_sta_ps_deliver_wakeup()
1295 sta->sta.addr); in ieee80211_sta_ps_deliver_wakeup()
1297 sta->sta.addr, in ieee80211_sta_ps_deliver_wakeup()
1303 sta_info_recalc_tim(sta); in ieee80211_sta_ps_deliver_wakeup()
1307 sta->sta.addr, sta->sta.aid, filtered, buffered); in ieee80211_sta_ps_deliver_wakeup()
1309 ieee80211_check_fast_xmit(sta); in ieee80211_sta_ps_deliver_wakeup()
1312 static void ieee80211_send_null_response(struct sta_info *sta, int tid, in ieee80211_send_null_response() argument
1316 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_send_null_response()
1322 bool qos = sta->sta.wme; in ieee80211_send_null_response()
1351 memcpy(nullfunc->addr1, sta->sta.addr, ETH_ALEN); in ieee80211_send_null_response()
1385 drv_allow_buffered_frames(local, sta, BIT(tid), 1, in ieee80211_send_null_response()
1399 ieee80211_xmit(sdata, sta, skb, 0); in ieee80211_send_null_response()
1420 ieee80211_sta_ps_more_data(struct sta_info *sta, u8 ignored_acs, in ieee80211_sta_ps_more_data() argument
1439 if (!skb_queue_empty(&sta->tx_filtered[ac]) || in ieee80211_sta_ps_more_data()
1440 !skb_queue_empty(&sta->ps_tx_buf[ac])) in ieee80211_sta_ps_more_data()
1448 ieee80211_sta_ps_get_frames(struct sta_info *sta, int n_frames, u8 ignored_acs, in ieee80211_sta_ps_get_frames() argument
1453 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_sta_ps_get_frames()
1471 sta->driver_buffered_tids & tids; in ieee80211_sta_ps_get_frames()
1472 *driver_release_tids |= sta->txq_buffered_tids & tids; in ieee80211_sta_ps_get_frames()
1479 skb = skb_dequeue(&sta->tx_filtered[ac]); in ieee80211_sta_ps_get_frames()
1482 &sta->ps_tx_buf[ac]); in ieee80211_sta_ps_get_frames()
1497 if (!skb_queue_empty(&sta->tx_filtered[ac]) || in ieee80211_sta_ps_get_frames()
1498 !skb_queue_empty(&sta->ps_tx_buf[ac])) in ieee80211_sta_ps_get_frames()
1504 ieee80211_sta_ps_deliver_response(struct sta_info *sta, in ieee80211_sta_ps_deliver_response() argument
1508 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_sta_ps_deliver_response()
1515 set_sta_flag(sta, WLAN_STA_SP); in ieee80211_sta_ps_deliver_response()
1519 ieee80211_sta_ps_get_frames(sta, n_frames, ignored_acs, reason, in ieee80211_sta_ps_deliver_response()
1522 more_data = ieee80211_sta_ps_more_data(sta, ignored_acs, reason, driver_release_tids); in ieee80211_sta_ps_deliver_response()
1552 ieee80211_send_null_response(sta, tid, reason, true, false); in ieee80211_sta_ps_deliver_response()
1645 drv_allow_buffered_frames(local, sta, tids, num, in ieee80211_sta_ps_deliver_response()
1652 sta, find_highest_prio_tid(tids), in ieee80211_sta_ps_deliver_response()
1655 sta_info_recalc_tim(sta); in ieee80211_sta_ps_deliver_response()
1669 drv_release_buffered_frames(local, sta, driver_release_tids, in ieee80211_sta_ps_deliver_response()
1682 if (!sta->sta.txq[0]) in ieee80211_sta_ps_deliver_response()
1685 for (tid = 0; tid < ARRAY_SIZE(sta->sta.txq); tid++) { in ieee80211_sta_ps_deliver_response()
1687 txq_has_queue(sta->sta.txq[tid])) in ieee80211_sta_ps_deliver_response()
1690 sta_info_recalc_tim(sta); in ieee80211_sta_ps_deliver_response()
1696 void ieee80211_sta_ps_deliver_poll_response(struct sta_info *sta) in ieee80211_sta_ps_deliver_poll_response() argument
1698 u8 ignore_for_response = sta->sta.uapsd_queues; in ieee80211_sta_ps_deliver_poll_response()
1708 ieee80211_sta_ps_deliver_response(sta, 1, ignore_for_response, in ieee80211_sta_ps_deliver_poll_response()
1712 void ieee80211_sta_ps_deliver_uapsd(struct sta_info *sta) in ieee80211_sta_ps_deliver_uapsd() argument
1714 int n_frames = sta->sta.max_sp; in ieee80211_sta_ps_deliver_uapsd()
1715 u8 delivery_enabled = sta->sta.uapsd_queues; in ieee80211_sta_ps_deliver_uapsd()
1726 switch (sta->sta.max_sp) { in ieee80211_sta_ps_deliver_uapsd()
1742 ieee80211_sta_ps_deliver_response(sta, n_frames, ~delivery_enabled, in ieee80211_sta_ps_deliver_uapsd()
1749 struct sta_info *sta = container_of(pubsta, struct sta_info, sta); in ieee80211_sta_block_awake() local
1751 trace_api_sta_block_awake(sta->local, pubsta, block); in ieee80211_sta_block_awake()
1754 set_sta_flag(sta, WLAN_STA_PS_DRIVER); in ieee80211_sta_block_awake()
1755 ieee80211_clear_fast_xmit(sta); in ieee80211_sta_block_awake()
1759 if (!test_sta_flag(sta, WLAN_STA_PS_DRIVER)) in ieee80211_sta_block_awake()
1762 if (!test_sta_flag(sta, WLAN_STA_PS_STA)) { in ieee80211_sta_block_awake()
1763 set_sta_flag(sta, WLAN_STA_PS_DELIVER); in ieee80211_sta_block_awake()
1764 clear_sta_flag(sta, WLAN_STA_PS_DRIVER); in ieee80211_sta_block_awake()
1765 ieee80211_queue_work(hw, &sta->drv_deliver_wk); in ieee80211_sta_block_awake()
1766 } else if (test_sta_flag(sta, WLAN_STA_PSPOLL) || in ieee80211_sta_block_awake()
1767 test_sta_flag(sta, WLAN_STA_UAPSD)) { in ieee80211_sta_block_awake()
1769 clear_sta_flag(sta, WLAN_STA_PS_DRIVER); in ieee80211_sta_block_awake()
1770 ieee80211_queue_work(hw, &sta->drv_deliver_wk); in ieee80211_sta_block_awake()
1772 clear_sta_flag(sta, WLAN_STA_PS_DRIVER); in ieee80211_sta_block_awake()
1773 ieee80211_check_fast_xmit(sta); in ieee80211_sta_block_awake()
1780 struct sta_info *sta = container_of(pubsta, struct sta_info, sta); in ieee80211_sta_eosp() local
1781 struct ieee80211_local *local = sta->local; in ieee80211_sta_eosp()
1785 clear_sta_flag(sta, WLAN_STA_SP); in ieee80211_sta_eosp()
1791 struct sta_info *sta = container_of(pubsta, struct sta_info, sta); in ieee80211_send_eosp_nullfunc() local
1795 trace_api_send_eosp_nullfunc(sta->local, pubsta, tid); in ieee80211_send_eosp_nullfunc()
1798 more_data = ieee80211_sta_ps_more_data(sta, ~sta->sta.uapsd_queues, in ieee80211_send_eosp_nullfunc()
1801 ieee80211_send_null_response(sta, tid, reason, false, more_data); in ieee80211_send_eosp_nullfunc()
1808 struct sta_info *sta = container_of(pubsta, struct sta_info, sta); in ieee80211_sta_set_buffered() local
1813 trace_api_sta_set_buffered(sta->local, pubsta, tid, buffered); in ieee80211_sta_set_buffered()
1816 set_bit(tid, &sta->driver_buffered_tids); in ieee80211_sta_set_buffered()
1818 clear_bit(tid, &sta->driver_buffered_tids); in ieee80211_sta_set_buffered()
1820 sta_info_recalc_tim(sta); in ieee80211_sta_set_buffered()
1824 int sta_info_move_state(struct sta_info *sta, in sta_info_move_state() argument
1829 if (sta->sta_state == new_state) in sta_info_move_state()
1836 if (sta->sta_state != IEEE80211_STA_AUTH) in sta_info_move_state()
1840 if (sta->sta_state != IEEE80211_STA_NONE && in sta_info_move_state()
1841 sta->sta_state != IEEE80211_STA_ASSOC) in sta_info_move_state()
1845 if (sta->sta_state != IEEE80211_STA_AUTH && in sta_info_move_state()
1846 sta->sta_state != IEEE80211_STA_AUTHORIZED) in sta_info_move_state()
1850 if (sta->sta_state != IEEE80211_STA_ASSOC) in sta_info_move_state()
1858 sta_dbg(sta->sdata, "moving STA %pM to state %d\n", in sta_info_move_state()
1859 sta->sta.addr, new_state); in sta_info_move_state()
1865 if (test_sta_flag(sta, WLAN_STA_INSERTED)) { in sta_info_move_state()
1866 int err = drv_sta_state(sta->local, sta->sdata, sta, in sta_info_move_state()
1867 sta->sta_state, new_state); in sta_info_move_state()
1876 if (sta->sta_state == IEEE80211_STA_AUTH) in sta_info_move_state()
1877 clear_bit(WLAN_STA_AUTH, &sta->_flags); in sta_info_move_state()
1880 if (sta->sta_state == IEEE80211_STA_NONE) { in sta_info_move_state()
1881 set_bit(WLAN_STA_AUTH, &sta->_flags); in sta_info_move_state()
1882 } else if (sta->sta_state == IEEE80211_STA_ASSOC) { in sta_info_move_state()
1883 clear_bit(WLAN_STA_ASSOC, &sta->_flags); in sta_info_move_state()
1884 ieee80211_recalc_min_chandef(sta->sdata); in sta_info_move_state()
1885 if (!sta->sta.support_p2p_ps) in sta_info_move_state()
1886 ieee80211_recalc_p2p_go_ps_allowed(sta->sdata); in sta_info_move_state()
1890 if (sta->sta_state == IEEE80211_STA_AUTH) { in sta_info_move_state()
1891 set_bit(WLAN_STA_ASSOC, &sta->_flags); in sta_info_move_state()
1892 ieee80211_recalc_min_chandef(sta->sdata); in sta_info_move_state()
1893 if (!sta->sta.support_p2p_ps) in sta_info_move_state()
1894 ieee80211_recalc_p2p_go_ps_allowed(sta->sdata); in sta_info_move_state()
1895 } else if (sta->sta_state == IEEE80211_STA_AUTHORIZED) { in sta_info_move_state()
1896 ieee80211_vif_dec_num_mcast(sta->sdata); in sta_info_move_state()
1897 clear_bit(WLAN_STA_AUTHORIZED, &sta->_flags); in sta_info_move_state()
1898 ieee80211_clear_fast_xmit(sta); in sta_info_move_state()
1899 ieee80211_clear_fast_rx(sta); in sta_info_move_state()
1903 if (sta->sta_state == IEEE80211_STA_ASSOC) { in sta_info_move_state()
1904 ieee80211_vif_inc_num_mcast(sta->sdata); in sta_info_move_state()
1905 set_bit(WLAN_STA_AUTHORIZED, &sta->_flags); in sta_info_move_state()
1906 ieee80211_check_fast_xmit(sta); in sta_info_move_state()
1907 ieee80211_check_fast_rx(sta); in sta_info_move_state()
1914 sta->sta_state = new_state; in sta_info_move_state()
1919 u8 sta_info_tx_streams(struct sta_info *sta) in sta_info_tx_streams() argument
1921 struct ieee80211_sta_ht_cap *ht_cap = &sta->sta.ht_cap; in sta_info_tx_streams()
1924 if (!sta->sta.ht_cap.ht_supported) in sta_info_tx_streams()
1927 if (sta->sta.vht_cap.vht_supported) { in sta_info_tx_streams()
1930 le16_to_cpu(sta->sta.vht_cap.vht_mcs.tx_mcs_map); in sta_info_tx_streams()
1955 sta_get_last_rx_stats(struct sta_info *sta) in sta_get_last_rx_stats() argument
1957 struct ieee80211_sta_rx_stats *stats = &sta->rx_stats; in sta_get_last_rx_stats()
1958 struct ieee80211_local *local = sta->local; in sta_get_last_rx_stats()
1967 cpustats = per_cpu_ptr(sta->pcpu_rx_stats, cpu); in sta_get_last_rx_stats()
2024 static int sta_set_rate_info_rx(struct sta_info *sta, struct rate_info *rinfo) in sta_set_rate_info_rx() argument
2026 u16 rate = READ_ONCE(sta_get_last_rx_stats(sta)->last_rate); in sta_set_rate_info_rx()
2031 sta_stats_decode_rate(sta->local, rate, rinfo); in sta_set_rate_info_rx()
2035 static void sta_set_tidstats(struct sta_info *sta, in sta_set_tidstats() argument
2039 struct ieee80211_local *local = sta->local; in sta_set_tidstats()
2045 start = u64_stats_fetch_begin(&sta->rx_stats.syncp); in sta_set_tidstats()
2046 tidstats->rx_msdu = sta->rx_stats.msdu[tid]; in sta_set_tidstats()
2047 } while (u64_stats_fetch_retry(&sta->rx_stats.syncp, start)); in sta_set_tidstats()
2054 tidstats->tx_msdu = sta->tx_stats.msdu[tid]; in sta_set_tidstats()
2060 tidstats->tx_msdu_retries = sta->status_stats.msdu_retries[tid]; in sta_set_tidstats()
2066 tidstats->tx_msdu_failed = sta->status_stats.msdu_failed[tid]; in sta_set_tidstats()
2075 to_txq_info(sta->sta.txq[tid])); in sta_set_tidstats()
2095 void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo, in sta_set_sinfo() argument
2098 struct ieee80211_sub_if_data *sdata = sta->sdata; in sta_set_sinfo()
2104 last_rxstats = sta_get_last_rx_stats(sta); in sta_set_sinfo()
2115 drv_sta_statistics(local, sdata, &sta->sta, sinfo); in sta_set_sinfo()
2128 sinfo->connected_time = ktime_get_seconds() - sta->last_connected; in sta_set_sinfo()
2130 jiffies_to_msecs(jiffies - ieee80211_sta_last_active(sta)); in sta_set_sinfo()
2136 sinfo->tx_bytes += sta->tx_stats.bytes[ac]; in sta_set_sinfo()
2143 sinfo->tx_packets += sta->tx_stats.packets[ac]; in sta_set_sinfo()
2149 sinfo->rx_bytes += sta_get_stats_bytes(&sta->rx_stats); in sta_set_sinfo()
2151 if (sta->pcpu_rx_stats) { in sta_set_sinfo()
2155 cpurxs = per_cpu_ptr(sta->pcpu_rx_stats, cpu); in sta_set_sinfo()
2164 sinfo->rx_packets = sta->rx_stats.packets; in sta_set_sinfo()
2165 if (sta->pcpu_rx_stats) { in sta_set_sinfo()
2169 cpurxs = per_cpu_ptr(sta->pcpu_rx_stats, cpu); in sta_set_sinfo()
2177 sinfo->tx_retries = sta->status_stats.retry_count; in sta_set_sinfo()
2182 sinfo->tx_failed = sta->status_stats.retry_failed; in sta_set_sinfo()
2186 sinfo->rx_dropped_misc = sta->rx_stats.dropped; in sta_set_sinfo()
2187 if (sta->pcpu_rx_stats) { in sta_set_sinfo()
2191 cpurxs = per_cpu_ptr(sta->pcpu_rx_stats, cpu); in sta_set_sinfo()
2203 if (ieee80211_hw_check(&sta->local->hw, SIGNAL_DBM) || in sta_set_sinfo()
2204 ieee80211_hw_check(&sta->local->hw, SIGNAL_UNSPEC)) { in sta_set_sinfo()
2210 if (!sta->pcpu_rx_stats && in sta_set_sinfo()
2213 -ewma_signal_read(&sta->rx_stats_avg.signal); in sta_set_sinfo()
2226 if (!sta->pcpu_rx_stats) in sta_set_sinfo()
2235 -ewma_signal_read(&sta->rx_stats_avg.chain_signal[i]); in sta_set_sinfo()
2240 sta_set_rate_info_tx(sta, &sta->tx_stats.last_rate, in sta_set_sinfo()
2246 if (sta_set_rate_info_rx(sta, &sinfo->rxrate) == 0) in sta_set_sinfo()
2254 sta_set_tidstats(sta, tidstats, i); in sta_set_sinfo()
2267 sinfo->llid = sta->mesh->llid; in sta_set_sinfo()
2268 sinfo->plid = sta->mesh->plid; in sta_set_sinfo()
2269 sinfo->plink_state = sta->mesh->plink_state; in sta_set_sinfo()
2270 if (test_sta_flag(sta, WLAN_STA_TOFFSET_KNOWN)) { in sta_set_sinfo()
2272 sinfo->t_offset = sta->mesh->t_offset; in sta_set_sinfo()
2274 sinfo->local_pm = sta->mesh->local_pm; in sta_set_sinfo()
2275 sinfo->peer_pm = sta->mesh->peer_pm; in sta_set_sinfo()
2276 sinfo->nonpeer_pm = sta->mesh->nonpeer_pm; in sta_set_sinfo()
2298 if (test_sta_flag(sta, WLAN_STA_AUTHORIZED)) in sta_set_sinfo()
2300 if (test_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE)) in sta_set_sinfo()
2302 if (sta->sta.wme) in sta_set_sinfo()
2304 if (test_sta_flag(sta, WLAN_STA_MFP)) in sta_set_sinfo()
2306 if (test_sta_flag(sta, WLAN_STA_AUTH)) in sta_set_sinfo()
2308 if (test_sta_flag(sta, WLAN_STA_ASSOC)) in sta_set_sinfo()
2310 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER)) in sta_set_sinfo()
2313 thr = sta_get_expected_throughput(sta); in sta_set_sinfo()
2321 sta->status_stats.ack_signal_filled) { in sta_set_sinfo()
2322 sinfo->ack_signal = sta->status_stats.last_ack_signal; in sta_set_sinfo()
2326 if (ieee80211_hw_check(&sta->local->hw, REPORTS_TX_ACK_STATUS) && in sta_set_sinfo()
2330 &sta->status_stats.avg_ack_signal); in sta_set_sinfo()
2336 u32 sta_get_expected_throughput(struct sta_info *sta) in sta_get_expected_throughput() argument
2338 struct ieee80211_sub_if_data *sdata = sta->sdata; in sta_get_expected_throughput()
2343 if (test_sta_flag(sta, WLAN_STA_RATE_CONTROL)) in sta_get_expected_throughput()
2348 thr = ref->ops->get_expected_throughput(sta->rate_ctrl_priv); in sta_get_expected_throughput()
2350 thr = drv_get_expected_throughput(local, sta); in sta_get_expected_throughput()
2355 unsigned long ieee80211_sta_last_active(struct sta_info *sta) in ieee80211_sta_last_active() argument
2357 struct ieee80211_sta_rx_stats *stats = sta_get_last_rx_stats(sta); in ieee80211_sta_last_active()
2359 if (time_after(stats->last_rx, sta->status_stats.last_ack)) in ieee80211_sta_last_active()
2361 return sta->status_stats.last_ack; in ieee80211_sta_last_active()
2364 static void sta_update_codel_params(struct sta_info *sta, u32 thr) in sta_update_codel_params() argument
2366 if (!sta->sdata->local->ops->wake_tx_queue) in sta_update_codel_params()
2369 if (thr && thr < STA_SLOW_THRESHOLD * sta->local->num_sta) { in sta_update_codel_params()
2370 sta->cparams.target = MS2TIME(50); in sta_update_codel_params()
2371 sta->cparams.interval = MS2TIME(300); in sta_update_codel_params()
2372 sta->cparams.ecn = false; in sta_update_codel_params()
2374 sta->cparams.target = MS2TIME(20); in sta_update_codel_params()
2375 sta->cparams.interval = MS2TIME(100); in sta_update_codel_params()
2376 sta->cparams.ecn = true; in sta_update_codel_params()
2383 struct sta_info *sta = container_of(pubsta, struct sta_info, sta); in ieee80211_sta_set_expected_throughput() local
2385 sta_update_codel_params(sta, thr); in ieee80211_sta_set_expected_throughput()