Lines Matching +full:ac +full:- +full:link
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright 2002-2005, Instant802 Networks, Inc.
4 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
5 * Copyright 2013-2014 Intel Mobile Communications GmbH
6 * Copyright (C) 2015 - 2017 Intel Deutschland GmbH
7 * Copyright (C) 2018-2023 Intel Corporation
24 #include "driver-ops.h"
44 * particular, it may not start any mesh peer link management or add
47 * When the insertion fails (sta_info_insert()) returns non-zero), the
50 * Station entries are added by mac80211 when you establish a link with a
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()
135 int ac, i; in __cleanup_single_sta() local
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()
161 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { 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()
294 struct ieee80211_link_data *link; in ieee80211_find_sta_by_link_addrs() local
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()
304 if (!link) 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()
520 link_info->sta = sta; in sta_info_add_link()
521 link_info->link_id = link_id; in sta_info_add_link()
522 link_info->pub = link_sta; in sta_info_add_link()
523 link_info->pub->sta = &sta->sta; in sta_info_add_link()
524 link_sta->link_id = link_id; in sta_info_add_link()
525 rcu_assign_pointer(sta->link[link_id], link_info); in sta_info_add_link()
526 rcu_assign_pointer(sta->sta.link[link_id], link_sta); in sta_info_add_link()
528 link_sta->smps_mode = IEEE80211_SMPS_OFF; in sta_info_add_link()
529 link_sta->agg.max_rc_amsdu_len = IEEE80211_MAX_MPDU_LEN_HT_BA; in sta_info_add_link()
537 struct ieee80211_local *local = sdata->local; in __sta_info_alloc()
538 struct ieee80211_hw *hw = &local->hw; in __sta_info_alloc()
544 sta = kzalloc(sizeof(*sta) + hw->sta_data_size, gfp); in __sta_info_alloc()
548 sta->local = local; in __sta_info_alloc()
549 sta->sdata = sdata; in __sta_info_alloc()
551 if (sta_info_alloc_link(local, &sta->deflink, gfp)) in __sta_info_alloc()
555 sta_info_add_link(sta, link_id, &sta->deflink, in __sta_info_alloc()
556 &sta->sta.deflink); in __sta_info_alloc()
557 sta->sta.valid_links = BIT(link_id); in __sta_info_alloc()
559 sta_info_add_link(sta, 0, &sta->deflink, &sta->sta.deflink); in __sta_info_alloc()
562 sta->sta.cur = &sta->sta.deflink.agg; in __sta_info_alloc()
564 spin_lock_init(&sta->lock); in __sta_info_alloc()
565 spin_lock_init(&sta->ps_lock); in __sta_info_alloc()
566 INIT_WORK(&sta->drv_deliver_wk, sta_deliver_ps_frames); in __sta_info_alloc()
567 wiphy_work_init(&sta->ampdu_mlme.work, ieee80211_ba_session_work); in __sta_info_alloc()
569 if (ieee80211_vif_is_mesh(&sdata->vif)) { in __sta_info_alloc()
570 sta->mesh = kzalloc(sizeof(*sta->mesh), gfp); in __sta_info_alloc()
571 if (!sta->mesh) in __sta_info_alloc()
573 sta->mesh->plink_sta = sta; in __sta_info_alloc()
574 spin_lock_init(&sta->mesh->plink_lock); in __sta_info_alloc()
575 if (!sdata->u.mesh.user_mpm) in __sta_info_alloc()
576 timer_setup(&sta->mesh->plink_timer, mesh_plink_timer, in __sta_info_alloc()
578 sta->mesh->nonpeer_pm = NL80211_MESH_POWER_ACTIVE; in __sta_info_alloc()
582 memcpy(sta->addr, addr, ETH_ALEN); in __sta_info_alloc()
583 memcpy(sta->sta.addr, addr, ETH_ALEN); in __sta_info_alloc()
584 memcpy(sta->deflink.addr, link_addr, ETH_ALEN); in __sta_info_alloc()
585 memcpy(sta->sta.deflink.addr, link_addr, ETH_ALEN); in __sta_info_alloc()
586 sta->sta.max_rx_aggregation_subframes = in __sta_info_alloc()
587 local->hw.max_rx_aggregation_subframes; in __sta_info_alloc()
589 /* TODO link specific alloc and assignments for MLO Link STA */ in __sta_info_alloc()
591 /* Extended Key ID needs to install keys for keyid 0 and 1 Rx-only. in __sta_info_alloc()
593 * references to is not NULL. To not use the initial Rx-only key in __sta_info_alloc()
597 BUILD_BUG_ON(ARRAY_SIZE(sta->ptk) <= INVALID_PTK_KEYIDX); in __sta_info_alloc()
598 sta->ptk_idx = INVALID_PTK_KEYIDX; in __sta_info_alloc()
601 ieee80211_init_frag_cache(&sta->frags); in __sta_info_alloc()
603 sta->sta_state = IEEE80211_STA_NONE; in __sta_info_alloc()
605 if (sdata->vif.type == NL80211_IFTYPE_MESH_POINT) in __sta_info_alloc()
606 sta->amsdu_mesh_control = -1; in __sta_info_alloc()
609 sta->reserved_tid = IEEE80211_TID_UNRESERVED; in __sta_info_alloc()
611 sta->last_connected = ktime_get_seconds(); in __sta_info_alloc()
614 ALIGN(hw->txq_data_size, sizeof(void *)); in __sta_info_alloc()
616 txq_data = kcalloc(ARRAY_SIZE(sta->sta.txq), size, gfp); in __sta_info_alloc()
620 for (i = 0; i < ARRAY_SIZE(sta->sta.txq); i++) { in __sta_info_alloc()
630 sta->airtime_weight = IEEE80211_DEFAULT_AIRTIME_WEIGHT; in __sta_info_alloc()
633 skb_queue_head_init(&sta->ps_tx_buf[i]); in __sta_info_alloc()
634 skb_queue_head_init(&sta->tx_filtered[i]); in __sta_info_alloc()
635 sta->airtime[i].deficit = sta->airtime_weight; in __sta_info_alloc()
636 atomic_set(&sta->airtime[i].aql_tx_pending, 0); in __sta_info_alloc()
637 sta->airtime[i].aql_limit_low = local->aql_txq_limit_low[i]; in __sta_info_alloc()
638 sta->airtime[i].aql_limit_high = local->aql_txq_limit_high[i]; in __sta_info_alloc()
642 sta->last_seq_ctrl[i] = cpu_to_le16(USHRT_MAX); in __sta_info_alloc()
648 if (!hw->wiphy->bands[i]) in __sta_info_alloc()
675 for (r = 0; r < hw->wiphy->bands[i]->n_bitrates; r++) { in __sta_info_alloc()
678 rate = &hw->wiphy->bands[i]->bitrates[r]; in __sta_info_alloc()
680 if (!(rate->flags & mandatory)) in __sta_info_alloc()
682 sta->sta.deflink.supp_rates[i] |= BIT(r); in __sta_info_alloc()
686 sta->cparams.ce_threshold = CODEL_DISABLED_THRESHOLD; in __sta_info_alloc()
687 sta->cparams.target = MS2TIME(20); in __sta_info_alloc()
688 sta->cparams.interval = MS2TIME(100); in __sta_info_alloc()
689 sta->cparams.ecn = true; in __sta_info_alloc()
690 sta->cparams.ce_threshold_selector = 0; in __sta_info_alloc()
691 sta->cparams.ce_threshold_mask = 0; in __sta_info_alloc()
693 sta_dbg(sdata, "Allocated STA %pM\n", sta->sta.addr); in __sta_info_alloc()
698 kfree(to_txq_info(sta->sta.txq[0])); in __sta_info_alloc()
700 sta_info_free_link(&sta->deflink); in __sta_info_alloc()
702 kfree(sta->mesh); in __sta_info_alloc()
711 return __sta_info_alloc(sdata, addr, -1, addr, gfp); in sta_info_alloc()
725 struct ieee80211_sub_if_data *sdata = sta->sdata; in sta_info_insert_check()
727 lockdep_assert_wiphy(sdata->local->hw.wiphy); in sta_info_insert_check()
735 return -ENETDOWN; in sta_info_insert_check()
737 if (WARN_ON(ether_addr_equal(sta->sta.addr, sdata->vif.addr) || in sta_info_insert_check()
738 !is_valid_ether_addr(sta->sta.addr))) in sta_info_insert_check()
739 return -EINVAL; in sta_info_insert_check()
746 if (ieee80211_hw_check(&sdata->local->hw, NEEDS_UNIQUE_STA_ADDR) && in sta_info_insert_check()
747 ieee80211_find_sta_by_ifaddr(&sdata->local->hw, sta->addr, NULL)) { in sta_info_insert_check()
749 return -ENOTUNIQ; in sta_info_insert_check()
763 for (state = IEEE80211_STA_NOTEXIST; state < sta->sta_state; state++) { in sta_info_insert_drv_state()
774 if (!local->ops->sta_add) in sta_info_insert_drv_state()
775 sta->uploaded = true; in sta_info_insert_drv_state()
779 if (sdata->vif.type == NL80211_IFTYPE_ADHOC) { in sta_info_insert_drv_state()
781 "failed to move IBSS STA %pM to state %d (%d) - keeping it anyway\n", in sta_info_insert_drv_state()
782 sta->sta.addr, state + 1, err); in sta_info_insert_drv_state()
787 for (; state > IEEE80211_STA_NOTEXIST; state--) in sta_info_insert_drv_state()
788 WARN_ON(drv_sta_state(local, sdata, sta, state, state - 1)); in sta_info_insert_drv_state()
796 struct ieee80211_local *local = sdata->local; in ieee80211_recalc_p2p_go_ps_allowed()
797 bool allow_p2p_go_ps = sdata->vif.p2p; in ieee80211_recalc_p2p_go_ps_allowed()
801 list_for_each_entry_rcu(sta, &local->sta_list, list) { in ieee80211_recalc_p2p_go_ps_allowed()
802 if (sdata != sta->sdata || in ieee80211_recalc_p2p_go_ps_allowed()
805 if (!sta->sta.support_p2p_ps) { in ieee80211_recalc_p2p_go_ps_allowed()
812 if (allow_p2p_go_ps != sdata->vif.bss_conf.allow_p2p_go_ps) { in ieee80211_recalc_p2p_go_ps_allowed()
813 sdata->vif.bss_conf.allow_p2p_go_ps = allow_p2p_go_ps; in ieee80211_recalc_p2p_go_ps_allowed()
814 ieee80211_link_info_change_notify(sdata, &sdata->deflink, in ieee80211_recalc_p2p_go_ps_allowed()
821 struct ieee80211_local *local = sta->local; in sta_info_insert_finish()
822 struct ieee80211_sub_if_data *sdata = sta->sdata; in sta_info_insert_finish()
826 lockdep_assert_wiphy(local->hw.wiphy); in sta_info_insert_finish()
829 if (sta_info_get_bss(sdata, sta->sta.addr)) { in sta_info_insert_finish()
830 err = -EEXIST; in sta_info_insert_finish()
836 err = -ENOMEM; in sta_info_insert_finish()
840 local->num_sta++; in sta_info_insert_finish()
841 local->sta_generation++; in sta_info_insert_finish()
852 if (sta->sta.valid_links) { in sta_info_insert_finish()
853 err = link_sta_info_hash_add(local, &sta->deflink); in sta_info_insert_finish()
860 list_add_tail_rcu(&sta->list, &local->sta_list); in sta_info_insert_finish()
865 if (sta->sta_state >= IEEE80211_STA_ASSOC) { in sta_info_insert_finish()
866 ieee80211_recalc_min_chandef(sta->sdata, -1); in sta_info_insert_finish()
867 if (!sta->sta.support_p2p_ps) in sta_info_insert_finish()
868 ieee80211_recalc_p2p_go_ps_allowed(sta->sdata); in sta_info_insert_finish()
883 if (sta->sta.valid_links) { in sta_info_insert_finish()
886 for (i = 0; i < ARRAY_SIZE(sta->link); i++) { in sta_info_insert_finish()
889 link_sta = rcu_dereference_protected(sta->link[i], in sta_info_insert_finish()
890 lockdep_is_held(&local->hw.wiphy->mtx)); in sta_info_insert_finish()
896 if (sdata->vif.active_links & BIT(i)) in sta_info_insert_finish()
900 ieee80211_link_sta_debugfs_add(&sta->deflink); in sta_info_insert_finish()
901 ieee80211_link_sta_debugfs_drv_add(&sta->deflink); in sta_info_insert_finish()
904 sinfo->generation = local->sta_generation; in sta_info_insert_finish()
905 cfg80211_new_sta(sdata->dev, sta->sta.addr, sinfo, GFP_KERNEL); in sta_info_insert_finish()
908 sta_dbg(sdata, "Inserted STA %pM\n", sta->sta.addr); in sta_info_insert_finish()
910 /* move reference to rcu-protected */ in sta_info_insert_finish()
913 if (ieee80211_vif_is_mesh(&sdata->vif)) in sta_info_insert_finish()
920 if (sta->sta.valid_links) in sta_info_insert_finish()
921 link_sta_info_hash_del(local, &sta->deflink); in sta_info_insert_finish()
923 list_del_rcu(&sta->list); in sta_info_insert_finish()
925 local->num_sta--; in sta_info_insert_finish()
936 struct ieee80211_local *local = sta->local; in sta_info_insert_rcu()
940 lockdep_assert_wiphy(local->hw.wiphy); in sta_info_insert_rcu()
988 static unsigned long ieee80211_tids_for_ac(int ac) in ieee80211_tids_for_ac() argument
991 switch (ac) { in ieee80211_tids_for_ac()
1008 struct ieee80211_local *local = sta->local; in __sta_info_recalc_tim()
1011 u8 ignore_for_tim = sta->sta.uapsd_queues; in __sta_info_recalc_tim()
1012 int ac; in __sta_info_recalc_tim() local
1013 u16 id = sta->sta.aid; in __sta_info_recalc_tim()
1015 if (sta->sdata->vif.type == NL80211_IFTYPE_AP || in __sta_info_recalc_tim()
1016 sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN) { in __sta_info_recalc_tim()
1017 if (WARN_ON_ONCE(!sta->sdata->bss)) in __sta_info_recalc_tim()
1020 ps = &sta->sdata->bss->ps; in __sta_info_recalc_tim()
1022 } else if (ieee80211_vif_is_mesh(&sta->sdata->vif)) { in __sta_info_recalc_tim()
1023 ps = &sta->sdata->u.mesh.ps; in __sta_info_recalc_tim()
1030 if (ieee80211_hw_check(&local->hw, AP_LINK_PS) && !local->ops->set_tim) in __sta_info_recalc_tim()
1033 if (sta->dead) in __sta_info_recalc_tim()
1037 * If all ACs are delivery-enabled then we should build in __sta_info_recalc_tim()
1040 * non-enabled ones. in __sta_info_recalc_tim()
1042 if (ignore_for_tim == BIT(IEEE80211_NUM_ACS) - 1) in __sta_info_recalc_tim()
1046 ignore_for_tim = BIT(IEEE80211_NUM_ACS) - 1; in __sta_info_recalc_tim()
1048 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { in __sta_info_recalc_tim()
1051 if (ignore_for_tim & ieee80211_ac_to_qos_mask[ac]) in __sta_info_recalc_tim()
1054 indicate_tim |= !skb_queue_empty(&sta->tx_filtered[ac]) || in __sta_info_recalc_tim()
1055 !skb_queue_empty(&sta->ps_tx_buf[ac]); in __sta_info_recalc_tim()
1059 tids = ieee80211_tids_for_ac(ac); in __sta_info_recalc_tim()
1062 sta->driver_buffered_tids & tids; in __sta_info_recalc_tim()
1064 sta->txq_buffered_tids & tids; in __sta_info_recalc_tim()
1068 spin_lock_bh(&local->tim_lock); in __sta_info_recalc_tim()
1070 if (indicate_tim == __bss_tim_get(ps->tim, id)) in __sta_info_recalc_tim()
1074 __bss_tim_set(ps->tim, id); in __sta_info_recalc_tim()
1076 __bss_tim_clear(ps->tim, id); in __sta_info_recalc_tim()
1078 if (local->ops->set_tim && !WARN_ON(sta->dead)) { in __sta_info_recalc_tim()
1079 local->tim_in_locked_section = true; in __sta_info_recalc_tim()
1080 drv_set_tim(local, &sta->sta, indicate_tim); in __sta_info_recalc_tim()
1081 local->tim_in_locked_section = false; in __sta_info_recalc_tim()
1085 spin_unlock_bh(&local->tim_lock); in __sta_info_recalc_tim()
1104 timeout = (sta->listen_interval * in sta_info_buffer_expired()
1105 sta->sdata->vif.bss_conf.beacon_int * in sta_info_buffer_expired()
1109 return time_after(jiffies, info->control.jiffies + timeout); in sta_info_buffer_expired()
1114 struct sta_info *sta, int ac) in sta_info_cleanup_expire_buffered_ac() argument
1122 * a separate queue to avoid reordering with normal PS-buffered in sta_info_cleanup_expire_buffered_ac()
1127 spin_lock_irqsave(&sta->tx_filtered[ac].lock, flags); in sta_info_cleanup_expire_buffered_ac()
1128 skb = skb_peek(&sta->tx_filtered[ac]); in sta_info_cleanup_expire_buffered_ac()
1130 skb = __skb_dequeue(&sta->tx_filtered[ac]); in sta_info_cleanup_expire_buffered_ac()
1133 spin_unlock_irqrestore(&sta->tx_filtered[ac].lock, flags); in sta_info_cleanup_expire_buffered_ac()
1143 ieee80211_free_txskb(&local->hw, skb); in sta_info_cleanup_expire_buffered_ac()
1147 * Now also check the normal PS-buffered queue, this will in sta_info_cleanup_expire_buffered_ac()
1153 spin_lock_irqsave(&sta->ps_tx_buf[ac].lock, flags); in sta_info_cleanup_expire_buffered_ac()
1154 skb = skb_peek(&sta->ps_tx_buf[ac]); in sta_info_cleanup_expire_buffered_ac()
1156 skb = __skb_dequeue(&sta->ps_tx_buf[ac]); in sta_info_cleanup_expire_buffered_ac()
1159 spin_unlock_irqrestore(&sta->ps_tx_buf[ac].lock, flags); in sta_info_cleanup_expire_buffered_ac()
1169 local->total_ps_buffered--; in sta_info_cleanup_expire_buffered_ac()
1170 ps_dbg(sta->sdata, "Buffered frame expired (STA %pM)\n", in sta_info_cleanup_expire_buffered_ac()
1171 sta->sta.addr); in sta_info_cleanup_expire_buffered_ac()
1172 ieee80211_free_txskb(&local->hw, skb); in sta_info_cleanup_expire_buffered_ac()
1176 * Finally, recalculate the TIM bit for this station -- it might in sta_info_cleanup_expire_buffered_ac()
1187 return !(skb_queue_empty(&sta->ps_tx_buf[ac]) && in sta_info_cleanup_expire_buffered_ac()
1188 skb_queue_empty(&sta->tx_filtered[ac])); in sta_info_cleanup_expire_buffered_ac()
1195 int ac; in sta_info_cleanup_expire_buffered() local
1198 if (!sta->sdata->bss && in sta_info_cleanup_expire_buffered()
1199 !ieee80211_vif_is_mesh(&sta->sdata->vif)) in sta_info_cleanup_expire_buffered()
1202 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) in sta_info_cleanup_expire_buffered()
1204 sta_info_cleanup_expire_buffered_ac(local, sta, ac); in sta_info_cleanup_expire_buffered()
1218 return -ENOENT; in __sta_info_destroy_part1()
1220 local = sta->local; in __sta_info_destroy_part1()
1221 sdata = sta->sdata; in __sta_info_destroy_part1()
1223 lockdep_assert_wiphy(local->hw.wiphy); in __sta_info_destroy_part1()
1228 * sessions -- block that to make sure the tear-down in __sta_info_destroy_part1()
1236 * rx frames on RSS queues sent prior to the disassociation - wait for in __sta_info_destroy_part1()
1241 for (i = 0; i < ARRAY_SIZE(sta->link); i++) { in __sta_info_destroy_part1()
1244 if (!(sta->sta.valid_links & BIT(i))) in __sta_info_destroy_part1()
1247 link_sta = rcu_dereference_protected(sta->link[i], in __sta_info_destroy_part1()
1248 lockdep_is_held(&local->hw.wiphy->mtx)); in __sta_info_destroy_part1()
1262 drv_tdls_cancel_channel_switch(local, sdata, &sta->sta); in __sta_info_destroy_part1()
1266 list_del_rcu(&sta->list); in __sta_info_destroy_part1()
1267 sta->removed = true; in __sta_info_destroy_part1()
1269 if (sta->uploaded) in __sta_info_destroy_part1()
1270 drv_sta_pre_rcu_remove(local, sta->sdata, sta); in __sta_info_destroy_part1()
1272 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN && in __sta_info_destroy_part1()
1273 rcu_access_pointer(sdata->u.vlan.sta) == sta) in __sta_info_destroy_part1()
1274 RCU_INIT_POINTER(sdata->u.vlan.sta, NULL); in __sta_info_destroy_part1()
1283 struct ieee80211_local *local = sta->local; in _sta_info_move_state()
1287 if (sta->sta_state == new_state) in _sta_info_move_state()
1294 if (sta->sta_state != IEEE80211_STA_AUTH) in _sta_info_move_state()
1295 return -EINVAL; in _sta_info_move_state()
1298 if (sta->sta_state != IEEE80211_STA_NONE && in _sta_info_move_state()
1299 sta->sta_state != IEEE80211_STA_ASSOC) in _sta_info_move_state()
1300 return -EINVAL; in _sta_info_move_state()
1303 if (sta->sta_state != IEEE80211_STA_AUTH && in _sta_info_move_state()
1304 sta->sta_state != IEEE80211_STA_AUTHORIZED) in _sta_info_move_state()
1305 return -EINVAL; in _sta_info_move_state()
1308 if (sta->sta_state != IEEE80211_STA_ASSOC) in _sta_info_move_state()
1309 return -EINVAL; in _sta_info_move_state()
1313 return -EINVAL; in _sta_info_move_state()
1316 sta_dbg(sta->sdata, "moving STA %pM to state %d\n", in _sta_info_move_state()
1317 sta->sta.addr, new_state); in _sta_info_move_state()
1323 int err = drv_sta_state(sta->local, sta->sdata, sta, in _sta_info_move_state()
1324 sta->sta_state, new_state); in _sta_info_move_state()
1333 if (sta->sta_state == IEEE80211_STA_AUTH) in _sta_info_move_state()
1334 clear_bit(WLAN_STA_AUTH, &sta->_flags); in _sta_info_move_state()
1337 if (sta->sta_state == IEEE80211_STA_NONE) { in _sta_info_move_state()
1338 set_bit(WLAN_STA_AUTH, &sta->_flags); in _sta_info_move_state()
1339 } else if (sta->sta_state == IEEE80211_STA_ASSOC) { in _sta_info_move_state()
1340 clear_bit(WLAN_STA_ASSOC, &sta->_flags); in _sta_info_move_state()
1342 ieee80211_recalc_min_chandef(sta->sdata, -1); in _sta_info_move_state()
1343 if (!sta->sta.support_p2p_ps) in _sta_info_move_state()
1344 ieee80211_recalc_p2p_go_ps_allowed(sta->sdata); in _sta_info_move_state()
1349 if (sta->sta_state == IEEE80211_STA_AUTH) { in _sta_info_move_state()
1350 set_bit(WLAN_STA_ASSOC, &sta->_flags); in _sta_info_move_state()
1351 sta->assoc_at = ktime_get_boottime_ns(); in _sta_info_move_state()
1353 ieee80211_recalc_min_chandef(sta->sdata, -1); in _sta_info_move_state()
1354 if (!sta->sta.support_p2p_ps) in _sta_info_move_state()
1355 ieee80211_recalc_p2p_go_ps_allowed(sta->sdata); in _sta_info_move_state()
1357 } else if (sta->sta_state == IEEE80211_STA_AUTHORIZED) { in _sta_info_move_state()
1358 ieee80211_vif_dec_num_mcast(sta->sdata); in _sta_info_move_state()
1359 clear_bit(WLAN_STA_AUTHORIZED, &sta->_flags); in _sta_info_move_state()
1368 if (local->ops->set_key) { in _sta_info_move_state()
1370 if (local->ops->flush_sta) in _sta_info_move_state()
1371 drv_flush_sta(local, sta->sdata, sta); in _sta_info_move_state()
1374 sta->sdata, in _sta_info_move_state()
1383 if (sta->sta_state == IEEE80211_STA_ASSOC) { in _sta_info_move_state()
1384 ieee80211_vif_inc_num_mcast(sta->sdata); in _sta_info_move_state()
1385 set_bit(WLAN_STA_AUTHORIZED, &sta->_flags); in _sta_info_move_state()
1389 if (sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN || in _sta_info_move_state()
1390 sta->sdata->vif.type == NL80211_IFTYPE_AP) in _sta_info_move_state()
1391 cfg80211_send_layer2_update(sta->sdata->dev, in _sta_info_move_state()
1392 sta->sta.addr); in _sta_info_move_state()
1398 sta->sta_state = new_state; in _sta_info_move_state()
1411 struct ieee80211_local *local = sta->local; in __sta_info_destroy_part2()
1412 struct ieee80211_sub_if_data *sdata = sta->sdata; in __sta_info_destroy_part2()
1436 lockdep_assert_wiphy(local->hw.wiphy); in __sta_info_destroy_part2()
1438 if (sta->sta_state == IEEE80211_STA_AUTHORIZED) { in __sta_info_destroy_part2()
1446 /* disable TIM bit - last chance to tell driver */ in __sta_info_destroy_part2()
1449 sta->dead = true; in __sta_info_destroy_part2()
1451 local->num_sta--; in __sta_info_destroy_part2()
1452 local->sta_generation++; in __sta_info_destroy_part2()
1454 while (sta->sta_state > IEEE80211_STA_NONE) { in __sta_info_destroy_part2()
1455 ret = _sta_info_move_state(sta, sta->sta_state - 1, recalc); in __sta_info_destroy_part2()
1462 if (sta->uploaded) { in __sta_info_destroy_part2()
1468 sta_dbg(sdata, "Removed STA %pM\n", sta->sta.addr); in __sta_info_destroy_part2()
1473 cfg80211_del_sta_sinfo(sdata->dev, sta->sta.addr, sinfo, GFP_KERNEL); in __sta_info_destroy_part2()
1478 ieee80211_destroy_frag_cache(&sta->frags); in __sta_info_destroy_part2()
1501 lockdep_assert_wiphy(sdata->local->hw.wiphy); in sta_info_destroy_addr()
1512 lockdep_assert_wiphy(sdata->local->hw.wiphy); in sta_info_destroy_addr_bss()
1525 list_for_each_entry_rcu(sta, &local->sta_list, list) in sta_info_cleanup()
1530 if (local->quiescing) in sta_info_cleanup()
1536 mod_timer(&local->sta_cleanup, in sta_info_cleanup()
1544 err = rhltable_init(&local->sta_hash, &sta_rht_params); in sta_info_init()
1548 err = rhltable_init(&local->link_sta_hash, &link_sta_rht_params); in sta_info_init()
1550 rhltable_destroy(&local->sta_hash); in sta_info_init()
1554 spin_lock_init(&local->tim_lock); in sta_info_init()
1555 INIT_LIST_HEAD(&local->sta_list); in sta_info_init()
1557 timer_setup(&local->sta_cleanup, sta_info_cleanup, 0); in sta_info_init()
1563 del_timer_sync(&local->sta_cleanup); in sta_info_stop()
1564 rhltable_destroy(&local->sta_hash); in sta_info_stop()
1565 rhltable_destroy(&local->link_sta_hash); in sta_info_stop()
1572 struct ieee80211_local *local = sdata->local; in __sta_info_flush()
1578 lockdep_assert_wiphy(local->hw.wiphy); in __sta_info_flush()
1580 WARN_ON(vlans && sdata->vif.type != NL80211_IFTYPE_AP); in __sta_info_flush()
1581 WARN_ON(vlans && !sdata->bss); in __sta_info_flush()
1583 list_for_each_entry_safe(sta, tmp, &local->sta_list, list) { in __sta_info_flush()
1584 if (sdata != sta->sdata && in __sta_info_flush()
1585 (!vlans || sdata->bss != sta->sdata->bss)) in __sta_info_flush()
1588 if (link_id >= 0 && sta->sta.valid_links && in __sta_info_flush()
1589 !(sta->sta.valid_links & BIT(link_id))) in __sta_info_flush()
1593 list_add(&sta->free_list, &free_list); in __sta_info_flush()
1603 if (!sta->sta.support_p2p_ps) in __sta_info_flush()
1608 ieee80211_recalc_min_chandef(sdata, -1); in __sta_info_flush()
1619 struct ieee80211_local *local = sdata->local; in ieee80211_sta_expire()
1622 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_sta_expire()
1624 list_for_each_entry_safe(sta, tmp, &local->sta_list, list) { in ieee80211_sta_expire()
1627 if (sdata != sta->sdata) in ieee80211_sta_expire()
1631 sta_dbg(sta->sdata, "expiring inactive STA %pM\n", in ieee80211_sta_expire()
1632 sta->sta.addr); in ieee80211_sta_expire()
1634 if (ieee80211_vif_is_mesh(&sdata->vif) && in ieee80211_sta_expire()
1636 atomic_dec(&sdata->u.mesh.ps.num_sta_ps); in ieee80211_sta_expire()
1657 !ether_addr_equal(sta->sdata->vif.addr, localaddr)) in ieee80211_find_sta_by_ifaddr()
1659 if (!sta->uploaded) in ieee80211_find_sta_by_ifaddr()
1661 return &sta->sta; in ieee80211_find_sta_by_ifaddr()
1680 if (!sta->uploaded) in ieee80211_find_sta()
1683 return &sta->sta; in ieee80211_find_sta()
1690 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_sta_ps_deliver_wakeup()
1691 struct ieee80211_local *local = sdata->local; in ieee80211_sta_ps_deliver_wakeup()
1693 int filtered = 0, buffered = 0, ac, i; in ieee80211_sta_ps_deliver_wakeup() local
1697 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) in ieee80211_sta_ps_deliver_wakeup()
1698 sdata = container_of(sdata->bss, struct ieee80211_sub_if_data, in ieee80211_sta_ps_deliver_wakeup()
1701 if (sdata->vif.type == NL80211_IFTYPE_AP) in ieee80211_sta_ps_deliver_wakeup()
1702 ps = &sdata->bss->ps; in ieee80211_sta_ps_deliver_wakeup()
1703 else if (ieee80211_vif_is_mesh(&sdata->vif)) in ieee80211_sta_ps_deliver_wakeup()
1704 ps = &sdata->u.mesh.ps; in ieee80211_sta_ps_deliver_wakeup()
1711 sta->driver_buffered_tids = 0; in ieee80211_sta_ps_deliver_wakeup()
1712 sta->txq_buffered_tids = 0; in ieee80211_sta_ps_deliver_wakeup()
1714 if (!ieee80211_hw_check(&local->hw, AP_LINK_PS)) in ieee80211_sta_ps_deliver_wakeup()
1715 drv_sta_notify(local, sdata, STA_NOTIFY_AWAKE, &sta->sta); in ieee80211_sta_ps_deliver_wakeup()
1717 for (i = 0; i < ARRAY_SIZE(sta->sta.txq); i++) { in ieee80211_sta_ps_deliver_wakeup()
1718 if (!sta->sta.txq[i] || !txq_has_queue(sta->sta.txq[i])) in ieee80211_sta_ps_deliver_wakeup()
1721 schedule_and_wake_txq(local, to_txq_info(sta->sta.txq[i])); in ieee80211_sta_ps_deliver_wakeup()
1727 spin_lock_bh(&sta->ps_lock); in ieee80211_sta_ps_deliver_wakeup()
1729 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { in ieee80211_sta_ps_deliver_wakeup()
1732 spin_lock_irqsave(&sta->tx_filtered[ac].lock, flags); in ieee80211_sta_ps_deliver_wakeup()
1733 skb_queue_splice_tail_init(&sta->tx_filtered[ac], &pending); in ieee80211_sta_ps_deliver_wakeup()
1734 spin_unlock_irqrestore(&sta->tx_filtered[ac].lock, flags); in ieee80211_sta_ps_deliver_wakeup()
1736 filtered += tmp - count; in ieee80211_sta_ps_deliver_wakeup()
1739 spin_lock_irqsave(&sta->ps_tx_buf[ac].lock, flags); in ieee80211_sta_ps_deliver_wakeup()
1740 skb_queue_splice_tail_init(&sta->ps_tx_buf[ac], &pending); in ieee80211_sta_ps_deliver_wakeup()
1741 spin_unlock_irqrestore(&sta->ps_tx_buf[ac].lock, flags); in ieee80211_sta_ps_deliver_wakeup()
1743 buffered += tmp - count; in ieee80211_sta_ps_deliver_wakeup()
1756 spin_unlock_bh(&sta->ps_lock); in ieee80211_sta_ps_deliver_wakeup()
1758 atomic_dec(&ps->num_sta_ps); in ieee80211_sta_ps_deliver_wakeup()
1760 local->total_ps_buffered -= buffered; in ieee80211_sta_ps_deliver_wakeup()
1766 sta->sta.addr, sta->sta.aid, filtered, buffered); in ieee80211_sta_ps_deliver_wakeup()
1775 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_send_null_response()
1776 struct ieee80211_local *local = sdata->local; in ieee80211_send_null_response()
1781 bool qos = sta->sta.wme; in ieee80211_send_null_response()
1790 size -= 2; in ieee80211_send_null_response()
1796 skb = dev_alloc_skb(local->hw.extra_tx_headroom + size); in ieee80211_send_null_response()
1800 skb_reserve(skb, local->hw.extra_tx_headroom); in ieee80211_send_null_response()
1803 nullfunc->frame_control = fc; in ieee80211_send_null_response()
1804 nullfunc->duration_id = 0; in ieee80211_send_null_response()
1805 memcpy(nullfunc->addr1, sta->sta.addr, ETH_ALEN); in ieee80211_send_null_response()
1806 memcpy(nullfunc->addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_send_null_response()
1807 memcpy(nullfunc->addr3, sdata->vif.addr, ETH_ALEN); in ieee80211_send_null_response()
1808 nullfunc->seq_ctrl = 0; in ieee80211_send_null_response()
1810 skb->priority = tid; in ieee80211_send_null_response()
1813 nullfunc->qos_ctrl = cpu_to_le16(tid); in ieee80211_send_null_response()
1816 nullfunc->qos_ctrl |= in ieee80211_send_null_response()
1819 nullfunc->frame_control |= in ieee80211_send_null_response()
1832 info->flags |= IEEE80211_TX_CTL_NO_PS_BUFFER | in ieee80211_send_null_response()
1836 info->control.flags |= IEEE80211_TX_CTRL_PS_RESPONSE; in ieee80211_send_null_response()
1842 skb->dev = sdata->dev; in ieee80211_send_null_response()
1845 chanctx_conf = rcu_dereference(sdata->vif.bss_conf.chanctx_conf); in ieee80211_send_null_response()
1852 info->band = chanctx_conf->def.chan->band; in ieee80211_send_null_response()
1861 return fls(tids) - 1; in find_highest_prio_tid()
1865 return fls(tids) - 1; in find_highest_prio_tid()
1878 int ac; in ieee80211_sta_ps_more_data() local
1883 * only happen for PS-Poll. in ieee80211_sta_ps_more_data()
1889 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { in ieee80211_sta_ps_more_data()
1890 if (ignored_acs & ieee80211_ac_to_qos_mask[ac]) in ieee80211_sta_ps_more_data()
1893 if (!skb_queue_empty(&sta->tx_filtered[ac]) || in ieee80211_sta_ps_more_data()
1894 !skb_queue_empty(&sta->ps_tx_buf[ac])) in ieee80211_sta_ps_more_data()
1907 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_sta_ps_get_frames()
1908 struct ieee80211_local *local = sdata->local; in ieee80211_sta_ps_get_frames()
1909 int ac; in ieee80211_sta_ps_get_frames() local
1912 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { in ieee80211_sta_ps_get_frames()
1915 if (ignored_acs & ieee80211_ac_to_qos_mask[ac]) in ieee80211_sta_ps_get_frames()
1918 tids = ieee80211_tids_for_ac(ac); in ieee80211_sta_ps_get_frames()
1925 sta->driver_buffered_tids & tids; in ieee80211_sta_ps_get_frames()
1926 *driver_release_tids |= sta->txq_buffered_tids & tids; in ieee80211_sta_ps_get_frames()
1933 skb = skb_dequeue(&sta->tx_filtered[ac]); in ieee80211_sta_ps_get_frames()
1936 &sta->ps_tx_buf[ac]); in ieee80211_sta_ps_get_frames()
1938 local->total_ps_buffered--; in ieee80211_sta_ps_get_frames()
1942 n_frames--; in ieee80211_sta_ps_get_frames()
1947 /* If we have more frames buffered on this AC, then abort the in ieee80211_sta_ps_get_frames()
1951 if (!skb_queue_empty(&sta->tx_filtered[ac]) || in ieee80211_sta_ps_get_frames()
1952 !skb_queue_empty(&sta->ps_tx_buf[ac])) in ieee80211_sta_ps_get_frames()
1962 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_sta_ps_deliver_response()
1963 struct ieee80211_local *local = sdata->local; in ieee80211_sta_ps_deliver_response()
1968 /* Service or PS-Poll period starts */ in ieee80211_sta_ps_deliver_response()
1983 int tid, ac; in ieee80211_sta_ps_deliver_response() local
1986 * For PS-Poll, this can only happen due to a race condition in ieee80211_sta_ps_deliver_response()
1991 * At each unscheduled SP for a non-AP STA, the AP shall in ieee80211_sta_ps_deliver_response()
1994 * in the QoS Capability element from delivery-enabled ACs, in ieee80211_sta_ps_deliver_response()
1995 * that are destined for the non-AP STA. in ieee80211_sta_ps_deliver_response()
2001 for (ac = IEEE80211_AC_VO; ac < IEEE80211_NUM_ACS; ac++) in ieee80211_sta_ps_deliver_response()
2002 if (!(ignored_acs & ieee80211_ac_to_qos_mask[ac])) in ieee80211_sta_ps_deliver_response()
2004 tid = 7 - 2 * ac; in ieee80211_sta_ps_deliver_response()
2018 struct ieee80211_hdr *hdr = (void *) skb->data; in ieee80211_sta_ps_deliver_response()
2028 info->flags |= IEEE80211_TX_CTL_NO_PS_BUFFER; in ieee80211_sta_ps_deliver_response()
2029 info->control.flags |= IEEE80211_TX_CTRL_PS_RESPONSE; in ieee80211_sta_ps_deliver_response()
2036 hdr->frame_control |= in ieee80211_sta_ps_deliver_response()
2039 hdr->frame_control &= in ieee80211_sta_ps_deliver_response()
2042 if (ieee80211_is_data_qos(hdr->frame_control) || in ieee80211_sta_ps_deliver_response()
2043 ieee80211_is_qos_nullfunc(hdr->frame_control)) in ieee80211_sta_ps_deliver_response()
2046 tids |= BIT(skb->priority); in ieee80211_sta_ps_deliver_response()
2055 /* for PS-Poll, there's only one frame */ in ieee80211_sta_ps_deliver_response()
2056 info->flags |= IEEE80211_TX_STATUS_EOSP | in ieee80211_sta_ps_deliver_response()
2062 * last frame has a QoS header (i.e. is a QoS-data or in ieee80211_sta_ps_deliver_response()
2063 * QoS-nulldata frame) then just set the EOSP bit there in ieee80211_sta_ps_deliver_response()
2067 * the EOSP bit in the QoS header; add a QoS-nulldata in ieee80211_sta_ps_deliver_response()
2070 * Note that this code is only in the mac80211-release in ieee80211_sta_ps_deliver_response()
2072 * anything but QoS-data frames, or if it does, will in ieee80211_sta_ps_deliver_response()
2073 * create the QoS-nulldata frame by itself if needed. in ieee80211_sta_ps_deliver_response()
2075 * Cf. 802.11-2012 10.2.1.10 (c). in ieee80211_sta_ps_deliver_response()
2080 info->flags |= IEEE80211_TX_STATUS_EOSP | in ieee80211_sta_ps_deliver_response()
2084 * as it says the more-data bit should be set in ieee80211_sta_ps_deliver_response()
2085 * if there are more BUs. The QoS-Null frame in ieee80211_sta_ps_deliver_response()
2089 * expect more-data=0 when eosp=1. in ieee80211_sta_ps_deliver_response()
2091 hdr->frame_control |= in ieee80211_sta_ps_deliver_response()
2117 * on the TIDs we're releasing from - if there are more than in ieee80211_sta_ps_deliver_response()
2118 * n_frames it has to set the more-data bit (if we didn't ask in ieee80211_sta_ps_deliver_response()
2136 for (tid = 0; tid < ARRAY_SIZE(sta->sta.txq); tid++) { in ieee80211_sta_ps_deliver_response()
2137 if (!sta->sta.txq[tid] || in ieee80211_sta_ps_deliver_response()
2139 txq_has_queue(sta->sta.txq[tid])) in ieee80211_sta_ps_deliver_response()
2150 u8 ignore_for_response = sta->sta.uapsd_queues; in ieee80211_sta_ps_deliver_poll_response()
2153 * If all ACs are delivery-enabled then we should reply in ieee80211_sta_ps_deliver_poll_response()
2155 * only from the non-enabled ones. in ieee80211_sta_ps_deliver_poll_response()
2157 if (ignore_for_response == BIT(IEEE80211_NUM_ACS) - 1) in ieee80211_sta_ps_deliver_poll_response()
2166 int n_frames = sta->sta.max_sp; in ieee80211_sta_ps_deliver_uapsd()
2167 u8 delivery_enabled = sta->sta.uapsd_queues; in ieee80211_sta_ps_deliver_uapsd()
2178 switch (sta->sta.max_sp) { in ieee80211_sta_ps_deliver_uapsd()
2203 trace_api_sta_block_awake(sta->local, pubsta, block); in ieee80211_sta_block_awake()
2217 ieee80211_queue_work(hw, &sta->drv_deliver_wk); in ieee80211_sta_block_awake()
2222 ieee80211_queue_work(hw, &sta->drv_deliver_wk); in ieee80211_sta_block_awake()
2233 struct ieee80211_local *local = sta->local; in ieee80211_sta_eosp()
2247 trace_api_send_eosp_nullfunc(sta->local, pubsta, tid); in ieee80211_send_eosp_nullfunc()
2250 more_data = ieee80211_sta_ps_more_data(sta, ~sta->sta.uapsd_queues, in ieee80211_send_eosp_nullfunc()
2265 trace_api_sta_set_buffered(sta->local, pubsta, tid, buffered); in ieee80211_sta_set_buffered()
2268 set_bit(tid, &sta->driver_buffered_tids); in ieee80211_sta_set_buffered()
2270 clear_bit(tid, &sta->driver_buffered_tids); in ieee80211_sta_set_buffered()
2280 struct ieee80211_local *local = sta->sdata->local; in ieee80211_sta_register_airtime()
2281 u8 ac = ieee80211_ac_from_tid(tid); in ieee80211_sta_register_airtime() local
2284 if (sta->local->airtime_flags & AIRTIME_USE_TX) in ieee80211_sta_register_airtime()
2286 if (sta->local->airtime_flags & AIRTIME_USE_RX) in ieee80211_sta_register_airtime()
2289 spin_lock_bh(&local->active_txq_lock[ac]); in ieee80211_sta_register_airtime()
2290 sta->airtime[ac].tx_airtime += tx_airtime; in ieee80211_sta_register_airtime()
2291 sta->airtime[ac].rx_airtime += rx_airtime; in ieee80211_sta_register_airtime()
2293 if (ieee80211_sta_keep_active(sta, ac)) in ieee80211_sta_register_airtime()
2294 sta->airtime[ac].deficit -= airtime; in ieee80211_sta_register_airtime()
2296 spin_unlock_bh(&local->active_txq_lock[ac]); in ieee80211_sta_register_airtime()
2305 if (!sta->sta.valid_links || !sta->sta.mlo) { in __ieee80211_sta_recalc_aggregates()
2306 sta->sta.cur = &sta->sta.deflink.agg; in __ieee80211_sta_recalc_aggregates()
2311 for (link_id = 0; link_id < ARRAY_SIZE((sta)->link); link_id++) { in __ieee80211_sta_recalc_aggregates()
2318 link_sta = rcu_dereference(sta->sta.link[link_id]); in __ieee80211_sta_recalc_aggregates()
2323 sta->cur = sta->sta.deflink.agg; in __ieee80211_sta_recalc_aggregates()
2328 sta->cur.max_amsdu_len = in __ieee80211_sta_recalc_aggregates()
2329 min(sta->cur.max_amsdu_len, in __ieee80211_sta_recalc_aggregates()
2330 link_sta->agg.max_amsdu_len); in __ieee80211_sta_recalc_aggregates()
2331 sta->cur.max_rc_amsdu_len = in __ieee80211_sta_recalc_aggregates()
2332 min(sta->cur.max_rc_amsdu_len, in __ieee80211_sta_recalc_aggregates()
2333 link_sta->agg.max_rc_amsdu_len); in __ieee80211_sta_recalc_aggregates()
2335 for (i = 0; i < ARRAY_SIZE(sta->cur.max_tid_amsdu_len); i++) in __ieee80211_sta_recalc_aggregates()
2336 sta->cur.max_tid_amsdu_len[i] = in __ieee80211_sta_recalc_aggregates()
2337 min(sta->cur.max_tid_amsdu_len[i], in __ieee80211_sta_recalc_aggregates()
2338 link_sta->agg.max_tid_amsdu_len[i]); in __ieee80211_sta_recalc_aggregates()
2342 sta->sta.cur = &sta->cur; in __ieee80211_sta_recalc_aggregates()
2349 __ieee80211_sta_recalc_aggregates(sta, sta->sdata->vif.active_links); in ieee80211_sta_recalc_aggregates()
2354 struct sta_info *sta, u8 ac, in ieee80211_sta_update_pending_airtime() argument
2359 if (!wiphy_ext_feature_isset(local->hw.wiphy, NL80211_EXT_FEATURE_AQL)) in ieee80211_sta_update_pending_airtime()
2365 &sta->airtime[ac].aql_tx_pending); in ieee80211_sta_update_pending_airtime()
2367 atomic_add(tx_airtime, &local->aql_total_pending_airtime); in ieee80211_sta_update_pending_airtime()
2368 atomic_add(tx_airtime, &local->aql_ac_pending_airtime[ac]); in ieee80211_sta_update_pending_airtime()
2374 &sta->airtime[ac].aql_tx_pending); in ieee80211_sta_update_pending_airtime()
2376 atomic_cmpxchg(&sta->airtime[ac].aql_tx_pending, in ieee80211_sta_update_pending_airtime()
2380 atomic_sub(tx_airtime, &local->aql_total_pending_airtime); in ieee80211_sta_update_pending_airtime()
2382 &local->aql_ac_pending_airtime[ac]); in ieee80211_sta_update_pending_airtime()
2384 "Device %s AC %d pending airtime underflow: %u, %u", in ieee80211_sta_update_pending_airtime()
2385 wiphy_name(local->hw.wiphy), ac, tx_pending, in ieee80211_sta_update_pending_airtime()
2387 atomic_cmpxchg(&local->aql_ac_pending_airtime[ac], in ieee80211_sta_update_pending_airtime()
2389 atomic_sub(tx_pending, &local->aql_total_pending_airtime); in ieee80211_sta_update_pending_airtime()
2396 struct ieee80211_sta_rx_stats *stats = &sta->deflink.rx_stats; in sta_get_last_rx_stats()
2399 if (!sta->deflink.pcpu_rx_stats) in sta_get_last_rx_stats()
2405 cpustats = per_cpu_ptr(sta->deflink.pcpu_rx_stats, cpu); in sta_get_last_rx_stats()
2407 if (time_after(cpustats->last_rx, stats->last_rx)) in sta_get_last_rx_stats()
2417 rinfo->bw = STA_STATS_GET(BW, rate); in sta_stats_decode_rate()
2421 rinfo->flags = RATE_INFO_FLAGS_VHT_MCS; in sta_stats_decode_rate()
2422 rinfo->mcs = STA_STATS_GET(VHT_MCS, rate); in sta_stats_decode_rate()
2423 rinfo->nss = STA_STATS_GET(VHT_NSS, rate); in sta_stats_decode_rate()
2425 rinfo->flags |= RATE_INFO_FLAGS_SHORT_GI; in sta_stats_decode_rate()
2428 rinfo->flags = RATE_INFO_FLAGS_MCS; in sta_stats_decode_rate()
2429 rinfo->mcs = STA_STATS_GET(HT_MCS, rate); in sta_stats_decode_rate()
2431 rinfo->flags |= RATE_INFO_FLAGS_SHORT_GI; in sta_stats_decode_rate()
2440 sband = local->hw.wiphy->bands[band]; in sta_stats_decode_rate()
2442 if (WARN_ON_ONCE(!sband->bitrates)) in sta_stats_decode_rate()
2445 brate = sband->bitrates[rate_idx].bitrate; in sta_stats_decode_rate()
2446 if (rinfo->bw == RATE_INFO_BW_5) in sta_stats_decode_rate()
2448 else if (rinfo->bw == RATE_INFO_BW_10) in sta_stats_decode_rate()
2452 rinfo->legacy = DIV_ROUND_UP(brate, 1 << shift); in sta_stats_decode_rate()
2456 rinfo->flags = RATE_INFO_FLAGS_HE_MCS; in sta_stats_decode_rate()
2457 rinfo->mcs = STA_STATS_GET(HE_MCS, rate); in sta_stats_decode_rate()
2458 rinfo->nss = STA_STATS_GET(HE_NSS, rate); in sta_stats_decode_rate()
2459 rinfo->he_gi = STA_STATS_GET(HE_GI, rate); in sta_stats_decode_rate()
2460 rinfo->he_ru_alloc = STA_STATS_GET(HE_RU, rate); in sta_stats_decode_rate()
2461 rinfo->he_dcm = STA_STATS_GET(HE_DCM, rate); in sta_stats_decode_rate()
2464 rinfo->flags = RATE_INFO_FLAGS_EHT_MCS; in sta_stats_decode_rate()
2465 rinfo->mcs = STA_STATS_GET(EHT_MCS, rate); in sta_stats_decode_rate()
2466 rinfo->nss = STA_STATS_GET(EHT_NSS, rate); in sta_stats_decode_rate()
2467 rinfo->eht_gi = STA_STATS_GET(EHT_GI, rate); in sta_stats_decode_rate()
2468 rinfo->eht_ru_alloc = STA_STATS_GET(EHT_RU, rate); in sta_stats_decode_rate()
2475 u32 rate = READ_ONCE(sta_get_last_rx_stats(sta)->last_rate); in sta_set_rate_info_rx()
2478 return -EINVAL; in sta_set_rate_info_rx()
2480 sta_stats_decode_rate(sta->local, rate, rinfo); in sta_set_rate_info_rx()
2491 start = u64_stats_fetch_begin(&rxstats->syncp); in sta_get_tidstats_msdu()
2492 value = rxstats->msdu[tid]; in sta_get_tidstats_msdu()
2493 } while (u64_stats_fetch_retry(&rxstats->syncp, start)); in sta_get_tidstats_msdu()
2502 struct ieee80211_local *local = sta->local; in sta_set_tidstats()
2505 if (!(tidstats->filled & BIT(NL80211_TID_STATS_RX_MSDU))) { in sta_set_tidstats()
2506 tidstats->rx_msdu += sta_get_tidstats_msdu(&sta->deflink.rx_stats, in sta_set_tidstats()
2509 if (sta->deflink.pcpu_rx_stats) { in sta_set_tidstats()
2513 cpurxs = per_cpu_ptr(sta->deflink.pcpu_rx_stats, in sta_set_tidstats()
2515 tidstats->rx_msdu += in sta_set_tidstats()
2520 tidstats->filled |= BIT(NL80211_TID_STATS_RX_MSDU); in sta_set_tidstats()
2523 if (!(tidstats->filled & BIT(NL80211_TID_STATS_TX_MSDU))) { in sta_set_tidstats()
2524 tidstats->filled |= BIT(NL80211_TID_STATS_TX_MSDU); in sta_set_tidstats()
2525 tidstats->tx_msdu = sta->deflink.tx_stats.msdu[tid]; in sta_set_tidstats()
2528 if (!(tidstats->filled & BIT(NL80211_TID_STATS_TX_MSDU_RETRIES)) && in sta_set_tidstats()
2529 ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) { in sta_set_tidstats()
2530 tidstats->filled |= BIT(NL80211_TID_STATS_TX_MSDU_RETRIES); in sta_set_tidstats()
2531 tidstats->tx_msdu_retries = sta->deflink.status_stats.msdu_retries[tid]; in sta_set_tidstats()
2534 if (!(tidstats->filled & BIT(NL80211_TID_STATS_TX_MSDU_FAILED)) && in sta_set_tidstats()
2535 ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) { in sta_set_tidstats()
2536 tidstats->filled |= BIT(NL80211_TID_STATS_TX_MSDU_FAILED); in sta_set_tidstats()
2537 tidstats->tx_msdu_failed = sta->deflink.status_stats.msdu_failed[tid]; in sta_set_tidstats()
2541 spin_lock_bh(&local->fq.lock); in sta_set_tidstats()
2544 tidstats->filled |= BIT(NL80211_TID_STATS_TXQ_STATS); in sta_set_tidstats()
2545 ieee80211_fill_txq_stats(&tidstats->txq_stats, in sta_set_tidstats()
2546 to_txq_info(sta->sta.txq[tid])); in sta_set_tidstats()
2549 spin_unlock_bh(&local->fq.lock); in sta_set_tidstats()
2559 start = u64_stats_fetch_begin(&rxstats->syncp); in sta_get_stats_bytes()
2560 value = rxstats->bytes; in sta_get_stats_bytes()
2561 } while (u64_stats_fetch_retry(&rxstats->syncp, start)); in sta_get_stats_bytes()
2569 struct ieee80211_sub_if_data *sdata = sta->sdata; in sta_set_sinfo()
2570 struct ieee80211_local *local = sdata->local; in sta_set_sinfo()
2572 int i, ac, cpu; in sta_set_sinfo() local
2577 sinfo->generation = sdata->local->sta_generation; in sta_set_sinfo()
2583 if (sdata->vif.type == NL80211_IFTYPE_STATION) in sta_set_sinfo()
2584 sinfo->rx_beacon = sdata->deflink.u.mgd.count_beacon_signal; in sta_set_sinfo()
2586 drv_sta_statistics(local, sdata, &sta->sta, sinfo); in sta_set_sinfo()
2587 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_INACTIVE_TIME) | in sta_set_sinfo()
2594 if (sdata->vif.type == NL80211_IFTYPE_STATION) { in sta_set_sinfo()
2595 sinfo->beacon_loss_count = in sta_set_sinfo()
2596 sdata->deflink.u.mgd.beacon_loss_count; in sta_set_sinfo()
2597 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_BEACON_LOSS); in sta_set_sinfo()
2600 sinfo->connected_time = ktime_get_seconds() - sta->last_connected; in sta_set_sinfo()
2601 sinfo->assoc_at = sta->assoc_at; in sta_set_sinfo()
2602 sinfo->inactive_time = in sta_set_sinfo()
2603 jiffies_to_msecs(jiffies - ieee80211_sta_last_active(sta)); in sta_set_sinfo()
2605 if (!(sinfo->filled & (BIT_ULL(NL80211_STA_INFO_TX_BYTES64) | in sta_set_sinfo()
2607 sinfo->tx_bytes = 0; in sta_set_sinfo()
2608 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) in sta_set_sinfo()
2609 sinfo->tx_bytes += sta->deflink.tx_stats.bytes[ac]; in sta_set_sinfo()
2610 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BYTES64); in sta_set_sinfo()
2613 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_TX_PACKETS))) { in sta_set_sinfo()
2614 sinfo->tx_packets = 0; in sta_set_sinfo()
2615 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) in sta_set_sinfo()
2616 sinfo->tx_packets += sta->deflink.tx_stats.packets[ac]; in sta_set_sinfo()
2617 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_PACKETS); in sta_set_sinfo()
2620 if (!(sinfo->filled & (BIT_ULL(NL80211_STA_INFO_RX_BYTES64) | in sta_set_sinfo()
2622 sinfo->rx_bytes += sta_get_stats_bytes(&sta->deflink.rx_stats); in sta_set_sinfo()
2624 if (sta->deflink.pcpu_rx_stats) { in sta_set_sinfo()
2628 cpurxs = per_cpu_ptr(sta->deflink.pcpu_rx_stats, in sta_set_sinfo()
2630 sinfo->rx_bytes += sta_get_stats_bytes(cpurxs); in sta_set_sinfo()
2634 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_BYTES64); in sta_set_sinfo()
2637 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_RX_PACKETS))) { in sta_set_sinfo()
2638 sinfo->rx_packets = sta->deflink.rx_stats.packets; in sta_set_sinfo()
2639 if (sta->deflink.pcpu_rx_stats) { in sta_set_sinfo()
2643 cpurxs = per_cpu_ptr(sta->deflink.pcpu_rx_stats, in sta_set_sinfo()
2645 sinfo->rx_packets += cpurxs->packets; in sta_set_sinfo()
2648 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_PACKETS); in sta_set_sinfo()
2651 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_TX_RETRIES))) { in sta_set_sinfo()
2652 sinfo->tx_retries = sta->deflink.status_stats.retry_count; in sta_set_sinfo()
2653 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_RETRIES); in sta_set_sinfo()
2656 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_TX_FAILED))) { in sta_set_sinfo()
2657 sinfo->tx_failed = sta->deflink.status_stats.retry_failed; in sta_set_sinfo()
2658 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_FAILED); in sta_set_sinfo()
2661 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_RX_DURATION))) { in sta_set_sinfo()
2662 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) in sta_set_sinfo()
2663 sinfo->rx_duration += sta->airtime[ac].rx_airtime; in sta_set_sinfo()
2664 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_DURATION); in sta_set_sinfo()
2667 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_TX_DURATION))) { in sta_set_sinfo()
2668 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) in sta_set_sinfo()
2669 sinfo->tx_duration += sta->airtime[ac].tx_airtime; in sta_set_sinfo()
2670 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_DURATION); in sta_set_sinfo()
2673 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_AIRTIME_WEIGHT))) { in sta_set_sinfo()
2674 sinfo->airtime_weight = sta->airtime_weight; in sta_set_sinfo()
2675 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_AIRTIME_WEIGHT); in sta_set_sinfo()
2678 sinfo->rx_dropped_misc = sta->deflink.rx_stats.dropped; in sta_set_sinfo()
2679 if (sta->deflink.pcpu_rx_stats) { in sta_set_sinfo()
2683 cpurxs = per_cpu_ptr(sta->deflink.pcpu_rx_stats, cpu); in sta_set_sinfo()
2684 sinfo->rx_dropped_misc += cpurxs->dropped; in sta_set_sinfo()
2688 if (sdata->vif.type == NL80211_IFTYPE_STATION && in sta_set_sinfo()
2689 !(sdata->vif.driver_flags & IEEE80211_VIF_BEACON_FILTER)) { in sta_set_sinfo()
2690 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_BEACON_RX) | in sta_set_sinfo()
2692 sinfo->rx_beacon_signal_avg = ieee80211_ave_rssi(&sdata->vif); in sta_set_sinfo()
2695 if (ieee80211_hw_check(&sta->local->hw, SIGNAL_DBM) || in sta_set_sinfo()
2696 ieee80211_hw_check(&sta->local->hw, SIGNAL_UNSPEC)) { in sta_set_sinfo()
2697 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_SIGNAL))) { in sta_set_sinfo()
2698 sinfo->signal = (s8)last_rxstats->last_signal; in sta_set_sinfo()
2699 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL); in sta_set_sinfo()
2702 if (!sta->deflink.pcpu_rx_stats && in sta_set_sinfo()
2703 !(sinfo->filled & BIT_ULL(NL80211_STA_INFO_SIGNAL_AVG))) { in sta_set_sinfo()
2704 sinfo->signal_avg = in sta_set_sinfo()
2705 -ewma_signal_read(&sta->deflink.rx_stats_avg.signal); in sta_set_sinfo()
2706 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL_AVG); in sta_set_sinfo()
2710 /* for the average - if pcpu_rx_stats isn't set - rxstats must point to in sta_set_sinfo()
2711 * the sta->rx_stats struct, so the check here is fine with and without in sta_set_sinfo()
2714 if (last_rxstats->chains && in sta_set_sinfo()
2715 !(sinfo->filled & (BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL) | in sta_set_sinfo()
2717 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL); in sta_set_sinfo()
2718 if (!sta->deflink.pcpu_rx_stats) in sta_set_sinfo()
2719 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL_AVG); in sta_set_sinfo()
2721 sinfo->chains = last_rxstats->chains; in sta_set_sinfo()
2723 for (i = 0; i < ARRAY_SIZE(sinfo->chain_signal); i++) { in sta_set_sinfo()
2724 sinfo->chain_signal[i] = in sta_set_sinfo()
2725 last_rxstats->chain_signal_last[i]; in sta_set_sinfo()
2726 sinfo->chain_signal_avg[i] = in sta_set_sinfo()
2727 -ewma_signal_read(&sta->deflink.rx_stats_avg.chain_signal[i]); in sta_set_sinfo()
2731 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_TX_BITRATE)) && in sta_set_sinfo()
2732 !sta->sta.valid_links && in sta_set_sinfo()
2733 ieee80211_rate_valid(&sta->deflink.tx_stats.last_rate)) { in sta_set_sinfo()
2734 sta_set_rate_info_tx(sta, &sta->deflink.tx_stats.last_rate, in sta_set_sinfo()
2735 &sinfo->txrate); in sta_set_sinfo()
2736 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BITRATE); in sta_set_sinfo()
2739 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_RX_BITRATE)) && in sta_set_sinfo()
2740 !sta->sta.valid_links) { in sta_set_sinfo()
2741 if (sta_set_rate_info_rx(sta, &sinfo->rxrate) == 0) in sta_set_sinfo()
2742 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_BITRATE); in sta_set_sinfo()
2747 sta_set_tidstats(sta, &sinfo->pertid[i], i); in sta_set_sinfo()
2750 if (ieee80211_vif_is_mesh(&sdata->vif)) { in sta_set_sinfo()
2752 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_LLID) | in sta_set_sinfo()
2761 sinfo->llid = sta->mesh->llid; in sta_set_sinfo()
2762 sinfo->plid = sta->mesh->plid; in sta_set_sinfo()
2763 sinfo->plink_state = sta->mesh->plink_state; in sta_set_sinfo()
2765 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_T_OFFSET); in sta_set_sinfo()
2766 sinfo->t_offset = sta->mesh->t_offset; in sta_set_sinfo()
2768 sinfo->local_pm = sta->mesh->local_pm; in sta_set_sinfo()
2769 sinfo->peer_pm = sta->mesh->peer_pm; in sta_set_sinfo()
2770 sinfo->nonpeer_pm = sta->mesh->nonpeer_pm; in sta_set_sinfo()
2771 sinfo->connected_to_gate = sta->mesh->connected_to_gate; in sta_set_sinfo()
2772 sinfo->connected_to_as = sta->mesh->connected_to_as; in sta_set_sinfo()
2776 sinfo->bss_param.flags = 0; in sta_set_sinfo()
2777 if (sdata->vif.bss_conf.use_cts_prot) in sta_set_sinfo()
2778 sinfo->bss_param.flags |= BSS_PARAM_FLAGS_CTS_PROT; in sta_set_sinfo()
2779 if (sdata->vif.bss_conf.use_short_preamble) in sta_set_sinfo()
2780 sinfo->bss_param.flags |= BSS_PARAM_FLAGS_SHORT_PREAMBLE; in sta_set_sinfo()
2781 if (sdata->vif.bss_conf.use_short_slot) in sta_set_sinfo()
2782 sinfo->bss_param.flags |= BSS_PARAM_FLAGS_SHORT_SLOT_TIME; in sta_set_sinfo()
2783 sinfo->bss_param.dtim_period = sdata->vif.bss_conf.dtim_period; in sta_set_sinfo()
2784 sinfo->bss_param.beacon_interval = sdata->vif.bss_conf.beacon_int; in sta_set_sinfo()
2786 sinfo->sta_flags.set = 0; in sta_set_sinfo()
2787 sinfo->sta_flags.mask = BIT(NL80211_STA_FLAG_AUTHORIZED) | in sta_set_sinfo()
2795 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_AUTHORIZED); in sta_set_sinfo()
2797 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_SHORT_PREAMBLE); in sta_set_sinfo()
2798 if (sta->sta.wme) in sta_set_sinfo()
2799 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_WME); in sta_set_sinfo()
2801 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_MFP); in sta_set_sinfo()
2803 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_AUTHENTICATED); in sta_set_sinfo()
2805 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_ASSOCIATED); in sta_set_sinfo()
2807 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_TDLS_PEER); in sta_set_sinfo()
2812 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_EXPECTED_THROUGHPUT); in sta_set_sinfo()
2813 sinfo->expected_throughput = thr; in sta_set_sinfo()
2816 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_ACK_SIGNAL)) && in sta_set_sinfo()
2817 sta->deflink.status_stats.ack_signal_filled) { in sta_set_sinfo()
2818 sinfo->ack_signal = sta->deflink.status_stats.last_ack_signal; in sta_set_sinfo()
2819 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_ACK_SIGNAL); in sta_set_sinfo()
2822 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_ACK_SIGNAL_AVG)) && in sta_set_sinfo()
2823 sta->deflink.status_stats.ack_signal_filled) { in sta_set_sinfo()
2824 sinfo->avg_ack_signal = in sta_set_sinfo()
2825 -(s8)ewma_avg_signal_read( in sta_set_sinfo()
2826 &sta->deflink.status_stats.avg_ack_signal); in sta_set_sinfo()
2827 sinfo->filled |= in sta_set_sinfo()
2831 if (ieee80211_vif_is_mesh(&sdata->vif)) { in sta_set_sinfo()
2832 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_AIRTIME_LINK_METRIC); in sta_set_sinfo()
2833 sinfo->airtime_link_metric = in sta_set_sinfo()
2840 struct ieee80211_sub_if_data *sdata = sta->sdata; in sta_get_expected_throughput()
2841 struct ieee80211_local *local = sdata->local; in sta_get_expected_throughput()
2846 ref = local->rate_ctrl; in sta_get_expected_throughput()
2849 if (ref && ref->ops->get_expected_throughput) in sta_get_expected_throughput()
2850 thr = ref->ops->get_expected_throughput(sta->rate_ctrl_priv); in sta_get_expected_throughput()
2861 if (!sta->deflink.status_stats.last_ack || in ieee80211_sta_last_active()
2862 time_after(stats->last_rx, sta->deflink.status_stats.last_ack)) in ieee80211_sta_last_active()
2863 return stats->last_rx; in ieee80211_sta_last_active()
2864 return sta->deflink.status_stats.last_ack; in ieee80211_sta_last_active()
2869 if (thr && thr < STA_SLOW_THRESHOLD * sta->local->num_sta) { in sta_update_codel_params()
2870 sta->cparams.target = MS2TIME(50); in sta_update_codel_params()
2871 sta->cparams.interval = MS2TIME(300); in sta_update_codel_params()
2872 sta->cparams.ecn = false; in sta_update_codel_params()
2874 sta->cparams.target = MS2TIME(20); in sta_update_codel_params()
2875 sta->cparams.interval = MS2TIME(100); in sta_update_codel_params()
2876 sta->cparams.ecn = true; in sta_update_codel_params()
2890 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_sta_allocate_link()
2894 lockdep_assert_wiphy(sdata->local->hw.wiphy); in ieee80211_sta_allocate_link()
2899 if (WARN_ON(!sta->sta.valid_links)) in ieee80211_sta_allocate_link()
2900 return -EINVAL; in ieee80211_sta_allocate_link()
2902 if (WARN_ON(sta->sta.valid_links & BIT(link_id) || in ieee80211_sta_allocate_link()
2903 sta->link[link_id])) in ieee80211_sta_allocate_link()
2904 return -EBUSY; in ieee80211_sta_allocate_link()
2908 return -ENOMEM; in ieee80211_sta_allocate_link()
2910 ret = sta_info_alloc_link(sdata->local, &alloc->info, GFP_KERNEL); in ieee80211_sta_allocate_link()
2916 sta_info_add_link(sta, link_id, &alloc->info, &alloc->sta); in ieee80211_sta_allocate_link()
2918 ieee80211_link_sta_debugfs_add(&alloc->info); in ieee80211_sta_allocate_link()
2925 lockdep_assert_wiphy(sta->sdata->local->hw.wiphy); in ieee80211_sta_free_link()
2934 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_sta_activate_link()
2936 u16 old_links = sta->sta.valid_links; in ieee80211_sta_activate_link()
2940 link_sta = rcu_dereference_protected(sta->link[link_id], in ieee80211_sta_activate_link()
2941 lockdep_is_held(&sdata->local->hw.wiphy->mtx)); in ieee80211_sta_activate_link()
2944 return -EINVAL; in ieee80211_sta_activate_link()
2947 if (link_sta_info_hash_lookup(sdata->local, link_sta->addr)) { in ieee80211_sta_activate_link()
2949 return -EALREADY; in ieee80211_sta_activate_link()
2954 sta->sta.valid_links = new_links; in ieee80211_sta_activate_link()
2964 ieee80211_sta_recalc_aggregates(&sta->sta); in ieee80211_sta_activate_link()
2966 ret = drv_change_sta_links(sdata->local, sdata, &sta->sta, in ieee80211_sta_activate_link()
2969 sta->sta.valid_links = old_links; in ieee80211_sta_activate_link()
2975 ret = link_sta_info_hash_add(sdata->local, link_sta); in ieee80211_sta_activate_link()
2982 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_sta_remove_link()
2983 u16 old_links = sta->sta.valid_links; in ieee80211_sta_remove_link()
2985 lockdep_assert_wiphy(sdata->local->hw.wiphy); in ieee80211_sta_remove_link()
2987 sta->sta.valid_links &= ~BIT(link_id); in ieee80211_sta_remove_link()
2990 drv_change_sta_links(sdata->local, sdata, &sta->sta, in ieee80211_sta_remove_link()
2991 old_links, sta->sta.valid_links); in ieee80211_sta_remove_link()
3002 sta->sta.max_amsdu_subframes = 0; in ieee80211_sta_set_max_amsdu_subframes()
3016 sta->sta.max_amsdu_subframes = 4 << (4 - val); in ieee80211_sta_set_max_amsdu_subframes()
3024 return lockdep_is_held(&sta->local->hw.wiphy->mtx); in lockdep_sta_mutex_held()