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