Lines Matching refs:sta

52  * we support. For a regular station this mean we add the AP sta when we
54 * get to know about a peer on the same IBSS. For WDS we add the sta for
78 struct sta_info *sta)
80 return rhltable_remove(&local->sta_hash, &sta->hash_node,
84 static void __cleanup_single_sta(struct sta_info *sta)
88 struct ieee80211_sub_if_data *sdata = sta->sdata;
92 if (test_sta_flag(sta, WLAN_STA_PS_STA) ||
93 test_sta_flag(sta, WLAN_STA_PS_DRIVER) ||
94 test_sta_flag(sta, WLAN_STA_PS_DELIVER)) {
95 if (sta->sdata->vif.type == NL80211_IFTYPE_AP ||
96 sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
103 clear_sta_flag(sta, WLAN_STA_PS_STA);
104 clear_sta_flag(sta, WLAN_STA_PS_DRIVER);
105 clear_sta_flag(sta, WLAN_STA_PS_DELIVER);
110 if (sta->sta.txq[0]) {
111 for (i = 0; i < ARRAY_SIZE(sta->sta.txq); i++) {
114 if (!sta->sta.txq[i])
117 txqi = to_txq_info(sta->sta.txq[i]);
124 local->total_ps_buffered -= skb_queue_len(&sta->ps_tx_buf[ac]);
125 ieee80211_purge_tx_queue(&local->hw, &sta->ps_tx_buf[ac]);
126 ieee80211_purge_tx_queue(&local->hw, &sta->tx_filtered[ac]);
130 mesh_sta_cleanup(sta);
132 cancel_work_sync(&sta->drv_deliver_wk);
141 kfree(sta->ampdu_mlme.tid_start_tx[i]);
142 tid_tx = rcu_dereference_raw(sta->ampdu_mlme.tid_tx[i]);
150 static void cleanup_single_sta(struct sta_info *sta)
152 struct ieee80211_sub_if_data *sdata = sta->sdata;
155 __cleanup_single_sta(sta);
156 sta_info_free(local, sta);
171 struct sta_info *sta;
174 for_each_sta_info(local, addr, sta, tmp) {
175 if (sta->sdata == sdata) {
180 return sta;
188 * Get sta info either from the specified interface
196 struct sta_info *sta;
199 for_each_sta_info(local, addr, sta, tmp) {
200 if (sta->sdata == sdata ||
201 (sta->sdata->bss && sta->sdata->bss == sdata->bss)) {
206 return sta;
217 struct sta_info *sta;
219 for_each_sta_info(local, sta_addr, sta, tmp) {
220 if (ether_addr_equal(vif_addr, sta->sdata->vif.addr))
221 return sta;
231 struct sta_info *sta;
234 list_for_each_entry_rcu(sta, &local->sta_list, list,
236 if (sdata != sta->sdata)
242 return sta;
252 * @sta: STA info to free
259 void sta_info_free(struct ieee80211_local *local, struct sta_info *sta)
269 while (sta->sta_state > IEEE80211_STA_NONE) {
272 WARN_ON_ONCE(test_sta_flag(sta, WLAN_STA_INSERTED));
274 ret = sta_info_move_state(sta, sta->sta_state - 1);
279 if (sta->rate_ctrl)
280 rate_control_free_sta(sta);
282 sta_dbg(sta->sdata, "Destroyed STA %pM\n", sta->sta.addr);
284 if (sta->sta.txq[0])
285 kfree(to_txq_info(sta->sta.txq[0]));
286 kfree(rcu_dereference_raw(sta->sta.rates));
288 kfree(sta->mesh);
290 free_percpu(sta->pcpu_rx_stats);
291 kfree(sta);
296 struct sta_info *sta)
298 return rhltable_insert(&local->sta_hash, &sta->hash_node,
304 struct sta_info *sta;
306 sta = container_of(wk, struct sta_info, drv_deliver_wk);
308 if (sta->dead)
312 if (!test_sta_flag(sta, WLAN_STA_PS_STA))
313 ieee80211_sta_ps_deliver_wakeup(sta);
314 else if (test_and_clear_sta_flag(sta, WLAN_STA_PSPOLL))
315 ieee80211_sta_ps_deliver_poll_response(sta);
316 else if (test_and_clear_sta_flag(sta, WLAN_STA_UAPSD))
317 ieee80211_sta_ps_deliver_uapsd(sta);
322 struct sta_info *sta, gfp_t gfp)
327 sta->rate_ctrl = local->rate_ctrl;
328 sta->rate_ctrl_priv = rate_control_alloc_sta(sta->rate_ctrl,
329 sta, gfp);
330 if (!sta->rate_ctrl_priv)
341 struct sta_info *sta;
344 sta = kzalloc(sizeof(*sta) + hw->sta_data_size, gfp);
345 if (!sta)
349 sta->pcpu_rx_stats =
351 if (!sta->pcpu_rx_stats)
355 spin_lock_init(&sta->lock);
356 spin_lock_init(&sta->ps_lock);
357 INIT_WORK(&sta->drv_deliver_wk, sta_deliver_ps_frames);
358 INIT_WORK(&sta->ampdu_mlme.work, ieee80211_ba_session_work);
359 mutex_init(&sta->ampdu_mlme.mtx);
362 sta->mesh = kzalloc(sizeof(*sta->mesh), gfp);
363 if (!sta->mesh)
365 sta->mesh->plink_sta = sta;
366 spin_lock_init(&sta->mesh->plink_lock);
369 timer_setup(&sta->mesh->plink_timer, mesh_plink_timer,
371 sta->mesh->nonpeer_pm = NL80211_MESH_POWER_ACTIVE;
375 memcpy(sta->addr, addr, ETH_ALEN);
376 memcpy(sta->sta.addr, addr, ETH_ALEN);
377 sta->sta.max_rx_aggregation_subframes =
386 BUILD_BUG_ON(ARRAY_SIZE(sta->ptk) <= INVALID_PTK_KEYIDX);
387 sta->ptk_idx = INVALID_PTK_KEYIDX;
389 sta->local = local;
390 sta->sdata = sdata;
391 sta->rx_stats.last_rx = jiffies;
393 u64_stats_init(&sta->rx_stats.syncp);
395 ieee80211_init_frag_cache(&sta->frags);
397 sta->sta_state = IEEE80211_STA_NONE;
400 sta->reserved_tid = IEEE80211_TID_UNRESERVED;
402 sta->last_connected = ktime_get_seconds();
403 ewma_signal_init(&sta->rx_stats_avg.signal);
404 ewma_avg_signal_init(&sta->status_stats.avg_ack_signal);
405 for (i = 0; i < ARRAY_SIZE(sta->rx_stats_avg.chain_signal); i++)
406 ewma_signal_init(&sta->rx_stats_avg.chain_signal[i]);
413 txq_data = kcalloc(ARRAY_SIZE(sta->sta.txq), size, gfp);
417 for (i = 0; i < ARRAY_SIZE(sta->sta.txq); i++) {
421 ieee80211_txq_init(sdata, sta, txq, i);
425 if (sta_prepare_rate_control(local, sta, gfp))
428 sta->airtime_weight = IEEE80211_DEFAULT_AIRTIME_WEIGHT;
431 skb_queue_head_init(&sta->ps_tx_buf[i]);
432 skb_queue_head_init(&sta->tx_filtered[i]);
433 sta->airtime[i].deficit = sta->airtime_weight;
434 atomic_set(&sta->airtime[i].aql_tx_pending, 0);
435 sta->airtime[i].aql_limit_low = local->aql_txq_limit_low[i];
436 sta->airtime[i].aql_limit_high = local->aql_txq_limit_high[i];
440 sta->last_seq_ctrl[i] = cpu_to_le16(USHRT_MAX);
479 sta->sta.supp_rates[i] |= BIT(r);
483 sta->sta.smps_mode = IEEE80211_SMPS_OFF;
501 sta->known_smps_mode = IEEE80211_SMPS_OFF;
504 sta->known_smps_mode = IEEE80211_SMPS_STATIC;
507 sta->known_smps_mode = IEEE80211_SMPS_DYNAMIC;
514 sta->sta.max_rc_amsdu_len = IEEE80211_MAX_MPDU_LEN_HT_BA;
516 sta->cparams.ce_threshold = CODEL_DISABLED_THRESHOLD;
517 sta->cparams.target = MS2TIME(20);
518 sta->cparams.interval = MS2TIME(100);
519 sta->cparams.ecn = true;
521 sta_dbg(sdata, "Allocated STA %pM\n", sta->sta.addr);
523 return sta;
526 if (sta->sta.txq[0])
527 kfree(to_txq_info(sta->sta.txq[0]));
529 free_percpu(sta->pcpu_rx_stats);
531 kfree(sta->mesh);
533 kfree(sta);
537 static int sta_info_insert_check(struct sta_info *sta)
539 struct ieee80211_sub_if_data *sdata = sta->sdata;
549 if (WARN_ON(ether_addr_equal(sta->sta.addr, sdata->vif.addr) ||
550 is_multicast_ether_addr(sta->sta.addr)))
560 ieee80211_find_sta_by_ifaddr(&sdata->local->hw, sta->addr, NULL)) {
571 struct sta_info *sta)
576 for (state = IEEE80211_STA_NOTEXIST; state < sta->sta_state; state++) {
577 err = drv_sta_state(local, sdata, sta, state, state + 1);
588 sta->uploaded = true;
595 sta->sta.addr, state + 1, err);
601 WARN_ON(drv_sta_state(local, sdata, sta, state, state - 1));
611 struct sta_info *sta;
614 list_for_each_entry_rcu(sta, &local->sta_list, list) {
615 if (sdata != sta->sdata ||
616 !test_sta_flag(sta, WLAN_STA_ASSOC))
618 if (!sta->sta.support_p2p_ps) {
636 static int sta_info_insert_finish(struct sta_info *sta) __acquires(RCU)
638 struct ieee80211_local *local = sta->local;
639 struct ieee80211_sub_if_data *sdata = sta->sdata;
646 if (sta_info_get_bss(sdata, sta->sta.addr)) {
662 set_sta_flag(sta, WLAN_STA_BLOCK_BA);
665 err = sta_info_hash_add(local, sta);
669 list_add_tail_rcu(&sta->list, &local->sta_list);
672 err = sta_info_insert_drv_state(local, sdata, sta);
676 set_sta_flag(sta, WLAN_STA_INSERTED);
678 if (sta->sta_state >= IEEE80211_STA_ASSOC) {
679 ieee80211_recalc_min_chandef(sta->sdata);
680 if (!sta->sta.support_p2p_ps)
681 ieee80211_recalc_p2p_go_ps_allowed(sta->sdata);
685 clear_sta_flag(sta, WLAN_STA_BLOCK_BA);
687 ieee80211_sta_debugfs_add(sta);
688 rate_control_add_sta_debugfs(sta);
691 cfg80211_new_sta(sdata->dev, sta->sta.addr, sinfo, GFP_KERNEL);
694 sta_dbg(sdata, "Inserted STA %pM\n", sta->sta.addr);
703 ieee80211_check_fast_xmit(sta);
707 sta_info_hash_del(local, sta);
708 list_del_rcu(&sta->list);
713 cleanup_single_sta(sta);
720 int sta_info_insert_rcu(struct sta_info *sta) __acquires(RCU)
722 struct ieee80211_local *local = sta->local;
729 err = sta_info_insert_check(sta);
731 sta_info_free(local, sta);
737 return sta_info_insert_finish(sta);
740 int sta_info_insert(struct sta_info *sta)
742 int err = sta_info_insert_rcu(sta);
794 static void __sta_info_recalc_tim(struct sta_info *sta, bool ignore_pending)
796 struct ieee80211_local *local = sta->local;
799 u8 ignore_for_tim = sta->sta.uapsd_queues;
801 u16 id = sta->sta.aid;
803 if (sta->sdata->vif.type == NL80211_IFTYPE_AP ||
804 sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN) {
805 if (WARN_ON_ONCE(!sta->sdata->bss))
808 ps = &sta->sdata->bss->ps;
810 } else if (ieee80211_vif_is_mesh(&sta->sdata->vif)) {
811 ps = &sta->sdata->u.mesh.ps;
821 if (sta->dead)
842 indicate_tim |= !skb_queue_empty(&sta->tx_filtered[ac]) ||
843 !skb_queue_empty(&sta->ps_tx_buf[ac]);
850 sta->driver_buffered_tids & tids;
852 sta->txq_buffered_tids & tids;
866 if (local->ops->set_tim && !WARN_ON(sta->dead)) {
868 drv_set_tim(local, &sta->sta, indicate_tim);
876 void sta_info_recalc_tim(struct sta_info *sta)
878 __sta_info_recalc_tim(sta, false);
881 static bool sta_info_buffer_expired(struct sta_info *sta, struct sk_buff *skb)
892 timeout = (sta->listen_interval *
893 sta->sdata->vif.bss_conf.beacon_int *
902 struct sta_info *sta, int ac)
915 spin_lock_irqsave(&sta->tx_filtered[ac].lock, flags);
916 skb = skb_peek(&sta->tx_filtered[ac]);
917 if (sta_info_buffer_expired(sta, skb))
918 skb = __skb_dequeue(&sta->tx_filtered[ac]);
921 spin_unlock_irqrestore(&sta->tx_filtered[ac].lock, flags);
941 spin_lock_irqsave(&sta->ps_tx_buf[ac].lock, flags);
942 skb = skb_peek(&sta->ps_tx_buf[ac]);
943 if (sta_info_buffer_expired(sta, skb))
944 skb = __skb_dequeue(&sta->ps_tx_buf[ac]);
947 spin_unlock_irqrestore(&sta->ps_tx_buf[ac].lock, flags);
958 ps_dbg(sta->sdata, "Buffered frame expired (STA %pM)\n",
959 sta->sta.addr);
968 sta_info_recalc_tim(sta);
975 return !(skb_queue_empty(&sta->ps_tx_buf[ac]) &&
976 skb_queue_empty(&sta->tx_filtered[ac]));
980 struct sta_info *sta)
986 if (!sta->sdata->bss &&
987 !ieee80211_vif_is_mesh(&sta->sdata->vif))
992 sta_info_cleanup_expire_buffered_ac(local, sta, ac);
997 static int __must_check __sta_info_destroy_part1(struct sta_info *sta)
1005 if (!sta)
1008 local = sta->local;
1009 sdata = sta->sdata;
1019 set_sta_flag(sta, WLAN_STA_BLOCK_BA);
1020 ieee80211_sta_tear_down_BA_sessions(sta, AGG_STOP_DESTROY_STA);
1027 drv_sync_rx_queues(local, sta);
1029 ret = sta_info_hash_del(local, sta);
1037 if (test_sta_flag(sta, WLAN_STA_TDLS_OFF_CHANNEL)) {
1038 drv_tdls_cancel_channel_switch(local, sdata, &sta->sta);
1039 clear_sta_flag(sta, WLAN_STA_TDLS_OFF_CHANNEL);
1042 list_del_rcu(&sta->list);
1043 sta->removed = true;
1045 if (sta->uploaded)
1046 drv_sta_pre_rcu_remove(local, sta->sdata, sta);
1049 rcu_access_pointer(sdata->u.vlan.sta) == sta)
1050 RCU_INIT_POINTER(sdata->u.vlan.sta, NULL);
1055 static void __sta_info_destroy_part2(struct sta_info *sta)
1057 struct ieee80211_local *local = sta->local;
1058 struct ieee80211_sub_if_data *sdata = sta->sdata;
1070 if (sta->sta_state == IEEE80211_STA_AUTHORIZED) {
1071 ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC);
1076 ieee80211_free_sta_keys(local, sta);
1079 __sta_info_recalc_tim(sta, true);
1081 sta->dead = true;
1086 while (sta->sta_state > IEEE80211_STA_NONE) {
1087 ret = sta_info_move_state(sta, sta->sta_state - 1);
1094 if (sta->uploaded) {
1095 ret = drv_sta_state(local, sdata, sta, IEEE80211_STA_NONE,
1100 sta_dbg(sdata, "Removed STA %pM\n", sta->sta.addr);
1104 sta_set_sinfo(sta, sinfo, true);
1105 cfg80211_del_sta_sinfo(sdata->dev, sta->sta.addr, sinfo, GFP_KERNEL);
1108 ieee80211_sta_debugfs_remove(sta);
1110 ieee80211_destroy_frag_cache(&sta->frags);
1112 cleanup_single_sta(sta);
1115 int __must_check __sta_info_destroy(struct sta_info *sta)
1117 int err = __sta_info_destroy_part1(sta);
1124 __sta_info_destroy_part2(sta);
1131 struct sta_info *sta;
1135 sta = sta_info_get(sdata, addr);
1136 ret = __sta_info_destroy(sta);
1145 struct sta_info *sta;
1149 sta = sta_info_get_bss(sdata, addr);
1150 ret = __sta_info_destroy(sta);
1159 struct sta_info *sta;
1163 list_for_each_entry_rcu(sta, &local->sta_list, list)
1164 if (sta_info_cleanup_expire_buffered(local, sta))
1204 struct sta_info *sta, *tmp;
1214 list_for_each_entry_safe(sta, tmp, &local->sta_list, list) {
1215 if (sdata == sta->sdata ||
1216 (vlans && sdata->bss == sta->sdata->bss)) {
1217 if (!WARN_ON(__sta_info_destroy_part1(sta)))
1218 list_add(&sta->free_list, &free_list);
1225 list_for_each_entry_safe(sta, tmp, &free_list, free_list)
1226 __sta_info_destroy_part2(sta);
1237 struct sta_info *sta, *tmp;
1241 list_for_each_entry_safe(sta, tmp, &local->sta_list, list) {
1242 unsigned long last_active = ieee80211_sta_last_active(sta);
1244 if (sdata != sta->sdata)
1248 sta_dbg(sta->sdata, "expiring inactive STA %pM\n",
1249 sta->sta.addr);
1252 test_sta_flag(sta, WLAN_STA_PS_STA))
1255 WARN_ON(__sta_info_destroy(sta));
1268 struct sta_info *sta;
1274 for_each_sta_info(local, addr, sta, tmp) {
1276 !ether_addr_equal(sta->sdata->vif.addr, localaddr))
1278 if (!sta->uploaded)
1280 return &sta->sta;
1290 struct sta_info *sta;
1295 sta = sta_info_get_bss(vif_to_sdata(vif), addr);
1296 if (!sta)
1299 if (!sta->uploaded)
1302 return &sta->sta;
1307 void ieee80211_sta_ps_deliver_wakeup(struct sta_info *sta)
1309 struct ieee80211_sub_if_data *sdata = sta->sdata;
1327 clear_sta_flag(sta, WLAN_STA_SP);
1330 sta->driver_buffered_tids = 0;
1331 sta->txq_buffered_tids = 0;
1334 drv_sta_notify(local, sdata, STA_NOTIFY_AWAKE, &sta->sta);
1336 for (i = 0; i < ARRAY_SIZE(sta->sta.txq); i++) {
1337 if (!sta->sta.txq[i] || !txq_has_queue(sta->sta.txq[i]))
1340 schedule_and_wake_txq(local, to_txq_info(sta->sta.txq[i]));
1346 spin_lock_bh(&sta->ps_lock);
1351 spin_lock_irqsave(&sta->tx_filtered[ac].lock, flags);
1352 skb_queue_splice_tail_init(&sta->tx_filtered[ac], &pending);
1353 spin_unlock_irqrestore(&sta->tx_filtered[ac].lock, flags);
1358 spin_lock_irqsave(&sta->ps_tx_buf[ac].lock, flags);
1359 skb_queue_splice_tail_init(&sta->ps_tx_buf[ac], &pending);
1360 spin_unlock_irqrestore(&sta->ps_tx_buf[ac].lock, flags);
1368 clear_sta_flag(sta, WLAN_STA_PS_DELIVER);
1373 clear_sta_flag(sta, WLAN_STA_PSPOLL);
1374 clear_sta_flag(sta, WLAN_STA_UAPSD);
1375 spin_unlock_bh(&sta->ps_lock);
1381 sta_info_recalc_tim(sta);
1385 sta->sta.addr, sta->sta.aid, filtered, buffered);
1387 ieee80211_check_fast_xmit(sta);
1390 static void ieee80211_send_null_response(struct sta_info *sta, int tid,
1394 struct ieee80211_sub_if_data *sdata = sta->sdata;
1400 bool qos = sta->sta.wme;
1424 memcpy(nullfunc->addr1, sta->sta.addr, ETH_ALEN);
1458 drv_allow_buffered_frames(local, sta, BIT(tid), 1,
1472 ieee80211_xmit(sdata, sta, skb);
1493 ieee80211_sta_ps_more_data(struct sta_info *sta, u8 ignored_acs,
1512 if (!skb_queue_empty(&sta->tx_filtered[ac]) ||
1513 !skb_queue_empty(&sta->ps_tx_buf[ac]))
1521 ieee80211_sta_ps_get_frames(struct sta_info *sta, int n_frames, u8 ignored_acs,
1526 struct ieee80211_sub_if_data *sdata = sta->sdata;
1544 sta->driver_buffered_tids & tids;
1545 *driver_release_tids |= sta->txq_buffered_tids & tids;
1552 skb = skb_dequeue(&sta->tx_filtered[ac]);
1555 &sta->ps_tx_buf[ac]);
1570 if (!skb_queue_empty(&sta->tx_filtered[ac]) ||
1571 !skb_queue_empty(&sta->ps_tx_buf[ac]))
1577 ieee80211_sta_ps_deliver_response(struct sta_info *sta,
1581 struct ieee80211_sub_if_data *sdata = sta->sdata;
1588 set_sta_flag(sta, WLAN_STA_SP);
1592 ieee80211_sta_ps_get_frames(sta, n_frames, ignored_acs, reason,
1595 more_data = ieee80211_sta_ps_more_data(sta, ignored_acs, reason, driver_release_tids);
1625 ieee80211_send_null_response(sta, tid, reason, true, false);
1718 drv_allow_buffered_frames(local, sta, tids, num,
1725 sta, find_highest_prio_tid(tids),
1728 sta_info_recalc_tim(sta);
1742 drv_release_buffered_frames(local, sta, driver_release_tids,
1755 if (!sta->sta.txq[0])
1758 for (tid = 0; tid < ARRAY_SIZE(sta->sta.txq); tid++) {
1759 if (!sta->sta.txq[tid] ||
1761 txq_has_queue(sta->sta.txq[tid]))
1764 sta_info_recalc_tim(sta);
1770 void ieee80211_sta_ps_deliver_poll_response(struct sta_info *sta)
1772 u8 ignore_for_response = sta->sta.uapsd_queues;
1782 ieee80211_sta_ps_deliver_response(sta, 1, ignore_for_response,
1786 void ieee80211_sta_ps_deliver_uapsd(struct sta_info *sta)
1788 int n_frames = sta->sta.max_sp;
1789 u8 delivery_enabled = sta->sta.uapsd_queues;
1800 switch (sta->sta.max_sp) {
1816 ieee80211_sta_ps_deliver_response(sta, n_frames, ~delivery_enabled,
1823 struct sta_info *sta = container_of(pubsta, struct sta_info, sta);
1825 trace_api_sta_block_awake(sta->local, pubsta, block);
1828 set_sta_flag(sta, WLAN_STA_PS_DRIVER);
1829 ieee80211_clear_fast_xmit(sta);
1833 if (!test_sta_flag(sta, WLAN_STA_PS_DRIVER))
1836 if (!test_sta_flag(sta, WLAN_STA_PS_STA)) {
1837 set_sta_flag(sta, WLAN_STA_PS_DELIVER);
1838 clear_sta_flag(sta, WLAN_STA_PS_DRIVER);
1839 ieee80211_queue_work(hw, &sta->drv_deliver_wk);
1840 } else if (test_sta_flag(sta, WLAN_STA_PSPOLL) ||
1841 test_sta_flag(sta, WLAN_STA_UAPSD)) {
1843 clear_sta_flag(sta, WLAN_STA_PS_DRIVER);
1844 ieee80211_queue_work(hw, &sta->drv_deliver_wk);
1846 clear_sta_flag(sta, WLAN_STA_PS_DRIVER);
1847 ieee80211_check_fast_xmit(sta);
1854 struct sta_info *sta = container_of(pubsta, struct sta_info, sta);
1855 struct ieee80211_local *local = sta->local;
1859 clear_sta_flag(sta, WLAN_STA_SP);
1865 struct sta_info *sta = container_of(pubsta, struct sta_info, sta);
1869 trace_api_send_eosp_nullfunc(sta->local, pubsta, tid);
1872 more_data = ieee80211_sta_ps_more_data(sta, ~sta->sta.uapsd_queues,
1875 ieee80211_send_null_response(sta, tid, reason, false, more_data);
1882 struct sta_info *sta = container_of(pubsta, struct sta_info, sta);
1887 trace_api_sta_set_buffered(sta->local, pubsta, tid, buffered);
1890 set_bit(tid, &sta->driver_buffered_tids);
1892 clear_bit(tid, &sta->driver_buffered_tids);
1894 sta_info_recalc_tim(sta);
1901 struct sta_info *sta = container_of(pubsta, struct sta_info, sta);
1902 struct ieee80211_local *local = sta->sdata->local;
1906 if (sta->local->airtime_flags & AIRTIME_USE_TX)
1908 if (sta->local->airtime_flags & AIRTIME_USE_RX)
1912 sta->airtime[ac].tx_airtime += tx_airtime;
1913 sta->airtime[ac].rx_airtime += rx_airtime;
1914 sta->airtime[ac].deficit -= airtime;
1920 struct sta_info *sta, u8 ac,
1929 if (sta)
1931 &sta->airtime[ac].aql_tx_pending);
1937 if (sta) {
1939 &sta->airtime[ac].aql_tx_pending);
1941 atomic_cmpxchg(&sta->airtime[ac].aql_tx_pending,
1955 int sta_info_move_state(struct sta_info *sta,
1960 if (sta->sta_state == new_state)
1967 if (sta->sta_state != IEEE80211_STA_AUTH)
1971 if (sta->sta_state != IEEE80211_STA_NONE &&
1972 sta->sta_state != IEEE80211_STA_ASSOC)
1976 if (sta->sta_state != IEEE80211_STA_AUTH &&
1977 sta->sta_state != IEEE80211_STA_AUTHORIZED)
1981 if (sta->sta_state != IEEE80211_STA_ASSOC)
1989 sta_dbg(sta->sdata, "moving STA %pM to state %d\n",
1990 sta->sta.addr, new_state);
1996 if (test_sta_flag(sta, WLAN_STA_INSERTED)) {
1997 int err = drv_sta_state(sta->local, sta->sdata, sta,
1998 sta->sta_state, new_state);
2007 if (sta->sta_state == IEEE80211_STA_AUTH)
2008 clear_bit(WLAN_STA_AUTH, &sta->_flags);
2011 if (sta->sta_state == IEEE80211_STA_NONE) {
2012 set_bit(WLAN_STA_AUTH, &sta->_flags);
2013 } else if (sta->sta_state == IEEE80211_STA_ASSOC) {
2014 clear_bit(WLAN_STA_ASSOC, &sta->_flags);
2015 ieee80211_recalc_min_chandef(sta->sdata);
2016 if (!sta->sta.support_p2p_ps)
2017 ieee80211_recalc_p2p_go_ps_allowed(sta->sdata);
2021 if (sta->sta_state == IEEE80211_STA_AUTH) {
2022 set_bit(WLAN_STA_ASSOC, &sta->_flags);
2023 sta->assoc_at = ktime_get_boottime_ns();
2024 ieee80211_recalc_min_chandef(sta->sdata);
2025 if (!sta->sta.support_p2p_ps)
2026 ieee80211_recalc_p2p_go_ps_allowed(sta->sdata);
2027 } else if (sta->sta_state == IEEE80211_STA_AUTHORIZED) {
2028 ieee80211_vif_dec_num_mcast(sta->sdata);
2029 clear_bit(WLAN_STA_AUTHORIZED, &sta->_flags);
2030 ieee80211_clear_fast_xmit(sta);
2031 ieee80211_clear_fast_rx(sta);
2035 if (sta->sta_state == IEEE80211_STA_ASSOC) {
2036 ieee80211_vif_inc_num_mcast(sta->sdata);
2037 set_bit(WLAN_STA_AUTHORIZED, &sta->_flags);
2038 ieee80211_check_fast_xmit(sta);
2039 ieee80211_check_fast_rx(sta);
2041 if (sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
2042 sta->sdata->vif.type == NL80211_IFTYPE_AP)
2043 cfg80211_send_layer2_update(sta->sdata->dev,
2044 sta->sta.addr);
2050 sta->sta_state = new_state;
2055 u8 sta_info_tx_streams(struct sta_info *sta)
2057 struct ieee80211_sta_ht_cap *ht_cap = &sta->sta.ht_cap;
2060 if (!sta->sta.ht_cap.ht_supported)
2063 if (sta->sta.vht_cap.vht_supported) {
2066 le16_to_cpu(sta->sta.vht_cap.vht_mcs.tx_mcs_map);
2091 sta_get_last_rx_stats(struct sta_info *sta)
2093 struct ieee80211_sta_rx_stats *stats = &sta->rx_stats;
2096 if (!sta->pcpu_rx_stats)
2102 cpustats = per_cpu_ptr(sta->pcpu_rx_stats, cpu);
2163 static int sta_set_rate_info_rx(struct sta_info *sta, struct rate_info *rinfo)
2165 u32 rate = READ_ONCE(sta_get_last_rx_stats(sta)->last_rate);
2170 sta_stats_decode_rate(sta->local, rate, rinfo);
2188 static void sta_set_tidstats(struct sta_info *sta,
2192 struct ieee80211_local *local = sta->local;
2196 tidstats->rx_msdu += sta_get_tidstats_msdu(&sta->rx_stats, tid);
2198 if (sta->pcpu_rx_stats) {
2202 cpurxs = per_cpu_ptr(sta->pcpu_rx_stats, cpu);
2213 tidstats->tx_msdu = sta->tx_stats.msdu[tid];
2219 tidstats->tx_msdu_retries = sta->status_stats.msdu_retries[tid];
2225 tidstats->tx_msdu_failed = sta->status_stats.msdu_failed[tid];
2234 to_txq_info(sta->sta.txq[tid]));
2254 void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo,
2257 struct ieee80211_sub_if_data *sdata = sta->sdata;
2263 last_rxstats = sta_get_last_rx_stats(sta);
2274 drv_sta_statistics(local, sdata, &sta->sta, sinfo);
2287 sinfo->connected_time = ktime_get_seconds() - sta->last_connected;
2288 sinfo->assoc_at = sta->assoc_at;
2290 jiffies_to_msecs(jiffies - ieee80211_sta_last_active(sta));
2296 sinfo->tx_bytes += sta->tx_stats.bytes[ac];
2303 sinfo->tx_packets += sta->tx_stats.packets[ac];
2309 sinfo->rx_bytes += sta_get_stats_bytes(&sta->rx_stats);
2311 if (sta->pcpu_rx_stats) {
2315 cpurxs = per_cpu_ptr(sta->pcpu_rx_stats, cpu);
2324 sinfo->rx_packets = sta->rx_stats.packets;
2325 if (sta->pcpu_rx_stats) {
2329 cpurxs = per_cpu_ptr(sta->pcpu_rx_stats, cpu);
2337 sinfo->tx_retries = sta->status_stats.retry_count;
2342 sinfo->tx_failed = sta->status_stats.retry_failed;
2348 sinfo->rx_duration += sta->airtime[ac].rx_airtime;
2354 sinfo->tx_duration += sta->airtime[ac].tx_airtime;
2359 sinfo->airtime_weight = sta->airtime_weight;
2363 sinfo->rx_dropped_misc = sta->rx_stats.dropped;
2364 if (sta->pcpu_rx_stats) {
2368 cpurxs = per_cpu_ptr(sta->pcpu_rx_stats, cpu);
2380 if (ieee80211_hw_check(&sta->local->hw, SIGNAL_DBM) ||
2381 ieee80211_hw_check(&sta->local->hw, SIGNAL_UNSPEC)) {
2387 if (!sta->pcpu_rx_stats &&
2390 -ewma_signal_read(&sta->rx_stats_avg.signal);
2396 * the sta->rx_stats struct, so the check here is fine with and without
2403 if (!sta->pcpu_rx_stats)
2412 -ewma_signal_read(&sta->rx_stats_avg.chain_signal[i]);
2417 sta_set_rate_info_tx(sta, &sta->tx_stats.last_rate,
2423 if (sta_set_rate_info_rx(sta, &sinfo->rxrate) == 0)
2429 sta_set_tidstats(sta, &sinfo->pertid[i], i);
2443 sinfo->llid = sta->mesh->llid;
2444 sinfo->plid = sta->mesh->plid;
2445 sinfo->plink_state = sta->mesh->plink_state;
2446 if (test_sta_flag(sta, WLAN_STA_TOFFSET_KNOWN)) {
2448 sinfo->t_offset = sta->mesh->t_offset;
2450 sinfo->local_pm = sta->mesh->local_pm;
2451 sinfo->peer_pm = sta->mesh->peer_pm;
2452 sinfo->nonpeer_pm = sta->mesh->nonpeer_pm;
2453 sinfo->connected_to_gate = sta->mesh->connected_to_gate;
2454 sinfo->connected_to_as = sta->mesh->connected_to_as;
2476 if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
2478 if (test_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE))
2480 if (sta->sta.wme)
2482 if (test_sta_flag(sta, WLAN_STA_MFP))
2484 if (test_sta_flag(sta, WLAN_STA_AUTH))
2486 if (test_sta_flag(sta, WLAN_STA_ASSOC))
2488 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER))
2491 thr = sta_get_expected_throughput(sta);
2499 sta->status_stats.ack_signal_filled) {
2500 sinfo->ack_signal = sta->status_stats.last_ack_signal;
2505 sta->status_stats.ack_signal_filled) {
2508 &sta->status_stats.avg_ack_signal);
2516 airtime_link_metric_get(local, sta);
2520 u32 sta_get_expected_throughput(struct sta_info *sta)
2522 struct ieee80211_sub_if_data *sdata = sta->sdata;
2527 if (test_sta_flag(sta, WLAN_STA_RATE_CONTROL))
2532 thr = ref->ops->get_expected_throughput(sta->rate_ctrl_priv);
2534 thr = drv_get_expected_throughput(local, sta);
2539 unsigned long ieee80211_sta_last_active(struct sta_info *sta)
2541 struct ieee80211_sta_rx_stats *stats = sta_get_last_rx_stats(sta);
2543 if (!sta->status_stats.last_ack ||
2544 time_after(stats->last_rx, sta->status_stats.last_ack))
2546 return sta->status_stats.last_ack;
2549 static void sta_update_codel_params(struct sta_info *sta, u32 thr)
2551 if (!sta->sdata->local->ops->wake_tx_queue)
2554 if (thr && thr < STA_SLOW_THRESHOLD * sta->local->num_sta) {
2555 sta->cparams.target = MS2TIME(50);
2556 sta->cparams.interval = MS2TIME(300);
2557 sta->cparams.ecn = false;
2559 sta->cparams.target = MS2TIME(20);
2560 sta->cparams.interval = MS2TIME(100);
2561 sta->cparams.ecn = true;
2568 struct sta_info *sta = container_of(pubsta, struct sta_info, sta);
2570 sta_update_codel_params(sta, thr);