Lines Matching +full:ac +full:- +full:link
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright 2002-2005, Instant802 Networks, Inc.
4 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
5 * Copyright 2013-2014 Intel Mobile Communications GmbH
6 * Copyright (C) 2015 - 2017 Intel Deutschland GmbH
7 * Copyright (C) 2018-2023 Intel Corporation
24 #include "driver-ops.h"
44 * particular, it may not start any mesh peer link management or add
47 * When the insertion fails (sta_info_insert()) returns non-zero), the
50 * Station entries are added by mac80211 when you establish a link with a
91 /* Caller must hold local->sta_mtx */
95 return rhltable_remove(&local->sta_hash, &sta->hash_node, in sta_info_hash_del()
102 lockdep_assert_held(&local->sta_mtx); in link_sta_info_hash_add()
103 return rhltable_insert(&local->link_sta_hash, in link_sta_info_hash_add()
104 &link_sta->link_hash_node, in link_sta_info_hash_add()
111 lockdep_assert_held(&local->sta_mtx); in link_sta_info_hash_del()
112 return rhltable_remove(&local->link_sta_hash, in link_sta_info_hash_del()
113 &link_sta->link_hash_node, in link_sta_info_hash_del()
119 int ac, i; in __cleanup_single_sta() local
121 struct ieee80211_sub_if_data *sdata = sta->sdata; in __cleanup_single_sta()
122 struct ieee80211_local *local = sdata->local; in __cleanup_single_sta()
128 if (sta->sdata->vif.type == NL80211_IFTYPE_AP || in __cleanup_single_sta()
129 sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN) in __cleanup_single_sta()
130 ps = &sdata->bss->ps; in __cleanup_single_sta()
131 else if (ieee80211_vif_is_mesh(&sdata->vif)) in __cleanup_single_sta()
132 ps = &sdata->u.mesh.ps; in __cleanup_single_sta()
140 atomic_dec(&ps->num_sta_ps); in __cleanup_single_sta()
143 for (i = 0; i < ARRAY_SIZE(sta->sta.txq); i++) { in __cleanup_single_sta()
146 if (!sta->sta.txq[i]) in __cleanup_single_sta()
149 txqi = to_txq_info(sta->sta.txq[i]); in __cleanup_single_sta()
154 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { in __cleanup_single_sta()
155 local->total_ps_buffered -= skb_queue_len(&sta->ps_tx_buf[ac]); in __cleanup_single_sta()
156 ieee80211_purge_tx_queue(&local->hw, &sta->ps_tx_buf[ac]); in __cleanup_single_sta()
157 ieee80211_purge_tx_queue(&local->hw, &sta->tx_filtered[ac]); in __cleanup_single_sta()
160 if (ieee80211_vif_is_mesh(&sdata->vif)) in __cleanup_single_sta()
163 cancel_work_sync(&sta->drv_deliver_wk); in __cleanup_single_sta()
172 kfree(sta->ampdu_mlme.tid_start_tx[i]); in __cleanup_single_sta()
173 tid_tx = rcu_dereference_raw(sta->ampdu_mlme.tid_tx[i]); in __cleanup_single_sta()
176 ieee80211_purge_tx_queue(&local->hw, &tid_tx->pending); in __cleanup_single_sta()
183 struct ieee80211_sub_if_data *sdata = sta->sdata; in cleanup_single_sta()
184 struct ieee80211_local *local = sdata->local; in cleanup_single_sta()
193 return rhltable_lookup(&local->sta_hash, addr, sta_rht_params); in sta_info_hash_lookup()
200 struct ieee80211_local *local = sdata->local; in sta_info_get()
206 if (sta->sdata == sdata) { in sta_info_get()
225 struct ieee80211_local *local = sdata->local; in sta_info_get_bss()
231 if (sta->sdata == sdata || in sta_info_get_bss()
232 (sta->sdata->bss && sta->sdata->bss == sdata->bss)) { in sta_info_get_bss()
247 return rhltable_lookup(&local->link_sta_hash, addr, in link_sta_info_hash_lookup()
254 struct ieee80211_local *local = sdata->local; in link_sta_info_get_bss()
260 struct sta_info *sta = link_sta->sta; in link_sta_info_get_bss()
262 if (sta->sdata == sdata || in link_sta_info_get_bss()
263 (sta->sdata->bss && sta->sdata->bss == sdata->bss)) { in link_sta_info_get_bss()
286 struct sta_info *sta = link_sta->sta; in ieee80211_find_sta_by_link_addrs()
287 struct ieee80211_link_data *link; in ieee80211_find_sta_by_link_addrs() local
288 u8 _link_id = link_sta->link_id; in ieee80211_find_sta_by_link_addrs()
293 return &sta->sta; in ieee80211_find_sta_by_link_addrs()
296 link = rcu_dereference(sta->sdata->link[_link_id]); in ieee80211_find_sta_by_link_addrs()
297 if (!link) in ieee80211_find_sta_by_link_addrs()
300 if (memcmp(link->conf->addr, localaddr, ETH_ALEN)) in ieee80211_find_sta_by_link_addrs()
305 return &sta->sta; in ieee80211_find_sta_by_link_addrs()
319 if (ether_addr_equal(vif_addr, sta->sdata->vif.addr)) in sta_info_get_by_addrs()
329 struct ieee80211_local *local = sdata->local; in sta_info_get_by_idx()
333 list_for_each_entry_rcu(sta, &local->sta_list, list, in sta_info_get_by_idx()
334 lockdep_is_held(&local->sta_mtx)) { in sta_info_get_by_idx()
335 if (sdata != sta->sdata) in sta_info_get_by_idx()
349 free_percpu(link_sta->pcpu_rx_stats); in sta_info_free_link()
358 link_sta = rcu_access_pointer(sta->link[link_id]); in sta_remove_link()
359 if (link_sta != &sta->deflink) in sta_remove_link()
360 lockdep_assert_held(&sta->local->sta_mtx); in sta_remove_link()
366 link_sta_info_hash_del(sta->local, link_sta); in sta_remove_link()
371 if (link_sta != &sta->deflink) in sta_remove_link()
374 sta->sta.valid_links &= ~BIT(link_id); in sta_remove_link()
375 RCU_INIT_POINTER(sta->link[link_id], NULL); in sta_remove_link()
376 RCU_INIT_POINTER(sta->sta.link[link_id], NULL); in sta_remove_link()
378 sta_info_free_link(&alloc->info); in sta_remove_link()
382 ieee80211_sta_recalc_aggregates(&sta->sta); in sta_remove_link()
386 * sta_info_free - free STA
400 for (i = 0; i < ARRAY_SIZE(sta->link); i++) { in sta_info_free()
403 link_sta = rcu_access_pointer(sta->link[i]); in sta_info_free()
418 while (sta->sta_state > IEEE80211_STA_NONE) { in sta_info_free()
423 ret = sta_info_move_state(sta, sta->sta_state - 1); in sta_info_free()
428 if (sta->rate_ctrl) in sta_info_free()
431 sta_dbg(sta->sdata, "Destroyed STA %pM\n", sta->sta.addr); in sta_info_free()
433 kfree(to_txq_info(sta->sta.txq[0])); in sta_info_free()
434 kfree(rcu_dereference_raw(sta->sta.rates)); in sta_info_free()
436 kfree(sta->mesh); in sta_info_free()
439 sta_info_free_link(&sta->deflink); in sta_info_free()
443 /* Caller must hold local->sta_mtx */
447 return rhltable_insert(&local->sta_hash, &sta->hash_node, in sta_info_hash_add()
457 if (sta->dead) in sta_deliver_ps_frames()
473 if (ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL)) in sta_prepare_rate_control()
476 sta->rate_ctrl = local->rate_ctrl; in sta_prepare_rate_control()
477 sta->rate_ctrl_priv = rate_control_alloc_sta(sta->rate_ctrl, in sta_prepare_rate_control()
479 if (!sta->rate_ctrl_priv) in sta_prepare_rate_control()
480 return -ENOMEM; in sta_prepare_rate_control()
489 struct ieee80211_hw *hw = &local->hw; in sta_info_alloc_link()
493 link_info->pcpu_rx_stats = in sta_info_alloc_link()
495 if (!link_info->pcpu_rx_stats) in sta_info_alloc_link()
496 return -ENOMEM; in sta_info_alloc_link()
499 link_info->rx_stats.last_rx = jiffies; in sta_info_alloc_link()
500 u64_stats_init(&link_info->rx_stats.syncp); in sta_info_alloc_link()
502 ewma_signal_init(&link_info->rx_stats_avg.signal); in sta_info_alloc_link()
503 ewma_avg_signal_init(&link_info->status_stats.avg_ack_signal); in sta_info_alloc_link()
504 for (i = 0; i < ARRAY_SIZE(link_info->rx_stats_avg.chain_signal); i++) in sta_info_alloc_link()
505 ewma_signal_init(&link_info->rx_stats_avg.chain_signal[i]); in sta_info_alloc_link()
515 link_info->sta = sta; in sta_info_add_link()
516 link_info->link_id = link_id; in sta_info_add_link()
517 link_info->pub = link_sta; in sta_info_add_link()
518 link_info->pub->sta = &sta->sta; in sta_info_add_link()
519 link_sta->link_id = link_id; in sta_info_add_link()
520 rcu_assign_pointer(sta->link[link_id], link_info); in sta_info_add_link()
521 rcu_assign_pointer(sta->sta.link[link_id], link_sta); in sta_info_add_link()
523 link_sta->smps_mode = IEEE80211_SMPS_OFF; in sta_info_add_link()
524 link_sta->agg.max_rc_amsdu_len = IEEE80211_MAX_MPDU_LEN_HT_BA; in sta_info_add_link()
532 struct ieee80211_local *local = sdata->local; in __sta_info_alloc()
533 struct ieee80211_hw *hw = &local->hw; in __sta_info_alloc()
539 sta = kzalloc(sizeof(*sta) + hw->sta_data_size, gfp); in __sta_info_alloc()
543 sta->local = local; in __sta_info_alloc()
544 sta->sdata = sdata; in __sta_info_alloc()
546 if (sta_info_alloc_link(local, &sta->deflink, gfp)) in __sta_info_alloc()
550 sta_info_add_link(sta, link_id, &sta->deflink, in __sta_info_alloc()
551 &sta->sta.deflink); in __sta_info_alloc()
552 sta->sta.valid_links = BIT(link_id); in __sta_info_alloc()
554 sta_info_add_link(sta, 0, &sta->deflink, &sta->sta.deflink); in __sta_info_alloc()
557 sta->sta.cur = &sta->sta.deflink.agg; in __sta_info_alloc()
559 spin_lock_init(&sta->lock); in __sta_info_alloc()
560 spin_lock_init(&sta->ps_lock); in __sta_info_alloc()
561 INIT_WORK(&sta->drv_deliver_wk, sta_deliver_ps_frames); in __sta_info_alloc()
562 INIT_WORK(&sta->ampdu_mlme.work, ieee80211_ba_session_work); in __sta_info_alloc()
563 mutex_init(&sta->ampdu_mlme.mtx); in __sta_info_alloc()
565 if (ieee80211_vif_is_mesh(&sdata->vif)) { in __sta_info_alloc()
566 sta->mesh = kzalloc(sizeof(*sta->mesh), gfp); in __sta_info_alloc()
567 if (!sta->mesh) in __sta_info_alloc()
569 sta->mesh->plink_sta = sta; in __sta_info_alloc()
570 spin_lock_init(&sta->mesh->plink_lock); in __sta_info_alloc()
571 if (!sdata->u.mesh.user_mpm) in __sta_info_alloc()
572 timer_setup(&sta->mesh->plink_timer, mesh_plink_timer, in __sta_info_alloc()
574 sta->mesh->nonpeer_pm = NL80211_MESH_POWER_ACTIVE; in __sta_info_alloc()
578 memcpy(sta->addr, addr, ETH_ALEN); in __sta_info_alloc()
579 memcpy(sta->sta.addr, addr, ETH_ALEN); in __sta_info_alloc()
580 memcpy(sta->deflink.addr, link_addr, ETH_ALEN); in __sta_info_alloc()
581 memcpy(sta->sta.deflink.addr, link_addr, ETH_ALEN); in __sta_info_alloc()
582 sta->sta.max_rx_aggregation_subframes = in __sta_info_alloc()
583 local->hw.max_rx_aggregation_subframes; in __sta_info_alloc()
585 /* TODO link specific alloc and assignments for MLO Link STA */ in __sta_info_alloc()
587 /* Extended Key ID needs to install keys for keyid 0 and 1 Rx-only. in __sta_info_alloc()
589 * references to is not NULL. To not use the initial Rx-only key in __sta_info_alloc()
593 BUILD_BUG_ON(ARRAY_SIZE(sta->ptk) <= INVALID_PTK_KEYIDX); in __sta_info_alloc()
594 sta->ptk_idx = INVALID_PTK_KEYIDX; in __sta_info_alloc()
597 ieee80211_init_frag_cache(&sta->frags); in __sta_info_alloc()
599 sta->sta_state = IEEE80211_STA_NONE; in __sta_info_alloc()
601 if (sdata->vif.type == NL80211_IFTYPE_MESH_POINT) in __sta_info_alloc()
602 sta->amsdu_mesh_control = -1; in __sta_info_alloc()
605 sta->reserved_tid = IEEE80211_TID_UNRESERVED; in __sta_info_alloc()
607 sta->last_connected = ktime_get_seconds(); in __sta_info_alloc()
610 ALIGN(hw->txq_data_size, sizeof(void *)); in __sta_info_alloc()
612 txq_data = kcalloc(ARRAY_SIZE(sta->sta.txq), size, gfp); in __sta_info_alloc()
616 for (i = 0; i < ARRAY_SIZE(sta->sta.txq); i++) { in __sta_info_alloc()
626 sta->airtime_weight = IEEE80211_DEFAULT_AIRTIME_WEIGHT; in __sta_info_alloc()
629 skb_queue_head_init(&sta->ps_tx_buf[i]); in __sta_info_alloc()
630 skb_queue_head_init(&sta->tx_filtered[i]); in __sta_info_alloc()
631 sta->airtime[i].deficit = sta->airtime_weight; in __sta_info_alloc()
632 atomic_set(&sta->airtime[i].aql_tx_pending, 0); in __sta_info_alloc()
633 sta->airtime[i].aql_limit_low = local->aql_txq_limit_low[i]; in __sta_info_alloc()
634 sta->airtime[i].aql_limit_high = local->aql_txq_limit_high[i]; in __sta_info_alloc()
638 sta->last_seq_ctrl[i] = cpu_to_le16(USHRT_MAX); in __sta_info_alloc()
644 if (!hw->wiphy->bands[i]) in __sta_info_alloc()
671 for (r = 0; r < hw->wiphy->bands[i]->n_bitrates; r++) { in __sta_info_alloc()
674 rate = &hw->wiphy->bands[i]->bitrates[r]; in __sta_info_alloc()
676 if (!(rate->flags & mandatory)) in __sta_info_alloc()
678 sta->sta.deflink.supp_rates[i] |= BIT(r); in __sta_info_alloc()
682 sta->cparams.ce_threshold = CODEL_DISABLED_THRESHOLD; in __sta_info_alloc()
683 sta->cparams.target = MS2TIME(20); in __sta_info_alloc()
684 sta->cparams.interval = MS2TIME(100); in __sta_info_alloc()
685 sta->cparams.ecn = true; in __sta_info_alloc()
686 sta->cparams.ce_threshold_selector = 0; in __sta_info_alloc()
687 sta->cparams.ce_threshold_mask = 0; in __sta_info_alloc()
689 sta_dbg(sdata, "Allocated STA %pM\n", sta->sta.addr); in __sta_info_alloc()
694 kfree(to_txq_info(sta->sta.txq[0])); in __sta_info_alloc()
696 sta_info_free_link(&sta->deflink); in __sta_info_alloc()
698 kfree(sta->mesh); in __sta_info_alloc()
707 return __sta_info_alloc(sdata, addr, -1, addr, gfp); in sta_info_alloc()
721 struct ieee80211_sub_if_data *sdata = sta->sdata; in sta_info_insert_check()
729 return -ENETDOWN; in sta_info_insert_check()
731 if (WARN_ON(ether_addr_equal(sta->sta.addr, sdata->vif.addr) || in sta_info_insert_check()
732 !is_valid_ether_addr(sta->sta.addr))) in sta_info_insert_check()
733 return -EINVAL; in sta_info_insert_check()
740 lockdep_assert_held(&sdata->local->sta_mtx); in sta_info_insert_check()
741 if (ieee80211_hw_check(&sdata->local->hw, NEEDS_UNIQUE_STA_ADDR) && in sta_info_insert_check()
742 ieee80211_find_sta_by_ifaddr(&sdata->local->hw, sta->addr, NULL)) { in sta_info_insert_check()
744 return -ENOTUNIQ; in sta_info_insert_check()
758 for (state = IEEE80211_STA_NOTEXIST; state < sta->sta_state; state++) { in sta_info_insert_drv_state()
769 if (!local->ops->sta_add) in sta_info_insert_drv_state()
770 sta->uploaded = true; in sta_info_insert_drv_state()
774 if (sdata->vif.type == NL80211_IFTYPE_ADHOC) { in sta_info_insert_drv_state()
776 "failed to move IBSS STA %pM to state %d (%d) - keeping it anyway\n", in sta_info_insert_drv_state()
777 sta->sta.addr, state + 1, err); in sta_info_insert_drv_state()
782 for (; state > IEEE80211_STA_NOTEXIST; state--) in sta_info_insert_drv_state()
783 WARN_ON(drv_sta_state(local, sdata, sta, state, state - 1)); in sta_info_insert_drv_state()
791 struct ieee80211_local *local = sdata->local; in ieee80211_recalc_p2p_go_ps_allowed()
792 bool allow_p2p_go_ps = sdata->vif.p2p; in ieee80211_recalc_p2p_go_ps_allowed()
796 list_for_each_entry_rcu(sta, &local->sta_list, list) { in ieee80211_recalc_p2p_go_ps_allowed()
797 if (sdata != sta->sdata || in ieee80211_recalc_p2p_go_ps_allowed()
800 if (!sta->sta.support_p2p_ps) { in ieee80211_recalc_p2p_go_ps_allowed()
807 if (allow_p2p_go_ps != sdata->vif.bss_conf.allow_p2p_go_ps) { in ieee80211_recalc_p2p_go_ps_allowed()
808 sdata->vif.bss_conf.allow_p2p_go_ps = allow_p2p_go_ps; in ieee80211_recalc_p2p_go_ps_allowed()
809 ieee80211_link_info_change_notify(sdata, &sdata->deflink, in ieee80211_recalc_p2p_go_ps_allowed()
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()
826 lockdep_assert_held(&local->sta_mtx); in sta_info_insert_finish()
829 if (sta_info_get_bss(sdata, sta->sta.addr)) { in sta_info_insert_finish()
830 err = -EEXIST; in sta_info_insert_finish()
836 err = -ENOMEM; in sta_info_insert_finish()
840 local->num_sta++; in sta_info_insert_finish()
841 local->sta_generation++; 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()
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()
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()
890 lockdep_is_held(&local->sta_mtx)); in sta_info_insert_finish()
896 if (sdata->vif.active_links & BIT(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()
904 sinfo->generation = local->sta_generation; 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()
910 /* move reference to rcu-protected */ in sta_info_insert_finish()
912 mutex_unlock(&local->sta_mtx); in sta_info_insert_finish()
914 if (ieee80211_vif_is_mesh(&sdata->vif)) in sta_info_insert_finish()
921 if (sta->sta.valid_links) in sta_info_insert_finish()
922 link_sta_info_hash_del(local, &sta->deflink); in sta_info_insert_finish()
924 list_del_rcu(&sta->list); in sta_info_insert_finish()
926 local->num_sta--; in sta_info_insert_finish()
930 mutex_unlock(&local->sta_mtx); in sta_info_insert_finish()
938 struct ieee80211_local *local = sta->local; in sta_info_insert_rcu()
943 mutex_lock(&local->sta_mtx); in sta_info_insert_rcu()
948 mutex_unlock(&local->sta_mtx); in sta_info_insert_rcu()
992 static unsigned long ieee80211_tids_for_ac(int ac) in ieee80211_tids_for_ac() argument
995 switch (ac) { in ieee80211_tids_for_ac()
1012 struct ieee80211_local *local = sta->local; in __sta_info_recalc_tim()
1015 u8 ignore_for_tim = sta->sta.uapsd_queues; in __sta_info_recalc_tim()
1016 int ac; in __sta_info_recalc_tim() local
1017 u16 id = sta->sta.aid; in __sta_info_recalc_tim()
1019 if (sta->sdata->vif.type == NL80211_IFTYPE_AP || in __sta_info_recalc_tim()
1020 sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN) { in __sta_info_recalc_tim()
1021 if (WARN_ON_ONCE(!sta->sdata->bss)) in __sta_info_recalc_tim()
1024 ps = &sta->sdata->bss->ps; in __sta_info_recalc_tim()
1026 } else if (ieee80211_vif_is_mesh(&sta->sdata->vif)) { in __sta_info_recalc_tim()
1027 ps = &sta->sdata->u.mesh.ps; in __sta_info_recalc_tim()
1034 if (ieee80211_hw_check(&local->hw, AP_LINK_PS) && !local->ops->set_tim) in __sta_info_recalc_tim()
1037 if (sta->dead) in __sta_info_recalc_tim()
1041 * If all ACs are delivery-enabled then we should build in __sta_info_recalc_tim()
1044 * non-enabled ones. in __sta_info_recalc_tim()
1046 if (ignore_for_tim == BIT(IEEE80211_NUM_ACS) - 1) in __sta_info_recalc_tim()
1050 ignore_for_tim = BIT(IEEE80211_NUM_ACS) - 1; in __sta_info_recalc_tim()
1052 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { in __sta_info_recalc_tim()
1055 if (ignore_for_tim & ieee80211_ac_to_qos_mask[ac]) in __sta_info_recalc_tim()
1058 indicate_tim |= !skb_queue_empty(&sta->tx_filtered[ac]) || in __sta_info_recalc_tim()
1059 !skb_queue_empty(&sta->ps_tx_buf[ac]); in __sta_info_recalc_tim()
1063 tids = ieee80211_tids_for_ac(ac); in __sta_info_recalc_tim()
1066 sta->driver_buffered_tids & tids; in __sta_info_recalc_tim()
1068 sta->txq_buffered_tids & tids; in __sta_info_recalc_tim()
1072 spin_lock_bh(&local->tim_lock); in __sta_info_recalc_tim()
1074 if (indicate_tim == __bss_tim_get(ps->tim, id)) in __sta_info_recalc_tim()
1078 __bss_tim_set(ps->tim, id); in __sta_info_recalc_tim()
1080 __bss_tim_clear(ps->tim, id); in __sta_info_recalc_tim()
1082 if (local->ops->set_tim && !WARN_ON(sta->dead)) { in __sta_info_recalc_tim()
1083 local->tim_in_locked_section = true; in __sta_info_recalc_tim()
1084 drv_set_tim(local, &sta->sta, indicate_tim); in __sta_info_recalc_tim()
1085 local->tim_in_locked_section = false; in __sta_info_recalc_tim()
1089 spin_unlock_bh(&local->tim_lock); in __sta_info_recalc_tim()
1108 timeout = (sta->listen_interval * in sta_info_buffer_expired()
1109 sta->sdata->vif.bss_conf.beacon_int * in sta_info_buffer_expired()
1113 return time_after(jiffies, info->control.jiffies + timeout); in sta_info_buffer_expired()
1118 struct sta_info *sta, int ac) in sta_info_cleanup_expire_buffered_ac() argument
1126 * a separate queue to avoid reordering with normal PS-buffered in sta_info_cleanup_expire_buffered_ac()
1131 spin_lock_irqsave(&sta->tx_filtered[ac].lock, flags); in sta_info_cleanup_expire_buffered_ac()
1132 skb = skb_peek(&sta->tx_filtered[ac]); in sta_info_cleanup_expire_buffered_ac()
1134 skb = __skb_dequeue(&sta->tx_filtered[ac]); in sta_info_cleanup_expire_buffered_ac()
1137 spin_unlock_irqrestore(&sta->tx_filtered[ac].lock, flags); in sta_info_cleanup_expire_buffered_ac()
1147 ieee80211_free_txskb(&local->hw, skb); in sta_info_cleanup_expire_buffered_ac()
1151 * Now also check the normal PS-buffered queue, this will in sta_info_cleanup_expire_buffered_ac()
1157 spin_lock_irqsave(&sta->ps_tx_buf[ac].lock, flags); in sta_info_cleanup_expire_buffered_ac()
1158 skb = skb_peek(&sta->ps_tx_buf[ac]); in sta_info_cleanup_expire_buffered_ac()
1160 skb = __skb_dequeue(&sta->ps_tx_buf[ac]); in sta_info_cleanup_expire_buffered_ac()
1163 spin_unlock_irqrestore(&sta->ps_tx_buf[ac].lock, flags); in sta_info_cleanup_expire_buffered_ac()
1173 local->total_ps_buffered--; in sta_info_cleanup_expire_buffered_ac()
1174 ps_dbg(sta->sdata, "Buffered frame expired (STA %pM)\n", in sta_info_cleanup_expire_buffered_ac()
1175 sta->sta.addr); in sta_info_cleanup_expire_buffered_ac()
1176 ieee80211_free_txskb(&local->hw, skb); in sta_info_cleanup_expire_buffered_ac()
1180 * Finally, recalculate the TIM bit for this station -- it might in sta_info_cleanup_expire_buffered_ac()
1191 return !(skb_queue_empty(&sta->ps_tx_buf[ac]) && in sta_info_cleanup_expire_buffered_ac()
1192 skb_queue_empty(&sta->tx_filtered[ac])); in sta_info_cleanup_expire_buffered_ac()
1199 int ac; in sta_info_cleanup_expire_buffered() local
1202 if (!sta->sdata->bss && in sta_info_cleanup_expire_buffered()
1203 !ieee80211_vif_is_mesh(&sta->sdata->vif)) in sta_info_cleanup_expire_buffered()
1206 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) in sta_info_cleanup_expire_buffered()
1208 sta_info_cleanup_expire_buffered_ac(local, sta, ac); in sta_info_cleanup_expire_buffered()
1222 return -ENOENT; in __sta_info_destroy_part1()
1224 local = sta->local; in __sta_info_destroy_part1()
1225 sdata = sta->sdata; in __sta_info_destroy_part1()
1227 lockdep_assert_held(&local->sta_mtx); in __sta_info_destroy_part1()
1232 * sessions -- block that to make sure the tear-down in __sta_info_destroy_part1()
1240 * rx frames on RSS queues sent prior to the disassociation - wait for in __sta_info_destroy_part1()
1245 for (i = 0; i < ARRAY_SIZE(sta->link); i++) { in __sta_info_destroy_part1()
1248 if (!(sta->sta.valid_links & BIT(i))) in __sta_info_destroy_part1()
1251 link_sta = rcu_dereference_protected(sta->link[i], in __sta_info_destroy_part1()
1252 lockdep_is_held(&local->sta_mtx)); in __sta_info_destroy_part1()
1266 drv_tdls_cancel_channel_switch(local, sdata, &sta->sta); in __sta_info_destroy_part1()
1270 list_del_rcu(&sta->list); in __sta_info_destroy_part1()
1271 sta->removed = true; in __sta_info_destroy_part1()
1273 if (sta->uploaded) in __sta_info_destroy_part1()
1274 drv_sta_pre_rcu_remove(local, sta->sdata, sta); in __sta_info_destroy_part1()
1276 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN && in __sta_info_destroy_part1()
1277 rcu_access_pointer(sdata->u.vlan.sta) == sta) in __sta_info_destroy_part1()
1278 RCU_INIT_POINTER(sdata->u.vlan.sta, NULL); in __sta_info_destroy_part1()
1287 struct ieee80211_local *local = sta->local; in _sta_info_move_state()
1291 if (sta->sta_state == new_state) in _sta_info_move_state()
1298 if (sta->sta_state != IEEE80211_STA_AUTH) in _sta_info_move_state()
1299 return -EINVAL; in _sta_info_move_state()
1302 if (sta->sta_state != IEEE80211_STA_NONE && in _sta_info_move_state()
1303 sta->sta_state != IEEE80211_STA_ASSOC) in _sta_info_move_state()
1304 return -EINVAL; in _sta_info_move_state()
1307 if (sta->sta_state != IEEE80211_STA_AUTH && in _sta_info_move_state()
1308 sta->sta_state != IEEE80211_STA_AUTHORIZED) in _sta_info_move_state()
1309 return -EINVAL; in _sta_info_move_state()
1312 if (sta->sta_state != IEEE80211_STA_ASSOC) in _sta_info_move_state()
1313 return -EINVAL; in _sta_info_move_state()
1317 return -EINVAL; in _sta_info_move_state()
1320 sta_dbg(sta->sdata, "moving STA %pM to state %d\n", in _sta_info_move_state()
1321 sta->sta.addr, new_state); in _sta_info_move_state()
1327 int err = drv_sta_state(sta->local, sta->sdata, sta, in _sta_info_move_state()
1328 sta->sta_state, new_state); in _sta_info_move_state()
1337 if (sta->sta_state == IEEE80211_STA_AUTH) in _sta_info_move_state()
1338 clear_bit(WLAN_STA_AUTH, &sta->_flags); in _sta_info_move_state()
1341 if (sta->sta_state == IEEE80211_STA_NONE) { in _sta_info_move_state()
1342 set_bit(WLAN_STA_AUTH, &sta->_flags); in _sta_info_move_state()
1343 } else if (sta->sta_state == IEEE80211_STA_ASSOC) { in _sta_info_move_state()
1344 clear_bit(WLAN_STA_ASSOC, &sta->_flags); in _sta_info_move_state()
1346 ieee80211_recalc_min_chandef(sta->sdata, -1); in _sta_info_move_state()
1347 if (!sta->sta.support_p2p_ps) in _sta_info_move_state()
1348 ieee80211_recalc_p2p_go_ps_allowed(sta->sdata); in _sta_info_move_state()
1353 if (sta->sta_state == IEEE80211_STA_AUTH) { in _sta_info_move_state()
1354 set_bit(WLAN_STA_ASSOC, &sta->_flags); in _sta_info_move_state()
1355 sta->assoc_at = ktime_get_boottime_ns(); in _sta_info_move_state()
1357 ieee80211_recalc_min_chandef(sta->sdata, -1); in _sta_info_move_state()
1358 if (!sta->sta.support_p2p_ps) in _sta_info_move_state()
1359 ieee80211_recalc_p2p_go_ps_allowed(sta->sdata); in _sta_info_move_state()
1361 } else if (sta->sta_state == IEEE80211_STA_AUTHORIZED) { in _sta_info_move_state()
1362 ieee80211_vif_dec_num_mcast(sta->sdata); in _sta_info_move_state()
1363 clear_bit(WLAN_STA_AUTHORIZED, &sta->_flags); in _sta_info_move_state()
1372 if (local->ops->set_key) { in _sta_info_move_state()
1374 if (local->ops->flush_sta) in _sta_info_move_state()
1375 drv_flush_sta(local, sta->sdata, sta); in _sta_info_move_state()
1378 sta->sdata, in _sta_info_move_state()
1387 if (sta->sta_state == IEEE80211_STA_ASSOC) { in _sta_info_move_state()
1388 ieee80211_vif_inc_num_mcast(sta->sdata); in _sta_info_move_state()
1389 set_bit(WLAN_STA_AUTHORIZED, &sta->_flags); in _sta_info_move_state()
1393 if (sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN || in _sta_info_move_state()
1394 sta->sdata->vif.type == NL80211_IFTYPE_AP) in _sta_info_move_state()
1395 cfg80211_send_layer2_update(sta->sdata->dev, in _sta_info_move_state()
1396 sta->sta.addr); in _sta_info_move_state()
1402 sta->sta_state = new_state; in _sta_info_move_state()
1415 struct ieee80211_local *local = sta->local; in __sta_info_destroy_part2()
1416 struct ieee80211_sub_if_data *sdata = sta->sdata; in __sta_info_destroy_part2()
1440 lockdep_assert_held(&local->sta_mtx); in __sta_info_destroy_part2()
1442 if (sta->sta_state == IEEE80211_STA_AUTHORIZED) { in __sta_info_destroy_part2()
1450 /* disable TIM bit - last chance to tell driver */ in __sta_info_destroy_part2()
1453 sta->dead = true; in __sta_info_destroy_part2()
1455 local->num_sta--; in __sta_info_destroy_part2()
1456 local->sta_generation++; in __sta_info_destroy_part2()
1458 while (sta->sta_state > IEEE80211_STA_NONE) { in __sta_info_destroy_part2()
1459 ret = _sta_info_move_state(sta, sta->sta_state - 1, recalc); in __sta_info_destroy_part2()
1466 if (sta->uploaded) { in __sta_info_destroy_part2()
1472 sta_dbg(sdata, "Removed STA %pM\n", sta->sta.addr); in __sta_info_destroy_part2()
1477 cfg80211_del_sta_sinfo(sdata->dev, sta->sta.addr, sinfo, GFP_KERNEL); in __sta_info_destroy_part2()
1482 ieee80211_destroy_frag_cache(&sta->frags); in __sta_info_destroy_part2()
1506 mutex_lock(&sdata->local->sta_mtx); in sta_info_destroy_addr()
1509 mutex_unlock(&sdata->local->sta_mtx); in sta_info_destroy_addr()
1520 mutex_lock(&sdata->local->sta_mtx); in sta_info_destroy_addr_bss()
1523 mutex_unlock(&sdata->local->sta_mtx); in sta_info_destroy_addr_bss()
1535 list_for_each_entry_rcu(sta, &local->sta_list, list) in sta_info_cleanup()
1540 if (local->quiescing) in sta_info_cleanup()
1546 mod_timer(&local->sta_cleanup, in sta_info_cleanup()
1554 err = rhltable_init(&local->sta_hash, &sta_rht_params); in sta_info_init()
1558 err = rhltable_init(&local->link_sta_hash, &link_sta_rht_params); in sta_info_init()
1560 rhltable_destroy(&local->sta_hash); in sta_info_init()
1564 spin_lock_init(&local->tim_lock); in sta_info_init()
1565 mutex_init(&local->sta_mtx); in sta_info_init()
1566 INIT_LIST_HEAD(&local->sta_list); in sta_info_init()
1568 timer_setup(&local->sta_cleanup, sta_info_cleanup, 0); in sta_info_init()
1574 del_timer_sync(&local->sta_cleanup); in sta_info_stop()
1575 rhltable_destroy(&local->sta_hash); in sta_info_stop()
1576 rhltable_destroy(&local->link_sta_hash); in sta_info_stop()
1582 struct ieee80211_local *local = sdata->local; in __sta_info_flush()
1589 WARN_ON(vlans && sdata->vif.type != NL80211_IFTYPE_AP); in __sta_info_flush()
1590 WARN_ON(vlans && !sdata->bss); in __sta_info_flush()
1592 mutex_lock(&local->sta_mtx); in __sta_info_flush()
1593 list_for_each_entry_safe(sta, tmp, &local->sta_list, list) { in __sta_info_flush()
1594 if (sdata == sta->sdata || in __sta_info_flush()
1595 (vlans && sdata->bss == sta->sdata->bss)) { in __sta_info_flush()
1597 list_add(&sta->free_list, &free_list); in __sta_info_flush()
1607 if (!sta->sta.support_p2p_ps) in __sta_info_flush()
1612 ieee80211_recalc_min_chandef(sdata, -1); in __sta_info_flush()
1616 mutex_unlock(&local->sta_mtx); in __sta_info_flush()
1624 struct ieee80211_local *local = sdata->local; in ieee80211_sta_expire()
1627 mutex_lock(&local->sta_mtx); in ieee80211_sta_expire()
1629 list_for_each_entry_safe(sta, tmp, &local->sta_list, list) { in ieee80211_sta_expire()
1632 if (sdata != sta->sdata) in ieee80211_sta_expire()
1636 sta_dbg(sta->sdata, "expiring inactive STA %pM\n", in ieee80211_sta_expire()
1637 sta->sta.addr); in ieee80211_sta_expire()
1639 if (ieee80211_vif_is_mesh(&sdata->vif) && in ieee80211_sta_expire()
1641 atomic_dec(&sdata->u.mesh.ps.num_sta_ps); in ieee80211_sta_expire()
1647 mutex_unlock(&local->sta_mtx); in ieee80211_sta_expire()
1664 !ether_addr_equal(sta->sdata->vif.addr, localaddr)) in ieee80211_find_sta_by_ifaddr()
1666 if (!sta->uploaded) in ieee80211_find_sta_by_ifaddr()
1668 return &sta->sta; in ieee80211_find_sta_by_ifaddr()
1687 if (!sta->uploaded) in ieee80211_find_sta()
1690 return &sta->sta; in ieee80211_find_sta()
1697 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_sta_ps_deliver_wakeup()
1698 struct ieee80211_local *local = sdata->local; in ieee80211_sta_ps_deliver_wakeup()
1700 int filtered = 0, buffered = 0, ac, i; in ieee80211_sta_ps_deliver_wakeup() local
1704 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) in ieee80211_sta_ps_deliver_wakeup()
1705 sdata = container_of(sdata->bss, struct ieee80211_sub_if_data, in ieee80211_sta_ps_deliver_wakeup()
1708 if (sdata->vif.type == NL80211_IFTYPE_AP) in ieee80211_sta_ps_deliver_wakeup()
1709 ps = &sdata->bss->ps; in ieee80211_sta_ps_deliver_wakeup()
1710 else if (ieee80211_vif_is_mesh(&sdata->vif)) in ieee80211_sta_ps_deliver_wakeup()
1711 ps = &sdata->u.mesh.ps; in ieee80211_sta_ps_deliver_wakeup()
1718 sta->driver_buffered_tids = 0; in ieee80211_sta_ps_deliver_wakeup()
1719 sta->txq_buffered_tids = 0; in ieee80211_sta_ps_deliver_wakeup()
1721 if (!ieee80211_hw_check(&local->hw, AP_LINK_PS)) in ieee80211_sta_ps_deliver_wakeup()
1722 drv_sta_notify(local, sdata, STA_NOTIFY_AWAKE, &sta->sta); in ieee80211_sta_ps_deliver_wakeup()
1724 for (i = 0; i < ARRAY_SIZE(sta->sta.txq); i++) { in ieee80211_sta_ps_deliver_wakeup()
1725 if (!sta->sta.txq[i] || !txq_has_queue(sta->sta.txq[i])) in ieee80211_sta_ps_deliver_wakeup()
1728 schedule_and_wake_txq(local, to_txq_info(sta->sta.txq[i])); in ieee80211_sta_ps_deliver_wakeup()
1734 spin_lock_bh(&sta->ps_lock); in ieee80211_sta_ps_deliver_wakeup()
1736 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { in ieee80211_sta_ps_deliver_wakeup()
1739 spin_lock_irqsave(&sta->tx_filtered[ac].lock, flags); in ieee80211_sta_ps_deliver_wakeup()
1740 skb_queue_splice_tail_init(&sta->tx_filtered[ac], &pending); in ieee80211_sta_ps_deliver_wakeup()
1741 spin_unlock_irqrestore(&sta->tx_filtered[ac].lock, flags); in ieee80211_sta_ps_deliver_wakeup()
1743 filtered += tmp - count; in ieee80211_sta_ps_deliver_wakeup()
1746 spin_lock_irqsave(&sta->ps_tx_buf[ac].lock, flags); in ieee80211_sta_ps_deliver_wakeup()
1747 skb_queue_splice_tail_init(&sta->ps_tx_buf[ac], &pending); in ieee80211_sta_ps_deliver_wakeup()
1748 spin_unlock_irqrestore(&sta->ps_tx_buf[ac].lock, flags); in ieee80211_sta_ps_deliver_wakeup()
1750 buffered += tmp - count; in ieee80211_sta_ps_deliver_wakeup()
1763 spin_unlock_bh(&sta->ps_lock); in ieee80211_sta_ps_deliver_wakeup()
1765 atomic_dec(&ps->num_sta_ps); in ieee80211_sta_ps_deliver_wakeup()
1767 local->total_ps_buffered -= buffered; in ieee80211_sta_ps_deliver_wakeup()
1773 sta->sta.addr, sta->sta.aid, filtered, buffered); in ieee80211_sta_ps_deliver_wakeup()
1782 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_send_null_response()
1783 struct ieee80211_local *local = sdata->local; in ieee80211_send_null_response()
1788 bool qos = sta->sta.wme; in ieee80211_send_null_response()
1797 size -= 2; in ieee80211_send_null_response()
1803 skb = dev_alloc_skb(local->hw.extra_tx_headroom + size); in ieee80211_send_null_response()
1807 skb_reserve(skb, local->hw.extra_tx_headroom); in ieee80211_send_null_response()
1810 nullfunc->frame_control = fc; in ieee80211_send_null_response()
1811 nullfunc->duration_id = 0; in ieee80211_send_null_response()
1812 memcpy(nullfunc->addr1, sta->sta.addr, ETH_ALEN); in ieee80211_send_null_response()
1813 memcpy(nullfunc->addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_send_null_response()
1814 memcpy(nullfunc->addr3, sdata->vif.addr, ETH_ALEN); in ieee80211_send_null_response()
1815 nullfunc->seq_ctrl = 0; in ieee80211_send_null_response()
1817 skb->priority = tid; in ieee80211_send_null_response()
1820 nullfunc->qos_ctrl = cpu_to_le16(tid); in ieee80211_send_null_response()
1823 nullfunc->qos_ctrl |= in ieee80211_send_null_response()
1826 nullfunc->frame_control |= in ieee80211_send_null_response()
1839 info->flags |= IEEE80211_TX_CTL_NO_PS_BUFFER | in ieee80211_send_null_response()
1843 info->control.flags |= IEEE80211_TX_CTRL_PS_RESPONSE; in ieee80211_send_null_response()
1849 skb->dev = sdata->dev; in ieee80211_send_null_response()
1852 chanctx_conf = rcu_dereference(sdata->vif.bss_conf.chanctx_conf); in ieee80211_send_null_response()
1859 info->band = chanctx_conf->def.chan->band; in ieee80211_send_null_response()
1868 return fls(tids) - 1; in find_highest_prio_tid()
1872 return fls(tids) - 1; in find_highest_prio_tid()
1885 int ac; in ieee80211_sta_ps_more_data() local
1890 * only happen for PS-Poll. in ieee80211_sta_ps_more_data()
1896 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { in ieee80211_sta_ps_more_data()
1897 if (ignored_acs & ieee80211_ac_to_qos_mask[ac]) in ieee80211_sta_ps_more_data()
1900 if (!skb_queue_empty(&sta->tx_filtered[ac]) || in ieee80211_sta_ps_more_data()
1901 !skb_queue_empty(&sta->ps_tx_buf[ac])) in ieee80211_sta_ps_more_data()
1914 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_sta_ps_get_frames()
1915 struct ieee80211_local *local = sdata->local; in ieee80211_sta_ps_get_frames()
1916 int ac; in ieee80211_sta_ps_get_frames() local
1919 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { in ieee80211_sta_ps_get_frames()
1922 if (ignored_acs & ieee80211_ac_to_qos_mask[ac]) in ieee80211_sta_ps_get_frames()
1925 tids = ieee80211_tids_for_ac(ac); in ieee80211_sta_ps_get_frames()
1932 sta->driver_buffered_tids & tids; in ieee80211_sta_ps_get_frames()
1933 *driver_release_tids |= sta->txq_buffered_tids & tids; in ieee80211_sta_ps_get_frames()
1940 skb = skb_dequeue(&sta->tx_filtered[ac]); in ieee80211_sta_ps_get_frames()
1943 &sta->ps_tx_buf[ac]); in ieee80211_sta_ps_get_frames()
1945 local->total_ps_buffered--; in ieee80211_sta_ps_get_frames()
1949 n_frames--; in ieee80211_sta_ps_get_frames()
1954 /* If we have more frames buffered on this AC, then abort the in ieee80211_sta_ps_get_frames()
1958 if (!skb_queue_empty(&sta->tx_filtered[ac]) || in ieee80211_sta_ps_get_frames()
1959 !skb_queue_empty(&sta->ps_tx_buf[ac])) in ieee80211_sta_ps_get_frames()
1969 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_sta_ps_deliver_response()
1970 struct ieee80211_local *local = sdata->local; in ieee80211_sta_ps_deliver_response()
1975 /* Service or PS-Poll period starts */ in ieee80211_sta_ps_deliver_response()
1990 int tid, ac; in ieee80211_sta_ps_deliver_response() local
1993 * For PS-Poll, this can only happen due to a race condition in ieee80211_sta_ps_deliver_response()
1998 * At each unscheduled SP for a non-AP STA, the AP shall in ieee80211_sta_ps_deliver_response()
2001 * in the QoS Capability element from delivery-enabled ACs, in ieee80211_sta_ps_deliver_response()
2002 * that are destined for the non-AP STA. in ieee80211_sta_ps_deliver_response()
2008 for (ac = IEEE80211_AC_VO; ac < IEEE80211_NUM_ACS; ac++) in ieee80211_sta_ps_deliver_response()
2009 if (!(ignored_acs & ieee80211_ac_to_qos_mask[ac])) in ieee80211_sta_ps_deliver_response()
2011 tid = 7 - 2 * ac; in ieee80211_sta_ps_deliver_response()
2025 struct ieee80211_hdr *hdr = (void *) skb->data; in ieee80211_sta_ps_deliver_response()
2035 info->flags |= IEEE80211_TX_CTL_NO_PS_BUFFER; in ieee80211_sta_ps_deliver_response()
2036 info->control.flags |= IEEE80211_TX_CTRL_PS_RESPONSE; in ieee80211_sta_ps_deliver_response()
2043 hdr->frame_control |= in ieee80211_sta_ps_deliver_response()
2046 hdr->frame_control &= in ieee80211_sta_ps_deliver_response()
2049 if (ieee80211_is_data_qos(hdr->frame_control) || in ieee80211_sta_ps_deliver_response()
2050 ieee80211_is_qos_nullfunc(hdr->frame_control)) in ieee80211_sta_ps_deliver_response()
2053 tids |= BIT(skb->priority); in ieee80211_sta_ps_deliver_response()
2062 /* for PS-Poll, there's only one frame */ in ieee80211_sta_ps_deliver_response()
2063 info->flags |= IEEE80211_TX_STATUS_EOSP | in ieee80211_sta_ps_deliver_response()
2069 * last frame has a QoS header (i.e. is a QoS-data or in ieee80211_sta_ps_deliver_response()
2070 * QoS-nulldata frame) then just set the EOSP bit there in ieee80211_sta_ps_deliver_response()
2074 * the EOSP bit in the QoS header; add a QoS-nulldata in ieee80211_sta_ps_deliver_response()
2077 * Note that this code is only in the mac80211-release in ieee80211_sta_ps_deliver_response()
2079 * anything but QoS-data frames, or if it does, will in ieee80211_sta_ps_deliver_response()
2080 * create the QoS-nulldata frame by itself if needed. in ieee80211_sta_ps_deliver_response()
2082 * Cf. 802.11-2012 10.2.1.10 (c). in ieee80211_sta_ps_deliver_response()
2087 info->flags |= IEEE80211_TX_STATUS_EOSP | in ieee80211_sta_ps_deliver_response()
2091 * as it says the more-data bit should be set in ieee80211_sta_ps_deliver_response()
2092 * if there are more BUs. The QoS-Null frame in ieee80211_sta_ps_deliver_response()
2096 * expect more-data=0 when eosp=1. in ieee80211_sta_ps_deliver_response()
2098 hdr->frame_control |= in ieee80211_sta_ps_deliver_response()
2124 * on the TIDs we're releasing from - if there are more than in ieee80211_sta_ps_deliver_response()
2125 * n_frames it has to set the more-data bit (if we didn't ask in ieee80211_sta_ps_deliver_response()
2143 for (tid = 0; tid < ARRAY_SIZE(sta->sta.txq); tid++) { in ieee80211_sta_ps_deliver_response()
2144 if (!sta->sta.txq[tid] || in ieee80211_sta_ps_deliver_response()
2146 txq_has_queue(sta->sta.txq[tid])) in ieee80211_sta_ps_deliver_response()
2157 u8 ignore_for_response = sta->sta.uapsd_queues; in ieee80211_sta_ps_deliver_poll_response()
2160 * If all ACs are delivery-enabled then we should reply in ieee80211_sta_ps_deliver_poll_response()
2162 * only from the non-enabled ones. in ieee80211_sta_ps_deliver_poll_response()
2164 if (ignore_for_response == BIT(IEEE80211_NUM_ACS) - 1) in ieee80211_sta_ps_deliver_poll_response()
2173 int n_frames = sta->sta.max_sp; in ieee80211_sta_ps_deliver_uapsd()
2174 u8 delivery_enabled = sta->sta.uapsd_queues; in ieee80211_sta_ps_deliver_uapsd()
2185 switch (sta->sta.max_sp) { in ieee80211_sta_ps_deliver_uapsd()
2210 trace_api_sta_block_awake(sta->local, pubsta, block); in ieee80211_sta_block_awake()
2224 ieee80211_queue_work(hw, &sta->drv_deliver_wk); in ieee80211_sta_block_awake()
2229 ieee80211_queue_work(hw, &sta->drv_deliver_wk); in ieee80211_sta_block_awake()
2240 struct ieee80211_local *local = sta->local; in ieee80211_sta_eosp()
2254 trace_api_send_eosp_nullfunc(sta->local, pubsta, tid); in ieee80211_send_eosp_nullfunc()
2257 more_data = ieee80211_sta_ps_more_data(sta, ~sta->sta.uapsd_queues, in ieee80211_send_eosp_nullfunc()
2272 trace_api_sta_set_buffered(sta->local, pubsta, tid, buffered); in ieee80211_sta_set_buffered()
2275 set_bit(tid, &sta->driver_buffered_tids); in ieee80211_sta_set_buffered()
2277 clear_bit(tid, &sta->driver_buffered_tids); in ieee80211_sta_set_buffered()
2287 struct ieee80211_local *local = sta->sdata->local; in ieee80211_sta_register_airtime()
2288 u8 ac = ieee80211_ac_from_tid(tid); in ieee80211_sta_register_airtime() local
2292 if (sta->local->airtime_flags & AIRTIME_USE_TX) in ieee80211_sta_register_airtime()
2294 if (sta->local->airtime_flags & AIRTIME_USE_RX) in ieee80211_sta_register_airtime()
2297 spin_lock_bh(&local->active_txq_lock[ac]); in ieee80211_sta_register_airtime()
2298 sta->airtime[ac].tx_airtime += tx_airtime; in ieee80211_sta_register_airtime()
2299 sta->airtime[ac].rx_airtime += rx_airtime; in ieee80211_sta_register_airtime()
2301 diff = (u32)jiffies - sta->airtime[ac].last_active; in ieee80211_sta_register_airtime()
2303 sta->airtime[ac].deficit -= airtime; in ieee80211_sta_register_airtime()
2305 spin_unlock_bh(&local->active_txq_lock[ac]); in ieee80211_sta_register_airtime()
2314 if (!sta->sta.valid_links || !sta->sta.mlo) { in __ieee80211_sta_recalc_aggregates()
2315 sta->sta.cur = &sta->sta.deflink.agg; in __ieee80211_sta_recalc_aggregates()
2320 for (link_id = 0; link_id < ARRAY_SIZE((sta)->link); link_id++) { in __ieee80211_sta_recalc_aggregates()
2327 link_sta = rcu_dereference(sta->sta.link[link_id]); in __ieee80211_sta_recalc_aggregates()
2332 sta->cur = sta->sta.deflink.agg; in __ieee80211_sta_recalc_aggregates()
2337 sta->cur.max_amsdu_len = in __ieee80211_sta_recalc_aggregates()
2338 min(sta->cur.max_amsdu_len, in __ieee80211_sta_recalc_aggregates()
2339 link_sta->agg.max_amsdu_len); in __ieee80211_sta_recalc_aggregates()
2340 sta->cur.max_rc_amsdu_len = in __ieee80211_sta_recalc_aggregates()
2341 min(sta->cur.max_rc_amsdu_len, in __ieee80211_sta_recalc_aggregates()
2342 link_sta->agg.max_rc_amsdu_len); in __ieee80211_sta_recalc_aggregates()
2344 for (i = 0; i < ARRAY_SIZE(sta->cur.max_tid_amsdu_len); i++) in __ieee80211_sta_recalc_aggregates()
2345 sta->cur.max_tid_amsdu_len[i] = in __ieee80211_sta_recalc_aggregates()
2346 min(sta->cur.max_tid_amsdu_len[i], in __ieee80211_sta_recalc_aggregates()
2347 link_sta->agg.max_tid_amsdu_len[i]); in __ieee80211_sta_recalc_aggregates()
2351 sta->sta.cur = &sta->cur; in __ieee80211_sta_recalc_aggregates()
2358 __ieee80211_sta_recalc_aggregates(sta, sta->sdata->vif.active_links); in ieee80211_sta_recalc_aggregates()
2363 struct sta_info *sta, u8 ac, in ieee80211_sta_update_pending_airtime() argument
2368 if (!wiphy_ext_feature_isset(local->hw.wiphy, NL80211_EXT_FEATURE_AQL)) in ieee80211_sta_update_pending_airtime()
2374 &sta->airtime[ac].aql_tx_pending); in ieee80211_sta_update_pending_airtime()
2376 atomic_add(tx_airtime, &local->aql_total_pending_airtime); in ieee80211_sta_update_pending_airtime()
2377 atomic_add(tx_airtime, &local->aql_ac_pending_airtime[ac]); in ieee80211_sta_update_pending_airtime()
2383 &sta->airtime[ac].aql_tx_pending); in ieee80211_sta_update_pending_airtime()
2385 atomic_cmpxchg(&sta->airtime[ac].aql_tx_pending, in ieee80211_sta_update_pending_airtime()
2389 atomic_sub(tx_airtime, &local->aql_total_pending_airtime); in ieee80211_sta_update_pending_airtime()
2391 &local->aql_ac_pending_airtime[ac]); in ieee80211_sta_update_pending_airtime()
2393 "Device %s AC %d pending airtime underflow: %u, %u", in ieee80211_sta_update_pending_airtime()
2394 wiphy_name(local->hw.wiphy), ac, tx_pending, in ieee80211_sta_update_pending_airtime()
2396 atomic_cmpxchg(&local->aql_ac_pending_airtime[ac], in ieee80211_sta_update_pending_airtime()
2398 atomic_sub(tx_pending, &local->aql_total_pending_airtime); in ieee80211_sta_update_pending_airtime()
2405 struct ieee80211_sta_rx_stats *stats = &sta->deflink.rx_stats; in sta_get_last_rx_stats()
2408 if (!sta->deflink.pcpu_rx_stats) in sta_get_last_rx_stats()
2414 cpustats = per_cpu_ptr(sta->deflink.pcpu_rx_stats, cpu); in sta_get_last_rx_stats()
2416 if (time_after(cpustats->last_rx, stats->last_rx)) in sta_get_last_rx_stats()
2426 rinfo->bw = STA_STATS_GET(BW, rate); in sta_stats_decode_rate()
2430 rinfo->flags = RATE_INFO_FLAGS_VHT_MCS; in sta_stats_decode_rate()
2431 rinfo->mcs = STA_STATS_GET(VHT_MCS, rate); in sta_stats_decode_rate()
2432 rinfo->nss = STA_STATS_GET(VHT_NSS, rate); in sta_stats_decode_rate()
2434 rinfo->flags |= RATE_INFO_FLAGS_SHORT_GI; in sta_stats_decode_rate()
2437 rinfo->flags = RATE_INFO_FLAGS_MCS; in sta_stats_decode_rate()
2438 rinfo->mcs = STA_STATS_GET(HT_MCS, rate); in sta_stats_decode_rate()
2440 rinfo->flags |= RATE_INFO_FLAGS_SHORT_GI; in sta_stats_decode_rate()
2449 sband = local->hw.wiphy->bands[band]; in sta_stats_decode_rate()
2451 if (WARN_ON_ONCE(!sband->bitrates)) in sta_stats_decode_rate()
2454 brate = sband->bitrates[rate_idx].bitrate; in sta_stats_decode_rate()
2455 if (rinfo->bw == RATE_INFO_BW_5) in sta_stats_decode_rate()
2457 else if (rinfo->bw == RATE_INFO_BW_10) in sta_stats_decode_rate()
2461 rinfo->legacy = DIV_ROUND_UP(brate, 1 << shift); in sta_stats_decode_rate()
2465 rinfo->flags = RATE_INFO_FLAGS_HE_MCS; in sta_stats_decode_rate()
2466 rinfo->mcs = STA_STATS_GET(HE_MCS, rate); in sta_stats_decode_rate()
2467 rinfo->nss = STA_STATS_GET(HE_NSS, rate); in sta_stats_decode_rate()
2468 rinfo->he_gi = STA_STATS_GET(HE_GI, rate); in sta_stats_decode_rate()
2469 rinfo->he_ru_alloc = STA_STATS_GET(HE_RU, rate); in sta_stats_decode_rate()
2470 rinfo->he_dcm = STA_STATS_GET(HE_DCM, rate); in sta_stats_decode_rate()
2473 rinfo->flags = RATE_INFO_FLAGS_EHT_MCS; in sta_stats_decode_rate()
2474 rinfo->mcs = STA_STATS_GET(EHT_MCS, rate); in sta_stats_decode_rate()
2475 rinfo->nss = STA_STATS_GET(EHT_NSS, rate); in sta_stats_decode_rate()
2476 rinfo->eht_gi = STA_STATS_GET(EHT_GI, rate); in sta_stats_decode_rate()
2477 rinfo->eht_ru_alloc = STA_STATS_GET(EHT_RU, rate); in sta_stats_decode_rate()
2484 u32 rate = READ_ONCE(sta_get_last_rx_stats(sta)->last_rate); in sta_set_rate_info_rx()
2487 return -EINVAL; in sta_set_rate_info_rx()
2489 sta_stats_decode_rate(sta->local, rate, rinfo); in sta_set_rate_info_rx()
2500 start = u64_stats_fetch_begin(&rxstats->syncp); in sta_get_tidstats_msdu()
2501 value = rxstats->msdu[tid]; in sta_get_tidstats_msdu()
2502 } while (u64_stats_fetch_retry(&rxstats->syncp, start)); in sta_get_tidstats_msdu()
2511 struct ieee80211_local *local = sta->local; in sta_set_tidstats()
2514 if (!(tidstats->filled & BIT(NL80211_TID_STATS_RX_MSDU))) { in sta_set_tidstats()
2515 tidstats->rx_msdu += sta_get_tidstats_msdu(&sta->deflink.rx_stats, in sta_set_tidstats()
2518 if (sta->deflink.pcpu_rx_stats) { in sta_set_tidstats()
2522 cpurxs = per_cpu_ptr(sta->deflink.pcpu_rx_stats, in sta_set_tidstats()
2524 tidstats->rx_msdu += in sta_set_tidstats()
2529 tidstats->filled |= BIT(NL80211_TID_STATS_RX_MSDU); in sta_set_tidstats()
2532 if (!(tidstats->filled & BIT(NL80211_TID_STATS_TX_MSDU))) { in sta_set_tidstats()
2533 tidstats->filled |= BIT(NL80211_TID_STATS_TX_MSDU); in sta_set_tidstats()
2534 tidstats->tx_msdu = sta->deflink.tx_stats.msdu[tid]; in sta_set_tidstats()
2537 if (!(tidstats->filled & BIT(NL80211_TID_STATS_TX_MSDU_RETRIES)) && in sta_set_tidstats()
2538 ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) { in sta_set_tidstats()
2539 tidstats->filled |= BIT(NL80211_TID_STATS_TX_MSDU_RETRIES); in sta_set_tidstats()
2540 tidstats->tx_msdu_retries = sta->deflink.status_stats.msdu_retries[tid]; in sta_set_tidstats()
2543 if (!(tidstats->filled & BIT(NL80211_TID_STATS_TX_MSDU_FAILED)) && in sta_set_tidstats()
2544 ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) { in sta_set_tidstats()
2545 tidstats->filled |= BIT(NL80211_TID_STATS_TX_MSDU_FAILED); in sta_set_tidstats()
2546 tidstats->tx_msdu_failed = sta->deflink.status_stats.msdu_failed[tid]; in sta_set_tidstats()
2550 spin_lock_bh(&local->fq.lock); in sta_set_tidstats()
2553 tidstats->filled |= BIT(NL80211_TID_STATS_TXQ_STATS); in sta_set_tidstats()
2554 ieee80211_fill_txq_stats(&tidstats->txq_stats, in sta_set_tidstats()
2555 to_txq_info(sta->sta.txq[tid])); in sta_set_tidstats()
2558 spin_unlock_bh(&local->fq.lock); in sta_set_tidstats()
2568 start = u64_stats_fetch_begin(&rxstats->syncp); in sta_get_stats_bytes()
2569 value = rxstats->bytes; in sta_get_stats_bytes()
2570 } while (u64_stats_fetch_retry(&rxstats->syncp, start)); in sta_get_stats_bytes()
2578 struct ieee80211_sub_if_data *sdata = sta->sdata; in sta_set_sinfo()
2579 struct ieee80211_local *local = sdata->local; in sta_set_sinfo()
2581 int i, ac, cpu; in sta_set_sinfo() local
2586 sinfo->generation = sdata->local->sta_generation; in sta_set_sinfo()
2592 if (sdata->vif.type == NL80211_IFTYPE_STATION) in sta_set_sinfo()
2593 sinfo->rx_beacon = sdata->deflink.u.mgd.count_beacon_signal; in sta_set_sinfo()
2595 drv_sta_statistics(local, sdata, &sta->sta, sinfo); in sta_set_sinfo()
2596 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_INACTIVE_TIME) | in sta_set_sinfo()
2603 if (sdata->vif.type == NL80211_IFTYPE_STATION) { in sta_set_sinfo()
2604 sinfo->beacon_loss_count = in sta_set_sinfo()
2605 sdata->deflink.u.mgd.beacon_loss_count; in sta_set_sinfo()
2606 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_BEACON_LOSS); in sta_set_sinfo()
2609 sinfo->connected_time = ktime_get_seconds() - sta->last_connected; in sta_set_sinfo()
2610 sinfo->assoc_at = sta->assoc_at; in sta_set_sinfo()
2611 sinfo->inactive_time = in sta_set_sinfo()
2612 jiffies_to_msecs(jiffies - ieee80211_sta_last_active(sta)); in sta_set_sinfo()
2614 if (!(sinfo->filled & (BIT_ULL(NL80211_STA_INFO_TX_BYTES64) | in sta_set_sinfo()
2616 sinfo->tx_bytes = 0; in sta_set_sinfo()
2617 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) in sta_set_sinfo()
2618 sinfo->tx_bytes += sta->deflink.tx_stats.bytes[ac]; in sta_set_sinfo()
2619 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BYTES64); in sta_set_sinfo()
2622 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_TX_PACKETS))) { in sta_set_sinfo()
2623 sinfo->tx_packets = 0; in sta_set_sinfo()
2624 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) in sta_set_sinfo()
2625 sinfo->tx_packets += sta->deflink.tx_stats.packets[ac]; in sta_set_sinfo()
2626 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_PACKETS); in sta_set_sinfo()
2629 if (!(sinfo->filled & (BIT_ULL(NL80211_STA_INFO_RX_BYTES64) | in sta_set_sinfo()
2631 sinfo->rx_bytes += sta_get_stats_bytes(&sta->deflink.rx_stats); in sta_set_sinfo()
2633 if (sta->deflink.pcpu_rx_stats) { in sta_set_sinfo()
2637 cpurxs = per_cpu_ptr(sta->deflink.pcpu_rx_stats, in sta_set_sinfo()
2639 sinfo->rx_bytes += sta_get_stats_bytes(cpurxs); in sta_set_sinfo()
2643 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_BYTES64); in sta_set_sinfo()
2646 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_RX_PACKETS))) { in sta_set_sinfo()
2647 sinfo->rx_packets = sta->deflink.rx_stats.packets; in sta_set_sinfo()
2648 if (sta->deflink.pcpu_rx_stats) { in sta_set_sinfo()
2652 cpurxs = per_cpu_ptr(sta->deflink.pcpu_rx_stats, in sta_set_sinfo()
2654 sinfo->rx_packets += cpurxs->packets; in sta_set_sinfo()
2657 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_PACKETS); in sta_set_sinfo()
2660 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_TX_RETRIES))) { in sta_set_sinfo()
2661 sinfo->tx_retries = sta->deflink.status_stats.retry_count; in sta_set_sinfo()
2662 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_RETRIES); in sta_set_sinfo()
2665 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_TX_FAILED))) { in sta_set_sinfo()
2666 sinfo->tx_failed = sta->deflink.status_stats.retry_failed; in sta_set_sinfo()
2667 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_FAILED); in sta_set_sinfo()
2670 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_RX_DURATION))) { in sta_set_sinfo()
2671 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) in sta_set_sinfo()
2672 sinfo->rx_duration += sta->airtime[ac].rx_airtime; in sta_set_sinfo()
2673 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_DURATION); in sta_set_sinfo()
2676 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_TX_DURATION))) { in sta_set_sinfo()
2677 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) in sta_set_sinfo()
2678 sinfo->tx_duration += sta->airtime[ac].tx_airtime; in sta_set_sinfo()
2679 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_DURATION); in sta_set_sinfo()
2682 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_AIRTIME_WEIGHT))) { in sta_set_sinfo()
2683 sinfo->airtime_weight = sta->airtime_weight; in sta_set_sinfo()
2684 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_AIRTIME_WEIGHT); in sta_set_sinfo()
2687 sinfo->rx_dropped_misc = sta->deflink.rx_stats.dropped; in sta_set_sinfo()
2688 if (sta->deflink.pcpu_rx_stats) { in sta_set_sinfo()
2692 cpurxs = per_cpu_ptr(sta->deflink.pcpu_rx_stats, cpu); in sta_set_sinfo()
2693 sinfo->rx_dropped_misc += cpurxs->dropped; in sta_set_sinfo()
2697 if (sdata->vif.type == NL80211_IFTYPE_STATION && in sta_set_sinfo()
2698 !(sdata->vif.driver_flags & IEEE80211_VIF_BEACON_FILTER)) { in sta_set_sinfo()
2699 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_BEACON_RX) | in sta_set_sinfo()
2701 sinfo->rx_beacon_signal_avg = ieee80211_ave_rssi(&sdata->vif); in sta_set_sinfo()
2704 if (ieee80211_hw_check(&sta->local->hw, SIGNAL_DBM) || in sta_set_sinfo()
2705 ieee80211_hw_check(&sta->local->hw, SIGNAL_UNSPEC)) { in sta_set_sinfo()
2706 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_SIGNAL))) { in sta_set_sinfo()
2707 sinfo->signal = (s8)last_rxstats->last_signal; in sta_set_sinfo()
2708 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL); in sta_set_sinfo()
2711 if (!sta->deflink.pcpu_rx_stats && in sta_set_sinfo()
2712 !(sinfo->filled & BIT_ULL(NL80211_STA_INFO_SIGNAL_AVG))) { in sta_set_sinfo()
2713 sinfo->signal_avg = in sta_set_sinfo()
2714 -ewma_signal_read(&sta->deflink.rx_stats_avg.signal); in sta_set_sinfo()
2715 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL_AVG); in sta_set_sinfo()
2719 /* for the average - if pcpu_rx_stats isn't set - rxstats must point to in sta_set_sinfo()
2720 * the sta->rx_stats struct, so the check here is fine with and without in sta_set_sinfo()
2723 if (last_rxstats->chains && in sta_set_sinfo()
2724 !(sinfo->filled & (BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL) | in sta_set_sinfo()
2726 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL); in sta_set_sinfo()
2727 if (!sta->deflink.pcpu_rx_stats) in sta_set_sinfo()
2728 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL_AVG); in sta_set_sinfo()
2730 sinfo->chains = last_rxstats->chains; in sta_set_sinfo()
2732 for (i = 0; i < ARRAY_SIZE(sinfo->chain_signal); i++) { in sta_set_sinfo()
2733 sinfo->chain_signal[i] = in sta_set_sinfo()
2734 last_rxstats->chain_signal_last[i]; in sta_set_sinfo()
2735 sinfo->chain_signal_avg[i] = in sta_set_sinfo()
2736 -ewma_signal_read(&sta->deflink.rx_stats_avg.chain_signal[i]); in sta_set_sinfo()
2740 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_TX_BITRATE)) && in sta_set_sinfo()
2741 !sta->sta.valid_links) { in sta_set_sinfo()
2742 sta_set_rate_info_tx(sta, &sta->deflink.tx_stats.last_rate, in sta_set_sinfo()
2743 &sinfo->txrate); in sta_set_sinfo()
2744 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BITRATE); in sta_set_sinfo()
2747 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_RX_BITRATE)) && in sta_set_sinfo()
2748 !sta->sta.valid_links) { in sta_set_sinfo()
2749 if (sta_set_rate_info_rx(sta, &sinfo->rxrate) == 0) in sta_set_sinfo()
2750 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_BITRATE); in sta_set_sinfo()
2755 sta_set_tidstats(sta, &sinfo->pertid[i], i); in sta_set_sinfo()
2758 if (ieee80211_vif_is_mesh(&sdata->vif)) { in sta_set_sinfo()
2760 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_LLID) | in sta_set_sinfo()
2769 sinfo->llid = sta->mesh->llid; in sta_set_sinfo()
2770 sinfo->plid = sta->mesh->plid; in sta_set_sinfo()
2771 sinfo->plink_state = sta->mesh->plink_state; in sta_set_sinfo()
2773 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_T_OFFSET); in sta_set_sinfo()
2774 sinfo->t_offset = sta->mesh->t_offset; in sta_set_sinfo()
2776 sinfo->local_pm = sta->mesh->local_pm; in sta_set_sinfo()
2777 sinfo->peer_pm = sta->mesh->peer_pm; in sta_set_sinfo()
2778 sinfo->nonpeer_pm = sta->mesh->nonpeer_pm; in sta_set_sinfo()
2779 sinfo->connected_to_gate = sta->mesh->connected_to_gate; in sta_set_sinfo()
2780 sinfo->connected_to_as = sta->mesh->connected_to_as; in sta_set_sinfo()
2784 sinfo->bss_param.flags = 0; in sta_set_sinfo()
2785 if (sdata->vif.bss_conf.use_cts_prot) in sta_set_sinfo()
2786 sinfo->bss_param.flags |= BSS_PARAM_FLAGS_CTS_PROT; in sta_set_sinfo()
2787 if (sdata->vif.bss_conf.use_short_preamble) in sta_set_sinfo()
2788 sinfo->bss_param.flags |= BSS_PARAM_FLAGS_SHORT_PREAMBLE; in sta_set_sinfo()
2789 if (sdata->vif.bss_conf.use_short_slot) in sta_set_sinfo()
2790 sinfo->bss_param.flags |= BSS_PARAM_FLAGS_SHORT_SLOT_TIME; in sta_set_sinfo()
2791 sinfo->bss_param.dtim_period = sdata->vif.bss_conf.dtim_period; in sta_set_sinfo()
2792 sinfo->bss_param.beacon_interval = sdata->vif.bss_conf.beacon_int; in sta_set_sinfo()
2794 sinfo->sta_flags.set = 0; in sta_set_sinfo()
2795 sinfo->sta_flags.mask = BIT(NL80211_STA_FLAG_AUTHORIZED) | in sta_set_sinfo()
2803 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_AUTHORIZED); in sta_set_sinfo()
2805 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_SHORT_PREAMBLE); in sta_set_sinfo()
2806 if (sta->sta.wme) in sta_set_sinfo()
2807 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_WME); in sta_set_sinfo()
2809 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_MFP); in sta_set_sinfo()
2811 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_AUTHENTICATED); in sta_set_sinfo()
2813 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_ASSOCIATED); in sta_set_sinfo()
2815 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_TDLS_PEER); in sta_set_sinfo()
2820 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_EXPECTED_THROUGHPUT); in sta_set_sinfo()
2821 sinfo->expected_throughput = thr; in sta_set_sinfo()
2824 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_ACK_SIGNAL)) && in sta_set_sinfo()
2825 sta->deflink.status_stats.ack_signal_filled) { in sta_set_sinfo()
2826 sinfo->ack_signal = sta->deflink.status_stats.last_ack_signal; in sta_set_sinfo()
2827 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_ACK_SIGNAL); in sta_set_sinfo()
2830 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_ACK_SIGNAL_AVG)) && in sta_set_sinfo()
2831 sta->deflink.status_stats.ack_signal_filled) { in sta_set_sinfo()
2832 sinfo->avg_ack_signal = in sta_set_sinfo()
2833 -(s8)ewma_avg_signal_read( in sta_set_sinfo()
2834 &sta->deflink.status_stats.avg_ack_signal); in sta_set_sinfo()
2835 sinfo->filled |= in sta_set_sinfo()
2839 if (ieee80211_vif_is_mesh(&sdata->vif)) { in sta_set_sinfo()
2840 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_AIRTIME_LINK_METRIC); in sta_set_sinfo()
2841 sinfo->airtime_link_metric = in sta_set_sinfo()
2848 struct ieee80211_sub_if_data *sdata = sta->sdata; in sta_get_expected_throughput()
2849 struct ieee80211_local *local = sdata->local; in sta_get_expected_throughput()
2854 ref = local->rate_ctrl; in sta_get_expected_throughput()
2857 if (ref && ref->ops->get_expected_throughput) in sta_get_expected_throughput()
2858 thr = ref->ops->get_expected_throughput(sta->rate_ctrl_priv); in sta_get_expected_throughput()
2869 if (!sta->deflink.status_stats.last_ack || in ieee80211_sta_last_active()
2870 time_after(stats->last_rx, sta->deflink.status_stats.last_ack)) in ieee80211_sta_last_active()
2871 return stats->last_rx; in ieee80211_sta_last_active()
2872 return sta->deflink.status_stats.last_ack; in ieee80211_sta_last_active()
2877 if (thr && thr < STA_SLOW_THRESHOLD * sta->local->num_sta) { in sta_update_codel_params()
2878 sta->cparams.target = MS2TIME(50); in sta_update_codel_params()
2879 sta->cparams.interval = MS2TIME(300); in sta_update_codel_params()
2880 sta->cparams.ecn = false; in sta_update_codel_params()
2882 sta->cparams.target = MS2TIME(20); in sta_update_codel_params()
2883 sta->cparams.interval = MS2TIME(100); in sta_update_codel_params()
2884 sta->cparams.ecn = true; in sta_update_codel_params()
2898 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_sta_allocate_link()
2902 lockdep_assert_held(&sdata->local->sta_mtx); in ieee80211_sta_allocate_link()
2905 if (WARN_ON(!sta->sta.valid_links)) in ieee80211_sta_allocate_link()
2906 return -EINVAL; in ieee80211_sta_allocate_link()
2908 if (WARN_ON(sta->sta.valid_links & BIT(link_id) || in ieee80211_sta_allocate_link()
2909 sta->link[link_id])) in ieee80211_sta_allocate_link()
2910 return -EBUSY; in ieee80211_sta_allocate_link()
2914 return -ENOMEM; in ieee80211_sta_allocate_link()
2916 ret = sta_info_alloc_link(sdata->local, &alloc->info, GFP_KERNEL); in ieee80211_sta_allocate_link()
2922 sta_info_add_link(sta, link_id, &alloc->info, &alloc->sta); in ieee80211_sta_allocate_link()
2924 ieee80211_link_sta_debugfs_add(&alloc->info); in ieee80211_sta_allocate_link()
2931 lockdep_assert_held(&sta->sdata->local->sta_mtx); in ieee80211_sta_free_link()
2938 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_sta_activate_link()
2940 u16 old_links = sta->sta.valid_links; in ieee80211_sta_activate_link()
2944 link_sta = rcu_dereference_protected(sta->link[link_id], in ieee80211_sta_activate_link()
2945 lockdep_is_held(&sdata->local->sta_mtx)); in ieee80211_sta_activate_link()
2948 return -EINVAL; in ieee80211_sta_activate_link()
2951 if (link_sta_info_hash_lookup(sdata->local, link_sta->addr)) { in ieee80211_sta_activate_link()
2953 return -EALREADY; in ieee80211_sta_activate_link()
2958 sta->sta.valid_links = new_links; in ieee80211_sta_activate_link()
2968 ieee80211_sta_recalc_aggregates(&sta->sta); in ieee80211_sta_activate_link()
2970 ret = drv_change_sta_links(sdata->local, sdata, &sta->sta, in ieee80211_sta_activate_link()
2973 sta->sta.valid_links = old_links; in ieee80211_sta_activate_link()
2979 ret = link_sta_info_hash_add(sdata->local, link_sta); in ieee80211_sta_activate_link()
2986 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_sta_remove_link()
2987 u16 old_links = sta->sta.valid_links; in ieee80211_sta_remove_link()
2989 lockdep_assert_held(&sdata->local->sta_mtx); in ieee80211_sta_remove_link()
2991 sta->sta.valid_links &= ~BIT(link_id); in ieee80211_sta_remove_link()
2994 drv_change_sta_links(sdata->local, sdata, &sta->sta, in ieee80211_sta_remove_link()
2995 old_links, sta->sta.valid_links); in ieee80211_sta_remove_link()
3006 sta->sta.max_amsdu_subframes = 0; in ieee80211_sta_set_max_amsdu_subframes()
3020 sta->sta.max_amsdu_subframes = 4 << (4 - val); in ieee80211_sta_set_max_amsdu_subframes()
3028 return lockdep_is_held(&sta->local->sta_mtx); in lockdep_sta_mutex_held()