Lines Matching +full:num +full:- +full:txq

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"
47 * When the insertion fails (sta_info_insert()) returns non-zero), the
94 return rhltable_remove(&local->sta_hash, &sta->hash_node, in sta_info_hash_del()
101 lockdep_assert_wiphy(local->hw.wiphy); 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, link_sta_rht_params); in link_sta_info_hash_add()
110 lockdep_assert_wiphy(local->hw.wiphy); 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, link_sta_rht_params); in link_sta_info_hash_del()
118 struct ieee80211_local *local = sta->sdata->local; in ieee80211_purge_sta_txqs()
121 for (i = 0; i < ARRAY_SIZE(sta->sta.txq); i++) { in ieee80211_purge_sta_txqs()
124 if (!sta->sta.txq[i]) in ieee80211_purge_sta_txqs()
127 txqi = to_txq_info(sta->sta.txq[i]); in ieee80211_purge_sta_txqs()
137 struct ieee80211_sub_if_data *sdata = sta->sdata; in __cleanup_single_sta()
138 struct ieee80211_local *local = sdata->local; in __cleanup_single_sta()
144 if (sta->sdata->vif.type == NL80211_IFTYPE_AP || in __cleanup_single_sta()
145 sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN) in __cleanup_single_sta()
146 ps = &sdata->bss->ps; in __cleanup_single_sta()
147 else if (ieee80211_vif_is_mesh(&sdata->vif)) in __cleanup_single_sta()
148 ps = &sdata->u.mesh.ps; in __cleanup_single_sta()
156 atomic_dec(&ps->num_sta_ps); in __cleanup_single_sta()
162 local->total_ps_buffered -= skb_queue_len(&sta->ps_tx_buf[ac]); in __cleanup_single_sta()
163 ieee80211_purge_tx_queue(&local->hw, &sta->ps_tx_buf[ac]); in __cleanup_single_sta()
164 ieee80211_purge_tx_queue(&local->hw, &sta->tx_filtered[ac]); in __cleanup_single_sta()
167 if (ieee80211_vif_is_mesh(&sdata->vif)) in __cleanup_single_sta()
170 cancel_work_sync(&sta->drv_deliver_wk); in __cleanup_single_sta()
179 kfree(sta->ampdu_mlme.tid_start_tx[i]); in __cleanup_single_sta()
180 tid_tx = rcu_dereference_raw(sta->ampdu_mlme.tid_tx[i]); in __cleanup_single_sta()
183 ieee80211_purge_tx_queue(&local->hw, &tid_tx->pending); in __cleanup_single_sta()
190 struct ieee80211_sub_if_data *sdata = sta->sdata; in cleanup_single_sta()
191 struct ieee80211_local *local = sdata->local; in cleanup_single_sta()
200 return rhltable_lookup(&local->sta_hash, addr, sta_rht_params); in sta_info_hash_lookup()
207 struct ieee80211_local *local = sdata->local; in sta_info_get()
213 if (sta->sdata == sdata) { in sta_info_get()
232 struct ieee80211_local *local = sdata->local; in sta_info_get_bss()
238 if (sta->sdata == sdata || in sta_info_get_bss()
239 (sta->sdata->bss && sta->sdata->bss == sdata->bss)) { in sta_info_get_bss()
254 return rhltable_lookup(&local->link_sta_hash, addr, in link_sta_info_hash_lookup()
261 struct ieee80211_local *local = sdata->local; in link_sta_info_get_bss()
267 struct sta_info *sta = link_sta->sta; in link_sta_info_get_bss()
269 if (sta->sdata == sdata || in link_sta_info_get_bss()
270 (sta->sdata->bss && sta->sdata->bss == sdata->bss)) { in link_sta_info_get_bss()
293 struct sta_info *sta = link_sta->sta; in ieee80211_find_sta_by_link_addrs()
295 u8 _link_id = link_sta->link_id; in ieee80211_find_sta_by_link_addrs()
300 return &sta->sta; in ieee80211_find_sta_by_link_addrs()
303 link = rcu_dereference(sta->sdata->link[_link_id]); in ieee80211_find_sta_by_link_addrs()
307 if (memcmp(link->conf->addr, localaddr, ETH_ALEN)) in ieee80211_find_sta_by_link_addrs()
312 return &sta->sta; in ieee80211_find_sta_by_link_addrs()
326 if (ether_addr_equal(vif_addr, sta->sdata->vif.addr)) in sta_info_get_by_addrs()
336 struct ieee80211_local *local = sdata->local; in sta_info_get_by_idx()
340 list_for_each_entry_rcu(sta, &local->sta_list, list, in sta_info_get_by_idx()
341 lockdep_is_held(&local->hw.wiphy->mtx)) { in sta_info_get_by_idx()
342 if (sdata != sta->sdata) in sta_info_get_by_idx()
356 free_percpu(link_sta->pcpu_rx_stats); in sta_info_free_link()
365 lockdep_assert_wiphy(sta->local->hw.wiphy); in sta_remove_link()
367 link_sta = rcu_access_pointer(sta->link[link_id]); in sta_remove_link()
372 link_sta_info_hash_del(sta->local, link_sta); in sta_remove_link()
377 if (link_sta != &sta->deflink) in sta_remove_link()
380 sta->sta.valid_links &= ~BIT(link_id); in sta_remove_link()
381 RCU_INIT_POINTER(sta->link[link_id], NULL); in sta_remove_link()
382 RCU_INIT_POINTER(sta->sta.link[link_id], NULL); in sta_remove_link()
384 sta_info_free_link(&alloc->info); in sta_remove_link()
388 ieee80211_sta_recalc_aggregates(&sta->sta); in sta_remove_link()
392 * sta_info_free - free STA
406 for (i = 0; i < ARRAY_SIZE(sta->link); i++) { in sta_info_free()
409 link_sta = rcu_access_pointer(sta->link[i]); in sta_info_free()
424 while (sta->sta_state > IEEE80211_STA_NONE) { in sta_info_free()
429 ret = sta_info_move_state(sta, sta->sta_state - 1); in sta_info_free()
434 if (sta->rate_ctrl) in sta_info_free()
437 sta_dbg(sta->sdata, "Destroyed STA %pM\n", sta->sta.addr); in sta_info_free()
439 kfree(to_txq_info(sta->sta.txq[0])); in sta_info_free()
440 kfree(rcu_dereference_raw(sta->sta.rates)); in sta_info_free()
442 kfree(sta->mesh); in sta_info_free()
445 sta_info_free_link(&sta->deflink); in sta_info_free()
452 return rhltable_insert(&local->sta_hash, &sta->hash_node, in sta_info_hash_add()
462 if (sta->dead) in sta_deliver_ps_frames()
478 if (ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL)) in sta_prepare_rate_control()
481 sta->rate_ctrl = local->rate_ctrl; in sta_prepare_rate_control()
482 sta->rate_ctrl_priv = rate_control_alloc_sta(sta->rate_ctrl, in sta_prepare_rate_control()
484 if (!sta->rate_ctrl_priv) in sta_prepare_rate_control()
485 return -ENOMEM; in sta_prepare_rate_control()
494 struct ieee80211_hw *hw = &local->hw; in sta_info_alloc_link()
498 link_info->pcpu_rx_stats = in sta_info_alloc_link()
500 if (!link_info->pcpu_rx_stats) in sta_info_alloc_link()
501 return -ENOMEM; in sta_info_alloc_link()
504 link_info->rx_stats.last_rx = jiffies; in sta_info_alloc_link()
505 u64_stats_init(&link_info->rx_stats.syncp); in sta_info_alloc_link()
507 ewma_signal_init(&link_info->rx_stats_avg.signal); in sta_info_alloc_link()
508 ewma_avg_signal_init(&link_info->status_stats.avg_ack_signal); in sta_info_alloc_link()
509 for (i = 0; i < ARRAY_SIZE(link_info->rx_stats_avg.chain_signal); i++) in sta_info_alloc_link()
510 ewma_signal_init(&link_info->rx_stats_avg.chain_signal[i]); in sta_info_alloc_link()
512 link_info->rx_omi_bw_rx = IEEE80211_STA_RX_BW_MAX; in sta_info_alloc_link()
513 link_info->rx_omi_bw_tx = IEEE80211_STA_RX_BW_MAX; in sta_info_alloc_link()
514 link_info->rx_omi_bw_staging = IEEE80211_STA_RX_BW_MAX; in sta_info_alloc_link()
520 switch (link_info->cur_max_bandwidth) { in sta_info_alloc_link()
538 link_info->sta = sta; in sta_info_add_link()
539 link_info->link_id = link_id; in sta_info_add_link()
540 link_info->pub = link_sta; in sta_info_add_link()
541 link_info->pub->sta = &sta->sta; in sta_info_add_link()
542 link_sta->link_id = link_id; in sta_info_add_link()
543 rcu_assign_pointer(sta->link[link_id], link_info); in sta_info_add_link()
544 rcu_assign_pointer(sta->sta.link[link_id], link_sta); in sta_info_add_link()
546 link_sta->smps_mode = IEEE80211_SMPS_OFF; in sta_info_add_link()
547 link_sta->agg.max_rc_amsdu_len = IEEE80211_MAX_MPDU_LEN_HT_BA; in sta_info_add_link()
555 struct ieee80211_local *local = sdata->local; in __sta_info_alloc()
556 struct ieee80211_hw *hw = &local->hw; in __sta_info_alloc()
562 sta = kzalloc(sizeof(*sta) + hw->sta_data_size, gfp); in __sta_info_alloc()
566 sta->local = local; in __sta_info_alloc()
567 sta->sdata = sdata; in __sta_info_alloc()
569 if (sta_info_alloc_link(local, &sta->deflink, gfp)) in __sta_info_alloc()
573 sta_info_add_link(sta, link_id, &sta->deflink, in __sta_info_alloc()
574 &sta->sta.deflink); in __sta_info_alloc()
575 sta->sta.valid_links = BIT(link_id); in __sta_info_alloc()
577 sta_info_add_link(sta, 0, &sta->deflink, &sta->sta.deflink); in __sta_info_alloc()
580 sta->sta.cur = &sta->sta.deflink.agg; in __sta_info_alloc()
582 spin_lock_init(&sta->lock); in __sta_info_alloc()
583 spin_lock_init(&sta->ps_lock); in __sta_info_alloc()
584 INIT_WORK(&sta->drv_deliver_wk, sta_deliver_ps_frames); in __sta_info_alloc()
585 wiphy_work_init(&sta->ampdu_mlme.work, ieee80211_ba_session_work); in __sta_info_alloc()
587 if (ieee80211_vif_is_mesh(&sdata->vif)) { in __sta_info_alloc()
588 sta->mesh = kzalloc(sizeof(*sta->mesh), gfp); in __sta_info_alloc()
589 if (!sta->mesh) in __sta_info_alloc()
591 sta->mesh->plink_sta = sta; in __sta_info_alloc()
592 spin_lock_init(&sta->mesh->plink_lock); in __sta_info_alloc()
593 if (!sdata->u.mesh.user_mpm) in __sta_info_alloc()
594 timer_setup(&sta->mesh->plink_timer, mesh_plink_timer, in __sta_info_alloc()
596 sta->mesh->nonpeer_pm = NL80211_MESH_POWER_ACTIVE; in __sta_info_alloc()
600 memcpy(sta->addr, addr, ETH_ALEN); in __sta_info_alloc()
601 memcpy(sta->sta.addr, addr, ETH_ALEN); in __sta_info_alloc()
602 memcpy(sta->deflink.addr, link_addr, ETH_ALEN); in __sta_info_alloc()
603 memcpy(sta->sta.deflink.addr, link_addr, ETH_ALEN); in __sta_info_alloc()
604 sta->sta.max_rx_aggregation_subframes = in __sta_info_alloc()
605 local->hw.max_rx_aggregation_subframes; in __sta_info_alloc()
609 /* Extended Key ID needs to install keys for keyid 0 and 1 Rx-only. in __sta_info_alloc()
611 * references to is not NULL. To not use the initial Rx-only key in __sta_info_alloc()
615 BUILD_BUG_ON(ARRAY_SIZE(sta->ptk) <= INVALID_PTK_KEYIDX); in __sta_info_alloc()
616 sta->ptk_idx = INVALID_PTK_KEYIDX; in __sta_info_alloc()
619 ieee80211_init_frag_cache(&sta->frags); in __sta_info_alloc()
621 sta->sta_state = IEEE80211_STA_NONE; in __sta_info_alloc()
623 if (sdata->vif.type == NL80211_IFTYPE_MESH_POINT) in __sta_info_alloc()
624 sta->amsdu_mesh_control = -1; in __sta_info_alloc()
627 sta->reserved_tid = IEEE80211_TID_UNRESERVED; in __sta_info_alloc()
629 sta->last_connected = ktime_get_seconds(); in __sta_info_alloc()
632 ALIGN(hw->txq_data_size, sizeof(void *)); in __sta_info_alloc()
634 txq_data = kcalloc(ARRAY_SIZE(sta->sta.txq), size, gfp); in __sta_info_alloc()
638 for (i = 0; i < ARRAY_SIZE(sta->sta.txq); i++) { in __sta_info_alloc()
639 struct txq_info *txq = txq_data + i * size; in __sta_info_alloc() local
641 /* might not do anything for the (bufferable) MMPDU TXQ */ in __sta_info_alloc()
642 ieee80211_txq_init(sdata, sta, txq, i); in __sta_info_alloc()
648 sta->airtime_weight = IEEE80211_DEFAULT_AIRTIME_WEIGHT; in __sta_info_alloc()
651 skb_queue_head_init(&sta->ps_tx_buf[i]); in __sta_info_alloc()
652 skb_queue_head_init(&sta->tx_filtered[i]); in __sta_info_alloc()
653 sta->airtime[i].deficit = sta->airtime_weight; in __sta_info_alloc()
654 atomic_set(&sta->airtime[i].aql_tx_pending, 0); in __sta_info_alloc()
655 sta->airtime[i].aql_limit_low = local->aql_txq_limit_low[i]; in __sta_info_alloc()
656 sta->airtime[i].aql_limit_high = local->aql_txq_limit_high[i]; in __sta_info_alloc()
660 sta->last_seq_ctrl[i] = cpu_to_le16(USHRT_MAX); in __sta_info_alloc()
666 if (!hw->wiphy->bands[i]) in __sta_info_alloc()
693 for (r = 0; r < hw->wiphy->bands[i]->n_bitrates; r++) { in __sta_info_alloc()
696 rate = &hw->wiphy->bands[i]->bitrates[r]; in __sta_info_alloc()
698 if (!(rate->flags & mandatory)) in __sta_info_alloc()
700 sta->sta.deflink.supp_rates[i] |= BIT(r); in __sta_info_alloc()
704 sta->cparams.ce_threshold = CODEL_DISABLED_THRESHOLD; in __sta_info_alloc()
705 sta->cparams.target = MS2TIME(20); in __sta_info_alloc()
706 sta->cparams.interval = MS2TIME(100); in __sta_info_alloc()
707 sta->cparams.ecn = true; in __sta_info_alloc()
708 sta->cparams.ce_threshold_selector = 0; in __sta_info_alloc()
709 sta->cparams.ce_threshold_mask = 0; in __sta_info_alloc()
711 sta_dbg(sdata, "Allocated STA %pM\n", sta->sta.addr); in __sta_info_alloc()
716 kfree(to_txq_info(sta->sta.txq[0])); in __sta_info_alloc()
718 sta_info_free_link(&sta->deflink); in __sta_info_alloc()
720 kfree(sta->mesh); in __sta_info_alloc()
729 return __sta_info_alloc(sdata, addr, -1, addr, gfp); in sta_info_alloc()
743 struct ieee80211_sub_if_data *sdata = sta->sdata; in sta_info_insert_check()
745 lockdep_assert_wiphy(sdata->local->hw.wiphy); in sta_info_insert_check()
753 return -ENETDOWN; in sta_info_insert_check()
755 if (WARN_ON(ether_addr_equal(sta->sta.addr, sdata->vif.addr) || in sta_info_insert_check()
756 !is_valid_ether_addr(sta->sta.addr))) in sta_info_insert_check()
757 return -EINVAL; in sta_info_insert_check()
764 if (ieee80211_hw_check(&sdata->local->hw, NEEDS_UNIQUE_STA_ADDR) && in sta_info_insert_check()
765 ieee80211_find_sta_by_ifaddr(&sdata->local->hw, sta->addr, NULL)) { in sta_info_insert_check()
767 return -ENOTUNIQ; in sta_info_insert_check()
781 for (state = IEEE80211_STA_NOTEXIST; state < sta->sta_state; state++) { in sta_info_insert_drv_state()
792 if (!local->ops->sta_add) in sta_info_insert_drv_state()
793 sta->uploaded = true; in sta_info_insert_drv_state()
797 if (sdata->vif.type == NL80211_IFTYPE_ADHOC) { in sta_info_insert_drv_state()
799 "failed to move IBSS STA %pM to state %d (%d) - keeping it anyway\n", in sta_info_insert_drv_state()
800 sta->sta.addr, state + 1, err); in sta_info_insert_drv_state()
805 for (; state > IEEE80211_STA_NOTEXIST; state--) in sta_info_insert_drv_state()
806 WARN_ON(drv_sta_state(local, sdata, sta, state, state - 1)); in sta_info_insert_drv_state()
814 struct ieee80211_local *local = sdata->local; in ieee80211_recalc_p2p_go_ps_allowed()
815 bool allow_p2p_go_ps = sdata->vif.p2p; in ieee80211_recalc_p2p_go_ps_allowed()
819 list_for_each_entry_rcu(sta, &local->sta_list, list) { in ieee80211_recalc_p2p_go_ps_allowed()
820 if (sdata != sta->sdata || in ieee80211_recalc_p2p_go_ps_allowed()
823 if (!sta->sta.support_p2p_ps) { in ieee80211_recalc_p2p_go_ps_allowed()
830 if (allow_p2p_go_ps != sdata->vif.bss_conf.allow_p2p_go_ps) { in ieee80211_recalc_p2p_go_ps_allowed()
831 sdata->vif.bss_conf.allow_p2p_go_ps = allow_p2p_go_ps; in ieee80211_recalc_p2p_go_ps_allowed()
832 ieee80211_link_info_change_notify(sdata, &sdata->deflink, in ieee80211_recalc_p2p_go_ps_allowed()
839 struct ieee80211_local *local = sta->local; in sta_info_insert_finish()
840 struct ieee80211_sub_if_data *sdata = sta->sdata; in sta_info_insert_finish()
844 lockdep_assert_wiphy(local->hw.wiphy); in sta_info_insert_finish()
847 if (sta_info_get_bss(sdata, sta->sta.addr)) { in sta_info_insert_finish()
848 err = -EEXIST; in sta_info_insert_finish()
854 err = -ENOMEM; in sta_info_insert_finish()
858 local->num_sta++; in sta_info_insert_finish()
859 local->sta_generation++; in sta_info_insert_finish()
870 if (sta->sta.valid_links) { in sta_info_insert_finish()
871 err = link_sta_info_hash_add(local, &sta->deflink); in sta_info_insert_finish()
878 list_add_tail_rcu(&sta->list, &local->sta_list); in sta_info_insert_finish()
883 if (sta->sta_state >= IEEE80211_STA_ASSOC) { in sta_info_insert_finish()
884 ieee80211_recalc_min_chandef(sta->sdata, -1); in sta_info_insert_finish()
885 if (!sta->sta.support_p2p_ps) in sta_info_insert_finish()
886 ieee80211_recalc_p2p_go_ps_allowed(sta->sdata); in sta_info_insert_finish()
901 if (sta->sta.valid_links) { in sta_info_insert_finish()
904 for (i = 0; i < ARRAY_SIZE(sta->link); i++) { in sta_info_insert_finish()
907 link_sta = rcu_dereference_protected(sta->link[i], in sta_info_insert_finish()
908 lockdep_is_held(&local->hw.wiphy->mtx)); in sta_info_insert_finish()
914 if (sdata->vif.active_links & BIT(i)) in sta_info_insert_finish()
918 ieee80211_link_sta_debugfs_add(&sta->deflink); in sta_info_insert_finish()
919 ieee80211_link_sta_debugfs_drv_add(&sta->deflink); in sta_info_insert_finish()
922 sinfo->generation = local->sta_generation; in sta_info_insert_finish()
923 cfg80211_new_sta(sdata->dev, sta->sta.addr, sinfo, GFP_KERNEL); in sta_info_insert_finish()
926 sta_dbg(sdata, "Inserted STA %pM\n", sta->sta.addr); in sta_info_insert_finish()
928 /* move reference to rcu-protected */ in sta_info_insert_finish()
931 if (ieee80211_vif_is_mesh(&sdata->vif)) in sta_info_insert_finish()
938 if (sta->sta.valid_links) in sta_info_insert_finish()
939 link_sta_info_hash_del(local, &sta->deflink); in sta_info_insert_finish()
941 list_del_rcu(&sta->list); in sta_info_insert_finish()
943 local->num_sta--; in sta_info_insert_finish()
954 struct ieee80211_local *local = sta->local; in sta_info_insert_rcu()
958 lockdep_assert_wiphy(local->hw.wiphy); in sta_info_insert_rcu()
1026 struct ieee80211_local *local = sta->local; in __sta_info_recalc_tim()
1029 u8 ignore_for_tim = sta->sta.uapsd_queues; in __sta_info_recalc_tim()
1031 u16 id = sta->sta.aid; in __sta_info_recalc_tim()
1033 if (sta->sdata->vif.type == NL80211_IFTYPE_AP || in __sta_info_recalc_tim()
1034 sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN) { in __sta_info_recalc_tim()
1035 if (WARN_ON_ONCE(!sta->sdata->bss)) in __sta_info_recalc_tim()
1038 ps = &sta->sdata->bss->ps; in __sta_info_recalc_tim()
1040 } else if (ieee80211_vif_is_mesh(&sta->sdata->vif)) { in __sta_info_recalc_tim()
1041 ps = &sta->sdata->u.mesh.ps; in __sta_info_recalc_tim()
1048 if (ieee80211_hw_check(&local->hw, AP_LINK_PS) && !local->ops->set_tim) in __sta_info_recalc_tim()
1051 if (sta->dead) in __sta_info_recalc_tim()
1055 * If all ACs are delivery-enabled then we should build in __sta_info_recalc_tim()
1058 * non-enabled ones. in __sta_info_recalc_tim()
1060 if (ignore_for_tim == BIT(IEEE80211_NUM_ACS) - 1) in __sta_info_recalc_tim()
1064 ignore_for_tim = BIT(IEEE80211_NUM_ACS) - 1; in __sta_info_recalc_tim()
1072 indicate_tim |= !skb_queue_empty(&sta->tx_filtered[ac]) || in __sta_info_recalc_tim()
1073 !skb_queue_empty(&sta->ps_tx_buf[ac]); in __sta_info_recalc_tim()
1080 sta->driver_buffered_tids & tids; in __sta_info_recalc_tim()
1082 sta->txq_buffered_tids & tids; in __sta_info_recalc_tim()
1086 spin_lock_bh(&local->tim_lock); in __sta_info_recalc_tim()
1088 if (indicate_tim == __bss_tim_get(ps->tim, id)) in __sta_info_recalc_tim()
1092 __bss_tim_set(ps->tim, id); in __sta_info_recalc_tim()
1094 __bss_tim_clear(ps->tim, id); in __sta_info_recalc_tim()
1096 if (local->ops->set_tim && !WARN_ON(sta->dead)) { in __sta_info_recalc_tim()
1097 local->tim_in_locked_section = true; in __sta_info_recalc_tim()
1098 drv_set_tim(local, &sta->sta, indicate_tim); in __sta_info_recalc_tim()
1099 local->tim_in_locked_section = false; in __sta_info_recalc_tim()
1103 spin_unlock_bh(&local->tim_lock); in __sta_info_recalc_tim()
1122 timeout = (sta->listen_interval * in sta_info_buffer_expired()
1123 sta->sdata->vif.bss_conf.beacon_int * in sta_info_buffer_expired()
1127 return time_after(jiffies, info->control.jiffies + timeout); in sta_info_buffer_expired()
1140 * a separate queue to avoid reordering with normal PS-buffered in sta_info_cleanup_expire_buffered_ac()
1145 spin_lock_irqsave(&sta->tx_filtered[ac].lock, flags); in sta_info_cleanup_expire_buffered_ac()
1146 skb = skb_peek(&sta->tx_filtered[ac]); in sta_info_cleanup_expire_buffered_ac()
1148 skb = __skb_dequeue(&sta->tx_filtered[ac]); in sta_info_cleanup_expire_buffered_ac()
1151 spin_unlock_irqrestore(&sta->tx_filtered[ac].lock, flags); in sta_info_cleanup_expire_buffered_ac()
1161 ieee80211_free_txskb(&local->hw, skb); in sta_info_cleanup_expire_buffered_ac()
1165 * Now also check the normal PS-buffered queue, this will in sta_info_cleanup_expire_buffered_ac()
1171 spin_lock_irqsave(&sta->ps_tx_buf[ac].lock, flags); in sta_info_cleanup_expire_buffered_ac()
1172 skb = skb_peek(&sta->ps_tx_buf[ac]); in sta_info_cleanup_expire_buffered_ac()
1174 skb = __skb_dequeue(&sta->ps_tx_buf[ac]); in sta_info_cleanup_expire_buffered_ac()
1177 spin_unlock_irqrestore(&sta->ps_tx_buf[ac].lock, flags); in sta_info_cleanup_expire_buffered_ac()
1187 local->total_ps_buffered--; in sta_info_cleanup_expire_buffered_ac()
1188 ps_dbg(sta->sdata, "Buffered frame expired (STA %pM)\n", in sta_info_cleanup_expire_buffered_ac()
1189 sta->sta.addr); in sta_info_cleanup_expire_buffered_ac()
1190 ieee80211_free_txskb(&local->hw, skb); in sta_info_cleanup_expire_buffered_ac()
1194 * Finally, recalculate the TIM bit for this station -- it might in sta_info_cleanup_expire_buffered_ac()
1205 return !(skb_queue_empty(&sta->ps_tx_buf[ac]) && in sta_info_cleanup_expire_buffered_ac()
1206 skb_queue_empty(&sta->tx_filtered[ac])); in sta_info_cleanup_expire_buffered_ac()
1216 if (!sta->sdata->bss && in sta_info_cleanup_expire_buffered()
1217 !ieee80211_vif_is_mesh(&sta->sdata->vif)) in sta_info_cleanup_expire_buffered()
1236 return -ENOENT; in __sta_info_destroy_part1()
1238 local = sta->local; in __sta_info_destroy_part1()
1239 sdata = sta->sdata; in __sta_info_destroy_part1()
1241 lockdep_assert_wiphy(local->hw.wiphy); in __sta_info_destroy_part1()
1246 * sessions -- block that to make sure the tear-down in __sta_info_destroy_part1()
1254 * rx frames on RSS queues sent prior to the disassociation - wait for in __sta_info_destroy_part1()
1259 for (i = 0; i < ARRAY_SIZE(sta->link); i++) { in __sta_info_destroy_part1()
1262 if (!(sta->sta.valid_links & BIT(i))) in __sta_info_destroy_part1()
1265 link_sta = rcu_dereference_protected(sta->link[i], in __sta_info_destroy_part1()
1266 lockdep_is_held(&local->hw.wiphy->mtx)); in __sta_info_destroy_part1()
1280 drv_tdls_cancel_channel_switch(local, sdata, &sta->sta); in __sta_info_destroy_part1()
1284 list_del_rcu(&sta->list); in __sta_info_destroy_part1()
1285 sta->removed = true; in __sta_info_destroy_part1()
1287 if (sta->uploaded) in __sta_info_destroy_part1()
1288 drv_sta_pre_rcu_remove(local, sta->sdata, sta); in __sta_info_destroy_part1()
1290 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN && in __sta_info_destroy_part1()
1291 rcu_access_pointer(sdata->u.vlan.sta) == sta) in __sta_info_destroy_part1()
1292 RCU_INIT_POINTER(sdata->u.vlan.sta, NULL); in __sta_info_destroy_part1()
1301 struct ieee80211_local *local = sta->local; in _sta_info_move_state()
1305 if (sta->sta_state == new_state) in _sta_info_move_state()
1312 if (sta->sta_state != IEEE80211_STA_AUTH) in _sta_info_move_state()
1313 return -EINVAL; in _sta_info_move_state()
1316 if (sta->sta_state != IEEE80211_STA_NONE && in _sta_info_move_state()
1317 sta->sta_state != IEEE80211_STA_ASSOC) in _sta_info_move_state()
1318 return -EINVAL; in _sta_info_move_state()
1321 if (sta->sta_state != IEEE80211_STA_AUTH && in _sta_info_move_state()
1322 sta->sta_state != IEEE80211_STA_AUTHORIZED) in _sta_info_move_state()
1323 return -EINVAL; in _sta_info_move_state()
1326 if (sta->sta_state != IEEE80211_STA_ASSOC) in _sta_info_move_state()
1327 return -EINVAL; in _sta_info_move_state()
1331 return -EINVAL; in _sta_info_move_state()
1334 sta_dbg(sta->sdata, "moving STA %pM to state %d\n", in _sta_info_move_state()
1335 sta->sta.addr, new_state); in _sta_info_move_state()
1343 if (new_state > sta->sta_state && in _sta_info_move_state()
1345 int err = drv_sta_state(sta->local, sta->sdata, sta, in _sta_info_move_state()
1346 sta->sta_state, new_state); in _sta_info_move_state()
1355 if (sta->sta_state == IEEE80211_STA_AUTH) in _sta_info_move_state()
1356 clear_bit(WLAN_STA_AUTH, &sta->_flags); in _sta_info_move_state()
1359 if (sta->sta_state == IEEE80211_STA_NONE) { in _sta_info_move_state()
1360 set_bit(WLAN_STA_AUTH, &sta->_flags); in _sta_info_move_state()
1361 } else if (sta->sta_state == IEEE80211_STA_ASSOC) { in _sta_info_move_state()
1362 clear_bit(WLAN_STA_ASSOC, &sta->_flags); in _sta_info_move_state()
1364 ieee80211_recalc_min_chandef(sta->sdata, -1); in _sta_info_move_state()
1365 if (!sta->sta.support_p2p_ps) in _sta_info_move_state()
1366 ieee80211_recalc_p2p_go_ps_allowed(sta->sdata); in _sta_info_move_state()
1371 if (sta->sta_state == IEEE80211_STA_AUTH) { in _sta_info_move_state()
1372 set_bit(WLAN_STA_ASSOC, &sta->_flags); in _sta_info_move_state()
1373 sta->assoc_at = ktime_get_boottime_ns(); in _sta_info_move_state()
1375 ieee80211_recalc_min_chandef(sta->sdata, -1); in _sta_info_move_state()
1376 if (!sta->sta.support_p2p_ps) in _sta_info_move_state()
1377 ieee80211_recalc_p2p_go_ps_allowed(sta->sdata); in _sta_info_move_state()
1379 } else if (sta->sta_state == IEEE80211_STA_AUTHORIZED) { in _sta_info_move_state()
1380 ieee80211_vif_dec_num_mcast(sta->sdata); in _sta_info_move_state()
1381 clear_bit(WLAN_STA_AUTHORIZED, &sta->_flags); in _sta_info_move_state()
1390 if (local->ops->set_key) { in _sta_info_move_state()
1392 if (local->ops->flush_sta) in _sta_info_move_state()
1393 drv_flush_sta(local, sta->sdata, sta); in _sta_info_move_state()
1396 sta->sdata, in _sta_info_move_state()
1405 if (sta->sta_state == IEEE80211_STA_ASSOC) { in _sta_info_move_state()
1406 ieee80211_vif_inc_num_mcast(sta->sdata); in _sta_info_move_state()
1407 set_bit(WLAN_STA_AUTHORIZED, &sta->_flags); in _sta_info_move_state()
1411 if (sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN || in _sta_info_move_state()
1412 sta->sdata->vif.type == NL80211_IFTYPE_AP) in _sta_info_move_state()
1413 cfg80211_send_layer2_update(sta->sdata->dev, in _sta_info_move_state()
1414 sta->sta.addr); in _sta_info_move_state()
1420 if (new_state < sta->sta_state && in _sta_info_move_state()
1422 int err = drv_sta_state(sta->local, sta->sdata, sta, in _sta_info_move_state()
1423 sta->sta_state, new_state); in _sta_info_move_state()
1430 sta->sta_state = new_state; in _sta_info_move_state()
1443 struct ieee80211_local *local = sta->local; in __sta_info_destroy_part2()
1444 struct ieee80211_sub_if_data *sdata = sta->sdata; in __sta_info_destroy_part2()
1468 lockdep_assert_wiphy(local->hw.wiphy); in __sta_info_destroy_part2()
1470 if (sta->sta_state == IEEE80211_STA_AUTHORIZED) { in __sta_info_destroy_part2()
1478 /* disable TIM bit - last chance to tell driver */ in __sta_info_destroy_part2()
1481 sta->dead = true; in __sta_info_destroy_part2()
1483 local->num_sta--; in __sta_info_destroy_part2()
1484 local->sta_generation++; in __sta_info_destroy_part2()
1486 while (sta->sta_state > IEEE80211_STA_NONE) { in __sta_info_destroy_part2()
1487 ret = _sta_info_move_state(sta, sta->sta_state - 1, recalc); in __sta_info_destroy_part2()
1494 if (sta->uploaded) { in __sta_info_destroy_part2()
1500 sta_dbg(sdata, "Removed STA %pM\n", sta->sta.addr); in __sta_info_destroy_part2()
1505 cfg80211_del_sta_sinfo(sdata->dev, sta->sta.addr, sinfo, GFP_KERNEL); in __sta_info_destroy_part2()
1510 ieee80211_destroy_frag_cache(&sta->frags); in __sta_info_destroy_part2()
1533 lockdep_assert_wiphy(sdata->local->hw.wiphy); in sta_info_destroy_addr()
1544 lockdep_assert_wiphy(sdata->local->hw.wiphy); in sta_info_destroy_addr_bss()
1557 list_for_each_entry_rcu(sta, &local->sta_list, list) in sta_info_cleanup()
1562 if (local->quiescing) in sta_info_cleanup()
1568 mod_timer(&local->sta_cleanup, in sta_info_cleanup()
1576 err = rhltable_init(&local->sta_hash, &sta_rht_params); in sta_info_init()
1580 err = rhltable_init(&local->link_sta_hash, &link_sta_rht_params); in sta_info_init()
1582 rhltable_destroy(&local->sta_hash); in sta_info_init()
1586 spin_lock_init(&local->tim_lock); in sta_info_init()
1587 INIT_LIST_HEAD(&local->sta_list); in sta_info_init()
1589 timer_setup(&local->sta_cleanup, sta_info_cleanup, 0); in sta_info_init()
1595 del_timer_sync(&local->sta_cleanup); in sta_info_stop()
1596 rhltable_destroy(&local->sta_hash); in sta_info_stop()
1597 rhltable_destroy(&local->link_sta_hash); in sta_info_stop()
1604 struct ieee80211_local *local = sdata->local; in __sta_info_flush()
1610 lockdep_assert_wiphy(local->hw.wiphy); in __sta_info_flush()
1612 WARN_ON(vlans && sdata->vif.type != NL80211_IFTYPE_AP); in __sta_info_flush()
1613 WARN_ON(vlans && !sdata->bss); in __sta_info_flush()
1615 list_for_each_entry_safe(sta, tmp, &local->sta_list, list) { in __sta_info_flush()
1616 if (sdata != sta->sdata && in __sta_info_flush()
1617 (!vlans || sdata->bss != sta->sdata->bss)) in __sta_info_flush()
1623 if (link_id >= 0 && sta->sta.valid_links && in __sta_info_flush()
1624 !(sta->sta.valid_links & BIT(link_id))) in __sta_info_flush()
1628 list_add(&sta->free_list, &free_list); in __sta_info_flush()
1638 if (!sta->sta.support_p2p_ps) in __sta_info_flush()
1643 ieee80211_recalc_min_chandef(sdata, -1); in __sta_info_flush()
1654 struct ieee80211_local *local = sdata->local; in ieee80211_sta_expire()
1657 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_sta_expire()
1659 list_for_each_entry_safe(sta, tmp, &local->sta_list, list) { in ieee80211_sta_expire()
1662 if (sdata != sta->sdata) in ieee80211_sta_expire()
1666 sta_dbg(sta->sdata, "expiring inactive STA %pM\n", in ieee80211_sta_expire()
1667 sta->sta.addr); in ieee80211_sta_expire()
1669 if (ieee80211_vif_is_mesh(&sdata->vif) && in ieee80211_sta_expire()
1671 atomic_dec(&sdata->u.mesh.ps.num_sta_ps); in ieee80211_sta_expire()
1692 !ether_addr_equal(sta->sdata->vif.addr, localaddr)) in ieee80211_find_sta_by_ifaddr()
1694 if (!sta->uploaded) in ieee80211_find_sta_by_ifaddr()
1696 return &sta->sta; in ieee80211_find_sta_by_ifaddr()
1715 if (!sta->uploaded) in ieee80211_find_sta()
1718 return &sta->sta; in ieee80211_find_sta()
1725 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_sta_ps_deliver_wakeup()
1726 struct ieee80211_local *local = sdata->local; in ieee80211_sta_ps_deliver_wakeup()
1732 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) in ieee80211_sta_ps_deliver_wakeup()
1733 sdata = container_of(sdata->bss, struct ieee80211_sub_if_data, in ieee80211_sta_ps_deliver_wakeup()
1736 if (sdata->vif.type == NL80211_IFTYPE_AP) in ieee80211_sta_ps_deliver_wakeup()
1737 ps = &sdata->bss->ps; in ieee80211_sta_ps_deliver_wakeup()
1738 else if (ieee80211_vif_is_mesh(&sdata->vif)) in ieee80211_sta_ps_deliver_wakeup()
1739 ps = &sdata->u.mesh.ps; in ieee80211_sta_ps_deliver_wakeup()
1746 sta->driver_buffered_tids = 0; in ieee80211_sta_ps_deliver_wakeup()
1747 sta->txq_buffered_tids = 0; in ieee80211_sta_ps_deliver_wakeup()
1749 if (!ieee80211_hw_check(&local->hw, AP_LINK_PS)) in ieee80211_sta_ps_deliver_wakeup()
1750 drv_sta_notify(local, sdata, STA_NOTIFY_AWAKE, &sta->sta); in ieee80211_sta_ps_deliver_wakeup()
1752 for (i = 0; i < ARRAY_SIZE(sta->sta.txq); i++) { in ieee80211_sta_ps_deliver_wakeup()
1753 if (!sta->sta.txq[i] || !txq_has_queue(sta->sta.txq[i])) in ieee80211_sta_ps_deliver_wakeup()
1756 schedule_and_wake_txq(local, to_txq_info(sta->sta.txq[i])); in ieee80211_sta_ps_deliver_wakeup()
1762 spin_lock_bh(&sta->ps_lock); in ieee80211_sta_ps_deliver_wakeup()
1767 spin_lock_irqsave(&sta->tx_filtered[ac].lock, flags); in ieee80211_sta_ps_deliver_wakeup()
1768 skb_queue_splice_tail_init(&sta->tx_filtered[ac], &pending); in ieee80211_sta_ps_deliver_wakeup()
1769 spin_unlock_irqrestore(&sta->tx_filtered[ac].lock, flags); in ieee80211_sta_ps_deliver_wakeup()
1771 filtered += tmp - count; in ieee80211_sta_ps_deliver_wakeup()
1774 spin_lock_irqsave(&sta->ps_tx_buf[ac].lock, flags); in ieee80211_sta_ps_deliver_wakeup()
1775 skb_queue_splice_tail_init(&sta->ps_tx_buf[ac], &pending); in ieee80211_sta_ps_deliver_wakeup()
1776 spin_unlock_irqrestore(&sta->ps_tx_buf[ac].lock, flags); in ieee80211_sta_ps_deliver_wakeup()
1778 buffered += tmp - count; in ieee80211_sta_ps_deliver_wakeup()
1791 spin_unlock_bh(&sta->ps_lock); in ieee80211_sta_ps_deliver_wakeup()
1793 atomic_dec(&ps->num_sta_ps); in ieee80211_sta_ps_deliver_wakeup()
1795 local->total_ps_buffered -= buffered; in ieee80211_sta_ps_deliver_wakeup()
1801 sta->sta.addr, sta->sta.aid, filtered, buffered); in ieee80211_sta_ps_deliver_wakeup()
1810 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_send_null_response()
1811 struct ieee80211_local *local = sdata->local; in ieee80211_send_null_response()
1816 bool qos = sta->sta.wme; in ieee80211_send_null_response()
1825 size -= 2; in ieee80211_send_null_response()
1831 skb = dev_alloc_skb(local->hw.extra_tx_headroom + size); in ieee80211_send_null_response()
1835 skb_reserve(skb, local->hw.extra_tx_headroom); in ieee80211_send_null_response()
1838 nullfunc->frame_control = fc; in ieee80211_send_null_response()
1839 nullfunc->duration_id = 0; in ieee80211_send_null_response()
1840 memcpy(nullfunc->addr1, sta->sta.addr, ETH_ALEN); in ieee80211_send_null_response()
1841 memcpy(nullfunc->addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_send_null_response()
1842 memcpy(nullfunc->addr3, sdata->vif.addr, ETH_ALEN); in ieee80211_send_null_response()
1843 nullfunc->seq_ctrl = 0; in ieee80211_send_null_response()
1845 skb->priority = tid; in ieee80211_send_null_response()
1848 nullfunc->qos_ctrl = cpu_to_le16(tid); in ieee80211_send_null_response()
1851 nullfunc->qos_ctrl |= in ieee80211_send_null_response()
1854 nullfunc->frame_control |= in ieee80211_send_null_response()
1867 info->flags |= IEEE80211_TX_CTL_NO_PS_BUFFER | in ieee80211_send_null_response()
1871 info->control.flags |= IEEE80211_TX_CTRL_PS_RESPONSE; in ieee80211_send_null_response()
1877 skb->dev = sdata->dev; in ieee80211_send_null_response()
1880 chanctx_conf = rcu_dereference(sdata->vif.bss_conf.chanctx_conf); in ieee80211_send_null_response()
1887 info->band = chanctx_conf->def.chan->band; in ieee80211_send_null_response()
1896 return fls(tids) - 1; in find_highest_prio_tid()
1900 return fls(tids) - 1; in find_highest_prio_tid()
1918 * only happen for PS-Poll. in ieee80211_sta_ps_more_data()
1928 if (!skb_queue_empty(&sta->tx_filtered[ac]) || in ieee80211_sta_ps_more_data()
1929 !skb_queue_empty(&sta->ps_tx_buf[ac])) in ieee80211_sta_ps_more_data()
1942 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_sta_ps_get_frames()
1943 struct ieee80211_local *local = sdata->local; in ieee80211_sta_ps_get_frames()
1960 sta->driver_buffered_tids & tids; in ieee80211_sta_ps_get_frames()
1961 *driver_release_tids |= sta->txq_buffered_tids & tids; in ieee80211_sta_ps_get_frames()
1968 skb = skb_dequeue(&sta->tx_filtered[ac]); in ieee80211_sta_ps_get_frames()
1971 &sta->ps_tx_buf[ac]); in ieee80211_sta_ps_get_frames()
1973 local->total_ps_buffered--; in ieee80211_sta_ps_get_frames()
1977 n_frames--; in ieee80211_sta_ps_get_frames()
1986 if (!skb_queue_empty(&sta->tx_filtered[ac]) || in ieee80211_sta_ps_get_frames()
1987 !skb_queue_empty(&sta->ps_tx_buf[ac])) in ieee80211_sta_ps_get_frames()
1997 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_sta_ps_deliver_response()
1998 struct ieee80211_local *local = sdata->local; in ieee80211_sta_ps_deliver_response()
2003 /* Service or PS-Poll period starts */ in ieee80211_sta_ps_deliver_response()
2021 * For PS-Poll, this can only happen due to a race condition in ieee80211_sta_ps_deliver_response()
2026 * At each unscheduled SP for a non-AP STA, the AP shall in ieee80211_sta_ps_deliver_response()
2029 * in the QoS Capability element from delivery-enabled ACs, in ieee80211_sta_ps_deliver_response()
2030 * that are destined for the non-AP STA. in ieee80211_sta_ps_deliver_response()
2039 tid = 7 - 2 * ac; in ieee80211_sta_ps_deliver_response()
2045 int num = 0; in ieee80211_sta_ps_deliver_response() local
2053 struct ieee80211_hdr *hdr = (void *) skb->data; in ieee80211_sta_ps_deliver_response()
2056 num++; in ieee80211_sta_ps_deliver_response()
2063 info->flags |= IEEE80211_TX_CTL_NO_PS_BUFFER; in ieee80211_sta_ps_deliver_response()
2064 info->control.flags |= IEEE80211_TX_CTRL_PS_RESPONSE; in ieee80211_sta_ps_deliver_response()
2071 hdr->frame_control |= in ieee80211_sta_ps_deliver_response()
2074 hdr->frame_control &= in ieee80211_sta_ps_deliver_response()
2077 if (ieee80211_is_data_qos(hdr->frame_control) || in ieee80211_sta_ps_deliver_response()
2078 ieee80211_is_qos_nullfunc(hdr->frame_control)) in ieee80211_sta_ps_deliver_response()
2081 tids |= BIT(skb->priority); in ieee80211_sta_ps_deliver_response()
2090 /* for PS-Poll, there's only one frame */ in ieee80211_sta_ps_deliver_response()
2091 info->flags |= IEEE80211_TX_STATUS_EOSP | in ieee80211_sta_ps_deliver_response()
2097 * last frame has a QoS header (i.e. is a QoS-data or in ieee80211_sta_ps_deliver_response()
2098 * QoS-nulldata frame) then just set the EOSP bit there in ieee80211_sta_ps_deliver_response()
2102 * the EOSP bit in the QoS header; add a QoS-nulldata in ieee80211_sta_ps_deliver_response()
2105 * Note that this code is only in the mac80211-release in ieee80211_sta_ps_deliver_response()
2107 * anything but QoS-data frames, or if it does, will in ieee80211_sta_ps_deliver_response()
2108 * create the QoS-nulldata frame by itself if needed. in ieee80211_sta_ps_deliver_response()
2110 * Cf. 802.11-2012 10.2.1.10 (c). in ieee80211_sta_ps_deliver_response()
2115 info->flags |= IEEE80211_TX_STATUS_EOSP | in ieee80211_sta_ps_deliver_response()
2119 * as it says the more-data bit should be set in ieee80211_sta_ps_deliver_response()
2120 * if there are more BUs. The QoS-Null frame in ieee80211_sta_ps_deliver_response()
2124 * expect more-data=0 when eosp=1. in ieee80211_sta_ps_deliver_response()
2126 hdr->frame_control |= in ieee80211_sta_ps_deliver_response()
2129 num++; in ieee80211_sta_ps_deliver_response()
2134 drv_allow_buffered_frames(local, sta, tids, num, in ieee80211_sta_ps_deliver_response()
2152 * on the TIDs we're releasing from - if there are more than in ieee80211_sta_ps_deliver_response()
2153 * n_frames it has to set the more-data bit (if we didn't ask in ieee80211_sta_ps_deliver_response()
2167 * became empty or we find that a txq became empty, we'll do the in ieee80211_sta_ps_deliver_response()
2171 for (tid = 0; tid < ARRAY_SIZE(sta->sta.txq); tid++) { in ieee80211_sta_ps_deliver_response()
2172 if (!sta->sta.txq[tid] || in ieee80211_sta_ps_deliver_response()
2174 txq_has_queue(sta->sta.txq[tid])) in ieee80211_sta_ps_deliver_response()
2185 u8 ignore_for_response = sta->sta.uapsd_queues; in ieee80211_sta_ps_deliver_poll_response()
2188 * If all ACs are delivery-enabled then we should reply in ieee80211_sta_ps_deliver_poll_response()
2190 * only from the non-enabled ones. in ieee80211_sta_ps_deliver_poll_response()
2192 if (ignore_for_response == BIT(IEEE80211_NUM_ACS) - 1) in ieee80211_sta_ps_deliver_poll_response()
2201 int n_frames = sta->sta.max_sp; in ieee80211_sta_ps_deliver_uapsd()
2202 u8 delivery_enabled = sta->sta.uapsd_queues; in ieee80211_sta_ps_deliver_uapsd()
2213 switch (sta->sta.max_sp) { in ieee80211_sta_ps_deliver_uapsd()
2238 trace_api_sta_block_awake(sta->local, pubsta, block); in ieee80211_sta_block_awake()
2252 ieee80211_queue_work(hw, &sta->drv_deliver_wk); in ieee80211_sta_block_awake()
2257 ieee80211_queue_work(hw, &sta->drv_deliver_wk); in ieee80211_sta_block_awake()
2268 struct ieee80211_local *local = sta->local; in ieee80211_sta_eosp()
2282 trace_api_send_eosp_nullfunc(sta->local, pubsta, tid); in ieee80211_send_eosp_nullfunc()
2285 more_data = ieee80211_sta_ps_more_data(sta, ~sta->sta.uapsd_queues, in ieee80211_send_eosp_nullfunc()
2300 trace_api_sta_set_buffered(sta->local, pubsta, tid, buffered); in ieee80211_sta_set_buffered()
2303 set_bit(tid, &sta->driver_buffered_tids); in ieee80211_sta_set_buffered()
2305 clear_bit(tid, &sta->driver_buffered_tids); in ieee80211_sta_set_buffered()
2315 struct ieee80211_local *local = sta->sdata->local; in ieee80211_sta_register_airtime()
2319 if (sta->local->airtime_flags & AIRTIME_USE_TX) in ieee80211_sta_register_airtime()
2321 if (sta->local->airtime_flags & AIRTIME_USE_RX) in ieee80211_sta_register_airtime()
2324 spin_lock_bh(&local->active_txq_lock[ac]); in ieee80211_sta_register_airtime()
2325 sta->airtime[ac].tx_airtime += tx_airtime; in ieee80211_sta_register_airtime()
2326 sta->airtime[ac].rx_airtime += rx_airtime; in ieee80211_sta_register_airtime()
2329 sta->airtime[ac].deficit -= airtime; in ieee80211_sta_register_airtime()
2331 spin_unlock_bh(&local->active_txq_lock[ac]); in ieee80211_sta_register_airtime()
2340 if (!sta->sta.valid_links || !sta->sta.mlo) { in __ieee80211_sta_recalc_aggregates()
2341 sta->sta.cur = &sta->sta.deflink.agg; in __ieee80211_sta_recalc_aggregates()
2346 for (link_id = 0; link_id < ARRAY_SIZE((sta)->link); link_id++) { in __ieee80211_sta_recalc_aggregates()
2353 link_sta = rcu_dereference(sta->sta.link[link_id]); in __ieee80211_sta_recalc_aggregates()
2358 sta->cur = sta->sta.deflink.agg; in __ieee80211_sta_recalc_aggregates()
2363 sta->cur.max_amsdu_len = in __ieee80211_sta_recalc_aggregates()
2364 min(sta->cur.max_amsdu_len, in __ieee80211_sta_recalc_aggregates()
2365 link_sta->agg.max_amsdu_len); in __ieee80211_sta_recalc_aggregates()
2366 sta->cur.max_rc_amsdu_len = in __ieee80211_sta_recalc_aggregates()
2367 min(sta->cur.max_rc_amsdu_len, in __ieee80211_sta_recalc_aggregates()
2368 link_sta->agg.max_rc_amsdu_len); in __ieee80211_sta_recalc_aggregates()
2370 for (i = 0; i < ARRAY_SIZE(sta->cur.max_tid_amsdu_len); i++) in __ieee80211_sta_recalc_aggregates()
2371 sta->cur.max_tid_amsdu_len[i] = in __ieee80211_sta_recalc_aggregates()
2372 min(sta->cur.max_tid_amsdu_len[i], in __ieee80211_sta_recalc_aggregates()
2373 link_sta->agg.max_tid_amsdu_len[i]); in __ieee80211_sta_recalc_aggregates()
2377 sta->sta.cur = &sta->cur; in __ieee80211_sta_recalc_aggregates()
2384 __ieee80211_sta_recalc_aggregates(sta, sta->sdata->vif.active_links); in ieee80211_sta_recalc_aggregates()
2394 if (!wiphy_ext_feature_isset(local->hw.wiphy, NL80211_EXT_FEATURE_AQL)) in ieee80211_sta_update_pending_airtime()
2400 &sta->airtime[ac].aql_tx_pending); in ieee80211_sta_update_pending_airtime()
2402 atomic_add(tx_airtime, &local->aql_total_pending_airtime); in ieee80211_sta_update_pending_airtime()
2403 atomic_add(tx_airtime, &local->aql_ac_pending_airtime[ac]); in ieee80211_sta_update_pending_airtime()
2409 &sta->airtime[ac].aql_tx_pending); in ieee80211_sta_update_pending_airtime()
2411 atomic_cmpxchg(&sta->airtime[ac].aql_tx_pending, in ieee80211_sta_update_pending_airtime()
2415 atomic_sub(tx_airtime, &local->aql_total_pending_airtime); in ieee80211_sta_update_pending_airtime()
2417 &local->aql_ac_pending_airtime[ac]); in ieee80211_sta_update_pending_airtime()
2420 wiphy_name(local->hw.wiphy), ac, tx_pending, in ieee80211_sta_update_pending_airtime()
2422 atomic_cmpxchg(&local->aql_ac_pending_airtime[ac], in ieee80211_sta_update_pending_airtime()
2424 atomic_sub(tx_pending, &local->aql_total_pending_airtime); in ieee80211_sta_update_pending_airtime()
2431 struct ieee80211_sta_rx_stats *stats = &sta->deflink.rx_stats; in sta_get_last_rx_stats()
2434 if (!sta->deflink.pcpu_rx_stats) in sta_get_last_rx_stats()
2440 cpustats = per_cpu_ptr(sta->deflink.pcpu_rx_stats, cpu); in sta_get_last_rx_stats()
2442 if (time_after(cpustats->last_rx, stats->last_rx)) in sta_get_last_rx_stats()
2452 rinfo->bw = STA_STATS_GET(BW, rate); in sta_stats_decode_rate()
2456 rinfo->flags = RATE_INFO_FLAGS_VHT_MCS; in sta_stats_decode_rate()
2457 rinfo->mcs = STA_STATS_GET(VHT_MCS, rate); in sta_stats_decode_rate()
2458 rinfo->nss = STA_STATS_GET(VHT_NSS, rate); in sta_stats_decode_rate()
2460 rinfo->flags |= RATE_INFO_FLAGS_SHORT_GI; in sta_stats_decode_rate()
2463 rinfo->flags = RATE_INFO_FLAGS_MCS; in sta_stats_decode_rate()
2464 rinfo->mcs = STA_STATS_GET(HT_MCS, rate); in sta_stats_decode_rate()
2466 rinfo->flags |= RATE_INFO_FLAGS_SHORT_GI; in sta_stats_decode_rate()
2475 sband = local->hw.wiphy->bands[band]; in sta_stats_decode_rate()
2477 if (WARN_ON_ONCE(!sband->bitrates)) in sta_stats_decode_rate()
2480 brate = sband->bitrates[rate_idx].bitrate; in sta_stats_decode_rate()
2481 if (rinfo->bw == RATE_INFO_BW_5) in sta_stats_decode_rate()
2483 else if (rinfo->bw == RATE_INFO_BW_10) in sta_stats_decode_rate()
2487 rinfo->legacy = DIV_ROUND_UP(brate, 1 << shift); in sta_stats_decode_rate()
2491 rinfo->flags = RATE_INFO_FLAGS_HE_MCS; in sta_stats_decode_rate()
2492 rinfo->mcs = STA_STATS_GET(HE_MCS, rate); in sta_stats_decode_rate()
2493 rinfo->nss = STA_STATS_GET(HE_NSS, rate); in sta_stats_decode_rate()
2494 rinfo->he_gi = STA_STATS_GET(HE_GI, rate); in sta_stats_decode_rate()
2495 rinfo->he_ru_alloc = STA_STATS_GET(HE_RU, rate); in sta_stats_decode_rate()
2496 rinfo->he_dcm = STA_STATS_GET(HE_DCM, rate); in sta_stats_decode_rate()
2499 rinfo->flags = RATE_INFO_FLAGS_EHT_MCS; in sta_stats_decode_rate()
2500 rinfo->mcs = STA_STATS_GET(EHT_MCS, rate); in sta_stats_decode_rate()
2501 rinfo->nss = STA_STATS_GET(EHT_NSS, rate); in sta_stats_decode_rate()
2502 rinfo->eht_gi = STA_STATS_GET(EHT_GI, rate); in sta_stats_decode_rate()
2503 rinfo->eht_ru_alloc = STA_STATS_GET(EHT_RU, rate); in sta_stats_decode_rate()
2510 u32 rate = READ_ONCE(sta_get_last_rx_stats(sta)->last_rate); in sta_set_rate_info_rx()
2513 return -EINVAL; in sta_set_rate_info_rx()
2515 sta_stats_decode_rate(sta->local, rate, rinfo); in sta_set_rate_info_rx()
2526 start = u64_stats_fetch_begin(&rxstats->syncp); in sta_get_tidstats_msdu()
2527 value = rxstats->msdu[tid]; in sta_get_tidstats_msdu()
2528 } while (u64_stats_fetch_retry(&rxstats->syncp, start)); in sta_get_tidstats_msdu()
2537 struct ieee80211_local *local = sta->local; in sta_set_tidstats()
2540 if (!(tidstats->filled & BIT(NL80211_TID_STATS_RX_MSDU))) { in sta_set_tidstats()
2541 tidstats->rx_msdu += sta_get_tidstats_msdu(&sta->deflink.rx_stats, in sta_set_tidstats()
2544 if (sta->deflink.pcpu_rx_stats) { in sta_set_tidstats()
2548 cpurxs = per_cpu_ptr(sta->deflink.pcpu_rx_stats, in sta_set_tidstats()
2550 tidstats->rx_msdu += in sta_set_tidstats()
2555 tidstats->filled |= BIT(NL80211_TID_STATS_RX_MSDU); in sta_set_tidstats()
2558 if (!(tidstats->filled & BIT(NL80211_TID_STATS_TX_MSDU))) { in sta_set_tidstats()
2559 tidstats->filled |= BIT(NL80211_TID_STATS_TX_MSDU); in sta_set_tidstats()
2560 tidstats->tx_msdu = sta->deflink.tx_stats.msdu[tid]; in sta_set_tidstats()
2563 if (!(tidstats->filled & BIT(NL80211_TID_STATS_TX_MSDU_RETRIES)) && in sta_set_tidstats()
2564 ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) { in sta_set_tidstats()
2565 tidstats->filled |= BIT(NL80211_TID_STATS_TX_MSDU_RETRIES); in sta_set_tidstats()
2566 tidstats->tx_msdu_retries = sta->deflink.status_stats.msdu_retries[tid]; in sta_set_tidstats()
2569 if (!(tidstats->filled & BIT(NL80211_TID_STATS_TX_MSDU_FAILED)) && in sta_set_tidstats()
2570 ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) { in sta_set_tidstats()
2571 tidstats->filled |= BIT(NL80211_TID_STATS_TX_MSDU_FAILED); in sta_set_tidstats()
2572 tidstats->tx_msdu_failed = sta->deflink.status_stats.msdu_failed[tid]; in sta_set_tidstats()
2576 spin_lock_bh(&local->fq.lock); in sta_set_tidstats()
2579 tidstats->filled |= BIT(NL80211_TID_STATS_TXQ_STATS); in sta_set_tidstats()
2580 ieee80211_fill_txq_stats(&tidstats->txq_stats, in sta_set_tidstats()
2581 to_txq_info(sta->sta.txq[tid])); in sta_set_tidstats()
2584 spin_unlock_bh(&local->fq.lock); in sta_set_tidstats()
2594 start = u64_stats_fetch_begin(&rxstats->syncp); in sta_get_stats_bytes()
2595 value = rxstats->bytes; in sta_get_stats_bytes()
2596 } while (u64_stats_fetch_retry(&rxstats->syncp, start)); in sta_get_stats_bytes()
2604 struct ieee80211_sub_if_data *sdata = sta->sdata; in sta_set_sinfo()
2605 struct ieee80211_local *local = sdata->local; in sta_set_sinfo()
2612 sinfo->generation = sdata->local->sta_generation; in sta_set_sinfo()
2618 if (sdata->vif.type == NL80211_IFTYPE_STATION) in sta_set_sinfo()
2619 sinfo->rx_beacon = sdata->deflink.u.mgd.count_beacon_signal; in sta_set_sinfo()
2621 drv_sta_statistics(local, sdata, &sta->sta, sinfo); in sta_set_sinfo()
2622 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_INACTIVE_TIME) | in sta_set_sinfo()
2629 if (sdata->vif.type == NL80211_IFTYPE_STATION) { in sta_set_sinfo()
2630 sinfo->beacon_loss_count = in sta_set_sinfo()
2631 sdata->deflink.u.mgd.beacon_loss_count; in sta_set_sinfo()
2632 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_BEACON_LOSS); in sta_set_sinfo()
2635 sinfo->connected_time = ktime_get_seconds() - sta->last_connected; in sta_set_sinfo()
2636 sinfo->assoc_at = sta->assoc_at; in sta_set_sinfo()
2637 sinfo->inactive_time = in sta_set_sinfo()
2638 jiffies_to_msecs(jiffies - ieee80211_sta_last_active(sta)); in sta_set_sinfo()
2640 if (!(sinfo->filled & (BIT_ULL(NL80211_STA_INFO_TX_BYTES64) | in sta_set_sinfo()
2642 sinfo->tx_bytes = 0; in sta_set_sinfo()
2644 sinfo->tx_bytes += sta->deflink.tx_stats.bytes[ac]; in sta_set_sinfo()
2645 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BYTES64); in sta_set_sinfo()
2648 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_TX_PACKETS))) { in sta_set_sinfo()
2649 sinfo->tx_packets = 0; in sta_set_sinfo()
2651 sinfo->tx_packets += sta->deflink.tx_stats.packets[ac]; in sta_set_sinfo()
2652 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_PACKETS); in sta_set_sinfo()
2655 if (!(sinfo->filled & (BIT_ULL(NL80211_STA_INFO_RX_BYTES64) | in sta_set_sinfo()
2657 sinfo->rx_bytes += sta_get_stats_bytes(&sta->deflink.rx_stats); in sta_set_sinfo()
2659 if (sta->deflink.pcpu_rx_stats) { in sta_set_sinfo()
2663 cpurxs = per_cpu_ptr(sta->deflink.pcpu_rx_stats, in sta_set_sinfo()
2665 sinfo->rx_bytes += sta_get_stats_bytes(cpurxs); in sta_set_sinfo()
2669 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_BYTES64); in sta_set_sinfo()
2672 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_RX_PACKETS))) { in sta_set_sinfo()
2673 sinfo->rx_packets = sta->deflink.rx_stats.packets; in sta_set_sinfo()
2674 if (sta->deflink.pcpu_rx_stats) { in sta_set_sinfo()
2678 cpurxs = per_cpu_ptr(sta->deflink.pcpu_rx_stats, in sta_set_sinfo()
2680 sinfo->rx_packets += cpurxs->packets; in sta_set_sinfo()
2683 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_PACKETS); in sta_set_sinfo()
2686 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_TX_RETRIES))) { in sta_set_sinfo()
2687 sinfo->tx_retries = sta->deflink.status_stats.retry_count; in sta_set_sinfo()
2688 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_RETRIES); in sta_set_sinfo()
2691 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_TX_FAILED))) { in sta_set_sinfo()
2692 sinfo->tx_failed = sta->deflink.status_stats.retry_failed; in sta_set_sinfo()
2693 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_FAILED); in sta_set_sinfo()
2696 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_RX_DURATION))) { in sta_set_sinfo()
2698 sinfo->rx_duration += sta->airtime[ac].rx_airtime; in sta_set_sinfo()
2699 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_DURATION); in sta_set_sinfo()
2702 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_TX_DURATION))) { in sta_set_sinfo()
2704 sinfo->tx_duration += sta->airtime[ac].tx_airtime; in sta_set_sinfo()
2705 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_DURATION); in sta_set_sinfo()
2708 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_AIRTIME_WEIGHT))) { in sta_set_sinfo()
2709 sinfo->airtime_weight = sta->airtime_weight; in sta_set_sinfo()
2710 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_AIRTIME_WEIGHT); in sta_set_sinfo()
2713 sinfo->rx_dropped_misc = sta->deflink.rx_stats.dropped; in sta_set_sinfo()
2714 if (sta->deflink.pcpu_rx_stats) { in sta_set_sinfo()
2718 cpurxs = per_cpu_ptr(sta->deflink.pcpu_rx_stats, cpu); in sta_set_sinfo()
2719 sinfo->rx_dropped_misc += cpurxs->dropped; in sta_set_sinfo()
2723 if (sdata->vif.type == NL80211_IFTYPE_STATION && in sta_set_sinfo()
2724 !(sdata->vif.driver_flags & IEEE80211_VIF_BEACON_FILTER)) { in sta_set_sinfo()
2725 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_BEACON_RX) | in sta_set_sinfo()
2727 sinfo->rx_beacon_signal_avg = ieee80211_ave_rssi(&sdata->vif); in sta_set_sinfo()
2730 if (ieee80211_hw_check(&sta->local->hw, SIGNAL_DBM) || in sta_set_sinfo()
2731 ieee80211_hw_check(&sta->local->hw, SIGNAL_UNSPEC)) { in sta_set_sinfo()
2732 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_SIGNAL))) { in sta_set_sinfo()
2733 sinfo->signal = (s8)last_rxstats->last_signal; in sta_set_sinfo()
2734 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL); in sta_set_sinfo()
2737 if (!sta->deflink.pcpu_rx_stats && in sta_set_sinfo()
2738 !(sinfo->filled & BIT_ULL(NL80211_STA_INFO_SIGNAL_AVG))) { in sta_set_sinfo()
2739 sinfo->signal_avg = in sta_set_sinfo()
2740 -ewma_signal_read(&sta->deflink.rx_stats_avg.signal); in sta_set_sinfo()
2741 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL_AVG); in sta_set_sinfo()
2745 /* for the average - if pcpu_rx_stats isn't set - rxstats must point to in sta_set_sinfo()
2746 * the sta->rx_stats struct, so the check here is fine with and without in sta_set_sinfo()
2749 if (last_rxstats->chains && in sta_set_sinfo()
2750 !(sinfo->filled & (BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL) | in sta_set_sinfo()
2752 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL); in sta_set_sinfo()
2753 if (!sta->deflink.pcpu_rx_stats) in sta_set_sinfo()
2754 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL_AVG); in sta_set_sinfo()
2756 sinfo->chains = last_rxstats->chains; in sta_set_sinfo()
2758 for (i = 0; i < ARRAY_SIZE(sinfo->chain_signal); i++) { in sta_set_sinfo()
2759 sinfo->chain_signal[i] = in sta_set_sinfo()
2760 last_rxstats->chain_signal_last[i]; in sta_set_sinfo()
2761 sinfo->chain_signal_avg[i] = in sta_set_sinfo()
2762 -ewma_signal_read(&sta->deflink.rx_stats_avg.chain_signal[i]); in sta_set_sinfo()
2766 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_TX_BITRATE)) && in sta_set_sinfo()
2767 !sta->sta.valid_links && in sta_set_sinfo()
2768 ieee80211_rate_valid(&sta->deflink.tx_stats.last_rate)) { in sta_set_sinfo()
2769 sta_set_rate_info_tx(sta, &sta->deflink.tx_stats.last_rate, in sta_set_sinfo()
2770 &sinfo->txrate); in sta_set_sinfo()
2771 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BITRATE); in sta_set_sinfo()
2774 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_RX_BITRATE)) && in sta_set_sinfo()
2775 !sta->sta.valid_links) { in sta_set_sinfo()
2776 if (sta_set_rate_info_rx(sta, &sinfo->rxrate) == 0) in sta_set_sinfo()
2777 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_BITRATE); in sta_set_sinfo()
2782 sta_set_tidstats(sta, &sinfo->pertid[i], i); in sta_set_sinfo()
2785 if (ieee80211_vif_is_mesh(&sdata->vif)) { in sta_set_sinfo()
2787 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_LLID) | in sta_set_sinfo()
2796 sinfo->llid = sta->mesh->llid; in sta_set_sinfo()
2797 sinfo->plid = sta->mesh->plid; in sta_set_sinfo()
2798 sinfo->plink_state = sta->mesh->plink_state; in sta_set_sinfo()
2800 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_T_OFFSET); in sta_set_sinfo()
2801 sinfo->t_offset = sta->mesh->t_offset; in sta_set_sinfo()
2803 sinfo->local_pm = sta->mesh->local_pm; in sta_set_sinfo()
2804 sinfo->peer_pm = sta->mesh->peer_pm; in sta_set_sinfo()
2805 sinfo->nonpeer_pm = sta->mesh->nonpeer_pm; in sta_set_sinfo()
2806 sinfo->connected_to_gate = sta->mesh->connected_to_gate; in sta_set_sinfo()
2807 sinfo->connected_to_as = sta->mesh->connected_to_as; in sta_set_sinfo()
2811 sinfo->bss_param.flags = 0; in sta_set_sinfo()
2812 if (sdata->vif.bss_conf.use_cts_prot) in sta_set_sinfo()
2813 sinfo->bss_param.flags |= BSS_PARAM_FLAGS_CTS_PROT; in sta_set_sinfo()
2814 if (sdata->vif.bss_conf.use_short_preamble) in sta_set_sinfo()
2815 sinfo->bss_param.flags |= BSS_PARAM_FLAGS_SHORT_PREAMBLE; in sta_set_sinfo()
2816 if (sdata->vif.bss_conf.use_short_slot) in sta_set_sinfo()
2817 sinfo->bss_param.flags |= BSS_PARAM_FLAGS_SHORT_SLOT_TIME; in sta_set_sinfo()
2818 sinfo->bss_param.dtim_period = sdata->vif.bss_conf.dtim_period; in sta_set_sinfo()
2819 sinfo->bss_param.beacon_interval = sdata->vif.bss_conf.beacon_int; in sta_set_sinfo()
2821 sinfo->sta_flags.set = 0; in sta_set_sinfo()
2822 sinfo->sta_flags.mask = BIT(NL80211_STA_FLAG_AUTHORIZED) | in sta_set_sinfo()
2830 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_AUTHORIZED); in sta_set_sinfo()
2832 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_SHORT_PREAMBLE); in sta_set_sinfo()
2833 if (sta->sta.wme) in sta_set_sinfo()
2834 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_WME); in sta_set_sinfo()
2836 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_MFP); in sta_set_sinfo()
2838 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_AUTHENTICATED); in sta_set_sinfo()
2840 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_ASSOCIATED); in sta_set_sinfo()
2842 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_TDLS_PEER); in sta_set_sinfo()
2847 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_EXPECTED_THROUGHPUT); in sta_set_sinfo()
2848 sinfo->expected_throughput = thr; in sta_set_sinfo()
2851 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_ACK_SIGNAL)) && in sta_set_sinfo()
2852 sta->deflink.status_stats.ack_signal_filled) { in sta_set_sinfo()
2853 sinfo->ack_signal = sta->deflink.status_stats.last_ack_signal; in sta_set_sinfo()
2854 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_ACK_SIGNAL); in sta_set_sinfo()
2857 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_ACK_SIGNAL_AVG)) && in sta_set_sinfo()
2858 sta->deflink.status_stats.ack_signal_filled) { in sta_set_sinfo()
2859 sinfo->avg_ack_signal = in sta_set_sinfo()
2860 -(s8)ewma_avg_signal_read( in sta_set_sinfo()
2861 &sta->deflink.status_stats.avg_ack_signal); in sta_set_sinfo()
2862 sinfo->filled |= in sta_set_sinfo()
2866 if (ieee80211_vif_is_mesh(&sdata->vif)) { in sta_set_sinfo()
2867 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_AIRTIME_LINK_METRIC); in sta_set_sinfo()
2868 sinfo->airtime_link_metric = in sta_set_sinfo()
2875 struct ieee80211_sub_if_data *sdata = sta->sdata; in sta_get_expected_throughput()
2876 struct ieee80211_local *local = sdata->local; in sta_get_expected_throughput()
2881 ref = local->rate_ctrl; in sta_get_expected_throughput()
2884 if (ref && ref->ops->get_expected_throughput) in sta_get_expected_throughput()
2885 thr = ref->ops->get_expected_throughput(sta->rate_ctrl_priv); in sta_get_expected_throughput()
2896 if (!sta->deflink.status_stats.last_ack || in ieee80211_sta_last_active()
2897 time_after(stats->last_rx, sta->deflink.status_stats.last_ack)) in ieee80211_sta_last_active()
2898 return stats->last_rx; in ieee80211_sta_last_active()
2899 return sta->deflink.status_stats.last_ack; in ieee80211_sta_last_active()
2904 if (thr && thr < STA_SLOW_THRESHOLD * sta->local->num_sta) { in sta_update_codel_params()
2905 sta->cparams.target = MS2TIME(50); in sta_update_codel_params()
2906 sta->cparams.interval = MS2TIME(300); in sta_update_codel_params()
2907 sta->cparams.ecn = false; in sta_update_codel_params()
2909 sta->cparams.target = MS2TIME(20); in sta_update_codel_params()
2910 sta->cparams.interval = MS2TIME(100); in sta_update_codel_params()
2911 sta->cparams.ecn = true; in sta_update_codel_params()
2925 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_sta_allocate_link()
2929 lockdep_assert_wiphy(sdata->local->hw.wiphy); in ieee80211_sta_allocate_link()
2934 if (WARN_ON(!sta->sta.valid_links)) in ieee80211_sta_allocate_link()
2935 return -EINVAL; in ieee80211_sta_allocate_link()
2937 if (WARN_ON(sta->sta.valid_links & BIT(link_id) || in ieee80211_sta_allocate_link()
2938 sta->link[link_id])) in ieee80211_sta_allocate_link()
2939 return -EBUSY; in ieee80211_sta_allocate_link()
2943 return -ENOMEM; in ieee80211_sta_allocate_link()
2945 ret = sta_info_alloc_link(sdata->local, &alloc->info, GFP_KERNEL); in ieee80211_sta_allocate_link()
2951 sta_info_add_link(sta, link_id, &alloc->info, &alloc->sta); in ieee80211_sta_allocate_link()
2953 ieee80211_link_sta_debugfs_add(&alloc->info); in ieee80211_sta_allocate_link()
2960 lockdep_assert_wiphy(sta->sdata->local->hw.wiphy); in ieee80211_sta_free_link()
2969 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_sta_activate_link()
2971 u16 old_links = sta->sta.valid_links; in ieee80211_sta_activate_link()
2975 link_sta = rcu_dereference_protected(sta->link[link_id], in ieee80211_sta_activate_link()
2976 lockdep_is_held(&sdata->local->hw.wiphy->mtx)); in ieee80211_sta_activate_link()
2979 return -EINVAL; in ieee80211_sta_activate_link()
2982 if (link_sta_info_hash_lookup(sdata->local, link_sta->addr)) { in ieee80211_sta_activate_link()
2984 return -EALREADY; in ieee80211_sta_activate_link()
2989 sta->sta.valid_links = new_links; in ieee80211_sta_activate_link()
2999 ieee80211_sta_recalc_aggregates(&sta->sta); in ieee80211_sta_activate_link()
3001 ret = drv_change_sta_links(sdata->local, sdata, &sta->sta, in ieee80211_sta_activate_link()
3004 sta->sta.valid_links = old_links; in ieee80211_sta_activate_link()
3010 ret = link_sta_info_hash_add(sdata->local, link_sta); in ieee80211_sta_activate_link()
3017 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_sta_remove_link()
3018 u16 old_links = sta->sta.valid_links; in ieee80211_sta_remove_link()
3020 lockdep_assert_wiphy(sdata->local->hw.wiphy); in ieee80211_sta_remove_link()
3022 sta->sta.valid_links &= ~BIT(link_id); in ieee80211_sta_remove_link()
3025 drv_change_sta_links(sdata->local, sdata, &sta->sta, in ieee80211_sta_remove_link()
3026 old_links, sta->sta.valid_links); in ieee80211_sta_remove_link()
3037 sta->sta.max_amsdu_subframes = 0; in ieee80211_sta_set_max_amsdu_subframes()
3051 sta->sta.max_amsdu_subframes = 4 << (4 - val); in ieee80211_sta_set_max_amsdu_subframes()
3059 return lockdep_is_held(&sta->local->hw.wiphy->mtx); in lockdep_sta_mutex_held()