Lines Matching +full:ac +full:- +full:link
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright 2002-2005, Instant802 Networks, Inc.
4 * Copyright 2005-2006, Devicescape Software, Inc.
5 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
7 * Copyright 2013-2014 Intel Mobile Communications GmbH
8 * Copyright (C) 2018-2024 Intel Corporation
32 #include "driver-ops.h"
48 struct ieee80211_local *local = tx->local; in ieee80211_duration()
56 if (tx->rate.flags & (IEEE80211_TX_RC_MCS | IEEE80211_TX_RC_VHT_MCS)) in ieee80211_duration()
60 chanctx_conf = rcu_dereference(tx->sdata->vif.bss_conf.chanctx_conf); in ieee80211_duration()
62 shift = ieee80211_chandef_get_shift(&chanctx_conf->def); in ieee80211_duration()
63 rate_flags = ieee80211_chandef_rate_flags(&chanctx_conf->def); in ieee80211_duration()
68 if (WARN_ON_ONCE(tx->rate.idx < 0)) in ieee80211_duration()
71 sband = local->hw.wiphy->bands[info->band]; in ieee80211_duration()
72 txrate = &sband->bitrates[tx->rate.idx]; in ieee80211_duration()
74 erp = txrate->flags & IEEE80211_RATE_ERP_G; in ieee80211_duration()
77 if (sband->band == NL80211_BAND_S1GHZ) in ieee80211_duration()
82 * - during CFP: 32768 in ieee80211_duration()
83 * - during contention period: in ieee80211_duration()
91 * - control response frame (CTS or ACK) shall be transmitted using the in ieee80211_duration()
97 hdr = (struct ieee80211_hdr *)skb->data; in ieee80211_duration()
98 if (ieee80211_is_ctl(hdr->frame_control)) { in ieee80211_duration()
120 if (group_addr) /* Group address as the destination - no ACK */ in ieee80211_duration()
133 rate = -1; in ieee80211_duration()
135 mrate = sband->bitrates[0].bitrate; in ieee80211_duration()
136 for (i = 0; i < sband->n_bitrates; i++) { in ieee80211_duration()
137 struct ieee80211_rate *r = &sband->bitrates[i]; in ieee80211_duration()
139 if (r->bitrate > txrate->bitrate) in ieee80211_duration()
142 if ((rate_flags & r->flags) != rate_flags) in ieee80211_duration()
145 if (tx->sdata->vif.bss_conf.basic_rates & BIT(i)) in ieee80211_duration()
146 rate = DIV_ROUND_UP(r->bitrate, 1 << shift); in ieee80211_duration()
148 switch (sband->band) { in ieee80211_duration()
152 if (tx->sdata->deflink.operating_11g_mode) in ieee80211_duration()
156 if (r->flags & flag) in ieee80211_duration()
157 mrate = r->bitrate; in ieee80211_duration()
162 if (r->flags & IEEE80211_RATE_MANDATORY_A) in ieee80211_duration()
163 mrate = r->bitrate; in ieee80211_duration()
173 if (rate == -1) { in ieee80211_duration()
180 if (ieee80211_is_data_qos(hdr->frame_control) && in ieee80211_duration()
185 * (10 bytes + 4-byte FCS = 112 bits) plus SIFS; rounded up in ieee80211_duration()
187 dur = ieee80211_frame_duration(sband->band, 10, rate, erp, in ieee80211_duration()
188 tx->sdata->vif.bss_conf.use_short_preamble, in ieee80211_duration()
196 dur += ieee80211_frame_duration(sband->band, next_frag_len, in ieee80211_duration()
197 txrate->bitrate, erp, in ieee80211_duration()
198 tx->sdata->vif.bss_conf.use_short_preamble, in ieee80211_duration()
209 struct ieee80211_local *local = tx->local; in ieee80211_tx_h_dynamic_ps()
211 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); in ieee80211_tx_h_dynamic_ps()
214 if (!ieee80211_hw_check(&local->hw, SUPPORTS_PS)) in ieee80211_tx_h_dynamic_ps()
218 if (ieee80211_hw_check(&local->hw, SUPPORTS_DYNAMIC_PS)) in ieee80211_tx_h_dynamic_ps()
222 if (local->hw.conf.dynamic_ps_timeout <= 0) in ieee80211_tx_h_dynamic_ps()
226 if (local->scanning) in ieee80211_tx_h_dynamic_ps()
229 if (!local->ps_sdata) in ieee80211_tx_h_dynamic_ps()
233 if (local->quiescing) in ieee80211_tx_h_dynamic_ps()
237 if (tx->sdata->vif.type != NL80211_IFTYPE_STATION) in ieee80211_tx_h_dynamic_ps()
240 if (unlikely(info->flags & IEEE80211_TX_INTFL_OFFCHAN_TX_OK)) in ieee80211_tx_h_dynamic_ps()
243 ifmgd = &tx->sdata->u.mgd; in ieee80211_tx_h_dynamic_ps()
246 * Don't wakeup from power save if u-apsd is enabled, voip ac has in ieee80211_tx_h_dynamic_ps()
247 * u-apsd enabled and the frame is in voip class. This effectively in ieee80211_tx_h_dynamic_ps()
248 * means that even if all access categories have u-apsd enabled, in in ieee80211_tx_h_dynamic_ps()
249 * practise u-apsd is only used with the voip ac. This is a in ieee80211_tx_h_dynamic_ps()
254 * Note: ifmgd->uapsd_queues access is racy here. If the value is in ieee80211_tx_h_dynamic_ps()
258 if ((ifmgd->flags & IEEE80211_STA_UAPSD_ENABLED) && in ieee80211_tx_h_dynamic_ps()
259 (ifmgd->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VO) && in ieee80211_tx_h_dynamic_ps()
260 skb_get_queue_mapping(tx->skb) == IEEE80211_AC_VO) in ieee80211_tx_h_dynamic_ps()
263 if (local->hw.conf.flags & IEEE80211_CONF_PS) { in ieee80211_tx_h_dynamic_ps()
264 ieee80211_stop_queues_by_reason(&local->hw, in ieee80211_tx_h_dynamic_ps()
268 ifmgd->flags &= ~IEEE80211_STA_NULLFUNC_ACKED; in ieee80211_tx_h_dynamic_ps()
269 ieee80211_queue_work(&local->hw, in ieee80211_tx_h_dynamic_ps()
270 &local->dynamic_ps_disable_work); in ieee80211_tx_h_dynamic_ps()
274 if (!ifmgd->associated) in ieee80211_tx_h_dynamic_ps()
277 mod_timer(&local->dynamic_ps_timer, jiffies + in ieee80211_tx_h_dynamic_ps()
278 msecs_to_jiffies(local->hw.conf.dynamic_ps_timeout)); in ieee80211_tx_h_dynamic_ps()
287 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; in ieee80211_tx_h_check_assoc()
288 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); in ieee80211_tx_h_check_assoc()
291 if (unlikely(info->flags & IEEE80211_TX_CTL_INJECTED)) in ieee80211_tx_h_check_assoc()
294 if (unlikely(test_bit(SCAN_SW_SCANNING, &tx->local->scanning)) && in ieee80211_tx_h_check_assoc()
295 test_bit(SDATA_STATE_OFFCHANNEL, &tx->sdata->state) && in ieee80211_tx_h_check_assoc()
296 !ieee80211_is_probe_req(hdr->frame_control) && in ieee80211_tx_h_check_assoc()
297 !ieee80211_is_any_nullfunc(hdr->frame_control)) in ieee80211_tx_h_check_assoc()
304 * off-channel. See the link below and in ieee80211_tx_h_check_assoc()
311 if (tx->sdata->vif.type == NL80211_IFTYPE_OCB) in ieee80211_tx_h_check_assoc()
314 if (tx->flags & IEEE80211_TX_PS_BUFFERED) in ieee80211_tx_h_check_assoc()
317 if (tx->sta) in ieee80211_tx_h_check_assoc()
318 assoc = test_sta_flag(tx->sta, WLAN_STA_ASSOC); in ieee80211_tx_h_check_assoc()
320 if (likely(tx->flags & IEEE80211_TX_UNICAST)) { in ieee80211_tx_h_check_assoc()
322 ieee80211_is_data(hdr->frame_control))) { in ieee80211_tx_h_check_assoc()
324 sdata_info(tx->sdata, in ieee80211_tx_h_check_assoc()
326 hdr->addr1); in ieee80211_tx_h_check_assoc()
328 I802_DEBUG_INC(tx->local->tx_handlers_drop_not_assoc); in ieee80211_tx_h_check_assoc()
331 } else if (unlikely(ieee80211_is_data(hdr->frame_control) && in ieee80211_tx_h_check_assoc()
332 ieee80211_vif_get_num_mcast_if(tx->sdata) == 0)) { in ieee80211_tx_h_check_assoc()
334 * No associated STAs - no need to send multicast in ieee80211_tx_h_check_assoc()
354 list_for_each_entry_rcu(sdata, &local->interfaces, list) { in purge_old_ps_buffers()
357 if (sdata->vif.type == NL80211_IFTYPE_AP) in purge_old_ps_buffers()
358 ps = &sdata->u.ap.ps; in purge_old_ps_buffers()
359 else if (ieee80211_vif_is_mesh(&sdata->vif)) in purge_old_ps_buffers()
360 ps = &sdata->u.mesh.ps; in purge_old_ps_buffers()
364 skb = skb_dequeue(&ps->bc_buf); in purge_old_ps_buffers()
367 ieee80211_free_txskb(&local->hw, skb); in purge_old_ps_buffers()
369 total += skb_queue_len(&ps->bc_buf); in purge_old_ps_buffers()
373 * Drop one frame from each station from the lowest-priority in purge_old_ps_buffers()
374 * AC that has frames at all. in purge_old_ps_buffers()
376 list_for_each_entry_rcu(sta, &local->sta_list, list) { in purge_old_ps_buffers()
377 int ac; in purge_old_ps_buffers() local
379 for (ac = IEEE80211_AC_BK; ac >= IEEE80211_AC_VO; ac--) { in purge_old_ps_buffers()
380 skb = skb_dequeue(&sta->ps_tx_buf[ac]); in purge_old_ps_buffers()
381 total += skb_queue_len(&sta->ps_tx_buf[ac]); in purge_old_ps_buffers()
384 ieee80211_free_txskb(&local->hw, skb); in purge_old_ps_buffers()
390 local->total_ps_buffered = total; in purge_old_ps_buffers()
391 ps_dbg_hw(&local->hw, "PS buffers full - purged %d frames\n", purged); in purge_old_ps_buffers()
397 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); in ieee80211_tx_h_multicast_ps_buf()
398 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; in ieee80211_tx_h_multicast_ps_buf()
410 if (tx->sdata->vif.type == NL80211_IFTYPE_AP || in ieee80211_tx_h_multicast_ps_buf()
411 tx->sdata->vif.type == NL80211_IFTYPE_AP_VLAN) { in ieee80211_tx_h_multicast_ps_buf()
412 if (!tx->sdata->bss) in ieee80211_tx_h_multicast_ps_buf()
415 ps = &tx->sdata->bss->ps; in ieee80211_tx_h_multicast_ps_buf()
416 } else if (ieee80211_vif_is_mesh(&tx->sdata->vif)) { in ieee80211_tx_h_multicast_ps_buf()
417 ps = &tx->sdata->u.mesh.ps; in ieee80211_tx_h_multicast_ps_buf()
424 if (ieee80211_has_order(hdr->frame_control)) in ieee80211_tx_h_multicast_ps_buf()
427 if (ieee80211_is_probe_req(hdr->frame_control)) in ieee80211_tx_h_multicast_ps_buf()
430 if (ieee80211_hw_check(&tx->local->hw, QUEUE_CONTROL)) in ieee80211_tx_h_multicast_ps_buf()
431 info->hw_queue = tx->sdata->vif.cab_queue; in ieee80211_tx_h_multicast_ps_buf()
434 if (!atomic_read(&ps->num_sta_ps) && skb_queue_empty(&ps->bc_buf)) in ieee80211_tx_h_multicast_ps_buf()
437 info->flags |= IEEE80211_TX_CTL_SEND_AFTER_DTIM; in ieee80211_tx_h_multicast_ps_buf()
440 if (!ieee80211_hw_check(&tx->local->hw, HOST_BROADCAST_PS_BUFFERING)) in ieee80211_tx_h_multicast_ps_buf()
444 if (tx->local->total_ps_buffered >= TOTAL_MAX_TX_BUFFER) in ieee80211_tx_h_multicast_ps_buf()
445 purge_old_ps_buffers(tx->local); in ieee80211_tx_h_multicast_ps_buf()
447 if (skb_queue_len(&ps->bc_buf) >= AP_MAX_BC_BUFFER) { in ieee80211_tx_h_multicast_ps_buf()
448 ps_dbg(tx->sdata, in ieee80211_tx_h_multicast_ps_buf()
449 "BC TX buffer full - dropping the oldest frame\n"); in ieee80211_tx_h_multicast_ps_buf()
450 ieee80211_free_txskb(&tx->local->hw, skb_dequeue(&ps->bc_buf)); in ieee80211_tx_h_multicast_ps_buf()
452 tx->local->total_ps_buffered++; in ieee80211_tx_h_multicast_ps_buf()
454 skb_queue_tail(&ps->bc_buf, tx->skb); in ieee80211_tx_h_multicast_ps_buf()
477 struct sta_info *sta = tx->sta; in ieee80211_tx_h_unicast_ps_buf()
478 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); in ieee80211_tx_h_unicast_ps_buf()
479 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; in ieee80211_tx_h_unicast_ps_buf()
480 struct ieee80211_local *local = tx->local; in ieee80211_tx_h_unicast_ps_buf()
488 !(info->flags & IEEE80211_TX_CTL_NO_PS_BUFFER))) { in ieee80211_tx_h_unicast_ps_buf()
489 int ac = skb_get_queue_mapping(tx->skb); in ieee80211_tx_h_unicast_ps_buf() local
491 if (ieee80211_is_mgmt(hdr->frame_control) && in ieee80211_tx_h_unicast_ps_buf()
492 !ieee80211_is_bufferable_mmpdu(tx->skb)) { in ieee80211_tx_h_unicast_ps_buf()
493 info->flags |= IEEE80211_TX_CTL_NO_PS_BUFFER; in ieee80211_tx_h_unicast_ps_buf()
497 ps_dbg(sta->sdata, "STA %pM aid %d: PS buffer for AC %d\n", in ieee80211_tx_h_unicast_ps_buf()
498 sta->sta.addr, sta->sta.aid, ac); in ieee80211_tx_h_unicast_ps_buf()
499 if (tx->local->total_ps_buffered >= TOTAL_MAX_TX_BUFFER) in ieee80211_tx_h_unicast_ps_buf()
500 purge_old_ps_buffers(tx->local); in ieee80211_tx_h_unicast_ps_buf()
503 spin_lock(&sta->ps_lock); in ieee80211_tx_h_unicast_ps_buf()
512 spin_unlock(&sta->ps_lock); in ieee80211_tx_h_unicast_ps_buf()
516 if (skb_queue_len(&sta->ps_tx_buf[ac]) >= STA_MAX_TX_BUFFER) { in ieee80211_tx_h_unicast_ps_buf()
517 struct sk_buff *old = skb_dequeue(&sta->ps_tx_buf[ac]); in ieee80211_tx_h_unicast_ps_buf()
518 ps_dbg(tx->sdata, in ieee80211_tx_h_unicast_ps_buf()
519 "STA %pM TX buffer for AC %d full - dropping oldest frame\n", in ieee80211_tx_h_unicast_ps_buf()
520 sta->sta.addr, ac); in ieee80211_tx_h_unicast_ps_buf()
521 ieee80211_free_txskb(&local->hw, old); in ieee80211_tx_h_unicast_ps_buf()
523 tx->local->total_ps_buffered++; in ieee80211_tx_h_unicast_ps_buf()
525 info->control.jiffies = jiffies; in ieee80211_tx_h_unicast_ps_buf()
526 info->control.vif = &tx->sdata->vif; in ieee80211_tx_h_unicast_ps_buf()
527 info->control.flags |= IEEE80211_TX_INTCFL_NEED_TXPROCESSING; in ieee80211_tx_h_unicast_ps_buf()
528 info->flags &= ~IEEE80211_TX_TEMPORARY_FLAGS; in ieee80211_tx_h_unicast_ps_buf()
529 skb_queue_tail(&sta->ps_tx_buf[ac], tx->skb); in ieee80211_tx_h_unicast_ps_buf()
530 spin_unlock(&sta->ps_lock); in ieee80211_tx_h_unicast_ps_buf()
532 if (!timer_pending(&local->sta_cleanup)) in ieee80211_tx_h_unicast_ps_buf()
533 mod_timer(&local->sta_cleanup, in ieee80211_tx_h_unicast_ps_buf()
545 ps_dbg(tx->sdata, in ieee80211_tx_h_unicast_ps_buf()
546 "STA %pM in PS mode, but polling/in SP -> send frame\n", in ieee80211_tx_h_unicast_ps_buf()
547 sta->sta.addr); in ieee80211_tx_h_unicast_ps_buf()
556 if (unlikely(tx->flags & IEEE80211_TX_PS_BUFFERED)) in ieee80211_tx_h_ps_buf()
559 if (tx->flags & IEEE80211_TX_UNICAST) in ieee80211_tx_h_ps_buf()
568 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); in ieee80211_tx_h_check_control_port_protocol()
570 if (unlikely(tx->sdata->control_port_protocol == tx->skb->protocol)) { in ieee80211_tx_h_check_control_port_protocol()
571 if (tx->sdata->control_port_no_encrypt) in ieee80211_tx_h_check_control_port_protocol()
572 info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; in ieee80211_tx_h_check_control_port_protocol()
573 info->control.flags |= IEEE80211_TX_CTRL_PORT_CTRL_PROTO; in ieee80211_tx_h_check_control_port_protocol()
574 info->flags |= IEEE80211_TX_CTL_USE_MINRATE; in ieee80211_tx_h_check_control_port_protocol()
583 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; in ieee80211_select_link_key()
584 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); in ieee80211_select_link_key()
585 struct ieee80211_link_data *link; in ieee80211_select_link_key() local
588 link_id = u32_get_bits(info->control.flags, IEEE80211_TX_CTRL_MLO_LINK); in ieee80211_select_link_key()
590 link = &tx->sdata->deflink; in ieee80211_select_link_key()
592 link = rcu_dereference(tx->sdata->link[link_id]); in ieee80211_select_link_key()
593 if (!link) in ieee80211_select_link_key()
597 if (ieee80211_is_group_privacy_action(tx->skb)) in ieee80211_select_link_key()
598 return rcu_dereference(link->default_multicast_key); in ieee80211_select_link_key()
599 else if (ieee80211_is_mgmt(hdr->frame_control) && in ieee80211_select_link_key()
600 is_multicast_ether_addr(hdr->addr1) && in ieee80211_select_link_key()
601 ieee80211_is_robust_mgmt_frame(tx->skb)) in ieee80211_select_link_key()
602 return rcu_dereference(link->default_mgmt_key); in ieee80211_select_link_key()
603 else if (is_multicast_ether_addr(hdr->addr1)) in ieee80211_select_link_key()
604 return rcu_dereference(link->default_multicast_key); in ieee80211_select_link_key()
613 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); in ieee80211_tx_h_select_key()
614 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; in ieee80211_tx_h_select_key()
616 if (unlikely(info->flags & IEEE80211_TX_INTFL_DONT_ENCRYPT)) { in ieee80211_tx_h_select_key()
617 tx->key = NULL; in ieee80211_tx_h_select_key()
621 if (tx->sta && in ieee80211_tx_h_select_key()
622 (key = rcu_dereference(tx->sta->ptk[tx->sta->ptk_idx]))) in ieee80211_tx_h_select_key()
623 tx->key = key; in ieee80211_tx_h_select_key()
625 tx->key = key; in ieee80211_tx_h_select_key()
626 else if (!is_multicast_ether_addr(hdr->addr1) && in ieee80211_tx_h_select_key()
627 (key = rcu_dereference(tx->sdata->default_unicast_key))) in ieee80211_tx_h_select_key()
628 tx->key = key; in ieee80211_tx_h_select_key()
630 tx->key = NULL; in ieee80211_tx_h_select_key()
632 if (tx->key) { in ieee80211_tx_h_select_key()
637 switch (tx->key->conf.cipher) { in ieee80211_tx_h_select_key()
641 if (!ieee80211_is_data_present(hdr->frame_control)) in ieee80211_tx_h_select_key()
642 tx->key = NULL; in ieee80211_tx_h_select_key()
648 if (!ieee80211_is_data_present(hdr->frame_control) && in ieee80211_tx_h_select_key()
649 !ieee80211_use_mfp(hdr->frame_control, tx->sta, in ieee80211_tx_h_select_key()
650 tx->skb) && in ieee80211_tx_h_select_key()
651 !ieee80211_is_group_privacy_action(tx->skb)) in ieee80211_tx_h_select_key()
652 tx->key = NULL; in ieee80211_tx_h_select_key()
654 skip_hw = (tx->key->conf.flags & in ieee80211_tx_h_select_key()
656 ieee80211_is_mgmt(hdr->frame_control); in ieee80211_tx_h_select_key()
662 if (!ieee80211_is_mgmt(hdr->frame_control)) in ieee80211_tx_h_select_key()
663 tx->key = NULL; in ieee80211_tx_h_select_key()
667 if (unlikely(tx->key && tx->key->flags & KEY_FLAG_TAINTED && in ieee80211_tx_h_select_key()
668 !ieee80211_is_deauth(hdr->frame_control)) && in ieee80211_tx_h_select_key()
669 tx->skb->protocol != tx->sdata->control_port_protocol) in ieee80211_tx_h_select_key()
672 if (!skip_hw && tx->key && in ieee80211_tx_h_select_key()
673 tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) in ieee80211_tx_h_select_key()
674 info->control.hw_key = &tx->key->conf; in ieee80211_tx_h_select_key()
675 } else if (ieee80211_is_data_present(hdr->frame_control) && tx->sta && in ieee80211_tx_h_select_key()
676 test_sta_flag(tx->sta, WLAN_STA_USES_ENCRYPTION)) { in ieee80211_tx_h_select_key()
686 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); in ieee80211_tx_h_rate_ctrl()
687 struct ieee80211_hdr *hdr = (void *)tx->skb->data; in ieee80211_tx_h_rate_ctrl()
692 bool encap = info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP; in ieee80211_tx_h_rate_ctrl()
697 sband = tx->local->hw.wiphy->bands[info->band]; in ieee80211_tx_h_rate_ctrl()
699 len = min_t(u32, tx->skb->len + FCS_LEN, in ieee80211_tx_h_rate_ctrl()
700 tx->local->hw.wiphy->frag_threshold); in ieee80211_tx_h_rate_ctrl()
703 txrc.hw = &tx->local->hw; in ieee80211_tx_h_rate_ctrl()
705 txrc.bss_conf = &tx->sdata->vif.bss_conf; in ieee80211_tx_h_rate_ctrl()
706 txrc.skb = tx->skb; in ieee80211_tx_h_rate_ctrl()
707 txrc.reported_rate.idx = -1; in ieee80211_tx_h_rate_ctrl()
709 if (unlikely(info->control.flags & IEEE80211_TX_CTRL_DONT_USE_RATE_MASK)) { in ieee80211_tx_h_rate_ctrl()
712 txrc.rate_idx_mask = tx->sdata->rc_rateidx_mask[info->band]; in ieee80211_tx_h_rate_ctrl()
714 if (tx->sdata->rc_has_mcs_mask[info->band]) in ieee80211_tx_h_rate_ctrl()
716 tx->sdata->rc_rateidx_mcs_mask[info->band]; in ieee80211_tx_h_rate_ctrl()
719 txrc.bss = (tx->sdata->vif.type == NL80211_IFTYPE_AP || in ieee80211_tx_h_rate_ctrl()
720 tx->sdata->vif.type == NL80211_IFTYPE_MESH_POINT || in ieee80211_tx_h_rate_ctrl()
721 tx->sdata->vif.type == NL80211_IFTYPE_ADHOC || in ieee80211_tx_h_rate_ctrl()
722 tx->sdata->vif.type == NL80211_IFTYPE_OCB); in ieee80211_tx_h_rate_ctrl()
725 if (len > tx->local->hw.wiphy->rts_threshold) { in ieee80211_tx_h_rate_ctrl()
729 info->control.use_rts = txrc.rts; in ieee80211_tx_h_rate_ctrl()
730 info->control.use_cts_prot = tx->sdata->vif.bss_conf.use_cts_prot; in ieee80211_tx_h_rate_ctrl()
735 * that -- the management frame might be to a station that in ieee80211_tx_h_rate_ctrl()
738 if (tx->sdata->vif.bss_conf.use_short_preamble && in ieee80211_tx_h_rate_ctrl()
739 (ieee80211_is_tx_data(tx->skb) || in ieee80211_tx_h_rate_ctrl()
740 (tx->sta && test_sta_flag(tx->sta, WLAN_STA_SHORT_PREAMBLE)))) in ieee80211_tx_h_rate_ctrl()
743 info->control.short_preamble = txrc.short_preamble; in ieee80211_tx_h_rate_ctrl()
746 if (info->control.flags & IEEE80211_TX_CTRL_RATE_INJECT) in ieee80211_tx_h_rate_ctrl()
749 if (tx->sta) in ieee80211_tx_h_rate_ctrl()
750 assoc = test_sta_flag(tx->sta, WLAN_STA_ASSOC); in ieee80211_tx_h_rate_ctrl()
756 if (WARN(test_bit(SCAN_SW_SCANNING, &tx->local->scanning) && assoc && in ieee80211_tx_h_rate_ctrl()
757 !rate_usable_index_exists(sband, &tx->sta->sta), in ieee80211_tx_h_rate_ctrl()
761 tx->sdata->name, in ieee80211_tx_h_rate_ctrl()
762 encap ? ((struct ethhdr *)hdr)->h_dest : hdr->addr1, in ieee80211_tx_h_rate_ctrl()
763 info->band ? 5 : 2)) in ieee80211_tx_h_rate_ctrl()
770 rate_control_get_rate(tx->sdata, tx->sta, &txrc); in ieee80211_tx_h_rate_ctrl()
772 if (tx->sta && !info->control.skip_table) in ieee80211_tx_h_rate_ctrl()
773 ratetbl = rcu_dereference(tx->sta->sta.rates); in ieee80211_tx_h_rate_ctrl()
775 if (unlikely(info->control.rates[0].idx < 0)) { in ieee80211_tx_h_rate_ctrl()
778 .idx = ratetbl->rate[0].idx, in ieee80211_tx_h_rate_ctrl()
779 .flags = ratetbl->rate[0].flags, in ieee80211_tx_h_rate_ctrl()
780 .count = ratetbl->rate[0].count in ieee80211_tx_h_rate_ctrl()
783 if (ratetbl->rate[0].idx < 0) in ieee80211_tx_h_rate_ctrl()
786 tx->rate = rate; in ieee80211_tx_h_rate_ctrl()
791 tx->rate = info->control.rates[0]; in ieee80211_tx_h_rate_ctrl()
795 txrc.reported_rate = tx->rate; in ieee80211_tx_h_rate_ctrl()
796 if (tx->sta && ieee80211_is_tx_data(tx->skb)) in ieee80211_tx_h_rate_ctrl()
797 tx->sta->deflink.tx_stats.last_rate = txrc.reported_rate; in ieee80211_tx_h_rate_ctrl()
798 } else if (tx->sta) in ieee80211_tx_h_rate_ctrl()
799 tx->sta->deflink.tx_stats.last_rate = txrc.reported_rate; in ieee80211_tx_h_rate_ctrl()
804 if (unlikely(!info->control.rates[0].count)) in ieee80211_tx_h_rate_ctrl()
805 info->control.rates[0].count = 1; in ieee80211_tx_h_rate_ctrl()
807 if (WARN_ON_ONCE((info->control.rates[0].count > 1) && in ieee80211_tx_h_rate_ctrl()
808 (info->flags & IEEE80211_TX_CTL_NO_ACK))) in ieee80211_tx_h_rate_ctrl()
809 info->control.rates[0].count = 1; in ieee80211_tx_h_rate_ctrl()
816 u16 *seq = &sta->tid_seq[tid]; in ieee80211_tx_next_seq()
828 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); in ieee80211_tx_h_sequence()
829 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; in ieee80211_tx_h_sequence()
837 if (unlikely(info->control.vif->type == NL80211_IFTYPE_MONITOR)) in ieee80211_tx_h_sequence()
840 if (unlikely(ieee80211_is_ctl(hdr->frame_control))) in ieee80211_tx_h_sequence()
843 if (ieee80211_hdrlen(hdr->frame_control) < 24) in ieee80211_tx_h_sequence()
846 if (ieee80211_is_qos_nullfunc(hdr->frame_control)) in ieee80211_tx_h_sequence()
849 if (info->control.flags & IEEE80211_TX_CTRL_NO_SEQNO) in ieee80211_tx_h_sequence()
853 if (unlikely(is_multicast_ether_addr(hdr->addr1) && in ieee80211_tx_h_sequence()
854 ieee80211_vif_is_mld(info->control.vif) && in ieee80211_tx_h_sequence()
855 info->control.vif->type == NL80211_IFTYPE_AP)) { in ieee80211_tx_h_sequence()
856 if (info->control.flags & IEEE80211_TX_CTRL_MCAST_MLO_FIRST_TX) in ieee80211_tx_h_sequence()
857 tx->sdata->mld_mcast_seq += 0x10; in ieee80211_tx_h_sequence()
858 hdr->seq_ctrl = cpu_to_le16(tx->sdata->mld_mcast_seq); in ieee80211_tx_h_sequence()
866 * also use the global counter (802.11-2012 9.3.2.10). in ieee80211_tx_h_sequence()
868 if (!ieee80211_is_data_qos(hdr->frame_control) || in ieee80211_tx_h_sequence()
869 is_multicast_ether_addr(hdr->addr1)) { in ieee80211_tx_h_sequence()
871 info->flags |= IEEE80211_TX_CTL_ASSIGN_SEQ; in ieee80211_tx_h_sequence()
873 hdr->seq_ctrl = cpu_to_le16(tx->sdata->sequence_number); in ieee80211_tx_h_sequence()
874 tx->sdata->sequence_number += 0x10; in ieee80211_tx_h_sequence()
875 if (tx->sta) in ieee80211_tx_h_sequence()
876 tx->sta->deflink.tx_stats.msdu[IEEE80211_NUM_TIDS]++; in ieee80211_tx_h_sequence()
883 * above since they are not QoS-data frames. in ieee80211_tx_h_sequence()
885 if (!tx->sta) in ieee80211_tx_h_sequence()
888 /* include per-STA, per-TID sequence counter */ in ieee80211_tx_h_sequence()
890 tx->sta->deflink.tx_stats.msdu[tid]++; in ieee80211_tx_h_sequence()
892 hdr->seq_ctrl = ieee80211_tx_next_seq(tx->sta, tid); in ieee80211_tx_h_sequence()
901 struct ieee80211_local *local = tx->local; in ieee80211_fragment()
904 int per_fragm = frag_threshold - hdrlen - FCS_LEN; in ieee80211_fragment()
906 int rem = skb->len - hdrlen - per_fragm; in ieee80211_fragment()
909 return -EINVAL; in ieee80211_fragment()
918 rem -= fraglen; in ieee80211_fragment()
919 tmp = dev_alloc_skb(local->tx_headroom + in ieee80211_fragment()
924 return -ENOMEM; in ieee80211_fragment()
926 __skb_queue_tail(&tx->skbs, tmp); in ieee80211_fragment()
929 local->tx_headroom + IEEE80211_ENCRYPT_HEADROOM); in ieee80211_fragment()
932 memcpy(tmp->cb, skb->cb, sizeof(tmp->cb)); in ieee80211_fragment()
935 info->flags &= ~(IEEE80211_TX_CTL_CLEAR_PS_FILT | in ieee80211_fragment()
939 info->flags |= IEEE80211_TX_CTL_MORE_FRAMES; in ieee80211_fragment()
942 tmp->priority = skb->priority; in ieee80211_fragment()
943 tmp->dev = skb->dev; in ieee80211_fragment()
946 skb_put_data(tmp, skb->data, hdrlen); in ieee80211_fragment()
947 skb_put_data(tmp, skb->data + pos, fraglen); in ieee80211_fragment()
960 struct sk_buff *skb = tx->skb; in ieee80211_tx_h_fragment()
962 struct ieee80211_hdr *hdr = (void *)skb->data; in ieee80211_tx_h_fragment()
963 int frag_threshold = tx->local->hw.wiphy->frag_threshold; in ieee80211_tx_h_fragment()
967 /* no matter what happens, tx->skb moves to tx->skbs */ in ieee80211_tx_h_fragment()
968 __skb_queue_tail(&tx->skbs, skb); in ieee80211_tx_h_fragment()
969 tx->skb = NULL; in ieee80211_tx_h_fragment()
971 if (info->flags & IEEE80211_TX_CTL_DONTFRAG) in ieee80211_tx_h_fragment()
974 if (ieee80211_hw_check(&tx->local->hw, SUPPORTS_TX_FRAG)) in ieee80211_tx_h_fragment()
978 * Warn when submitting a fragmented A-MPDU frame and drop it. in ieee80211_tx_h_fragment()
982 if (WARN_ON(info->flags & IEEE80211_TX_CTL_AMPDU)) in ieee80211_tx_h_fragment()
985 hdrlen = ieee80211_hdrlen(hdr->frame_control); in ieee80211_tx_h_fragment()
988 if (WARN_ON(skb->len + FCS_LEN <= frag_threshold)) in ieee80211_tx_h_fragment()
993 * chain them (using skb as the first fragment) to skb->next. in ieee80211_tx_h_fragment()
995 * fragments from this list. When the low-level driver rejects one in ieee80211_tx_h_fragment()
1005 skb_queue_walk(&tx->skbs, skb) { in ieee80211_tx_h_fragment()
1008 hdr = (void *)skb->data; in ieee80211_tx_h_fragment()
1011 if (!skb_queue_is_last(&tx->skbs, skb)) { in ieee80211_tx_h_fragment()
1012 hdr->frame_control |= morefrags; in ieee80211_tx_h_fragment()
1014 * No multi-rate retries for fragmented frames, that in ieee80211_tx_h_fragment()
1017 info->control.rates[1].idx = -1; in ieee80211_tx_h_fragment()
1018 info->control.rates[2].idx = -1; in ieee80211_tx_h_fragment()
1019 info->control.rates[3].idx = -1; in ieee80211_tx_h_fragment()
1021 info->flags &= ~IEEE80211_TX_CTL_RATE_CTRL_PROBE; in ieee80211_tx_h_fragment()
1023 hdr->frame_control &= ~morefrags; in ieee80211_tx_h_fragment()
1025 hdr->seq_ctrl |= cpu_to_le16(fragnum & IEEE80211_SCTL_FRAG); in ieee80211_tx_h_fragment()
1036 int ac = -1; in ieee80211_tx_h_stats() local
1038 if (!tx->sta) in ieee80211_tx_h_stats()
1041 skb_queue_walk(&tx->skbs, skb) { in ieee80211_tx_h_stats()
1042 ac = skb_get_queue_mapping(skb); in ieee80211_tx_h_stats()
1043 tx->sta->deflink.tx_stats.bytes[ac] += skb->len; in ieee80211_tx_h_stats()
1045 if (ac >= 0) in ieee80211_tx_h_stats()
1046 tx->sta->deflink.tx_stats.packets[ac]++; in ieee80211_tx_h_stats()
1054 if (!tx->key) in ieee80211_tx_h_encrypt()
1057 switch (tx->key->conf.cipher) { in ieee80211_tx_h_encrypt()
1092 skb_queue_walk(&tx->skbs, skb) { in ieee80211_tx_h_calculate_duration()
1093 hdr = (void *) skb->data; in ieee80211_tx_h_calculate_duration()
1094 if (unlikely(ieee80211_is_pspoll(hdr->frame_control))) in ieee80211_tx_h_calculate_duration()
1096 if (!skb_queue_is_last(&tx->skbs, skb)) { in ieee80211_tx_h_calculate_duration()
1097 struct sk_buff *next = skb_queue_next(&tx->skbs, skb); in ieee80211_tx_h_calculate_duration()
1098 next_len = next->len; in ieee80211_tx_h_calculate_duration()
1101 group_addr = is_multicast_ether_addr(hdr->addr1); in ieee80211_tx_h_calculate_duration()
1103 hdr->duration_id = in ieee80211_tx_h_calculate_duration()
1122 if (test_bit(HT_AGG_STATE_OPERATIONAL, &tid_tx->state)) { in ieee80211_tx_prep_agg()
1124 } else if (test_bit(HT_AGG_STATE_WANT_START, &tid_tx->state)) { in ieee80211_tx_prep_agg()
1126 * nothing -- this aggregation session is being started in ieee80211_tx_prep_agg()
1129 } else if (!tx->sta->sta.txq[tid]) { in ieee80211_tx_prep_agg()
1130 spin_lock(&tx->sta->lock); in ieee80211_tx_prep_agg()
1132 * Need to re-check now, because we may get here in ieee80211_tx_prep_agg()
1137 * queue yet -- if this happened we acquire the lock in ieee80211_tx_prep_agg()
1144 * before it was assigned) -- in this case it may in ieee80211_tx_prep_agg()
1149 tid_tx = rcu_dereference_protected_tid_tx(tx->sta, tid); in ieee80211_tx_prep_agg()
1153 } else if (test_bit(HT_AGG_STATE_OPERATIONAL, &tid_tx->state)) { in ieee80211_tx_prep_agg()
1157 if (info->flags & IEEE80211_TX_CTL_NO_PS_BUFFER) { in ieee80211_tx_prep_agg()
1158 clear_sta_flag(tx->sta, WLAN_STA_SP); in ieee80211_tx_prep_agg()
1159 ps_dbg(tx->sta->sdata, in ieee80211_tx_prep_agg()
1161 tx->sta->sta.addr, tx->sta->sta.aid); in ieee80211_tx_prep_agg()
1163 info->control.vif = &tx->sdata->vif; in ieee80211_tx_prep_agg()
1164 info->control.flags |= IEEE80211_TX_INTCFL_NEED_TXPROCESSING; in ieee80211_tx_prep_agg()
1165 info->flags &= ~IEEE80211_TX_TEMPORARY_FLAGS; in ieee80211_tx_prep_agg()
1166 __skb_queue_tail(&tid_tx->pending, skb); in ieee80211_tx_prep_agg()
1167 if (skb_queue_len(&tid_tx->pending) > STA_MAX_TX_BUFFER) in ieee80211_tx_prep_agg()
1168 purge_skb = __skb_dequeue(&tid_tx->pending); in ieee80211_tx_prep_agg()
1170 spin_unlock(&tx->sta->lock); in ieee80211_tx_prep_agg()
1173 ieee80211_free_txskb(&tx->local->hw, purge_skb); in ieee80211_tx_prep_agg()
1178 tid_tx->last_tx = jiffies; in ieee80211_tx_prep_agg()
1186 struct rate_control_ref *ref = sdata->local->rate_ctrl; in ieee80211_aggr_check()
1189 if (!ref || !(ref->ops->capa & RATE_CTRL_CAPA_AMPDU_TRIGGER)) in ieee80211_aggr_check()
1192 if (!sta || !sta->sta.deflink.ht_cap.ht_supported || in ieee80211_aggr_check()
1193 !sta->sta.wme || skb_get_queue_mapping(skb) == IEEE80211_AC_VO || in ieee80211_aggr_check()
1194 skb->protocol == sdata->control_port_protocol) in ieee80211_aggr_check()
1197 tid = skb->priority & IEEE80211_QOS_CTL_TID_MASK; in ieee80211_aggr_check()
1198 if (likely(sta->ampdu_mlme.tid_tx[tid])) in ieee80211_aggr_check()
1201 ieee80211_start_tx_ba_session(&sta->sta, tid, 0); in ieee80211_aggr_check()
1214 struct ieee80211_local *local = sdata->local; in ieee80211_tx_prepare()
1221 tx->skb = skb; in ieee80211_tx_prepare()
1222 tx->local = local; in ieee80211_tx_prepare()
1223 tx->sdata = sdata; in ieee80211_tx_prepare()
1224 __skb_queue_head_init(&tx->skbs); in ieee80211_tx_prepare()
1231 info->control.flags &= ~IEEE80211_TX_INTCFL_NEED_TXPROCESSING; in ieee80211_tx_prepare()
1233 hdr = (struct ieee80211_hdr *) skb->data; in ieee80211_tx_prepare()
1237 tx->sta = sta; in ieee80211_tx_prepare()
1239 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) { in ieee80211_tx_prepare()
1240 tx->sta = rcu_dereference(sdata->u.vlan.sta); in ieee80211_tx_prepare()
1241 if (!tx->sta && sdata->wdev.use_4addr) in ieee80211_tx_prepare()
1243 } else if (tx->sdata->control_port_protocol == tx->skb->protocol) { in ieee80211_tx_prepare()
1244 tx->sta = sta_info_get_bss(sdata, hdr->addr1); in ieee80211_tx_prepare()
1246 if (!tx->sta && !is_multicast_ether_addr(hdr->addr1)) { in ieee80211_tx_prepare()
1247 tx->sta = sta_info_get(sdata, hdr->addr1); in ieee80211_tx_prepare()
1252 if (tx->sta && ieee80211_is_data_qos(hdr->frame_control) && in ieee80211_tx_prepare()
1253 !ieee80211_is_qos_nullfunc(hdr->frame_control) && in ieee80211_tx_prepare()
1254 ieee80211_hw_check(&local->hw, AMPDU_AGGREGATION) && in ieee80211_tx_prepare()
1255 !ieee80211_hw_check(&local->hw, TX_AMPDU_SETUP_IN_HW)) { in ieee80211_tx_prepare()
1259 tid_tx = rcu_dereference(tx->sta->ampdu_mlme.tid_tx[tid]); in ieee80211_tx_prepare()
1261 ieee80211_aggr_check(sdata, tx->sta, skb); in ieee80211_tx_prepare()
1262 tid_tx = rcu_dereference(tx->sta->ampdu_mlme.tid_tx[tid]); in ieee80211_tx_prepare()
1276 if (is_multicast_ether_addr(hdr->addr1)) { in ieee80211_tx_prepare()
1277 tx->flags &= ~IEEE80211_TX_UNICAST; in ieee80211_tx_prepare()
1278 info->flags |= IEEE80211_TX_CTL_NO_ACK; in ieee80211_tx_prepare()
1280 tx->flags |= IEEE80211_TX_UNICAST; in ieee80211_tx_prepare()
1282 if (!(info->flags & IEEE80211_TX_CTL_DONTFRAG)) { in ieee80211_tx_prepare()
1283 if (!(tx->flags & IEEE80211_TX_UNICAST) || in ieee80211_tx_prepare()
1284 skb->len + FCS_LEN <= local->hw.wiphy->frag_threshold || in ieee80211_tx_prepare()
1285 info->flags & IEEE80211_TX_CTL_AMPDU) in ieee80211_tx_prepare()
1286 info->flags |= IEEE80211_TX_CTL_DONTFRAG; in ieee80211_tx_prepare()
1289 if (!tx->sta) in ieee80211_tx_prepare()
1290 info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT; in ieee80211_tx_prepare()
1291 else if (test_and_clear_sta_flag(tx->sta, WLAN_STA_CLEAR_PS_FILT)) { in ieee80211_tx_prepare()
1292 info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT; in ieee80211_tx_prepare()
1293 ieee80211_check_fast_xmit(tx->sta); in ieee80211_tx_prepare()
1296 info->flags |= IEEE80211_TX_CTL_FIRST_FRAGMENT; in ieee80211_tx_prepare()
1306 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; in ieee80211_get_txq()
1310 if ((info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM) || in ieee80211_get_txq()
1311 (info->control.flags & IEEE80211_TX_CTRL_PS_RESPONSE)) in ieee80211_get_txq()
1314 if (!(info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP) && in ieee80211_get_txq()
1315 unlikely(!ieee80211_is_data_present(hdr->frame_control))) { in ieee80211_get_txq()
1316 if ((!ieee80211_is_mgmt(hdr->frame_control) || in ieee80211_get_txq()
1318 vif->type == NL80211_IFTYPE_STATION) && in ieee80211_get_txq()
1319 sta && sta->uploaded) { in ieee80211_get_txq()
1322 * opt-in hardware flag. in ieee80211_get_txq()
1324 txq = sta->sta.txq[IEEE80211_NUM_TIDS]; in ieee80211_get_txq()
1327 u8 tid = skb->priority & IEEE80211_QOS_CTL_TID_MASK; in ieee80211_get_txq()
1329 if (!sta->uploaded) in ieee80211_get_txq()
1332 txq = sta->sta.txq[tid]; in ieee80211_get_txq()
1334 txq = vif->txq; in ieee80211_get_txq()
1349 IEEE80211_SKB_CB(skb)->control.enqueue_time = now; in ieee80211_set_skb_enqueue_time()
1354 return skb->len; in codel_skb_len_func()
1361 info = (const struct ieee80211_tx_info *)skb->cb; in codel_skb_time_func()
1362 return info->control.enqueue_time; in codel_skb_time_func()
1374 local = vif_to_sdata(txqi->txq.vif)->local; in codel_dequeue_func()
1375 fq = &local->fq; in codel_dequeue_func()
1377 if (cvars == &txqi->def_cvars) in codel_dequeue_func()
1378 flow = &txqi->tin.default_flow; in codel_dequeue_func()
1380 flow = &fq->flows[cvars - local->cvars]; in codel_dequeue_func()
1393 local = vif_to_sdata(txqi->txq.vif)->local; in codel_drop_func()
1394 hw = &local->hw; in codel_drop_func()
1411 cstats = &txqi->cstats; in fq_tin_dequeue_func()
1413 if (txqi->txq.sta) { in fq_tin_dequeue_func()
1414 struct sta_info *sta = container_of(txqi->txq.sta, in fq_tin_dequeue_func()
1416 cparams = &sta->cparams; in fq_tin_dequeue_func()
1418 cparams = &local->cparams; in fq_tin_dequeue_func()
1421 if (flow == &tin->default_flow) in fq_tin_dequeue_func()
1422 cvars = &txqi->def_cvars; in fq_tin_dequeue_func()
1424 cvars = &local->cvars[flow - fq->flows]; in fq_tin_dequeue_func()
1427 &flow->backlog, in fq_tin_dequeue_func()
1445 ieee80211_free_txskb(&local->hw, skb); in fq_skb_free_func()
1452 struct fq *fq = &local->fq; in ieee80211_txq_enqueue()
1453 struct fq_tin *tin = &txqi->tin; in ieee80211_txq_enqueue()
1458 spin_lock_bh(&fq->lock); in ieee80211_txq_enqueue()
1465 if (unlikely(txqi->txq.tid == IEEE80211_NUM_TIDS)) { in ieee80211_txq_enqueue()
1466 IEEE80211_SKB_CB(skb)->control.flags |= in ieee80211_txq_enqueue()
1468 __skb_queue_tail(&txqi->frags, skb); in ieee80211_txq_enqueue()
1473 spin_unlock_bh(&fq->lock); in ieee80211_txq_enqueue()
1482 return info->control.vif == data; in fq_vlan_filter_func()
1488 struct fq *fq = &local->fq; in ieee80211_txq_remove_vlan()
1493 if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_AP_VLAN)) in ieee80211_txq_remove_vlan()
1496 ap = container_of(sdata->bss, struct ieee80211_sub_if_data, u.ap); in ieee80211_txq_remove_vlan()
1498 if (!ap->vif.txq) in ieee80211_txq_remove_vlan()
1501 txqi = to_txq_info(ap->vif.txq); in ieee80211_txq_remove_vlan()
1502 tin = &txqi->tin; in ieee80211_txq_remove_vlan()
1504 spin_lock_bh(&fq->lock); in ieee80211_txq_remove_vlan()
1505 fq_tin_filter(fq, tin, fq_vlan_filter_func, &sdata->vif, in ieee80211_txq_remove_vlan()
1507 spin_unlock_bh(&fq->lock); in ieee80211_txq_remove_vlan()
1514 fq_tin_init(&txqi->tin); in ieee80211_txq_init()
1515 codel_vars_init(&txqi->def_cvars); in ieee80211_txq_init()
1516 codel_stats_init(&txqi->cstats); in ieee80211_txq_init()
1517 __skb_queue_head_init(&txqi->frags); in ieee80211_txq_init()
1518 INIT_LIST_HEAD(&txqi->schedule_order); in ieee80211_txq_init()
1520 txqi->txq.vif = &sdata->vif; in ieee80211_txq_init()
1523 sdata->vif.txq = &txqi->txq; in ieee80211_txq_init()
1524 txqi->txq.tid = 0; in ieee80211_txq_init()
1525 txqi->txq.ac = IEEE80211_AC_BE; in ieee80211_txq_init()
1531 if (sdata->vif.type == NL80211_IFTYPE_STATION) { in ieee80211_txq_init()
1533 if (!ieee80211_hw_check(&sdata->local->hw, in ieee80211_txq_init()
1536 } else if (!ieee80211_hw_check(&sdata->local->hw, in ieee80211_txq_init()
1541 txqi->txq.ac = IEEE80211_AC_VO; in ieee80211_txq_init()
1543 txqi->txq.ac = ieee80211_ac_from_tid(tid); in ieee80211_txq_init()
1546 txqi->txq.sta = &sta->sta; in ieee80211_txq_init()
1547 txqi->txq.tid = tid; in ieee80211_txq_init()
1548 sta->sta.txq[tid] = &txqi->txq; in ieee80211_txq_init()
1554 struct fq *fq = &local->fq; in ieee80211_txq_purge()
1555 struct fq_tin *tin = &txqi->tin; in ieee80211_txq_purge()
1557 spin_lock_bh(&fq->lock); in ieee80211_txq_purge()
1559 ieee80211_purge_tx_queue(&local->hw, &txqi->frags); in ieee80211_txq_purge()
1560 spin_unlock_bh(&fq->lock); in ieee80211_txq_purge()
1562 spin_lock_bh(&local->active_txq_lock[txqi->txq.ac]); in ieee80211_txq_purge()
1563 list_del_init(&txqi->schedule_order); in ieee80211_txq_purge()
1564 spin_unlock_bh(&local->active_txq_lock[txqi->txq.ac]); in ieee80211_txq_purge()
1569 if (local->hw.wiphy->txq_limit) in ieee80211_txq_set_params()
1570 local->fq.limit = local->hw.wiphy->txq_limit; in ieee80211_txq_set_params()
1572 local->hw.wiphy->txq_limit = local->fq.limit; in ieee80211_txq_set_params()
1574 if (local->hw.wiphy->txq_memory_limit) in ieee80211_txq_set_params()
1575 local->fq.memory_limit = local->hw.wiphy->txq_memory_limit; in ieee80211_txq_set_params()
1577 local->hw.wiphy->txq_memory_limit = local->fq.memory_limit; in ieee80211_txq_set_params()
1579 if (local->hw.wiphy->txq_quantum) in ieee80211_txq_set_params()
1580 local->fq.quantum = local->hw.wiphy->txq_quantum; in ieee80211_txq_set_params()
1582 local->hw.wiphy->txq_quantum = local->fq.quantum; in ieee80211_txq_set_params()
1587 struct fq *fq = &local->fq; in ieee80211_txq_setup_flows()
1599 * queue size. 4 Mbytes is 64 max-size aggregates in 802.11n. in ieee80211_txq_setup_flows()
1604 sband = local->hw.wiphy->bands[band]; in ieee80211_txq_setup_flows()
1608 supp_vht = supp_vht || sband->vht_cap.vht_supported; in ieee80211_txq_setup_flows()
1612 fq->memory_limit = 4 << 20; /* 4 Mbytes */ in ieee80211_txq_setup_flows()
1614 codel_params_init(&local->cparams); in ieee80211_txq_setup_flows()
1615 local->cparams.interval = MS2TIME(100); in ieee80211_txq_setup_flows()
1616 local->cparams.target = MS2TIME(20); in ieee80211_txq_setup_flows()
1617 local->cparams.ecn = true; in ieee80211_txq_setup_flows()
1619 local->cvars = kcalloc(fq->flows_cnt, sizeof(local->cvars[0]), in ieee80211_txq_setup_flows()
1621 if (!local->cvars) { in ieee80211_txq_setup_flows()
1622 spin_lock_bh(&fq->lock); in ieee80211_txq_setup_flows()
1624 spin_unlock_bh(&fq->lock); in ieee80211_txq_setup_flows()
1625 return -ENOMEM; in ieee80211_txq_setup_flows()
1628 for (i = 0; i < fq->flows_cnt; i++) in ieee80211_txq_setup_flows()
1629 codel_vars_init(&local->cvars[i]); in ieee80211_txq_setup_flows()
1638 struct fq *fq = &local->fq; in ieee80211_txq_teardown_flows()
1640 kfree(local->cvars); in ieee80211_txq_teardown_flows()
1641 local->cvars = NULL; in ieee80211_txq_teardown_flows()
1643 spin_lock_bh(&fq->lock); in ieee80211_txq_teardown_flows()
1645 spin_unlock_bh(&fq->lock); in ieee80211_txq_teardown_flows()
1656 if (sdata->vif.type == NL80211_IFTYPE_MONITOR) in ieee80211_queue_skb()
1659 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) in ieee80211_queue_skb()
1660 sdata = container_of(sdata->bss, in ieee80211_queue_skb()
1663 vif = &sdata->vif; in ieee80211_queue_skb()
1688 int q = info->hw_queue; in ieee80211_tx_frags()
1691 if (WARN_ON_ONCE(q >= local->hw.queues)) { in ieee80211_tx_frags()
1693 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_frags()
1698 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in ieee80211_tx_frags()
1699 if (local->queue_stop_reasons[q] || in ieee80211_tx_frags()
1700 (!txpending && !skb_queue_empty(&local->pending[q]))) { in ieee80211_tx_frags()
1701 if (unlikely(info->flags & in ieee80211_tx_frags()
1703 if (local->queue_stop_reasons[q] & in ieee80211_tx_frags()
1706 * Drop off-channel frames if queues in ieee80211_tx_frags()
1708 * than off-channel operation. Never in ieee80211_tx_frags()
1712 &local->queue_stop_reason_lock, in ieee80211_tx_frags()
1714 ieee80211_purge_tx_queue(&local->hw, in ieee80211_tx_frags()
1722 * later transmission from the tx-pending in ieee80211_tx_frags()
1727 &local->pending[q]); in ieee80211_tx_frags()
1730 &local->pending[q]); in ieee80211_tx_frags()
1732 spin_unlock_irqrestore(&local->queue_stop_reason_lock, in ieee80211_tx_frags()
1737 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_tx_frags()
1739 info->control.vif = vif; in ieee80211_tx_frags()
1740 control.sta = sta ? &sta->sta : NULL; in ieee80211_tx_frags()
1767 sdata = vif_to_sdata(info->control.vif); in __ieee80211_tx()
1768 if (sta && !sta->uploaded) in __ieee80211_tx()
1771 switch (sdata->vif.type) { in __ieee80211_tx()
1773 if (sdata->u.mntr.flags & MONITOR_FLAG_ACTIVE) { in __ieee80211_tx()
1774 vif = &sdata->vif; in __ieee80211_tx()
1777 sdata = rcu_dereference(local->monitor_sdata); in __ieee80211_tx()
1779 vif = &sdata->vif; in __ieee80211_tx()
1780 info->hw_queue = in __ieee80211_tx()
1781 vif->hw_queue[skb_get_queue_mapping(skb)]; in __ieee80211_tx()
1782 } else if (ieee80211_hw_check(&local->hw, QUEUE_CONTROL)) { in __ieee80211_tx()
1783 ieee80211_purge_tx_queue(&local->hw, skbs); in __ieee80211_tx()
1789 sdata = container_of(sdata->bss, in __ieee80211_tx()
1793 vif = &sdata->vif; in __ieee80211_tx()
1805 * Invoke TX handlers, return 0 on success and non-zero if the
1831 I802_DEBUG_INC(tx->local->tx_handlers_drop); in invoke_tx_handlers_early()
1832 if (tx->skb) in invoke_tx_handlers_early()
1833 ieee80211_free_txskb(&tx->local->hw, tx->skb); in invoke_tx_handlers_early()
1835 ieee80211_purge_tx_queue(&tx->local->hw, &tx->skbs); in invoke_tx_handlers_early()
1836 return -1; in invoke_tx_handlers_early()
1838 I802_DEBUG_INC(tx->local->tx_handlers_queued); in invoke_tx_handlers_early()
1839 return -1; in invoke_tx_handlers_early()
1851 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); in invoke_tx_handlers_late()
1854 if (!ieee80211_hw_check(&tx->local->hw, HAS_RATE_CONTROL)) in invoke_tx_handlers_late()
1857 if (unlikely(info->flags & IEEE80211_TX_INTFL_RETRANSMISSION)) { in invoke_tx_handlers_late()
1858 __skb_queue_tail(&tx->skbs, tx->skb); in invoke_tx_handlers_late()
1859 tx->skb = NULL; in invoke_tx_handlers_late()
1869 if (!ieee80211_hw_check(&tx->local->hw, HAS_RATE_CONTROL)) in invoke_tx_handlers_late()
1875 I802_DEBUG_INC(tx->local->tx_handlers_drop); in invoke_tx_handlers_late()
1876 if (tx->skb) in invoke_tx_handlers_late()
1877 ieee80211_free_txskb(&tx->local->hw, tx->skb); in invoke_tx_handlers_late()
1879 ieee80211_purge_tx_queue(&tx->local->hw, &tx->skbs); in invoke_tx_handlers_late()
1880 return -1; in invoke_tx_handlers_late()
1882 I802_DEBUG_INC(tx->local->tx_handlers_queued); in invoke_tx_handlers_late()
1883 return -1; in invoke_tx_handlers_late()
1910 info->band = band; in ieee80211_tx_prepare_skb()
1911 info->control.vif = vif; in ieee80211_tx_prepare_skb()
1912 info->hw_queue = vif->hw_queue[skb_get_queue_mapping(skb)]; in ieee80211_tx_prepare_skb()
1919 *sta = &tx.sta->sta; in ieee80211_tx_prepare_skb()
1943 struct ieee80211_local *local = sdata->local; in ieee80211_tx()
1949 if (unlikely(skb->len < 10)) { in ieee80211_tx()
1958 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx()
1965 if (!(info->flags & IEEE80211_TX_CTL_TX_OFFCHAN) || in ieee80211_tx()
1966 !ieee80211_hw_check(&local->hw, QUEUE_CONTROL)) in ieee80211_tx()
1967 info->hw_queue = in ieee80211_tx()
1968 sdata->vif.hw_queue[skb_get_queue_mapping(skb)]; in ieee80211_tx()
1995 struct ieee80211_local *local = sdata->local; in ieee80211_skb_resize()
2001 sdata->crypto_tx_tailroom_needed_cnt); in ieee80211_skb_resize()
2005 tail_need -= skb_tailroom(skb); in ieee80211_skb_resize()
2010 (!ieee80211_hw_check(&local->hw, SUPPORTS_CLONED_SKBS) || in ieee80211_skb_resize()
2012 I802_DEBUG_INC(local->tx_expand_skb_head_cloned); in ieee80211_skb_resize()
2014 I802_DEBUG_INC(local->tx_expand_skb_head); in ieee80211_skb_resize()
2019 wiphy_debug(local->hw.wiphy, in ieee80211_skb_resize()
2021 return -ENOMEM; in ieee80211_skb_resize()
2030 struct ieee80211_local *local = sdata->local; in ieee80211_xmit()
2032 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; in ieee80211_xmit()
2036 if (info->flags & IEEE80211_TX_INTFL_DONT_ENCRYPT) in ieee80211_xmit()
2038 else if (ieee80211_is_mgmt(hdr->frame_control)) in ieee80211_xmit()
2043 headroom = local->tx_headroom; in ieee80211_xmit()
2046 headroom -= skb_headroom(skb); in ieee80211_xmit()
2050 ieee80211_free_txskb(&local->hw, skb); in ieee80211_xmit()
2055 hdr = (struct ieee80211_hdr *) skb->data; in ieee80211_xmit()
2056 info->control.vif = &sdata->vif; in ieee80211_xmit()
2058 if (ieee80211_vif_is_mesh(&sdata->vif)) { in ieee80211_xmit()
2059 if (ieee80211_is_data(hdr->frame_control) && in ieee80211_xmit()
2060 is_unicast_ether_addr(hdr->addr1)) { in ieee80211_xmit()
2075 (struct ieee80211_radiotap_header *)skb->data; in ieee80211_validate_radiotap_len()
2078 if (unlikely(skb->len < sizeof(struct ieee80211_radiotap_header))) in ieee80211_validate_radiotap_len()
2082 if (unlikely(rthdr->it_version)) in ieee80211_validate_radiotap_len()
2086 if (unlikely(skb->len < ieee80211_get_radiotap_len(skb->data))) in ieee80211_validate_radiotap_len()
2095 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); in ieee80211_parse_tx_radiotap()
2098 (struct ieee80211_radiotap_header *) skb->data; in ieee80211_parse_tx_radiotap()
2100 int ret = ieee80211_radiotap_iterator_init(&iterator, rthdr, skb->len, in ieee80211_parse_tx_radiotap()
2115 info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT | in ieee80211_parse_tx_radiotap()
2120 * (ieee80211_radiotap_iterator_next returns -ENOENT when no more in ieee80211_parse_tx_radiotap()
2121 * entries present, or -EINVAL on error) in ieee80211_parse_tx_radiotap()
2142 * handed has the 32-bit FCS CRC at the end... in ieee80211_parse_tx_radiotap()
2147 if (skb->len < (iterator._max_length + FCS_LEN)) in ieee80211_parse_tx_radiotap()
2150 skb_trim(skb, skb->len - FCS_LEN); in ieee80211_parse_tx_radiotap()
2153 info->flags &= ~IEEE80211_TX_INTFL_DONT_ENCRYPT; in ieee80211_parse_tx_radiotap()
2155 info->flags &= ~IEEE80211_TX_CTL_DONTFRAG; in ieee80211_parse_tx_radiotap()
2161 info->flags |= IEEE80211_TX_CTL_NO_ACK; in ieee80211_parse_tx_radiotap()
2163 info->control.flags |= IEEE80211_TX_CTRL_NO_SEQNO; in ieee80211_parse_tx_radiotap()
2165 info->control.flags |= in ieee80211_parse_tx_radiotap()
2200 info->flags |= IEEE80211_TX_CTL_LDPC; in ieee80211_parse_tx_radiotap()
2206 info->flags |= in ieee80211_parse_tx_radiotap()
2244 * Documentation/networking/mac80211-injection.rst in ieee80211_parse_tx_radiotap()
2253 if (ret != -ENOENT) /* ie, if we didn't simply run out of fields */ in ieee80211_parse_tx_radiotap()
2258 local->hw.wiphy->bands[info->band]; in ieee80211_parse_tx_radiotap()
2260 info->control.flags |= IEEE80211_TX_CTRL_RATE_INJECT; in ieee80211_parse_tx_radiotap()
2263 info->control.rates[i].idx = -1; in ieee80211_parse_tx_radiotap()
2264 info->control.rates[i].flags = 0; in ieee80211_parse_tx_radiotap()
2265 info->control.rates[i].count = 0; in ieee80211_parse_tx_radiotap()
2269 info->control.rates[0].idx = rate; in ieee80211_parse_tx_radiotap()
2271 ieee80211_rate_set_vht(info->control.rates, vht_mcs, in ieee80211_parse_tx_radiotap()
2274 for (i = 0; i < sband->n_bitrates; i++) { in ieee80211_parse_tx_radiotap()
2275 if (rate * 5 != sband->bitrates[i].bitrate) in ieee80211_parse_tx_radiotap()
2278 info->control.rates[0].idx = i; in ieee80211_parse_tx_radiotap()
2283 if (info->control.rates[0].idx < 0) in ieee80211_parse_tx_radiotap()
2284 info->control.flags &= ~IEEE80211_TX_CTRL_RATE_INJECT; in ieee80211_parse_tx_radiotap()
2286 info->control.rates[0].flags = rate_flags; in ieee80211_parse_tx_radiotap()
2287 info->control.rates[0].count = min_t(u8, rate_retries + 1, in ieee80211_parse_tx_radiotap()
2288 local->hw.max_rate_tries); in ieee80211_parse_tx_radiotap()
2297 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); in ieee80211_monitor_start_xmit()
2311 info->flags = IEEE80211_TX_CTL_REQ_TX_STATUS | in ieee80211_monitor_start_xmit()
2314 /* Sanity-check the length of the radiotap header */ in ieee80211_monitor_start_xmit()
2319 len_rthdr = ieee80211_get_radiotap_len(skb->data); in ieee80211_monitor_start_xmit()
2335 if (skb->len < len_rthdr + 2) in ieee80211_monitor_start_xmit()
2338 hdr = (struct ieee80211_hdr *)(skb->data + len_rthdr); in ieee80211_monitor_start_xmit()
2339 hdrlen = ieee80211_hdrlen(hdr->frame_control); in ieee80211_monitor_start_xmit()
2341 if (skb->len < len_rthdr + hdrlen) in ieee80211_monitor_start_xmit()
2345 * Initialize skb->protocol if the injected frame is a data frame in ieee80211_monitor_start_xmit()
2348 if (ieee80211_is_data(hdr->frame_control) && in ieee80211_monitor_start_xmit()
2349 skb->len >= len_rthdr + hdrlen + sizeof(rfc1042_header) + 2) { in ieee80211_monitor_start_xmit()
2353 skb->protocol = cpu_to_be16((payload[6] << 8) | in ieee80211_monitor_start_xmit()
2361 * we handle as though they are non-injected frames. in ieee80211_monitor_start_xmit()
2364 * VLAN support we have an nl80211-based mechanism. in ieee80211_monitor_start_xmit()
2367 * don't use nl80211-based management TX/RX. in ieee80211_monitor_start_xmit()
2369 list_for_each_entry_rcu(tmp_sdata, &local->interfaces, list) { in ieee80211_monitor_start_xmit()
2372 if (tmp_sdata->vif.type == NL80211_IFTYPE_MONITOR || in ieee80211_monitor_start_xmit()
2373 tmp_sdata->vif.type == NL80211_IFTYPE_AP_VLAN) in ieee80211_monitor_start_xmit()
2375 if (ether_addr_equal(tmp_sdata->vif.addr, hdr->addr2)) { in ieee80211_monitor_start_xmit()
2381 chanctx_conf = rcu_dereference(sdata->vif.bss_conf.chanctx_conf); in ieee80211_monitor_start_xmit()
2383 tmp_sdata = rcu_dereference(local->monitor_sdata); in ieee80211_monitor_start_xmit()
2386 rcu_dereference(tmp_sdata->vif.bss_conf.chanctx_conf); in ieee80211_monitor_start_xmit()
2390 chandef = &chanctx_conf->def; in ieee80211_monitor_start_xmit()
2391 else if (!local->use_chanctx) in ieee80211_monitor_start_xmit()
2392 chandef = &local->_oper_chandef; in ieee80211_monitor_start_xmit()
2412 if (!cfg80211_reg_can_beacon(local->hw.wiphy, chandef, in ieee80211_monitor_start_xmit()
2413 sdata->vif.type)) in ieee80211_monitor_start_xmit()
2416 info->band = chandef->chan->band; in ieee80211_monitor_start_xmit()
2418 /* Initialize skb->priority according to frame type and TID class, in ieee80211_monitor_start_xmit()
2421 * skb-priority is preserved to assure frames injected with this in ieee80211_monitor_start_xmit()
2425 skb_set_queue_mapping(skb, ieee80211_ac_from_tid(skb->priority)); in ieee80211_monitor_start_xmit()
2452 u16 ethertype = (skb->data[12] << 8) | skb->data[13]; in ieee80211_is_tdls_setup()
2455 skb->len > 14 && in ieee80211_is_tdls_setup()
2456 skb->data[14] == WLAN_TDLS_SNAP_RFTYPE; in ieee80211_is_tdls_setup()
2465 switch (sdata->vif.type) { in ieee80211_lookup_ra_sta()
2467 sta = rcu_dereference(sdata->u.vlan.sta); in ieee80211_lookup_ra_sta()
2471 } else if (sdata->wdev.use_4addr) { in ieee80211_lookup_ra_sta()
2472 return -ENOLINK; in ieee80211_lookup_ra_sta()
2478 if (is_multicast_ether_addr(skb->data)) { in ieee80211_lookup_ra_sta()
2479 *sta_out = ERR_PTR(-ENOENT); in ieee80211_lookup_ra_sta()
2482 sta = sta_info_get_bss(sdata, skb->data); in ieee80211_lookup_ra_sta()
2491 if (sdata->wdev.wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS) { in ieee80211_lookup_ra_sta()
2492 sta = sta_info_get(sdata, skb->data); in ieee80211_lookup_ra_sta()
2501 * TDLS link during setup - throw out frames to in ieee80211_lookup_ra_sta()
2502 * peer. Allow TDLS-setup frames to unauthorized in ieee80211_lookup_ra_sta()
2503 * peers for the special case of a link teardown in ieee80211_lookup_ra_sta()
2508 return -EINVAL; in ieee80211_lookup_ra_sta()
2513 sta = sta_info_get(sdata, sdata->vif.cfg.ap_addr); in ieee80211_lookup_ra_sta()
2515 return -ENOLINK; in ieee80211_lookup_ra_sta()
2518 return -EINVAL; in ieee80211_lookup_ra_sta()
2521 *sta_out = sta ?: ERR_PTR(-ENOENT); in ieee80211_lookup_ra_sta()
2533 if (skb->sk) in ieee80211_store_ack_skb()
2542 spin_lock_irqsave(&local->ack_status_lock, flags); in ieee80211_store_ack_skb()
2543 id = idr_alloc(&local->ack_status_frames, ack_skb, in ieee80211_store_ack_skb()
2545 spin_unlock_irqrestore(&local->ack_status_lock, flags); in ieee80211_store_ack_skb()
2552 IEEE80211_SKB_CB(ack_skb)->ack.cookie = *cookie; in ieee80211_store_ack_skb()
2563 * ieee80211_build_hdr - build 802.11 header in the given frame
2576 * potential unsharing of the SKB - this needs to be interleaved with the
2579 * The function requires the read-side RCU lock held
2588 struct ieee80211_local *local = sdata->local; in ieee80211_build_hdr()
2611 if (local->force_tx_status) in ieee80211_build_hdr()
2617 ethertype = (skb->data[12] << 8) | skb->data[13]; in ieee80211_build_hdr()
2620 if (!ieee80211_vif_is_mld(&sdata->vif)) in ieee80211_build_hdr()
2622 rcu_dereference(sdata->vif.bss_conf.chanctx_conf); in ieee80211_build_hdr()
2624 switch (sdata->vif.type) { in ieee80211_build_hdr()
2626 if (sdata->wdev.use_4addr) { in ieee80211_build_hdr()
2629 memcpy(hdr.addr1, sta->sta.addr, ETH_ALEN); in ieee80211_build_hdr()
2630 memcpy(hdr.addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_build_hdr()
2631 memcpy(hdr.addr3, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2632 memcpy(hdr.addr4, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2635 wme_sta = sta->sta.wme; in ieee80211_build_hdr()
2637 if (!ieee80211_vif_is_mld(&sdata->vif)) { in ieee80211_build_hdr()
2641 ap_sdata = container_of(sdata->bss, in ieee80211_build_hdr()
2645 rcu_dereference(ap_sdata->vif.bss_conf.chanctx_conf); in ieee80211_build_hdr()
2647 if (sdata->wdev.use_4addr) in ieee80211_build_hdr()
2653 memcpy(hdr.addr1, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2655 if (ieee80211_vif_is_mld(&sdata->vif) && sta && !sta->sta.mlo) { in ieee80211_build_hdr()
2656 struct ieee80211_link_data *link; in ieee80211_build_hdr() local
2658 link_id = sta->deflink.link_id; in ieee80211_build_hdr()
2659 link = rcu_dereference(sdata->link[link_id]); in ieee80211_build_hdr()
2660 if (WARN_ON(!link)) { in ieee80211_build_hdr()
2661 ret = -ENOLINK; in ieee80211_build_hdr()
2664 memcpy(hdr.addr2, link->conf->addr, ETH_ALEN); in ieee80211_build_hdr()
2666 (sta && sta->sta.mlo)) { in ieee80211_build_hdr()
2667 memcpy(hdr.addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_build_hdr()
2671 conf = rcu_dereference(sdata->vif.link_conf[link_id]); in ieee80211_build_hdr()
2673 ret = -ENOLINK; in ieee80211_build_hdr()
2677 memcpy(hdr.addr2, conf->addr, ETH_ALEN); in ieee80211_build_hdr()
2680 memcpy(hdr.addr3, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2685 if (!is_multicast_ether_addr(skb->data)) { in ieee80211_build_hdr()
2689 mpath = mesh_path_lookup(sdata, skb->data); in ieee80211_build_hdr()
2692 next_hop = rcu_dereference(mpath->next_hop); in ieee80211_build_hdr()
2694 !(mpath->flags & (MESH_PATH_ACTIVE | in ieee80211_build_hdr()
2700 mppath = mpp_path_lookup(sdata, skb->data); in ieee80211_build_hdr()
2702 mppath->exp_time = jiffies; in ieee80211_build_hdr()
2706 mesh_path_del(sdata, mpath->dst); in ieee80211_build_hdr()
2715 if (ether_addr_equal(sdata->vif.addr, skb->data + ETH_ALEN) && in ieee80211_build_hdr()
2716 !(mppath && !ether_addr_equal(mppath->mpp, skb->data))) { in ieee80211_build_hdr()
2718 skb->data, skb->data + ETH_ALEN); in ieee80211_build_hdr()
2722 /* DS -> MBSS (802.11-2012 13.11.3.3). in ieee80211_build_hdr()
2728 const u8 *mesh_da = skb->data; in ieee80211_build_hdr()
2731 mesh_da = mppath->mpp; in ieee80211_build_hdr()
2733 mesh_da = mpath->dst; in ieee80211_build_hdr()
2736 mesh_da, sdata->vif.addr); in ieee80211_build_hdr()
2741 skb->data + ETH_ALEN, NULL); in ieee80211_build_hdr()
2745 sdata, &mesh_hdr, skb->data, in ieee80211_build_hdr()
2746 skb->data + ETH_ALEN); in ieee80211_build_hdr()
2755 memcpy(hdr.addr1, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2763 /* For TDLS only one link can be valid with peer STA */ in ieee80211_build_hdr()
2764 int tdls_link_id = sta->sta.valid_links ? in ieee80211_build_hdr()
2765 __ffs(sta->sta.valid_links) : 0; in ieee80211_build_hdr()
2766 struct ieee80211_link_data *link; in ieee80211_build_hdr() local
2769 memcpy(hdr.addr1, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2770 memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2771 link = rcu_dereference(sdata->link[tdls_link_id]); in ieee80211_build_hdr()
2772 if (WARN_ON_ONCE(!link)) { in ieee80211_build_hdr()
2773 ret = -EINVAL; in ieee80211_build_hdr()
2776 memcpy(hdr.addr3, link->u.mgd.bssid, ETH_ALEN); in ieee80211_build_hdr()
2778 } else if (sdata->u.mgd.use_4addr && in ieee80211_build_hdr()
2779 cpu_to_be16(ethertype) != sdata->control_port_protocol) { in ieee80211_build_hdr()
2783 memcpy(hdr.addr1, sdata->deflink.u.mgd.bssid, ETH_ALEN); in ieee80211_build_hdr()
2784 memcpy(hdr.addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_build_hdr()
2785 memcpy(hdr.addr3, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2786 memcpy(hdr.addr4, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2791 memcpy(hdr.addr1, sdata->vif.cfg.ap_addr, ETH_ALEN); in ieee80211_build_hdr()
2792 memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2793 memcpy(hdr.addr3, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2799 memcpy(hdr.addr1, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2800 memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2806 memcpy(hdr.addr1, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2807 memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2808 memcpy(hdr.addr3, sdata->u.ibss.bssid, ETH_ALEN); in ieee80211_build_hdr()
2812 ret = -EINVAL; in ieee80211_build_hdr()
2817 if (!ieee80211_vif_is_mld(&sdata->vif)) { in ieee80211_build_hdr()
2818 ret = -ENOTCONN; in ieee80211_build_hdr()
2824 band = chanctx_conf->def.chan->band; in ieee80211_build_hdr()
2832 wme_sta = sta->sta.wme; in ieee80211_build_hdr()
2833 } else if (ieee80211_vif_is_mesh(&sdata->vif)) { in ieee80211_build_hdr()
2848 if (unlikely(!ieee80211_vif_is_mesh(&sdata->vif) && in ieee80211_build_hdr()
2849 (sdata->vif.type != NL80211_IFTYPE_OCB) && in ieee80211_build_hdr()
2851 (cpu_to_be16(ethertype) != sdata->control_port_protocol || in ieee80211_build_hdr()
2852 !ieee80211_is_our_addr(sdata, skb->data + ETH_ALEN, NULL)))) { in ieee80211_build_hdr()
2855 sdata->name, hdr.addr1); in ieee80211_build_hdr()
2858 I802_DEBUG_INC(local->tx_handlers_drop_unauth_port); in ieee80211_build_hdr()
2860 ret = -EPERM; in ieee80211_build_hdr()
2864 if (unlikely(!multicast && ((skb->sk && in ieee80211_build_hdr()
2865 skb_shinfo(skb)->tx_flags & SKBTX_WIFI_STATUS) || in ieee80211_build_hdr()
2875 ret = -ENOMEM; in ieee80211_build_hdr()
2887 skip_header_bytes -= 2; in ieee80211_build_hdr()
2891 skip_header_bytes -= 2; in ieee80211_build_hdr()
2898 head_need = hdrlen + encaps_len + meshhdrlen - skb_headroom(skb); in ieee80211_build_hdr()
2914 head_need += local->tx_headroom; in ieee80211_build_hdr()
2917 ieee80211_free_txskb(&local->hw, skb); in ieee80211_build_hdr()
2919 return ERR_PTR(-ENOMEM); in ieee80211_build_hdr()
2935 memcpy(skb_push(skb, hdrlen - 2), &hdr, hdrlen - 2); in ieee80211_build_hdr()
2949 info->flags = info_flags; in ieee80211_build_hdr()
2950 info->ack_frame_id = info_id; in ieee80211_build_hdr()
2951 info->band = band; in ieee80211_build_hdr()
2971 net_info_ratelimited("%s: dropped frame to %pM with bad link ID request (%d vs. %d)\n", in ieee80211_build_hdr()
2972 sdata->name, hdr.addr1, in ieee80211_build_hdr()
2975 ret = -EINVAL; in ieee80211_build_hdr()
2980 info->control.flags = ctrl_flags; in ieee80211_build_hdr()
2989 * fast-xmit overview
2991 * The core idea of this fast-xmit is to remove per-packet checks by checking
2992 * them out of band. ieee80211_check_fast_xmit() implements the out-of-band
2993 * checks that are needed to get the sta->fast_tx pointer assigned, after which
2998 * Once assigned, the fast_tx data structure also caches the per-packet 802.11
3004 * since the per-packet code no longer checks the conditions. This is reflected
3012 struct ieee80211_local *local = sta->local; in ieee80211_check_fast_xmit()
3013 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_check_fast_xmit()
3018 if (!ieee80211_hw_check(&local->hw, SUPPORT_FAST_XMIT)) in ieee80211_check_fast_xmit()
3021 if (ieee80211_vif_is_mesh(&sdata->vif)) in ieee80211_check_fast_xmit()
3032 * key and the fast-tx assignment are done atomically, so the CPU that in ieee80211_check_fast_xmit()
3036 spin_lock_bh(&sta->lock); in ieee80211_check_fast_xmit()
3037 if (ieee80211_hw_check(&local->hw, SUPPORTS_PS) && in ieee80211_check_fast_xmit()
3038 !ieee80211_hw_check(&local->hw, SUPPORTS_DYNAMIC_PS) && in ieee80211_check_fast_xmit()
3039 sdata->vif.type == NL80211_IFTYPE_STATION) in ieee80211_check_fast_xmit()
3042 if (!test_sta_flag(sta, WLAN_STA_AUTHORIZED) || !sta->uploaded) in ieee80211_check_fast_xmit()
3051 if (sdata->noack_map) in ieee80211_check_fast_xmit()
3054 /* fast-xmit doesn't handle fragmentation at all */ in ieee80211_check_fast_xmit()
3055 if (local->hw.wiphy->frag_threshold != (u32)-1 && in ieee80211_check_fast_xmit()
3056 !ieee80211_hw_check(&local->hw, SUPPORTS_TX_FRAG)) in ieee80211_check_fast_xmit()
3059 if (!ieee80211_vif_is_mld(&sdata->vif)) { in ieee80211_check_fast_xmit()
3062 rcu_dereference(sdata->vif.bss_conf.chanctx_conf); in ieee80211_check_fast_xmit()
3067 build.band = chanctx_conf->def.chan->band; in ieee80211_check_fast_xmit()
3076 switch (sdata->vif.type) { in ieee80211_check_fast_xmit()
3081 memcpy(hdr->addr3, sdata->u.ibss.bssid, ETH_ALEN); in ieee80211_check_fast_xmit()
3086 /* For TDLS only one link can be valid with peer STA */ in ieee80211_check_fast_xmit()
3087 int tdls_link_id = sta->sta.valid_links ? in ieee80211_check_fast_xmit()
3088 __ffs(sta->sta.valid_links) : 0; in ieee80211_check_fast_xmit()
3089 struct ieee80211_link_data *link; in ieee80211_check_fast_xmit() local
3095 link = rcu_dereference(sdata->link[tdls_link_id]); in ieee80211_check_fast_xmit()
3096 if (!WARN_ON_ONCE(!link)) in ieee80211_check_fast_xmit()
3097 memcpy(hdr->addr3, link->u.mgd.bssid, ETH_ALEN); in ieee80211_check_fast_xmit()
3103 if (sdata->u.mgd.use_4addr) { in ieee80211_check_fast_xmit()
3104 /* non-regular ethertype cannot use the fastpath */ in ieee80211_check_fast_xmit()
3108 memcpy(hdr->addr1, sdata->deflink.u.mgd.bssid, ETH_ALEN); in ieee80211_check_fast_xmit()
3109 memcpy(hdr->addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_check_fast_xmit()
3117 memcpy(hdr->addr1, sdata->vif.cfg.ap_addr, ETH_ALEN); in ieee80211_check_fast_xmit()
3123 if (sdata->wdev.use_4addr) { in ieee80211_check_fast_xmit()
3127 memcpy(hdr->addr1, sta->sta.addr, ETH_ALEN); in ieee80211_check_fast_xmit()
3128 memcpy(hdr->addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_check_fast_xmit()
3139 if (sta->sta.mlo || !ieee80211_vif_is_mld(&sdata->vif)) { in ieee80211_check_fast_xmit()
3140 memcpy(hdr->addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_check_fast_xmit()
3142 unsigned int link_id = sta->deflink.link_id; in ieee80211_check_fast_xmit()
3143 struct ieee80211_link_data *link; in ieee80211_check_fast_xmit() local
3146 link = rcu_dereference(sdata->link[link_id]); in ieee80211_check_fast_xmit()
3147 if (WARN_ON(!link)) { in ieee80211_check_fast_xmit()
3151 memcpy(hdr->addr2, link->conf->addr, ETH_ALEN); in ieee80211_check_fast_xmit()
3158 /* not handled on fast-xmit */ in ieee80211_check_fast_xmit()
3162 if (sta->sta.wme) { in ieee80211_check_fast_xmit()
3172 build.key = rcu_access_pointer(sta->ptk[sta->ptk_idx]); in ieee80211_check_fast_xmit()
3174 build.key = rcu_access_pointer(sdata->default_unicast_key); in ieee80211_check_fast_xmit()
3178 gen_iv = build.key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV; in ieee80211_check_fast_xmit()
3179 iv_spc = build.key->conf.flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE; in ieee80211_check_fast_xmit()
3180 mmic = build.key->conf.flags & in ieee80211_check_fast_xmit()
3185 if (!(build.key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) in ieee80211_check_fast_xmit()
3189 if (build.key->flags & KEY_FLAG_TAINTED) in ieee80211_check_fast_xmit()
3192 switch (build.key->conf.cipher) { in ieee80211_check_fast_xmit()
3208 /* cannot handle MMIC or IV generation in xmit-fast */ in ieee80211_check_fast_xmit()
3216 /* cannot handle IV generation in fast-xmit */ in ieee80211_check_fast_xmit()
3228 build.key->conf.cipher); in ieee80211_check_fast_xmit()
3239 hdr->frame_control = fc; in ieee80211_check_fast_xmit()
3250 old = rcu_dereference_protected(sta->fast_tx, in ieee80211_check_fast_xmit()
3251 lockdep_is_held(&sta->lock)); in ieee80211_check_fast_xmit()
3252 rcu_assign_pointer(sta->fast_tx, fast_tx); in ieee80211_check_fast_xmit()
3255 spin_unlock_bh(&sta->lock); in ieee80211_check_fast_xmit()
3263 list_for_each_entry_rcu(sta, &local->sta_list, list) in ieee80211_check_fast_xmit_all()
3270 struct ieee80211_local *local = sdata->local; in ieee80211_check_fast_xmit_iface()
3275 list_for_each_entry_rcu(sta, &local->sta_list, list) { in ieee80211_check_fast_xmit_iface()
3276 if (sdata != sta->sdata && in ieee80211_check_fast_xmit_iface()
3277 (!sta->sdata->bss || sta->sdata->bss != sdata->bss)) in ieee80211_check_fast_xmit_iface()
3289 spin_lock_bh(&sta->lock); in ieee80211_clear_fast_xmit()
3290 fast_tx = rcu_dereference_protected(sta->fast_tx, in ieee80211_clear_fast_xmit()
3291 lockdep_is_held(&sta->lock)); in ieee80211_clear_fast_xmit()
3292 RCU_INIT_POINTER(sta->fast_tx, NULL); in ieee80211_clear_fast_xmit()
3293 spin_unlock_bh(&sta->lock); in ieee80211_clear_fast_xmit()
3303 I802_DEBUG_INC(local->tx_expand_skb_head); in ieee80211_amsdu_realloc_pad()
3306 wiphy_debug(local->hw.wiphy, in ieee80211_amsdu_realloc_pad()
3319 struct ieee80211_local *local = sdata->local; in ieee80211_amsdu_prepare_head()
3323 int hdr_len = fast_tx->hdr_len - sizeof(rfc1042_header); in ieee80211_amsdu_prepare_head()
3324 int subframe_len = skb->len - hdr_len; in ieee80211_amsdu_prepare_head()
3329 if (info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE) in ieee80211_amsdu_prepare_head()
3332 if (info->control.flags & IEEE80211_TX_CTRL_AMSDU) in ieee80211_amsdu_prepare_head()
3337 local->hw.extra_tx_headroom)) in ieee80211_amsdu_prepare_head()
3345 h_80211_src = data + fast_tx->sa_offs; in ieee80211_amsdu_prepare_head()
3346 h_80211_dst = data + fast_tx->da_offs; in ieee80211_amsdu_prepare_head()
3348 amsdu_hdr->h_proto = cpu_to_be16(subframe_len); in ieee80211_amsdu_prepare_head()
3349 ether_addr_copy(amsdu_hdr->h_source, h_80211_src); in ieee80211_amsdu_prepare_head()
3350 ether_addr_copy(amsdu_hdr->h_dest, h_80211_dst); in ieee80211_amsdu_prepare_head()
3352 /* according to IEEE 802.11-2012 8.3.2 table 8-19, the outer SA/DA in ieee80211_amsdu_prepare_head()
3353 * fields needs to be changed to BSSID for A-MSDU frames depending in ieee80211_amsdu_prepare_head()
3356 switch (sdata->vif.type) { in ieee80211_amsdu_prepare_head()
3358 bssid = sdata->vif.cfg.ap_addr; in ieee80211_amsdu_prepare_head()
3362 bssid = sdata->vif.addr; in ieee80211_amsdu_prepare_head()
3368 if (bssid && ieee80211_has_fromds(hdr->frame_control)) in ieee80211_amsdu_prepare_head()
3371 if (bssid && ieee80211_has_tods(hdr->frame_control)) in ieee80211_amsdu_prepare_head()
3377 info->control.flags |= IEEE80211_TX_CTRL_AMSDU; in ieee80211_amsdu_prepare_head()
3388 struct ieee80211_local *local = sdata->local; in ieee80211_amsdu_aggregate()
3389 struct fq *fq = &local->fq; in ieee80211_amsdu_aggregate()
3392 u8 tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; in ieee80211_amsdu_aggregate()
3393 struct ieee80211_txq *txq = sta->sta.txq[tid]; in ieee80211_amsdu_aggregate()
3396 int subframe_len = skb->len - ETH_ALEN; in ieee80211_amsdu_aggregate()
3397 u8 max_subframes = sta->sta.max_amsdu_subframes; in ieee80211_amsdu_aggregate()
3398 int max_frags = local->hw.max_tx_fragments; in ieee80211_amsdu_aggregate()
3399 int max_amsdu_len = sta->sta.cur->max_amsdu_len; in ieee80211_amsdu_aggregate()
3409 if (!ieee80211_hw_check(&local->hw, TX_AMSDU)) in ieee80211_amsdu_aggregate()
3412 if (sdata->vif.offload_flags & IEEE80211_OFFLOAD_ENCAP_ENABLED) in ieee80211_amsdu_aggregate()
3415 if (ieee80211_vif_is_mesh(&sdata->vif)) in ieee80211_amsdu_aggregate()
3425 if (test_bit(IEEE80211_TXQ_NO_AMSDU, &txqi->flags)) in ieee80211_amsdu_aggregate()
3428 if (sta->sta.cur->max_rc_amsdu_len) in ieee80211_amsdu_aggregate()
3430 sta->sta.cur->max_rc_amsdu_len); in ieee80211_amsdu_aggregate()
3432 if (sta->sta.cur->max_tid_amsdu_len[tid]) in ieee80211_amsdu_aggregate()
3434 sta->sta.cur->max_tid_amsdu_len[tid]); in ieee80211_amsdu_aggregate()
3438 spin_lock_bh(&fq->lock); in ieee80211_amsdu_aggregate()
3444 tin = &txqi->tin; in ieee80211_amsdu_aggregate()
3446 head = skb_peek_tail(&flow->queue); in ieee80211_amsdu_aggregate()
3450 orig_truesize = head->truesize; in ieee80211_amsdu_aggregate()
3451 orig_len = head->len; in ieee80211_amsdu_aggregate()
3453 if (skb->len + head->len > max_amsdu_len) in ieee80211_amsdu_aggregate()
3456 nfrags = 1 + skb_shinfo(skb)->nr_frags; in ieee80211_amsdu_aggregate()
3457 nfrags += 1 + skb_shinfo(head)->nr_frags; in ieee80211_amsdu_aggregate()
3458 frag_tail = &skb_shinfo(head)->frag_list; in ieee80211_amsdu_aggregate()
3460 nfrags += 1 + skb_shinfo(*frag_tail)->nr_frags; in ieee80211_amsdu_aggregate()
3461 frag_tail = &(*frag_tail)->next; in ieee80211_amsdu_aggregate()
3478 * and frag_tail should be &skb_shinfo(head)->frag_list. in ieee80211_amsdu_aggregate()
3483 frag_tail = &skb_shinfo(head)->frag_list; in ieee80211_amsdu_aggregate()
3487 * padding to the next one, that's being added. Note that head->len in ieee80211_amsdu_aggregate()
3488 * is the length of the full A-MSDU, but that works since each time in ieee80211_amsdu_aggregate()
3492 hdrlen = fast_tx->hdr_len - sizeof(rfc1042_header); in ieee80211_amsdu_aggregate()
3493 if ((head->len - hdrlen) & 3) in ieee80211_amsdu_aggregate()
3494 pad = 4 - ((head->len - hdrlen) & 3); in ieee80211_amsdu_aggregate()
3512 head->len += skb->len; in ieee80211_amsdu_aggregate()
3513 head->data_len += skb->len; in ieee80211_amsdu_aggregate()
3517 fq->memory_usage += head->truesize - orig_truesize; in ieee80211_amsdu_aggregate()
3518 if (head->len != orig_len) { in ieee80211_amsdu_aggregate()
3519 flow->backlog += head->len - orig_len; in ieee80211_amsdu_aggregate()
3520 tin->backlog_bytes += head->len - orig_len; in ieee80211_amsdu_aggregate()
3523 spin_unlock_bh(&fq->lock); in ieee80211_amsdu_aggregate()
3538 struct sk_buff *skb = tx->skb; in ieee80211_xmit_fast_finish()
3540 struct ieee80211_hdr *hdr = (void *)skb->data; in ieee80211_xmit_fast_finish()
3543 if (!ieee80211_hw_check(&tx->local->hw, HAS_RATE_CONTROL) && in ieee80211_xmit_fast_finish()
3548 info->control.hw_key = &key->conf; in ieee80211_xmit_fast_finish()
3550 dev_sw_netstats_tx_add(skb->dev, 1, skb->len); in ieee80211_xmit_fast_finish()
3552 if (hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) { in ieee80211_xmit_fast_finish()
3553 tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; in ieee80211_xmit_fast_finish()
3554 hdr->seq_ctrl = ieee80211_tx_next_seq(sta, tid); in ieee80211_xmit_fast_finish()
3556 info->flags |= IEEE80211_TX_CTL_ASSIGN_SEQ; in ieee80211_xmit_fast_finish()
3557 hdr->seq_ctrl = cpu_to_le16(sdata->sequence_number); in ieee80211_xmit_fast_finish()
3558 sdata->sequence_number += 0x10; in ieee80211_xmit_fast_finish()
3561 if (skb_shinfo(skb)->gso_size) in ieee80211_xmit_fast_finish()
3562 sta->deflink.tx_stats.msdu[tid] += in ieee80211_xmit_fast_finish()
3563 DIV_ROUND_UP(skb->len, skb_shinfo(skb)->gso_size); in ieee80211_xmit_fast_finish()
3565 sta->deflink.tx_stats.msdu[tid]++; in ieee80211_xmit_fast_finish()
3567 info->hw_queue = sdata->vif.hw_queue[skb_get_queue_mapping(skb)]; in ieee80211_xmit_fast_finish()
3572 sta->deflink.tx_stats.bytes[skb_get_queue_mapping(skb)] += skb->len; in ieee80211_xmit_fast_finish()
3573 sta->deflink.tx_stats.packets[skb_get_queue_mapping(skb)]++; in ieee80211_xmit_fast_finish()
3577 u8 *crypto_hdr = skb->data + pn_offs; in ieee80211_xmit_fast_finish()
3579 switch (key->conf.cipher) { in ieee80211_xmit_fast_finish()
3584 pn = atomic64_inc_return(&key->conf.tx_pn); in ieee80211_xmit_fast_finish()
3587 crypto_hdr[3] = 0x20 | (key->conf.keyidx << 6); in ieee80211_xmit_fast_finish()
3602 if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN) in ieee80211_sdata_netdev_features()
3603 return sdata->vif.netdev_features; in ieee80211_sdata_netdev_features()
3605 if (!sdata->bss) in ieee80211_sdata_netdev_features()
3608 sdata = container_of(sdata->bss, struct ieee80211_sub_if_data, u.ap); in ieee80211_sdata_netdev_features()
3609 return sdata->vif.netdev_features; in ieee80211_sdata_netdev_features()
3631 if (skb->ip_summed == CHECKSUM_PARTIAL) { in ieee80211_tx_skb_fixup()
3634 if (skb->encapsulation) in ieee80211_tx_skb_fixup()
3657 struct ieee80211_local *local = sdata->local; in __ieee80211_xmit_fast()
3658 struct ieee80211_hdr *hdr = (void *)fast_tx->hdr; in __ieee80211_xmit_fast()
3662 int hw_headroom = sdata->local->hw.extra_tx_headroom; in __ieee80211_xmit_fast()
3663 int extra_head = fast_tx->hdr_len - (ETH_HLEN - 2); in __ieee80211_xmit_fast()
3669 if ((hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) && in __ieee80211_xmit_fast()
3673 /* will not be crypto-handled beyond what we do here, so use false in __ieee80211_xmit_fast()
3674 * as the may-encrypt argument for the resize to not account for in __ieee80211_xmit_fast()
3678 max_t(int, extra_head + hw_headroom - in __ieee80211_xmit_fast()
3684 memcpy(skb->data, fast_tx->hdr, fast_tx->hdr_len); in __ieee80211_xmit_fast()
3685 memcpy(skb->data + fast_tx->da_offs, da, ETH_ALEN); in __ieee80211_xmit_fast()
3686 memcpy(skb->data + fast_tx->sa_offs, sa, ETH_ALEN); in __ieee80211_xmit_fast()
3690 info->band = fast_tx->band; in __ieee80211_xmit_fast()
3691 info->control.vif = &sdata->vif; in __ieee80211_xmit_fast()
3692 info->flags = IEEE80211_TX_CTL_FIRST_FRAGMENT | in __ieee80211_xmit_fast()
3694 info->control.flags = IEEE80211_TX_CTRL_FAST_XMIT | in __ieee80211_xmit_fast()
3699 if (local->force_tx_status) in __ieee80211_xmit_fast()
3700 info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS; in __ieee80211_xmit_fast()
3703 if (hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) { in __ieee80211_xmit_fast()
3704 u8 tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; in __ieee80211_xmit_fast()
3715 tx.key = fast_tx->key; in __ieee80211_xmit_fast()
3721 r = ieee80211_xmit_fast_finish(sdata, sta, fast_tx->pn_offs, in __ieee80211_xmit_fast()
3722 fast_tx->key, &tx); in __ieee80211_xmit_fast()
3727 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) in __ieee80211_xmit_fast()
3728 sdata = container_of(sdata->bss, in __ieee80211_xmit_fast()
3732 ieee80211_tx_frags(local, &sdata->vif, sta, &tx.skbs, false); in __ieee80211_xmit_fast()
3744 u16 ethertype = (skb->data[12] << 8) | skb->data[13]; in ieee80211_xmit_fast()
3745 struct ieee80211_hdr *hdr = (void *)fast_tx->hdr; in ieee80211_xmit_fast()
3752 if (cpu_to_be16(ethertype) == sdata->control_port_protocol) in ieee80211_xmit_fast()
3760 if (skb->sk && skb_shinfo(skb)->tx_flags & SKBTX_WIFI_STATUS) in ieee80211_xmit_fast()
3763 if (hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) { in ieee80211_xmit_fast()
3764 tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; in ieee80211_xmit_fast()
3765 tid_tx = rcu_dereference(sta->ampdu_mlme.tid_tx[tid]); in ieee80211_xmit_fast()
3767 if (!test_bit(HT_AGG_STATE_OPERATIONAL, &tid_tx->state)) in ieee80211_xmit_fast()
3769 if (tid_tx->timeout) in ieee80211_xmit_fast()
3770 tid_tx->last_tx = jiffies; in ieee80211_xmit_fast()
3774 memcpy(ð, skb->data, ETH_HLEN - 2); in ieee80211_xmit_fast()
3797 struct fq *fq = &local->fq; in ieee80211_tx_dequeue()
3798 struct fq_tin *tin = &txqi->tin; in ieee80211_tx_dequeue()
3802 struct ieee80211_vif *vif = txq->vif; in ieee80211_tx_dequeue()
3803 int q = vif->hw_queue[txq->ac]; in ieee80211_tx_dequeue()
3813 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in ieee80211_tx_dequeue()
3814 q_stopped = local->queue_stop_reasons[q]; in ieee80211_tx_dequeue()
3815 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_tx_dequeue()
3819 set_bit(IEEE80211_TXQ_DIRTY, &txqi->flags); in ieee80211_tx_dequeue()
3823 spin_lock_bh(&fq->lock); in ieee80211_tx_dequeue()
3826 skb = __skb_dequeue(&txqi->frags); in ieee80211_tx_dequeue()
3828 if (!(IEEE80211_SKB_CB(skb)->control.flags & in ieee80211_tx_dequeue()
3831 IEEE80211_SKB_CB(skb)->control.flags &= in ieee80211_tx_dequeue()
3834 if (unlikely(test_bit(IEEE80211_TXQ_STOP, &txqi->flags))) in ieee80211_tx_dequeue()
3843 spin_unlock_bh(&fq->lock); in ieee80211_tx_dequeue()
3845 hdr = (struct ieee80211_hdr *)skb->data; in ieee80211_tx_dequeue()
3852 tx.sdata = vif_to_sdata(info->control.vif); in ieee80211_tx_dequeue()
3854 if (txq->sta) { in ieee80211_tx_dequeue()
3855 tx.sta = container_of(txq->sta, struct sta_info, sta); in ieee80211_tx_dequeue()
3860 if (unlikely(!(info->flags & IEEE80211_TX_CTL_INJECTED) && in ieee80211_tx_dequeue()
3861 ieee80211_is_data(hdr->frame_control) && in ieee80211_tx_dequeue()
3862 !ieee80211_vif_is_mesh(&tx.sdata->vif) && in ieee80211_tx_dequeue()
3863 tx.sdata->vif.type != NL80211_IFTYPE_OCB && in ieee80211_tx_dequeue()
3864 !is_multicast_ether_addr(hdr->addr1) && in ieee80211_tx_dequeue()
3866 (!(info->control.flags & in ieee80211_tx_dequeue()
3868 !ieee80211_is_our_addr(tx.sdata, hdr->addr2, in ieee80211_tx_dequeue()
3870 I802_DEBUG_INC(local->tx_handlers_drop_unauth_port); in ieee80211_tx_dequeue()
3871 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_dequeue()
3882 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_dequeue()
3886 if (test_bit(IEEE80211_TXQ_AMPDU, &txqi->flags)) in ieee80211_tx_dequeue()
3887 info->flags |= (IEEE80211_TX_CTL_AMPDU | in ieee80211_tx_dequeue()
3890 if (info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP) { in ieee80211_tx_dequeue()
3891 if (!ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL)) { in ieee80211_tx_dequeue()
3894 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_dequeue()
3901 if (info->control.flags & IEEE80211_TX_CTRL_FAST_XMIT) { in ieee80211_tx_dequeue()
3902 struct sta_info *sta = container_of(txq->sta, struct sta_info, in ieee80211_tx_dequeue()
3907 (tx.key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)) in ieee80211_tx_dequeue()
3908 pn_offs = ieee80211_hdrlen(hdr->frame_control); in ieee80211_tx_dequeue()
3910 r = ieee80211_xmit_fast_finish(sta->sdata, sta, pn_offs, in ieee80211_tx_dequeue()
3913 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_dequeue()
3924 spin_lock_bh(&fq->lock); in ieee80211_tx_dequeue()
3925 skb_queue_splice_tail(&tx.skbs, &txqi->frags); in ieee80211_tx_dequeue()
3926 spin_unlock_bh(&fq->lock); in ieee80211_tx_dequeue()
3931 !ieee80211_hw_check(&local->hw, TX_FRAG_LIST)) { in ieee80211_tx_dequeue()
3933 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_dequeue()
3938 switch (tx.sdata->vif.type) { in ieee80211_tx_dequeue()
3940 if (tx.sdata->u.mntr.flags & MONITOR_FLAG_ACTIVE) { in ieee80211_tx_dequeue()
3941 vif = &tx.sdata->vif; in ieee80211_tx_dequeue()
3944 tx.sdata = rcu_dereference(local->monitor_sdata); in ieee80211_tx_dequeue()
3946 vif = &tx.sdata->vif; in ieee80211_tx_dequeue()
3947 info->hw_queue = in ieee80211_tx_dequeue()
3948 vif->hw_queue[skb_get_queue_mapping(skb)]; in ieee80211_tx_dequeue()
3949 } else if (ieee80211_hw_check(&local->hw, QUEUE_CONTROL)) { in ieee80211_tx_dequeue()
3950 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_dequeue()
3957 tx.sdata = container_of(tx.sdata->bss, in ieee80211_tx_dequeue()
3961 vif = &tx.sdata->vif; in ieee80211_tx_dequeue()
3966 info->control.vif = vif; in ieee80211_tx_dequeue()
3969 wiphy_ext_feature_isset(local->hw.wiphy, NL80211_EXT_FEATURE_AQL)) { in ieee80211_tx_dequeue()
3970 bool ampdu = txq->ac != IEEE80211_AC_VO; in ieee80211_tx_dequeue()
3973 airtime = ieee80211_calc_expected_tx_airtime(hw, vif, txq->sta, in ieee80211_tx_dequeue()
3974 skb->len, ampdu); in ieee80211_tx_dequeue()
3978 txq->ac, in ieee80211_tx_dequeue()
3987 spin_unlock_bh(&fq->lock); in ieee80211_tx_dequeue()
3993 static inline s32 ieee80211_sta_deficit(struct sta_info *sta, u8 ac) in ieee80211_sta_deficit() argument
3995 struct airtime_info *air_info = &sta->airtime[ac]; in ieee80211_sta_deficit()
3997 return air_info->deficit - atomic_read(&air_info->aql_tx_pending); in ieee80211_sta_deficit()
4005 if (!txqi->txq.sta) in ieee80211_txq_set_active()
4008 sta = container_of(txqi->txq.sta, struct sta_info, sta); in ieee80211_txq_set_active()
4009 sta->airtime[txqi->txq.ac].last_active = (u32)jiffies; in ieee80211_txq_set_active()
4018 if (!txqi->txq.sta) in ieee80211_txq_keep_active()
4021 sta = container_of(txqi->txq.sta, struct sta_info, sta); in ieee80211_txq_keep_active()
4022 if (ieee80211_sta_deficit(sta, txqi->txq.ac) >= 0) in ieee80211_txq_keep_active()
4025 diff = (u32)jiffies - sta->airtime[txqi->txq.ac].last_active; in ieee80211_txq_keep_active()
4030 struct ieee80211_txq *ieee80211_next_txq(struct ieee80211_hw *hw, u8 ac) in ieee80211_next_txq() argument
4037 spin_lock_bh(&local->active_txq_lock[ac]); in ieee80211_next_txq()
4039 if (!local->schedule_round[ac]) in ieee80211_next_txq()
4043 txqi = list_first_entry_or_null(&local->active_txqs[ac], in ieee80211_next_txq()
4059 if (txqi->txq.sta) { in ieee80211_next_txq()
4060 struct sta_info *sta = container_of(txqi->txq.sta, in ieee80211_next_txq()
4062 bool aql_check = ieee80211_txq_airtime_check(hw, &txqi->txq); in ieee80211_next_txq()
4063 s32 deficit = ieee80211_sta_deficit(sta, txqi->txq.ac); in ieee80211_next_txq()
4069 sta->airtime[txqi->txq.ac].deficit += in ieee80211_next_txq()
4070 sta->airtime_weight; in ieee80211_next_txq()
4073 list_move_tail(&txqi->schedule_order, in ieee80211_next_txq()
4074 &local->active_txqs[txqi->txq.ac]); in ieee80211_next_txq()
4079 if (txqi->schedule_round == local->schedule_round[ac]) in ieee80211_next_txq()
4082 list_del_init(&txqi->schedule_order); in ieee80211_next_txq()
4083 txqi->schedule_round = local->schedule_round[ac]; in ieee80211_next_txq()
4084 ret = &txqi->txq; in ieee80211_next_txq()
4087 spin_unlock_bh(&local->active_txq_lock[ac]); in ieee80211_next_txq()
4100 spin_lock_bh(&local->active_txq_lock[txq->ac]); in __ieee80211_schedule_txq()
4103 if (list_empty(&txqi->schedule_order) && in __ieee80211_schedule_txq()
4112 if (txqi->txq.sta && local->airtime_flags && has_queue && in __ieee80211_schedule_txq()
4113 wiphy_ext_feature_isset(local->hw.wiphy, in __ieee80211_schedule_txq()
4115 list_add(&txqi->schedule_order, in __ieee80211_schedule_txq()
4116 &local->active_txqs[txq->ac]); in __ieee80211_schedule_txq()
4118 list_add_tail(&txqi->schedule_order, in __ieee80211_schedule_txq()
4119 &local->active_txqs[txq->ac]); in __ieee80211_schedule_txq()
4124 spin_unlock_bh(&local->active_txq_lock[txq->ac]); in __ieee80211_schedule_txq()
4136 if (!wiphy_ext_feature_isset(local->hw.wiphy, NL80211_EXT_FEATURE_AQL)) in ieee80211_txq_airtime_check()
4142 if (!txq->sta) in ieee80211_txq_airtime_check()
4145 if (unlikely(txq->tid == IEEE80211_NUM_TIDS)) in ieee80211_txq_airtime_check()
4148 sta = container_of(txq->sta, struct sta_info, sta); in ieee80211_txq_airtime_check()
4149 if (atomic_read(&sta->airtime[txq->ac].aql_tx_pending) < in ieee80211_txq_airtime_check()
4150 sta->airtime[txq->ac].aql_limit_low) in ieee80211_txq_airtime_check()
4153 if (atomic_read(&local->aql_total_pending_airtime) < in ieee80211_txq_airtime_check()
4154 local->aql_threshold && in ieee80211_txq_airtime_check()
4155 atomic_read(&sta->airtime[txq->ac].aql_tx_pending) < in ieee80211_txq_airtime_check()
4156 sta->airtime[txq->ac].aql_limit_high) in ieee80211_txq_airtime_check()
4164 ieee80211_txq_schedule_airtime_check(struct ieee80211_local *local, u8 ac) in ieee80211_txq_schedule_airtime_check() argument
4170 if (!wiphy_ext_feature_isset(local->hw.wiphy, NL80211_EXT_FEATURE_AQL)) in ieee80211_txq_schedule_airtime_check()
4173 list_for_each_entry(txq, &local->active_txqs[ac], schedule_order) in ieee80211_txq_schedule_airtime_check()
4176 aql_limit = (num_txq - 1) * local->aql_txq_limit_low[ac] / 2 + in ieee80211_txq_schedule_airtime_check()
4177 local->aql_txq_limit_high[ac]; in ieee80211_txq_schedule_airtime_check()
4179 return atomic_read(&local->aql_ac_pending_airtime[ac]) < aql_limit; in ieee80211_txq_schedule_airtime_check()
4188 u8 ac = txq->ac; in ieee80211_txq_may_transmit() local
4190 spin_lock_bh(&local->active_txq_lock[ac]); in ieee80211_txq_may_transmit()
4192 if (!txqi->txq.sta) in ieee80211_txq_may_transmit()
4195 if (list_empty(&txqi->schedule_order)) in ieee80211_txq_may_transmit()
4198 if (!ieee80211_txq_schedule_airtime_check(local, ac)) in ieee80211_txq_may_transmit()
4201 list_for_each_entry_safe(iter, tmp, &local->active_txqs[ac], in ieee80211_txq_may_transmit()
4206 if (!iter->txq.sta) { in ieee80211_txq_may_transmit()
4207 list_move_tail(&iter->schedule_order, in ieee80211_txq_may_transmit()
4208 &local->active_txqs[ac]); in ieee80211_txq_may_transmit()
4211 sta = container_of(iter->txq.sta, struct sta_info, sta); in ieee80211_txq_may_transmit()
4212 if (ieee80211_sta_deficit(sta, ac) < 0) in ieee80211_txq_may_transmit()
4213 sta->airtime[ac].deficit += sta->airtime_weight; in ieee80211_txq_may_transmit()
4214 list_move_tail(&iter->schedule_order, &local->active_txqs[ac]); in ieee80211_txq_may_transmit()
4217 sta = container_of(txqi->txq.sta, struct sta_info, sta); in ieee80211_txq_may_transmit()
4218 if (sta->airtime[ac].deficit >= 0) in ieee80211_txq_may_transmit()
4221 sta->airtime[ac].deficit += sta->airtime_weight; in ieee80211_txq_may_transmit()
4222 list_move_tail(&txqi->schedule_order, &local->active_txqs[ac]); in ieee80211_txq_may_transmit()
4223 spin_unlock_bh(&local->active_txq_lock[ac]); in ieee80211_txq_may_transmit()
4227 if (!list_empty(&txqi->schedule_order)) in ieee80211_txq_may_transmit()
4228 list_del_init(&txqi->schedule_order); in ieee80211_txq_may_transmit()
4229 spin_unlock_bh(&local->active_txq_lock[ac]); in ieee80211_txq_may_transmit()
4235 void ieee80211_txq_schedule_start(struct ieee80211_hw *hw, u8 ac) in ieee80211_txq_schedule_start() argument
4239 spin_lock_bh(&local->active_txq_lock[ac]); in ieee80211_txq_schedule_start()
4241 if (ieee80211_txq_schedule_airtime_check(local, ac)) { in ieee80211_txq_schedule_start()
4242 local->schedule_round[ac]++; in ieee80211_txq_schedule_start()
4243 if (!local->schedule_round[ac]) in ieee80211_txq_schedule_start()
4244 local->schedule_round[ac]++; in ieee80211_txq_schedule_start()
4246 local->schedule_round[ac] = 0; in ieee80211_txq_schedule_start()
4249 spin_unlock_bh(&local->active_txq_lock[ac]); in ieee80211_txq_schedule_start()
4260 struct ieee80211_local *local = sdata->local; in __ieee80211_subif_start_xmit()
4263 int len = skb->len; in __ieee80211_subif_start_xmit()
4265 if (unlikely(!ieee80211_sdata_running(sdata) || skb->len < ETH_HLEN)) { in __ieee80211_subif_start_xmit()
4270 sk_pacing_shift_update(skb->sk, sdata->local->hw.tx_sk_pacing_shift); in __ieee80211_subif_start_xmit()
4274 if (ieee80211_vif_is_mesh(&sdata->vif) && in __ieee80211_subif_start_xmit()
4275 ieee80211_hw_check(&local->hw, SUPPORT_FAST_XMIT) && in __ieee80211_subif_start_xmit()
4291 fast_tx = rcu_dereference(sta->fast_tx); in __ieee80211_subif_start_xmit()
4298 /* the frame could be fragmented, software-encrypted, and other in __ieee80211_subif_start_xmit()
4311 if (skb->protocol == sdata->control_port_protocol) in __ieee80211_subif_start_xmit()
4321 dev_sw_netstats_tx_add(dev, 1, skb->len); in __ieee80211_subif_start_xmit()
4344 eth = (void *)skb->data; in ieee80211_change_da()
4345 ether_addr_copy(eth->h_dest, sta->sta.addr); in ieee80211_change_da()
4354 const struct ethhdr *eth = (void *)skb->data; in ieee80211_multicast_to_unicast()
4355 const struct vlan_ethhdr *ethvlan = (void *)skb->data; in ieee80211_multicast_to_unicast()
4358 switch (sdata->vif.type) { in ieee80211_multicast_to_unicast()
4360 if (sdata->u.vlan.sta) in ieee80211_multicast_to_unicast()
4362 if (sdata->wdev.use_4addr) in ieee80211_multicast_to_unicast()
4367 if (!sdata->bss->multicast_to_unicast) in ieee80211_multicast_to_unicast()
4375 ethertype = eth->h_proto; in ieee80211_multicast_to_unicast()
4376 if (ethertype == htons(ETH_P_8021Q) && skb->len >= VLAN_ETH_HLEN) in ieee80211_multicast_to_unicast()
4377 ethertype = ethvlan->h_vlan_encapsulated_proto; in ieee80211_multicast_to_unicast()
4395 struct ieee80211_local *local = sdata->local; in ieee80211_convert_to_unicast()
4396 const struct ethhdr *eth = (struct ethhdr *)skb->data; in ieee80211_convert_to_unicast()
4402 list_for_each_entry_rcu(sta, &local->sta_list, list) { in ieee80211_convert_to_unicast()
4403 if (sdata != sta->sdata) in ieee80211_convert_to_unicast()
4404 /* AP-VLAN mismatch */ in ieee80211_convert_to_unicast()
4406 if (unlikely(ether_addr_equal(eth->h_source, sta->sta.addr))) in ieee80211_convert_to_unicast()
4452 __ieee80211_subif_start_xmit(out, sdata->dev, 0, ctrl_flags, NULL); in ieee80211_mlo_multicast_tx_one()
4459 unsigned long links = sdata->vif.active_links; in ieee80211_mlo_multicast_tx()
4460 unsigned int link; in ieee80211_mlo_multicast_tx() local
4467 __ieee80211_subif_start_xmit(skb, sdata->dev, 0, ctrl_flags, in ieee80211_mlo_multicast_tx()
4472 for_each_set_bit(link, &links, IEEE80211_MLD_MAX_NUM_LINKS) { in ieee80211_mlo_multicast_tx()
4473 ieee80211_mlo_multicast_tx_one(sdata, skb, ctrl_flags, link); in ieee80211_mlo_multicast_tx()
4480 * ieee80211_subif_start_xmit - netif start_xmit function for 802.3 vifs
4490 const struct ethhdr *eth = (void *)skb->data; in ieee80211_subif_start_xmit()
4492 if (likely(!is_multicast_ether_addr(eth->h_dest))) in ieee80211_subif_start_xmit()
4509 } else if (ieee80211_vif_is_mld(&sdata->vif) && in ieee80211_subif_start_xmit()
4510 sdata->vif.type == NL80211_IFTYPE_AP && in ieee80211_subif_start_xmit()
4511 !ieee80211_hw_check(&sdata->local->hw, MLO_MCAST_MULTI_LINK_TX)) { in ieee80211_subif_start_xmit()
4529 struct ieee80211_local *local = sdata->local; in __ieee80211_tx_8023()
4534 int q = info->hw_queue; in __ieee80211_tx_8023()
4536 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in __ieee80211_tx_8023()
4538 if (local->queue_stop_reasons[q] || in __ieee80211_tx_8023()
4539 (!txpending && !skb_queue_empty(&local->pending[q]))) { in __ieee80211_tx_8023()
4541 skb_queue_head(&local->pending[q], skb); in __ieee80211_tx_8023()
4543 skb_queue_tail(&local->pending[q], skb); in __ieee80211_tx_8023()
4545 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in __ieee80211_tx_8023()
4550 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in __ieee80211_tx_8023()
4552 if (sta && sta->uploaded) in __ieee80211_tx_8023()
4553 pubsta = &sta->sta; in __ieee80211_tx_8023()
4566 struct ieee80211_local *local = sdata->local; in ieee80211_tx_8023()
4587 struct ieee80211_local *local = sdata->local; in ieee80211_8023_xmit()
4597 if (unlikely(test_bit(SCAN_SW_SCANNING, &local->scanning)) && in ieee80211_8023_xmit()
4598 test_bit(SDATA_STATE_OFFCHANNEL, &sdata->state)) in ieee80211_8023_xmit()
4607 tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; in ieee80211_8023_xmit()
4608 tid_tx = rcu_dereference(sta->ampdu_mlme.tid_tx[tid]); in ieee80211_8023_xmit()
4610 if (!test_bit(HT_AGG_STATE_OPERATIONAL, &tid_tx->state)) { in ieee80211_8023_xmit()
4611 /* fall back to non-offload slow path */ in ieee80211_8023_xmit()
4618 if (tid_tx->timeout) in ieee80211_8023_xmit()
4619 tid_tx->last_tx = jiffies; in ieee80211_8023_xmit()
4629 info->hw_queue = sdata->vif.hw_queue[queue]; in ieee80211_8023_xmit()
4631 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) in ieee80211_8023_xmit()
4632 sdata = container_of(sdata->bss, in ieee80211_8023_xmit()
4635 info->flags |= IEEE80211_TX_CTL_HW_80211_ENCAP; in ieee80211_8023_xmit()
4636 info->control.vif = &sdata->vif; in ieee80211_8023_xmit()
4639 info->control.hw_key = &key->conf; in ieee80211_8023_xmit()
4643 len += seg->len; in ieee80211_8023_xmit()
4648 if (unlikely(skb->sk && in ieee80211_8023_xmit()
4649 skb_shinfo(skb)->tx_flags & SKBTX_WIFI_STATUS)) in ieee80211_8023_xmit()
4650 info->ack_frame_id = ieee80211_store_ack_skb(local, skb, in ieee80211_8023_xmit()
4651 &info->flags, NULL); in ieee80211_8023_xmit()
4654 sta->deflink.tx_stats.packets[queue] += skbs; in ieee80211_8023_xmit()
4655 sta->deflink.tx_stats.bytes[queue] += len; in ieee80211_8023_xmit()
4671 struct ethhdr *ehdr = (struct ethhdr *)skb->data; in ieee80211_subif_start_xmit_8023()
4675 if (unlikely(!ieee80211_sdata_running(sdata) || skb->len < ETH_HLEN)) { in ieee80211_subif_start_xmit_8023()
4687 if (unlikely(IS_ERR_OR_NULL(sta) || !sta->uploaded || in ieee80211_subif_start_xmit_8023()
4689 sdata->control_port_protocol == ehdr->h_proto)) in ieee80211_subif_start_xmit_8023()
4692 key = rcu_dereference(sta->ptk[sta->ptk_idx]); in ieee80211_subif_start_xmit_8023()
4694 key = rcu_dereference(sdata->default_unicast_key); in ieee80211_subif_start_xmit_8023()
4696 if (key && (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) || in ieee80211_subif_start_xmit_8023()
4697 key->conf.cipher == WLAN_CIPHER_SUITE_TKIP)) in ieee80211_subif_start_xmit_8023()
4700 sk_pacing_shift_update(skb->sk, sdata->local->hw.tx_sk_pacing_shift); in ieee80211_subif_start_xmit_8023()
4718 .local = sdata->local, in ieee80211_build_data_template()
4727 skb = ERR_PTR(-EINVAL); in ieee80211_build_data_template()
4736 hdr = (void *)skb->data; in ieee80211_build_data_template()
4737 tx.sta = sta_info_get(sdata, hdr->addr1); in ieee80211_build_data_template()
4743 return ERR_PTR(-EINVAL); in ieee80211_build_data_template()
4760 for (i = 0; i < local->hw.queues; i++) { in ieee80211_clear_tx_pending()
4761 while ((skb = skb_dequeue(&local->pending[i])) != NULL) in ieee80211_clear_tx_pending()
4762 ieee80211_free_txskb(&local->hw, skb); in ieee80211_clear_tx_pending()
4768 * which in this case means re-queued -- take as an indication to stop sending
4781 sdata = vif_to_sdata(info->control.vif); in ieee80211_tx_pending_skb()
4783 if (info->control.flags & IEEE80211_TX_INTCFL_NEED_TXPROCESSING) { in ieee80211_tx_pending_skb()
4784 /* update band only for non-MLD */ in ieee80211_tx_pending_skb()
4785 if (!ieee80211_vif_is_mld(&sdata->vif)) { in ieee80211_tx_pending_skb()
4787 rcu_dereference(sdata->vif.bss_conf.chanctx_conf); in ieee80211_tx_pending_skb()
4792 info->band = chanctx_conf->def.chan->band; in ieee80211_tx_pending_skb()
4795 } else if (info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP) { in ieee80211_tx_pending_skb()
4801 if (IS_ERR(sta) || (sta && !sta->uploaded)) in ieee80211_tx_pending_skb()
4811 hdr = (struct ieee80211_hdr *)skb->data; in ieee80211_tx_pending_skb()
4812 sta = sta_info_get(sdata, hdr->addr1); in ieee80211_tx_pending_skb()
4833 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in ieee80211_tx_pending()
4834 for (i = 0; i < local->hw.queues; i++) { in ieee80211_tx_pending()
4839 if (local->queue_stop_reasons[i] || in ieee80211_tx_pending()
4840 skb_queue_empty(&local->pending[i])) in ieee80211_tx_pending()
4843 while (!skb_queue_empty(&local->pending[i])) { in ieee80211_tx_pending()
4844 struct sk_buff *skb = __skb_dequeue(&local->pending[i]); in ieee80211_tx_pending()
4847 if (WARN_ON(!info->control.vif)) { in ieee80211_tx_pending()
4848 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_pending()
4852 spin_unlock_irqrestore(&local->queue_stop_reason_lock, in ieee80211_tx_pending()
4856 spin_lock_irqsave(&local->queue_stop_reason_lock, in ieee80211_tx_pending()
4862 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_tx_pending()
4870 struct ieee80211_link_data *link, in __ieee80211_beacon_add_tim() argument
4877 struct ieee80211_bss_conf *link_conf = link->conf; in __ieee80211_beacon_add_tim()
4881 if (atomic_read(&ps->num_sta_ps) > 0) in __ieee80211_beacon_add_tim()
4883 * checking byte-for-byte */ in __ieee80211_beacon_add_tim()
4884 have_bits = !bitmap_empty((unsigned long *)ps->tim, in __ieee80211_beacon_add_tim()
4887 if (ps->dtim_count == 0) in __ieee80211_beacon_add_tim()
4888 ps->dtim_count = link_conf->dtim_period - 1; in __ieee80211_beacon_add_tim()
4890 ps->dtim_count--; in __ieee80211_beacon_add_tim()
4896 *pos++ = ps->dtim_count; in __ieee80211_beacon_add_tim()
4897 *pos++ = link_conf->dtim_period; in __ieee80211_beacon_add_tim()
4899 if (ps->dtim_count == 0 && !skb_queue_empty(&ps->bc_buf)) in __ieee80211_beacon_add_tim()
4902 ps->dtim_bc_mc = aid0 == 1; in __ieee80211_beacon_add_tim()
4906 * (N1 x 8) - 1 in the bitmap are 0 and number N2 so that bits in __ieee80211_beacon_add_tim()
4910 if (ps->tim[i]) { in __ieee80211_beacon_add_tim()
4916 for (i = IEEE80211_MAX_TIM_LEN - 1; i >= n1; i--) { in __ieee80211_beacon_add_tim()
4917 if (ps->tim[i]) { in __ieee80211_beacon_add_tim()
4926 skb_put_data(skb, ps->tim + n1, n2 - n1 + 1); in __ieee80211_beacon_add_tim()
4928 tim[1] = n2 - n1 + 4; in __ieee80211_beacon_add_tim()
4932 if (ieee80211_get_link_sband(link)->band != NL80211_BAND_S1GHZ) { in __ieee80211_beacon_add_tim()
4941 struct ieee80211_link_data *link, in ieee80211_beacon_add_tim() argument
4945 struct ieee80211_local *local = sdata->local; in ieee80211_beacon_add_tim()
4951 * sta_lock to guarantee consistent and race-free update in ieee80211_beacon_add_tim()
4954 if (local->tim_in_locked_section) { in ieee80211_beacon_add_tim()
4955 __ieee80211_beacon_add_tim(sdata, link, ps, skb, is_template); in ieee80211_beacon_add_tim()
4957 spin_lock_bh(&local->tim_lock); in ieee80211_beacon_add_tim()
4958 __ieee80211_beacon_add_tim(sdata, link, ps, skb, is_template); in ieee80211_beacon_add_tim()
4959 spin_unlock_bh(&local->tim_lock); in ieee80211_beacon_add_tim()
4967 struct ieee80211_link_data *link) in ieee80211_set_beacon_cntdwn() argument
4975 switch (sdata->vif.type) { in ieee80211_set_beacon_cntdwn()
4977 beacon_data = beacon->tail; in ieee80211_set_beacon_cntdwn()
4978 beacon_data_len = beacon->tail_len; in ieee80211_set_beacon_cntdwn()
4981 beacon_data = beacon->head; in ieee80211_set_beacon_cntdwn()
4982 beacon_data_len = beacon->head_len; in ieee80211_set_beacon_cntdwn()
4985 beacon_data = beacon->head; in ieee80211_set_beacon_cntdwn()
4986 beacon_data_len = beacon->head_len; in ieee80211_set_beacon_cntdwn()
4992 resp = rcu_dereference(link->u.ap.probe_resp); in ieee80211_set_beacon_cntdwn()
4994 bcn_offsets = beacon->cntdwn_counter_offsets; in ieee80211_set_beacon_cntdwn()
4995 count = beacon->cntdwn_current_counter; in ieee80211_set_beacon_cntdwn()
4996 if (link->conf->csa_active) in ieee80211_set_beacon_cntdwn()
5006 if (sdata->vif.type == NL80211_IFTYPE_AP && resp) { in ieee80211_set_beacon_cntdwn()
5007 u16 *resp_offsets = resp->cntdwn_counter_offsets; in ieee80211_set_beacon_cntdwn()
5009 resp->data[resp_offsets[i]] = count; in ieee80211_set_beacon_cntdwn()
5016 beacon->cntdwn_current_counter--; in __ieee80211_beacon_update_cntdwn()
5019 WARN_ON_ONCE(!beacon->cntdwn_current_counter); in __ieee80211_beacon_update_cntdwn()
5021 return beacon->cntdwn_current_counter; in __ieee80211_beacon_update_cntdwn()
5032 if (sdata->vif.type == NL80211_IFTYPE_AP) in ieee80211_beacon_update_cntdwn()
5033 beacon = rcu_dereference(sdata->deflink.u.ap.beacon); in ieee80211_beacon_update_cntdwn()
5034 else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) in ieee80211_beacon_update_cntdwn()
5035 beacon = rcu_dereference(sdata->u.ibss.presp); in ieee80211_beacon_update_cntdwn()
5036 else if (ieee80211_vif_is_mesh(&sdata->vif)) in ieee80211_beacon_update_cntdwn()
5037 beacon = rcu_dereference(sdata->u.mesh.beacon); in ieee80211_beacon_update_cntdwn()
5057 if (sdata->vif.type == NL80211_IFTYPE_AP) in ieee80211_beacon_set_cntdwn()
5058 beacon = rcu_dereference(sdata->deflink.u.ap.beacon); in ieee80211_beacon_set_cntdwn()
5059 else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) in ieee80211_beacon_set_cntdwn()
5060 beacon = rcu_dereference(sdata->u.ibss.presp); in ieee80211_beacon_set_cntdwn()
5061 else if (ieee80211_vif_is_mesh(&sdata->vif)) in ieee80211_beacon_set_cntdwn()
5062 beacon = rcu_dereference(sdata->u.mesh.beacon); in ieee80211_beacon_set_cntdwn()
5067 if (counter < beacon->cntdwn_current_counter) in ieee80211_beacon_set_cntdwn()
5068 beacon->cntdwn_current_counter = counter; in ieee80211_beacon_set_cntdwn()
5087 if (vif->type == NL80211_IFTYPE_AP) { in ieee80211_beacon_cntdwn_is_complete()
5088 beacon = rcu_dereference(sdata->deflink.u.ap.beacon); in ieee80211_beacon_cntdwn_is_complete()
5089 if (WARN_ON(!beacon || !beacon->tail)) in ieee80211_beacon_cntdwn_is_complete()
5091 beacon_data = beacon->tail; in ieee80211_beacon_cntdwn_is_complete()
5092 beacon_data_len = beacon->tail_len; in ieee80211_beacon_cntdwn_is_complete()
5093 } else if (vif->type == NL80211_IFTYPE_ADHOC) { in ieee80211_beacon_cntdwn_is_complete()
5094 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; in ieee80211_beacon_cntdwn_is_complete()
5096 beacon = rcu_dereference(ifibss->presp); in ieee80211_beacon_cntdwn_is_complete()
5100 beacon_data = beacon->head; in ieee80211_beacon_cntdwn_is_complete()
5101 beacon_data_len = beacon->head_len; in ieee80211_beacon_cntdwn_is_complete()
5102 } else if (vif->type == NL80211_IFTYPE_MESH_POINT) { in ieee80211_beacon_cntdwn_is_complete()
5103 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; in ieee80211_beacon_cntdwn_is_complete()
5105 beacon = rcu_dereference(ifmsh->beacon); in ieee80211_beacon_cntdwn_is_complete()
5109 beacon_data = beacon->head; in ieee80211_beacon_cntdwn_is_complete()
5110 beacon_data_len = beacon->head_len; in ieee80211_beacon_cntdwn_is_complete()
5116 if (!beacon->cntdwn_counter_offsets[0]) in ieee80211_beacon_cntdwn_is_complete()
5119 if (WARN_ON_ONCE(beacon->cntdwn_counter_offsets[0] > beacon_data_len)) in ieee80211_beacon_cntdwn_is_complete()
5122 if (beacon_data[beacon->cntdwn_counter_offsets[0]] == 1) in ieee80211_beacon_cntdwn_is_complete()
5135 struct ieee80211_link_data *link) in ieee80211_beacon_protect() argument
5142 tx.key = rcu_dereference(link->default_beacon_key); in ieee80211_beacon_protect()
5146 if (unlikely(tx.key->flags & KEY_FLAG_TAINTED)) { in ieee80211_beacon_protect()
5148 return -EINVAL; in ieee80211_beacon_protect()
5151 if (!(tx.key->conf.flags & IEEE80211_KEY_FLAG_SW_MGMT_TX) && in ieee80211_beacon_protect()
5152 tx.key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) in ieee80211_beacon_protect()
5153 IEEE80211_SKB_CB(skb)->control.hw_key = &tx.key->conf; in ieee80211_beacon_protect()
5164 return -EINVAL; in ieee80211_beacon_protect()
5172 struct ieee80211_link_data *link, in ieee80211_beacon_get_finish() argument
5190 u16 csa_off = beacon->cntdwn_counter_offsets[i]; in ieee80211_beacon_get_finish()
5195 offs->cntdwn_counter_offs[i] = csa_off_base + csa_off; in ieee80211_beacon_get_finish()
5199 band = chanctx_conf->def.chan->band; in ieee80211_beacon_get_finish()
5201 info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; in ieee80211_beacon_get_finish()
5202 info->flags |= IEEE80211_TX_CTL_NO_ACK; in ieee80211_beacon_get_finish()
5203 info->band = band; in ieee80211_beacon_get_finish()
5207 txrc.sband = local->hw.wiphy->bands[band]; in ieee80211_beacon_get_finish()
5208 txrc.bss_conf = link->conf; in ieee80211_beacon_get_finish()
5210 txrc.reported_rate.idx = -1; in ieee80211_beacon_get_finish()
5211 if (sdata->beacon_rate_set && sdata->beacon_rateidx_mask[band]) in ieee80211_beacon_get_finish()
5212 txrc.rate_idx_mask = sdata->beacon_rateidx_mask[band]; in ieee80211_beacon_get_finish()
5214 txrc.rate_idx_mask = sdata->rc_rateidx_mask[band]; in ieee80211_beacon_get_finish()
5218 info->control.vif = vif; in ieee80211_beacon_get_finish()
5219 info->control.flags |= u32_encode_bits(link->link_id, in ieee80211_beacon_get_finish()
5221 info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT | in ieee80211_beacon_get_finish()
5230 if (!beacon->mbssid_ies || !beacon->mbssid_ies->cnt || in ieee80211_beacon_add_mbssid()
5231 i > beacon->mbssid_ies->cnt) in ieee80211_beacon_add_mbssid()
5234 if (i < beacon->mbssid_ies->cnt) { in ieee80211_beacon_add_mbssid()
5235 skb_put_data(skb, beacon->mbssid_ies->elem[i].data, in ieee80211_beacon_add_mbssid()
5236 beacon->mbssid_ies->elem[i].len); in ieee80211_beacon_add_mbssid()
5238 if (beacon->rnr_ies && beacon->rnr_ies->cnt) { in ieee80211_beacon_add_mbssid()
5239 skb_put_data(skb, beacon->rnr_ies->elem[i].data, in ieee80211_beacon_add_mbssid()
5240 beacon->rnr_ies->elem[i].len); in ieee80211_beacon_add_mbssid()
5242 for (i = beacon->mbssid_ies->cnt; i < beacon->rnr_ies->cnt; i++) in ieee80211_beacon_add_mbssid()
5243 skb_put_data(skb, beacon->rnr_ies->elem[i].data, in ieee80211_beacon_add_mbssid()
5244 beacon->rnr_ies->elem[i].len); in ieee80211_beacon_add_mbssid()
5249 /* i == beacon->mbssid_ies->cnt, include all MBSSID elements */ in ieee80211_beacon_add_mbssid()
5250 for (i = 0; i < beacon->mbssid_ies->cnt; i++) in ieee80211_beacon_add_mbssid()
5251 skb_put_data(skb, beacon->mbssid_ies->elem[i].data, in ieee80211_beacon_add_mbssid()
5252 beacon->mbssid_ies->elem[i].len); in ieee80211_beacon_add_mbssid()
5258 struct ieee80211_link_data *link, in ieee80211_beacon_get_ap() argument
5267 struct ieee80211_if_ap *ap = &sdata->u.ap; in ieee80211_beacon_get_ap()
5272 if (beacon->cntdwn_counter_offsets[0]) { in ieee80211_beacon_get_ap()
5276 ieee80211_set_beacon_cntdwn(sdata, beacon, link); in ieee80211_beacon_get_ap()
5282 mbssid_len = ieee80211_get_mbssid_beacon_len(beacon->mbssid_ies, in ieee80211_beacon_get_ap()
5283 beacon->rnr_ies, in ieee80211_beacon_get_ap()
5286 skb = dev_alloc_skb(local->tx_headroom + beacon->head_len + in ieee80211_beacon_get_ap()
5287 beacon->tail_len + 256 + in ieee80211_beacon_get_ap()
5288 local->hw.extra_beacon_tailroom + mbssid_len); in ieee80211_beacon_get_ap()
5292 skb_reserve(skb, local->tx_headroom); in ieee80211_beacon_get_ap()
5293 skb_put_data(skb, beacon->head, beacon->head_len); in ieee80211_beacon_get_ap()
5295 ieee80211_beacon_add_tim(sdata, link, &ap->ps, skb, is_template); in ieee80211_beacon_get_ap()
5298 offs->tim_offset = beacon->head_len; in ieee80211_beacon_get_ap()
5299 offs->tim_length = skb->len - beacon->head_len; in ieee80211_beacon_get_ap()
5300 offs->cntdwn_counter_offs[0] = beacon->cntdwn_counter_offsets[0]; in ieee80211_beacon_get_ap()
5304 offs->mbssid_off = skb->len - mbssid_len; in ieee80211_beacon_get_ap()
5308 csa_off_base = skb->len; in ieee80211_beacon_get_ap()
5311 if (beacon->tail) in ieee80211_beacon_get_ap()
5312 skb_put_data(skb, beacon->tail, beacon->tail_len); in ieee80211_beacon_get_ap()
5314 if (ieee80211_beacon_protect(skb, local, sdata, link) < 0) { in ieee80211_beacon_get_ap()
5319 ieee80211_beacon_get_finish(hw, vif, link, offs, beacon, skb, in ieee80211_beacon_get_ap()
5327 struct ieee80211_link_data *link, in ieee80211_beacon_get_ap_ema_list() argument
5334 if (!beacon->mbssid_ies || !beacon->mbssid_ies->cnt) in ieee80211_beacon_get_ap_ema_list()
5337 ema = kzalloc(struct_size(ema, bcn, beacon->mbssid_ies->cnt), in ieee80211_beacon_get_ap_ema_list()
5342 for (ema->cnt = 0; ema->cnt < beacon->mbssid_ies->cnt; ema->cnt++) { in ieee80211_beacon_get_ap_ema_list()
5343 ema->bcn[ema->cnt].skb = in ieee80211_beacon_get_ap_ema_list()
5344 ieee80211_beacon_get_ap(hw, vif, link, in ieee80211_beacon_get_ap_ema_list()
5345 &ema->bcn[ema->cnt].offs, in ieee80211_beacon_get_ap_ema_list()
5347 chanctx_conf, ema->cnt); in ieee80211_beacon_get_ap_ema_list()
5348 if (!ema->bcn[ema->cnt].skb) in ieee80211_beacon_get_ap_ema_list()
5352 if (ema->cnt == beacon->mbssid_ies->cnt) in ieee80211_beacon_get_ap_ema_list()
5359 #define IEEE80211_INCLUDE_ALL_MBSSID_ELEMS -1
5375 struct ieee80211_link_data *link; in __ieee80211_beacon_get() local
5380 link = rcu_dereference(sdata->link[link_id]); in __ieee80211_beacon_get()
5381 if (!link) in __ieee80211_beacon_get()
5384 rcu_dereference(link->conf->chanctx_conf); in __ieee80211_beacon_get()
5392 if (sdata->vif.type == NL80211_IFTYPE_AP) { in __ieee80211_beacon_get()
5393 beacon = rcu_dereference(link->u.ap.beacon); in __ieee80211_beacon_get()
5399 ieee80211_beacon_get_ap_ema_list(hw, vif, link, in __ieee80211_beacon_get()
5405 if (beacon->mbssid_ies && beacon->mbssid_ies->cnt) { in __ieee80211_beacon_get()
5406 if (ema_index >= beacon->mbssid_ies->cnt) in __ieee80211_beacon_get()
5410 ema_index = beacon->mbssid_ies->cnt; in __ieee80211_beacon_get()
5415 skb = ieee80211_beacon_get_ap(hw, vif, link, offs, in __ieee80211_beacon_get()
5420 } else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) { in __ieee80211_beacon_get()
5421 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; in __ieee80211_beacon_get()
5424 beacon = rcu_dereference(ifibss->presp); in __ieee80211_beacon_get()
5428 if (beacon->cntdwn_counter_offsets[0]) { in __ieee80211_beacon_get()
5432 ieee80211_set_beacon_cntdwn(sdata, beacon, link); in __ieee80211_beacon_get()
5435 skb = dev_alloc_skb(local->tx_headroom + beacon->head_len + in __ieee80211_beacon_get()
5436 local->hw.extra_beacon_tailroom); in __ieee80211_beacon_get()
5439 skb_reserve(skb, local->tx_headroom); in __ieee80211_beacon_get()
5440 skb_put_data(skb, beacon->head, beacon->head_len); in __ieee80211_beacon_get()
5442 hdr = (struct ieee80211_hdr *) skb->data; in __ieee80211_beacon_get()
5443 hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | in __ieee80211_beacon_get()
5446 ieee80211_beacon_get_finish(hw, vif, link, offs, beacon, skb, in __ieee80211_beacon_get()
5448 } else if (ieee80211_vif_is_mesh(&sdata->vif)) { in __ieee80211_beacon_get()
5449 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; in __ieee80211_beacon_get()
5451 beacon = rcu_dereference(ifmsh->beacon); in __ieee80211_beacon_get()
5455 if (beacon->cntdwn_counter_offsets[0]) { in __ieee80211_beacon_get()
5464 ieee80211_set_beacon_cntdwn(sdata, beacon, link); in __ieee80211_beacon_get()
5467 if (ifmsh->sync_ops) in __ieee80211_beacon_get()
5468 ifmsh->sync_ops->adjust_tsf(sdata, beacon); in __ieee80211_beacon_get()
5470 skb = dev_alloc_skb(local->tx_headroom + in __ieee80211_beacon_get()
5471 beacon->head_len + in __ieee80211_beacon_get()
5473 beacon->tail_len + in __ieee80211_beacon_get()
5474 local->hw.extra_beacon_tailroom); in __ieee80211_beacon_get()
5477 skb_reserve(skb, local->tx_headroom); in __ieee80211_beacon_get()
5478 skb_put_data(skb, beacon->head, beacon->head_len); in __ieee80211_beacon_get()
5479 ieee80211_beacon_add_tim(sdata, link, &ifmsh->ps, skb, in __ieee80211_beacon_get()
5483 offs->tim_offset = beacon->head_len; in __ieee80211_beacon_get()
5484 offs->tim_length = skb->len - beacon->head_len; in __ieee80211_beacon_get()
5487 skb_put_data(skb, beacon->tail, beacon->tail_len); in __ieee80211_beacon_get()
5488 ieee80211_beacon_get_finish(hw, vif, link, offs, beacon, skb, in __ieee80211_beacon_get()
5530 for (i = 0; i < ema_beacons->cnt; i++) in ieee80211_beacon_free_ema_list()
5531 kfree_skb(ema_beacons->bcn[i].skb); in ieee80211_beacon_free_ema_list()
5574 !hw_to_local(hw)->monitors) in ieee80211_beacon_get_tim()
5597 if (sdata->vif.type != NL80211_IFTYPE_AP) in ieee80211_proberesp_get()
5601 presp = rcu_dereference(sdata->deflink.u.ap.probe_resp); in ieee80211_proberesp_get()
5605 skb = dev_alloc_skb(presp->len); in ieee80211_proberesp_get()
5609 skb_put_data(skb, presp->data, presp->len); in ieee80211_proberesp_get()
5611 hdr = (struct ieee80211_hdr *) skb->data; in ieee80211_proberesp_get()
5612 memset(hdr->addr1, 0, sizeof(hdr->addr1)); in ieee80211_proberesp_get()
5627 if (sdata->vif.type != NL80211_IFTYPE_AP) in ieee80211_get_fils_discovery_tmpl()
5631 tmpl = rcu_dereference(sdata->deflink.u.ap.fils_discovery); in ieee80211_get_fils_discovery_tmpl()
5637 skb = dev_alloc_skb(sdata->local->hw.extra_tx_headroom + tmpl->len); in ieee80211_get_fils_discovery_tmpl()
5639 skb_reserve(skb, sdata->local->hw.extra_tx_headroom); in ieee80211_get_fils_discovery_tmpl()
5640 skb_put_data(skb, tmpl->data, tmpl->len); in ieee80211_get_fils_discovery_tmpl()
5656 if (sdata->vif.type != NL80211_IFTYPE_AP) in ieee80211_get_unsol_bcast_probe_resp_tmpl()
5660 tmpl = rcu_dereference(sdata->deflink.u.ap.unsol_bcast_probe_resp); in ieee80211_get_unsol_bcast_probe_resp_tmpl()
5666 skb = dev_alloc_skb(sdata->local->hw.extra_tx_headroom + tmpl->len); in ieee80211_get_unsol_bcast_probe_resp_tmpl()
5668 skb_reserve(skb, sdata->local->hw.extra_tx_headroom); in ieee80211_get_unsol_bcast_probe_resp_tmpl()
5669 skb_put_data(skb, tmpl->data, tmpl->len); in ieee80211_get_unsol_bcast_probe_resp_tmpl()
5685 if (WARN_ON(vif->type != NL80211_IFTYPE_STATION)) in ieee80211_pspoll_get()
5689 local = sdata->local; in ieee80211_pspoll_get()
5691 skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*pspoll)); in ieee80211_pspoll_get()
5695 skb_reserve(skb, local->hw.extra_tx_headroom); in ieee80211_pspoll_get()
5698 pspoll->frame_control = cpu_to_le16(IEEE80211_FTYPE_CTL | in ieee80211_pspoll_get()
5700 pspoll->aid = cpu_to_le16(sdata->vif.cfg.aid); in ieee80211_pspoll_get()
5702 /* aid in PS-Poll has its two MSBs each set to 1 */ in ieee80211_pspoll_get()
5703 pspoll->aid |= cpu_to_le16(1 << 15 | 1 << 14); in ieee80211_pspoll_get()
5705 memcpy(pspoll->bssid, sdata->deflink.u.mgd.bssid, ETH_ALEN); in ieee80211_pspoll_get()
5706 memcpy(pspoll->ta, vif->addr, ETH_ALEN); in ieee80211_pspoll_get()
5717 struct ieee80211_local *local = sdata->local; in ieee80211_nullfunc_get()
5718 struct ieee80211_link_data *link = NULL; in ieee80211_nullfunc_get() local
5723 if (WARN_ON(vif->type != NL80211_IFTYPE_STATION)) in ieee80211_nullfunc_get()
5726 skb = dev_alloc_skb(local->hw.extra_tx_headroom + in ieee80211_nullfunc_get()
5735 sta = sta_info_get(sdata, vif->cfg.ap_addr); in ieee80211_nullfunc_get()
5736 qos = sta && sta->sta.wme; in ieee80211_nullfunc_get()
5740 link = rcu_dereference(sdata->link[link_id]); in ieee80211_nullfunc_get()
5741 if (WARN_ON_ONCE(!link)) { in ieee80211_nullfunc_get()
5748 skb_reserve(skb, local->hw.extra_tx_headroom); in ieee80211_nullfunc_get()
5751 nullfunc->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA | in ieee80211_nullfunc_get()
5760 nullfunc->frame_control |= in ieee80211_nullfunc_get()
5762 skb->priority = 7; in ieee80211_nullfunc_get()
5767 if (link) { in ieee80211_nullfunc_get()
5768 memcpy(nullfunc->addr1, link->conf->bssid, ETH_ALEN); in ieee80211_nullfunc_get()
5769 memcpy(nullfunc->addr2, link->conf->addr, ETH_ALEN); in ieee80211_nullfunc_get()
5770 memcpy(nullfunc->addr3, link->conf->bssid, ETH_ALEN); in ieee80211_nullfunc_get()
5772 memcpy(nullfunc->addr1, vif->cfg.ap_addr, ETH_ALEN); in ieee80211_nullfunc_get()
5773 memcpy(nullfunc->addr2, vif->addr, ETH_ALEN); in ieee80211_nullfunc_get()
5774 memcpy(nullfunc->addr3, vif->cfg.ap_addr, ETH_ALEN); in ieee80211_nullfunc_get()
5795 skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*hdr) + in ieee80211_probereq_get()
5800 skb_reserve(skb, local->hw.extra_tx_headroom); in ieee80211_probereq_get()
5803 hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | in ieee80211_probereq_get()
5805 eth_broadcast_addr(hdr->addr1); in ieee80211_probereq_get()
5806 memcpy(hdr->addr2, src_addr, ETH_ALEN); in ieee80211_probereq_get()
5807 eth_broadcast_addr(hdr->addr3); in ieee80211_probereq_get()
5827 rts->frame_control = in ieee80211_rts_get()
5829 rts->duration = ieee80211_rts_duration(hw, vif, frame_len, in ieee80211_rts_get()
5831 memcpy(rts->ra, hdr->addr1, sizeof(rts->ra)); in ieee80211_rts_get()
5832 memcpy(rts->ta, hdr->addr2, sizeof(rts->ta)); in ieee80211_rts_get()
5843 cts->frame_control = in ieee80211_ctstoself_get()
5845 cts->duration = ieee80211_ctstoself_duration(hw, vif, in ieee80211_ctstoself_get()
5847 memcpy(cts->ra, hdr->addr1, sizeof(cts->ra)); in ieee80211_ctstoself_get()
5866 chanctx_conf = rcu_dereference(sdata->vif.bss_conf.chanctx_conf); in ieee80211_get_buffered_bc()
5871 if (sdata->vif.type == NL80211_IFTYPE_AP) { in ieee80211_get_buffered_bc()
5873 rcu_dereference(sdata->deflink.u.ap.beacon); in ieee80211_get_buffered_bc()
5875 if (!beacon || !beacon->head) in ieee80211_get_buffered_bc()
5878 ps = &sdata->u.ap.ps; in ieee80211_get_buffered_bc()
5879 } else if (ieee80211_vif_is_mesh(&sdata->vif)) { in ieee80211_get_buffered_bc()
5880 ps = &sdata->u.mesh.ps; in ieee80211_get_buffered_bc()
5885 if (ps->dtim_count != 0 || !ps->dtim_bc_mc) in ieee80211_get_buffered_bc()
5889 skb = skb_dequeue(&ps->bc_buf); in ieee80211_get_buffered_bc()
5892 local->total_ps_buffered--; in ieee80211_get_buffered_bc()
5894 if (!skb_queue_empty(&ps->bc_buf) && skb->len >= 2) { in ieee80211_get_buffered_bc()
5896 (struct ieee80211_hdr *) skb->data; in ieee80211_get_buffered_bc()
5900 hdr->frame_control |= in ieee80211_get_buffered_bc()
5904 if (sdata->vif.type == NL80211_IFTYPE_AP) in ieee80211_get_buffered_bc()
5905 sdata = IEEE80211_DEV_TO_SUB_IF(skb->dev); in ieee80211_get_buffered_bc()
5914 info->band = chanctx_conf->def.chan->band; in ieee80211_get_buffered_bc()
5928 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_reserve_tid()
5929 struct ieee80211_local *local = sdata->local; in ieee80211_reserve_tid()
5933 lockdep_assert_held(&local->sta_mtx); in ieee80211_reserve_tid()
5936 switch (sdata->vif.type) { in ieee80211_reserve_tid()
5943 return -EINVAL; in ieee80211_reserve_tid()
5947 return -EINVAL; in ieee80211_reserve_tid()
5949 if (sta->reserved_tid == tid) { in ieee80211_reserve_tid()
5954 if (sta->reserved_tid != IEEE80211_TID_UNRESERVED) { in ieee80211_reserve_tid()
5956 ret = -EALREADY; in ieee80211_reserve_tid()
5960 ieee80211_stop_vif_queues(sdata->local, sdata, in ieee80211_reserve_tid()
5966 if (ieee80211_hw_check(&local->hw, AMPDU_AGGREGATION)) { in ieee80211_reserve_tid()
5972 queues = BIT(sdata->vif.hw_queue[ieee802_1d_to_ac[tid]]); in ieee80211_reserve_tid()
5975 sta->reserved_tid = tid; in ieee80211_reserve_tid()
5980 if (ieee80211_hw_check(&local->hw, AMPDU_AGGREGATION)) in ieee80211_reserve_tid()
5992 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_unreserve_tid()
5994 lockdep_assert_held(&sdata->local->sta_mtx); in ieee80211_unreserve_tid()
5997 switch (sdata->vif.type) { in ieee80211_unreserve_tid()
6007 if (tid != sta->reserved_tid) { in ieee80211_unreserve_tid()
6012 sta->reserved_tid = IEEE80211_TID_UNRESERVED; in ieee80211_unreserve_tid()
6020 const struct ieee80211_hdr *hdr = (void *)skb->data; in __ieee80211_tx_skb_tid_band()
6021 int ac = ieee80211_ac_from_tid(tid); in __ieee80211_tx_skb_tid_band() local
6022 unsigned int link; in __ieee80211_tx_skb_tid_band() local
6025 skb_set_queue_mapping(skb, ac); in __ieee80211_tx_skb_tid_band()
6026 skb->priority = tid; in __ieee80211_tx_skb_tid_band()
6028 skb->dev = sdata->dev; in __ieee80211_tx_skb_tid_band()
6034 if (!ieee80211_vif_is_mld(&sdata->vif)) { in __ieee80211_tx_skb_tid_band()
6035 link = 0; in __ieee80211_tx_skb_tid_band()
6037 link = link_id; in __ieee80211_tx_skb_tid_band()
6038 } else if (memcmp(sdata->vif.addr, hdr->addr2, ETH_ALEN) == 0) { in __ieee80211_tx_skb_tid_band()
6040 link = IEEE80211_LINK_UNSPECIFIED; in __ieee80211_tx_skb_tid_band()
6042 /* otherwise must be addressed from a link */ in __ieee80211_tx_skb_tid_band()
6044 for (link = 0; link < ARRAY_SIZE(sdata->vif.link_conf); link++) { in __ieee80211_tx_skb_tid_band()
6047 link_conf = rcu_dereference(sdata->vif.link_conf[link]); in __ieee80211_tx_skb_tid_band()
6050 if (memcmp(link_conf->addr, hdr->addr2, ETH_ALEN) == 0) in __ieee80211_tx_skb_tid_band()
6055 if (WARN_ON_ONCE(link == ARRAY_SIZE(sdata->vif.link_conf))) in __ieee80211_tx_skb_tid_band()
6056 link = ffs(sdata->vif.active_links) - 1; in __ieee80211_tx_skb_tid_band()
6059 IEEE80211_SKB_CB(skb)->control.flags |= in __ieee80211_tx_skb_tid_band()
6060 u32_encode_bits(link, IEEE80211_TX_CTRL_MLO_LINK); in __ieee80211_tx_skb_tid_band()
6068 IEEE80211_SKB_CB(skb)->band = band; in __ieee80211_tx_skb_tid_band()
6080 if (!ieee80211_vif_is_mld(&sdata->vif)) { in ieee80211_tx_skb_tid()
6083 rcu_dereference(sdata->vif.bss_conf.chanctx_conf); in ieee80211_tx_skb_tid()
6089 band = chanctx_conf->def.chan->band; in ieee80211_tx_skb_tid()
6092 !(sdata->vif.active_links & BIT(link_id))); in ieee80211_tx_skb_tid()
6107 struct ieee80211_local *local = sdata->local; in ieee80211_tx_control_port()
6116 * or Pre-Authentication in ieee80211_tx_control_port()
6118 if (proto != sdata->control_port_protocol && in ieee80211_tx_control_port()
6120 return -EINVAL; in ieee80211_tx_control_port()
6122 if (proto == sdata->control_port_protocol) in ieee80211_tx_control_port()
6134 skb = dev_alloc_skb(local->hw.extra_tx_headroom + in ieee80211_tx_control_port()
6137 return -ENOMEM; in ieee80211_tx_control_port()
6139 skb_reserve(skb, local->hw.extra_tx_headroom + sizeof(struct ethhdr)); in ieee80211_tx_control_port()
6144 memcpy(ehdr->h_dest, dest, ETH_ALEN); in ieee80211_tx_control_port()
6150 memcpy(ehdr->h_source, sdata->vif.addr, ETH_ALEN); in ieee80211_tx_control_port()
6158 link_conf = rcu_dereference(sdata->vif.link_conf[link_id]); in ieee80211_tx_control_port()
6162 return -ENOLINK; in ieee80211_tx_control_port()
6164 memcpy(ehdr->h_source, link_conf->addr, ETH_ALEN); in ieee80211_tx_control_port()
6168 ehdr->h_proto = proto; in ieee80211_tx_control_port()
6170 skb->dev = dev; in ieee80211_tx_control_port()
6171 skb->protocol = proto; in ieee80211_tx_control_port()
6175 if (local->hw.queues < IEEE80211_NUM_ACS) in ieee80211_tx_control_port()
6197 * the link ID has been selected already in ieee80211_tx_control_port()
6199 if (sta && sta->sta.mlo) in ieee80211_tx_control_port()
6200 memcpy(ehdr->h_source, sdata->vif.addr, ETH_ALEN); in ieee80211_tx_control_port()
6206 mutex_lock(&local->mtx); in ieee80211_tx_control_port()
6209 __ieee80211_subif_start_xmit(skb, skb->dev, flags, ctrl_flags, cookie); in ieee80211_tx_control_port()
6212 mutex_unlock(&local->mtx); in ieee80211_tx_control_port()
6221 struct ieee80211_local *local = sdata->local; in ieee80211_probe_mesh_link()
6224 skb = dev_alloc_skb(local->hw.extra_tx_headroom + len + in ieee80211_probe_mesh_link()
6228 return -ENOMEM; in ieee80211_probe_mesh_link()
6230 skb_reserve(skb, local->hw.extra_tx_headroom); in ieee80211_probe_mesh_link()
6233 skb->dev = dev; in ieee80211_probe_mesh_link()
6234 skb->protocol = htons(ETH_P_802_3); in ieee80211_probe_mesh_link()
6239 __ieee80211_subif_start_xmit(skb, skb->dev, 0, in ieee80211_probe_mesh_link()