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-2021 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 if (sta->sta.txq[0]) { in __cleanup_single_sta()
144 for (i = 0; i < ARRAY_SIZE(sta->sta.txq); i++) { in __cleanup_single_sta()
147 if (!sta->sta.txq[i]) in __cleanup_single_sta()
150 txqi = to_txq_info(sta->sta.txq[i]); in __cleanup_single_sta()
156 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { in __cleanup_single_sta()
157 local->total_ps_buffered -= skb_queue_len(&sta->ps_tx_buf[ac]); in __cleanup_single_sta()
158 ieee80211_purge_tx_queue(&local->hw, &sta->ps_tx_buf[ac]); in __cleanup_single_sta()
159 ieee80211_purge_tx_queue(&local->hw, &sta->tx_filtered[ac]); in __cleanup_single_sta()
162 if (ieee80211_vif_is_mesh(&sdata->vif)) in __cleanup_single_sta()
165 cancel_work_sync(&sta->drv_deliver_wk); in __cleanup_single_sta()
174 kfree(sta->ampdu_mlme.tid_start_tx[i]); in __cleanup_single_sta()
175 tid_tx = rcu_dereference_raw(sta->ampdu_mlme.tid_tx[i]); in __cleanup_single_sta()
178 ieee80211_purge_tx_queue(&local->hw, &tid_tx->pending); in __cleanup_single_sta()
185 struct ieee80211_sub_if_data *sdata = sta->sdata; in cleanup_single_sta()
186 struct ieee80211_local *local = sdata->local; in cleanup_single_sta()
195 return rhltable_lookup(&local->sta_hash, addr, sta_rht_params); in sta_info_hash_lookup()
202 struct ieee80211_local *local = sdata->local; in sta_info_get()
208 if (sta->sdata == sdata) { in sta_info_get()
227 struct ieee80211_local *local = sdata->local; in sta_info_get_bss()
233 if (sta->sdata == sdata || in sta_info_get_bss()
234 (sta->sdata->bss && sta->sdata->bss == sdata->bss)) { in sta_info_get_bss()
249 return rhltable_lookup(&local->link_sta_hash, addr, in link_sta_info_hash_lookup()
256 struct ieee80211_local *local = sdata->local; in link_sta_info_get_bss()
262 struct sta_info *sta = link_sta->sta; in link_sta_info_get_bss()
264 if (sta->sdata == sdata || in link_sta_info_get_bss()
265 (sta->sdata->bss && sta->sdata->bss == sdata->bss)) { in link_sta_info_get_bss()
288 struct sta_info *sta = link_sta->sta; in ieee80211_find_sta_by_link_addrs()
289 struct ieee80211_link_data *link; in ieee80211_find_sta_by_link_addrs() local
290 u8 _link_id = link_sta->link_id; in ieee80211_find_sta_by_link_addrs()
295 return &sta->sta; in ieee80211_find_sta_by_link_addrs()
298 link = rcu_dereference(sta->sdata->link[_link_id]); in ieee80211_find_sta_by_link_addrs()
299 if (!link) in ieee80211_find_sta_by_link_addrs()
302 if (memcmp(link->conf->addr, localaddr, ETH_ALEN)) in ieee80211_find_sta_by_link_addrs()
307 return &sta->sta; in ieee80211_find_sta_by_link_addrs()
321 if (ether_addr_equal(vif_addr, sta->sdata->vif.addr)) in sta_info_get_by_addrs()
331 struct ieee80211_local *local = sdata->local; in sta_info_get_by_idx()
335 list_for_each_entry_rcu(sta, &local->sta_list, list, in sta_info_get_by_idx()
336 lockdep_is_held(&local->sta_mtx)) { in sta_info_get_by_idx()
337 if (sdata != sta->sdata) in sta_info_get_by_idx()
351 free_percpu(link_sta->pcpu_rx_stats); in sta_info_free_link()
360 link_sta = rcu_dereference_protected(sta->link[link_id], in sta_remove_link()
361 lockdep_is_held(&sta->local->sta_mtx)); in sta_remove_link()
367 link_sta_info_hash_del(sta->local, link_sta); in sta_remove_link()
369 if (link_sta != &sta->deflink) in sta_remove_link()
372 sta->sta.valid_links &= ~BIT(link_id); in sta_remove_link()
373 RCU_INIT_POINTER(sta->link[link_id], NULL); in sta_remove_link()
374 RCU_INIT_POINTER(sta->sta.link[link_id], NULL); in sta_remove_link()
376 sta_info_free_link(&alloc->info); in sta_remove_link()
380 ieee80211_sta_recalc_aggregates(&sta->sta); in sta_remove_link()
384 * sta_info_free - free STA
398 for (i = 0; i < ARRAY_SIZE(sta->link); i++) { in sta_info_free()
399 if (!(sta->sta.valid_links & BIT(i))) in sta_info_free()
413 while (sta->sta_state > IEEE80211_STA_NONE) { in sta_info_free()
418 ret = sta_info_move_state(sta, sta->sta_state - 1); in sta_info_free()
423 if (sta->rate_ctrl) in sta_info_free()
426 sta_dbg(sta->sdata, "Destroyed STA %pM\n", sta->sta.addr); in sta_info_free()
428 if (sta->sta.txq[0]) in sta_info_free()
429 kfree(to_txq_info(sta->sta.txq[0])); in sta_info_free()
430 kfree(rcu_dereference_raw(sta->sta.rates)); in sta_info_free()
432 kfree(sta->mesh); in sta_info_free()
435 sta_info_free_link(&sta->deflink); in sta_info_free()
439 /* Caller must hold local->sta_mtx */
443 return rhltable_insert(&local->sta_hash, &sta->hash_node, in sta_info_hash_add()
453 if (sta->dead) in sta_deliver_ps_frames()
469 if (ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL)) in sta_prepare_rate_control()
472 sta->rate_ctrl = local->rate_ctrl; in sta_prepare_rate_control()
473 sta->rate_ctrl_priv = rate_control_alloc_sta(sta->rate_ctrl, in sta_prepare_rate_control()
475 if (!sta->rate_ctrl_priv) in sta_prepare_rate_control()
476 return -ENOMEM; in sta_prepare_rate_control()
485 struct ieee80211_hw *hw = &local->hw; in sta_info_alloc_link()
489 link_info->pcpu_rx_stats = in sta_info_alloc_link()
491 if (!link_info->pcpu_rx_stats) in sta_info_alloc_link()
492 return -ENOMEM; in sta_info_alloc_link()
495 link_info->rx_stats.last_rx = jiffies; in sta_info_alloc_link()
496 u64_stats_init(&link_info->rx_stats.syncp); in sta_info_alloc_link()
498 ewma_signal_init(&link_info->rx_stats_avg.signal); in sta_info_alloc_link()
499 ewma_avg_signal_init(&link_info->status_stats.avg_ack_signal); in sta_info_alloc_link()
500 for (i = 0; i < ARRAY_SIZE(link_info->rx_stats_avg.chain_signal); i++) in sta_info_alloc_link()
501 ewma_signal_init(&link_info->rx_stats_avg.chain_signal[i]); in sta_info_alloc_link()
511 link_info->sta = sta; in sta_info_add_link()
512 link_info->link_id = link_id; in sta_info_add_link()
513 link_info->pub = link_sta; in sta_info_add_link()
514 link_sta->link_id = link_id; in sta_info_add_link()
515 rcu_assign_pointer(sta->link[link_id], link_info); in sta_info_add_link()
516 rcu_assign_pointer(sta->sta.link[link_id], link_sta); in sta_info_add_link()
518 link_sta->smps_mode = IEEE80211_SMPS_OFF; in sta_info_add_link()
519 link_sta->agg.max_rc_amsdu_len = IEEE80211_MAX_MPDU_LEN_HT_BA; in sta_info_add_link()
527 struct ieee80211_local *local = sdata->local; in __sta_info_alloc()
528 struct ieee80211_hw *hw = &local->hw; in __sta_info_alloc()
532 sta = kzalloc(sizeof(*sta) + hw->sta_data_size, gfp); in __sta_info_alloc()
536 sta->local = local; in __sta_info_alloc()
537 sta->sdata = sdata; in __sta_info_alloc()
539 if (sta_info_alloc_link(local, &sta->deflink, gfp)) in __sta_info_alloc()
543 sta_info_add_link(sta, link_id, &sta->deflink, in __sta_info_alloc()
544 &sta->sta.deflink); in __sta_info_alloc()
545 sta->sta.valid_links = BIT(link_id); in __sta_info_alloc()
547 sta_info_add_link(sta, 0, &sta->deflink, &sta->sta.deflink); in __sta_info_alloc()
550 sta->sta.cur = &sta->sta.deflink.agg; in __sta_info_alloc()
552 spin_lock_init(&sta->lock); in __sta_info_alloc()
553 spin_lock_init(&sta->ps_lock); in __sta_info_alloc()
554 INIT_WORK(&sta->drv_deliver_wk, sta_deliver_ps_frames); in __sta_info_alloc()
555 INIT_WORK(&sta->ampdu_mlme.work, ieee80211_ba_session_work); in __sta_info_alloc()
556 mutex_init(&sta->ampdu_mlme.mtx); in __sta_info_alloc()
558 if (ieee80211_vif_is_mesh(&sdata->vif)) { in __sta_info_alloc()
559 sta->mesh = kzalloc(sizeof(*sta->mesh), gfp); in __sta_info_alloc()
560 if (!sta->mesh) in __sta_info_alloc()
562 sta->mesh->plink_sta = sta; in __sta_info_alloc()
563 spin_lock_init(&sta->mesh->plink_lock); in __sta_info_alloc()
564 if (!sdata->u.mesh.user_mpm) in __sta_info_alloc()
565 timer_setup(&sta->mesh->plink_timer, mesh_plink_timer, in __sta_info_alloc()
567 sta->mesh->nonpeer_pm = NL80211_MESH_POWER_ACTIVE; in __sta_info_alloc()
571 memcpy(sta->addr, addr, ETH_ALEN); in __sta_info_alloc()
572 memcpy(sta->sta.addr, addr, ETH_ALEN); in __sta_info_alloc()
573 memcpy(sta->deflink.addr, link_addr, ETH_ALEN); in __sta_info_alloc()
574 memcpy(sta->sta.deflink.addr, link_addr, ETH_ALEN); in __sta_info_alloc()
575 sta->sta.max_rx_aggregation_subframes = in __sta_info_alloc()
576 local->hw.max_rx_aggregation_subframes; in __sta_info_alloc()
578 /* TODO link specific alloc and assignments for MLO Link STA */ in __sta_info_alloc()
580 /* Extended Key ID needs to install keys for keyid 0 and 1 Rx-only. in __sta_info_alloc()
582 * references to is not NULL. To not use the initial Rx-only key in __sta_info_alloc()
586 BUILD_BUG_ON(ARRAY_SIZE(sta->ptk) <= INVALID_PTK_KEYIDX); in __sta_info_alloc()
587 sta->ptk_idx = INVALID_PTK_KEYIDX; in __sta_info_alloc()
590 ieee80211_init_frag_cache(&sta->frags); in __sta_info_alloc()
592 sta->sta_state = IEEE80211_STA_NONE; in __sta_info_alloc()
595 sta->reserved_tid = IEEE80211_TID_UNRESERVED; in __sta_info_alloc()
597 sta->last_connected = ktime_get_seconds(); in __sta_info_alloc()
599 if (local->ops->wake_tx_queue) { in __sta_info_alloc()
602 ALIGN(hw->txq_data_size, sizeof(void *)); in __sta_info_alloc()
604 txq_data = kcalloc(ARRAY_SIZE(sta->sta.txq), size, gfp); in __sta_info_alloc()
608 for (i = 0; i < ARRAY_SIZE(sta->sta.txq); i++) { in __sta_info_alloc()
619 sta->airtime_weight = IEEE80211_DEFAULT_AIRTIME_WEIGHT; in __sta_info_alloc()
622 skb_queue_head_init(&sta->ps_tx_buf[i]); in __sta_info_alloc()
623 skb_queue_head_init(&sta->tx_filtered[i]); in __sta_info_alloc()
624 sta->airtime[i].deficit = sta->airtime_weight; in __sta_info_alloc()
625 atomic_set(&sta->airtime[i].aql_tx_pending, 0); in __sta_info_alloc()
626 sta->airtime[i].aql_limit_low = local->aql_txq_limit_low[i]; in __sta_info_alloc()
627 sta->airtime[i].aql_limit_high = local->aql_txq_limit_high[i]; in __sta_info_alloc()
631 sta->last_seq_ctrl[i] = cpu_to_le16(USHRT_MAX); in __sta_info_alloc()
637 if (!hw->wiphy->bands[i]) in __sta_info_alloc()
664 for (r = 0; r < hw->wiphy->bands[i]->n_bitrates; r++) { in __sta_info_alloc()
667 rate = &hw->wiphy->bands[i]->bitrates[r]; in __sta_info_alloc()
669 if (!(rate->flags & mandatory)) in __sta_info_alloc()
671 sta->sta.deflink.supp_rates[i] |= BIT(r); in __sta_info_alloc()
675 sta->cparams.ce_threshold = CODEL_DISABLED_THRESHOLD; in __sta_info_alloc()
676 sta->cparams.target = MS2TIME(20); in __sta_info_alloc()
677 sta->cparams.interval = MS2TIME(100); in __sta_info_alloc()
678 sta->cparams.ecn = true; in __sta_info_alloc()
679 sta->cparams.ce_threshold_selector = 0; in __sta_info_alloc()
680 sta->cparams.ce_threshold_mask = 0; in __sta_info_alloc()
682 sta_dbg(sdata, "Allocated STA %pM\n", sta->sta.addr); in __sta_info_alloc()
687 if (sta->sta.txq[0]) in __sta_info_alloc()
688 kfree(to_txq_info(sta->sta.txq[0])); in __sta_info_alloc()
690 sta_info_free_link(&sta->deflink); in __sta_info_alloc()
692 kfree(sta->mesh); in __sta_info_alloc()
701 return __sta_info_alloc(sdata, addr, -1, addr, gfp); in sta_info_alloc()
715 struct ieee80211_sub_if_data *sdata = sta->sdata; in sta_info_insert_check()
723 return -ENETDOWN; in sta_info_insert_check()
725 if (WARN_ON(ether_addr_equal(sta->sta.addr, sdata->vif.addr) || in sta_info_insert_check()
726 !is_valid_ether_addr(sta->sta.addr))) in sta_info_insert_check()
727 return -EINVAL; in sta_info_insert_check()
734 lockdep_assert_held(&sdata->local->sta_mtx); in sta_info_insert_check()
735 if (ieee80211_hw_check(&sdata->local->hw, NEEDS_UNIQUE_STA_ADDR) && in sta_info_insert_check()
736 ieee80211_find_sta_by_ifaddr(&sdata->local->hw, sta->addr, NULL)) { in sta_info_insert_check()
738 return -ENOTUNIQ; in sta_info_insert_check()
752 for (state = IEEE80211_STA_NOTEXIST; state < sta->sta_state; state++) { in sta_info_insert_drv_state()
763 if (!local->ops->sta_add) in sta_info_insert_drv_state()
764 sta->uploaded = true; in sta_info_insert_drv_state()
768 if (sdata->vif.type == NL80211_IFTYPE_ADHOC) { in sta_info_insert_drv_state()
770 "failed to move IBSS STA %pM to state %d (%d) - keeping it anyway\n", in sta_info_insert_drv_state()
771 sta->sta.addr, state + 1, err); in sta_info_insert_drv_state()
776 for (; state > IEEE80211_STA_NOTEXIST; state--) in sta_info_insert_drv_state()
777 WARN_ON(drv_sta_state(local, sdata, sta, state, state - 1)); in sta_info_insert_drv_state()
785 struct ieee80211_local *local = sdata->local; in ieee80211_recalc_p2p_go_ps_allowed()
786 bool allow_p2p_go_ps = sdata->vif.p2p; in ieee80211_recalc_p2p_go_ps_allowed()
790 list_for_each_entry_rcu(sta, &local->sta_list, list) { in ieee80211_recalc_p2p_go_ps_allowed()
791 if (sdata != sta->sdata || in ieee80211_recalc_p2p_go_ps_allowed()
794 if (!sta->sta.support_p2p_ps) { in ieee80211_recalc_p2p_go_ps_allowed()
801 if (allow_p2p_go_ps != sdata->vif.bss_conf.allow_p2p_go_ps) { in ieee80211_recalc_p2p_go_ps_allowed()
802 sdata->vif.bss_conf.allow_p2p_go_ps = allow_p2p_go_ps; in ieee80211_recalc_p2p_go_ps_allowed()
803 ieee80211_link_info_change_notify(sdata, &sdata->deflink, in ieee80211_recalc_p2p_go_ps_allowed()
815 struct ieee80211_local *local = sta->local; in sta_info_insert_finish()
816 struct ieee80211_sub_if_data *sdata = sta->sdata; in sta_info_insert_finish()
820 lockdep_assert_held(&local->sta_mtx); in sta_info_insert_finish()
823 if (sta_info_get_bss(sdata, sta->sta.addr)) { in sta_info_insert_finish()
824 err = -EEXIST; in sta_info_insert_finish()
830 err = -ENOMEM; in sta_info_insert_finish()
834 local->num_sta++; in sta_info_insert_finish()
835 local->sta_generation++; in sta_info_insert_finish()
846 if (sta->sta.valid_links) { in sta_info_insert_finish()
847 err = link_sta_info_hash_add(local, &sta->deflink); in sta_info_insert_finish()
854 list_add_tail_rcu(&sta->list, &local->sta_list); in sta_info_insert_finish()
859 if (sta->sta_state >= IEEE80211_STA_ASSOC) { in sta_info_insert_finish()
860 ieee80211_recalc_min_chandef(sta->sdata, -1); in sta_info_insert_finish()
861 if (!sta->sta.support_p2p_ps) in sta_info_insert_finish()
862 ieee80211_recalc_p2p_go_ps_allowed(sta->sdata); in sta_info_insert_finish()
878 sinfo->generation = local->sta_generation; in sta_info_insert_finish()
879 cfg80211_new_sta(sdata->dev, sta->sta.addr, sinfo, GFP_KERNEL); in sta_info_insert_finish()
882 sta_dbg(sdata, "Inserted STA %pM\n", sta->sta.addr); in sta_info_insert_finish()
884 /* move reference to rcu-protected */ in sta_info_insert_finish()
886 mutex_unlock(&local->sta_mtx); in sta_info_insert_finish()
888 if (ieee80211_vif_is_mesh(&sdata->vif)) in sta_info_insert_finish()
893 if (sta->sta.valid_links) in sta_info_insert_finish()
894 link_sta_info_hash_del(local, &sta->deflink); in sta_info_insert_finish()
896 list_del_rcu(&sta->list); in sta_info_insert_finish()
898 local->num_sta--; in sta_info_insert_finish()
902 mutex_unlock(&local->sta_mtx); in sta_info_insert_finish()
910 struct ieee80211_local *local = sta->local; in sta_info_insert_rcu()
915 mutex_lock(&local->sta_mtx); in sta_info_insert_rcu()
920 mutex_unlock(&local->sta_mtx); in sta_info_insert_rcu()
964 static unsigned long ieee80211_tids_for_ac(int ac) in ieee80211_tids_for_ac() argument
967 switch (ac) { in ieee80211_tids_for_ac()
984 struct ieee80211_local *local = sta->local; in __sta_info_recalc_tim()
987 u8 ignore_for_tim = sta->sta.uapsd_queues; in __sta_info_recalc_tim()
988 int ac; in __sta_info_recalc_tim() local
989 u16 id = sta->sta.aid; in __sta_info_recalc_tim()
991 if (sta->sdata->vif.type == NL80211_IFTYPE_AP || in __sta_info_recalc_tim()
992 sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN) { in __sta_info_recalc_tim()
993 if (WARN_ON_ONCE(!sta->sdata->bss)) in __sta_info_recalc_tim()
996 ps = &sta->sdata->bss->ps; in __sta_info_recalc_tim()
998 } else if (ieee80211_vif_is_mesh(&sta->sdata->vif)) { in __sta_info_recalc_tim()
999 ps = &sta->sdata->u.mesh.ps; in __sta_info_recalc_tim()
1006 if (ieee80211_hw_check(&local->hw, AP_LINK_PS) && !local->ops->set_tim) in __sta_info_recalc_tim()
1009 if (sta->dead) in __sta_info_recalc_tim()
1013 * If all ACs are delivery-enabled then we should build in __sta_info_recalc_tim()
1016 * non-enabled ones. in __sta_info_recalc_tim()
1018 if (ignore_for_tim == BIT(IEEE80211_NUM_ACS) - 1) in __sta_info_recalc_tim()
1022 ignore_for_tim = BIT(IEEE80211_NUM_ACS) - 1; in __sta_info_recalc_tim()
1024 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { in __sta_info_recalc_tim()
1027 if (ignore_for_tim & ieee80211_ac_to_qos_mask[ac]) in __sta_info_recalc_tim()
1030 indicate_tim |= !skb_queue_empty(&sta->tx_filtered[ac]) || in __sta_info_recalc_tim()
1031 !skb_queue_empty(&sta->ps_tx_buf[ac]); in __sta_info_recalc_tim()
1035 tids = ieee80211_tids_for_ac(ac); in __sta_info_recalc_tim()
1038 sta->driver_buffered_tids & tids; in __sta_info_recalc_tim()
1040 sta->txq_buffered_tids & tids; in __sta_info_recalc_tim()
1044 spin_lock_bh(&local->tim_lock); in __sta_info_recalc_tim()
1046 if (indicate_tim == __bss_tim_get(ps->tim, id)) in __sta_info_recalc_tim()
1050 __bss_tim_set(ps->tim, id); in __sta_info_recalc_tim()
1052 __bss_tim_clear(ps->tim, id); in __sta_info_recalc_tim()
1054 if (local->ops->set_tim && !WARN_ON(sta->dead)) { in __sta_info_recalc_tim()
1055 local->tim_in_locked_section = true; in __sta_info_recalc_tim()
1056 drv_set_tim(local, &sta->sta, indicate_tim); in __sta_info_recalc_tim()
1057 local->tim_in_locked_section = false; in __sta_info_recalc_tim()
1061 spin_unlock_bh(&local->tim_lock); in __sta_info_recalc_tim()
1080 timeout = (sta->listen_interval * in sta_info_buffer_expired()
1081 sta->sdata->vif.bss_conf.beacon_int * in sta_info_buffer_expired()
1085 return time_after(jiffies, info->control.jiffies + timeout); in sta_info_buffer_expired()
1090 struct sta_info *sta, int ac) in sta_info_cleanup_expire_buffered_ac() argument
1098 * a separate queue to avoid reordering with normal PS-buffered in sta_info_cleanup_expire_buffered_ac()
1103 spin_lock_irqsave(&sta->tx_filtered[ac].lock, flags); in sta_info_cleanup_expire_buffered_ac()
1104 skb = skb_peek(&sta->tx_filtered[ac]); in sta_info_cleanup_expire_buffered_ac()
1106 skb = __skb_dequeue(&sta->tx_filtered[ac]); in sta_info_cleanup_expire_buffered_ac()
1109 spin_unlock_irqrestore(&sta->tx_filtered[ac].lock, flags); in sta_info_cleanup_expire_buffered_ac()
1119 ieee80211_free_txskb(&local->hw, skb); in sta_info_cleanup_expire_buffered_ac()
1123 * Now also check the normal PS-buffered queue, this will in sta_info_cleanup_expire_buffered_ac()
1129 spin_lock_irqsave(&sta->ps_tx_buf[ac].lock, flags); in sta_info_cleanup_expire_buffered_ac()
1130 skb = skb_peek(&sta->ps_tx_buf[ac]); in sta_info_cleanup_expire_buffered_ac()
1132 skb = __skb_dequeue(&sta->ps_tx_buf[ac]); in sta_info_cleanup_expire_buffered_ac()
1135 spin_unlock_irqrestore(&sta->ps_tx_buf[ac].lock, flags); in sta_info_cleanup_expire_buffered_ac()
1145 local->total_ps_buffered--; in sta_info_cleanup_expire_buffered_ac()
1146 ps_dbg(sta->sdata, "Buffered frame expired (STA %pM)\n", in sta_info_cleanup_expire_buffered_ac()
1147 sta->sta.addr); in sta_info_cleanup_expire_buffered_ac()
1148 ieee80211_free_txskb(&local->hw, skb); in sta_info_cleanup_expire_buffered_ac()
1152 * Finally, recalculate the TIM bit for this station -- it might in sta_info_cleanup_expire_buffered_ac()
1163 return !(skb_queue_empty(&sta->ps_tx_buf[ac]) && in sta_info_cleanup_expire_buffered_ac()
1164 skb_queue_empty(&sta->tx_filtered[ac])); in sta_info_cleanup_expire_buffered_ac()
1171 int ac; in sta_info_cleanup_expire_buffered() local
1174 if (!sta->sdata->bss && in sta_info_cleanup_expire_buffered()
1175 !ieee80211_vif_is_mesh(&sta->sdata->vif)) in sta_info_cleanup_expire_buffered()
1178 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) in sta_info_cleanup_expire_buffered()
1180 sta_info_cleanup_expire_buffered_ac(local, sta, ac); in sta_info_cleanup_expire_buffered()
1194 return -ENOENT; in __sta_info_destroy_part1()
1196 local = sta->local; in __sta_info_destroy_part1()
1197 sdata = sta->sdata; in __sta_info_destroy_part1()
1199 lockdep_assert_held(&local->sta_mtx); in __sta_info_destroy_part1()
1204 * sessions -- block that to make sure the tear-down in __sta_info_destroy_part1()
1212 * rx frames on RSS queues sent prior to the disassociation - wait for in __sta_info_destroy_part1()
1217 for (i = 0; i < ARRAY_SIZE(sta->link); i++) { in __sta_info_destroy_part1()
1220 if (!(sta->sta.valid_links & BIT(i))) in __sta_info_destroy_part1()
1223 link_sta = rcu_dereference_protected(sta->link[i], in __sta_info_destroy_part1()
1224 lockdep_is_held(&local->sta_mtx)); in __sta_info_destroy_part1()
1238 drv_tdls_cancel_channel_switch(local, sdata, &sta->sta); in __sta_info_destroy_part1()
1242 list_del_rcu(&sta->list); in __sta_info_destroy_part1()
1243 sta->removed = true; in __sta_info_destroy_part1()
1245 drv_sta_pre_rcu_remove(local, sta->sdata, sta); in __sta_info_destroy_part1()
1247 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN && in __sta_info_destroy_part1()
1248 rcu_access_pointer(sdata->u.vlan.sta) == sta) in __sta_info_destroy_part1()
1249 RCU_INIT_POINTER(sdata->u.vlan.sta, NULL); in __sta_info_destroy_part1()
1256 struct ieee80211_local *local = sta->local; in __sta_info_destroy_part2()
1257 struct ieee80211_sub_if_data *sdata = sta->sdata; in __sta_info_destroy_part2()
1267 lockdep_assert_held(&local->sta_mtx); in __sta_info_destroy_part2()
1269 if (sta->sta_state == IEEE80211_STA_AUTHORIZED) { in __sta_info_destroy_part2()
1277 /* disable TIM bit - last chance to tell driver */ in __sta_info_destroy_part2()
1280 sta->dead = true; in __sta_info_destroy_part2()
1282 local->num_sta--; in __sta_info_destroy_part2()
1283 local->sta_generation++; in __sta_info_destroy_part2()
1285 while (sta->sta_state > IEEE80211_STA_NONE) { in __sta_info_destroy_part2()
1286 ret = sta_info_move_state(sta, sta->sta_state - 1); in __sta_info_destroy_part2()
1293 if (sta->uploaded) { in __sta_info_destroy_part2()
1299 sta_dbg(sdata, "Removed STA %pM\n", sta->sta.addr); in __sta_info_destroy_part2()
1304 cfg80211_del_sta_sinfo(sdata->dev, sta->sta.addr, sinfo, GFP_KERNEL); in __sta_info_destroy_part2()
1309 ieee80211_destroy_frag_cache(&sta->frags); in __sta_info_destroy_part2()
1333 mutex_lock(&sdata->local->sta_mtx); in sta_info_destroy_addr()
1336 mutex_unlock(&sdata->local->sta_mtx); in sta_info_destroy_addr()
1347 mutex_lock(&sdata->local->sta_mtx); in sta_info_destroy_addr_bss()
1350 mutex_unlock(&sdata->local->sta_mtx); in sta_info_destroy_addr_bss()
1362 list_for_each_entry_rcu(sta, &local->sta_list, list) in sta_info_cleanup()
1367 if (local->quiescing) in sta_info_cleanup()
1373 mod_timer(&local->sta_cleanup, in sta_info_cleanup()
1381 err = rhltable_init(&local->sta_hash, &sta_rht_params); in sta_info_init()
1385 err = rhltable_init(&local->link_sta_hash, &link_sta_rht_params); in sta_info_init()
1387 rhltable_destroy(&local->sta_hash); in sta_info_init()
1391 spin_lock_init(&local->tim_lock); in sta_info_init()
1392 mutex_init(&local->sta_mtx); in sta_info_init()
1393 INIT_LIST_HEAD(&local->sta_list); in sta_info_init()
1395 timer_setup(&local->sta_cleanup, sta_info_cleanup, 0); in sta_info_init()
1401 del_timer_sync(&local->sta_cleanup); in sta_info_stop()
1402 rhltable_destroy(&local->sta_hash); in sta_info_stop()
1403 rhltable_destroy(&local->link_sta_hash); in sta_info_stop()
1409 struct ieee80211_local *local = sdata->local; in __sta_info_flush()
1416 WARN_ON(vlans && sdata->vif.type != NL80211_IFTYPE_AP); in __sta_info_flush()
1417 WARN_ON(vlans && !sdata->bss); in __sta_info_flush()
1419 mutex_lock(&local->sta_mtx); in __sta_info_flush()
1420 list_for_each_entry_safe(sta, tmp, &local->sta_list, list) { in __sta_info_flush()
1421 if (sdata == sta->sdata || in __sta_info_flush()
1422 (vlans && sdata->bss == sta->sdata->bss)) { in __sta_info_flush()
1424 list_add(&sta->free_list, &free_list); in __sta_info_flush()
1434 mutex_unlock(&local->sta_mtx); in __sta_info_flush()
1442 struct ieee80211_local *local = sdata->local; in ieee80211_sta_expire()
1445 mutex_lock(&local->sta_mtx); in ieee80211_sta_expire()
1447 list_for_each_entry_safe(sta, tmp, &local->sta_list, list) { in ieee80211_sta_expire()
1450 if (sdata != sta->sdata) in ieee80211_sta_expire()
1454 sta_dbg(sta->sdata, "expiring inactive STA %pM\n", in ieee80211_sta_expire()
1455 sta->sta.addr); in ieee80211_sta_expire()
1457 if (ieee80211_vif_is_mesh(&sdata->vif) && in ieee80211_sta_expire()
1459 atomic_dec(&sdata->u.mesh.ps.num_sta_ps); in ieee80211_sta_expire()
1465 mutex_unlock(&local->sta_mtx); in ieee80211_sta_expire()
1482 !ether_addr_equal(sta->sdata->vif.addr, localaddr)) in ieee80211_find_sta_by_ifaddr()
1484 if (!sta->uploaded) in ieee80211_find_sta_by_ifaddr()
1486 return &sta->sta; in ieee80211_find_sta_by_ifaddr()
1505 if (!sta->uploaded) in ieee80211_find_sta()
1508 return &sta->sta; in ieee80211_find_sta()
1515 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_sta_ps_deliver_wakeup()
1516 struct ieee80211_local *local = sdata->local; in ieee80211_sta_ps_deliver_wakeup()
1518 int filtered = 0, buffered = 0, ac, i; in ieee80211_sta_ps_deliver_wakeup() local
1522 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) in ieee80211_sta_ps_deliver_wakeup()
1523 sdata = container_of(sdata->bss, struct ieee80211_sub_if_data, in ieee80211_sta_ps_deliver_wakeup()
1526 if (sdata->vif.type == NL80211_IFTYPE_AP) in ieee80211_sta_ps_deliver_wakeup()
1527 ps = &sdata->bss->ps; in ieee80211_sta_ps_deliver_wakeup()
1528 else if (ieee80211_vif_is_mesh(&sdata->vif)) in ieee80211_sta_ps_deliver_wakeup()
1529 ps = &sdata->u.mesh.ps; in ieee80211_sta_ps_deliver_wakeup()
1536 sta->driver_buffered_tids = 0; in ieee80211_sta_ps_deliver_wakeup()
1537 sta->txq_buffered_tids = 0; in ieee80211_sta_ps_deliver_wakeup()
1539 if (!ieee80211_hw_check(&local->hw, AP_LINK_PS)) in ieee80211_sta_ps_deliver_wakeup()
1540 drv_sta_notify(local, sdata, STA_NOTIFY_AWAKE, &sta->sta); in ieee80211_sta_ps_deliver_wakeup()
1542 for (i = 0; i < ARRAY_SIZE(sta->sta.txq); i++) { in ieee80211_sta_ps_deliver_wakeup()
1543 if (!sta->sta.txq[i] || !txq_has_queue(sta->sta.txq[i])) in ieee80211_sta_ps_deliver_wakeup()
1546 schedule_and_wake_txq(local, to_txq_info(sta->sta.txq[i])); in ieee80211_sta_ps_deliver_wakeup()
1552 spin_lock(&sta->ps_lock); in ieee80211_sta_ps_deliver_wakeup()
1554 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { in ieee80211_sta_ps_deliver_wakeup()
1557 spin_lock_irqsave(&sta->tx_filtered[ac].lock, flags); in ieee80211_sta_ps_deliver_wakeup()
1558 skb_queue_splice_tail_init(&sta->tx_filtered[ac], &pending); in ieee80211_sta_ps_deliver_wakeup()
1559 spin_unlock_irqrestore(&sta->tx_filtered[ac].lock, flags); in ieee80211_sta_ps_deliver_wakeup()
1561 filtered += tmp - count; in ieee80211_sta_ps_deliver_wakeup()
1564 spin_lock_irqsave(&sta->ps_tx_buf[ac].lock, flags); in ieee80211_sta_ps_deliver_wakeup()
1565 skb_queue_splice_tail_init(&sta->ps_tx_buf[ac], &pending); in ieee80211_sta_ps_deliver_wakeup()
1566 spin_unlock_irqrestore(&sta->ps_tx_buf[ac].lock, flags); in ieee80211_sta_ps_deliver_wakeup()
1568 buffered += tmp - count; in ieee80211_sta_ps_deliver_wakeup()
1581 spin_unlock(&sta->ps_lock); in ieee80211_sta_ps_deliver_wakeup()
1583 atomic_dec(&ps->num_sta_ps); in ieee80211_sta_ps_deliver_wakeup()
1585 local->total_ps_buffered -= buffered; in ieee80211_sta_ps_deliver_wakeup()
1591 sta->sta.addr, sta->sta.aid, filtered, buffered); in ieee80211_sta_ps_deliver_wakeup()
1600 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_send_null_response()
1601 struct ieee80211_local *local = sdata->local; in ieee80211_send_null_response()
1606 bool qos = sta->sta.wme; in ieee80211_send_null_response()
1615 size -= 2; in ieee80211_send_null_response()
1621 skb = dev_alloc_skb(local->hw.extra_tx_headroom + size); in ieee80211_send_null_response()
1625 skb_reserve(skb, local->hw.extra_tx_headroom); in ieee80211_send_null_response()
1628 nullfunc->frame_control = fc; in ieee80211_send_null_response()
1629 nullfunc->duration_id = 0; in ieee80211_send_null_response()
1630 memcpy(nullfunc->addr1, sta->sta.addr, ETH_ALEN); in ieee80211_send_null_response()
1631 memcpy(nullfunc->addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_send_null_response()
1632 memcpy(nullfunc->addr3, sdata->vif.addr, ETH_ALEN); in ieee80211_send_null_response()
1633 nullfunc->seq_ctrl = 0; in ieee80211_send_null_response()
1635 skb->priority = tid; in ieee80211_send_null_response()
1638 nullfunc->qos_ctrl = cpu_to_le16(tid); in ieee80211_send_null_response()
1641 nullfunc->qos_ctrl |= in ieee80211_send_null_response()
1644 nullfunc->frame_control |= in ieee80211_send_null_response()
1657 info->flags |= IEEE80211_TX_CTL_NO_PS_BUFFER | in ieee80211_send_null_response()
1661 info->control.flags |= IEEE80211_TX_CTRL_PS_RESPONSE; in ieee80211_send_null_response()
1667 skb->dev = sdata->dev; in ieee80211_send_null_response()
1670 chanctx_conf = rcu_dereference(sdata->vif.bss_conf.chanctx_conf); in ieee80211_send_null_response()
1677 info->band = chanctx_conf->def.chan->band; in ieee80211_send_null_response()
1686 return fls(tids) - 1; in find_highest_prio_tid()
1690 return fls(tids) - 1; in find_highest_prio_tid()
1703 int ac; in ieee80211_sta_ps_more_data() local
1708 * only happen for PS-Poll. in ieee80211_sta_ps_more_data()
1714 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { in ieee80211_sta_ps_more_data()
1715 if (ignored_acs & ieee80211_ac_to_qos_mask[ac]) in ieee80211_sta_ps_more_data()
1718 if (!skb_queue_empty(&sta->tx_filtered[ac]) || in ieee80211_sta_ps_more_data()
1719 !skb_queue_empty(&sta->ps_tx_buf[ac])) in ieee80211_sta_ps_more_data()
1732 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_sta_ps_get_frames()
1733 struct ieee80211_local *local = sdata->local; in ieee80211_sta_ps_get_frames()
1734 int ac; in ieee80211_sta_ps_get_frames() local
1737 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { in ieee80211_sta_ps_get_frames()
1740 if (ignored_acs & ieee80211_ac_to_qos_mask[ac]) in ieee80211_sta_ps_get_frames()
1743 tids = ieee80211_tids_for_ac(ac); in ieee80211_sta_ps_get_frames()
1750 sta->driver_buffered_tids & tids; in ieee80211_sta_ps_get_frames()
1751 *driver_release_tids |= sta->txq_buffered_tids & tids; in ieee80211_sta_ps_get_frames()
1758 skb = skb_dequeue(&sta->tx_filtered[ac]); in ieee80211_sta_ps_get_frames()
1761 &sta->ps_tx_buf[ac]); in ieee80211_sta_ps_get_frames()
1763 local->total_ps_buffered--; in ieee80211_sta_ps_get_frames()
1767 n_frames--; in ieee80211_sta_ps_get_frames()
1772 /* If we have more frames buffered on this AC, then abort the in ieee80211_sta_ps_get_frames()
1776 if (!skb_queue_empty(&sta->tx_filtered[ac]) || in ieee80211_sta_ps_get_frames()
1777 !skb_queue_empty(&sta->ps_tx_buf[ac])) in ieee80211_sta_ps_get_frames()
1787 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_sta_ps_deliver_response()
1788 struct ieee80211_local *local = sdata->local; in ieee80211_sta_ps_deliver_response()
1793 /* Service or PS-Poll period starts */ in ieee80211_sta_ps_deliver_response()
1808 int tid, ac; in ieee80211_sta_ps_deliver_response() local
1811 * For PS-Poll, this can only happen due to a race condition in ieee80211_sta_ps_deliver_response()
1816 * At each unscheduled SP for a non-AP STA, the AP shall in ieee80211_sta_ps_deliver_response()
1819 * in the QoS Capability element from delivery-enabled ACs, in ieee80211_sta_ps_deliver_response()
1820 * that are destined for the non-AP STA. in ieee80211_sta_ps_deliver_response()
1826 for (ac = IEEE80211_AC_VO; ac < IEEE80211_NUM_ACS; ac++) in ieee80211_sta_ps_deliver_response()
1827 if (!(ignored_acs & ieee80211_ac_to_qos_mask[ac])) in ieee80211_sta_ps_deliver_response()
1829 tid = 7 - 2 * ac; in ieee80211_sta_ps_deliver_response()
1843 struct ieee80211_hdr *hdr = (void *) skb->data; in ieee80211_sta_ps_deliver_response()
1853 info->flags |= IEEE80211_TX_CTL_NO_PS_BUFFER; in ieee80211_sta_ps_deliver_response()
1854 info->control.flags |= IEEE80211_TX_CTRL_PS_RESPONSE; in ieee80211_sta_ps_deliver_response()
1861 hdr->frame_control |= in ieee80211_sta_ps_deliver_response()
1864 hdr->frame_control &= in ieee80211_sta_ps_deliver_response()
1867 if (ieee80211_is_data_qos(hdr->frame_control) || in ieee80211_sta_ps_deliver_response()
1868 ieee80211_is_qos_nullfunc(hdr->frame_control)) in ieee80211_sta_ps_deliver_response()
1871 tids |= BIT(skb->priority); in ieee80211_sta_ps_deliver_response()
1880 /* for PS-Poll, there's only one frame */ in ieee80211_sta_ps_deliver_response()
1881 info->flags |= IEEE80211_TX_STATUS_EOSP | in ieee80211_sta_ps_deliver_response()
1887 * last frame has a QoS header (i.e. is a QoS-data or in ieee80211_sta_ps_deliver_response()
1888 * QoS-nulldata frame) then just set the EOSP bit there in ieee80211_sta_ps_deliver_response()
1892 * the EOSP bit in the QoS header; add a QoS-nulldata in ieee80211_sta_ps_deliver_response()
1895 * Note that this code is only in the mac80211-release in ieee80211_sta_ps_deliver_response()
1897 * anything but QoS-data frames, or if it does, will in ieee80211_sta_ps_deliver_response()
1898 * create the QoS-nulldata frame by itself if needed. in ieee80211_sta_ps_deliver_response()
1900 * Cf. 802.11-2012 10.2.1.10 (c). in ieee80211_sta_ps_deliver_response()
1905 info->flags |= IEEE80211_TX_STATUS_EOSP | in ieee80211_sta_ps_deliver_response()
1909 * as it says the more-data bit should be set in ieee80211_sta_ps_deliver_response()
1910 * if there are more BUs. The QoS-Null frame in ieee80211_sta_ps_deliver_response()
1914 * expect more-data=0 when eosp=1. in ieee80211_sta_ps_deliver_response()
1916 hdr->frame_control |= in ieee80211_sta_ps_deliver_response()
1942 * on the TIDs we're releasing from - if there are more than in ieee80211_sta_ps_deliver_response()
1943 * n_frames it has to set the more-data bit (if we didn't ask in ieee80211_sta_ps_deliver_response()
1961 if (!sta->sta.txq[0]) in ieee80211_sta_ps_deliver_response()
1964 for (tid = 0; tid < ARRAY_SIZE(sta->sta.txq); tid++) { in ieee80211_sta_ps_deliver_response()
1965 if (!sta->sta.txq[tid] || in ieee80211_sta_ps_deliver_response()
1967 txq_has_queue(sta->sta.txq[tid])) in ieee80211_sta_ps_deliver_response()
1978 u8 ignore_for_response = sta->sta.uapsd_queues; in ieee80211_sta_ps_deliver_poll_response()
1981 * If all ACs are delivery-enabled then we should reply in ieee80211_sta_ps_deliver_poll_response()
1983 * only from the non-enabled ones. in ieee80211_sta_ps_deliver_poll_response()
1985 if (ignore_for_response == BIT(IEEE80211_NUM_ACS) - 1) in ieee80211_sta_ps_deliver_poll_response()
1994 int n_frames = sta->sta.max_sp; in ieee80211_sta_ps_deliver_uapsd()
1995 u8 delivery_enabled = sta->sta.uapsd_queues; in ieee80211_sta_ps_deliver_uapsd()
2006 switch (sta->sta.max_sp) { in ieee80211_sta_ps_deliver_uapsd()
2031 trace_api_sta_block_awake(sta->local, pubsta, block); in ieee80211_sta_block_awake()
2045 ieee80211_queue_work(hw, &sta->drv_deliver_wk); in ieee80211_sta_block_awake()
2050 ieee80211_queue_work(hw, &sta->drv_deliver_wk); in ieee80211_sta_block_awake()
2061 struct ieee80211_local *local = sta->local; in ieee80211_sta_eosp()
2075 trace_api_send_eosp_nullfunc(sta->local, pubsta, tid); in ieee80211_send_eosp_nullfunc()
2078 more_data = ieee80211_sta_ps_more_data(sta, ~sta->sta.uapsd_queues, in ieee80211_send_eosp_nullfunc()
2093 trace_api_sta_set_buffered(sta->local, pubsta, tid, buffered); in ieee80211_sta_set_buffered()
2096 set_bit(tid, &sta->driver_buffered_tids); in ieee80211_sta_set_buffered()
2098 clear_bit(tid, &sta->driver_buffered_tids); in ieee80211_sta_set_buffered()
2108 struct ieee80211_local *local = sta->sdata->local; in ieee80211_sta_register_airtime()
2109 u8 ac = ieee80211_ac_from_tid(tid); in ieee80211_sta_register_airtime() local
2113 if (sta->local->airtime_flags & AIRTIME_USE_TX) in ieee80211_sta_register_airtime()
2115 if (sta->local->airtime_flags & AIRTIME_USE_RX) in ieee80211_sta_register_airtime()
2118 spin_lock_bh(&local->active_txq_lock[ac]); in ieee80211_sta_register_airtime()
2119 sta->airtime[ac].tx_airtime += tx_airtime; in ieee80211_sta_register_airtime()
2120 sta->airtime[ac].rx_airtime += rx_airtime; in ieee80211_sta_register_airtime()
2122 diff = (u32)jiffies - sta->airtime[ac].last_active; in ieee80211_sta_register_airtime()
2124 sta->airtime[ac].deficit -= airtime; in ieee80211_sta_register_airtime()
2126 spin_unlock_bh(&local->active_txq_lock[ac]); in ieee80211_sta_register_airtime()
2137 if (!pubsta->valid_links || !pubsta->mlo) { in ieee80211_sta_recalc_aggregates()
2138 pubsta->cur = &pubsta->deflink.agg; in ieee80211_sta_recalc_aggregates()
2143 for_each_sta_active_link(&sta->sdata->vif, pubsta, link_sta, link_id) { in ieee80211_sta_recalc_aggregates()
2145 sta->cur = pubsta->deflink.agg; in ieee80211_sta_recalc_aggregates()
2150 sta->cur.max_amsdu_len = in ieee80211_sta_recalc_aggregates()
2151 min(sta->cur.max_amsdu_len, in ieee80211_sta_recalc_aggregates()
2152 link_sta->agg.max_amsdu_len); in ieee80211_sta_recalc_aggregates()
2153 sta->cur.max_rc_amsdu_len = in ieee80211_sta_recalc_aggregates()
2154 min(sta->cur.max_rc_amsdu_len, in ieee80211_sta_recalc_aggregates()
2155 link_sta->agg.max_rc_amsdu_len); in ieee80211_sta_recalc_aggregates()
2157 for (i = 0; i < ARRAY_SIZE(sta->cur.max_tid_amsdu_len); i++) in ieee80211_sta_recalc_aggregates()
2158 sta->cur.max_tid_amsdu_len[i] = in ieee80211_sta_recalc_aggregates()
2159 min(sta->cur.max_tid_amsdu_len[i], in ieee80211_sta_recalc_aggregates()
2160 link_sta->agg.max_tid_amsdu_len[i]); in ieee80211_sta_recalc_aggregates()
2164 pubsta->cur = &sta->cur; in ieee80211_sta_recalc_aggregates()
2169 struct sta_info *sta, u8 ac, in ieee80211_sta_update_pending_airtime() argument
2174 if (!wiphy_ext_feature_isset(local->hw.wiphy, NL80211_EXT_FEATURE_AQL)) in ieee80211_sta_update_pending_airtime()
2180 &sta->airtime[ac].aql_tx_pending); in ieee80211_sta_update_pending_airtime()
2182 atomic_add(tx_airtime, &local->aql_total_pending_airtime); in ieee80211_sta_update_pending_airtime()
2183 atomic_add(tx_airtime, &local->aql_ac_pending_airtime[ac]); in ieee80211_sta_update_pending_airtime()
2189 &sta->airtime[ac].aql_tx_pending); in ieee80211_sta_update_pending_airtime()
2191 atomic_cmpxchg(&sta->airtime[ac].aql_tx_pending, in ieee80211_sta_update_pending_airtime()
2195 atomic_sub(tx_airtime, &local->aql_total_pending_airtime); in ieee80211_sta_update_pending_airtime()
2197 &local->aql_ac_pending_airtime[ac]); in ieee80211_sta_update_pending_airtime()
2199 "Device %s AC %d pending airtime underflow: %u, %u", in ieee80211_sta_update_pending_airtime()
2200 wiphy_name(local->hw.wiphy), ac, tx_pending, in ieee80211_sta_update_pending_airtime()
2202 atomic_cmpxchg(&local->aql_ac_pending_airtime[ac], in ieee80211_sta_update_pending_airtime()
2204 atomic_sub(tx_pending, &local->aql_total_pending_airtime); in ieee80211_sta_update_pending_airtime()
2213 if (sta->sta_state == new_state) in sta_info_move_state()
2220 if (sta->sta_state != IEEE80211_STA_AUTH) in sta_info_move_state()
2221 return -EINVAL; in sta_info_move_state()
2224 if (sta->sta_state != IEEE80211_STA_NONE && in sta_info_move_state()
2225 sta->sta_state != IEEE80211_STA_ASSOC) in sta_info_move_state()
2226 return -EINVAL; in sta_info_move_state()
2229 if (sta->sta_state != IEEE80211_STA_AUTH && in sta_info_move_state()
2230 sta->sta_state != IEEE80211_STA_AUTHORIZED) in sta_info_move_state()
2231 return -EINVAL; in sta_info_move_state()
2234 if (sta->sta_state != IEEE80211_STA_ASSOC) in sta_info_move_state()
2235 return -EINVAL; in sta_info_move_state()
2239 return -EINVAL; in sta_info_move_state()
2242 sta_dbg(sta->sdata, "moving STA %pM to state %d\n", in sta_info_move_state()
2243 sta->sta.addr, new_state); in sta_info_move_state()
2250 int err = drv_sta_state(sta->local, sta->sdata, sta, in sta_info_move_state()
2251 sta->sta_state, new_state); in sta_info_move_state()
2260 if (sta->sta_state == IEEE80211_STA_AUTH) in sta_info_move_state()
2261 clear_bit(WLAN_STA_AUTH, &sta->_flags); in sta_info_move_state()
2264 if (sta->sta_state == IEEE80211_STA_NONE) { in sta_info_move_state()
2265 set_bit(WLAN_STA_AUTH, &sta->_flags); in sta_info_move_state()
2266 } else if (sta->sta_state == IEEE80211_STA_ASSOC) { in sta_info_move_state()
2267 clear_bit(WLAN_STA_ASSOC, &sta->_flags); in sta_info_move_state()
2268 ieee80211_recalc_min_chandef(sta->sdata, -1); in sta_info_move_state()
2269 if (!sta->sta.support_p2p_ps) in sta_info_move_state()
2270 ieee80211_recalc_p2p_go_ps_allowed(sta->sdata); in sta_info_move_state()
2274 if (sta->sta_state == IEEE80211_STA_AUTH) { in sta_info_move_state()
2275 set_bit(WLAN_STA_ASSOC, &sta->_flags); in sta_info_move_state()
2276 sta->assoc_at = ktime_get_boottime_ns(); in sta_info_move_state()
2277 ieee80211_recalc_min_chandef(sta->sdata, -1); in sta_info_move_state()
2278 if (!sta->sta.support_p2p_ps) in sta_info_move_state()
2279 ieee80211_recalc_p2p_go_ps_allowed(sta->sdata); in sta_info_move_state()
2280 } else if (sta->sta_state == IEEE80211_STA_AUTHORIZED) { in sta_info_move_state()
2281 ieee80211_vif_dec_num_mcast(sta->sdata); in sta_info_move_state()
2282 clear_bit(WLAN_STA_AUTHORIZED, &sta->_flags); in sta_info_move_state()
2288 if (sta->sta_state == IEEE80211_STA_ASSOC) { in sta_info_move_state()
2289 ieee80211_vif_inc_num_mcast(sta->sdata); in sta_info_move_state()
2290 set_bit(WLAN_STA_AUTHORIZED, &sta->_flags); in sta_info_move_state()
2294 if (sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN || in sta_info_move_state()
2295 sta->sdata->vif.type == NL80211_IFTYPE_AP) in sta_info_move_state()
2296 cfg80211_send_layer2_update(sta->sdata->dev, in sta_info_move_state()
2297 sta->sta.addr); in sta_info_move_state()
2303 sta->sta_state = new_state; in sta_info_move_state()
2311 struct ieee80211_sta_rx_stats *stats = &sta->deflink.rx_stats; in sta_get_last_rx_stats()
2314 if (!sta->deflink.pcpu_rx_stats) in sta_get_last_rx_stats()
2320 cpustats = per_cpu_ptr(sta->deflink.pcpu_rx_stats, cpu); in sta_get_last_rx_stats()
2322 if (time_after(cpustats->last_rx, stats->last_rx)) in sta_get_last_rx_stats()
2332 rinfo->bw = STA_STATS_GET(BW, rate); in sta_stats_decode_rate()
2336 rinfo->flags = RATE_INFO_FLAGS_VHT_MCS; in sta_stats_decode_rate()
2337 rinfo->mcs = STA_STATS_GET(VHT_MCS, rate); in sta_stats_decode_rate()
2338 rinfo->nss = STA_STATS_GET(VHT_NSS, rate); in sta_stats_decode_rate()
2340 rinfo->flags |= RATE_INFO_FLAGS_SHORT_GI; in sta_stats_decode_rate()
2343 rinfo->flags = RATE_INFO_FLAGS_MCS; in sta_stats_decode_rate()
2344 rinfo->mcs = STA_STATS_GET(HT_MCS, rate); in sta_stats_decode_rate()
2346 rinfo->flags |= RATE_INFO_FLAGS_SHORT_GI; in sta_stats_decode_rate()
2355 sband = local->hw.wiphy->bands[band]; in sta_stats_decode_rate()
2357 if (WARN_ON_ONCE(!sband->bitrates)) in sta_stats_decode_rate()
2360 brate = sband->bitrates[rate_idx].bitrate; in sta_stats_decode_rate()
2361 if (rinfo->bw == RATE_INFO_BW_5) in sta_stats_decode_rate()
2363 else if (rinfo->bw == RATE_INFO_BW_10) in sta_stats_decode_rate()
2367 rinfo->legacy = DIV_ROUND_UP(brate, 1 << shift); in sta_stats_decode_rate()
2371 rinfo->flags = RATE_INFO_FLAGS_HE_MCS; in sta_stats_decode_rate()
2372 rinfo->mcs = STA_STATS_GET(HE_MCS, rate); in sta_stats_decode_rate()
2373 rinfo->nss = STA_STATS_GET(HE_NSS, rate); in sta_stats_decode_rate()
2374 rinfo->he_gi = STA_STATS_GET(HE_GI, rate); in sta_stats_decode_rate()
2375 rinfo->he_ru_alloc = STA_STATS_GET(HE_RU, rate); in sta_stats_decode_rate()
2376 rinfo->he_dcm = STA_STATS_GET(HE_DCM, rate); in sta_stats_decode_rate()
2383 u16 rate = READ_ONCE(sta_get_last_rx_stats(sta)->last_rate); in sta_set_rate_info_rx()
2386 return -EINVAL; in sta_set_rate_info_rx()
2388 sta_stats_decode_rate(sta->local, rate, rinfo); in sta_set_rate_info_rx()
2399 start = u64_stats_fetch_begin_irq(&rxstats->syncp); in sta_get_tidstats_msdu()
2400 value = rxstats->msdu[tid]; in sta_get_tidstats_msdu()
2401 } while (u64_stats_fetch_retry_irq(&rxstats->syncp, start)); in sta_get_tidstats_msdu()
2410 struct ieee80211_local *local = sta->local; in sta_set_tidstats()
2413 if (!(tidstats->filled & BIT(NL80211_TID_STATS_RX_MSDU))) { in sta_set_tidstats()
2414 tidstats->rx_msdu += sta_get_tidstats_msdu(&sta->deflink.rx_stats, in sta_set_tidstats()
2417 if (sta->deflink.pcpu_rx_stats) { in sta_set_tidstats()
2421 cpurxs = per_cpu_ptr(sta->deflink.pcpu_rx_stats, in sta_set_tidstats()
2423 tidstats->rx_msdu += in sta_set_tidstats()
2428 tidstats->filled |= BIT(NL80211_TID_STATS_RX_MSDU); in sta_set_tidstats()
2431 if (!(tidstats->filled & BIT(NL80211_TID_STATS_TX_MSDU))) { in sta_set_tidstats()
2432 tidstats->filled |= BIT(NL80211_TID_STATS_TX_MSDU); in sta_set_tidstats()
2433 tidstats->tx_msdu = sta->deflink.tx_stats.msdu[tid]; in sta_set_tidstats()
2436 if (!(tidstats->filled & BIT(NL80211_TID_STATS_TX_MSDU_RETRIES)) && in sta_set_tidstats()
2437 ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) { in sta_set_tidstats()
2438 tidstats->filled |= BIT(NL80211_TID_STATS_TX_MSDU_RETRIES); in sta_set_tidstats()
2439 tidstats->tx_msdu_retries = sta->deflink.status_stats.msdu_retries[tid]; in sta_set_tidstats()
2442 if (!(tidstats->filled & BIT(NL80211_TID_STATS_TX_MSDU_FAILED)) && in sta_set_tidstats()
2443 ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) { in sta_set_tidstats()
2444 tidstats->filled |= BIT(NL80211_TID_STATS_TX_MSDU_FAILED); in sta_set_tidstats()
2445 tidstats->tx_msdu_failed = sta->deflink.status_stats.msdu_failed[tid]; in sta_set_tidstats()
2448 if (local->ops->wake_tx_queue && tid < IEEE80211_NUM_TIDS) { in sta_set_tidstats()
2449 spin_lock_bh(&local->fq.lock); in sta_set_tidstats()
2452 tidstats->filled |= BIT(NL80211_TID_STATS_TXQ_STATS); in sta_set_tidstats()
2453 ieee80211_fill_txq_stats(&tidstats->txq_stats, in sta_set_tidstats()
2454 to_txq_info(sta->sta.txq[tid])); in sta_set_tidstats()
2457 spin_unlock_bh(&local->fq.lock); in sta_set_tidstats()
2467 start = u64_stats_fetch_begin_irq(&rxstats->syncp); in sta_get_stats_bytes()
2468 value = rxstats->bytes; in sta_get_stats_bytes()
2469 } while (u64_stats_fetch_retry_irq(&rxstats->syncp, start)); in sta_get_stats_bytes()
2477 struct ieee80211_sub_if_data *sdata = sta->sdata; in sta_set_sinfo()
2478 struct ieee80211_local *local = sdata->local; in sta_set_sinfo()
2480 int i, ac, cpu; in sta_set_sinfo() local
2485 sinfo->generation = sdata->local->sta_generation; in sta_set_sinfo()
2491 if (sdata->vif.type == NL80211_IFTYPE_STATION) in sta_set_sinfo()
2492 sinfo->rx_beacon = sdata->deflink.u.mgd.count_beacon_signal; in sta_set_sinfo()
2494 drv_sta_statistics(local, sdata, &sta->sta, sinfo); in sta_set_sinfo()
2495 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_INACTIVE_TIME) | in sta_set_sinfo()
2502 if (sdata->vif.type == NL80211_IFTYPE_STATION) { in sta_set_sinfo()
2503 sinfo->beacon_loss_count = in sta_set_sinfo()
2504 sdata->deflink.u.mgd.beacon_loss_count; in sta_set_sinfo()
2505 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_BEACON_LOSS); in sta_set_sinfo()
2508 sinfo->connected_time = ktime_get_seconds() - sta->last_connected; in sta_set_sinfo()
2509 sinfo->assoc_at = sta->assoc_at; in sta_set_sinfo()
2510 sinfo->inactive_time = in sta_set_sinfo()
2511 jiffies_to_msecs(jiffies - ieee80211_sta_last_active(sta)); in sta_set_sinfo()
2513 if (!(sinfo->filled & (BIT_ULL(NL80211_STA_INFO_TX_BYTES64) | in sta_set_sinfo()
2515 sinfo->tx_bytes = 0; in sta_set_sinfo()
2516 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) in sta_set_sinfo()
2517 sinfo->tx_bytes += sta->deflink.tx_stats.bytes[ac]; in sta_set_sinfo()
2518 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BYTES64); in sta_set_sinfo()
2521 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_TX_PACKETS))) { in sta_set_sinfo()
2522 sinfo->tx_packets = 0; in sta_set_sinfo()
2523 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) in sta_set_sinfo()
2524 sinfo->tx_packets += sta->deflink.tx_stats.packets[ac]; in sta_set_sinfo()
2525 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_PACKETS); in sta_set_sinfo()
2528 if (!(sinfo->filled & (BIT_ULL(NL80211_STA_INFO_RX_BYTES64) | in sta_set_sinfo()
2530 sinfo->rx_bytes += sta_get_stats_bytes(&sta->deflink.rx_stats); in sta_set_sinfo()
2532 if (sta->deflink.pcpu_rx_stats) { in sta_set_sinfo()
2536 cpurxs = per_cpu_ptr(sta->deflink.pcpu_rx_stats, in sta_set_sinfo()
2538 sinfo->rx_bytes += sta_get_stats_bytes(cpurxs); in sta_set_sinfo()
2542 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_BYTES64); in sta_set_sinfo()
2545 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_RX_PACKETS))) { in sta_set_sinfo()
2546 sinfo->rx_packets = sta->deflink.rx_stats.packets; in sta_set_sinfo()
2547 if (sta->deflink.pcpu_rx_stats) { in sta_set_sinfo()
2551 cpurxs = per_cpu_ptr(sta->deflink.pcpu_rx_stats, in sta_set_sinfo()
2553 sinfo->rx_packets += cpurxs->packets; in sta_set_sinfo()
2556 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_PACKETS); in sta_set_sinfo()
2559 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_TX_RETRIES))) { in sta_set_sinfo()
2560 sinfo->tx_retries = sta->deflink.status_stats.retry_count; in sta_set_sinfo()
2561 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_RETRIES); in sta_set_sinfo()
2564 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_TX_FAILED))) { in sta_set_sinfo()
2565 sinfo->tx_failed = sta->deflink.status_stats.retry_failed; in sta_set_sinfo()
2566 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_FAILED); in sta_set_sinfo()
2569 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_RX_DURATION))) { in sta_set_sinfo()
2570 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) in sta_set_sinfo()
2571 sinfo->rx_duration += sta->airtime[ac].rx_airtime; in sta_set_sinfo()
2572 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_DURATION); in sta_set_sinfo()
2575 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_TX_DURATION))) { in sta_set_sinfo()
2576 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) in sta_set_sinfo()
2577 sinfo->tx_duration += sta->airtime[ac].tx_airtime; in sta_set_sinfo()
2578 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_DURATION); in sta_set_sinfo()
2581 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_AIRTIME_WEIGHT))) { in sta_set_sinfo()
2582 sinfo->airtime_weight = sta->airtime_weight; in sta_set_sinfo()
2583 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_AIRTIME_WEIGHT); in sta_set_sinfo()
2586 sinfo->rx_dropped_misc = sta->deflink.rx_stats.dropped; in sta_set_sinfo()
2587 if (sta->deflink.pcpu_rx_stats) { in sta_set_sinfo()
2591 cpurxs = per_cpu_ptr(sta->deflink.pcpu_rx_stats, cpu); in sta_set_sinfo()
2592 sinfo->rx_dropped_misc += cpurxs->dropped; in sta_set_sinfo()
2596 if (sdata->vif.type == NL80211_IFTYPE_STATION && in sta_set_sinfo()
2597 !(sdata->vif.driver_flags & IEEE80211_VIF_BEACON_FILTER)) { in sta_set_sinfo()
2598 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_BEACON_RX) | in sta_set_sinfo()
2600 sinfo->rx_beacon_signal_avg = ieee80211_ave_rssi(&sdata->vif); in sta_set_sinfo()
2603 if (ieee80211_hw_check(&sta->local->hw, SIGNAL_DBM) || in sta_set_sinfo()
2604 ieee80211_hw_check(&sta->local->hw, SIGNAL_UNSPEC)) { in sta_set_sinfo()
2605 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_SIGNAL))) { in sta_set_sinfo()
2606 sinfo->signal = (s8)last_rxstats->last_signal; in sta_set_sinfo()
2607 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL); in sta_set_sinfo()
2610 if (!sta->deflink.pcpu_rx_stats && in sta_set_sinfo()
2611 !(sinfo->filled & BIT_ULL(NL80211_STA_INFO_SIGNAL_AVG))) { in sta_set_sinfo()
2612 sinfo->signal_avg = in sta_set_sinfo()
2613 -ewma_signal_read(&sta->deflink.rx_stats_avg.signal); in sta_set_sinfo()
2614 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL_AVG); in sta_set_sinfo()
2618 /* for the average - if pcpu_rx_stats isn't set - rxstats must point to in sta_set_sinfo()
2619 * the sta->rx_stats struct, so the check here is fine with and without in sta_set_sinfo()
2622 if (last_rxstats->chains && in sta_set_sinfo()
2623 !(sinfo->filled & (BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL) | in sta_set_sinfo()
2625 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL); in sta_set_sinfo()
2626 if (!sta->deflink.pcpu_rx_stats) in sta_set_sinfo()
2627 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL_AVG); in sta_set_sinfo()
2629 sinfo->chains = last_rxstats->chains; in sta_set_sinfo()
2631 for (i = 0; i < ARRAY_SIZE(sinfo->chain_signal); i++) { in sta_set_sinfo()
2632 sinfo->chain_signal[i] = in sta_set_sinfo()
2633 last_rxstats->chain_signal_last[i]; in sta_set_sinfo()
2634 sinfo->chain_signal_avg[i] = in sta_set_sinfo()
2635 -ewma_signal_read(&sta->deflink.rx_stats_avg.chain_signal[i]); in sta_set_sinfo()
2639 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_TX_BITRATE)) && in sta_set_sinfo()
2640 !sta->sta.valid_links) { in sta_set_sinfo()
2641 sta_set_rate_info_tx(sta, &sta->deflink.tx_stats.last_rate, in sta_set_sinfo()
2642 &sinfo->txrate); in sta_set_sinfo()
2643 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BITRATE); in sta_set_sinfo()
2646 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_RX_BITRATE)) && in sta_set_sinfo()
2647 !sta->sta.valid_links) { in sta_set_sinfo()
2648 if (sta_set_rate_info_rx(sta, &sinfo->rxrate) == 0) in sta_set_sinfo()
2649 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_BITRATE); in sta_set_sinfo()
2654 sta_set_tidstats(sta, &sinfo->pertid[i], i); in sta_set_sinfo()
2657 if (ieee80211_vif_is_mesh(&sdata->vif)) { in sta_set_sinfo()
2659 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_LLID) | in sta_set_sinfo()
2668 sinfo->llid = sta->mesh->llid; in sta_set_sinfo()
2669 sinfo->plid = sta->mesh->plid; in sta_set_sinfo()
2670 sinfo->plink_state = sta->mesh->plink_state; in sta_set_sinfo()
2672 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_T_OFFSET); in sta_set_sinfo()
2673 sinfo->t_offset = sta->mesh->t_offset; in sta_set_sinfo()
2675 sinfo->local_pm = sta->mesh->local_pm; in sta_set_sinfo()
2676 sinfo->peer_pm = sta->mesh->peer_pm; in sta_set_sinfo()
2677 sinfo->nonpeer_pm = sta->mesh->nonpeer_pm; in sta_set_sinfo()
2678 sinfo->connected_to_gate = sta->mesh->connected_to_gate; in sta_set_sinfo()
2679 sinfo->connected_to_as = sta->mesh->connected_to_as; in sta_set_sinfo()
2683 sinfo->bss_param.flags = 0; in sta_set_sinfo()
2684 if (sdata->vif.bss_conf.use_cts_prot) in sta_set_sinfo()
2685 sinfo->bss_param.flags |= BSS_PARAM_FLAGS_CTS_PROT; in sta_set_sinfo()
2686 if (sdata->vif.bss_conf.use_short_preamble) in sta_set_sinfo()
2687 sinfo->bss_param.flags |= BSS_PARAM_FLAGS_SHORT_PREAMBLE; in sta_set_sinfo()
2688 if (sdata->vif.bss_conf.use_short_slot) in sta_set_sinfo()
2689 sinfo->bss_param.flags |= BSS_PARAM_FLAGS_SHORT_SLOT_TIME; in sta_set_sinfo()
2690 sinfo->bss_param.dtim_period = sdata->vif.bss_conf.dtim_period; in sta_set_sinfo()
2691 sinfo->bss_param.beacon_interval = sdata->vif.bss_conf.beacon_int; in sta_set_sinfo()
2693 sinfo->sta_flags.set = 0; in sta_set_sinfo()
2694 sinfo->sta_flags.mask = BIT(NL80211_STA_FLAG_AUTHORIZED) | in sta_set_sinfo()
2702 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_AUTHORIZED); in sta_set_sinfo()
2704 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_SHORT_PREAMBLE); in sta_set_sinfo()
2705 if (sta->sta.wme) in sta_set_sinfo()
2706 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_WME); in sta_set_sinfo()
2708 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_MFP); in sta_set_sinfo()
2710 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_AUTHENTICATED); in sta_set_sinfo()
2712 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_ASSOCIATED); in sta_set_sinfo()
2714 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_TDLS_PEER); in sta_set_sinfo()
2719 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_EXPECTED_THROUGHPUT); in sta_set_sinfo()
2720 sinfo->expected_throughput = thr; in sta_set_sinfo()
2723 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_ACK_SIGNAL)) && in sta_set_sinfo()
2724 sta->deflink.status_stats.ack_signal_filled) { in sta_set_sinfo()
2725 sinfo->ack_signal = sta->deflink.status_stats.last_ack_signal; in sta_set_sinfo()
2726 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_ACK_SIGNAL); in sta_set_sinfo()
2729 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_ACK_SIGNAL_AVG)) && in sta_set_sinfo()
2730 sta->deflink.status_stats.ack_signal_filled) { in sta_set_sinfo()
2731 sinfo->avg_ack_signal = in sta_set_sinfo()
2732 -(s8)ewma_avg_signal_read( in sta_set_sinfo()
2733 &sta->deflink.status_stats.avg_ack_signal); in sta_set_sinfo()
2734 sinfo->filled |= in sta_set_sinfo()
2738 if (ieee80211_vif_is_mesh(&sdata->vif)) { in sta_set_sinfo()
2739 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_AIRTIME_LINK_METRIC); in sta_set_sinfo()
2740 sinfo->airtime_link_metric = in sta_set_sinfo()
2747 struct ieee80211_sub_if_data *sdata = sta->sdata; in sta_get_expected_throughput()
2748 struct ieee80211_local *local = sdata->local; in sta_get_expected_throughput()
2753 ref = local->rate_ctrl; in sta_get_expected_throughput()
2756 if (ref && ref->ops->get_expected_throughput) in sta_get_expected_throughput()
2757 thr = ref->ops->get_expected_throughput(sta->rate_ctrl_priv); in sta_get_expected_throughput()
2768 if (!sta->deflink.status_stats.last_ack || in ieee80211_sta_last_active()
2769 time_after(stats->last_rx, sta->deflink.status_stats.last_ack)) in ieee80211_sta_last_active()
2770 return stats->last_rx; in ieee80211_sta_last_active()
2771 return sta->deflink.status_stats.last_ack; in ieee80211_sta_last_active()
2776 if (!sta->sdata->local->ops->wake_tx_queue) in sta_update_codel_params()
2779 if (thr && thr < STA_SLOW_THRESHOLD * sta->local->num_sta) { in sta_update_codel_params()
2780 sta->cparams.target = MS2TIME(50); in sta_update_codel_params()
2781 sta->cparams.interval = MS2TIME(300); in sta_update_codel_params()
2782 sta->cparams.ecn = false; in sta_update_codel_params()
2784 sta->cparams.target = MS2TIME(20); in sta_update_codel_params()
2785 sta->cparams.interval = MS2TIME(100); in sta_update_codel_params()
2786 sta->cparams.ecn = true; in sta_update_codel_params()
2800 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_sta_allocate_link()
2804 lockdep_assert_held(&sdata->local->sta_mtx); in ieee80211_sta_allocate_link()
2807 if (WARN_ON(!sta->sta.valid_links)) in ieee80211_sta_allocate_link()
2808 return -EINVAL; in ieee80211_sta_allocate_link()
2810 if (WARN_ON(sta->sta.valid_links & BIT(link_id) || in ieee80211_sta_allocate_link()
2811 sta->link[link_id])) in ieee80211_sta_allocate_link()
2812 return -EBUSY; in ieee80211_sta_allocate_link()
2816 return -ENOMEM; in ieee80211_sta_allocate_link()
2818 ret = sta_info_alloc_link(sdata->local, &alloc->info, GFP_KERNEL); in ieee80211_sta_allocate_link()
2824 sta_info_add_link(sta, link_id, &alloc->info, &alloc->sta); in ieee80211_sta_allocate_link()
2831 lockdep_assert_held(&sta->sdata->local->sta_mtx); in ieee80211_sta_free_link()
2838 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_sta_activate_link()
2840 u16 old_links = sta->sta.valid_links; in ieee80211_sta_activate_link()
2844 link_sta = rcu_dereference_protected(sta->link[link_id], in ieee80211_sta_activate_link()
2845 lockdep_is_held(&sdata->local->sta_mtx)); in ieee80211_sta_activate_link()
2848 return -EINVAL; in ieee80211_sta_activate_link()
2851 if (link_sta_info_hash_lookup(sdata->local, link_sta->addr)) { in ieee80211_sta_activate_link()
2853 return -EALREADY; in ieee80211_sta_activate_link()
2858 sta->sta.valid_links = new_links; in ieee80211_sta_activate_link()
2866 ieee80211_sta_recalc_aggregates(&sta->sta); in ieee80211_sta_activate_link()
2868 ret = drv_change_sta_links(sdata->local, sdata, &sta->sta, in ieee80211_sta_activate_link()
2871 sta->sta.valid_links = old_links; in ieee80211_sta_activate_link()
2877 ret = link_sta_info_hash_add(sdata->local, link_sta); in ieee80211_sta_activate_link()
2884 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_sta_remove_link()
2885 u16 old_links = sta->sta.valid_links; in ieee80211_sta_remove_link()
2887 lockdep_assert_held(&sdata->local->sta_mtx); in ieee80211_sta_remove_link()
2889 sta->sta.valid_links &= ~BIT(link_id); in ieee80211_sta_remove_link()
2892 drv_change_sta_links(sdata->local, sdata, &sta->sta, in ieee80211_sta_remove_link()
2893 old_links, sta->sta.valid_links); in ieee80211_sta_remove_link()
2904 sta->sta.max_amsdu_subframes = 0; in ieee80211_sta_set_max_amsdu_subframes()
2918 sta->sta.max_amsdu_subframes = 4 << val; in ieee80211_sta_set_max_amsdu_subframes()
2926 return lockdep_is_held(&sta->local->sta_mtx); in lockdep_sta_mutex_held()