Lines Matching refs:sta

69 	struct ieee80211_link_sta sta;  member
92 struct sta_info *sta) in sta_info_hash_del() argument
94 return rhltable_remove(&local->sta_hash, &sta->hash_node, in sta_info_hash_del()
116 void ieee80211_purge_sta_txqs(struct sta_info *sta) in ieee80211_purge_sta_txqs() argument
118 struct ieee80211_local *local = sta->sdata->local; in ieee80211_purge_sta_txqs()
121 for (i = 0; i < ARRAY_SIZE(sta->sta.txq); i++) { in ieee80211_purge_sta_txqs()
124 if (!sta->sta.txq[i]) in ieee80211_purge_sta_txqs()
127 txqi = to_txq_info(sta->sta.txq[i]); in ieee80211_purge_sta_txqs()
133 static void __cleanup_single_sta(struct sta_info *sta) in __cleanup_single_sta() argument
137 struct ieee80211_sub_if_data *sdata = sta->sdata; in __cleanup_single_sta()
141 if (test_sta_flag(sta, WLAN_STA_PS_STA) || in __cleanup_single_sta()
142 test_sta_flag(sta, WLAN_STA_PS_DRIVER) || in __cleanup_single_sta()
143 test_sta_flag(sta, WLAN_STA_PS_DELIVER)) { in __cleanup_single_sta()
144 if (sta->sdata->vif.type == NL80211_IFTYPE_AP || in __cleanup_single_sta()
145 sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN) in __cleanup_single_sta()
152 clear_sta_flag(sta, WLAN_STA_PS_STA); in __cleanup_single_sta()
153 clear_sta_flag(sta, WLAN_STA_PS_DRIVER); in __cleanup_single_sta()
154 clear_sta_flag(sta, WLAN_STA_PS_DELIVER); in __cleanup_single_sta()
159 ieee80211_purge_sta_txqs(sta); in __cleanup_single_sta()
162 local->total_ps_buffered -= skb_queue_len(&sta->ps_tx_buf[ac]); in __cleanup_single_sta()
163 ieee80211_purge_tx_queue(&local->hw, &sta->ps_tx_buf[ac]); in __cleanup_single_sta()
164 ieee80211_purge_tx_queue(&local->hw, &sta->tx_filtered[ac]); in __cleanup_single_sta()
168 mesh_sta_cleanup(sta); in __cleanup_single_sta()
170 cancel_work_sync(&sta->drv_deliver_wk); in __cleanup_single_sta()
179 kfree(sta->ampdu_mlme.tid_start_tx[i]); in __cleanup_single_sta()
180 tid_tx = rcu_dereference_raw(sta->ampdu_mlme.tid_tx[i]); in __cleanup_single_sta()
188 static void cleanup_single_sta(struct sta_info *sta) in cleanup_single_sta() argument
190 struct ieee80211_sub_if_data *sdata = sta->sdata; in cleanup_single_sta()
193 __cleanup_single_sta(sta); in cleanup_single_sta()
194 sta_info_free(local, sta); in cleanup_single_sta()
209 struct sta_info *sta; in sta_info_get() local
212 for_each_sta_info(local, addr, sta, tmp) { in sta_info_get()
213 if (sta->sdata == sdata) { in sta_info_get()
218 return sta; in sta_info_get()
234 struct sta_info *sta; in sta_info_get_bss() local
237 for_each_sta_info(local, addr, sta, tmp) { in sta_info_get_bss()
238 if (sta->sdata == sdata || in sta_info_get_bss()
239 (sta->sdata->bss && sta->sdata->bss == sdata->bss)) { in sta_info_get_bss()
244 return sta; in sta_info_get_bss()
267 struct sta_info *sta = link_sta->sta; in link_sta_info_get_bss() local
269 if (sta->sdata == sdata || in link_sta_info_get_bss()
270 (sta->sdata->bss && sta->sdata->bss == sdata->bss)) { in link_sta_info_get_bss()
293 struct sta_info *sta = link_sta->sta; in ieee80211_find_sta_by_link_addrs() local
300 return &sta->sta; in ieee80211_find_sta_by_link_addrs()
303 link = rcu_dereference(sta->sdata->link[_link_id]); in ieee80211_find_sta_by_link_addrs()
312 return &sta->sta; in ieee80211_find_sta_by_link_addrs()
323 struct sta_info *sta; in sta_info_get_by_addrs() local
325 for_each_sta_info(local, sta_addr, sta, tmp) { in sta_info_get_by_addrs()
326 if (ether_addr_equal(vif_addr, sta->sdata->vif.addr)) in sta_info_get_by_addrs()
327 return sta; in sta_info_get_by_addrs()
337 struct sta_info *sta; in sta_info_get_by_idx() local
340 list_for_each_entry_rcu(sta, &local->sta_list, list, in sta_info_get_by_idx()
342 if (sdata != sta->sdata) in sta_info_get_by_idx()
348 return sta; in sta_info_get_by_idx()
359 static void sta_remove_link(struct sta_info *sta, unsigned int link_id, in sta_remove_link() argument
365 lockdep_assert_wiphy(sta->local->hw.wiphy); in sta_remove_link()
367 link_sta = rcu_access_pointer(sta->link[link_id]); in sta_remove_link()
372 link_sta_info_hash_del(sta->local, link_sta); in sta_remove_link()
374 if (test_sta_flag(sta, WLAN_STA_INSERTED)) in sta_remove_link()
377 if (link_sta != &sta->deflink) in sta_remove_link()
380 sta->sta.valid_links &= ~BIT(link_id); in sta_remove_link()
381 RCU_INIT_POINTER(sta->link[link_id], NULL); in sta_remove_link()
382 RCU_INIT_POINTER(sta->sta.link[link_id], NULL); in sta_remove_link()
388 ieee80211_sta_recalc_aggregates(&sta->sta); in sta_remove_link()
402 void sta_info_free(struct ieee80211_local *local, struct sta_info *sta) in sta_info_free() argument
406 for (i = 0; i < ARRAY_SIZE(sta->link); i++) { in sta_info_free()
409 link_sta = rcu_access_pointer(sta->link[i]); in sta_info_free()
413 sta_remove_link(sta, i, false); in sta_info_free()
424 while (sta->sta_state > IEEE80211_STA_NONE) { in sta_info_free()
427 WARN_ON_ONCE(test_sta_flag(sta, WLAN_STA_INSERTED)); in sta_info_free()
429 ret = sta_info_move_state(sta, sta->sta_state - 1); in sta_info_free()
434 if (sta->rate_ctrl) in sta_info_free()
435 rate_control_free_sta(sta); in sta_info_free()
437 sta_dbg(sta->sdata, "Destroyed STA %pM\n", sta->sta.addr); in sta_info_free()
439 kfree(to_txq_info(sta->sta.txq[0])); in sta_info_free()
440 kfree(rcu_dereference_raw(sta->sta.rates)); in sta_info_free()
442 kfree(sta->mesh); in sta_info_free()
445 sta_info_free_link(&sta->deflink); in sta_info_free()
446 kfree(sta); in sta_info_free()
450 struct sta_info *sta) in sta_info_hash_add() argument
452 return rhltable_insert(&local->sta_hash, &sta->hash_node, in sta_info_hash_add()
458 struct sta_info *sta; in sta_deliver_ps_frames() local
460 sta = container_of(wk, struct sta_info, drv_deliver_wk); in sta_deliver_ps_frames()
462 if (sta->dead) in sta_deliver_ps_frames()
466 if (!test_sta_flag(sta, WLAN_STA_PS_STA)) in sta_deliver_ps_frames()
467 ieee80211_sta_ps_deliver_wakeup(sta); in sta_deliver_ps_frames()
468 else if (test_and_clear_sta_flag(sta, WLAN_STA_PSPOLL)) in sta_deliver_ps_frames()
469 ieee80211_sta_ps_deliver_poll_response(sta); in sta_deliver_ps_frames()
470 else if (test_and_clear_sta_flag(sta, WLAN_STA_UAPSD)) in sta_deliver_ps_frames()
471 ieee80211_sta_ps_deliver_uapsd(sta); in sta_deliver_ps_frames()
476 struct sta_info *sta, gfp_t gfp) in sta_prepare_rate_control() argument
481 sta->rate_ctrl = local->rate_ctrl; in sta_prepare_rate_control()
482 sta->rate_ctrl_priv = rate_control_alloc_sta(sta->rate_ctrl, in sta_prepare_rate_control()
483 sta, gfp); in sta_prepare_rate_control()
484 if (!sta->rate_ctrl_priv) in sta_prepare_rate_control()
515 static void sta_info_add_link(struct sta_info *sta, in sta_info_add_link() argument
520 link_info->sta = sta; in sta_info_add_link()
523 link_info->pub->sta = &sta->sta; in sta_info_add_link()
525 rcu_assign_pointer(sta->link[link_id], link_info); in sta_info_add_link()
526 rcu_assign_pointer(sta->sta.link[link_id], link_sta); in sta_info_add_link()
539 struct sta_info *sta; in __sta_info_alloc() local
544 sta = kzalloc(sizeof(*sta) + hw->sta_data_size, gfp); in __sta_info_alloc()
545 if (!sta) in __sta_info_alloc()
548 sta->local = local; in __sta_info_alloc()
549 sta->sdata = sdata; in __sta_info_alloc()
551 if (sta_info_alloc_link(local, &sta->deflink, gfp)) in __sta_info_alloc()
555 sta_info_add_link(sta, link_id, &sta->deflink, in __sta_info_alloc()
556 &sta->sta.deflink); in __sta_info_alloc()
557 sta->sta.valid_links = BIT(link_id); in __sta_info_alloc()
559 sta_info_add_link(sta, 0, &sta->deflink, &sta->sta.deflink); in __sta_info_alloc()
562 sta->sta.cur = &sta->sta.deflink.agg; in __sta_info_alloc()
564 spin_lock_init(&sta->lock); in __sta_info_alloc()
565 spin_lock_init(&sta->ps_lock); in __sta_info_alloc()
566 INIT_WORK(&sta->drv_deliver_wk, sta_deliver_ps_frames); in __sta_info_alloc()
567 wiphy_work_init(&sta->ampdu_mlme.work, ieee80211_ba_session_work); in __sta_info_alloc()
570 sta->mesh = kzalloc(sizeof(*sta->mesh), gfp); in __sta_info_alloc()
571 if (!sta->mesh) in __sta_info_alloc()
573 sta->mesh->plink_sta = sta; in __sta_info_alloc()
574 spin_lock_init(&sta->mesh->plink_lock); in __sta_info_alloc()
576 timer_setup(&sta->mesh->plink_timer, mesh_plink_timer, in __sta_info_alloc()
578 sta->mesh->nonpeer_pm = NL80211_MESH_POWER_ACTIVE; in __sta_info_alloc()
582 memcpy(sta->addr, addr, ETH_ALEN); in __sta_info_alloc()
583 memcpy(sta->sta.addr, addr, ETH_ALEN); in __sta_info_alloc()
584 memcpy(sta->deflink.addr, link_addr, ETH_ALEN); in __sta_info_alloc()
585 memcpy(sta->sta.deflink.addr, link_addr, ETH_ALEN); in __sta_info_alloc()
586 sta->sta.max_rx_aggregation_subframes = in __sta_info_alloc()
597 BUILD_BUG_ON(ARRAY_SIZE(sta->ptk) <= INVALID_PTK_KEYIDX); in __sta_info_alloc()
598 sta->ptk_idx = INVALID_PTK_KEYIDX; in __sta_info_alloc()
601 ieee80211_init_frag_cache(&sta->frags); in __sta_info_alloc()
603 sta->sta_state = IEEE80211_STA_NONE; in __sta_info_alloc()
606 sta->amsdu_mesh_control = -1; in __sta_info_alloc()
609 sta->reserved_tid = IEEE80211_TID_UNRESERVED; in __sta_info_alloc()
611 sta->last_connected = ktime_get_seconds(); in __sta_info_alloc()
616 txq_data = kcalloc(ARRAY_SIZE(sta->sta.txq), size, gfp); in __sta_info_alloc()
620 for (i = 0; i < ARRAY_SIZE(sta->sta.txq); i++) { in __sta_info_alloc()
624 ieee80211_txq_init(sdata, sta, txq, i); in __sta_info_alloc()
627 if (sta_prepare_rate_control(local, sta, gfp)) in __sta_info_alloc()
630 sta->airtime_weight = IEEE80211_DEFAULT_AIRTIME_WEIGHT; in __sta_info_alloc()
633 skb_queue_head_init(&sta->ps_tx_buf[i]); in __sta_info_alloc()
634 skb_queue_head_init(&sta->tx_filtered[i]); in __sta_info_alloc()
635 sta->airtime[i].deficit = sta->airtime_weight; in __sta_info_alloc()
636 atomic_set(&sta->airtime[i].aql_tx_pending, 0); in __sta_info_alloc()
637 sta->airtime[i].aql_limit_low = local->aql_txq_limit_low[i]; in __sta_info_alloc()
638 sta->airtime[i].aql_limit_high = local->aql_txq_limit_high[i]; in __sta_info_alloc()
642 sta->last_seq_ctrl[i] = cpu_to_le16(USHRT_MAX); in __sta_info_alloc()
682 sta->sta.deflink.supp_rates[i] |= BIT(r); in __sta_info_alloc()
686 sta->cparams.ce_threshold = CODEL_DISABLED_THRESHOLD; in __sta_info_alloc()
687 sta->cparams.target = MS2TIME(20); in __sta_info_alloc()
688 sta->cparams.interval = MS2TIME(100); in __sta_info_alloc()
689 sta->cparams.ecn = true; in __sta_info_alloc()
690 sta->cparams.ce_threshold_selector = 0; in __sta_info_alloc()
691 sta->cparams.ce_threshold_mask = 0; in __sta_info_alloc()
693 sta_dbg(sdata, "Allocated STA %pM\n", sta->sta.addr); in __sta_info_alloc()
695 return sta; in __sta_info_alloc()
698 kfree(to_txq_info(sta->sta.txq[0])); in __sta_info_alloc()
700 sta_info_free_link(&sta->deflink); in __sta_info_alloc()
702 kfree(sta->mesh); in __sta_info_alloc()
704 kfree(sta); in __sta_info_alloc()
723 static int sta_info_insert_check(struct sta_info *sta) in sta_info_insert_check() argument
725 struct ieee80211_sub_if_data *sdata = sta->sdata; in sta_info_insert_check()
737 if (WARN_ON(ether_addr_equal(sta->sta.addr, sdata->vif.addr) || in sta_info_insert_check()
738 !is_valid_ether_addr(sta->sta.addr))) in sta_info_insert_check()
747 ieee80211_find_sta_by_ifaddr(&sdata->local->hw, sta->addr, NULL)) { in sta_info_insert_check()
758 struct sta_info *sta) in sta_info_insert_drv_state() argument
763 for (state = IEEE80211_STA_NOTEXIST; state < sta->sta_state; state++) { in sta_info_insert_drv_state()
764 err = drv_sta_state(local, sdata, sta, state, state + 1); in sta_info_insert_drv_state()
775 sta->uploaded = true; in sta_info_insert_drv_state()
782 sta->sta.addr, state + 1, err); in sta_info_insert_drv_state()
788 WARN_ON(drv_sta_state(local, sdata, sta, state, state - 1)); in sta_info_insert_drv_state()
798 struct sta_info *sta; in ieee80211_recalc_p2p_go_ps_allowed() local
801 list_for_each_entry_rcu(sta, &local->sta_list, list) { in ieee80211_recalc_p2p_go_ps_allowed()
802 if (sdata != sta->sdata || in ieee80211_recalc_p2p_go_ps_allowed()
803 !test_sta_flag(sta, WLAN_STA_ASSOC)) in ieee80211_recalc_p2p_go_ps_allowed()
805 if (!sta->sta.support_p2p_ps) { in ieee80211_recalc_p2p_go_ps_allowed()
819 static int sta_info_insert_finish(struct sta_info *sta) __acquires(RCU) in sta_info_insert_finish() argument
821 struct ieee80211_local *local = sta->local; in sta_info_insert_finish()
822 struct ieee80211_sub_if_data *sdata = sta->sdata; in sta_info_insert_finish()
829 if (sta_info_get_bss(sdata, sta->sta.addr)) { in sta_info_insert_finish()
845 set_sta_flag(sta, WLAN_STA_BLOCK_BA); in sta_info_insert_finish()
848 err = sta_info_hash_add(local, sta); in sta_info_insert_finish()
852 if (sta->sta.valid_links) { in sta_info_insert_finish()
853 err = link_sta_info_hash_add(local, &sta->deflink); in sta_info_insert_finish()
855 sta_info_hash_del(local, sta); in sta_info_insert_finish()
860 list_add_tail_rcu(&sta->list, &local->sta_list); in sta_info_insert_finish()
865 if (sta->sta_state >= IEEE80211_STA_ASSOC) { in sta_info_insert_finish()
866 ieee80211_recalc_min_chandef(sta->sdata, -1); in sta_info_insert_finish()
867 if (!sta->sta.support_p2p_ps) in sta_info_insert_finish()
868 ieee80211_recalc_p2p_go_ps_allowed(sta->sdata); in sta_info_insert_finish()
872 err = sta_info_insert_drv_state(local, sdata, sta); in sta_info_insert_finish()
876 set_sta_flag(sta, WLAN_STA_INSERTED); in sta_info_insert_finish()
879 clear_sta_flag(sta, WLAN_STA_BLOCK_BA); in sta_info_insert_finish()
881 ieee80211_sta_debugfs_add(sta); in sta_info_insert_finish()
882 rate_control_add_sta_debugfs(sta); in sta_info_insert_finish()
883 if (sta->sta.valid_links) { in sta_info_insert_finish()
886 for (i = 0; i < ARRAY_SIZE(sta->link); i++) { in sta_info_insert_finish()
889 link_sta = rcu_dereference_protected(sta->link[i], in sta_info_insert_finish()
900 ieee80211_link_sta_debugfs_add(&sta->deflink); in sta_info_insert_finish()
901 ieee80211_link_sta_debugfs_drv_add(&sta->deflink); in sta_info_insert_finish()
905 cfg80211_new_sta(sdata->dev, sta->sta.addr, sinfo, GFP_KERNEL); in sta_info_insert_finish()
908 sta_dbg(sdata, "Inserted STA %pM\n", sta->sta.addr); in sta_info_insert_finish()
916 ieee80211_check_fast_xmit(sta); in sta_info_insert_finish()
920 if (sta->sta.valid_links) in sta_info_insert_finish()
921 link_sta_info_hash_del(local, &sta->deflink); in sta_info_insert_finish()
922 sta_info_hash_del(local, sta); in sta_info_insert_finish()
923 list_del_rcu(&sta->list); in sta_info_insert_finish()
928 cleanup_single_sta(sta); in sta_info_insert_finish()
934 int sta_info_insert_rcu(struct sta_info *sta) __acquires(RCU) in sta_info_insert_rcu() argument
936 struct ieee80211_local *local = sta->local; in sta_info_insert_rcu()
942 err = sta_info_insert_check(sta); in sta_info_insert_rcu()
944 sta_info_free(local, sta); in sta_info_insert_rcu()
949 return sta_info_insert_finish(sta); in sta_info_insert_rcu()
952 int sta_info_insert(struct sta_info *sta) in sta_info_insert() argument
954 int err = sta_info_insert_rcu(sta); in sta_info_insert()
1006 static void __sta_info_recalc_tim(struct sta_info *sta, bool ignore_pending) in __sta_info_recalc_tim() argument
1008 struct ieee80211_local *local = sta->local; in __sta_info_recalc_tim()
1011 u8 ignore_for_tim = sta->sta.uapsd_queues; in __sta_info_recalc_tim()
1013 u16 id = sta->sta.aid; in __sta_info_recalc_tim()
1015 if (sta->sdata->vif.type == NL80211_IFTYPE_AP || in __sta_info_recalc_tim()
1016 sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN) { in __sta_info_recalc_tim()
1017 if (WARN_ON_ONCE(!sta->sdata->bss)) in __sta_info_recalc_tim()
1020 ps = &sta->sdata->bss->ps; in __sta_info_recalc_tim()
1022 } else if (ieee80211_vif_is_mesh(&sta->sdata->vif)) { in __sta_info_recalc_tim()
1023 ps = &sta->sdata->u.mesh.ps; in __sta_info_recalc_tim()
1033 if (sta->dead) in __sta_info_recalc_tim()
1054 indicate_tim |= !skb_queue_empty(&sta->tx_filtered[ac]) || in __sta_info_recalc_tim()
1055 !skb_queue_empty(&sta->ps_tx_buf[ac]); in __sta_info_recalc_tim()
1062 sta->driver_buffered_tids & tids; in __sta_info_recalc_tim()
1064 sta->txq_buffered_tids & tids; in __sta_info_recalc_tim()
1078 if (local->ops->set_tim && !WARN_ON(sta->dead)) { in __sta_info_recalc_tim()
1080 drv_set_tim(local, &sta->sta, indicate_tim); in __sta_info_recalc_tim()
1088 void sta_info_recalc_tim(struct sta_info *sta) in sta_info_recalc_tim() argument
1090 __sta_info_recalc_tim(sta, false); in sta_info_recalc_tim()
1093 static bool sta_info_buffer_expired(struct sta_info *sta, struct sk_buff *skb) in sta_info_buffer_expired() argument
1104 timeout = (sta->listen_interval * in sta_info_buffer_expired()
1105 sta->sdata->vif.bss_conf.beacon_int * in sta_info_buffer_expired()
1114 struct sta_info *sta, int ac) in sta_info_cleanup_expire_buffered_ac() argument
1127 spin_lock_irqsave(&sta->tx_filtered[ac].lock, flags); in sta_info_cleanup_expire_buffered_ac()
1128 skb = skb_peek(&sta->tx_filtered[ac]); in sta_info_cleanup_expire_buffered_ac()
1129 if (sta_info_buffer_expired(sta, skb)) in sta_info_cleanup_expire_buffered_ac()
1130 skb = __skb_dequeue(&sta->tx_filtered[ac]); in sta_info_cleanup_expire_buffered_ac()
1133 spin_unlock_irqrestore(&sta->tx_filtered[ac].lock, flags); in sta_info_cleanup_expire_buffered_ac()
1153 spin_lock_irqsave(&sta->ps_tx_buf[ac].lock, flags); in sta_info_cleanup_expire_buffered_ac()
1154 skb = skb_peek(&sta->ps_tx_buf[ac]); in sta_info_cleanup_expire_buffered_ac()
1155 if (sta_info_buffer_expired(sta, skb)) in sta_info_cleanup_expire_buffered_ac()
1156 skb = __skb_dequeue(&sta->ps_tx_buf[ac]); in sta_info_cleanup_expire_buffered_ac()
1159 spin_unlock_irqrestore(&sta->ps_tx_buf[ac].lock, flags); in sta_info_cleanup_expire_buffered_ac()
1170 ps_dbg(sta->sdata, "Buffered frame expired (STA %pM)\n", in sta_info_cleanup_expire_buffered_ac()
1171 sta->sta.addr); in sta_info_cleanup_expire_buffered_ac()
1180 sta_info_recalc_tim(sta); in sta_info_cleanup_expire_buffered_ac()
1187 return !(skb_queue_empty(&sta->ps_tx_buf[ac]) && in sta_info_cleanup_expire_buffered_ac()
1188 skb_queue_empty(&sta->tx_filtered[ac])); in sta_info_cleanup_expire_buffered_ac()
1192 struct sta_info *sta) in sta_info_cleanup_expire_buffered() argument
1198 if (!sta->sdata->bss && in sta_info_cleanup_expire_buffered()
1199 !ieee80211_vif_is_mesh(&sta->sdata->vif)) in sta_info_cleanup_expire_buffered()
1204 sta_info_cleanup_expire_buffered_ac(local, sta, ac); in sta_info_cleanup_expire_buffered()
1209 static int __must_check __sta_info_destroy_part1(struct sta_info *sta) in __sta_info_destroy_part1() argument
1217 if (!sta) in __sta_info_destroy_part1()
1220 local = sta->local; in __sta_info_destroy_part1()
1221 sdata = sta->sdata; in __sta_info_destroy_part1()
1231 set_sta_flag(sta, WLAN_STA_BLOCK_BA); in __sta_info_destroy_part1()
1232 ieee80211_sta_tear_down_BA_sessions(sta, AGG_STOP_DESTROY_STA); in __sta_info_destroy_part1()
1239 drv_sync_rx_queues(local, sta); in __sta_info_destroy_part1()
1241 for (i = 0; i < ARRAY_SIZE(sta->link); i++) { in __sta_info_destroy_part1()
1244 if (!(sta->sta.valid_links & BIT(i))) in __sta_info_destroy_part1()
1247 link_sta = rcu_dereference_protected(sta->link[i], in __sta_info_destroy_part1()
1253 ret = sta_info_hash_del(local, sta); in __sta_info_destroy_part1()
1261 if (test_sta_flag(sta, WLAN_STA_TDLS_OFF_CHANNEL)) { in __sta_info_destroy_part1()
1262 drv_tdls_cancel_channel_switch(local, sdata, &sta->sta); in __sta_info_destroy_part1()
1263 clear_sta_flag(sta, WLAN_STA_TDLS_OFF_CHANNEL); in __sta_info_destroy_part1()
1266 list_del_rcu(&sta->list); in __sta_info_destroy_part1()
1267 sta->removed = true; in __sta_info_destroy_part1()
1269 if (sta->uploaded) in __sta_info_destroy_part1()
1270 drv_sta_pre_rcu_remove(local, sta->sdata, sta); in __sta_info_destroy_part1()
1273 rcu_access_pointer(sdata->u.vlan.sta) == sta) in __sta_info_destroy_part1()
1274 RCU_INIT_POINTER(sdata->u.vlan.sta, NULL); in __sta_info_destroy_part1()
1279 static int _sta_info_move_state(struct sta_info *sta, in _sta_info_move_state() argument
1283 struct ieee80211_local *local = sta->local; in _sta_info_move_state()
1287 if (sta->sta_state == new_state) in _sta_info_move_state()
1294 if (sta->sta_state != IEEE80211_STA_AUTH) in _sta_info_move_state()
1298 if (sta->sta_state != IEEE80211_STA_NONE && in _sta_info_move_state()
1299 sta->sta_state != IEEE80211_STA_ASSOC) in _sta_info_move_state()
1303 if (sta->sta_state != IEEE80211_STA_AUTH && in _sta_info_move_state()
1304 sta->sta_state != IEEE80211_STA_AUTHORIZED) in _sta_info_move_state()
1308 if (sta->sta_state != IEEE80211_STA_ASSOC) in _sta_info_move_state()
1316 sta_dbg(sta->sdata, "moving STA %pM to state %d\n", in _sta_info_move_state()
1317 sta->sta.addr, new_state); in _sta_info_move_state()
1322 if (test_sta_flag(sta, WLAN_STA_INSERTED)) { in _sta_info_move_state()
1323 int err = drv_sta_state(sta->local, sta->sdata, sta, in _sta_info_move_state()
1324 sta->sta_state, new_state); in _sta_info_move_state()
1333 if (sta->sta_state == IEEE80211_STA_AUTH) in _sta_info_move_state()
1334 clear_bit(WLAN_STA_AUTH, &sta->_flags); in _sta_info_move_state()
1337 if (sta->sta_state == IEEE80211_STA_NONE) { in _sta_info_move_state()
1338 set_bit(WLAN_STA_AUTH, &sta->_flags); in _sta_info_move_state()
1339 } else if (sta->sta_state == IEEE80211_STA_ASSOC) { in _sta_info_move_state()
1340 clear_bit(WLAN_STA_ASSOC, &sta->_flags); in _sta_info_move_state()
1342 ieee80211_recalc_min_chandef(sta->sdata, -1); in _sta_info_move_state()
1343 if (!sta->sta.support_p2p_ps) in _sta_info_move_state()
1344 ieee80211_recalc_p2p_go_ps_allowed(sta->sdata); in _sta_info_move_state()
1349 if (sta->sta_state == IEEE80211_STA_AUTH) { in _sta_info_move_state()
1350 set_bit(WLAN_STA_ASSOC, &sta->_flags); in _sta_info_move_state()
1351 sta->assoc_at = ktime_get_boottime_ns(); in _sta_info_move_state()
1353 ieee80211_recalc_min_chandef(sta->sdata, -1); in _sta_info_move_state()
1354 if (!sta->sta.support_p2p_ps) in _sta_info_move_state()
1355 ieee80211_recalc_p2p_go_ps_allowed(sta->sdata); in _sta_info_move_state()
1357 } else if (sta->sta_state == IEEE80211_STA_AUTHORIZED) { in _sta_info_move_state()
1358 ieee80211_vif_dec_num_mcast(sta->sdata); in _sta_info_move_state()
1359 clear_bit(WLAN_STA_AUTHORIZED, &sta->_flags); in _sta_info_move_state()
1371 drv_flush_sta(local, sta->sdata, sta); in _sta_info_move_state()
1374 sta->sdata, in _sta_info_move_state()
1378 ieee80211_clear_fast_xmit(sta); in _sta_info_move_state()
1379 ieee80211_clear_fast_rx(sta); in _sta_info_move_state()
1383 if (sta->sta_state == IEEE80211_STA_ASSOC) { in _sta_info_move_state()
1384 ieee80211_vif_inc_num_mcast(sta->sdata); in _sta_info_move_state()
1385 set_bit(WLAN_STA_AUTHORIZED, &sta->_flags); in _sta_info_move_state()
1386 ieee80211_check_fast_xmit(sta); in _sta_info_move_state()
1387 ieee80211_check_fast_rx(sta); in _sta_info_move_state()
1389 if (sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN || in _sta_info_move_state()
1390 sta->sdata->vif.type == NL80211_IFTYPE_AP) in _sta_info_move_state()
1391 cfg80211_send_layer2_update(sta->sdata->dev, in _sta_info_move_state()
1392 sta->sta.addr); in _sta_info_move_state()
1398 sta->sta_state = new_state; in _sta_info_move_state()
1403 int sta_info_move_state(struct sta_info *sta, in sta_info_move_state() argument
1406 return _sta_info_move_state(sta, new_state, true); in sta_info_move_state()
1409 static void __sta_info_destroy_part2(struct sta_info *sta, bool recalc) in __sta_info_destroy_part2() argument
1411 struct ieee80211_local *local = sta->local; in __sta_info_destroy_part2()
1412 struct ieee80211_sub_if_data *sdata = sta->sdata; in __sta_info_destroy_part2()
1433 ieee80211_sta_tear_down_BA_sessions(sta, AGG_STOP_DESTROY_STA); in __sta_info_destroy_part2()
1438 if (sta->sta_state == IEEE80211_STA_AUTHORIZED) { in __sta_info_destroy_part2()
1439 ret = _sta_info_move_state(sta, IEEE80211_STA_ASSOC, recalc); in __sta_info_destroy_part2()
1444 ieee80211_free_sta_keys(local, sta); in __sta_info_destroy_part2()
1447 __sta_info_recalc_tim(sta, true); in __sta_info_destroy_part2()
1449 sta->dead = true; in __sta_info_destroy_part2()
1454 while (sta->sta_state > IEEE80211_STA_NONE) { in __sta_info_destroy_part2()
1455 ret = _sta_info_move_state(sta, sta->sta_state - 1, recalc); in __sta_info_destroy_part2()
1462 if (sta->uploaded) { in __sta_info_destroy_part2()
1463 ret = drv_sta_state(local, sdata, sta, IEEE80211_STA_NONE, in __sta_info_destroy_part2()
1468 sta_dbg(sdata, "Removed STA %pM\n", sta->sta.addr); in __sta_info_destroy_part2()
1472 sta_set_sinfo(sta, sinfo, true); in __sta_info_destroy_part2()
1473 cfg80211_del_sta_sinfo(sdata->dev, sta->sta.addr, sinfo, GFP_KERNEL); in __sta_info_destroy_part2()
1476 ieee80211_sta_debugfs_remove(sta); in __sta_info_destroy_part2()
1478 ieee80211_destroy_frag_cache(&sta->frags); in __sta_info_destroy_part2()
1480 cleanup_single_sta(sta); in __sta_info_destroy_part2()
1483 int __must_check __sta_info_destroy(struct sta_info *sta) in __sta_info_destroy() argument
1485 int err = __sta_info_destroy_part1(sta); in __sta_info_destroy()
1492 __sta_info_destroy_part2(sta, true); in __sta_info_destroy()
1499 struct sta_info *sta; in sta_info_destroy_addr() local
1503 sta = sta_info_get(sdata, addr); in sta_info_destroy_addr()
1504 return __sta_info_destroy(sta); in sta_info_destroy_addr()
1510 struct sta_info *sta; in sta_info_destroy_addr_bss() local
1514 sta = sta_info_get_bss(sdata, addr); in sta_info_destroy_addr_bss()
1515 return __sta_info_destroy(sta); in sta_info_destroy_addr_bss()
1521 struct sta_info *sta; in sta_info_cleanup() local
1525 list_for_each_entry_rcu(sta, &local->sta_list, list) in sta_info_cleanup()
1526 if (sta_info_cleanup_expire_buffered(local, sta)) in sta_info_cleanup()
1573 struct sta_info *sta, *tmp; in __sta_info_flush() local
1583 list_for_each_entry_safe(sta, tmp, &local->sta_list, list) { in __sta_info_flush()
1584 if (sdata != sta->sdata && in __sta_info_flush()
1585 (!vlans || sdata->bss != sta->sdata->bss)) in __sta_info_flush()
1588 if (link_id >= 0 && sta->sta.valid_links && in __sta_info_flush()
1589 !(sta->sta.valid_links & BIT(link_id))) in __sta_info_flush()
1592 if (!WARN_ON(__sta_info_destroy_part1(sta))) in __sta_info_flush()
1593 list_add(&sta->free_list, &free_list); in __sta_info_flush()
1602 list_for_each_entry_safe(sta, tmp, &free_list, free_list) { in __sta_info_flush()
1603 if (!sta->sta.support_p2p_ps) in __sta_info_flush()
1605 __sta_info_destroy_part2(sta, false); in __sta_info_flush()
1620 struct sta_info *sta, *tmp; in ieee80211_sta_expire() local
1624 list_for_each_entry_safe(sta, tmp, &local->sta_list, list) { in ieee80211_sta_expire()
1625 unsigned long last_active = ieee80211_sta_last_active(sta); in ieee80211_sta_expire()
1627 if (sdata != sta->sdata) in ieee80211_sta_expire()
1631 sta_dbg(sta->sdata, "expiring inactive STA %pM\n", in ieee80211_sta_expire()
1632 sta->sta.addr); in ieee80211_sta_expire()
1635 test_sta_flag(sta, WLAN_STA_PS_STA)) in ieee80211_sta_expire()
1638 WARN_ON(__sta_info_destroy(sta)); in ieee80211_sta_expire()
1649 struct sta_info *sta; in ieee80211_find_sta_by_ifaddr() local
1655 for_each_sta_info(local, addr, sta, tmp) { in ieee80211_find_sta_by_ifaddr()
1657 !ether_addr_equal(sta->sdata->vif.addr, localaddr)) in ieee80211_find_sta_by_ifaddr()
1659 if (!sta->uploaded) in ieee80211_find_sta_by_ifaddr()
1661 return &sta->sta; in ieee80211_find_sta_by_ifaddr()
1671 struct sta_info *sta; in ieee80211_find_sta() local
1676 sta = sta_info_get_bss(vif_to_sdata(vif), addr); in ieee80211_find_sta()
1677 if (!sta) in ieee80211_find_sta()
1680 if (!sta->uploaded) in ieee80211_find_sta()
1683 return &sta->sta; in ieee80211_find_sta()
1688 void ieee80211_sta_ps_deliver_wakeup(struct sta_info *sta) in ieee80211_sta_ps_deliver_wakeup() argument
1690 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_sta_ps_deliver_wakeup()
1708 clear_sta_flag(sta, WLAN_STA_SP); in ieee80211_sta_ps_deliver_wakeup()
1711 sta->driver_buffered_tids = 0; in ieee80211_sta_ps_deliver_wakeup()
1712 sta->txq_buffered_tids = 0; in ieee80211_sta_ps_deliver_wakeup()
1715 drv_sta_notify(local, sdata, STA_NOTIFY_AWAKE, &sta->sta); in ieee80211_sta_ps_deliver_wakeup()
1717 for (i = 0; i < ARRAY_SIZE(sta->sta.txq); i++) { in ieee80211_sta_ps_deliver_wakeup()
1718 if (!sta->sta.txq[i] || !txq_has_queue(sta->sta.txq[i])) in ieee80211_sta_ps_deliver_wakeup()
1721 schedule_and_wake_txq(local, to_txq_info(sta->sta.txq[i])); in ieee80211_sta_ps_deliver_wakeup()
1727 spin_lock_bh(&sta->ps_lock); in ieee80211_sta_ps_deliver_wakeup()
1732 spin_lock_irqsave(&sta->tx_filtered[ac].lock, flags); in ieee80211_sta_ps_deliver_wakeup()
1733 skb_queue_splice_tail_init(&sta->tx_filtered[ac], &pending); in ieee80211_sta_ps_deliver_wakeup()
1734 spin_unlock_irqrestore(&sta->tx_filtered[ac].lock, flags); in ieee80211_sta_ps_deliver_wakeup()
1739 spin_lock_irqsave(&sta->ps_tx_buf[ac].lock, flags); in ieee80211_sta_ps_deliver_wakeup()
1740 skb_queue_splice_tail_init(&sta->ps_tx_buf[ac], &pending); in ieee80211_sta_ps_deliver_wakeup()
1741 spin_unlock_irqrestore(&sta->ps_tx_buf[ac].lock, flags); in ieee80211_sta_ps_deliver_wakeup()
1749 clear_sta_flag(sta, WLAN_STA_PS_DELIVER); in ieee80211_sta_ps_deliver_wakeup()
1754 clear_sta_flag(sta, WLAN_STA_PSPOLL); in ieee80211_sta_ps_deliver_wakeup()
1755 clear_sta_flag(sta, WLAN_STA_UAPSD); in ieee80211_sta_ps_deliver_wakeup()
1756 spin_unlock_bh(&sta->ps_lock); in ieee80211_sta_ps_deliver_wakeup()
1762 sta_info_recalc_tim(sta); in ieee80211_sta_ps_deliver_wakeup()
1766 sta->sta.addr, sta->sta.aid, filtered, buffered); in ieee80211_sta_ps_deliver_wakeup()
1768 ieee80211_check_fast_xmit(sta); in ieee80211_sta_ps_deliver_wakeup()
1771 static void ieee80211_send_null_response(struct sta_info *sta, int tid, in ieee80211_send_null_response() argument
1775 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_send_null_response()
1781 bool qos = sta->sta.wme; in ieee80211_send_null_response()
1805 memcpy(nullfunc->addr1, sta->sta.addr, ETH_ALEN); in ieee80211_send_null_response()
1839 drv_allow_buffered_frames(local, sta, BIT(tid), 1, in ieee80211_send_null_response()
1853 ieee80211_xmit(sdata, sta, skb); in ieee80211_send_null_response()
1874 ieee80211_sta_ps_more_data(struct sta_info *sta, u8 ignored_acs, in ieee80211_sta_ps_more_data() argument
1893 if (!skb_queue_empty(&sta->tx_filtered[ac]) || in ieee80211_sta_ps_more_data()
1894 !skb_queue_empty(&sta->ps_tx_buf[ac])) in ieee80211_sta_ps_more_data()
1902 ieee80211_sta_ps_get_frames(struct sta_info *sta, int n_frames, u8 ignored_acs, in ieee80211_sta_ps_get_frames() argument
1907 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_sta_ps_get_frames()
1925 sta->driver_buffered_tids & tids; in ieee80211_sta_ps_get_frames()
1926 *driver_release_tids |= sta->txq_buffered_tids & tids; in ieee80211_sta_ps_get_frames()
1933 skb = skb_dequeue(&sta->tx_filtered[ac]); in ieee80211_sta_ps_get_frames()
1936 &sta->ps_tx_buf[ac]); in ieee80211_sta_ps_get_frames()
1951 if (!skb_queue_empty(&sta->tx_filtered[ac]) || in ieee80211_sta_ps_get_frames()
1952 !skb_queue_empty(&sta->ps_tx_buf[ac])) in ieee80211_sta_ps_get_frames()
1958 ieee80211_sta_ps_deliver_response(struct sta_info *sta, in ieee80211_sta_ps_deliver_response() argument
1962 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_sta_ps_deliver_response()
1969 set_sta_flag(sta, WLAN_STA_SP); in ieee80211_sta_ps_deliver_response()
1973 ieee80211_sta_ps_get_frames(sta, n_frames, ignored_acs, reason, in ieee80211_sta_ps_deliver_response()
1976 more_data = ieee80211_sta_ps_more_data(sta, ignored_acs, reason, driver_release_tids); in ieee80211_sta_ps_deliver_response()
2006 ieee80211_send_null_response(sta, tid, reason, true, false); in ieee80211_sta_ps_deliver_response()
2099 drv_allow_buffered_frames(local, sta, tids, num, in ieee80211_sta_ps_deliver_response()
2106 sta, find_highest_prio_tid(tids), in ieee80211_sta_ps_deliver_response()
2109 sta_info_recalc_tim(sta); in ieee80211_sta_ps_deliver_response()
2123 drv_release_buffered_frames(local, sta, driver_release_tids, in ieee80211_sta_ps_deliver_response()
2136 for (tid = 0; tid < ARRAY_SIZE(sta->sta.txq); tid++) { in ieee80211_sta_ps_deliver_response()
2137 if (!sta->sta.txq[tid] || in ieee80211_sta_ps_deliver_response()
2139 txq_has_queue(sta->sta.txq[tid])) in ieee80211_sta_ps_deliver_response()
2142 sta_info_recalc_tim(sta); in ieee80211_sta_ps_deliver_response()
2148 void ieee80211_sta_ps_deliver_poll_response(struct sta_info *sta) in ieee80211_sta_ps_deliver_poll_response() argument
2150 u8 ignore_for_response = sta->sta.uapsd_queues; in ieee80211_sta_ps_deliver_poll_response()
2160 ieee80211_sta_ps_deliver_response(sta, 1, ignore_for_response, in ieee80211_sta_ps_deliver_poll_response()
2164 void ieee80211_sta_ps_deliver_uapsd(struct sta_info *sta) in ieee80211_sta_ps_deliver_uapsd() argument
2166 int n_frames = sta->sta.max_sp; in ieee80211_sta_ps_deliver_uapsd()
2167 u8 delivery_enabled = sta->sta.uapsd_queues; in ieee80211_sta_ps_deliver_uapsd()
2178 switch (sta->sta.max_sp) { in ieee80211_sta_ps_deliver_uapsd()
2194 ieee80211_sta_ps_deliver_response(sta, n_frames, ~delivery_enabled, in ieee80211_sta_ps_deliver_uapsd()
2201 struct sta_info *sta = container_of(pubsta, struct sta_info, sta); in ieee80211_sta_block_awake() local
2203 trace_api_sta_block_awake(sta->local, pubsta, block); in ieee80211_sta_block_awake()
2206 set_sta_flag(sta, WLAN_STA_PS_DRIVER); in ieee80211_sta_block_awake()
2207 ieee80211_clear_fast_xmit(sta); in ieee80211_sta_block_awake()
2211 if (!test_sta_flag(sta, WLAN_STA_PS_DRIVER)) in ieee80211_sta_block_awake()
2214 if (!test_sta_flag(sta, WLAN_STA_PS_STA)) { in ieee80211_sta_block_awake()
2215 set_sta_flag(sta, WLAN_STA_PS_DELIVER); in ieee80211_sta_block_awake()
2216 clear_sta_flag(sta, WLAN_STA_PS_DRIVER); in ieee80211_sta_block_awake()
2217 ieee80211_queue_work(hw, &sta->drv_deliver_wk); in ieee80211_sta_block_awake()
2218 } else if (test_sta_flag(sta, WLAN_STA_PSPOLL) || in ieee80211_sta_block_awake()
2219 test_sta_flag(sta, WLAN_STA_UAPSD)) { in ieee80211_sta_block_awake()
2221 clear_sta_flag(sta, WLAN_STA_PS_DRIVER); in ieee80211_sta_block_awake()
2222 ieee80211_queue_work(hw, &sta->drv_deliver_wk); in ieee80211_sta_block_awake()
2224 clear_sta_flag(sta, WLAN_STA_PS_DRIVER); in ieee80211_sta_block_awake()
2225 ieee80211_check_fast_xmit(sta); in ieee80211_sta_block_awake()
2232 struct sta_info *sta = container_of(pubsta, struct sta_info, sta); in ieee80211_sta_eosp() local
2233 struct ieee80211_local *local = sta->local; in ieee80211_sta_eosp()
2237 clear_sta_flag(sta, WLAN_STA_SP); in ieee80211_sta_eosp()
2243 struct sta_info *sta = container_of(pubsta, struct sta_info, sta); in ieee80211_send_eosp_nullfunc() local
2247 trace_api_send_eosp_nullfunc(sta->local, pubsta, tid); in ieee80211_send_eosp_nullfunc()
2250 more_data = ieee80211_sta_ps_more_data(sta, ~sta->sta.uapsd_queues, in ieee80211_send_eosp_nullfunc()
2253 ieee80211_send_null_response(sta, tid, reason, false, more_data); in ieee80211_send_eosp_nullfunc()
2260 struct sta_info *sta = container_of(pubsta, struct sta_info, sta); in ieee80211_sta_set_buffered() local
2265 trace_api_sta_set_buffered(sta->local, pubsta, tid, buffered); in ieee80211_sta_set_buffered()
2268 set_bit(tid, &sta->driver_buffered_tids); in ieee80211_sta_set_buffered()
2270 clear_bit(tid, &sta->driver_buffered_tids); in ieee80211_sta_set_buffered()
2272 sta_info_recalc_tim(sta); in ieee80211_sta_set_buffered()
2279 struct sta_info *sta = container_of(pubsta, struct sta_info, sta); in ieee80211_sta_register_airtime() local
2280 struct ieee80211_local *local = sta->sdata->local; in ieee80211_sta_register_airtime()
2284 if (sta->local->airtime_flags & AIRTIME_USE_TX) in ieee80211_sta_register_airtime()
2286 if (sta->local->airtime_flags & AIRTIME_USE_RX) in ieee80211_sta_register_airtime()
2290 sta->airtime[ac].tx_airtime += tx_airtime; in ieee80211_sta_register_airtime()
2291 sta->airtime[ac].rx_airtime += rx_airtime; in ieee80211_sta_register_airtime()
2293 if (ieee80211_sta_keep_active(sta, ac)) in ieee80211_sta_register_airtime()
2294 sta->airtime[ac].deficit -= airtime; in ieee80211_sta_register_airtime()
2300 void __ieee80211_sta_recalc_aggregates(struct sta_info *sta, u16 active_links) in __ieee80211_sta_recalc_aggregates() argument
2305 if (!sta->sta.valid_links || !sta->sta.mlo) { in __ieee80211_sta_recalc_aggregates()
2306 sta->sta.cur = &sta->sta.deflink.agg; in __ieee80211_sta_recalc_aggregates()
2311 for (link_id = 0; link_id < ARRAY_SIZE((sta)->link); link_id++) { in __ieee80211_sta_recalc_aggregates()
2318 link_sta = rcu_dereference(sta->sta.link[link_id]); in __ieee80211_sta_recalc_aggregates()
2323 sta->cur = sta->sta.deflink.agg; in __ieee80211_sta_recalc_aggregates()
2328 sta->cur.max_amsdu_len = in __ieee80211_sta_recalc_aggregates()
2329 min(sta->cur.max_amsdu_len, in __ieee80211_sta_recalc_aggregates()
2331 sta->cur.max_rc_amsdu_len = in __ieee80211_sta_recalc_aggregates()
2332 min(sta->cur.max_rc_amsdu_len, in __ieee80211_sta_recalc_aggregates()
2335 for (i = 0; i < ARRAY_SIZE(sta->cur.max_tid_amsdu_len); i++) in __ieee80211_sta_recalc_aggregates()
2336 sta->cur.max_tid_amsdu_len[i] = in __ieee80211_sta_recalc_aggregates()
2337 min(sta->cur.max_tid_amsdu_len[i], in __ieee80211_sta_recalc_aggregates()
2342 sta->sta.cur = &sta->cur; in __ieee80211_sta_recalc_aggregates()
2347 struct sta_info *sta = container_of(pubsta, struct sta_info, sta); in ieee80211_sta_recalc_aggregates() local
2349 __ieee80211_sta_recalc_aggregates(sta, sta->sdata->vif.active_links); in ieee80211_sta_recalc_aggregates()
2354 struct sta_info *sta, u8 ac, in ieee80211_sta_update_pending_airtime() argument
2363 if (sta) in ieee80211_sta_update_pending_airtime()
2365 &sta->airtime[ac].aql_tx_pending); in ieee80211_sta_update_pending_airtime()
2372 if (sta) { in ieee80211_sta_update_pending_airtime()
2374 &sta->airtime[ac].aql_tx_pending); in ieee80211_sta_update_pending_airtime()
2376 atomic_cmpxchg(&sta->airtime[ac].aql_tx_pending, in ieee80211_sta_update_pending_airtime()
2394 sta_get_last_rx_stats(struct sta_info *sta) in sta_get_last_rx_stats() argument
2396 struct ieee80211_sta_rx_stats *stats = &sta->deflink.rx_stats; in sta_get_last_rx_stats()
2399 if (!sta->deflink.pcpu_rx_stats) in sta_get_last_rx_stats()
2405 cpustats = per_cpu_ptr(sta->deflink.pcpu_rx_stats, cpu); in sta_get_last_rx_stats()
2473 static int sta_set_rate_info_rx(struct sta_info *sta, struct rate_info *rinfo) in sta_set_rate_info_rx() argument
2475 u32 rate = READ_ONCE(sta_get_last_rx_stats(sta)->last_rate); in sta_set_rate_info_rx()
2480 sta_stats_decode_rate(sta->local, rate, rinfo); in sta_set_rate_info_rx()
2498 static void sta_set_tidstats(struct sta_info *sta, in sta_set_tidstats() argument
2502 struct ieee80211_local *local = sta->local; in sta_set_tidstats()
2506 tidstats->rx_msdu += sta_get_tidstats_msdu(&sta->deflink.rx_stats, in sta_set_tidstats()
2509 if (sta->deflink.pcpu_rx_stats) { in sta_set_tidstats()
2513 cpurxs = per_cpu_ptr(sta->deflink.pcpu_rx_stats, in sta_set_tidstats()
2525 tidstats->tx_msdu = sta->deflink.tx_stats.msdu[tid]; in sta_set_tidstats()
2531 tidstats->tx_msdu_retries = sta->deflink.status_stats.msdu_retries[tid]; in sta_set_tidstats()
2537 tidstats->tx_msdu_failed = sta->deflink.status_stats.msdu_failed[tid]; in sta_set_tidstats()
2546 to_txq_info(sta->sta.txq[tid])); in sta_set_tidstats()
2566 void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo, in sta_set_sinfo() argument
2569 struct ieee80211_sub_if_data *sdata = sta->sdata; in sta_set_sinfo()
2575 last_rxstats = sta_get_last_rx_stats(sta); in sta_set_sinfo()
2586 drv_sta_statistics(local, sdata, &sta->sta, sinfo); in sta_set_sinfo()
2600 sinfo->connected_time = ktime_get_seconds() - sta->last_connected; in sta_set_sinfo()
2601 sinfo->assoc_at = sta->assoc_at; in sta_set_sinfo()
2603 jiffies_to_msecs(jiffies - ieee80211_sta_last_active(sta)); in sta_set_sinfo()
2609 sinfo->tx_bytes += sta->deflink.tx_stats.bytes[ac]; in sta_set_sinfo()
2616 sinfo->tx_packets += sta->deflink.tx_stats.packets[ac]; in sta_set_sinfo()
2622 sinfo->rx_bytes += sta_get_stats_bytes(&sta->deflink.rx_stats); in sta_set_sinfo()
2624 if (sta->deflink.pcpu_rx_stats) { in sta_set_sinfo()
2628 cpurxs = per_cpu_ptr(sta->deflink.pcpu_rx_stats, in sta_set_sinfo()
2638 sinfo->rx_packets = sta->deflink.rx_stats.packets; in sta_set_sinfo()
2639 if (sta->deflink.pcpu_rx_stats) { in sta_set_sinfo()
2643 cpurxs = per_cpu_ptr(sta->deflink.pcpu_rx_stats, in sta_set_sinfo()
2652 sinfo->tx_retries = sta->deflink.status_stats.retry_count; in sta_set_sinfo()
2657 sinfo->tx_failed = sta->deflink.status_stats.retry_failed; in sta_set_sinfo()
2663 sinfo->rx_duration += sta->airtime[ac].rx_airtime; in sta_set_sinfo()
2669 sinfo->tx_duration += sta->airtime[ac].tx_airtime; in sta_set_sinfo()
2674 sinfo->airtime_weight = sta->airtime_weight; in sta_set_sinfo()
2678 sinfo->rx_dropped_misc = sta->deflink.rx_stats.dropped; in sta_set_sinfo()
2679 if (sta->deflink.pcpu_rx_stats) { in sta_set_sinfo()
2683 cpurxs = per_cpu_ptr(sta->deflink.pcpu_rx_stats, cpu); in sta_set_sinfo()
2695 if (ieee80211_hw_check(&sta->local->hw, SIGNAL_DBM) || in sta_set_sinfo()
2696 ieee80211_hw_check(&sta->local->hw, SIGNAL_UNSPEC)) { in sta_set_sinfo()
2702 if (!sta->deflink.pcpu_rx_stats && in sta_set_sinfo()
2705 -ewma_signal_read(&sta->deflink.rx_stats_avg.signal); in sta_set_sinfo()
2718 if (!sta->deflink.pcpu_rx_stats) in sta_set_sinfo()
2727 -ewma_signal_read(&sta->deflink.rx_stats_avg.chain_signal[i]); in sta_set_sinfo()
2732 !sta->sta.valid_links && in sta_set_sinfo()
2733 ieee80211_rate_valid(&sta->deflink.tx_stats.last_rate)) { in sta_set_sinfo()
2734 sta_set_rate_info_tx(sta, &sta->deflink.tx_stats.last_rate, in sta_set_sinfo()
2740 !sta->sta.valid_links) { in sta_set_sinfo()
2741 if (sta_set_rate_info_rx(sta, &sinfo->rxrate) == 0) in sta_set_sinfo()
2747 sta_set_tidstats(sta, &sinfo->pertid[i], i); in sta_set_sinfo()
2761 sinfo->llid = sta->mesh->llid; in sta_set_sinfo()
2762 sinfo->plid = sta->mesh->plid; in sta_set_sinfo()
2763 sinfo->plink_state = sta->mesh->plink_state; in sta_set_sinfo()
2764 if (test_sta_flag(sta, WLAN_STA_TOFFSET_KNOWN)) { in sta_set_sinfo()
2766 sinfo->t_offset = sta->mesh->t_offset; in sta_set_sinfo()
2768 sinfo->local_pm = sta->mesh->local_pm; in sta_set_sinfo()
2769 sinfo->peer_pm = sta->mesh->peer_pm; in sta_set_sinfo()
2770 sinfo->nonpeer_pm = sta->mesh->nonpeer_pm; in sta_set_sinfo()
2771 sinfo->connected_to_gate = sta->mesh->connected_to_gate; in sta_set_sinfo()
2772 sinfo->connected_to_as = sta->mesh->connected_to_as; in sta_set_sinfo()
2794 if (test_sta_flag(sta, WLAN_STA_AUTHORIZED)) in sta_set_sinfo()
2796 if (test_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE)) in sta_set_sinfo()
2798 if (sta->sta.wme) in sta_set_sinfo()
2800 if (test_sta_flag(sta, WLAN_STA_MFP)) in sta_set_sinfo()
2802 if (test_sta_flag(sta, WLAN_STA_AUTH)) in sta_set_sinfo()
2804 if (test_sta_flag(sta, WLAN_STA_ASSOC)) in sta_set_sinfo()
2806 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER)) in sta_set_sinfo()
2809 thr = sta_get_expected_throughput(sta); in sta_set_sinfo()
2817 sta->deflink.status_stats.ack_signal_filled) { in sta_set_sinfo()
2818 sinfo->ack_signal = sta->deflink.status_stats.last_ack_signal; in sta_set_sinfo()
2823 sta->deflink.status_stats.ack_signal_filled) { in sta_set_sinfo()
2826 &sta->deflink.status_stats.avg_ack_signal); in sta_set_sinfo()
2834 airtime_link_metric_get(local, sta); in sta_set_sinfo()
2838 u32 sta_get_expected_throughput(struct sta_info *sta) in sta_get_expected_throughput() argument
2840 struct ieee80211_sub_if_data *sdata = sta->sdata; in sta_get_expected_throughput()
2845 if (test_sta_flag(sta, WLAN_STA_RATE_CONTROL)) in sta_get_expected_throughput()
2850 thr = ref->ops->get_expected_throughput(sta->rate_ctrl_priv); in sta_get_expected_throughput()
2852 thr = drv_get_expected_throughput(local, sta); in sta_get_expected_throughput()
2857 unsigned long ieee80211_sta_last_active(struct sta_info *sta) in ieee80211_sta_last_active() argument
2859 struct ieee80211_sta_rx_stats *stats = sta_get_last_rx_stats(sta); in ieee80211_sta_last_active()
2861 if (!sta->deflink.status_stats.last_ack || in ieee80211_sta_last_active()
2862 time_after(stats->last_rx, sta->deflink.status_stats.last_ack)) in ieee80211_sta_last_active()
2864 return sta->deflink.status_stats.last_ack; in ieee80211_sta_last_active()
2867 static void sta_update_codel_params(struct sta_info *sta, u32 thr) in sta_update_codel_params() argument
2869 if (thr && thr < STA_SLOW_THRESHOLD * sta->local->num_sta) { in sta_update_codel_params()
2870 sta->cparams.target = MS2TIME(50); in sta_update_codel_params()
2871 sta->cparams.interval = MS2TIME(300); in sta_update_codel_params()
2872 sta->cparams.ecn = false; in sta_update_codel_params()
2874 sta->cparams.target = MS2TIME(20); in sta_update_codel_params()
2875 sta->cparams.interval = MS2TIME(100); in sta_update_codel_params()
2876 sta->cparams.ecn = true; in sta_update_codel_params()
2883 struct sta_info *sta = container_of(pubsta, struct sta_info, sta); in ieee80211_sta_set_expected_throughput() local
2885 sta_update_codel_params(sta, thr); in ieee80211_sta_set_expected_throughput()
2888 int ieee80211_sta_allocate_link(struct sta_info *sta, unsigned int link_id) in ieee80211_sta_allocate_link() argument
2890 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_sta_allocate_link()
2896 WARN_ON(!test_sta_flag(sta, WLAN_STA_INSERTED)); in ieee80211_sta_allocate_link()
2899 if (WARN_ON(!sta->sta.valid_links)) in ieee80211_sta_allocate_link()
2902 if (WARN_ON(sta->sta.valid_links & BIT(link_id) || in ieee80211_sta_allocate_link()
2903 sta->link[link_id])) in ieee80211_sta_allocate_link()
2916 sta_info_add_link(sta, link_id, &alloc->info, &alloc->sta); in ieee80211_sta_allocate_link()
2923 void ieee80211_sta_free_link(struct sta_info *sta, unsigned int link_id) in ieee80211_sta_free_link() argument
2925 lockdep_assert_wiphy(sta->sdata->local->hw.wiphy); in ieee80211_sta_free_link()
2927 WARN_ON(!test_sta_flag(sta, WLAN_STA_INSERTED)); in ieee80211_sta_free_link()
2929 sta_remove_link(sta, link_id, false); in ieee80211_sta_free_link()
2932 int ieee80211_sta_activate_link(struct sta_info *sta, unsigned int link_id) in ieee80211_sta_activate_link() argument
2934 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_sta_activate_link()
2936 u16 old_links = sta->sta.valid_links; in ieee80211_sta_activate_link()
2940 link_sta = rcu_dereference_protected(sta->link[link_id], in ieee80211_sta_activate_link()
2954 sta->sta.valid_links = new_links; in ieee80211_sta_activate_link()
2956 if (WARN_ON(!test_sta_flag(sta, WLAN_STA_INSERTED))) in ieee80211_sta_activate_link()
2964 ieee80211_sta_recalc_aggregates(&sta->sta); in ieee80211_sta_activate_link()
2966 ret = drv_change_sta_links(sdata->local, sdata, &sta->sta, in ieee80211_sta_activate_link()
2969 sta->sta.valid_links = old_links; in ieee80211_sta_activate_link()
2970 sta_remove_link(sta, link_id, false); in ieee80211_sta_activate_link()
2980 void ieee80211_sta_remove_link(struct sta_info *sta, unsigned int link_id) in ieee80211_sta_remove_link() argument
2982 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_sta_remove_link()
2983 u16 old_links = sta->sta.valid_links; in ieee80211_sta_remove_link()
2987 sta->sta.valid_links &= ~BIT(link_id); in ieee80211_sta_remove_link()
2989 if (!WARN_ON(!test_sta_flag(sta, WLAN_STA_INSERTED))) in ieee80211_sta_remove_link()
2990 drv_change_sta_links(sdata->local, sdata, &sta->sta, in ieee80211_sta_remove_link()
2991 old_links, sta->sta.valid_links); in ieee80211_sta_remove_link()
2993 sta_remove_link(sta, link_id, true); in ieee80211_sta_remove_link()
2996 void ieee80211_sta_set_max_amsdu_subframes(struct sta_info *sta, in ieee80211_sta_set_max_amsdu_subframes() argument
3002 sta->sta.max_amsdu_subframes = 0; in ieee80211_sta_set_max_amsdu_subframes()
3016 sta->sta.max_amsdu_subframes = 4 << (4 - val); in ieee80211_sta_set_max_amsdu_subframes()
3022 struct sta_info *sta = container_of(pubsta, struct sta_info, sta); in lockdep_sta_mutex_held() local
3024 return lockdep_is_held(&sta->local->hw.wiphy->mtx); in lockdep_sta_mutex_held()