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-2024 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()
1329 if (new_state > sta->sta_state && in _sta_info_move_state()
1331 int err = drv_sta_state(sta->local, sta->sdata, sta, in _sta_info_move_state()
1332 sta->sta_state, new_state); in _sta_info_move_state()
1341 if (sta->sta_state == IEEE80211_STA_AUTH) in _sta_info_move_state()
1342 clear_bit(WLAN_STA_AUTH, &sta->_flags); in _sta_info_move_state()
1345 if (sta->sta_state == IEEE80211_STA_NONE) { in _sta_info_move_state()
1346 set_bit(WLAN_STA_AUTH, &sta->_flags); in _sta_info_move_state()
1347 } else if (sta->sta_state == IEEE80211_STA_ASSOC) { in _sta_info_move_state()
1348 clear_bit(WLAN_STA_ASSOC, &sta->_flags); in _sta_info_move_state()
1350 ieee80211_recalc_min_chandef(sta->sdata, -1); in _sta_info_move_state()
1351 if (!sta->sta.support_p2p_ps) in _sta_info_move_state()
1352 ieee80211_recalc_p2p_go_ps_allowed(sta->sdata); in _sta_info_move_state()
1357 if (sta->sta_state == IEEE80211_STA_AUTH) { in _sta_info_move_state()
1358 set_bit(WLAN_STA_ASSOC, &sta->_flags); in _sta_info_move_state()
1359 sta->assoc_at = ktime_get_boottime_ns(); in _sta_info_move_state()
1361 ieee80211_recalc_min_chandef(sta->sdata, -1); in _sta_info_move_state()
1362 if (!sta->sta.support_p2p_ps) in _sta_info_move_state()
1363 ieee80211_recalc_p2p_go_ps_allowed(sta->sdata); in _sta_info_move_state()
1365 } else if (sta->sta_state == IEEE80211_STA_AUTHORIZED) { in _sta_info_move_state()
1366 ieee80211_vif_dec_num_mcast(sta->sdata); in _sta_info_move_state()
1367 clear_bit(WLAN_STA_AUTHORIZED, &sta->_flags); in _sta_info_move_state()
1376 if (local->ops->set_key) { in _sta_info_move_state()
1378 if (local->ops->flush_sta) in _sta_info_move_state()
1379 drv_flush_sta(local, sta->sdata, sta); in _sta_info_move_state()
1382 sta->sdata, in _sta_info_move_state()
1391 if (sta->sta_state == IEEE80211_STA_ASSOC) { in _sta_info_move_state()
1392 ieee80211_vif_inc_num_mcast(sta->sdata); in _sta_info_move_state()
1393 set_bit(WLAN_STA_AUTHORIZED, &sta->_flags); in _sta_info_move_state()
1397 if (sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN || in _sta_info_move_state()
1398 sta->sdata->vif.type == NL80211_IFTYPE_AP) in _sta_info_move_state()
1399 cfg80211_send_layer2_update(sta->sdata->dev, in _sta_info_move_state()
1400 sta->sta.addr); in _sta_info_move_state()
1406 if (new_state < sta->sta_state && in _sta_info_move_state()
1408 int err = drv_sta_state(sta->local, sta->sdata, sta, in _sta_info_move_state()
1409 sta->sta_state, new_state); in _sta_info_move_state()
1416 sta->sta_state = new_state; in _sta_info_move_state()
1429 struct ieee80211_local *local = sta->local; in __sta_info_destroy_part2()
1430 struct ieee80211_sub_if_data *sdata = sta->sdata; in __sta_info_destroy_part2()
1454 lockdep_assert_held(&local->sta_mtx); in __sta_info_destroy_part2()
1456 if (sta->sta_state == IEEE80211_STA_AUTHORIZED) { in __sta_info_destroy_part2()
1464 /* disable TIM bit - last chance to tell driver */ in __sta_info_destroy_part2()
1467 sta->dead = true; in __sta_info_destroy_part2()
1469 local->num_sta--; in __sta_info_destroy_part2()
1470 local->sta_generation++; in __sta_info_destroy_part2()
1472 while (sta->sta_state > IEEE80211_STA_NONE) { in __sta_info_destroy_part2()
1473 ret = _sta_info_move_state(sta, sta->sta_state - 1, recalc); in __sta_info_destroy_part2()
1480 if (sta->uploaded) { in __sta_info_destroy_part2()
1486 sta_dbg(sdata, "Removed STA %pM\n", sta->sta.addr); in __sta_info_destroy_part2()
1491 cfg80211_del_sta_sinfo(sdata->dev, sta->sta.addr, sinfo, GFP_KERNEL); in __sta_info_destroy_part2()
1496 ieee80211_destroy_frag_cache(&sta->frags); in __sta_info_destroy_part2()
1520 mutex_lock(&sdata->local->sta_mtx); in sta_info_destroy_addr()
1523 mutex_unlock(&sdata->local->sta_mtx); in sta_info_destroy_addr()
1534 mutex_lock(&sdata->local->sta_mtx); in sta_info_destroy_addr_bss()
1537 mutex_unlock(&sdata->local->sta_mtx); in sta_info_destroy_addr_bss()
1549 list_for_each_entry_rcu(sta, &local->sta_list, list) in sta_info_cleanup()
1554 if (local->quiescing) in sta_info_cleanup()
1560 mod_timer(&local->sta_cleanup, in sta_info_cleanup()
1568 err = rhltable_init(&local->sta_hash, &sta_rht_params); in sta_info_init()
1572 err = rhltable_init(&local->link_sta_hash, &link_sta_rht_params); in sta_info_init()
1574 rhltable_destroy(&local->sta_hash); in sta_info_init()
1578 spin_lock_init(&local->tim_lock); in sta_info_init()
1579 mutex_init(&local->sta_mtx); in sta_info_init()
1580 INIT_LIST_HEAD(&local->sta_list); in sta_info_init()
1582 timer_setup(&local->sta_cleanup, sta_info_cleanup, 0); in sta_info_init()
1588 del_timer_sync(&local->sta_cleanup); in sta_info_stop()
1589 rhltable_destroy(&local->sta_hash); in sta_info_stop()
1590 rhltable_destroy(&local->link_sta_hash); in sta_info_stop()
1596 struct ieee80211_local *local = sdata->local; in __sta_info_flush()
1603 WARN_ON(vlans && sdata->vif.type != NL80211_IFTYPE_AP); in __sta_info_flush()
1604 WARN_ON(vlans && !sdata->bss); in __sta_info_flush()
1606 mutex_lock(&local->sta_mtx); in __sta_info_flush()
1607 list_for_each_entry_safe(sta, tmp, &local->sta_list, list) { in __sta_info_flush()
1608 if (sdata == sta->sdata || in __sta_info_flush()
1609 (vlans && sdata->bss == sta->sdata->bss)) { in __sta_info_flush()
1611 list_add(&sta->free_list, &free_list); in __sta_info_flush()
1621 if (!sta->sta.support_p2p_ps) in __sta_info_flush()
1626 ieee80211_recalc_min_chandef(sdata, -1); in __sta_info_flush()
1630 mutex_unlock(&local->sta_mtx); in __sta_info_flush()
1638 struct ieee80211_local *local = sdata->local; in ieee80211_sta_expire()
1641 mutex_lock(&local->sta_mtx); in ieee80211_sta_expire()
1643 list_for_each_entry_safe(sta, tmp, &local->sta_list, list) { in ieee80211_sta_expire()
1646 if (sdata != sta->sdata) in ieee80211_sta_expire()
1650 sta_dbg(sta->sdata, "expiring inactive STA %pM\n", in ieee80211_sta_expire()
1651 sta->sta.addr); in ieee80211_sta_expire()
1653 if (ieee80211_vif_is_mesh(&sdata->vif) && in ieee80211_sta_expire()
1655 atomic_dec(&sdata->u.mesh.ps.num_sta_ps); in ieee80211_sta_expire()
1661 mutex_unlock(&local->sta_mtx); in ieee80211_sta_expire()
1678 !ether_addr_equal(sta->sdata->vif.addr, localaddr)) in ieee80211_find_sta_by_ifaddr()
1680 if (!sta->uploaded) in ieee80211_find_sta_by_ifaddr()
1682 return &sta->sta; in ieee80211_find_sta_by_ifaddr()
1701 if (!sta->uploaded) in ieee80211_find_sta()
1704 return &sta->sta; in ieee80211_find_sta()
1711 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_sta_ps_deliver_wakeup()
1712 struct ieee80211_local *local = sdata->local; in ieee80211_sta_ps_deliver_wakeup()
1714 int filtered = 0, buffered = 0, ac, i; in ieee80211_sta_ps_deliver_wakeup() local
1718 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) in ieee80211_sta_ps_deliver_wakeup()
1719 sdata = container_of(sdata->bss, struct ieee80211_sub_if_data, in ieee80211_sta_ps_deliver_wakeup()
1722 if (sdata->vif.type == NL80211_IFTYPE_AP) in ieee80211_sta_ps_deliver_wakeup()
1723 ps = &sdata->bss->ps; in ieee80211_sta_ps_deliver_wakeup()
1724 else if (ieee80211_vif_is_mesh(&sdata->vif)) in ieee80211_sta_ps_deliver_wakeup()
1725 ps = &sdata->u.mesh.ps; in ieee80211_sta_ps_deliver_wakeup()
1732 sta->driver_buffered_tids = 0; in ieee80211_sta_ps_deliver_wakeup()
1733 sta->txq_buffered_tids = 0; in ieee80211_sta_ps_deliver_wakeup()
1735 if (!ieee80211_hw_check(&local->hw, AP_LINK_PS)) in ieee80211_sta_ps_deliver_wakeup()
1736 drv_sta_notify(local, sdata, STA_NOTIFY_AWAKE, &sta->sta); in ieee80211_sta_ps_deliver_wakeup()
1738 for (i = 0; i < ARRAY_SIZE(sta->sta.txq); i++) { in ieee80211_sta_ps_deliver_wakeup()
1739 if (!sta->sta.txq[i] || !txq_has_queue(sta->sta.txq[i])) in ieee80211_sta_ps_deliver_wakeup()
1742 schedule_and_wake_txq(local, to_txq_info(sta->sta.txq[i])); in ieee80211_sta_ps_deliver_wakeup()
1748 spin_lock_bh(&sta->ps_lock); in ieee80211_sta_ps_deliver_wakeup()
1750 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { in ieee80211_sta_ps_deliver_wakeup()
1753 spin_lock_irqsave(&sta->tx_filtered[ac].lock, flags); in ieee80211_sta_ps_deliver_wakeup()
1754 skb_queue_splice_tail_init(&sta->tx_filtered[ac], &pending); in ieee80211_sta_ps_deliver_wakeup()
1755 spin_unlock_irqrestore(&sta->tx_filtered[ac].lock, flags); in ieee80211_sta_ps_deliver_wakeup()
1757 filtered += tmp - count; in ieee80211_sta_ps_deliver_wakeup()
1760 spin_lock_irqsave(&sta->ps_tx_buf[ac].lock, flags); in ieee80211_sta_ps_deliver_wakeup()
1761 skb_queue_splice_tail_init(&sta->ps_tx_buf[ac], &pending); in ieee80211_sta_ps_deliver_wakeup()
1762 spin_unlock_irqrestore(&sta->ps_tx_buf[ac].lock, flags); in ieee80211_sta_ps_deliver_wakeup()
1764 buffered += tmp - count; in ieee80211_sta_ps_deliver_wakeup()
1777 spin_unlock_bh(&sta->ps_lock); in ieee80211_sta_ps_deliver_wakeup()
1779 atomic_dec(&ps->num_sta_ps); in ieee80211_sta_ps_deliver_wakeup()
1781 local->total_ps_buffered -= buffered; in ieee80211_sta_ps_deliver_wakeup()
1787 sta->sta.addr, sta->sta.aid, filtered, buffered); in ieee80211_sta_ps_deliver_wakeup()
1796 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_send_null_response()
1797 struct ieee80211_local *local = sdata->local; in ieee80211_send_null_response()
1802 bool qos = sta->sta.wme; in ieee80211_send_null_response()
1811 size -= 2; in ieee80211_send_null_response()
1817 skb = dev_alloc_skb(local->hw.extra_tx_headroom + size); in ieee80211_send_null_response()
1821 skb_reserve(skb, local->hw.extra_tx_headroom); in ieee80211_send_null_response()
1824 nullfunc->frame_control = fc; in ieee80211_send_null_response()
1825 nullfunc->duration_id = 0; in ieee80211_send_null_response()
1826 memcpy(nullfunc->addr1, sta->sta.addr, ETH_ALEN); in ieee80211_send_null_response()
1827 memcpy(nullfunc->addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_send_null_response()
1828 memcpy(nullfunc->addr3, sdata->vif.addr, ETH_ALEN); in ieee80211_send_null_response()
1829 nullfunc->seq_ctrl = 0; in ieee80211_send_null_response()
1831 skb->priority = tid; in ieee80211_send_null_response()
1834 nullfunc->qos_ctrl = cpu_to_le16(tid); in ieee80211_send_null_response()
1837 nullfunc->qos_ctrl |= in ieee80211_send_null_response()
1840 nullfunc->frame_control |= in ieee80211_send_null_response()
1853 info->flags |= IEEE80211_TX_CTL_NO_PS_BUFFER | in ieee80211_send_null_response()
1857 info->control.flags |= IEEE80211_TX_CTRL_PS_RESPONSE; in ieee80211_send_null_response()
1863 skb->dev = sdata->dev; in ieee80211_send_null_response()
1866 chanctx_conf = rcu_dereference(sdata->vif.bss_conf.chanctx_conf); in ieee80211_send_null_response()
1873 info->band = chanctx_conf->def.chan->band; in ieee80211_send_null_response()
1882 return fls(tids) - 1; in find_highest_prio_tid()
1886 return fls(tids) - 1; in find_highest_prio_tid()
1899 int ac; in ieee80211_sta_ps_more_data() local
1904 * only happen for PS-Poll. in ieee80211_sta_ps_more_data()
1910 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { in ieee80211_sta_ps_more_data()
1911 if (ignored_acs & ieee80211_ac_to_qos_mask[ac]) in ieee80211_sta_ps_more_data()
1914 if (!skb_queue_empty(&sta->tx_filtered[ac]) || in ieee80211_sta_ps_more_data()
1915 !skb_queue_empty(&sta->ps_tx_buf[ac])) in ieee80211_sta_ps_more_data()
1928 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_sta_ps_get_frames()
1929 struct ieee80211_local *local = sdata->local; in ieee80211_sta_ps_get_frames()
1930 int ac; in ieee80211_sta_ps_get_frames() local
1933 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { in ieee80211_sta_ps_get_frames()
1936 if (ignored_acs & ieee80211_ac_to_qos_mask[ac]) in ieee80211_sta_ps_get_frames()
1939 tids = ieee80211_tids_for_ac(ac); in ieee80211_sta_ps_get_frames()
1946 sta->driver_buffered_tids & tids; in ieee80211_sta_ps_get_frames()
1947 *driver_release_tids |= sta->txq_buffered_tids & tids; in ieee80211_sta_ps_get_frames()
1954 skb = skb_dequeue(&sta->tx_filtered[ac]); in ieee80211_sta_ps_get_frames()
1957 &sta->ps_tx_buf[ac]); in ieee80211_sta_ps_get_frames()
1959 local->total_ps_buffered--; in ieee80211_sta_ps_get_frames()
1963 n_frames--; in ieee80211_sta_ps_get_frames()
1968 /* If we have more frames buffered on this AC, then abort the in ieee80211_sta_ps_get_frames()
1972 if (!skb_queue_empty(&sta->tx_filtered[ac]) || in ieee80211_sta_ps_get_frames()
1973 !skb_queue_empty(&sta->ps_tx_buf[ac])) in ieee80211_sta_ps_get_frames()
1983 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_sta_ps_deliver_response()
1984 struct ieee80211_local *local = sdata->local; in ieee80211_sta_ps_deliver_response()
1989 /* Service or PS-Poll period starts */ in ieee80211_sta_ps_deliver_response()
2004 int tid, ac; in ieee80211_sta_ps_deliver_response() local
2007 * For PS-Poll, this can only happen due to a race condition in ieee80211_sta_ps_deliver_response()
2012 * At each unscheduled SP for a non-AP STA, the AP shall in ieee80211_sta_ps_deliver_response()
2015 * in the QoS Capability element from delivery-enabled ACs, in ieee80211_sta_ps_deliver_response()
2016 * that are destined for the non-AP STA. in ieee80211_sta_ps_deliver_response()
2022 for (ac = IEEE80211_AC_VO; ac < IEEE80211_NUM_ACS; ac++) in ieee80211_sta_ps_deliver_response()
2023 if (!(ignored_acs & ieee80211_ac_to_qos_mask[ac])) in ieee80211_sta_ps_deliver_response()
2025 tid = 7 - 2 * ac; in ieee80211_sta_ps_deliver_response()
2039 struct ieee80211_hdr *hdr = (void *) skb->data; in ieee80211_sta_ps_deliver_response()
2049 info->flags |= IEEE80211_TX_CTL_NO_PS_BUFFER; in ieee80211_sta_ps_deliver_response()
2050 info->control.flags |= IEEE80211_TX_CTRL_PS_RESPONSE; in ieee80211_sta_ps_deliver_response()
2057 hdr->frame_control |= in ieee80211_sta_ps_deliver_response()
2060 hdr->frame_control &= in ieee80211_sta_ps_deliver_response()
2063 if (ieee80211_is_data_qos(hdr->frame_control) || in ieee80211_sta_ps_deliver_response()
2064 ieee80211_is_qos_nullfunc(hdr->frame_control)) in ieee80211_sta_ps_deliver_response()
2067 tids |= BIT(skb->priority); in ieee80211_sta_ps_deliver_response()
2076 /* for PS-Poll, there's only one frame */ in ieee80211_sta_ps_deliver_response()
2077 info->flags |= IEEE80211_TX_STATUS_EOSP | in ieee80211_sta_ps_deliver_response()
2083 * last frame has a QoS header (i.e. is a QoS-data or in ieee80211_sta_ps_deliver_response()
2084 * QoS-nulldata frame) then just set the EOSP bit there in ieee80211_sta_ps_deliver_response()
2088 * the EOSP bit in the QoS header; add a QoS-nulldata in ieee80211_sta_ps_deliver_response()
2091 * Note that this code is only in the mac80211-release in ieee80211_sta_ps_deliver_response()
2093 * anything but QoS-data frames, or if it does, will in ieee80211_sta_ps_deliver_response()
2094 * create the QoS-nulldata frame by itself if needed. in ieee80211_sta_ps_deliver_response()
2096 * Cf. 802.11-2012 10.2.1.10 (c). in ieee80211_sta_ps_deliver_response()
2101 info->flags |= IEEE80211_TX_STATUS_EOSP | in ieee80211_sta_ps_deliver_response()
2105 * as it says the more-data bit should be set in ieee80211_sta_ps_deliver_response()
2106 * if there are more BUs. The QoS-Null frame in ieee80211_sta_ps_deliver_response()
2110 * expect more-data=0 when eosp=1. in ieee80211_sta_ps_deliver_response()
2112 hdr->frame_control |= in ieee80211_sta_ps_deliver_response()
2138 * on the TIDs we're releasing from - if there are more than in ieee80211_sta_ps_deliver_response()
2139 * n_frames it has to set the more-data bit (if we didn't ask in ieee80211_sta_ps_deliver_response()
2157 for (tid = 0; tid < ARRAY_SIZE(sta->sta.txq); tid++) { in ieee80211_sta_ps_deliver_response()
2158 if (!sta->sta.txq[tid] || in ieee80211_sta_ps_deliver_response()
2160 txq_has_queue(sta->sta.txq[tid])) in ieee80211_sta_ps_deliver_response()
2171 u8 ignore_for_response = sta->sta.uapsd_queues; in ieee80211_sta_ps_deliver_poll_response()
2174 * If all ACs are delivery-enabled then we should reply in ieee80211_sta_ps_deliver_poll_response()
2176 * only from the non-enabled ones. in ieee80211_sta_ps_deliver_poll_response()
2178 if (ignore_for_response == BIT(IEEE80211_NUM_ACS) - 1) in ieee80211_sta_ps_deliver_poll_response()
2187 int n_frames = sta->sta.max_sp; in ieee80211_sta_ps_deliver_uapsd()
2188 u8 delivery_enabled = sta->sta.uapsd_queues; in ieee80211_sta_ps_deliver_uapsd()
2199 switch (sta->sta.max_sp) { in ieee80211_sta_ps_deliver_uapsd()
2224 trace_api_sta_block_awake(sta->local, pubsta, block); in ieee80211_sta_block_awake()
2238 ieee80211_queue_work(hw, &sta->drv_deliver_wk); in ieee80211_sta_block_awake()
2243 ieee80211_queue_work(hw, &sta->drv_deliver_wk); in ieee80211_sta_block_awake()
2254 struct ieee80211_local *local = sta->local; in ieee80211_sta_eosp()
2268 trace_api_send_eosp_nullfunc(sta->local, pubsta, tid); in ieee80211_send_eosp_nullfunc()
2271 more_data = ieee80211_sta_ps_more_data(sta, ~sta->sta.uapsd_queues, in ieee80211_send_eosp_nullfunc()
2286 trace_api_sta_set_buffered(sta->local, pubsta, tid, buffered); in ieee80211_sta_set_buffered()
2289 set_bit(tid, &sta->driver_buffered_tids); in ieee80211_sta_set_buffered()
2291 clear_bit(tid, &sta->driver_buffered_tids); in ieee80211_sta_set_buffered()
2301 struct ieee80211_local *local = sta->sdata->local; in ieee80211_sta_register_airtime()
2302 u8 ac = ieee80211_ac_from_tid(tid); in ieee80211_sta_register_airtime() local
2306 if (sta->local->airtime_flags & AIRTIME_USE_TX) in ieee80211_sta_register_airtime()
2308 if (sta->local->airtime_flags & AIRTIME_USE_RX) in ieee80211_sta_register_airtime()
2311 spin_lock_bh(&local->active_txq_lock[ac]); in ieee80211_sta_register_airtime()
2312 sta->airtime[ac].tx_airtime += tx_airtime; in ieee80211_sta_register_airtime()
2313 sta->airtime[ac].rx_airtime += rx_airtime; in ieee80211_sta_register_airtime()
2315 diff = (u32)jiffies - sta->airtime[ac].last_active; in ieee80211_sta_register_airtime()
2317 sta->airtime[ac].deficit -= airtime; in ieee80211_sta_register_airtime()
2319 spin_unlock_bh(&local->active_txq_lock[ac]); in ieee80211_sta_register_airtime()
2328 if (!sta->sta.valid_links || !sta->sta.mlo) { in __ieee80211_sta_recalc_aggregates()
2329 sta->sta.cur = &sta->sta.deflink.agg; in __ieee80211_sta_recalc_aggregates()
2334 for (link_id = 0; link_id < ARRAY_SIZE((sta)->link); link_id++) { in __ieee80211_sta_recalc_aggregates()
2341 link_sta = rcu_dereference(sta->sta.link[link_id]); in __ieee80211_sta_recalc_aggregates()
2346 sta->cur = sta->sta.deflink.agg; in __ieee80211_sta_recalc_aggregates()
2351 sta->cur.max_amsdu_len = in __ieee80211_sta_recalc_aggregates()
2352 min(sta->cur.max_amsdu_len, in __ieee80211_sta_recalc_aggregates()
2353 link_sta->agg.max_amsdu_len); in __ieee80211_sta_recalc_aggregates()
2354 sta->cur.max_rc_amsdu_len = in __ieee80211_sta_recalc_aggregates()
2355 min(sta->cur.max_rc_amsdu_len, in __ieee80211_sta_recalc_aggregates()
2356 link_sta->agg.max_rc_amsdu_len); in __ieee80211_sta_recalc_aggregates()
2358 for (i = 0; i < ARRAY_SIZE(sta->cur.max_tid_amsdu_len); i++) in __ieee80211_sta_recalc_aggregates()
2359 sta->cur.max_tid_amsdu_len[i] = in __ieee80211_sta_recalc_aggregates()
2360 min(sta->cur.max_tid_amsdu_len[i], in __ieee80211_sta_recalc_aggregates()
2361 link_sta->agg.max_tid_amsdu_len[i]); in __ieee80211_sta_recalc_aggregates()
2365 sta->sta.cur = &sta->cur; in __ieee80211_sta_recalc_aggregates()
2372 __ieee80211_sta_recalc_aggregates(sta, sta->sdata->vif.active_links); in ieee80211_sta_recalc_aggregates()
2377 struct sta_info *sta, u8 ac, in ieee80211_sta_update_pending_airtime() argument
2382 if (!wiphy_ext_feature_isset(local->hw.wiphy, NL80211_EXT_FEATURE_AQL)) in ieee80211_sta_update_pending_airtime()
2388 &sta->airtime[ac].aql_tx_pending); in ieee80211_sta_update_pending_airtime()
2390 atomic_add(tx_airtime, &local->aql_total_pending_airtime); in ieee80211_sta_update_pending_airtime()
2391 atomic_add(tx_airtime, &local->aql_ac_pending_airtime[ac]); in ieee80211_sta_update_pending_airtime()
2397 &sta->airtime[ac].aql_tx_pending); in ieee80211_sta_update_pending_airtime()
2399 atomic_cmpxchg(&sta->airtime[ac].aql_tx_pending, in ieee80211_sta_update_pending_airtime()
2403 atomic_sub(tx_airtime, &local->aql_total_pending_airtime); in ieee80211_sta_update_pending_airtime()
2405 &local->aql_ac_pending_airtime[ac]); in ieee80211_sta_update_pending_airtime()
2407 "Device %s AC %d pending airtime underflow: %u, %u", in ieee80211_sta_update_pending_airtime()
2408 wiphy_name(local->hw.wiphy), ac, tx_pending, in ieee80211_sta_update_pending_airtime()
2410 atomic_cmpxchg(&local->aql_ac_pending_airtime[ac], in ieee80211_sta_update_pending_airtime()
2412 atomic_sub(tx_pending, &local->aql_total_pending_airtime); in ieee80211_sta_update_pending_airtime()
2419 struct ieee80211_sta_rx_stats *stats = &sta->deflink.rx_stats; in sta_get_last_rx_stats()
2422 if (!sta->deflink.pcpu_rx_stats) in sta_get_last_rx_stats()
2428 cpustats = per_cpu_ptr(sta->deflink.pcpu_rx_stats, cpu); in sta_get_last_rx_stats()
2430 if (time_after(cpustats->last_rx, stats->last_rx)) in sta_get_last_rx_stats()
2440 rinfo->bw = STA_STATS_GET(BW, rate); in sta_stats_decode_rate()
2444 rinfo->flags = RATE_INFO_FLAGS_VHT_MCS; in sta_stats_decode_rate()
2445 rinfo->mcs = STA_STATS_GET(VHT_MCS, rate); in sta_stats_decode_rate()
2446 rinfo->nss = STA_STATS_GET(VHT_NSS, rate); in sta_stats_decode_rate()
2448 rinfo->flags |= RATE_INFO_FLAGS_SHORT_GI; in sta_stats_decode_rate()
2451 rinfo->flags = RATE_INFO_FLAGS_MCS; in sta_stats_decode_rate()
2452 rinfo->mcs = STA_STATS_GET(HT_MCS, rate); in sta_stats_decode_rate()
2454 rinfo->flags |= RATE_INFO_FLAGS_SHORT_GI; in sta_stats_decode_rate()
2463 sband = local->hw.wiphy->bands[band]; in sta_stats_decode_rate()
2465 if (WARN_ON_ONCE(!sband->bitrates)) in sta_stats_decode_rate()
2468 brate = sband->bitrates[rate_idx].bitrate; in sta_stats_decode_rate()
2469 if (rinfo->bw == RATE_INFO_BW_5) in sta_stats_decode_rate()
2471 else if (rinfo->bw == RATE_INFO_BW_10) in sta_stats_decode_rate()
2475 rinfo->legacy = DIV_ROUND_UP(brate, 1 << shift); in sta_stats_decode_rate()
2479 rinfo->flags = RATE_INFO_FLAGS_HE_MCS; in sta_stats_decode_rate()
2480 rinfo->mcs = STA_STATS_GET(HE_MCS, rate); in sta_stats_decode_rate()
2481 rinfo->nss = STA_STATS_GET(HE_NSS, rate); in sta_stats_decode_rate()
2482 rinfo->he_gi = STA_STATS_GET(HE_GI, rate); in sta_stats_decode_rate()
2483 rinfo->he_ru_alloc = STA_STATS_GET(HE_RU, rate); in sta_stats_decode_rate()
2484 rinfo->he_dcm = STA_STATS_GET(HE_DCM, rate); in sta_stats_decode_rate()
2487 rinfo->flags = RATE_INFO_FLAGS_EHT_MCS; in sta_stats_decode_rate()
2488 rinfo->mcs = STA_STATS_GET(EHT_MCS, rate); in sta_stats_decode_rate()
2489 rinfo->nss = STA_STATS_GET(EHT_NSS, rate); in sta_stats_decode_rate()
2490 rinfo->eht_gi = STA_STATS_GET(EHT_GI, rate); in sta_stats_decode_rate()
2491 rinfo->eht_ru_alloc = STA_STATS_GET(EHT_RU, rate); in sta_stats_decode_rate()
2498 u32 rate = READ_ONCE(sta_get_last_rx_stats(sta)->last_rate); in sta_set_rate_info_rx()
2501 return -EINVAL; in sta_set_rate_info_rx()
2503 sta_stats_decode_rate(sta->local, rate, rinfo); in sta_set_rate_info_rx()
2514 start = u64_stats_fetch_begin(&rxstats->syncp); in sta_get_tidstats_msdu()
2515 value = rxstats->msdu[tid]; in sta_get_tidstats_msdu()
2516 } while (u64_stats_fetch_retry(&rxstats->syncp, start)); in sta_get_tidstats_msdu()
2525 struct ieee80211_local *local = sta->local; in sta_set_tidstats()
2528 if (!(tidstats->filled & BIT(NL80211_TID_STATS_RX_MSDU))) { in sta_set_tidstats()
2529 tidstats->rx_msdu += sta_get_tidstats_msdu(&sta->deflink.rx_stats, in sta_set_tidstats()
2532 if (sta->deflink.pcpu_rx_stats) { in sta_set_tidstats()
2536 cpurxs = per_cpu_ptr(sta->deflink.pcpu_rx_stats, in sta_set_tidstats()
2538 tidstats->rx_msdu += in sta_set_tidstats()
2543 tidstats->filled |= BIT(NL80211_TID_STATS_RX_MSDU); in sta_set_tidstats()
2546 if (!(tidstats->filled & BIT(NL80211_TID_STATS_TX_MSDU))) { in sta_set_tidstats()
2547 tidstats->filled |= BIT(NL80211_TID_STATS_TX_MSDU); in sta_set_tidstats()
2548 tidstats->tx_msdu = sta->deflink.tx_stats.msdu[tid]; in sta_set_tidstats()
2551 if (!(tidstats->filled & BIT(NL80211_TID_STATS_TX_MSDU_RETRIES)) && in sta_set_tidstats()
2552 ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) { in sta_set_tidstats()
2553 tidstats->filled |= BIT(NL80211_TID_STATS_TX_MSDU_RETRIES); in sta_set_tidstats()
2554 tidstats->tx_msdu_retries = sta->deflink.status_stats.msdu_retries[tid]; in sta_set_tidstats()
2557 if (!(tidstats->filled & BIT(NL80211_TID_STATS_TX_MSDU_FAILED)) && in sta_set_tidstats()
2558 ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) { in sta_set_tidstats()
2559 tidstats->filled |= BIT(NL80211_TID_STATS_TX_MSDU_FAILED); in sta_set_tidstats()
2560 tidstats->tx_msdu_failed = sta->deflink.status_stats.msdu_failed[tid]; in sta_set_tidstats()
2564 spin_lock_bh(&local->fq.lock); in sta_set_tidstats()
2567 tidstats->filled |= BIT(NL80211_TID_STATS_TXQ_STATS); in sta_set_tidstats()
2568 ieee80211_fill_txq_stats(&tidstats->txq_stats, in sta_set_tidstats()
2569 to_txq_info(sta->sta.txq[tid])); in sta_set_tidstats()
2572 spin_unlock_bh(&local->fq.lock); in sta_set_tidstats()
2582 start = u64_stats_fetch_begin(&rxstats->syncp); in sta_get_stats_bytes()
2583 value = rxstats->bytes; in sta_get_stats_bytes()
2584 } while (u64_stats_fetch_retry(&rxstats->syncp, start)); in sta_get_stats_bytes()
2592 struct ieee80211_sub_if_data *sdata = sta->sdata; in sta_set_sinfo()
2593 struct ieee80211_local *local = sdata->local; in sta_set_sinfo()
2595 int i, ac, cpu; in sta_set_sinfo() local
2600 sinfo->generation = sdata->local->sta_generation; in sta_set_sinfo()
2606 if (sdata->vif.type == NL80211_IFTYPE_STATION) in sta_set_sinfo()
2607 sinfo->rx_beacon = sdata->deflink.u.mgd.count_beacon_signal; in sta_set_sinfo()
2609 drv_sta_statistics(local, sdata, &sta->sta, sinfo); in sta_set_sinfo()
2610 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_INACTIVE_TIME) | in sta_set_sinfo()
2617 if (sdata->vif.type == NL80211_IFTYPE_STATION) { in sta_set_sinfo()
2618 sinfo->beacon_loss_count = in sta_set_sinfo()
2619 sdata->deflink.u.mgd.beacon_loss_count; in sta_set_sinfo()
2620 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_BEACON_LOSS); in sta_set_sinfo()
2623 sinfo->connected_time = ktime_get_seconds() - sta->last_connected; in sta_set_sinfo()
2624 sinfo->assoc_at = sta->assoc_at; in sta_set_sinfo()
2625 sinfo->inactive_time = in sta_set_sinfo()
2626 jiffies_to_msecs(jiffies - ieee80211_sta_last_active(sta)); in sta_set_sinfo()
2628 if (!(sinfo->filled & (BIT_ULL(NL80211_STA_INFO_TX_BYTES64) | in sta_set_sinfo()
2630 sinfo->tx_bytes = 0; in sta_set_sinfo()
2631 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) in sta_set_sinfo()
2632 sinfo->tx_bytes += sta->deflink.tx_stats.bytes[ac]; in sta_set_sinfo()
2633 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BYTES64); in sta_set_sinfo()
2636 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_TX_PACKETS))) { in sta_set_sinfo()
2637 sinfo->tx_packets = 0; in sta_set_sinfo()
2638 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) in sta_set_sinfo()
2639 sinfo->tx_packets += sta->deflink.tx_stats.packets[ac]; in sta_set_sinfo()
2640 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_PACKETS); in sta_set_sinfo()
2643 if (!(sinfo->filled & (BIT_ULL(NL80211_STA_INFO_RX_BYTES64) | in sta_set_sinfo()
2645 sinfo->rx_bytes += sta_get_stats_bytes(&sta->deflink.rx_stats); in sta_set_sinfo()
2647 if (sta->deflink.pcpu_rx_stats) { in sta_set_sinfo()
2651 cpurxs = per_cpu_ptr(sta->deflink.pcpu_rx_stats, in sta_set_sinfo()
2653 sinfo->rx_bytes += sta_get_stats_bytes(cpurxs); in sta_set_sinfo()
2657 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_BYTES64); in sta_set_sinfo()
2660 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_RX_PACKETS))) { in sta_set_sinfo()
2661 sinfo->rx_packets = sta->deflink.rx_stats.packets; in sta_set_sinfo()
2662 if (sta->deflink.pcpu_rx_stats) { in sta_set_sinfo()
2666 cpurxs = per_cpu_ptr(sta->deflink.pcpu_rx_stats, in sta_set_sinfo()
2668 sinfo->rx_packets += cpurxs->packets; in sta_set_sinfo()
2671 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_PACKETS); in sta_set_sinfo()
2674 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_TX_RETRIES))) { in sta_set_sinfo()
2675 sinfo->tx_retries = sta->deflink.status_stats.retry_count; in sta_set_sinfo()
2676 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_RETRIES); in sta_set_sinfo()
2679 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_TX_FAILED))) { in sta_set_sinfo()
2680 sinfo->tx_failed = sta->deflink.status_stats.retry_failed; in sta_set_sinfo()
2681 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_FAILED); in sta_set_sinfo()
2684 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_RX_DURATION))) { in sta_set_sinfo()
2685 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) in sta_set_sinfo()
2686 sinfo->rx_duration += sta->airtime[ac].rx_airtime; in sta_set_sinfo()
2687 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_DURATION); in sta_set_sinfo()
2690 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_TX_DURATION))) { in sta_set_sinfo()
2691 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) in sta_set_sinfo()
2692 sinfo->tx_duration += sta->airtime[ac].tx_airtime; in sta_set_sinfo()
2693 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_DURATION); in sta_set_sinfo()
2696 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_AIRTIME_WEIGHT))) { in sta_set_sinfo()
2697 sinfo->airtime_weight = sta->airtime_weight; in sta_set_sinfo()
2698 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_AIRTIME_WEIGHT); in sta_set_sinfo()
2701 sinfo->rx_dropped_misc = sta->deflink.rx_stats.dropped; in sta_set_sinfo()
2702 if (sta->deflink.pcpu_rx_stats) { in sta_set_sinfo()
2706 cpurxs = per_cpu_ptr(sta->deflink.pcpu_rx_stats, cpu); in sta_set_sinfo()
2707 sinfo->rx_dropped_misc += cpurxs->dropped; in sta_set_sinfo()
2711 if (sdata->vif.type == NL80211_IFTYPE_STATION && in sta_set_sinfo()
2712 !(sdata->vif.driver_flags & IEEE80211_VIF_BEACON_FILTER)) { in sta_set_sinfo()
2713 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_BEACON_RX) | in sta_set_sinfo()
2715 sinfo->rx_beacon_signal_avg = ieee80211_ave_rssi(&sdata->vif); in sta_set_sinfo()
2718 if (ieee80211_hw_check(&sta->local->hw, SIGNAL_DBM) || in sta_set_sinfo()
2719 ieee80211_hw_check(&sta->local->hw, SIGNAL_UNSPEC)) { in sta_set_sinfo()
2720 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_SIGNAL))) { in sta_set_sinfo()
2721 sinfo->signal = (s8)last_rxstats->last_signal; in sta_set_sinfo()
2722 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL); in sta_set_sinfo()
2725 if (!sta->deflink.pcpu_rx_stats && in sta_set_sinfo()
2726 !(sinfo->filled & BIT_ULL(NL80211_STA_INFO_SIGNAL_AVG))) { in sta_set_sinfo()
2727 sinfo->signal_avg = in sta_set_sinfo()
2728 -ewma_signal_read(&sta->deflink.rx_stats_avg.signal); in sta_set_sinfo()
2729 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL_AVG); in sta_set_sinfo()
2733 /* for the average - if pcpu_rx_stats isn't set - rxstats must point to in sta_set_sinfo()
2734 * the sta->rx_stats struct, so the check here is fine with and without in sta_set_sinfo()
2737 if (last_rxstats->chains && in sta_set_sinfo()
2738 !(sinfo->filled & (BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL) | in sta_set_sinfo()
2740 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL); in sta_set_sinfo()
2741 if (!sta->deflink.pcpu_rx_stats) in sta_set_sinfo()
2742 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL_AVG); in sta_set_sinfo()
2744 sinfo->chains = last_rxstats->chains; in sta_set_sinfo()
2746 for (i = 0; i < ARRAY_SIZE(sinfo->chain_signal); i++) { in sta_set_sinfo()
2747 sinfo->chain_signal[i] = in sta_set_sinfo()
2748 last_rxstats->chain_signal_last[i]; in sta_set_sinfo()
2749 sinfo->chain_signal_avg[i] = in sta_set_sinfo()
2750 -ewma_signal_read(&sta->deflink.rx_stats_avg.chain_signal[i]); in sta_set_sinfo()
2754 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_TX_BITRATE)) && in sta_set_sinfo()
2755 !sta->sta.valid_links) { in sta_set_sinfo()
2756 sta_set_rate_info_tx(sta, &sta->deflink.tx_stats.last_rate, in sta_set_sinfo()
2757 &sinfo->txrate); in sta_set_sinfo()
2758 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BITRATE); in sta_set_sinfo()
2761 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_RX_BITRATE)) && in sta_set_sinfo()
2762 !sta->sta.valid_links) { in sta_set_sinfo()
2763 if (sta_set_rate_info_rx(sta, &sinfo->rxrate) == 0) in sta_set_sinfo()
2764 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_BITRATE); in sta_set_sinfo()
2769 sta_set_tidstats(sta, &sinfo->pertid[i], i); in sta_set_sinfo()
2772 if (ieee80211_vif_is_mesh(&sdata->vif)) { in sta_set_sinfo()
2774 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_LLID) | in sta_set_sinfo()
2783 sinfo->llid = sta->mesh->llid; in sta_set_sinfo()
2784 sinfo->plid = sta->mesh->plid; in sta_set_sinfo()
2785 sinfo->plink_state = sta->mesh->plink_state; in sta_set_sinfo()
2787 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_T_OFFSET); in sta_set_sinfo()
2788 sinfo->t_offset = sta->mesh->t_offset; in sta_set_sinfo()
2790 sinfo->local_pm = sta->mesh->local_pm; in sta_set_sinfo()
2791 sinfo->peer_pm = sta->mesh->peer_pm; in sta_set_sinfo()
2792 sinfo->nonpeer_pm = sta->mesh->nonpeer_pm; in sta_set_sinfo()
2793 sinfo->connected_to_gate = sta->mesh->connected_to_gate; in sta_set_sinfo()
2794 sinfo->connected_to_as = sta->mesh->connected_to_as; in sta_set_sinfo()
2798 sinfo->bss_param.flags = 0; in sta_set_sinfo()
2799 if (sdata->vif.bss_conf.use_cts_prot) in sta_set_sinfo()
2800 sinfo->bss_param.flags |= BSS_PARAM_FLAGS_CTS_PROT; in sta_set_sinfo()
2801 if (sdata->vif.bss_conf.use_short_preamble) in sta_set_sinfo()
2802 sinfo->bss_param.flags |= BSS_PARAM_FLAGS_SHORT_PREAMBLE; in sta_set_sinfo()
2803 if (sdata->vif.bss_conf.use_short_slot) in sta_set_sinfo()
2804 sinfo->bss_param.flags |= BSS_PARAM_FLAGS_SHORT_SLOT_TIME; in sta_set_sinfo()
2805 sinfo->bss_param.dtim_period = sdata->vif.bss_conf.dtim_period; in sta_set_sinfo()
2806 sinfo->bss_param.beacon_interval = sdata->vif.bss_conf.beacon_int; in sta_set_sinfo()
2808 sinfo->sta_flags.set = 0; in sta_set_sinfo()
2809 sinfo->sta_flags.mask = BIT(NL80211_STA_FLAG_AUTHORIZED) | in sta_set_sinfo()
2817 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_AUTHORIZED); in sta_set_sinfo()
2819 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_SHORT_PREAMBLE); in sta_set_sinfo()
2820 if (sta->sta.wme) in sta_set_sinfo()
2821 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_WME); in sta_set_sinfo()
2823 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_MFP); in sta_set_sinfo()
2825 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_AUTHENTICATED); in sta_set_sinfo()
2827 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_ASSOCIATED); in sta_set_sinfo()
2829 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_TDLS_PEER); in sta_set_sinfo()
2834 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_EXPECTED_THROUGHPUT); in sta_set_sinfo()
2835 sinfo->expected_throughput = thr; in sta_set_sinfo()
2838 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_ACK_SIGNAL)) && in sta_set_sinfo()
2839 sta->deflink.status_stats.ack_signal_filled) { in sta_set_sinfo()
2840 sinfo->ack_signal = sta->deflink.status_stats.last_ack_signal; in sta_set_sinfo()
2841 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_ACK_SIGNAL); in sta_set_sinfo()
2844 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_ACK_SIGNAL_AVG)) && in sta_set_sinfo()
2845 sta->deflink.status_stats.ack_signal_filled) { in sta_set_sinfo()
2846 sinfo->avg_ack_signal = in sta_set_sinfo()
2847 -(s8)ewma_avg_signal_read( in sta_set_sinfo()
2848 &sta->deflink.status_stats.avg_ack_signal); in sta_set_sinfo()
2849 sinfo->filled |= in sta_set_sinfo()
2853 if (ieee80211_vif_is_mesh(&sdata->vif)) { in sta_set_sinfo()
2854 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_AIRTIME_LINK_METRIC); in sta_set_sinfo()
2855 sinfo->airtime_link_metric = in sta_set_sinfo()
2862 struct ieee80211_sub_if_data *sdata = sta->sdata; in sta_get_expected_throughput()
2863 struct ieee80211_local *local = sdata->local; in sta_get_expected_throughput()
2868 ref = local->rate_ctrl; in sta_get_expected_throughput()
2871 if (ref && ref->ops->get_expected_throughput) in sta_get_expected_throughput()
2872 thr = ref->ops->get_expected_throughput(sta->rate_ctrl_priv); in sta_get_expected_throughput()
2883 if (!sta->deflink.status_stats.last_ack || in ieee80211_sta_last_active()
2884 time_after(stats->last_rx, sta->deflink.status_stats.last_ack)) in ieee80211_sta_last_active()
2885 return stats->last_rx; in ieee80211_sta_last_active()
2886 return sta->deflink.status_stats.last_ack; in ieee80211_sta_last_active()
2891 if (thr && thr < STA_SLOW_THRESHOLD * sta->local->num_sta) { in sta_update_codel_params()
2892 sta->cparams.target = MS2TIME(50); in sta_update_codel_params()
2893 sta->cparams.interval = MS2TIME(300); in sta_update_codel_params()
2894 sta->cparams.ecn = false; in sta_update_codel_params()
2896 sta->cparams.target = MS2TIME(20); in sta_update_codel_params()
2897 sta->cparams.interval = MS2TIME(100); in sta_update_codel_params()
2898 sta->cparams.ecn = true; in sta_update_codel_params()
2912 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_sta_allocate_link()
2916 lockdep_assert_held(&sdata->local->sta_mtx); in ieee80211_sta_allocate_link()
2919 if (WARN_ON(!sta->sta.valid_links)) in ieee80211_sta_allocate_link()
2920 return -EINVAL; in ieee80211_sta_allocate_link()
2922 if (WARN_ON(sta->sta.valid_links & BIT(link_id) || in ieee80211_sta_allocate_link()
2923 sta->link[link_id])) in ieee80211_sta_allocate_link()
2924 return -EBUSY; in ieee80211_sta_allocate_link()
2928 return -ENOMEM; in ieee80211_sta_allocate_link()
2930 ret = sta_info_alloc_link(sdata->local, &alloc->info, GFP_KERNEL); in ieee80211_sta_allocate_link()
2936 sta_info_add_link(sta, link_id, &alloc->info, &alloc->sta); in ieee80211_sta_allocate_link()
2938 ieee80211_link_sta_debugfs_add(&alloc->info); in ieee80211_sta_allocate_link()
2945 lockdep_assert_held(&sta->sdata->local->sta_mtx); in ieee80211_sta_free_link()
2952 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_sta_activate_link()
2954 u16 old_links = sta->sta.valid_links; in ieee80211_sta_activate_link()
2958 link_sta = rcu_dereference_protected(sta->link[link_id], in ieee80211_sta_activate_link()
2959 lockdep_is_held(&sdata->local->sta_mtx)); in ieee80211_sta_activate_link()
2962 return -EINVAL; in ieee80211_sta_activate_link()
2965 if (link_sta_info_hash_lookup(sdata->local, link_sta->addr)) { in ieee80211_sta_activate_link()
2967 return -EALREADY; in ieee80211_sta_activate_link()
2972 sta->sta.valid_links = new_links; in ieee80211_sta_activate_link()
2982 ieee80211_sta_recalc_aggregates(&sta->sta); in ieee80211_sta_activate_link()
2984 ret = drv_change_sta_links(sdata->local, sdata, &sta->sta, in ieee80211_sta_activate_link()
2987 sta->sta.valid_links = old_links; in ieee80211_sta_activate_link()
2993 ret = link_sta_info_hash_add(sdata->local, link_sta); in ieee80211_sta_activate_link()
3000 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_sta_remove_link()
3001 u16 old_links = sta->sta.valid_links; in ieee80211_sta_remove_link()
3003 lockdep_assert_held(&sdata->local->sta_mtx); in ieee80211_sta_remove_link()
3005 sta->sta.valid_links &= ~BIT(link_id); in ieee80211_sta_remove_link()
3008 drv_change_sta_links(sdata->local, sdata, &sta->sta, in ieee80211_sta_remove_link()
3009 old_links, sta->sta.valid_links); in ieee80211_sta_remove_link()
3020 sta->sta.max_amsdu_subframes = 0; in ieee80211_sta_set_max_amsdu_subframes()
3034 sta->sta.max_amsdu_subframes = 4 << (4 - val); in ieee80211_sta_set_max_amsdu_subframes()
3042 return lockdep_is_held(&sta->local->sta_mtx); in lockdep_sta_mutex_held()