• Home
  • Raw
  • Download

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()
708 txrc.rate_idx_mask = tx->sdata->rc_rateidx_mask[info->band]; in ieee80211_tx_h_rate_ctrl()
710 if (tx->sdata->rc_has_mcs_mask[info->band]) in ieee80211_tx_h_rate_ctrl()
712 tx->sdata->rc_rateidx_mcs_mask[info->band]; in ieee80211_tx_h_rate_ctrl()
714 txrc.bss = (tx->sdata->vif.type == NL80211_IFTYPE_AP || in ieee80211_tx_h_rate_ctrl()
715 tx->sdata->vif.type == NL80211_IFTYPE_MESH_POINT || in ieee80211_tx_h_rate_ctrl()
716 tx->sdata->vif.type == NL80211_IFTYPE_ADHOC || in ieee80211_tx_h_rate_ctrl()
717 tx->sdata->vif.type == NL80211_IFTYPE_OCB); in ieee80211_tx_h_rate_ctrl()
720 if (len > tx->local->hw.wiphy->rts_threshold) { in ieee80211_tx_h_rate_ctrl()
724 info->control.use_rts = txrc.rts; in ieee80211_tx_h_rate_ctrl()
725 info->control.use_cts_prot = tx->sdata->vif.bss_conf.use_cts_prot; in ieee80211_tx_h_rate_ctrl()
730 * that -- the management frame might be to a station that in ieee80211_tx_h_rate_ctrl()
733 if (tx->sdata->vif.bss_conf.use_short_preamble && in ieee80211_tx_h_rate_ctrl()
734 (ieee80211_is_tx_data(tx->skb) || in ieee80211_tx_h_rate_ctrl()
735 (tx->sta && test_sta_flag(tx->sta, WLAN_STA_SHORT_PREAMBLE)))) in ieee80211_tx_h_rate_ctrl()
738 info->control.short_preamble = txrc.short_preamble; in ieee80211_tx_h_rate_ctrl()
741 if (info->control.flags & IEEE80211_TX_CTRL_RATE_INJECT) in ieee80211_tx_h_rate_ctrl()
744 if (tx->sta) in ieee80211_tx_h_rate_ctrl()
745 assoc = test_sta_flag(tx->sta, WLAN_STA_ASSOC); in ieee80211_tx_h_rate_ctrl()
751 if (WARN(test_bit(SCAN_SW_SCANNING, &tx->local->scanning) && assoc && in ieee80211_tx_h_rate_ctrl()
752 !rate_usable_index_exists(sband, &tx->sta->sta), in ieee80211_tx_h_rate_ctrl()
756 tx->sdata->name, in ieee80211_tx_h_rate_ctrl()
757 encap ? ((struct ethhdr *)hdr)->h_dest : hdr->addr1, in ieee80211_tx_h_rate_ctrl()
758 info->band ? 5 : 2)) in ieee80211_tx_h_rate_ctrl()
765 rate_control_get_rate(tx->sdata, tx->sta, &txrc); in ieee80211_tx_h_rate_ctrl()
767 if (tx->sta && !info->control.skip_table) in ieee80211_tx_h_rate_ctrl()
768 ratetbl = rcu_dereference(tx->sta->sta.rates); in ieee80211_tx_h_rate_ctrl()
770 if (unlikely(info->control.rates[0].idx < 0)) { in ieee80211_tx_h_rate_ctrl()
773 .idx = ratetbl->rate[0].idx, in ieee80211_tx_h_rate_ctrl()
774 .flags = ratetbl->rate[0].flags, in ieee80211_tx_h_rate_ctrl()
775 .count = ratetbl->rate[0].count in ieee80211_tx_h_rate_ctrl()
778 if (ratetbl->rate[0].idx < 0) in ieee80211_tx_h_rate_ctrl()
781 tx->rate = rate; in ieee80211_tx_h_rate_ctrl()
786 tx->rate = info->control.rates[0]; in ieee80211_tx_h_rate_ctrl()
790 txrc.reported_rate = tx->rate; in ieee80211_tx_h_rate_ctrl()
791 if (tx->sta && ieee80211_is_tx_data(tx->skb)) in ieee80211_tx_h_rate_ctrl()
792 tx->sta->deflink.tx_stats.last_rate = txrc.reported_rate; in ieee80211_tx_h_rate_ctrl()
793 } else if (tx->sta) in ieee80211_tx_h_rate_ctrl()
794 tx->sta->deflink.tx_stats.last_rate = txrc.reported_rate; in ieee80211_tx_h_rate_ctrl()
799 if (unlikely(!info->control.rates[0].count)) in ieee80211_tx_h_rate_ctrl()
800 info->control.rates[0].count = 1; in ieee80211_tx_h_rate_ctrl()
802 if (WARN_ON_ONCE((info->control.rates[0].count > 1) && in ieee80211_tx_h_rate_ctrl()
803 (info->flags & IEEE80211_TX_CTL_NO_ACK))) in ieee80211_tx_h_rate_ctrl()
804 info->control.rates[0].count = 1; in ieee80211_tx_h_rate_ctrl()
811 u16 *seq = &sta->tid_seq[tid]; in ieee80211_tx_next_seq()
823 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); in ieee80211_tx_h_sequence()
824 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; in ieee80211_tx_h_sequence()
832 if (unlikely(info->control.vif->type == NL80211_IFTYPE_MONITOR)) in ieee80211_tx_h_sequence()
835 if (unlikely(ieee80211_is_ctl(hdr->frame_control))) in ieee80211_tx_h_sequence()
838 if (ieee80211_hdrlen(hdr->frame_control) < 24) in ieee80211_tx_h_sequence()
841 if (ieee80211_is_qos_nullfunc(hdr->frame_control)) in ieee80211_tx_h_sequence()
844 if (info->control.flags & IEEE80211_TX_CTRL_NO_SEQNO) in ieee80211_tx_h_sequence()
848 if (unlikely(is_multicast_ether_addr(hdr->addr1) && in ieee80211_tx_h_sequence()
849 ieee80211_vif_is_mld(info->control.vif) && in ieee80211_tx_h_sequence()
850 info->control.vif->type == NL80211_IFTYPE_AP)) { in ieee80211_tx_h_sequence()
851 if (info->control.flags & IEEE80211_TX_CTRL_MCAST_MLO_FIRST_TX) in ieee80211_tx_h_sequence()
852 tx->sdata->mld_mcast_seq += 0x10; in ieee80211_tx_h_sequence()
853 hdr->seq_ctrl = cpu_to_le16(tx->sdata->mld_mcast_seq); in ieee80211_tx_h_sequence()
861 * also use the global counter (802.11-2012 9.3.2.10). in ieee80211_tx_h_sequence()
863 if (!ieee80211_is_data_qos(hdr->frame_control) || in ieee80211_tx_h_sequence()
864 is_multicast_ether_addr(hdr->addr1)) { in ieee80211_tx_h_sequence()
866 info->flags |= IEEE80211_TX_CTL_ASSIGN_SEQ; in ieee80211_tx_h_sequence()
868 hdr->seq_ctrl = cpu_to_le16(tx->sdata->sequence_number); in ieee80211_tx_h_sequence()
869 tx->sdata->sequence_number += 0x10; in ieee80211_tx_h_sequence()
870 if (tx->sta) in ieee80211_tx_h_sequence()
871 tx->sta->deflink.tx_stats.msdu[IEEE80211_NUM_TIDS]++; in ieee80211_tx_h_sequence()
878 * above since they are not QoS-data frames. in ieee80211_tx_h_sequence()
880 if (!tx->sta) in ieee80211_tx_h_sequence()
883 /* include per-STA, per-TID sequence counter */ in ieee80211_tx_h_sequence()
885 tx->sta->deflink.tx_stats.msdu[tid]++; in ieee80211_tx_h_sequence()
887 hdr->seq_ctrl = ieee80211_tx_next_seq(tx->sta, tid); in ieee80211_tx_h_sequence()
896 struct ieee80211_local *local = tx->local; in ieee80211_fragment()
899 int per_fragm = frag_threshold - hdrlen - FCS_LEN; in ieee80211_fragment()
901 int rem = skb->len - hdrlen - per_fragm; in ieee80211_fragment()
904 return -EINVAL; in ieee80211_fragment()
913 rem -= fraglen; in ieee80211_fragment()
914 tmp = dev_alloc_skb(local->tx_headroom + in ieee80211_fragment()
919 return -ENOMEM; in ieee80211_fragment()
921 __skb_queue_tail(&tx->skbs, tmp); in ieee80211_fragment()
924 local->tx_headroom + IEEE80211_ENCRYPT_HEADROOM); in ieee80211_fragment()
927 memcpy(tmp->cb, skb->cb, sizeof(tmp->cb)); in ieee80211_fragment()
930 info->flags &= ~(IEEE80211_TX_CTL_CLEAR_PS_FILT | in ieee80211_fragment()
934 info->flags |= IEEE80211_TX_CTL_MORE_FRAMES; in ieee80211_fragment()
937 tmp->priority = skb->priority; in ieee80211_fragment()
938 tmp->dev = skb->dev; in ieee80211_fragment()
941 skb_put_data(tmp, skb->data, hdrlen); in ieee80211_fragment()
942 skb_put_data(tmp, skb->data + pos, fraglen); in ieee80211_fragment()
955 struct sk_buff *skb = tx->skb; in ieee80211_tx_h_fragment()
957 struct ieee80211_hdr *hdr = (void *)skb->data; in ieee80211_tx_h_fragment()
958 int frag_threshold = tx->local->hw.wiphy->frag_threshold; in ieee80211_tx_h_fragment()
962 /* no matter what happens, tx->skb moves to tx->skbs */ in ieee80211_tx_h_fragment()
963 __skb_queue_tail(&tx->skbs, skb); in ieee80211_tx_h_fragment()
964 tx->skb = NULL; in ieee80211_tx_h_fragment()
966 if (info->flags & IEEE80211_TX_CTL_DONTFRAG) in ieee80211_tx_h_fragment()
969 if (ieee80211_hw_check(&tx->local->hw, SUPPORTS_TX_FRAG)) in ieee80211_tx_h_fragment()
973 * Warn when submitting a fragmented A-MPDU frame and drop it. in ieee80211_tx_h_fragment()
977 if (WARN_ON(info->flags & IEEE80211_TX_CTL_AMPDU)) in ieee80211_tx_h_fragment()
980 hdrlen = ieee80211_hdrlen(hdr->frame_control); in ieee80211_tx_h_fragment()
983 if (WARN_ON(skb->len + FCS_LEN <= frag_threshold)) in ieee80211_tx_h_fragment()
988 * chain them (using skb as the first fragment) to skb->next. in ieee80211_tx_h_fragment()
990 * fragments from this list. When the low-level driver rejects one in ieee80211_tx_h_fragment()
1000 skb_queue_walk(&tx->skbs, skb) { in ieee80211_tx_h_fragment()
1003 hdr = (void *)skb->data; in ieee80211_tx_h_fragment()
1006 if (!skb_queue_is_last(&tx->skbs, skb)) { in ieee80211_tx_h_fragment()
1007 hdr->frame_control |= morefrags; in ieee80211_tx_h_fragment()
1009 * No multi-rate retries for fragmented frames, that in ieee80211_tx_h_fragment()
1012 info->control.rates[1].idx = -1; in ieee80211_tx_h_fragment()
1013 info->control.rates[2].idx = -1; in ieee80211_tx_h_fragment()
1014 info->control.rates[3].idx = -1; in ieee80211_tx_h_fragment()
1016 info->flags &= ~IEEE80211_TX_CTL_RATE_CTRL_PROBE; in ieee80211_tx_h_fragment()
1018 hdr->frame_control &= ~morefrags; in ieee80211_tx_h_fragment()
1020 hdr->seq_ctrl |= cpu_to_le16(fragnum & IEEE80211_SCTL_FRAG); in ieee80211_tx_h_fragment()
1031 int ac = -1; in ieee80211_tx_h_stats() local
1033 if (!tx->sta) in ieee80211_tx_h_stats()
1036 skb_queue_walk(&tx->skbs, skb) { in ieee80211_tx_h_stats()
1037 ac = skb_get_queue_mapping(skb); in ieee80211_tx_h_stats()
1038 tx->sta->deflink.tx_stats.bytes[ac] += skb->len; in ieee80211_tx_h_stats()
1040 if (ac >= 0) in ieee80211_tx_h_stats()
1041 tx->sta->deflink.tx_stats.packets[ac]++; in ieee80211_tx_h_stats()
1049 if (!tx->key) in ieee80211_tx_h_encrypt()
1052 switch (tx->key->conf.cipher) { in ieee80211_tx_h_encrypt()
1087 skb_queue_walk(&tx->skbs, skb) { in ieee80211_tx_h_calculate_duration()
1088 hdr = (void *) skb->data; in ieee80211_tx_h_calculate_duration()
1089 if (unlikely(ieee80211_is_pspoll(hdr->frame_control))) in ieee80211_tx_h_calculate_duration()
1091 if (!skb_queue_is_last(&tx->skbs, skb)) { in ieee80211_tx_h_calculate_duration()
1092 struct sk_buff *next = skb_queue_next(&tx->skbs, skb); in ieee80211_tx_h_calculate_duration()
1093 next_len = next->len; in ieee80211_tx_h_calculate_duration()
1096 group_addr = is_multicast_ether_addr(hdr->addr1); in ieee80211_tx_h_calculate_duration()
1098 hdr->duration_id = in ieee80211_tx_h_calculate_duration()
1117 if (test_bit(HT_AGG_STATE_OPERATIONAL, &tid_tx->state)) { in ieee80211_tx_prep_agg()
1119 } else if (test_bit(HT_AGG_STATE_WANT_START, &tid_tx->state)) { in ieee80211_tx_prep_agg()
1121 * nothing -- this aggregation session is being started in ieee80211_tx_prep_agg()
1124 } else if (!tx->sta->sta.txq[tid]) { in ieee80211_tx_prep_agg()
1125 spin_lock(&tx->sta->lock); in ieee80211_tx_prep_agg()
1127 * Need to re-check now, because we may get here in ieee80211_tx_prep_agg()
1132 * queue yet -- if this happened we acquire the lock in ieee80211_tx_prep_agg()
1139 * before it was assigned) -- in this case it may in ieee80211_tx_prep_agg()
1144 tid_tx = rcu_dereference_protected_tid_tx(tx->sta, tid); in ieee80211_tx_prep_agg()
1148 } else if (test_bit(HT_AGG_STATE_OPERATIONAL, &tid_tx->state)) { in ieee80211_tx_prep_agg()
1152 if (info->flags & IEEE80211_TX_CTL_NO_PS_BUFFER) { in ieee80211_tx_prep_agg()
1153 clear_sta_flag(tx->sta, WLAN_STA_SP); in ieee80211_tx_prep_agg()
1154 ps_dbg(tx->sta->sdata, in ieee80211_tx_prep_agg()
1156 tx->sta->sta.addr, tx->sta->sta.aid); in ieee80211_tx_prep_agg()
1158 info->control.vif = &tx->sdata->vif; in ieee80211_tx_prep_agg()
1159 info->control.flags |= IEEE80211_TX_INTCFL_NEED_TXPROCESSING; in ieee80211_tx_prep_agg()
1160 info->flags &= ~IEEE80211_TX_TEMPORARY_FLAGS; in ieee80211_tx_prep_agg()
1161 __skb_queue_tail(&tid_tx->pending, skb); in ieee80211_tx_prep_agg()
1162 if (skb_queue_len(&tid_tx->pending) > STA_MAX_TX_BUFFER) in ieee80211_tx_prep_agg()
1163 purge_skb = __skb_dequeue(&tid_tx->pending); in ieee80211_tx_prep_agg()
1165 spin_unlock(&tx->sta->lock); in ieee80211_tx_prep_agg()
1168 ieee80211_free_txskb(&tx->local->hw, purge_skb); in ieee80211_tx_prep_agg()
1173 tid_tx->last_tx = jiffies; in ieee80211_tx_prep_agg()
1181 struct rate_control_ref *ref = sdata->local->rate_ctrl; in ieee80211_aggr_check()
1184 if (!ref || !(ref->ops->capa & RATE_CTRL_CAPA_AMPDU_TRIGGER)) in ieee80211_aggr_check()
1187 if (!sta || !sta->sta.deflink.ht_cap.ht_supported || in ieee80211_aggr_check()
1188 !sta->sta.wme || skb_get_queue_mapping(skb) == IEEE80211_AC_VO || in ieee80211_aggr_check()
1189 skb->protocol == sdata->control_port_protocol) in ieee80211_aggr_check()
1192 tid = skb->priority & IEEE80211_QOS_CTL_TID_MASK; in ieee80211_aggr_check()
1193 if (likely(sta->ampdu_mlme.tid_tx[tid])) in ieee80211_aggr_check()
1196 ieee80211_start_tx_ba_session(&sta->sta, tid, 0); in ieee80211_aggr_check()
1209 struct ieee80211_local *local = sdata->local; in ieee80211_tx_prepare()
1216 tx->skb = skb; in ieee80211_tx_prepare()
1217 tx->local = local; in ieee80211_tx_prepare()
1218 tx->sdata = sdata; in ieee80211_tx_prepare()
1219 __skb_queue_head_init(&tx->skbs); in ieee80211_tx_prepare()
1226 info->control.flags &= ~IEEE80211_TX_INTCFL_NEED_TXPROCESSING; in ieee80211_tx_prepare()
1228 hdr = (struct ieee80211_hdr *) skb->data; in ieee80211_tx_prepare()
1232 tx->sta = sta; in ieee80211_tx_prepare()
1234 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) { in ieee80211_tx_prepare()
1235 tx->sta = rcu_dereference(sdata->u.vlan.sta); in ieee80211_tx_prepare()
1236 if (!tx->sta && sdata->wdev.use_4addr) in ieee80211_tx_prepare()
1238 } else if (tx->sdata->control_port_protocol == tx->skb->protocol) { in ieee80211_tx_prepare()
1239 tx->sta = sta_info_get_bss(sdata, hdr->addr1); in ieee80211_tx_prepare()
1241 if (!tx->sta && !is_multicast_ether_addr(hdr->addr1)) { in ieee80211_tx_prepare()
1242 tx->sta = sta_info_get(sdata, hdr->addr1); in ieee80211_tx_prepare()
1247 if (tx->sta && ieee80211_is_data_qos(hdr->frame_control) && in ieee80211_tx_prepare()
1248 !ieee80211_is_qos_nullfunc(hdr->frame_control) && in ieee80211_tx_prepare()
1249 ieee80211_hw_check(&local->hw, AMPDU_AGGREGATION) && in ieee80211_tx_prepare()
1250 !ieee80211_hw_check(&local->hw, TX_AMPDU_SETUP_IN_HW)) { in ieee80211_tx_prepare()
1254 tid_tx = rcu_dereference(tx->sta->ampdu_mlme.tid_tx[tid]); in ieee80211_tx_prepare()
1256 ieee80211_aggr_check(sdata, tx->sta, skb); in ieee80211_tx_prepare()
1257 tid_tx = rcu_dereference(tx->sta->ampdu_mlme.tid_tx[tid]); in ieee80211_tx_prepare()
1271 if (is_multicast_ether_addr(hdr->addr1)) { in ieee80211_tx_prepare()
1272 tx->flags &= ~IEEE80211_TX_UNICAST; in ieee80211_tx_prepare()
1273 info->flags |= IEEE80211_TX_CTL_NO_ACK; in ieee80211_tx_prepare()
1275 tx->flags |= IEEE80211_TX_UNICAST; in ieee80211_tx_prepare()
1277 if (!(info->flags & IEEE80211_TX_CTL_DONTFRAG)) { in ieee80211_tx_prepare()
1278 if (!(tx->flags & IEEE80211_TX_UNICAST) || in ieee80211_tx_prepare()
1279 skb->len + FCS_LEN <= local->hw.wiphy->frag_threshold || in ieee80211_tx_prepare()
1280 info->flags & IEEE80211_TX_CTL_AMPDU) in ieee80211_tx_prepare()
1281 info->flags |= IEEE80211_TX_CTL_DONTFRAG; in ieee80211_tx_prepare()
1284 if (!tx->sta) in ieee80211_tx_prepare()
1285 info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT; in ieee80211_tx_prepare()
1286 else if (test_and_clear_sta_flag(tx->sta, WLAN_STA_CLEAR_PS_FILT)) { in ieee80211_tx_prepare()
1287 info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT; in ieee80211_tx_prepare()
1288 ieee80211_check_fast_xmit(tx->sta); in ieee80211_tx_prepare()
1291 info->flags |= IEEE80211_TX_CTL_FIRST_FRAGMENT; in ieee80211_tx_prepare()
1301 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; in ieee80211_get_txq()
1305 if ((info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM) || in ieee80211_get_txq()
1306 (info->control.flags & IEEE80211_TX_CTRL_PS_RESPONSE)) in ieee80211_get_txq()
1309 if (!(info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP) && in ieee80211_get_txq()
1310 unlikely(!ieee80211_is_data_present(hdr->frame_control))) { in ieee80211_get_txq()
1311 if ((!ieee80211_is_mgmt(hdr->frame_control) || in ieee80211_get_txq()
1313 vif->type == NL80211_IFTYPE_STATION) && in ieee80211_get_txq()
1314 sta && sta->uploaded) { in ieee80211_get_txq()
1317 * opt-in hardware flag. in ieee80211_get_txq()
1319 txq = sta->sta.txq[IEEE80211_NUM_TIDS]; in ieee80211_get_txq()
1322 u8 tid = skb->priority & IEEE80211_QOS_CTL_TID_MASK; in ieee80211_get_txq()
1324 if (!sta->uploaded) in ieee80211_get_txq()
1327 txq = sta->sta.txq[tid]; in ieee80211_get_txq()
1329 txq = vif->txq; in ieee80211_get_txq()
1344 IEEE80211_SKB_CB(skb)->control.enqueue_time = now; in ieee80211_set_skb_enqueue_time()
1349 return skb->len; in codel_skb_len_func()
1356 info = (const struct ieee80211_tx_info *)skb->cb; in codel_skb_time_func()
1357 return info->control.enqueue_time; in codel_skb_time_func()
1369 local = vif_to_sdata(txqi->txq.vif)->local; in codel_dequeue_func()
1370 fq = &local->fq; in codel_dequeue_func()
1372 if (cvars == &txqi->def_cvars) in codel_dequeue_func()
1373 flow = &txqi->tin.default_flow; in codel_dequeue_func()
1375 flow = &fq->flows[cvars - local->cvars]; in codel_dequeue_func()
1388 local = vif_to_sdata(txqi->txq.vif)->local; in codel_drop_func()
1389 hw = &local->hw; in codel_drop_func()
1406 cstats = &txqi->cstats; in fq_tin_dequeue_func()
1408 if (txqi->txq.sta) { in fq_tin_dequeue_func()
1409 struct sta_info *sta = container_of(txqi->txq.sta, in fq_tin_dequeue_func()
1411 cparams = &sta->cparams; in fq_tin_dequeue_func()
1413 cparams = &local->cparams; in fq_tin_dequeue_func()
1416 if (flow == &tin->default_flow) in fq_tin_dequeue_func()
1417 cvars = &txqi->def_cvars; in fq_tin_dequeue_func()
1419 cvars = &local->cvars[flow - fq->flows]; in fq_tin_dequeue_func()
1422 &flow->backlog, in fq_tin_dequeue_func()
1440 ieee80211_free_txskb(&local->hw, skb); in fq_skb_free_func()
1447 struct fq *fq = &local->fq; in ieee80211_txq_enqueue()
1448 struct fq_tin *tin = &txqi->tin; in ieee80211_txq_enqueue()
1453 spin_lock_bh(&fq->lock); in ieee80211_txq_enqueue()
1460 if (unlikely(txqi->txq.tid == IEEE80211_NUM_TIDS)) { in ieee80211_txq_enqueue()
1461 IEEE80211_SKB_CB(skb)->control.flags |= in ieee80211_txq_enqueue()
1463 __skb_queue_tail(&txqi->frags, skb); in ieee80211_txq_enqueue()
1468 spin_unlock_bh(&fq->lock); in ieee80211_txq_enqueue()
1477 return info->control.vif == data; in fq_vlan_filter_func()
1483 struct fq *fq = &local->fq; in ieee80211_txq_remove_vlan()
1488 if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_AP_VLAN)) in ieee80211_txq_remove_vlan()
1491 ap = container_of(sdata->bss, struct ieee80211_sub_if_data, u.ap); in ieee80211_txq_remove_vlan()
1493 if (!ap->vif.txq) in ieee80211_txq_remove_vlan()
1496 txqi = to_txq_info(ap->vif.txq); in ieee80211_txq_remove_vlan()
1497 tin = &txqi->tin; in ieee80211_txq_remove_vlan()
1499 spin_lock_bh(&fq->lock); in ieee80211_txq_remove_vlan()
1500 fq_tin_filter(fq, tin, fq_vlan_filter_func, &sdata->vif, in ieee80211_txq_remove_vlan()
1502 spin_unlock_bh(&fq->lock); in ieee80211_txq_remove_vlan()
1509 fq_tin_init(&txqi->tin); in ieee80211_txq_init()
1510 codel_vars_init(&txqi->def_cvars); in ieee80211_txq_init()
1511 codel_stats_init(&txqi->cstats); in ieee80211_txq_init()
1512 __skb_queue_head_init(&txqi->frags); in ieee80211_txq_init()
1513 INIT_LIST_HEAD(&txqi->schedule_order); in ieee80211_txq_init()
1515 txqi->txq.vif = &sdata->vif; in ieee80211_txq_init()
1518 sdata->vif.txq = &txqi->txq; in ieee80211_txq_init()
1519 txqi->txq.tid = 0; in ieee80211_txq_init()
1520 txqi->txq.ac = IEEE80211_AC_BE; in ieee80211_txq_init()
1526 if (sdata->vif.type == NL80211_IFTYPE_STATION) { in ieee80211_txq_init()
1528 if (!ieee80211_hw_check(&sdata->local->hw, in ieee80211_txq_init()
1531 } else if (!ieee80211_hw_check(&sdata->local->hw, in ieee80211_txq_init()
1536 txqi->txq.ac = IEEE80211_AC_VO; in ieee80211_txq_init()
1538 txqi->txq.ac = ieee80211_ac_from_tid(tid); in ieee80211_txq_init()
1541 txqi->txq.sta = &sta->sta; in ieee80211_txq_init()
1542 txqi->txq.tid = tid; in ieee80211_txq_init()
1543 sta->sta.txq[tid] = &txqi->txq; in ieee80211_txq_init()
1549 struct fq *fq = &local->fq; in ieee80211_txq_purge()
1550 struct fq_tin *tin = &txqi->tin; in ieee80211_txq_purge()
1552 spin_lock_bh(&fq->lock); in ieee80211_txq_purge()
1554 ieee80211_purge_tx_queue(&local->hw, &txqi->frags); in ieee80211_txq_purge()
1555 spin_unlock_bh(&fq->lock); in ieee80211_txq_purge()
1557 spin_lock_bh(&local->active_txq_lock[txqi->txq.ac]); in ieee80211_txq_purge()
1558 list_del_init(&txqi->schedule_order); in ieee80211_txq_purge()
1559 spin_unlock_bh(&local->active_txq_lock[txqi->txq.ac]); in ieee80211_txq_purge()
1564 if (local->hw.wiphy->txq_limit) in ieee80211_txq_set_params()
1565 local->fq.limit = local->hw.wiphy->txq_limit; in ieee80211_txq_set_params()
1567 local->hw.wiphy->txq_limit = local->fq.limit; in ieee80211_txq_set_params()
1569 if (local->hw.wiphy->txq_memory_limit) in ieee80211_txq_set_params()
1570 local->fq.memory_limit = local->hw.wiphy->txq_memory_limit; in ieee80211_txq_set_params()
1572 local->hw.wiphy->txq_memory_limit = local->fq.memory_limit; in ieee80211_txq_set_params()
1574 if (local->hw.wiphy->txq_quantum) in ieee80211_txq_set_params()
1575 local->fq.quantum = local->hw.wiphy->txq_quantum; in ieee80211_txq_set_params()
1577 local->hw.wiphy->txq_quantum = local->fq.quantum; in ieee80211_txq_set_params()
1582 struct fq *fq = &local->fq; in ieee80211_txq_setup_flows()
1594 * queue size. 4 Mbytes is 64 max-size aggregates in 802.11n. in ieee80211_txq_setup_flows()
1599 sband = local->hw.wiphy->bands[band]; in ieee80211_txq_setup_flows()
1603 supp_vht = supp_vht || sband->vht_cap.vht_supported; in ieee80211_txq_setup_flows()
1607 fq->memory_limit = 4 << 20; /* 4 Mbytes */ in ieee80211_txq_setup_flows()
1609 codel_params_init(&local->cparams); in ieee80211_txq_setup_flows()
1610 local->cparams.interval = MS2TIME(100); in ieee80211_txq_setup_flows()
1611 local->cparams.target = MS2TIME(20); in ieee80211_txq_setup_flows()
1612 local->cparams.ecn = true; in ieee80211_txq_setup_flows()
1614 local->cvars = kcalloc(fq->flows_cnt, sizeof(local->cvars[0]), in ieee80211_txq_setup_flows()
1616 if (!local->cvars) { in ieee80211_txq_setup_flows()
1617 spin_lock_bh(&fq->lock); in ieee80211_txq_setup_flows()
1619 spin_unlock_bh(&fq->lock); in ieee80211_txq_setup_flows()
1620 return -ENOMEM; in ieee80211_txq_setup_flows()
1623 for (i = 0; i < fq->flows_cnt; i++) in ieee80211_txq_setup_flows()
1624 codel_vars_init(&local->cvars[i]); in ieee80211_txq_setup_flows()
1633 struct fq *fq = &local->fq; in ieee80211_txq_teardown_flows()
1635 kfree(local->cvars); in ieee80211_txq_teardown_flows()
1636 local->cvars = NULL; in ieee80211_txq_teardown_flows()
1638 spin_lock_bh(&fq->lock); in ieee80211_txq_teardown_flows()
1640 spin_unlock_bh(&fq->lock); in ieee80211_txq_teardown_flows()
1651 if (sdata->vif.type == NL80211_IFTYPE_MONITOR) in ieee80211_queue_skb()
1654 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) in ieee80211_queue_skb()
1655 sdata = container_of(sdata->bss, in ieee80211_queue_skb()
1658 vif = &sdata->vif; in ieee80211_queue_skb()
1683 int q = info->hw_queue; in ieee80211_tx_frags()
1686 if (WARN_ON_ONCE(q >= local->hw.queues)) { in ieee80211_tx_frags()
1688 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_frags()
1693 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in ieee80211_tx_frags()
1694 if (local->queue_stop_reasons[q] || in ieee80211_tx_frags()
1695 (!txpending && !skb_queue_empty(&local->pending[q]))) { in ieee80211_tx_frags()
1696 if (unlikely(info->flags & in ieee80211_tx_frags()
1698 if (local->queue_stop_reasons[q] & in ieee80211_tx_frags()
1701 * Drop off-channel frames if queues in ieee80211_tx_frags()
1703 * than off-channel operation. Never in ieee80211_tx_frags()
1707 &local->queue_stop_reason_lock, in ieee80211_tx_frags()
1709 ieee80211_purge_tx_queue(&local->hw, in ieee80211_tx_frags()
1717 * later transmission from the tx-pending in ieee80211_tx_frags()
1722 &local->pending[q]); in ieee80211_tx_frags()
1725 &local->pending[q]); in ieee80211_tx_frags()
1727 spin_unlock_irqrestore(&local->queue_stop_reason_lock, in ieee80211_tx_frags()
1732 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_tx_frags()
1734 info->control.vif = vif; in ieee80211_tx_frags()
1735 control.sta = sta ? &sta->sta : NULL; in ieee80211_tx_frags()
1762 sdata = vif_to_sdata(info->control.vif); in __ieee80211_tx()
1763 if (sta && !sta->uploaded) in __ieee80211_tx()
1766 switch (sdata->vif.type) { in __ieee80211_tx()
1768 if (sdata->u.mntr.flags & MONITOR_FLAG_ACTIVE) { in __ieee80211_tx()
1769 vif = &sdata->vif; in __ieee80211_tx()
1772 sdata = rcu_dereference(local->monitor_sdata); in __ieee80211_tx()
1774 vif = &sdata->vif; in __ieee80211_tx()
1775 info->hw_queue = in __ieee80211_tx()
1776 vif->hw_queue[skb_get_queue_mapping(skb)]; in __ieee80211_tx()
1777 } else if (ieee80211_hw_check(&local->hw, QUEUE_CONTROL)) { in __ieee80211_tx()
1778 ieee80211_purge_tx_queue(&local->hw, skbs); in __ieee80211_tx()
1784 sdata = container_of(sdata->bss, in __ieee80211_tx()
1788 vif = &sdata->vif; in __ieee80211_tx()
1800 * Invoke TX handlers, return 0 on success and non-zero if the
1826 I802_DEBUG_INC(tx->local->tx_handlers_drop); in invoke_tx_handlers_early()
1827 if (tx->skb) in invoke_tx_handlers_early()
1828 ieee80211_free_txskb(&tx->local->hw, tx->skb); in invoke_tx_handlers_early()
1830 ieee80211_purge_tx_queue(&tx->local->hw, &tx->skbs); in invoke_tx_handlers_early()
1831 return -1; in invoke_tx_handlers_early()
1833 I802_DEBUG_INC(tx->local->tx_handlers_queued); in invoke_tx_handlers_early()
1834 return -1; in invoke_tx_handlers_early()
1846 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); in invoke_tx_handlers_late()
1849 if (!ieee80211_hw_check(&tx->local->hw, HAS_RATE_CONTROL)) in invoke_tx_handlers_late()
1852 if (unlikely(info->flags & IEEE80211_TX_INTFL_RETRANSMISSION)) { in invoke_tx_handlers_late()
1853 __skb_queue_tail(&tx->skbs, tx->skb); in invoke_tx_handlers_late()
1854 tx->skb = NULL; in invoke_tx_handlers_late()
1864 if (!ieee80211_hw_check(&tx->local->hw, HAS_RATE_CONTROL)) in invoke_tx_handlers_late()
1870 I802_DEBUG_INC(tx->local->tx_handlers_drop); in invoke_tx_handlers_late()
1871 if (tx->skb) in invoke_tx_handlers_late()
1872 ieee80211_free_txskb(&tx->local->hw, tx->skb); in invoke_tx_handlers_late()
1874 ieee80211_purge_tx_queue(&tx->local->hw, &tx->skbs); in invoke_tx_handlers_late()
1875 return -1; in invoke_tx_handlers_late()
1877 I802_DEBUG_INC(tx->local->tx_handlers_queued); in invoke_tx_handlers_late()
1878 return -1; in invoke_tx_handlers_late()
1905 info->band = band; in ieee80211_tx_prepare_skb()
1906 info->control.vif = vif; in ieee80211_tx_prepare_skb()
1907 info->hw_queue = vif->hw_queue[skb_get_queue_mapping(skb)]; in ieee80211_tx_prepare_skb()
1914 *sta = &tx.sta->sta; in ieee80211_tx_prepare_skb()
1938 struct ieee80211_local *local = sdata->local; in ieee80211_tx()
1944 if (unlikely(skb->len < 10)) { in ieee80211_tx()
1953 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx()
1960 if (!(info->flags & IEEE80211_TX_CTL_TX_OFFCHAN) || in ieee80211_tx()
1961 !ieee80211_hw_check(&local->hw, QUEUE_CONTROL)) in ieee80211_tx()
1962 info->hw_queue = in ieee80211_tx()
1963 sdata->vif.hw_queue[skb_get_queue_mapping(skb)]; in ieee80211_tx()
1990 struct ieee80211_local *local = sdata->local; in ieee80211_skb_resize()
1996 sdata->crypto_tx_tailroom_needed_cnt); in ieee80211_skb_resize()
2000 tail_need -= skb_tailroom(skb); in ieee80211_skb_resize()
2005 (!ieee80211_hw_check(&local->hw, SUPPORTS_CLONED_SKBS) || in ieee80211_skb_resize()
2007 I802_DEBUG_INC(local->tx_expand_skb_head_cloned); in ieee80211_skb_resize()
2009 I802_DEBUG_INC(local->tx_expand_skb_head); in ieee80211_skb_resize()
2014 wiphy_debug(local->hw.wiphy, in ieee80211_skb_resize()
2016 return -ENOMEM; in ieee80211_skb_resize()
2025 struct ieee80211_local *local = sdata->local; in ieee80211_xmit()
2027 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; in ieee80211_xmit()
2031 if (info->flags & IEEE80211_TX_INTFL_DONT_ENCRYPT) in ieee80211_xmit()
2033 else if (ieee80211_is_mgmt(hdr->frame_control)) in ieee80211_xmit()
2038 headroom = local->tx_headroom; in ieee80211_xmit()
2041 headroom -= skb_headroom(skb); in ieee80211_xmit()
2045 ieee80211_free_txskb(&local->hw, skb); in ieee80211_xmit()
2050 hdr = (struct ieee80211_hdr *) skb->data; in ieee80211_xmit()
2051 info->control.vif = &sdata->vif; in ieee80211_xmit()
2053 if (ieee80211_vif_is_mesh(&sdata->vif)) { in ieee80211_xmit()
2054 if (ieee80211_is_data(hdr->frame_control) && in ieee80211_xmit()
2055 is_unicast_ether_addr(hdr->addr1)) { in ieee80211_xmit()
2070 (struct ieee80211_radiotap_header *)skb->data; in ieee80211_validate_radiotap_len()
2073 if (unlikely(skb->len < sizeof(struct ieee80211_radiotap_header))) in ieee80211_validate_radiotap_len()
2077 if (unlikely(rthdr->it_version)) in ieee80211_validate_radiotap_len()
2081 if (unlikely(skb->len < ieee80211_get_radiotap_len(skb->data))) in ieee80211_validate_radiotap_len()
2090 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); in ieee80211_parse_tx_radiotap()
2093 (struct ieee80211_radiotap_header *) skb->data; in ieee80211_parse_tx_radiotap()
2095 int ret = ieee80211_radiotap_iterator_init(&iterator, rthdr, skb->len, in ieee80211_parse_tx_radiotap()
2110 info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT | in ieee80211_parse_tx_radiotap()
2115 * (ieee80211_radiotap_iterator_next returns -ENOENT when no more in ieee80211_parse_tx_radiotap()
2116 * entries present, or -EINVAL on error) in ieee80211_parse_tx_radiotap()
2137 * handed has the 32-bit FCS CRC at the end... in ieee80211_parse_tx_radiotap()
2142 if (skb->len < (iterator._max_length + FCS_LEN)) in ieee80211_parse_tx_radiotap()
2145 skb_trim(skb, skb->len - FCS_LEN); in ieee80211_parse_tx_radiotap()
2148 info->flags &= ~IEEE80211_TX_INTFL_DONT_ENCRYPT; in ieee80211_parse_tx_radiotap()
2150 info->flags &= ~IEEE80211_TX_CTL_DONTFRAG; in ieee80211_parse_tx_radiotap()
2156 info->flags |= IEEE80211_TX_CTL_NO_ACK; in ieee80211_parse_tx_radiotap()
2158 info->control.flags |= IEEE80211_TX_CTRL_NO_SEQNO; in ieee80211_parse_tx_radiotap()
2160 info->control.flags |= in ieee80211_parse_tx_radiotap()
2195 info->flags |= IEEE80211_TX_CTL_LDPC; in ieee80211_parse_tx_radiotap()
2201 info->flags |= in ieee80211_parse_tx_radiotap()
2239 * Documentation/networking/mac80211-injection.rst in ieee80211_parse_tx_radiotap()
2248 if (ret != -ENOENT) /* ie, if we didn't simply run out of fields */ in ieee80211_parse_tx_radiotap()
2253 local->hw.wiphy->bands[info->band]; in ieee80211_parse_tx_radiotap()
2255 info->control.flags |= IEEE80211_TX_CTRL_RATE_INJECT; in ieee80211_parse_tx_radiotap()
2258 info->control.rates[i].idx = -1; in ieee80211_parse_tx_radiotap()
2259 info->control.rates[i].flags = 0; in ieee80211_parse_tx_radiotap()
2260 info->control.rates[i].count = 0; in ieee80211_parse_tx_radiotap()
2264 info->control.rates[0].idx = rate; in ieee80211_parse_tx_radiotap()
2266 ieee80211_rate_set_vht(info->control.rates, vht_mcs, in ieee80211_parse_tx_radiotap()
2269 for (i = 0; i < sband->n_bitrates; i++) { in ieee80211_parse_tx_radiotap()
2270 if (rate * 5 != sband->bitrates[i].bitrate) in ieee80211_parse_tx_radiotap()
2273 info->control.rates[0].idx = i; in ieee80211_parse_tx_radiotap()
2278 if (info->control.rates[0].idx < 0) in ieee80211_parse_tx_radiotap()
2279 info->control.flags &= ~IEEE80211_TX_CTRL_RATE_INJECT; in ieee80211_parse_tx_radiotap()
2281 info->control.rates[0].flags = rate_flags; in ieee80211_parse_tx_radiotap()
2282 info->control.rates[0].count = min_t(u8, rate_retries + 1, in ieee80211_parse_tx_radiotap()
2283 local->hw.max_rate_tries); in ieee80211_parse_tx_radiotap()
2292 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); in ieee80211_monitor_start_xmit()
2306 info->flags = IEEE80211_TX_CTL_REQ_TX_STATUS | in ieee80211_monitor_start_xmit()
2309 /* Sanity-check the length of the radiotap header */ in ieee80211_monitor_start_xmit()
2314 len_rthdr = ieee80211_get_radiotap_len(skb->data); in ieee80211_monitor_start_xmit()
2330 if (skb->len < len_rthdr + 2) in ieee80211_monitor_start_xmit()
2333 hdr = (struct ieee80211_hdr *)(skb->data + len_rthdr); in ieee80211_monitor_start_xmit()
2334 hdrlen = ieee80211_hdrlen(hdr->frame_control); in ieee80211_monitor_start_xmit()
2336 if (skb->len < len_rthdr + hdrlen) in ieee80211_monitor_start_xmit()
2340 * Initialize skb->protocol if the injected frame is a data frame in ieee80211_monitor_start_xmit()
2343 if (ieee80211_is_data(hdr->frame_control) && in ieee80211_monitor_start_xmit()
2344 skb->len >= len_rthdr + hdrlen + sizeof(rfc1042_header) + 2) { in ieee80211_monitor_start_xmit()
2348 skb->protocol = cpu_to_be16((payload[6] << 8) | in ieee80211_monitor_start_xmit()
2356 * we handle as though they are non-injected frames. in ieee80211_monitor_start_xmit()
2359 * VLAN support we have an nl80211-based mechanism. in ieee80211_monitor_start_xmit()
2362 * don't use nl80211-based management TX/RX. in ieee80211_monitor_start_xmit()
2364 list_for_each_entry_rcu(tmp_sdata, &local->interfaces, list) { in ieee80211_monitor_start_xmit()
2367 if (tmp_sdata->vif.type == NL80211_IFTYPE_MONITOR || in ieee80211_monitor_start_xmit()
2368 tmp_sdata->vif.type == NL80211_IFTYPE_AP_VLAN) in ieee80211_monitor_start_xmit()
2370 if (ether_addr_equal(tmp_sdata->vif.addr, hdr->addr2)) { in ieee80211_monitor_start_xmit()
2376 chanctx_conf = rcu_dereference(sdata->vif.bss_conf.chanctx_conf); in ieee80211_monitor_start_xmit()
2378 tmp_sdata = rcu_dereference(local->monitor_sdata); in ieee80211_monitor_start_xmit()
2381 rcu_dereference(tmp_sdata->vif.bss_conf.chanctx_conf); in ieee80211_monitor_start_xmit()
2385 chandef = &chanctx_conf->def; in ieee80211_monitor_start_xmit()
2386 else if (!local->use_chanctx) in ieee80211_monitor_start_xmit()
2387 chandef = &local->_oper_chandef; in ieee80211_monitor_start_xmit()
2407 if (!cfg80211_reg_can_beacon(local->hw.wiphy, chandef, in ieee80211_monitor_start_xmit()
2408 sdata->vif.type)) in ieee80211_monitor_start_xmit()
2411 info->band = chandef->chan->band; in ieee80211_monitor_start_xmit()
2413 /* Initialize skb->priority according to frame type and TID class, in ieee80211_monitor_start_xmit()
2416 * skb-priority is preserved to assure frames injected with this in ieee80211_monitor_start_xmit()
2420 skb_set_queue_mapping(skb, ieee80211_ac_from_tid(skb->priority)); in ieee80211_monitor_start_xmit()
2447 u16 ethertype = (skb->data[12] << 8) | skb->data[13]; in ieee80211_is_tdls_setup()
2450 skb->len > 14 && in ieee80211_is_tdls_setup()
2451 skb->data[14] == WLAN_TDLS_SNAP_RFTYPE; in ieee80211_is_tdls_setup()
2460 switch (sdata->vif.type) { in ieee80211_lookup_ra_sta()
2462 sta = rcu_dereference(sdata->u.vlan.sta); in ieee80211_lookup_ra_sta()
2466 } else if (sdata->wdev.use_4addr) { in ieee80211_lookup_ra_sta()
2467 return -ENOLINK; in ieee80211_lookup_ra_sta()
2473 if (is_multicast_ether_addr(skb->data)) { in ieee80211_lookup_ra_sta()
2474 *sta_out = ERR_PTR(-ENOENT); in ieee80211_lookup_ra_sta()
2477 sta = sta_info_get_bss(sdata, skb->data); in ieee80211_lookup_ra_sta()
2486 if (sdata->wdev.wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS) { in ieee80211_lookup_ra_sta()
2487 sta = sta_info_get(sdata, skb->data); in ieee80211_lookup_ra_sta()
2496 * TDLS link during setup - throw out frames to in ieee80211_lookup_ra_sta()
2497 * peer. Allow TDLS-setup frames to unauthorized in ieee80211_lookup_ra_sta()
2498 * peers for the special case of a link teardown in ieee80211_lookup_ra_sta()
2503 return -EINVAL; in ieee80211_lookup_ra_sta()
2508 sta = sta_info_get(sdata, sdata->vif.cfg.ap_addr); in ieee80211_lookup_ra_sta()
2510 return -ENOLINK; in ieee80211_lookup_ra_sta()
2513 return -EINVAL; in ieee80211_lookup_ra_sta()
2516 *sta_out = sta ?: ERR_PTR(-ENOENT); in ieee80211_lookup_ra_sta()
2528 if (skb->sk) in ieee80211_store_ack_skb()
2537 spin_lock_irqsave(&local->ack_status_lock, flags); in ieee80211_store_ack_skb()
2538 id = idr_alloc(&local->ack_status_frames, ack_skb, in ieee80211_store_ack_skb()
2540 spin_unlock_irqrestore(&local->ack_status_lock, flags); in ieee80211_store_ack_skb()
2547 IEEE80211_SKB_CB(ack_skb)->ack.cookie = *cookie; in ieee80211_store_ack_skb()
2558 * ieee80211_build_hdr - build 802.11 header in the given frame
2571 * potential unsharing of the SKB - this needs to be interleaved with the
2574 * The function requires the read-side RCU lock held
2583 struct ieee80211_local *local = sdata->local; in ieee80211_build_hdr()
2606 if (local->force_tx_status) in ieee80211_build_hdr()
2612 ethertype = (skb->data[12] << 8) | skb->data[13]; in ieee80211_build_hdr()
2615 if (!ieee80211_vif_is_mld(&sdata->vif)) in ieee80211_build_hdr()
2617 rcu_dereference(sdata->vif.bss_conf.chanctx_conf); in ieee80211_build_hdr()
2619 switch (sdata->vif.type) { in ieee80211_build_hdr()
2621 if (sdata->wdev.use_4addr) { in ieee80211_build_hdr()
2624 memcpy(hdr.addr1, sta->sta.addr, ETH_ALEN); in ieee80211_build_hdr()
2625 memcpy(hdr.addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_build_hdr()
2626 memcpy(hdr.addr3, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2627 memcpy(hdr.addr4, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2630 wme_sta = sta->sta.wme; in ieee80211_build_hdr()
2632 if (!ieee80211_vif_is_mld(&sdata->vif)) { in ieee80211_build_hdr()
2636 ap_sdata = container_of(sdata->bss, in ieee80211_build_hdr()
2640 rcu_dereference(ap_sdata->vif.bss_conf.chanctx_conf); in ieee80211_build_hdr()
2642 if (sdata->wdev.use_4addr) in ieee80211_build_hdr()
2648 memcpy(hdr.addr1, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2650 if (ieee80211_vif_is_mld(&sdata->vif) && sta && !sta->sta.mlo) { in ieee80211_build_hdr()
2651 struct ieee80211_link_data *link; in ieee80211_build_hdr() local
2653 link_id = sta->deflink.link_id; in ieee80211_build_hdr()
2654 link = rcu_dereference(sdata->link[link_id]); in ieee80211_build_hdr()
2655 if (WARN_ON(!link)) { in ieee80211_build_hdr()
2656 ret = -ENOLINK; in ieee80211_build_hdr()
2659 memcpy(hdr.addr2, link->conf->addr, ETH_ALEN); in ieee80211_build_hdr()
2661 (sta && sta->sta.mlo)) { in ieee80211_build_hdr()
2662 memcpy(hdr.addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_build_hdr()
2666 conf = rcu_dereference(sdata->vif.link_conf[link_id]); in ieee80211_build_hdr()
2668 ret = -ENOLINK; in ieee80211_build_hdr()
2672 memcpy(hdr.addr2, conf->addr, ETH_ALEN); in ieee80211_build_hdr()
2675 memcpy(hdr.addr3, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2680 if (!is_multicast_ether_addr(skb->data)) { in ieee80211_build_hdr()
2684 mpath = mesh_path_lookup(sdata, skb->data); in ieee80211_build_hdr()
2687 next_hop = rcu_dereference(mpath->next_hop); in ieee80211_build_hdr()
2689 !(mpath->flags & (MESH_PATH_ACTIVE | in ieee80211_build_hdr()
2695 mppath = mpp_path_lookup(sdata, skb->data); in ieee80211_build_hdr()
2697 mppath->exp_time = jiffies; in ieee80211_build_hdr()
2701 mesh_path_del(sdata, mpath->dst); in ieee80211_build_hdr()
2710 if (ether_addr_equal(sdata->vif.addr, skb->data + ETH_ALEN) && in ieee80211_build_hdr()
2711 !(mppath && !ether_addr_equal(mppath->mpp, skb->data))) { in ieee80211_build_hdr()
2713 skb->data, skb->data + ETH_ALEN); in ieee80211_build_hdr()
2717 /* DS -> MBSS (802.11-2012 13.11.3.3). in ieee80211_build_hdr()
2723 const u8 *mesh_da = skb->data; in ieee80211_build_hdr()
2726 mesh_da = mppath->mpp; in ieee80211_build_hdr()
2728 mesh_da = mpath->dst; in ieee80211_build_hdr()
2731 mesh_da, sdata->vif.addr); in ieee80211_build_hdr()
2736 skb->data + ETH_ALEN, NULL); in ieee80211_build_hdr()
2740 sdata, &mesh_hdr, skb->data, in ieee80211_build_hdr()
2741 skb->data + ETH_ALEN); in ieee80211_build_hdr()
2750 memcpy(hdr.addr1, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2758 /* For TDLS only one link can be valid with peer STA */ in ieee80211_build_hdr()
2759 int tdls_link_id = sta->sta.valid_links ? in ieee80211_build_hdr()
2760 __ffs(sta->sta.valid_links) : 0; in ieee80211_build_hdr()
2761 struct ieee80211_link_data *link; in ieee80211_build_hdr() local
2764 memcpy(hdr.addr1, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2765 memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2766 link = rcu_dereference(sdata->link[tdls_link_id]); in ieee80211_build_hdr()
2767 if (WARN_ON_ONCE(!link)) { in ieee80211_build_hdr()
2768 ret = -EINVAL; in ieee80211_build_hdr()
2771 memcpy(hdr.addr3, link->u.mgd.bssid, ETH_ALEN); in ieee80211_build_hdr()
2773 } else if (sdata->u.mgd.use_4addr && in ieee80211_build_hdr()
2774 cpu_to_be16(ethertype) != sdata->control_port_protocol) { in ieee80211_build_hdr()
2778 memcpy(hdr.addr1, sdata->deflink.u.mgd.bssid, ETH_ALEN); in ieee80211_build_hdr()
2779 memcpy(hdr.addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_build_hdr()
2780 memcpy(hdr.addr3, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2781 memcpy(hdr.addr4, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2786 memcpy(hdr.addr1, sdata->vif.cfg.ap_addr, ETH_ALEN); in ieee80211_build_hdr()
2787 memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2788 memcpy(hdr.addr3, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2794 memcpy(hdr.addr1, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2795 memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2801 memcpy(hdr.addr1, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2802 memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2803 memcpy(hdr.addr3, sdata->u.ibss.bssid, ETH_ALEN); in ieee80211_build_hdr()
2807 ret = -EINVAL; in ieee80211_build_hdr()
2812 if (!ieee80211_vif_is_mld(&sdata->vif)) { in ieee80211_build_hdr()
2813 ret = -ENOTCONN; in ieee80211_build_hdr()
2819 band = chanctx_conf->def.chan->band; in ieee80211_build_hdr()
2827 wme_sta = sta->sta.wme; in ieee80211_build_hdr()
2828 } else if (ieee80211_vif_is_mesh(&sdata->vif)) { in ieee80211_build_hdr()
2843 if (unlikely(!ieee80211_vif_is_mesh(&sdata->vif) && in ieee80211_build_hdr()
2844 (sdata->vif.type != NL80211_IFTYPE_OCB) && in ieee80211_build_hdr()
2846 (cpu_to_be16(ethertype) != sdata->control_port_protocol || in ieee80211_build_hdr()
2847 !ieee80211_is_our_addr(sdata, skb->data + ETH_ALEN, NULL)))) { in ieee80211_build_hdr()
2850 sdata->name, hdr.addr1); in ieee80211_build_hdr()
2853 I802_DEBUG_INC(local->tx_handlers_drop_unauth_port); in ieee80211_build_hdr()
2855 ret = -EPERM; in ieee80211_build_hdr()
2859 if (unlikely(!multicast && ((skb->sk && in ieee80211_build_hdr()
2860 skb_shinfo(skb)->tx_flags & SKBTX_WIFI_STATUS) || in ieee80211_build_hdr()
2870 ret = -ENOMEM; in ieee80211_build_hdr()
2882 skip_header_bytes -= 2; in ieee80211_build_hdr()
2886 skip_header_bytes -= 2; in ieee80211_build_hdr()
2893 head_need = hdrlen + encaps_len + meshhdrlen - skb_headroom(skb); in ieee80211_build_hdr()
2909 head_need += local->tx_headroom; in ieee80211_build_hdr()
2912 ieee80211_free_txskb(&local->hw, skb); in ieee80211_build_hdr()
2914 return ERR_PTR(-ENOMEM); in ieee80211_build_hdr()
2930 memcpy(skb_push(skb, hdrlen - 2), &hdr, hdrlen - 2); in ieee80211_build_hdr()
2944 info->flags = info_flags; in ieee80211_build_hdr()
2945 info->ack_frame_id = info_id; in ieee80211_build_hdr()
2946 info->band = band; in ieee80211_build_hdr()
2966 net_info_ratelimited("%s: dropped frame to %pM with bad link ID request (%d vs. %d)\n", in ieee80211_build_hdr()
2967 sdata->name, hdr.addr1, in ieee80211_build_hdr()
2970 ret = -EINVAL; in ieee80211_build_hdr()
2975 info->control.flags = ctrl_flags; in ieee80211_build_hdr()
2984 * fast-xmit overview
2986 * The core idea of this fast-xmit is to remove per-packet checks by checking
2987 * them out of band. ieee80211_check_fast_xmit() implements the out-of-band
2988 * checks that are needed to get the sta->fast_tx pointer assigned, after which
2993 * Once assigned, the fast_tx data structure also caches the per-packet 802.11
2999 * since the per-packet code no longer checks the conditions. This is reflected
3007 struct ieee80211_local *local = sta->local; in ieee80211_check_fast_xmit()
3008 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_check_fast_xmit()
3013 if (!ieee80211_hw_check(&local->hw, SUPPORT_FAST_XMIT)) in ieee80211_check_fast_xmit()
3016 if (ieee80211_vif_is_mesh(&sdata->vif)) in ieee80211_check_fast_xmit()
3027 * key and the fast-tx assignment are done atomically, so the CPU that in ieee80211_check_fast_xmit()
3031 spin_lock_bh(&sta->lock); in ieee80211_check_fast_xmit()
3032 if (ieee80211_hw_check(&local->hw, SUPPORTS_PS) && in ieee80211_check_fast_xmit()
3033 !ieee80211_hw_check(&local->hw, SUPPORTS_DYNAMIC_PS) && in ieee80211_check_fast_xmit()
3034 sdata->vif.type == NL80211_IFTYPE_STATION) in ieee80211_check_fast_xmit()
3037 if (!test_sta_flag(sta, WLAN_STA_AUTHORIZED) || !sta->uploaded) in ieee80211_check_fast_xmit()
3046 if (sdata->noack_map) in ieee80211_check_fast_xmit()
3049 /* fast-xmit doesn't handle fragmentation at all */ in ieee80211_check_fast_xmit()
3050 if (local->hw.wiphy->frag_threshold != (u32)-1 && in ieee80211_check_fast_xmit()
3051 !ieee80211_hw_check(&local->hw, SUPPORTS_TX_FRAG)) in ieee80211_check_fast_xmit()
3054 if (!ieee80211_vif_is_mld(&sdata->vif)) { in ieee80211_check_fast_xmit()
3057 rcu_dereference(sdata->vif.bss_conf.chanctx_conf); in ieee80211_check_fast_xmit()
3062 build.band = chanctx_conf->def.chan->band; in ieee80211_check_fast_xmit()
3071 switch (sdata->vif.type) { in ieee80211_check_fast_xmit()
3076 memcpy(hdr->addr3, sdata->u.ibss.bssid, ETH_ALEN); in ieee80211_check_fast_xmit()
3081 /* For TDLS only one link can be valid with peer STA */ in ieee80211_check_fast_xmit()
3082 int tdls_link_id = sta->sta.valid_links ? in ieee80211_check_fast_xmit()
3083 __ffs(sta->sta.valid_links) : 0; in ieee80211_check_fast_xmit()
3084 struct ieee80211_link_data *link; in ieee80211_check_fast_xmit() local
3090 link = rcu_dereference(sdata->link[tdls_link_id]); in ieee80211_check_fast_xmit()
3091 if (!WARN_ON_ONCE(!link)) in ieee80211_check_fast_xmit()
3092 memcpy(hdr->addr3, link->u.mgd.bssid, ETH_ALEN); in ieee80211_check_fast_xmit()
3098 if (sdata->u.mgd.use_4addr) { in ieee80211_check_fast_xmit()
3099 /* non-regular ethertype cannot use the fastpath */ in ieee80211_check_fast_xmit()
3103 memcpy(hdr->addr1, sdata->deflink.u.mgd.bssid, ETH_ALEN); in ieee80211_check_fast_xmit()
3104 memcpy(hdr->addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_check_fast_xmit()
3112 memcpy(hdr->addr1, sdata->vif.cfg.ap_addr, ETH_ALEN); in ieee80211_check_fast_xmit()
3118 if (sdata->wdev.use_4addr) { in ieee80211_check_fast_xmit()
3122 memcpy(hdr->addr1, sta->sta.addr, ETH_ALEN); in ieee80211_check_fast_xmit()
3123 memcpy(hdr->addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_check_fast_xmit()
3134 if (sta->sta.mlo || !ieee80211_vif_is_mld(&sdata->vif)) { in ieee80211_check_fast_xmit()
3135 memcpy(hdr->addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_check_fast_xmit()
3137 unsigned int link_id = sta->deflink.link_id; in ieee80211_check_fast_xmit()
3138 struct ieee80211_link_data *link; in ieee80211_check_fast_xmit() local
3141 link = rcu_dereference(sdata->link[link_id]); in ieee80211_check_fast_xmit()
3142 if (WARN_ON(!link)) { in ieee80211_check_fast_xmit()
3146 memcpy(hdr->addr2, link->conf->addr, ETH_ALEN); in ieee80211_check_fast_xmit()
3153 /* not handled on fast-xmit */ in ieee80211_check_fast_xmit()
3157 if (sta->sta.wme) { in ieee80211_check_fast_xmit()
3167 build.key = rcu_access_pointer(sta->ptk[sta->ptk_idx]); in ieee80211_check_fast_xmit()
3169 build.key = rcu_access_pointer(sdata->default_unicast_key); in ieee80211_check_fast_xmit()
3173 gen_iv = build.key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV; in ieee80211_check_fast_xmit()
3174 iv_spc = build.key->conf.flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE; in ieee80211_check_fast_xmit()
3175 mmic = build.key->conf.flags & in ieee80211_check_fast_xmit()
3180 if (!(build.key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) in ieee80211_check_fast_xmit()
3184 if (build.key->flags & KEY_FLAG_TAINTED) in ieee80211_check_fast_xmit()
3187 switch (build.key->conf.cipher) { in ieee80211_check_fast_xmit()
3203 /* cannot handle MMIC or IV generation in xmit-fast */ in ieee80211_check_fast_xmit()
3211 /* cannot handle IV generation in fast-xmit */ in ieee80211_check_fast_xmit()
3223 build.key->conf.cipher); in ieee80211_check_fast_xmit()
3234 hdr->frame_control = fc; in ieee80211_check_fast_xmit()
3245 old = rcu_dereference_protected(sta->fast_tx, in ieee80211_check_fast_xmit()
3246 lockdep_is_held(&sta->lock)); in ieee80211_check_fast_xmit()
3247 rcu_assign_pointer(sta->fast_tx, fast_tx); in ieee80211_check_fast_xmit()
3250 spin_unlock_bh(&sta->lock); in ieee80211_check_fast_xmit()
3258 list_for_each_entry_rcu(sta, &local->sta_list, list) in ieee80211_check_fast_xmit_all()
3265 struct ieee80211_local *local = sdata->local; in ieee80211_check_fast_xmit_iface()
3270 list_for_each_entry_rcu(sta, &local->sta_list, list) { in ieee80211_check_fast_xmit_iface()
3271 if (sdata != sta->sdata && in ieee80211_check_fast_xmit_iface()
3272 (!sta->sdata->bss || sta->sdata->bss != sdata->bss)) in ieee80211_check_fast_xmit_iface()
3284 spin_lock_bh(&sta->lock); in ieee80211_clear_fast_xmit()
3285 fast_tx = rcu_dereference_protected(sta->fast_tx, in ieee80211_clear_fast_xmit()
3286 lockdep_is_held(&sta->lock)); in ieee80211_clear_fast_xmit()
3287 RCU_INIT_POINTER(sta->fast_tx, NULL); in ieee80211_clear_fast_xmit()
3288 spin_unlock_bh(&sta->lock); in ieee80211_clear_fast_xmit()
3298 I802_DEBUG_INC(local->tx_expand_skb_head); in ieee80211_amsdu_realloc_pad()
3301 wiphy_debug(local->hw.wiphy, in ieee80211_amsdu_realloc_pad()
3314 struct ieee80211_local *local = sdata->local; in ieee80211_amsdu_prepare_head()
3318 int hdr_len = fast_tx->hdr_len - sizeof(rfc1042_header); in ieee80211_amsdu_prepare_head()
3319 int subframe_len = skb->len - hdr_len; in ieee80211_amsdu_prepare_head()
3324 if (info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE) in ieee80211_amsdu_prepare_head()
3327 if (info->control.flags & IEEE80211_TX_CTRL_AMSDU) in ieee80211_amsdu_prepare_head()
3332 local->hw.extra_tx_headroom)) in ieee80211_amsdu_prepare_head()
3340 h_80211_src = data + fast_tx->sa_offs; in ieee80211_amsdu_prepare_head()
3341 h_80211_dst = data + fast_tx->da_offs; in ieee80211_amsdu_prepare_head()
3343 amsdu_hdr->h_proto = cpu_to_be16(subframe_len); in ieee80211_amsdu_prepare_head()
3344 ether_addr_copy(amsdu_hdr->h_source, h_80211_src); in ieee80211_amsdu_prepare_head()
3345 ether_addr_copy(amsdu_hdr->h_dest, h_80211_dst); in ieee80211_amsdu_prepare_head()
3347 /* according to IEEE 802.11-2012 8.3.2 table 8-19, the outer SA/DA in ieee80211_amsdu_prepare_head()
3348 * fields needs to be changed to BSSID for A-MSDU frames depending in ieee80211_amsdu_prepare_head()
3351 switch (sdata->vif.type) { in ieee80211_amsdu_prepare_head()
3353 bssid = sdata->vif.cfg.ap_addr; in ieee80211_amsdu_prepare_head()
3357 bssid = sdata->vif.addr; in ieee80211_amsdu_prepare_head()
3363 if (bssid && ieee80211_has_fromds(hdr->frame_control)) in ieee80211_amsdu_prepare_head()
3366 if (bssid && ieee80211_has_tods(hdr->frame_control)) in ieee80211_amsdu_prepare_head()
3372 info->control.flags |= IEEE80211_TX_CTRL_AMSDU; in ieee80211_amsdu_prepare_head()
3383 struct ieee80211_local *local = sdata->local; in ieee80211_amsdu_aggregate()
3384 struct fq *fq = &local->fq; in ieee80211_amsdu_aggregate()
3387 u8 tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; in ieee80211_amsdu_aggregate()
3388 struct ieee80211_txq *txq = sta->sta.txq[tid]; in ieee80211_amsdu_aggregate()
3391 int subframe_len = skb->len - ETH_ALEN; in ieee80211_amsdu_aggregate()
3392 u8 max_subframes = sta->sta.max_amsdu_subframes; in ieee80211_amsdu_aggregate()
3393 int max_frags = local->hw.max_tx_fragments; in ieee80211_amsdu_aggregate()
3394 int max_amsdu_len = sta->sta.cur->max_amsdu_len; in ieee80211_amsdu_aggregate()
3404 if (!ieee80211_hw_check(&local->hw, TX_AMSDU)) in ieee80211_amsdu_aggregate()
3407 if (sdata->vif.offload_flags & IEEE80211_OFFLOAD_ENCAP_ENABLED) in ieee80211_amsdu_aggregate()
3410 if (ieee80211_vif_is_mesh(&sdata->vif)) in ieee80211_amsdu_aggregate()
3420 if (test_bit(IEEE80211_TXQ_NO_AMSDU, &txqi->flags)) in ieee80211_amsdu_aggregate()
3423 if (sta->sta.cur->max_rc_amsdu_len) in ieee80211_amsdu_aggregate()
3425 sta->sta.cur->max_rc_amsdu_len); in ieee80211_amsdu_aggregate()
3427 if (sta->sta.cur->max_tid_amsdu_len[tid]) in ieee80211_amsdu_aggregate()
3429 sta->sta.cur->max_tid_amsdu_len[tid]); in ieee80211_amsdu_aggregate()
3433 spin_lock_bh(&fq->lock); in ieee80211_amsdu_aggregate()
3439 tin = &txqi->tin; in ieee80211_amsdu_aggregate()
3441 head = skb_peek_tail(&flow->queue); in ieee80211_amsdu_aggregate()
3445 orig_truesize = head->truesize; in ieee80211_amsdu_aggregate()
3446 orig_len = head->len; in ieee80211_amsdu_aggregate()
3448 if (skb->len + head->len > max_amsdu_len) in ieee80211_amsdu_aggregate()
3451 nfrags = 1 + skb_shinfo(skb)->nr_frags; in ieee80211_amsdu_aggregate()
3452 nfrags += 1 + skb_shinfo(head)->nr_frags; in ieee80211_amsdu_aggregate()
3453 frag_tail = &skb_shinfo(head)->frag_list; in ieee80211_amsdu_aggregate()
3455 nfrags += 1 + skb_shinfo(*frag_tail)->nr_frags; in ieee80211_amsdu_aggregate()
3456 frag_tail = &(*frag_tail)->next; in ieee80211_amsdu_aggregate()
3473 * and frag_tail should be &skb_shinfo(head)->frag_list. in ieee80211_amsdu_aggregate()
3478 frag_tail = &skb_shinfo(head)->frag_list; in ieee80211_amsdu_aggregate()
3482 * padding to the next one, that's being added. Note that head->len in ieee80211_amsdu_aggregate()
3483 * is the length of the full A-MSDU, but that works since each time in ieee80211_amsdu_aggregate()
3487 hdrlen = fast_tx->hdr_len - sizeof(rfc1042_header); in ieee80211_amsdu_aggregate()
3488 if ((head->len - hdrlen) & 3) in ieee80211_amsdu_aggregate()
3489 pad = 4 - ((head->len - hdrlen) & 3); in ieee80211_amsdu_aggregate()
3507 head->len += skb->len; in ieee80211_amsdu_aggregate()
3508 head->data_len += skb->len; in ieee80211_amsdu_aggregate()
3512 fq->memory_usage += head->truesize - orig_truesize; in ieee80211_amsdu_aggregate()
3513 if (head->len != orig_len) { in ieee80211_amsdu_aggregate()
3514 flow->backlog += head->len - orig_len; in ieee80211_amsdu_aggregate()
3515 tin->backlog_bytes += head->len - orig_len; in ieee80211_amsdu_aggregate()
3518 spin_unlock_bh(&fq->lock); in ieee80211_amsdu_aggregate()
3533 struct sk_buff *skb = tx->skb; in ieee80211_xmit_fast_finish()
3535 struct ieee80211_hdr *hdr = (void *)skb->data; in ieee80211_xmit_fast_finish()
3538 if (!ieee80211_hw_check(&tx->local->hw, HAS_RATE_CONTROL) && in ieee80211_xmit_fast_finish()
3543 info->control.hw_key = &key->conf; in ieee80211_xmit_fast_finish()
3545 dev_sw_netstats_tx_add(skb->dev, 1, skb->len); in ieee80211_xmit_fast_finish()
3547 if (hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) { in ieee80211_xmit_fast_finish()
3548 tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; in ieee80211_xmit_fast_finish()
3549 hdr->seq_ctrl = ieee80211_tx_next_seq(sta, tid); in ieee80211_xmit_fast_finish()
3551 info->flags |= IEEE80211_TX_CTL_ASSIGN_SEQ; in ieee80211_xmit_fast_finish()
3552 hdr->seq_ctrl = cpu_to_le16(sdata->sequence_number); in ieee80211_xmit_fast_finish()
3553 sdata->sequence_number += 0x10; in ieee80211_xmit_fast_finish()
3556 if (skb_shinfo(skb)->gso_size) in ieee80211_xmit_fast_finish()
3557 sta->deflink.tx_stats.msdu[tid] += in ieee80211_xmit_fast_finish()
3558 DIV_ROUND_UP(skb->len, skb_shinfo(skb)->gso_size); in ieee80211_xmit_fast_finish()
3560 sta->deflink.tx_stats.msdu[tid]++; in ieee80211_xmit_fast_finish()
3562 info->hw_queue = sdata->vif.hw_queue[skb_get_queue_mapping(skb)]; in ieee80211_xmit_fast_finish()
3567 sta->deflink.tx_stats.bytes[skb_get_queue_mapping(skb)] += skb->len; in ieee80211_xmit_fast_finish()
3568 sta->deflink.tx_stats.packets[skb_get_queue_mapping(skb)]++; in ieee80211_xmit_fast_finish()
3572 u8 *crypto_hdr = skb->data + pn_offs; in ieee80211_xmit_fast_finish()
3574 switch (key->conf.cipher) { in ieee80211_xmit_fast_finish()
3579 pn = atomic64_inc_return(&key->conf.tx_pn); in ieee80211_xmit_fast_finish()
3582 crypto_hdr[3] = 0x20 | (key->conf.keyidx << 6); in ieee80211_xmit_fast_finish()
3597 if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN) in ieee80211_sdata_netdev_features()
3598 return sdata->vif.netdev_features; in ieee80211_sdata_netdev_features()
3600 if (!sdata->bss) in ieee80211_sdata_netdev_features()
3603 sdata = container_of(sdata->bss, struct ieee80211_sub_if_data, u.ap); in ieee80211_sdata_netdev_features()
3604 return sdata->vif.netdev_features; in ieee80211_sdata_netdev_features()
3626 if (skb->ip_summed == CHECKSUM_PARTIAL) { in ieee80211_tx_skb_fixup()
3629 if (skb->encapsulation) in ieee80211_tx_skb_fixup()
3652 struct ieee80211_local *local = sdata->local; in __ieee80211_xmit_fast()
3653 struct ieee80211_hdr *hdr = (void *)fast_tx->hdr; in __ieee80211_xmit_fast()
3657 int hw_headroom = sdata->local->hw.extra_tx_headroom; in __ieee80211_xmit_fast()
3658 int extra_head = fast_tx->hdr_len - (ETH_HLEN - 2); in __ieee80211_xmit_fast()
3664 if ((hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) && in __ieee80211_xmit_fast()
3668 /* will not be crypto-handled beyond what we do here, so use false in __ieee80211_xmit_fast()
3669 * as the may-encrypt argument for the resize to not account for in __ieee80211_xmit_fast()
3673 max_t(int, extra_head + hw_headroom - in __ieee80211_xmit_fast()
3679 memcpy(skb->data, fast_tx->hdr, fast_tx->hdr_len); in __ieee80211_xmit_fast()
3680 memcpy(skb->data + fast_tx->da_offs, da, ETH_ALEN); in __ieee80211_xmit_fast()
3681 memcpy(skb->data + fast_tx->sa_offs, sa, ETH_ALEN); in __ieee80211_xmit_fast()
3685 info->band = fast_tx->band; in __ieee80211_xmit_fast()
3686 info->control.vif = &sdata->vif; in __ieee80211_xmit_fast()
3687 info->flags = IEEE80211_TX_CTL_FIRST_FRAGMENT | in __ieee80211_xmit_fast()
3689 info->control.flags = IEEE80211_TX_CTRL_FAST_XMIT | in __ieee80211_xmit_fast()
3694 if (local->force_tx_status) in __ieee80211_xmit_fast()
3695 info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS; in __ieee80211_xmit_fast()
3698 if (hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) { in __ieee80211_xmit_fast()
3699 u8 tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; in __ieee80211_xmit_fast()
3710 tx.key = fast_tx->key; in __ieee80211_xmit_fast()
3716 r = ieee80211_xmit_fast_finish(sdata, sta, fast_tx->pn_offs, in __ieee80211_xmit_fast()
3717 fast_tx->key, &tx); in __ieee80211_xmit_fast()
3722 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) in __ieee80211_xmit_fast()
3723 sdata = container_of(sdata->bss, in __ieee80211_xmit_fast()
3727 ieee80211_tx_frags(local, &sdata->vif, sta, &tx.skbs, false); in __ieee80211_xmit_fast()
3739 u16 ethertype = (skb->data[12] << 8) | skb->data[13]; in ieee80211_xmit_fast()
3740 struct ieee80211_hdr *hdr = (void *)fast_tx->hdr; in ieee80211_xmit_fast()
3747 if (cpu_to_be16(ethertype) == sdata->control_port_protocol) in ieee80211_xmit_fast()
3755 if (skb->sk && skb_shinfo(skb)->tx_flags & SKBTX_WIFI_STATUS) in ieee80211_xmit_fast()
3758 if (hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) { in ieee80211_xmit_fast()
3759 tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; in ieee80211_xmit_fast()
3760 tid_tx = rcu_dereference(sta->ampdu_mlme.tid_tx[tid]); in ieee80211_xmit_fast()
3762 if (!test_bit(HT_AGG_STATE_OPERATIONAL, &tid_tx->state)) in ieee80211_xmit_fast()
3764 if (tid_tx->timeout) in ieee80211_xmit_fast()
3765 tid_tx->last_tx = jiffies; in ieee80211_xmit_fast()
3769 memcpy(&eth, skb->data, ETH_HLEN - 2); in ieee80211_xmit_fast()
3792 struct fq *fq = &local->fq; in ieee80211_tx_dequeue()
3793 struct fq_tin *tin = &txqi->tin; in ieee80211_tx_dequeue()
3797 struct ieee80211_vif *vif = txq->vif; in ieee80211_tx_dequeue()
3798 int q = vif->hw_queue[txq->ac]; in ieee80211_tx_dequeue()
3808 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in ieee80211_tx_dequeue()
3809 q_stopped = local->queue_stop_reasons[q]; in ieee80211_tx_dequeue()
3810 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_tx_dequeue()
3814 set_bit(IEEE80211_TXQ_DIRTY, &txqi->flags); in ieee80211_tx_dequeue()
3818 spin_lock_bh(&fq->lock); in ieee80211_tx_dequeue()
3821 skb = __skb_dequeue(&txqi->frags); in ieee80211_tx_dequeue()
3823 if (!(IEEE80211_SKB_CB(skb)->control.flags & in ieee80211_tx_dequeue()
3826 IEEE80211_SKB_CB(skb)->control.flags &= in ieee80211_tx_dequeue()
3829 if (unlikely(test_bit(IEEE80211_TXQ_STOP, &txqi->flags))) in ieee80211_tx_dequeue()
3838 spin_unlock_bh(&fq->lock); in ieee80211_tx_dequeue()
3840 hdr = (struct ieee80211_hdr *)skb->data; in ieee80211_tx_dequeue()
3847 tx.sdata = vif_to_sdata(info->control.vif); in ieee80211_tx_dequeue()
3849 if (txq->sta) { in ieee80211_tx_dequeue()
3850 tx.sta = container_of(txq->sta, struct sta_info, sta); in ieee80211_tx_dequeue()
3855 if (unlikely(!(info->flags & IEEE80211_TX_CTL_INJECTED) && in ieee80211_tx_dequeue()
3856 ieee80211_is_data(hdr->frame_control) && in ieee80211_tx_dequeue()
3857 !ieee80211_vif_is_mesh(&tx.sdata->vif) && in ieee80211_tx_dequeue()
3858 tx.sdata->vif.type != NL80211_IFTYPE_OCB && in ieee80211_tx_dequeue()
3859 !is_multicast_ether_addr(hdr->addr1) && in ieee80211_tx_dequeue()
3861 (!(info->control.flags & in ieee80211_tx_dequeue()
3863 !ieee80211_is_our_addr(tx.sdata, hdr->addr2, in ieee80211_tx_dequeue()
3865 I802_DEBUG_INC(local->tx_handlers_drop_unauth_port); in ieee80211_tx_dequeue()
3866 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_dequeue()
3877 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_dequeue()
3881 if (test_bit(IEEE80211_TXQ_AMPDU, &txqi->flags)) in ieee80211_tx_dequeue()
3882 info->flags |= (IEEE80211_TX_CTL_AMPDU | in ieee80211_tx_dequeue()
3885 if (info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP) { in ieee80211_tx_dequeue()
3886 if (!ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL)) { in ieee80211_tx_dequeue()
3889 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_dequeue()
3896 if (info->control.flags & IEEE80211_TX_CTRL_FAST_XMIT) { in ieee80211_tx_dequeue()
3897 struct sta_info *sta = container_of(txq->sta, struct sta_info, in ieee80211_tx_dequeue()
3902 (tx.key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)) in ieee80211_tx_dequeue()
3903 pn_offs = ieee80211_hdrlen(hdr->frame_control); in ieee80211_tx_dequeue()
3905 r = ieee80211_xmit_fast_finish(sta->sdata, sta, pn_offs, in ieee80211_tx_dequeue()
3908 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_dequeue()
3919 spin_lock_bh(&fq->lock); in ieee80211_tx_dequeue()
3920 skb_queue_splice_tail(&tx.skbs, &txqi->frags); in ieee80211_tx_dequeue()
3921 spin_unlock_bh(&fq->lock); in ieee80211_tx_dequeue()
3926 !ieee80211_hw_check(&local->hw, TX_FRAG_LIST)) { in ieee80211_tx_dequeue()
3928 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_dequeue()
3933 switch (tx.sdata->vif.type) { in ieee80211_tx_dequeue()
3935 if (tx.sdata->u.mntr.flags & MONITOR_FLAG_ACTIVE) { in ieee80211_tx_dequeue()
3936 vif = &tx.sdata->vif; in ieee80211_tx_dequeue()
3939 tx.sdata = rcu_dereference(local->monitor_sdata); in ieee80211_tx_dequeue()
3941 vif = &tx.sdata->vif; in ieee80211_tx_dequeue()
3942 info->hw_queue = in ieee80211_tx_dequeue()
3943 vif->hw_queue[skb_get_queue_mapping(skb)]; in ieee80211_tx_dequeue()
3944 } else if (ieee80211_hw_check(&local->hw, QUEUE_CONTROL)) { in ieee80211_tx_dequeue()
3945 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_dequeue()
3952 tx.sdata = container_of(tx.sdata->bss, in ieee80211_tx_dequeue()
3956 vif = &tx.sdata->vif; in ieee80211_tx_dequeue()
3961 info->control.vif = vif; in ieee80211_tx_dequeue()
3964 wiphy_ext_feature_isset(local->hw.wiphy, NL80211_EXT_FEATURE_AQL)) { in ieee80211_tx_dequeue()
3965 bool ampdu = txq->ac != IEEE80211_AC_VO; in ieee80211_tx_dequeue()
3968 airtime = ieee80211_calc_expected_tx_airtime(hw, vif, txq->sta, in ieee80211_tx_dequeue()
3969 skb->len, ampdu); in ieee80211_tx_dequeue()
3973 txq->ac, in ieee80211_tx_dequeue()
3982 spin_unlock_bh(&fq->lock); in ieee80211_tx_dequeue()
3988 static inline s32 ieee80211_sta_deficit(struct sta_info *sta, u8 ac) in ieee80211_sta_deficit() argument
3990 struct airtime_info *air_info = &sta->airtime[ac]; in ieee80211_sta_deficit()
3992 return air_info->deficit - atomic_read(&air_info->aql_tx_pending); in ieee80211_sta_deficit()
4000 if (!txqi->txq.sta) in ieee80211_txq_set_active()
4003 sta = container_of(txqi->txq.sta, struct sta_info, sta); in ieee80211_txq_set_active()
4004 sta->airtime[txqi->txq.ac].last_active = (u32)jiffies; in ieee80211_txq_set_active()
4013 if (!txqi->txq.sta) in ieee80211_txq_keep_active()
4016 sta = container_of(txqi->txq.sta, struct sta_info, sta); in ieee80211_txq_keep_active()
4017 if (ieee80211_sta_deficit(sta, txqi->txq.ac) >= 0) in ieee80211_txq_keep_active()
4020 diff = (u32)jiffies - sta->airtime[txqi->txq.ac].last_active; in ieee80211_txq_keep_active()
4025 struct ieee80211_txq *ieee80211_next_txq(struct ieee80211_hw *hw, u8 ac) in ieee80211_next_txq() argument
4032 spin_lock_bh(&local->active_txq_lock[ac]); in ieee80211_next_txq()
4034 if (!local->schedule_round[ac]) in ieee80211_next_txq()
4038 txqi = list_first_entry_or_null(&local->active_txqs[ac], in ieee80211_next_txq()
4054 if (txqi->txq.sta) { in ieee80211_next_txq()
4055 struct sta_info *sta = container_of(txqi->txq.sta, in ieee80211_next_txq()
4057 bool aql_check = ieee80211_txq_airtime_check(hw, &txqi->txq); in ieee80211_next_txq()
4058 s32 deficit = ieee80211_sta_deficit(sta, txqi->txq.ac); in ieee80211_next_txq()
4064 sta->airtime[txqi->txq.ac].deficit += in ieee80211_next_txq()
4065 sta->airtime_weight; in ieee80211_next_txq()
4068 list_move_tail(&txqi->schedule_order, in ieee80211_next_txq()
4069 &local->active_txqs[txqi->txq.ac]); in ieee80211_next_txq()
4074 if (txqi->schedule_round == local->schedule_round[ac]) in ieee80211_next_txq()
4077 list_del_init(&txqi->schedule_order); in ieee80211_next_txq()
4078 txqi->schedule_round = local->schedule_round[ac]; in ieee80211_next_txq()
4079 ret = &txqi->txq; in ieee80211_next_txq()
4082 spin_unlock_bh(&local->active_txq_lock[ac]); in ieee80211_next_txq()
4095 spin_lock_bh(&local->active_txq_lock[txq->ac]); in __ieee80211_schedule_txq()
4098 if (list_empty(&txqi->schedule_order) && in __ieee80211_schedule_txq()
4107 if (txqi->txq.sta && local->airtime_flags && has_queue && in __ieee80211_schedule_txq()
4108 wiphy_ext_feature_isset(local->hw.wiphy, in __ieee80211_schedule_txq()
4110 list_add(&txqi->schedule_order, in __ieee80211_schedule_txq()
4111 &local->active_txqs[txq->ac]); in __ieee80211_schedule_txq()
4113 list_add_tail(&txqi->schedule_order, in __ieee80211_schedule_txq()
4114 &local->active_txqs[txq->ac]); in __ieee80211_schedule_txq()
4119 spin_unlock_bh(&local->active_txq_lock[txq->ac]); in __ieee80211_schedule_txq()
4131 if (!wiphy_ext_feature_isset(local->hw.wiphy, NL80211_EXT_FEATURE_AQL)) in ieee80211_txq_airtime_check()
4137 if (!txq->sta) in ieee80211_txq_airtime_check()
4140 if (unlikely(txq->tid == IEEE80211_NUM_TIDS)) in ieee80211_txq_airtime_check()
4143 sta = container_of(txq->sta, struct sta_info, sta); in ieee80211_txq_airtime_check()
4144 if (atomic_read(&sta->airtime[txq->ac].aql_tx_pending) < in ieee80211_txq_airtime_check()
4145 sta->airtime[txq->ac].aql_limit_low) in ieee80211_txq_airtime_check()
4148 if (atomic_read(&local->aql_total_pending_airtime) < in ieee80211_txq_airtime_check()
4149 local->aql_threshold && in ieee80211_txq_airtime_check()
4150 atomic_read(&sta->airtime[txq->ac].aql_tx_pending) < in ieee80211_txq_airtime_check()
4151 sta->airtime[txq->ac].aql_limit_high) in ieee80211_txq_airtime_check()
4159 ieee80211_txq_schedule_airtime_check(struct ieee80211_local *local, u8 ac) in ieee80211_txq_schedule_airtime_check() argument
4165 if (!wiphy_ext_feature_isset(local->hw.wiphy, NL80211_EXT_FEATURE_AQL)) in ieee80211_txq_schedule_airtime_check()
4168 list_for_each_entry(txq, &local->active_txqs[ac], schedule_order) in ieee80211_txq_schedule_airtime_check()
4171 aql_limit = (num_txq - 1) * local->aql_txq_limit_low[ac] / 2 + in ieee80211_txq_schedule_airtime_check()
4172 local->aql_txq_limit_high[ac]; in ieee80211_txq_schedule_airtime_check()
4174 return atomic_read(&local->aql_ac_pending_airtime[ac]) < aql_limit; in ieee80211_txq_schedule_airtime_check()
4183 u8 ac = txq->ac; in ieee80211_txq_may_transmit() local
4185 spin_lock_bh(&local->active_txq_lock[ac]); in ieee80211_txq_may_transmit()
4187 if (!txqi->txq.sta) in ieee80211_txq_may_transmit()
4190 if (list_empty(&txqi->schedule_order)) in ieee80211_txq_may_transmit()
4193 if (!ieee80211_txq_schedule_airtime_check(local, ac)) in ieee80211_txq_may_transmit()
4196 list_for_each_entry_safe(iter, tmp, &local->active_txqs[ac], in ieee80211_txq_may_transmit()
4201 if (!iter->txq.sta) { in ieee80211_txq_may_transmit()
4202 list_move_tail(&iter->schedule_order, in ieee80211_txq_may_transmit()
4203 &local->active_txqs[ac]); in ieee80211_txq_may_transmit()
4206 sta = container_of(iter->txq.sta, struct sta_info, sta); in ieee80211_txq_may_transmit()
4207 if (ieee80211_sta_deficit(sta, ac) < 0) in ieee80211_txq_may_transmit()
4208 sta->airtime[ac].deficit += sta->airtime_weight; in ieee80211_txq_may_transmit()
4209 list_move_tail(&iter->schedule_order, &local->active_txqs[ac]); in ieee80211_txq_may_transmit()
4212 sta = container_of(txqi->txq.sta, struct sta_info, sta); in ieee80211_txq_may_transmit()
4213 if (sta->airtime[ac].deficit >= 0) in ieee80211_txq_may_transmit()
4216 sta->airtime[ac].deficit += sta->airtime_weight; in ieee80211_txq_may_transmit()
4217 list_move_tail(&txqi->schedule_order, &local->active_txqs[ac]); in ieee80211_txq_may_transmit()
4218 spin_unlock_bh(&local->active_txq_lock[ac]); in ieee80211_txq_may_transmit()
4222 if (!list_empty(&txqi->schedule_order)) in ieee80211_txq_may_transmit()
4223 list_del_init(&txqi->schedule_order); in ieee80211_txq_may_transmit()
4224 spin_unlock_bh(&local->active_txq_lock[ac]); in ieee80211_txq_may_transmit()
4230 void ieee80211_txq_schedule_start(struct ieee80211_hw *hw, u8 ac) in ieee80211_txq_schedule_start() argument
4234 spin_lock_bh(&local->active_txq_lock[ac]); in ieee80211_txq_schedule_start()
4236 if (ieee80211_txq_schedule_airtime_check(local, ac)) { in ieee80211_txq_schedule_start()
4237 local->schedule_round[ac]++; in ieee80211_txq_schedule_start()
4238 if (!local->schedule_round[ac]) in ieee80211_txq_schedule_start()
4239 local->schedule_round[ac]++; in ieee80211_txq_schedule_start()
4241 local->schedule_round[ac] = 0; in ieee80211_txq_schedule_start()
4244 spin_unlock_bh(&local->active_txq_lock[ac]); in ieee80211_txq_schedule_start()
4255 struct ieee80211_local *local = sdata->local; in __ieee80211_subif_start_xmit()
4258 int len = skb->len; in __ieee80211_subif_start_xmit()
4260 if (unlikely(!ieee80211_sdata_running(sdata) || skb->len < ETH_HLEN)) { in __ieee80211_subif_start_xmit()
4265 sk_pacing_shift_update(skb->sk, sdata->local->hw.tx_sk_pacing_shift); in __ieee80211_subif_start_xmit()
4269 if (ieee80211_vif_is_mesh(&sdata->vif) && in __ieee80211_subif_start_xmit()
4270 ieee80211_hw_check(&local->hw, SUPPORT_FAST_XMIT) && in __ieee80211_subif_start_xmit()
4286 fast_tx = rcu_dereference(sta->fast_tx); in __ieee80211_subif_start_xmit()
4293 /* the frame could be fragmented, software-encrypted, and other in __ieee80211_subif_start_xmit()
4306 if (skb->protocol == sdata->control_port_protocol) in __ieee80211_subif_start_xmit()
4316 dev_sw_netstats_tx_add(dev, 1, skb->len); in __ieee80211_subif_start_xmit()
4339 eth = (void *)skb->data; in ieee80211_change_da()
4340 ether_addr_copy(eth->h_dest, sta->sta.addr); in ieee80211_change_da()
4349 const struct ethhdr *eth = (void *)skb->data; in ieee80211_multicast_to_unicast()
4350 const struct vlan_ethhdr *ethvlan = (void *)skb->data; in ieee80211_multicast_to_unicast()
4353 switch (sdata->vif.type) { in ieee80211_multicast_to_unicast()
4355 if (sdata->u.vlan.sta) in ieee80211_multicast_to_unicast()
4357 if (sdata->wdev.use_4addr) in ieee80211_multicast_to_unicast()
4362 if (!sdata->bss->multicast_to_unicast) in ieee80211_multicast_to_unicast()
4370 ethertype = eth->h_proto; in ieee80211_multicast_to_unicast()
4371 if (ethertype == htons(ETH_P_8021Q) && skb->len >= VLAN_ETH_HLEN) in ieee80211_multicast_to_unicast()
4372 ethertype = ethvlan->h_vlan_encapsulated_proto; in ieee80211_multicast_to_unicast()
4390 struct ieee80211_local *local = sdata->local; in ieee80211_convert_to_unicast()
4391 const struct ethhdr *eth = (struct ethhdr *)skb->data; in ieee80211_convert_to_unicast()
4397 list_for_each_entry_rcu(sta, &local->sta_list, list) { in ieee80211_convert_to_unicast()
4398 if (sdata != sta->sdata) in ieee80211_convert_to_unicast()
4399 /* AP-VLAN mismatch */ in ieee80211_convert_to_unicast()
4401 if (unlikely(ether_addr_equal(eth->h_source, sta->sta.addr))) in ieee80211_convert_to_unicast()
4447 __ieee80211_subif_start_xmit(out, sdata->dev, 0, ctrl_flags, NULL); in ieee80211_mlo_multicast_tx_one()
4454 unsigned long links = sdata->vif.active_links; in ieee80211_mlo_multicast_tx()
4455 unsigned int link; in ieee80211_mlo_multicast_tx() local
4462 __ieee80211_subif_start_xmit(skb, sdata->dev, 0, ctrl_flags, in ieee80211_mlo_multicast_tx()
4467 for_each_set_bit(link, &links, IEEE80211_MLD_MAX_NUM_LINKS) { in ieee80211_mlo_multicast_tx()
4468 ieee80211_mlo_multicast_tx_one(sdata, skb, ctrl_flags, link); in ieee80211_mlo_multicast_tx()
4475 * ieee80211_subif_start_xmit - netif start_xmit function for 802.3 vifs
4485 const struct ethhdr *eth = (void *)skb->data; in ieee80211_subif_start_xmit()
4487 if (likely(!is_multicast_ether_addr(eth->h_dest))) in ieee80211_subif_start_xmit()
4504 } else if (ieee80211_vif_is_mld(&sdata->vif) && in ieee80211_subif_start_xmit()
4505 sdata->vif.type == NL80211_IFTYPE_AP && in ieee80211_subif_start_xmit()
4506 !ieee80211_hw_check(&sdata->local->hw, MLO_MCAST_MULTI_LINK_TX)) { in ieee80211_subif_start_xmit()
4524 struct ieee80211_local *local = sdata->local; in __ieee80211_tx_8023()
4529 int q = info->hw_queue; in __ieee80211_tx_8023()
4531 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in __ieee80211_tx_8023()
4533 if (local->queue_stop_reasons[q] || in __ieee80211_tx_8023()
4534 (!txpending && !skb_queue_empty(&local->pending[q]))) { in __ieee80211_tx_8023()
4536 skb_queue_head(&local->pending[q], skb); in __ieee80211_tx_8023()
4538 skb_queue_tail(&local->pending[q], skb); in __ieee80211_tx_8023()
4540 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in __ieee80211_tx_8023()
4545 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in __ieee80211_tx_8023()
4547 if (sta && sta->uploaded) in __ieee80211_tx_8023()
4548 pubsta = &sta->sta; in __ieee80211_tx_8023()
4561 struct ieee80211_local *local = sdata->local; in ieee80211_tx_8023()
4582 struct ieee80211_local *local = sdata->local; in ieee80211_8023_xmit()
4592 if (unlikely(test_bit(SCAN_SW_SCANNING, &local->scanning)) && in ieee80211_8023_xmit()
4593 test_bit(SDATA_STATE_OFFCHANNEL, &sdata->state)) in ieee80211_8023_xmit()
4602 tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; in ieee80211_8023_xmit()
4603 tid_tx = rcu_dereference(sta->ampdu_mlme.tid_tx[tid]); in ieee80211_8023_xmit()
4605 if (!test_bit(HT_AGG_STATE_OPERATIONAL, &tid_tx->state)) { in ieee80211_8023_xmit()
4606 /* fall back to non-offload slow path */ in ieee80211_8023_xmit()
4613 if (tid_tx->timeout) in ieee80211_8023_xmit()
4614 tid_tx->last_tx = jiffies; in ieee80211_8023_xmit()
4624 info->hw_queue = sdata->vif.hw_queue[queue]; in ieee80211_8023_xmit()
4626 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) in ieee80211_8023_xmit()
4627 sdata = container_of(sdata->bss, in ieee80211_8023_xmit()
4630 info->flags |= IEEE80211_TX_CTL_HW_80211_ENCAP; in ieee80211_8023_xmit()
4631 info->control.vif = &sdata->vif; in ieee80211_8023_xmit()
4634 info->control.hw_key = &key->conf; in ieee80211_8023_xmit()
4638 len += seg->len; in ieee80211_8023_xmit()
4643 if (unlikely(skb->sk && in ieee80211_8023_xmit()
4644 skb_shinfo(skb)->tx_flags & SKBTX_WIFI_STATUS)) in ieee80211_8023_xmit()
4645 info->ack_frame_id = ieee80211_store_ack_skb(local, skb, in ieee80211_8023_xmit()
4646 &info->flags, NULL); in ieee80211_8023_xmit()
4649 sta->deflink.tx_stats.packets[queue] += skbs; in ieee80211_8023_xmit()
4650 sta->deflink.tx_stats.bytes[queue] += len; in ieee80211_8023_xmit()
4666 struct ethhdr *ehdr = (struct ethhdr *)skb->data; in ieee80211_subif_start_xmit_8023()
4670 if (unlikely(!ieee80211_sdata_running(sdata) || skb->len < ETH_HLEN)) { in ieee80211_subif_start_xmit_8023()
4682 if (unlikely(IS_ERR_OR_NULL(sta) || !sta->uploaded || in ieee80211_subif_start_xmit_8023()
4684 sdata->control_port_protocol == ehdr->h_proto)) in ieee80211_subif_start_xmit_8023()
4687 key = rcu_dereference(sta->ptk[sta->ptk_idx]); in ieee80211_subif_start_xmit_8023()
4689 key = rcu_dereference(sdata->default_unicast_key); in ieee80211_subif_start_xmit_8023()
4691 if (key && (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) || in ieee80211_subif_start_xmit_8023()
4692 key->conf.cipher == WLAN_CIPHER_SUITE_TKIP)) in ieee80211_subif_start_xmit_8023()
4695 sk_pacing_shift_update(skb->sk, sdata->local->hw.tx_sk_pacing_shift); in ieee80211_subif_start_xmit_8023()
4713 .local = sdata->local, in ieee80211_build_data_template()
4722 skb = ERR_PTR(-EINVAL); in ieee80211_build_data_template()
4731 hdr = (void *)skb->data; in ieee80211_build_data_template()
4732 tx.sta = sta_info_get(sdata, hdr->addr1); in ieee80211_build_data_template()
4738 return ERR_PTR(-EINVAL); in ieee80211_build_data_template()
4755 for (i = 0; i < local->hw.queues; i++) { in ieee80211_clear_tx_pending()
4756 while ((skb = skb_dequeue(&local->pending[i])) != NULL) in ieee80211_clear_tx_pending()
4757 ieee80211_free_txskb(&local->hw, skb); in ieee80211_clear_tx_pending()
4763 * which in this case means re-queued -- take as an indication to stop sending
4776 sdata = vif_to_sdata(info->control.vif); in ieee80211_tx_pending_skb()
4778 if (info->control.flags & IEEE80211_TX_INTCFL_NEED_TXPROCESSING) { in ieee80211_tx_pending_skb()
4779 /* update band only for non-MLD */ in ieee80211_tx_pending_skb()
4780 if (!ieee80211_vif_is_mld(&sdata->vif)) { in ieee80211_tx_pending_skb()
4782 rcu_dereference(sdata->vif.bss_conf.chanctx_conf); in ieee80211_tx_pending_skb()
4787 info->band = chanctx_conf->def.chan->band; in ieee80211_tx_pending_skb()
4790 } else if (info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP) { in ieee80211_tx_pending_skb()
4796 if (IS_ERR(sta) || (sta && !sta->uploaded)) in ieee80211_tx_pending_skb()
4806 hdr = (struct ieee80211_hdr *)skb->data; in ieee80211_tx_pending_skb()
4807 sta = sta_info_get(sdata, hdr->addr1); in ieee80211_tx_pending_skb()
4828 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in ieee80211_tx_pending()
4829 for (i = 0; i < local->hw.queues; i++) { in ieee80211_tx_pending()
4834 if (local->queue_stop_reasons[i] || in ieee80211_tx_pending()
4835 skb_queue_empty(&local->pending[i])) in ieee80211_tx_pending()
4838 while (!skb_queue_empty(&local->pending[i])) { in ieee80211_tx_pending()
4839 struct sk_buff *skb = __skb_dequeue(&local->pending[i]); in ieee80211_tx_pending()
4842 if (WARN_ON(!info->control.vif)) { in ieee80211_tx_pending()
4843 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_pending()
4847 spin_unlock_irqrestore(&local->queue_stop_reason_lock, in ieee80211_tx_pending()
4851 spin_lock_irqsave(&local->queue_stop_reason_lock, in ieee80211_tx_pending()
4857 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_tx_pending()
4865 struct ieee80211_link_data *link, in __ieee80211_beacon_add_tim() argument
4872 struct ieee80211_bss_conf *link_conf = link->conf; in __ieee80211_beacon_add_tim()
4876 if (atomic_read(&ps->num_sta_ps) > 0) in __ieee80211_beacon_add_tim()
4878 * checking byte-for-byte */ in __ieee80211_beacon_add_tim()
4879 have_bits = !bitmap_empty((unsigned long *)ps->tim, in __ieee80211_beacon_add_tim()
4882 if (ps->dtim_count == 0) in __ieee80211_beacon_add_tim()
4883 ps->dtim_count = link_conf->dtim_period - 1; in __ieee80211_beacon_add_tim()
4885 ps->dtim_count--; in __ieee80211_beacon_add_tim()
4891 *pos++ = ps->dtim_count; in __ieee80211_beacon_add_tim()
4892 *pos++ = link_conf->dtim_period; in __ieee80211_beacon_add_tim()
4894 if (ps->dtim_count == 0 && !skb_queue_empty(&ps->bc_buf)) in __ieee80211_beacon_add_tim()
4897 ps->dtim_bc_mc = aid0 == 1; in __ieee80211_beacon_add_tim()
4901 * (N1 x 8) - 1 in the bitmap are 0 and number N2 so that bits in __ieee80211_beacon_add_tim()
4905 if (ps->tim[i]) { in __ieee80211_beacon_add_tim()
4911 for (i = IEEE80211_MAX_TIM_LEN - 1; i >= n1; i--) { in __ieee80211_beacon_add_tim()
4912 if (ps->tim[i]) { in __ieee80211_beacon_add_tim()
4921 skb_put_data(skb, ps->tim + n1, n2 - n1 + 1); in __ieee80211_beacon_add_tim()
4923 tim[1] = n2 - n1 + 4; in __ieee80211_beacon_add_tim()
4927 if (ieee80211_get_link_sband(link)->band != NL80211_BAND_S1GHZ) { in __ieee80211_beacon_add_tim()
4936 struct ieee80211_link_data *link, in ieee80211_beacon_add_tim() argument
4940 struct ieee80211_local *local = sdata->local; in ieee80211_beacon_add_tim()
4946 * sta_lock to guarantee consistent and race-free update in ieee80211_beacon_add_tim()
4949 if (local->tim_in_locked_section) { in ieee80211_beacon_add_tim()
4950 __ieee80211_beacon_add_tim(sdata, link, ps, skb, is_template); in ieee80211_beacon_add_tim()
4952 spin_lock_bh(&local->tim_lock); in ieee80211_beacon_add_tim()
4953 __ieee80211_beacon_add_tim(sdata, link, ps, skb, is_template); in ieee80211_beacon_add_tim()
4954 spin_unlock_bh(&local->tim_lock); in ieee80211_beacon_add_tim()
4962 struct ieee80211_link_data *link) in ieee80211_set_beacon_cntdwn() argument
4970 switch (sdata->vif.type) { in ieee80211_set_beacon_cntdwn()
4972 beacon_data = beacon->tail; in ieee80211_set_beacon_cntdwn()
4973 beacon_data_len = beacon->tail_len; in ieee80211_set_beacon_cntdwn()
4976 beacon_data = beacon->head; in ieee80211_set_beacon_cntdwn()
4977 beacon_data_len = beacon->head_len; in ieee80211_set_beacon_cntdwn()
4980 beacon_data = beacon->head; in ieee80211_set_beacon_cntdwn()
4981 beacon_data_len = beacon->head_len; in ieee80211_set_beacon_cntdwn()
4987 resp = rcu_dereference(link->u.ap.probe_resp); in ieee80211_set_beacon_cntdwn()
4989 bcn_offsets = beacon->cntdwn_counter_offsets; in ieee80211_set_beacon_cntdwn()
4990 count = beacon->cntdwn_current_counter; in ieee80211_set_beacon_cntdwn()
4991 if (link->conf->csa_active) in ieee80211_set_beacon_cntdwn()
5001 if (sdata->vif.type == NL80211_IFTYPE_AP && resp) { in ieee80211_set_beacon_cntdwn()
5002 u16 *resp_offsets = resp->cntdwn_counter_offsets; in ieee80211_set_beacon_cntdwn()
5004 resp->data[resp_offsets[i]] = count; in ieee80211_set_beacon_cntdwn()
5011 beacon->cntdwn_current_counter--; in __ieee80211_beacon_update_cntdwn()
5014 WARN_ON_ONCE(!beacon->cntdwn_current_counter); in __ieee80211_beacon_update_cntdwn()
5016 return beacon->cntdwn_current_counter; in __ieee80211_beacon_update_cntdwn()
5027 if (sdata->vif.type == NL80211_IFTYPE_AP) in ieee80211_beacon_update_cntdwn()
5028 beacon = rcu_dereference(sdata->deflink.u.ap.beacon); in ieee80211_beacon_update_cntdwn()
5029 else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) in ieee80211_beacon_update_cntdwn()
5030 beacon = rcu_dereference(sdata->u.ibss.presp); in ieee80211_beacon_update_cntdwn()
5031 else if (ieee80211_vif_is_mesh(&sdata->vif)) in ieee80211_beacon_update_cntdwn()
5032 beacon = rcu_dereference(sdata->u.mesh.beacon); in ieee80211_beacon_update_cntdwn()
5052 if (sdata->vif.type == NL80211_IFTYPE_AP) in ieee80211_beacon_set_cntdwn()
5053 beacon = rcu_dereference(sdata->deflink.u.ap.beacon); in ieee80211_beacon_set_cntdwn()
5054 else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) in ieee80211_beacon_set_cntdwn()
5055 beacon = rcu_dereference(sdata->u.ibss.presp); in ieee80211_beacon_set_cntdwn()
5056 else if (ieee80211_vif_is_mesh(&sdata->vif)) in ieee80211_beacon_set_cntdwn()
5057 beacon = rcu_dereference(sdata->u.mesh.beacon); in ieee80211_beacon_set_cntdwn()
5062 if (counter < beacon->cntdwn_current_counter) in ieee80211_beacon_set_cntdwn()
5063 beacon->cntdwn_current_counter = counter; in ieee80211_beacon_set_cntdwn()
5082 if (vif->type == NL80211_IFTYPE_AP) { in ieee80211_beacon_cntdwn_is_complete()
5083 beacon = rcu_dereference(sdata->deflink.u.ap.beacon); in ieee80211_beacon_cntdwn_is_complete()
5084 if (WARN_ON(!beacon || !beacon->tail)) in ieee80211_beacon_cntdwn_is_complete()
5086 beacon_data = beacon->tail; in ieee80211_beacon_cntdwn_is_complete()
5087 beacon_data_len = beacon->tail_len; in ieee80211_beacon_cntdwn_is_complete()
5088 } else if (vif->type == NL80211_IFTYPE_ADHOC) { in ieee80211_beacon_cntdwn_is_complete()
5089 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; in ieee80211_beacon_cntdwn_is_complete()
5091 beacon = rcu_dereference(ifibss->presp); in ieee80211_beacon_cntdwn_is_complete()
5095 beacon_data = beacon->head; in ieee80211_beacon_cntdwn_is_complete()
5096 beacon_data_len = beacon->head_len; in ieee80211_beacon_cntdwn_is_complete()
5097 } else if (vif->type == NL80211_IFTYPE_MESH_POINT) { in ieee80211_beacon_cntdwn_is_complete()
5098 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; in ieee80211_beacon_cntdwn_is_complete()
5100 beacon = rcu_dereference(ifmsh->beacon); in ieee80211_beacon_cntdwn_is_complete()
5104 beacon_data = beacon->head; in ieee80211_beacon_cntdwn_is_complete()
5105 beacon_data_len = beacon->head_len; in ieee80211_beacon_cntdwn_is_complete()
5111 if (!beacon->cntdwn_counter_offsets[0]) in ieee80211_beacon_cntdwn_is_complete()
5114 if (WARN_ON_ONCE(beacon->cntdwn_counter_offsets[0] > beacon_data_len)) in ieee80211_beacon_cntdwn_is_complete()
5117 if (beacon_data[beacon->cntdwn_counter_offsets[0]] == 1) in ieee80211_beacon_cntdwn_is_complete()
5130 struct ieee80211_link_data *link) in ieee80211_beacon_protect() argument
5137 tx.key = rcu_dereference(link->default_beacon_key); in ieee80211_beacon_protect()
5141 if (unlikely(tx.key->flags & KEY_FLAG_TAINTED)) { in ieee80211_beacon_protect()
5143 return -EINVAL; in ieee80211_beacon_protect()
5146 if (!(tx.key->conf.flags & IEEE80211_KEY_FLAG_SW_MGMT_TX) && in ieee80211_beacon_protect()
5147 tx.key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) in ieee80211_beacon_protect()
5148 IEEE80211_SKB_CB(skb)->control.hw_key = &tx.key->conf; in ieee80211_beacon_protect()
5159 return -EINVAL; in ieee80211_beacon_protect()
5167 struct ieee80211_link_data *link, in ieee80211_beacon_get_finish() argument
5185 u16 csa_off = beacon->cntdwn_counter_offsets[i]; in ieee80211_beacon_get_finish()
5190 offs->cntdwn_counter_offs[i] = csa_off_base + csa_off; in ieee80211_beacon_get_finish()
5194 band = chanctx_conf->def.chan->band; in ieee80211_beacon_get_finish()
5196 info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; in ieee80211_beacon_get_finish()
5197 info->flags |= IEEE80211_TX_CTL_NO_ACK; in ieee80211_beacon_get_finish()
5198 info->band = band; in ieee80211_beacon_get_finish()
5202 txrc.sband = local->hw.wiphy->bands[band]; in ieee80211_beacon_get_finish()
5203 txrc.bss_conf = link->conf; in ieee80211_beacon_get_finish()
5205 txrc.reported_rate.idx = -1; in ieee80211_beacon_get_finish()
5206 if (sdata->beacon_rate_set && sdata->beacon_rateidx_mask[band]) in ieee80211_beacon_get_finish()
5207 txrc.rate_idx_mask = sdata->beacon_rateidx_mask[band]; in ieee80211_beacon_get_finish()
5209 txrc.rate_idx_mask = sdata->rc_rateidx_mask[band]; in ieee80211_beacon_get_finish()
5213 info->control.vif = vif; in ieee80211_beacon_get_finish()
5214 info->control.flags |= u32_encode_bits(link->link_id, in ieee80211_beacon_get_finish()
5216 info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT | in ieee80211_beacon_get_finish()
5225 if (!beacon->mbssid_ies || !beacon->mbssid_ies->cnt || in ieee80211_beacon_add_mbssid()
5226 i > beacon->mbssid_ies->cnt) in ieee80211_beacon_add_mbssid()
5229 if (i < beacon->mbssid_ies->cnt) { in ieee80211_beacon_add_mbssid()
5230 skb_put_data(skb, beacon->mbssid_ies->elem[i].data, in ieee80211_beacon_add_mbssid()
5231 beacon->mbssid_ies->elem[i].len); in ieee80211_beacon_add_mbssid()
5233 if (beacon->rnr_ies && beacon->rnr_ies->cnt) { in ieee80211_beacon_add_mbssid()
5234 skb_put_data(skb, beacon->rnr_ies->elem[i].data, in ieee80211_beacon_add_mbssid()
5235 beacon->rnr_ies->elem[i].len); in ieee80211_beacon_add_mbssid()
5237 for (i = beacon->mbssid_ies->cnt; i < beacon->rnr_ies->cnt; i++) in ieee80211_beacon_add_mbssid()
5238 skb_put_data(skb, beacon->rnr_ies->elem[i].data, in ieee80211_beacon_add_mbssid()
5239 beacon->rnr_ies->elem[i].len); in ieee80211_beacon_add_mbssid()
5244 /* i == beacon->mbssid_ies->cnt, include all MBSSID elements */ in ieee80211_beacon_add_mbssid()
5245 for (i = 0; i < beacon->mbssid_ies->cnt; i++) in ieee80211_beacon_add_mbssid()
5246 skb_put_data(skb, beacon->mbssid_ies->elem[i].data, in ieee80211_beacon_add_mbssid()
5247 beacon->mbssid_ies->elem[i].len); in ieee80211_beacon_add_mbssid()
5253 struct ieee80211_link_data *link, in ieee80211_beacon_get_ap() argument
5262 struct ieee80211_if_ap *ap = &sdata->u.ap; in ieee80211_beacon_get_ap()
5267 if (beacon->cntdwn_counter_offsets[0]) { in ieee80211_beacon_get_ap()
5271 ieee80211_set_beacon_cntdwn(sdata, beacon, link); in ieee80211_beacon_get_ap()
5277 mbssid_len = ieee80211_get_mbssid_beacon_len(beacon->mbssid_ies, in ieee80211_beacon_get_ap()
5278 beacon->rnr_ies, in ieee80211_beacon_get_ap()
5281 skb = dev_alloc_skb(local->tx_headroom + beacon->head_len + in ieee80211_beacon_get_ap()
5282 beacon->tail_len + 256 + in ieee80211_beacon_get_ap()
5283 local->hw.extra_beacon_tailroom + mbssid_len); in ieee80211_beacon_get_ap()
5287 skb_reserve(skb, local->tx_headroom); in ieee80211_beacon_get_ap()
5288 skb_put_data(skb, beacon->head, beacon->head_len); in ieee80211_beacon_get_ap()
5290 ieee80211_beacon_add_tim(sdata, link, &ap->ps, skb, is_template); in ieee80211_beacon_get_ap()
5293 offs->tim_offset = beacon->head_len; in ieee80211_beacon_get_ap()
5294 offs->tim_length = skb->len - beacon->head_len; in ieee80211_beacon_get_ap()
5295 offs->cntdwn_counter_offs[0] = beacon->cntdwn_counter_offsets[0]; in ieee80211_beacon_get_ap()
5299 offs->mbssid_off = skb->len - mbssid_len; in ieee80211_beacon_get_ap()
5303 csa_off_base = skb->len; in ieee80211_beacon_get_ap()
5306 if (beacon->tail) in ieee80211_beacon_get_ap()
5307 skb_put_data(skb, beacon->tail, beacon->tail_len); in ieee80211_beacon_get_ap()
5309 if (ieee80211_beacon_protect(skb, local, sdata, link) < 0) in ieee80211_beacon_get_ap()
5312 ieee80211_beacon_get_finish(hw, vif, link, offs, beacon, skb, in ieee80211_beacon_get_ap()
5320 struct ieee80211_link_data *link, in ieee80211_beacon_get_ap_ema_list() argument
5327 if (!beacon->mbssid_ies || !beacon->mbssid_ies->cnt) in ieee80211_beacon_get_ap_ema_list()
5330 ema = kzalloc(struct_size(ema, bcn, beacon->mbssid_ies->cnt), in ieee80211_beacon_get_ap_ema_list()
5335 for (ema->cnt = 0; ema->cnt < beacon->mbssid_ies->cnt; ema->cnt++) { in ieee80211_beacon_get_ap_ema_list()
5336 ema->bcn[ema->cnt].skb = in ieee80211_beacon_get_ap_ema_list()
5337 ieee80211_beacon_get_ap(hw, vif, link, in ieee80211_beacon_get_ap_ema_list()
5338 &ema->bcn[ema->cnt].offs, in ieee80211_beacon_get_ap_ema_list()
5340 chanctx_conf, ema->cnt); in ieee80211_beacon_get_ap_ema_list()
5341 if (!ema->bcn[ema->cnt].skb) in ieee80211_beacon_get_ap_ema_list()
5345 if (ema->cnt == beacon->mbssid_ies->cnt) in ieee80211_beacon_get_ap_ema_list()
5352 #define IEEE80211_INCLUDE_ALL_MBSSID_ELEMS -1
5368 struct ieee80211_link_data *link; in __ieee80211_beacon_get() local
5373 link = rcu_dereference(sdata->link[link_id]); in __ieee80211_beacon_get()
5374 if (!link) in __ieee80211_beacon_get()
5377 rcu_dereference(link->conf->chanctx_conf); in __ieee80211_beacon_get()
5385 if (sdata->vif.type == NL80211_IFTYPE_AP) { in __ieee80211_beacon_get()
5386 beacon = rcu_dereference(link->u.ap.beacon); in __ieee80211_beacon_get()
5392 ieee80211_beacon_get_ap_ema_list(hw, vif, link, in __ieee80211_beacon_get()
5398 if (beacon->mbssid_ies && beacon->mbssid_ies->cnt) { in __ieee80211_beacon_get()
5399 if (ema_index >= beacon->mbssid_ies->cnt) in __ieee80211_beacon_get()
5403 ema_index = beacon->mbssid_ies->cnt; in __ieee80211_beacon_get()
5408 skb = ieee80211_beacon_get_ap(hw, vif, link, offs, in __ieee80211_beacon_get()
5413 } else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) { in __ieee80211_beacon_get()
5414 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; in __ieee80211_beacon_get()
5417 beacon = rcu_dereference(ifibss->presp); in __ieee80211_beacon_get()
5421 if (beacon->cntdwn_counter_offsets[0]) { in __ieee80211_beacon_get()
5425 ieee80211_set_beacon_cntdwn(sdata, beacon, link); in __ieee80211_beacon_get()
5428 skb = dev_alloc_skb(local->tx_headroom + beacon->head_len + in __ieee80211_beacon_get()
5429 local->hw.extra_beacon_tailroom); in __ieee80211_beacon_get()
5432 skb_reserve(skb, local->tx_headroom); in __ieee80211_beacon_get()
5433 skb_put_data(skb, beacon->head, beacon->head_len); in __ieee80211_beacon_get()
5435 hdr = (struct ieee80211_hdr *) skb->data; in __ieee80211_beacon_get()
5436 hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | in __ieee80211_beacon_get()
5439 ieee80211_beacon_get_finish(hw, vif, link, offs, beacon, skb, in __ieee80211_beacon_get()
5441 } else if (ieee80211_vif_is_mesh(&sdata->vif)) { in __ieee80211_beacon_get()
5442 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; in __ieee80211_beacon_get()
5444 beacon = rcu_dereference(ifmsh->beacon); in __ieee80211_beacon_get()
5448 if (beacon->cntdwn_counter_offsets[0]) { in __ieee80211_beacon_get()
5457 ieee80211_set_beacon_cntdwn(sdata, beacon, link); in __ieee80211_beacon_get()
5460 if (ifmsh->sync_ops) in __ieee80211_beacon_get()
5461 ifmsh->sync_ops->adjust_tsf(sdata, beacon); in __ieee80211_beacon_get()
5463 skb = dev_alloc_skb(local->tx_headroom + in __ieee80211_beacon_get()
5464 beacon->head_len + in __ieee80211_beacon_get()
5466 beacon->tail_len + in __ieee80211_beacon_get()
5467 local->hw.extra_beacon_tailroom); in __ieee80211_beacon_get()
5470 skb_reserve(skb, local->tx_headroom); in __ieee80211_beacon_get()
5471 skb_put_data(skb, beacon->head, beacon->head_len); in __ieee80211_beacon_get()
5472 ieee80211_beacon_add_tim(sdata, link, &ifmsh->ps, skb, in __ieee80211_beacon_get()
5476 offs->tim_offset = beacon->head_len; in __ieee80211_beacon_get()
5477 offs->tim_length = skb->len - beacon->head_len; in __ieee80211_beacon_get()
5480 skb_put_data(skb, beacon->tail, beacon->tail_len); in __ieee80211_beacon_get()
5481 ieee80211_beacon_get_finish(hw, vif, link, offs, beacon, skb, in __ieee80211_beacon_get()
5523 for (i = 0; i < ema_beacons->cnt; i++) in ieee80211_beacon_free_ema_list()
5524 kfree_skb(ema_beacons->bcn[i].skb); in ieee80211_beacon_free_ema_list()
5567 !hw_to_local(hw)->monitors) in ieee80211_beacon_get_tim()
5590 if (sdata->vif.type != NL80211_IFTYPE_AP) in ieee80211_proberesp_get()
5594 presp = rcu_dereference(sdata->deflink.u.ap.probe_resp); in ieee80211_proberesp_get()
5598 skb = dev_alloc_skb(presp->len); in ieee80211_proberesp_get()
5602 skb_put_data(skb, presp->data, presp->len); in ieee80211_proberesp_get()
5604 hdr = (struct ieee80211_hdr *) skb->data; in ieee80211_proberesp_get()
5605 memset(hdr->addr1, 0, sizeof(hdr->addr1)); in ieee80211_proberesp_get()
5620 if (sdata->vif.type != NL80211_IFTYPE_AP) in ieee80211_get_fils_discovery_tmpl()
5624 tmpl = rcu_dereference(sdata->deflink.u.ap.fils_discovery); in ieee80211_get_fils_discovery_tmpl()
5630 skb = dev_alloc_skb(sdata->local->hw.extra_tx_headroom + tmpl->len); in ieee80211_get_fils_discovery_tmpl()
5632 skb_reserve(skb, sdata->local->hw.extra_tx_headroom); in ieee80211_get_fils_discovery_tmpl()
5633 skb_put_data(skb, tmpl->data, tmpl->len); in ieee80211_get_fils_discovery_tmpl()
5649 if (sdata->vif.type != NL80211_IFTYPE_AP) in ieee80211_get_unsol_bcast_probe_resp_tmpl()
5653 tmpl = rcu_dereference(sdata->deflink.u.ap.unsol_bcast_probe_resp); in ieee80211_get_unsol_bcast_probe_resp_tmpl()
5659 skb = dev_alloc_skb(sdata->local->hw.extra_tx_headroom + tmpl->len); in ieee80211_get_unsol_bcast_probe_resp_tmpl()
5661 skb_reserve(skb, sdata->local->hw.extra_tx_headroom); in ieee80211_get_unsol_bcast_probe_resp_tmpl()
5662 skb_put_data(skb, tmpl->data, tmpl->len); in ieee80211_get_unsol_bcast_probe_resp_tmpl()
5678 if (WARN_ON(vif->type != NL80211_IFTYPE_STATION)) in ieee80211_pspoll_get()
5682 local = sdata->local; in ieee80211_pspoll_get()
5684 skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*pspoll)); in ieee80211_pspoll_get()
5688 skb_reserve(skb, local->hw.extra_tx_headroom); in ieee80211_pspoll_get()
5691 pspoll->frame_control = cpu_to_le16(IEEE80211_FTYPE_CTL | in ieee80211_pspoll_get()
5693 pspoll->aid = cpu_to_le16(sdata->vif.cfg.aid); in ieee80211_pspoll_get()
5695 /* aid in PS-Poll has its two MSBs each set to 1 */ in ieee80211_pspoll_get()
5696 pspoll->aid |= cpu_to_le16(1 << 15 | 1 << 14); in ieee80211_pspoll_get()
5698 memcpy(pspoll->bssid, sdata->deflink.u.mgd.bssid, ETH_ALEN); in ieee80211_pspoll_get()
5699 memcpy(pspoll->ta, vif->addr, ETH_ALEN); in ieee80211_pspoll_get()
5710 struct ieee80211_local *local = sdata->local; in ieee80211_nullfunc_get()
5711 struct ieee80211_link_data *link = NULL; in ieee80211_nullfunc_get() local
5716 if (WARN_ON(vif->type != NL80211_IFTYPE_STATION)) in ieee80211_nullfunc_get()
5719 skb = dev_alloc_skb(local->hw.extra_tx_headroom + in ieee80211_nullfunc_get()
5728 sta = sta_info_get(sdata, vif->cfg.ap_addr); in ieee80211_nullfunc_get()
5729 qos = sta && sta->sta.wme; in ieee80211_nullfunc_get()
5733 link = rcu_dereference(sdata->link[link_id]); in ieee80211_nullfunc_get()
5734 if (WARN_ON_ONCE(!link)) { in ieee80211_nullfunc_get()
5741 skb_reserve(skb, local->hw.extra_tx_headroom); in ieee80211_nullfunc_get()
5744 nullfunc->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA | in ieee80211_nullfunc_get()
5753 nullfunc->frame_control |= in ieee80211_nullfunc_get()
5755 skb->priority = 7; in ieee80211_nullfunc_get()
5760 if (link) { in ieee80211_nullfunc_get()
5761 memcpy(nullfunc->addr1, link->conf->bssid, ETH_ALEN); in ieee80211_nullfunc_get()
5762 memcpy(nullfunc->addr2, link->conf->addr, ETH_ALEN); in ieee80211_nullfunc_get()
5763 memcpy(nullfunc->addr3, link->conf->bssid, ETH_ALEN); in ieee80211_nullfunc_get()
5765 memcpy(nullfunc->addr1, vif->cfg.ap_addr, ETH_ALEN); in ieee80211_nullfunc_get()
5766 memcpy(nullfunc->addr2, vif->addr, ETH_ALEN); in ieee80211_nullfunc_get()
5767 memcpy(nullfunc->addr3, vif->cfg.ap_addr, ETH_ALEN); in ieee80211_nullfunc_get()
5788 skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*hdr) + in ieee80211_probereq_get()
5793 skb_reserve(skb, local->hw.extra_tx_headroom); in ieee80211_probereq_get()
5796 hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | in ieee80211_probereq_get()
5798 eth_broadcast_addr(hdr->addr1); in ieee80211_probereq_get()
5799 memcpy(hdr->addr2, src_addr, ETH_ALEN); in ieee80211_probereq_get()
5800 eth_broadcast_addr(hdr->addr3); in ieee80211_probereq_get()
5820 rts->frame_control = in ieee80211_rts_get()
5822 rts->duration = ieee80211_rts_duration(hw, vif, frame_len, in ieee80211_rts_get()
5824 memcpy(rts->ra, hdr->addr1, sizeof(rts->ra)); in ieee80211_rts_get()
5825 memcpy(rts->ta, hdr->addr2, sizeof(rts->ta)); in ieee80211_rts_get()
5836 cts->frame_control = in ieee80211_ctstoself_get()
5838 cts->duration = ieee80211_ctstoself_duration(hw, vif, in ieee80211_ctstoself_get()
5840 memcpy(cts->ra, hdr->addr1, sizeof(cts->ra)); in ieee80211_ctstoself_get()
5859 chanctx_conf = rcu_dereference(sdata->vif.bss_conf.chanctx_conf); in ieee80211_get_buffered_bc()
5864 if (sdata->vif.type == NL80211_IFTYPE_AP) { in ieee80211_get_buffered_bc()
5866 rcu_dereference(sdata->deflink.u.ap.beacon); in ieee80211_get_buffered_bc()
5868 if (!beacon || !beacon->head) in ieee80211_get_buffered_bc()
5871 ps = &sdata->u.ap.ps; in ieee80211_get_buffered_bc()
5872 } else if (ieee80211_vif_is_mesh(&sdata->vif)) { in ieee80211_get_buffered_bc()
5873 ps = &sdata->u.mesh.ps; in ieee80211_get_buffered_bc()
5878 if (ps->dtim_count != 0 || !ps->dtim_bc_mc) in ieee80211_get_buffered_bc()
5882 skb = skb_dequeue(&ps->bc_buf); in ieee80211_get_buffered_bc()
5885 local->total_ps_buffered--; in ieee80211_get_buffered_bc()
5887 if (!skb_queue_empty(&ps->bc_buf) && skb->len >= 2) { in ieee80211_get_buffered_bc()
5889 (struct ieee80211_hdr *) skb->data; in ieee80211_get_buffered_bc()
5893 hdr->frame_control |= in ieee80211_get_buffered_bc()
5897 if (sdata->vif.type == NL80211_IFTYPE_AP) in ieee80211_get_buffered_bc()
5898 sdata = IEEE80211_DEV_TO_SUB_IF(skb->dev); in ieee80211_get_buffered_bc()
5907 info->band = chanctx_conf->def.chan->band; in ieee80211_get_buffered_bc()
5921 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_reserve_tid()
5922 struct ieee80211_local *local = sdata->local; in ieee80211_reserve_tid()
5926 lockdep_assert_held(&local->sta_mtx); in ieee80211_reserve_tid()
5929 switch (sdata->vif.type) { in ieee80211_reserve_tid()
5936 return -EINVAL; in ieee80211_reserve_tid()
5940 return -EINVAL; in ieee80211_reserve_tid()
5942 if (sta->reserved_tid == tid) { in ieee80211_reserve_tid()
5947 if (sta->reserved_tid != IEEE80211_TID_UNRESERVED) { in ieee80211_reserve_tid()
5949 ret = -EALREADY; in ieee80211_reserve_tid()
5953 ieee80211_stop_vif_queues(sdata->local, sdata, in ieee80211_reserve_tid()
5959 if (ieee80211_hw_check(&local->hw, AMPDU_AGGREGATION)) { in ieee80211_reserve_tid()
5965 queues = BIT(sdata->vif.hw_queue[ieee802_1d_to_ac[tid]]); in ieee80211_reserve_tid()
5968 sta->reserved_tid = tid; in ieee80211_reserve_tid()
5973 if (ieee80211_hw_check(&local->hw, AMPDU_AGGREGATION)) in ieee80211_reserve_tid()
5985 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_unreserve_tid()
5987 lockdep_assert_held(&sdata->local->sta_mtx); in ieee80211_unreserve_tid()
5990 switch (sdata->vif.type) { in ieee80211_unreserve_tid()
6000 if (tid != sta->reserved_tid) { in ieee80211_unreserve_tid()
6005 sta->reserved_tid = IEEE80211_TID_UNRESERVED; in ieee80211_unreserve_tid()
6013 const struct ieee80211_hdr *hdr = (void *)skb->data; in __ieee80211_tx_skb_tid_band()
6014 int ac = ieee80211_ac_from_tid(tid); in __ieee80211_tx_skb_tid_band() local
6015 unsigned int link; in __ieee80211_tx_skb_tid_band() local
6018 skb_set_queue_mapping(skb, ac); in __ieee80211_tx_skb_tid_band()
6019 skb->priority = tid; in __ieee80211_tx_skb_tid_band()
6021 skb->dev = sdata->dev; in __ieee80211_tx_skb_tid_band()
6027 if (!ieee80211_vif_is_mld(&sdata->vif)) { in __ieee80211_tx_skb_tid_band()
6028 link = 0; in __ieee80211_tx_skb_tid_band()
6030 link = link_id; in __ieee80211_tx_skb_tid_band()
6031 } else if (memcmp(sdata->vif.addr, hdr->addr2, ETH_ALEN) == 0) { in __ieee80211_tx_skb_tid_band()
6033 link = IEEE80211_LINK_UNSPECIFIED; in __ieee80211_tx_skb_tid_band()
6035 /* otherwise must be addressed from a link */ in __ieee80211_tx_skb_tid_band()
6037 for (link = 0; link < ARRAY_SIZE(sdata->vif.link_conf); link++) { in __ieee80211_tx_skb_tid_band()
6040 link_conf = rcu_dereference(sdata->vif.link_conf[link]); in __ieee80211_tx_skb_tid_band()
6043 if (memcmp(link_conf->addr, hdr->addr2, ETH_ALEN) == 0) in __ieee80211_tx_skb_tid_band()
6048 if (WARN_ON_ONCE(link == ARRAY_SIZE(sdata->vif.link_conf))) in __ieee80211_tx_skb_tid_band()
6049 link = ffs(sdata->vif.active_links) - 1; in __ieee80211_tx_skb_tid_band()
6052 IEEE80211_SKB_CB(skb)->control.flags |= in __ieee80211_tx_skb_tid_band()
6053 u32_encode_bits(link, IEEE80211_TX_CTRL_MLO_LINK); in __ieee80211_tx_skb_tid_band()
6061 IEEE80211_SKB_CB(skb)->band = band; in __ieee80211_tx_skb_tid_band()
6073 if (!ieee80211_vif_is_mld(&sdata->vif)) { in ieee80211_tx_skb_tid()
6076 rcu_dereference(sdata->vif.bss_conf.chanctx_conf); in ieee80211_tx_skb_tid()
6082 band = chanctx_conf->def.chan->band; in ieee80211_tx_skb_tid()
6085 !(sdata->vif.active_links & BIT(link_id))); in ieee80211_tx_skb_tid()
6100 struct ieee80211_local *local = sdata->local; in ieee80211_tx_control_port()
6109 * or Pre-Authentication in ieee80211_tx_control_port()
6111 if (proto != sdata->control_port_protocol && in ieee80211_tx_control_port()
6113 return -EINVAL; in ieee80211_tx_control_port()
6115 if (proto == sdata->control_port_protocol) in ieee80211_tx_control_port()
6127 skb = dev_alloc_skb(local->hw.extra_tx_headroom + in ieee80211_tx_control_port()
6130 return -ENOMEM; in ieee80211_tx_control_port()
6132 skb_reserve(skb, local->hw.extra_tx_headroom + sizeof(struct ethhdr)); in ieee80211_tx_control_port()
6137 memcpy(ehdr->h_dest, dest, ETH_ALEN); in ieee80211_tx_control_port()
6143 memcpy(ehdr->h_source, sdata->vif.addr, ETH_ALEN); in ieee80211_tx_control_port()
6151 link_conf = rcu_dereference(sdata->vif.link_conf[link_id]); in ieee80211_tx_control_port()
6155 return -ENOLINK; in ieee80211_tx_control_port()
6157 memcpy(ehdr->h_source, link_conf->addr, ETH_ALEN); in ieee80211_tx_control_port()
6161 ehdr->h_proto = proto; in ieee80211_tx_control_port()
6163 skb->dev = dev; in ieee80211_tx_control_port()
6164 skb->protocol = proto; in ieee80211_tx_control_port()
6168 if (local->hw.queues < IEEE80211_NUM_ACS) in ieee80211_tx_control_port()
6190 * the link ID has been selected already in ieee80211_tx_control_port()
6192 if (sta && sta->sta.mlo) in ieee80211_tx_control_port()
6193 memcpy(ehdr->h_source, sdata->vif.addr, ETH_ALEN); in ieee80211_tx_control_port()
6199 mutex_lock(&local->mtx); in ieee80211_tx_control_port()
6202 __ieee80211_subif_start_xmit(skb, skb->dev, flags, ctrl_flags, cookie); in ieee80211_tx_control_port()
6205 mutex_unlock(&local->mtx); in ieee80211_tx_control_port()
6214 struct ieee80211_local *local = sdata->local; in ieee80211_probe_mesh_link()
6217 skb = dev_alloc_skb(local->hw.extra_tx_headroom + len + in ieee80211_probe_mesh_link()
6221 return -ENOMEM; in ieee80211_probe_mesh_link()
6223 skb_reserve(skb, local->hw.extra_tx_headroom); in ieee80211_probe_mesh_link()
6226 skb->dev = dev; in ieee80211_probe_mesh_link()
6227 skb->protocol = htons(ETH_P_802_3); in ieee80211_probe_mesh_link()
6232 __ieee80211_subif_start_xmit(skb, skb->dev, 0, in ieee80211_probe_mesh_link()