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 rate_flags = ieee80211_chandef_rate_flags(&chanctx_conf->def); in ieee80211_duration()
66 if (WARN_ON_ONCE(tx->rate.idx < 0)) in ieee80211_duration()
69 sband = local->hw.wiphy->bands[info->band]; in ieee80211_duration()
70 txrate = &sband->bitrates[tx->rate.idx]; in ieee80211_duration()
72 erp = txrate->flags & IEEE80211_RATE_ERP_G; in ieee80211_duration()
75 if (sband->band == NL80211_BAND_S1GHZ) in ieee80211_duration()
80 * - during CFP: 32768 in ieee80211_duration()
81 * - during contention period: in ieee80211_duration()
89 * - control response frame (CTS or ACK) shall be transmitted using the in ieee80211_duration()
95 hdr = (struct ieee80211_hdr *)skb->data; in ieee80211_duration()
96 if (ieee80211_is_ctl(hdr->frame_control)) { in ieee80211_duration()
118 if (group_addr) /* Group address as the destination - no ACK */ in ieee80211_duration()
131 rate = -1; in ieee80211_duration()
133 mrate = sband->bitrates[0].bitrate; in ieee80211_duration()
134 for (i = 0; i < sband->n_bitrates; i++) { in ieee80211_duration()
135 struct ieee80211_rate *r = &sband->bitrates[i]; in ieee80211_duration()
138 if (r->bitrate > txrate->bitrate) in ieee80211_duration()
141 if ((rate_flags & r->flags) != rate_flags) in ieee80211_duration()
144 if (tx->sdata->vif.bss_conf.basic_rates & BIT(i)) in ieee80211_duration()
145 rate = r->bitrate; in ieee80211_duration()
147 switch (sband->band) { in ieee80211_duration()
150 if (tx->sdata->deflink.operating_11g_mode) in ieee80211_duration()
165 if (r->flags & flag) in ieee80211_duration()
166 mrate = r->bitrate; in ieee80211_duration()
168 if (rate == -1) { in ieee80211_duration()
175 if (ieee80211_is_data_qos(hdr->frame_control) && in ieee80211_duration()
180 * (10 bytes + 4-byte FCS = 112 bits) plus SIFS; rounded up in ieee80211_duration()
182 dur = ieee80211_frame_duration(sband->band, 10, rate, erp, in ieee80211_duration()
183 tx->sdata->vif.bss_conf.use_short_preamble); in ieee80211_duration()
190 dur += ieee80211_frame_duration(sband->band, next_frag_len, in ieee80211_duration()
191 txrate->bitrate, erp, in ieee80211_duration()
192 tx->sdata->vif.bss_conf.use_short_preamble); in ieee80211_duration()
202 struct ieee80211_local *local = tx->local; in ieee80211_tx_h_dynamic_ps()
204 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); in ieee80211_tx_h_dynamic_ps()
207 if (!ieee80211_hw_check(&local->hw, SUPPORTS_PS)) in ieee80211_tx_h_dynamic_ps()
211 if (ieee80211_hw_check(&local->hw, SUPPORTS_DYNAMIC_PS)) in ieee80211_tx_h_dynamic_ps()
215 if (local->hw.conf.dynamic_ps_timeout <= 0) in ieee80211_tx_h_dynamic_ps()
219 if (local->scanning) in ieee80211_tx_h_dynamic_ps()
222 if (!local->ps_sdata) in ieee80211_tx_h_dynamic_ps()
226 if (local->quiescing) in ieee80211_tx_h_dynamic_ps()
230 if (tx->sdata->vif.type != NL80211_IFTYPE_STATION) in ieee80211_tx_h_dynamic_ps()
233 if (unlikely(info->flags & IEEE80211_TX_INTFL_OFFCHAN_TX_OK)) in ieee80211_tx_h_dynamic_ps()
236 ifmgd = &tx->sdata->u.mgd; in ieee80211_tx_h_dynamic_ps()
239 * Don't wakeup from power save if u-apsd is enabled, voip ac has in ieee80211_tx_h_dynamic_ps()
240 * u-apsd enabled and the frame is in voip class. This effectively in ieee80211_tx_h_dynamic_ps()
241 * means that even if all access categories have u-apsd enabled, in in ieee80211_tx_h_dynamic_ps()
242 * practise u-apsd is only used with the voip ac. This is a in ieee80211_tx_h_dynamic_ps()
247 * Note: ifmgd->uapsd_queues access is racy here. If the value is in ieee80211_tx_h_dynamic_ps()
251 if ((ifmgd->flags & IEEE80211_STA_UAPSD_ENABLED) && in ieee80211_tx_h_dynamic_ps()
252 (ifmgd->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VO) && in ieee80211_tx_h_dynamic_ps()
253 skb_get_queue_mapping(tx->skb) == IEEE80211_AC_VO) in ieee80211_tx_h_dynamic_ps()
256 if (local->hw.conf.flags & IEEE80211_CONF_PS) { in ieee80211_tx_h_dynamic_ps()
257 ieee80211_stop_queues_by_reason(&local->hw, in ieee80211_tx_h_dynamic_ps()
261 ifmgd->flags &= ~IEEE80211_STA_NULLFUNC_ACKED; in ieee80211_tx_h_dynamic_ps()
262 wiphy_work_queue(local->hw.wiphy, in ieee80211_tx_h_dynamic_ps()
263 &local->dynamic_ps_disable_work); in ieee80211_tx_h_dynamic_ps()
267 if (!ifmgd->associated) in ieee80211_tx_h_dynamic_ps()
270 mod_timer(&local->dynamic_ps_timer, jiffies + in ieee80211_tx_h_dynamic_ps()
271 msecs_to_jiffies(local->hw.conf.dynamic_ps_timeout)); in ieee80211_tx_h_dynamic_ps()
280 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; in ieee80211_tx_h_check_assoc()
281 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); in ieee80211_tx_h_check_assoc()
284 if (unlikely(info->flags & IEEE80211_TX_CTL_INJECTED)) in ieee80211_tx_h_check_assoc()
287 if (unlikely(test_bit(SCAN_SW_SCANNING, &tx->local->scanning)) && in ieee80211_tx_h_check_assoc()
288 test_bit(SDATA_STATE_OFFCHANNEL, &tx->sdata->state) && in ieee80211_tx_h_check_assoc()
289 !ieee80211_is_probe_req(hdr->frame_control) && in ieee80211_tx_h_check_assoc()
290 !ieee80211_is_any_nullfunc(hdr->frame_control)) in ieee80211_tx_h_check_assoc()
297 * off-channel. See the link below and in ieee80211_tx_h_check_assoc()
304 if (tx->sdata->vif.type == NL80211_IFTYPE_OCB) in ieee80211_tx_h_check_assoc()
307 if (tx->flags & IEEE80211_TX_PS_BUFFERED) in ieee80211_tx_h_check_assoc()
310 if (tx->sta) in ieee80211_tx_h_check_assoc()
311 assoc = test_sta_flag(tx->sta, WLAN_STA_ASSOC); in ieee80211_tx_h_check_assoc()
313 if (likely(tx->flags & IEEE80211_TX_UNICAST)) { in ieee80211_tx_h_check_assoc()
315 ieee80211_is_data(hdr->frame_control))) { in ieee80211_tx_h_check_assoc()
317 sdata_info(tx->sdata, in ieee80211_tx_h_check_assoc()
319 hdr->addr1); in ieee80211_tx_h_check_assoc()
321 I802_DEBUG_INC(tx->local->tx_handlers_drop_not_assoc); in ieee80211_tx_h_check_assoc()
324 } else if (unlikely(ieee80211_is_data(hdr->frame_control) && in ieee80211_tx_h_check_assoc()
325 ieee80211_vif_get_num_mcast_if(tx->sdata) == 0)) { in ieee80211_tx_h_check_assoc()
327 * No associated STAs - no need to send multicast in ieee80211_tx_h_check_assoc()
347 list_for_each_entry_rcu(sdata, &local->interfaces, list) { in purge_old_ps_buffers()
350 if (sdata->vif.type == NL80211_IFTYPE_AP) in purge_old_ps_buffers()
351 ps = &sdata->u.ap.ps; in purge_old_ps_buffers()
352 else if (ieee80211_vif_is_mesh(&sdata->vif)) in purge_old_ps_buffers()
353 ps = &sdata->u.mesh.ps; in purge_old_ps_buffers()
357 skb = skb_dequeue(&ps->bc_buf); in purge_old_ps_buffers()
360 ieee80211_free_txskb(&local->hw, skb); in purge_old_ps_buffers()
362 total += skb_queue_len(&ps->bc_buf); in purge_old_ps_buffers()
366 * Drop one frame from each station from the lowest-priority in purge_old_ps_buffers()
367 * AC that has frames at all. in purge_old_ps_buffers()
369 list_for_each_entry_rcu(sta, &local->sta_list, list) { in purge_old_ps_buffers()
370 int ac; in purge_old_ps_buffers() local
372 for (ac = IEEE80211_AC_BK; ac >= IEEE80211_AC_VO; ac--) { in purge_old_ps_buffers()
373 skb = skb_dequeue(&sta->ps_tx_buf[ac]); in purge_old_ps_buffers()
374 total += skb_queue_len(&sta->ps_tx_buf[ac]); in purge_old_ps_buffers()
377 ieee80211_free_txskb(&local->hw, skb); in purge_old_ps_buffers()
383 local->total_ps_buffered = total; in purge_old_ps_buffers()
384 ps_dbg_hw(&local->hw, "PS buffers full - purged %d frames\n", purged); in purge_old_ps_buffers()
390 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); in ieee80211_tx_h_multicast_ps_buf()
391 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; in ieee80211_tx_h_multicast_ps_buf()
403 if (tx->sdata->vif.type == NL80211_IFTYPE_AP || in ieee80211_tx_h_multicast_ps_buf()
404 tx->sdata->vif.type == NL80211_IFTYPE_AP_VLAN) { in ieee80211_tx_h_multicast_ps_buf()
405 if (!tx->sdata->bss) in ieee80211_tx_h_multicast_ps_buf()
408 ps = &tx->sdata->bss->ps; in ieee80211_tx_h_multicast_ps_buf()
409 } else if (ieee80211_vif_is_mesh(&tx->sdata->vif)) { in ieee80211_tx_h_multicast_ps_buf()
410 ps = &tx->sdata->u.mesh.ps; in ieee80211_tx_h_multicast_ps_buf()
417 if (ieee80211_has_order(hdr->frame_control)) in ieee80211_tx_h_multicast_ps_buf()
420 if (ieee80211_is_probe_req(hdr->frame_control)) in ieee80211_tx_h_multicast_ps_buf()
423 if (ieee80211_hw_check(&tx->local->hw, QUEUE_CONTROL)) in ieee80211_tx_h_multicast_ps_buf()
424 info->hw_queue = tx->sdata->vif.cab_queue; in ieee80211_tx_h_multicast_ps_buf()
427 if (!atomic_read(&ps->num_sta_ps) && skb_queue_empty(&ps->bc_buf)) in ieee80211_tx_h_multicast_ps_buf()
430 info->flags |= IEEE80211_TX_CTL_SEND_AFTER_DTIM; in ieee80211_tx_h_multicast_ps_buf()
433 if (!ieee80211_hw_check(&tx->local->hw, HOST_BROADCAST_PS_BUFFERING)) in ieee80211_tx_h_multicast_ps_buf()
437 if (tx->local->total_ps_buffered >= TOTAL_MAX_TX_BUFFER) in ieee80211_tx_h_multicast_ps_buf()
438 purge_old_ps_buffers(tx->local); in ieee80211_tx_h_multicast_ps_buf()
440 if (skb_queue_len(&ps->bc_buf) >= AP_MAX_BC_BUFFER) { in ieee80211_tx_h_multicast_ps_buf()
441 ps_dbg(tx->sdata, in ieee80211_tx_h_multicast_ps_buf()
442 "BC TX buffer full - dropping the oldest frame\n"); in ieee80211_tx_h_multicast_ps_buf()
443 ieee80211_free_txskb(&tx->local->hw, skb_dequeue(&ps->bc_buf)); in ieee80211_tx_h_multicast_ps_buf()
445 tx->local->total_ps_buffered++; in ieee80211_tx_h_multicast_ps_buf()
447 skb_queue_tail(&ps->bc_buf, tx->skb); in ieee80211_tx_h_multicast_ps_buf()
470 struct sta_info *sta = tx->sta; in ieee80211_tx_h_unicast_ps_buf()
471 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); in ieee80211_tx_h_unicast_ps_buf()
472 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; in ieee80211_tx_h_unicast_ps_buf()
473 struct ieee80211_local *local = tx->local; in ieee80211_tx_h_unicast_ps_buf()
481 !(info->flags & IEEE80211_TX_CTL_NO_PS_BUFFER))) { in ieee80211_tx_h_unicast_ps_buf()
482 int ac = skb_get_queue_mapping(tx->skb); in ieee80211_tx_h_unicast_ps_buf() local
484 if (ieee80211_is_mgmt(hdr->frame_control) && in ieee80211_tx_h_unicast_ps_buf()
485 !ieee80211_is_bufferable_mmpdu(tx->skb)) { in ieee80211_tx_h_unicast_ps_buf()
486 info->flags |= IEEE80211_TX_CTL_NO_PS_BUFFER; in ieee80211_tx_h_unicast_ps_buf()
490 ps_dbg(sta->sdata, "STA %pM aid %d: PS buffer for AC %d\n", in ieee80211_tx_h_unicast_ps_buf()
491 sta->sta.addr, sta->sta.aid, ac); in ieee80211_tx_h_unicast_ps_buf()
492 if (tx->local->total_ps_buffered >= TOTAL_MAX_TX_BUFFER) in ieee80211_tx_h_unicast_ps_buf()
493 purge_old_ps_buffers(tx->local); in ieee80211_tx_h_unicast_ps_buf()
496 spin_lock(&sta->ps_lock); in ieee80211_tx_h_unicast_ps_buf()
505 spin_unlock(&sta->ps_lock); in ieee80211_tx_h_unicast_ps_buf()
509 if (skb_queue_len(&sta->ps_tx_buf[ac]) >= STA_MAX_TX_BUFFER) { in ieee80211_tx_h_unicast_ps_buf()
510 struct sk_buff *old = skb_dequeue(&sta->ps_tx_buf[ac]); in ieee80211_tx_h_unicast_ps_buf()
511 ps_dbg(tx->sdata, in ieee80211_tx_h_unicast_ps_buf()
512 "STA %pM TX buffer for AC %d full - dropping oldest frame\n", in ieee80211_tx_h_unicast_ps_buf()
513 sta->sta.addr, ac); in ieee80211_tx_h_unicast_ps_buf()
514 ieee80211_free_txskb(&local->hw, old); in ieee80211_tx_h_unicast_ps_buf()
516 tx->local->total_ps_buffered++; in ieee80211_tx_h_unicast_ps_buf()
518 info->control.jiffies = jiffies; in ieee80211_tx_h_unicast_ps_buf()
519 info->control.vif = &tx->sdata->vif; in ieee80211_tx_h_unicast_ps_buf()
520 info->control.flags |= IEEE80211_TX_INTCFL_NEED_TXPROCESSING; in ieee80211_tx_h_unicast_ps_buf()
521 info->flags &= ~IEEE80211_TX_TEMPORARY_FLAGS; in ieee80211_tx_h_unicast_ps_buf()
522 skb_queue_tail(&sta->ps_tx_buf[ac], tx->skb); in ieee80211_tx_h_unicast_ps_buf()
523 spin_unlock(&sta->ps_lock); in ieee80211_tx_h_unicast_ps_buf()
525 if (!timer_pending(&local->sta_cleanup)) in ieee80211_tx_h_unicast_ps_buf()
526 mod_timer(&local->sta_cleanup, in ieee80211_tx_h_unicast_ps_buf()
538 ps_dbg(tx->sdata, in ieee80211_tx_h_unicast_ps_buf()
539 "STA %pM in PS mode, but polling/in SP -> send frame\n", in ieee80211_tx_h_unicast_ps_buf()
540 sta->sta.addr); in ieee80211_tx_h_unicast_ps_buf()
549 if (unlikely(tx->flags & IEEE80211_TX_PS_BUFFERED)) in ieee80211_tx_h_ps_buf()
552 if (tx->flags & IEEE80211_TX_UNICAST) in ieee80211_tx_h_ps_buf()
561 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); in ieee80211_tx_h_check_control_port_protocol()
563 if (unlikely(tx->sdata->control_port_protocol == tx->skb->protocol)) { in ieee80211_tx_h_check_control_port_protocol()
564 if (tx->sdata->control_port_no_encrypt) in ieee80211_tx_h_check_control_port_protocol()
565 info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; in ieee80211_tx_h_check_control_port_protocol()
566 info->control.flags |= IEEE80211_TX_CTRL_PORT_CTRL_PROTO; in ieee80211_tx_h_check_control_port_protocol()
567 info->flags |= IEEE80211_TX_CTL_USE_MINRATE; in ieee80211_tx_h_check_control_port_protocol()
576 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; in ieee80211_select_link_key()
577 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); in ieee80211_select_link_key()
578 struct ieee80211_link_data *link; in ieee80211_select_link_key() local
581 link_id = u32_get_bits(info->control.flags, IEEE80211_TX_CTRL_MLO_LINK); in ieee80211_select_link_key()
583 link = &tx->sdata->deflink; in ieee80211_select_link_key()
585 link = rcu_dereference(tx->sdata->link[link_id]); in ieee80211_select_link_key()
586 if (!link) in ieee80211_select_link_key()
590 if (ieee80211_is_group_privacy_action(tx->skb)) in ieee80211_select_link_key()
591 return rcu_dereference(link->default_multicast_key); in ieee80211_select_link_key()
592 else if (ieee80211_is_mgmt(hdr->frame_control) && in ieee80211_select_link_key()
593 is_multicast_ether_addr(hdr->addr1) && in ieee80211_select_link_key()
594 ieee80211_is_robust_mgmt_frame(tx->skb)) in ieee80211_select_link_key()
595 return rcu_dereference(link->default_mgmt_key); in ieee80211_select_link_key()
596 else if (is_multicast_ether_addr(hdr->addr1)) in ieee80211_select_link_key()
597 return rcu_dereference(link->default_multicast_key); in ieee80211_select_link_key()
606 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); in ieee80211_tx_h_select_key()
607 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; in ieee80211_tx_h_select_key()
609 if (unlikely(info->flags & IEEE80211_TX_INTFL_DONT_ENCRYPT)) { in ieee80211_tx_h_select_key()
610 tx->key = NULL; in ieee80211_tx_h_select_key()
614 if (tx->sta && in ieee80211_tx_h_select_key()
615 (key = rcu_dereference(tx->sta->ptk[tx->sta->ptk_idx]))) in ieee80211_tx_h_select_key()
616 tx->key = key; in ieee80211_tx_h_select_key()
618 tx->key = key; in ieee80211_tx_h_select_key()
619 else if (!is_multicast_ether_addr(hdr->addr1) && in ieee80211_tx_h_select_key()
620 (key = rcu_dereference(tx->sdata->default_unicast_key))) in ieee80211_tx_h_select_key()
621 tx->key = key; in ieee80211_tx_h_select_key()
623 tx->key = NULL; in ieee80211_tx_h_select_key()
625 if (tx->key) { in ieee80211_tx_h_select_key()
630 switch (tx->key->conf.cipher) { in ieee80211_tx_h_select_key()
634 if (!ieee80211_is_data_present(hdr->frame_control)) in ieee80211_tx_h_select_key()
635 tx->key = NULL; in ieee80211_tx_h_select_key()
641 if (!ieee80211_is_data_present(hdr->frame_control) && in ieee80211_tx_h_select_key()
642 !ieee80211_use_mfp(hdr->frame_control, tx->sta, in ieee80211_tx_h_select_key()
643 tx->skb) && in ieee80211_tx_h_select_key()
644 !ieee80211_is_group_privacy_action(tx->skb)) in ieee80211_tx_h_select_key()
645 tx->key = NULL; in ieee80211_tx_h_select_key()
647 skip_hw = (tx->key->conf.flags & in ieee80211_tx_h_select_key()
649 ieee80211_is_mgmt(hdr->frame_control); in ieee80211_tx_h_select_key()
655 if (!ieee80211_is_mgmt(hdr->frame_control)) in ieee80211_tx_h_select_key()
656 tx->key = NULL; in ieee80211_tx_h_select_key()
660 if (unlikely(tx->key && tx->key->flags & KEY_FLAG_TAINTED && in ieee80211_tx_h_select_key()
661 !ieee80211_is_deauth(hdr->frame_control)) && in ieee80211_tx_h_select_key()
662 tx->skb->protocol != tx->sdata->control_port_protocol) in ieee80211_tx_h_select_key()
665 if (!skip_hw && tx->key && in ieee80211_tx_h_select_key()
666 tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) in ieee80211_tx_h_select_key()
667 info->control.hw_key = &tx->key->conf; in ieee80211_tx_h_select_key()
668 } else if (ieee80211_is_data_present(hdr->frame_control) && tx->sta && in ieee80211_tx_h_select_key()
669 test_sta_flag(tx->sta, WLAN_STA_USES_ENCRYPTION)) { in ieee80211_tx_h_select_key()
679 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); in ieee80211_tx_h_rate_ctrl()
680 struct ieee80211_hdr *hdr = (void *)tx->skb->data; in ieee80211_tx_h_rate_ctrl()
685 bool encap = info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP; in ieee80211_tx_h_rate_ctrl()
690 sband = tx->local->hw.wiphy->bands[info->band]; in ieee80211_tx_h_rate_ctrl()
692 len = min_t(u32, tx->skb->len + FCS_LEN, in ieee80211_tx_h_rate_ctrl()
693 tx->local->hw.wiphy->frag_threshold); in ieee80211_tx_h_rate_ctrl()
696 txrc.hw = &tx->local->hw; in ieee80211_tx_h_rate_ctrl()
698 txrc.bss_conf = &tx->sdata->vif.bss_conf; in ieee80211_tx_h_rate_ctrl()
699 txrc.skb = tx->skb; in ieee80211_tx_h_rate_ctrl()
700 txrc.reported_rate.idx = -1; in ieee80211_tx_h_rate_ctrl()
702 if (unlikely(info->control.flags & IEEE80211_TX_CTRL_DONT_USE_RATE_MASK)) { in ieee80211_tx_h_rate_ctrl()
705 txrc.rate_idx_mask = tx->sdata->rc_rateidx_mask[info->band]; in ieee80211_tx_h_rate_ctrl()
707 if (tx->sdata->rc_has_mcs_mask[info->band]) in ieee80211_tx_h_rate_ctrl()
709 tx->sdata->rc_rateidx_mcs_mask[info->band]; in ieee80211_tx_h_rate_ctrl()
712 txrc.bss = (tx->sdata->vif.type == NL80211_IFTYPE_AP || in ieee80211_tx_h_rate_ctrl()
713 tx->sdata->vif.type == NL80211_IFTYPE_MESH_POINT || in ieee80211_tx_h_rate_ctrl()
714 tx->sdata->vif.type == NL80211_IFTYPE_ADHOC || in ieee80211_tx_h_rate_ctrl()
715 tx->sdata->vif.type == NL80211_IFTYPE_OCB); in ieee80211_tx_h_rate_ctrl()
718 if (len > tx->local->hw.wiphy->rts_threshold) { in ieee80211_tx_h_rate_ctrl()
722 info->control.use_rts = txrc.rts; in ieee80211_tx_h_rate_ctrl()
723 info->control.use_cts_prot = tx->sdata->vif.bss_conf.use_cts_prot; in ieee80211_tx_h_rate_ctrl()
728 * that -- the management frame might be to a station that in ieee80211_tx_h_rate_ctrl()
731 if (tx->sdata->vif.bss_conf.use_short_preamble && in ieee80211_tx_h_rate_ctrl()
732 (ieee80211_is_tx_data(tx->skb) || in ieee80211_tx_h_rate_ctrl()
733 (tx->sta && test_sta_flag(tx->sta, WLAN_STA_SHORT_PREAMBLE)))) in ieee80211_tx_h_rate_ctrl()
736 info->control.short_preamble = txrc.short_preamble; in ieee80211_tx_h_rate_ctrl()
739 if (info->control.flags & IEEE80211_TX_CTRL_RATE_INJECT) in ieee80211_tx_h_rate_ctrl()
742 if (tx->sta) in ieee80211_tx_h_rate_ctrl()
743 assoc = test_sta_flag(tx->sta, WLAN_STA_ASSOC); in ieee80211_tx_h_rate_ctrl()
749 if (WARN(test_bit(SCAN_SW_SCANNING, &tx->local->scanning) && assoc && in ieee80211_tx_h_rate_ctrl()
750 !rate_usable_index_exists(sband, &tx->sta->sta), in ieee80211_tx_h_rate_ctrl()
754 tx->sdata->name, in ieee80211_tx_h_rate_ctrl()
755 encap ? ((struct ethhdr *)hdr)->h_dest : hdr->addr1, in ieee80211_tx_h_rate_ctrl()
756 info->band ? 5 : 2)) in ieee80211_tx_h_rate_ctrl()
763 rate_control_get_rate(tx->sdata, tx->sta, &txrc); in ieee80211_tx_h_rate_ctrl()
765 if (tx->sta && !info->control.skip_table) in ieee80211_tx_h_rate_ctrl()
766 ratetbl = rcu_dereference(tx->sta->sta.rates); in ieee80211_tx_h_rate_ctrl()
768 if (unlikely(info->control.rates[0].idx < 0)) { in ieee80211_tx_h_rate_ctrl()
771 .idx = ratetbl->rate[0].idx, in ieee80211_tx_h_rate_ctrl()
772 .flags = ratetbl->rate[0].flags, in ieee80211_tx_h_rate_ctrl()
773 .count = ratetbl->rate[0].count in ieee80211_tx_h_rate_ctrl()
776 if (ratetbl->rate[0].idx < 0) in ieee80211_tx_h_rate_ctrl()
779 tx->rate = rate; in ieee80211_tx_h_rate_ctrl()
784 tx->rate = info->control.rates[0]; in ieee80211_tx_h_rate_ctrl()
788 txrc.reported_rate = tx->rate; in ieee80211_tx_h_rate_ctrl()
789 if (tx->sta && ieee80211_is_tx_data(tx->skb)) in ieee80211_tx_h_rate_ctrl()
790 tx->sta->deflink.tx_stats.last_rate = txrc.reported_rate; in ieee80211_tx_h_rate_ctrl()
791 } else if (tx->sta) in ieee80211_tx_h_rate_ctrl()
792 tx->sta->deflink.tx_stats.last_rate = txrc.reported_rate; in ieee80211_tx_h_rate_ctrl()
797 if (unlikely(!info->control.rates[0].count)) in ieee80211_tx_h_rate_ctrl()
798 info->control.rates[0].count = 1; in ieee80211_tx_h_rate_ctrl()
800 if (WARN_ON_ONCE((info->control.rates[0].count > 1) && in ieee80211_tx_h_rate_ctrl()
801 (info->flags & IEEE80211_TX_CTL_NO_ACK))) in ieee80211_tx_h_rate_ctrl()
802 info->control.rates[0].count = 1; in ieee80211_tx_h_rate_ctrl()
809 u16 *seq = &sta->tid_seq[tid]; in ieee80211_tx_next_seq()
821 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); in ieee80211_tx_h_sequence()
822 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; in ieee80211_tx_h_sequence()
830 if (unlikely(info->control.vif->type == NL80211_IFTYPE_MONITOR)) in ieee80211_tx_h_sequence()
833 if (unlikely(ieee80211_is_ctl(hdr->frame_control))) in ieee80211_tx_h_sequence()
836 if (ieee80211_hdrlen(hdr->frame_control) < 24) in ieee80211_tx_h_sequence()
839 if (ieee80211_is_qos_nullfunc(hdr->frame_control)) in ieee80211_tx_h_sequence()
842 if (info->control.flags & IEEE80211_TX_CTRL_NO_SEQNO) in ieee80211_tx_h_sequence()
846 if (unlikely(is_multicast_ether_addr(hdr->addr1) && in ieee80211_tx_h_sequence()
847 ieee80211_vif_is_mld(info->control.vif) && in ieee80211_tx_h_sequence()
848 info->control.vif->type == NL80211_IFTYPE_AP)) { in ieee80211_tx_h_sequence()
849 if (info->control.flags & IEEE80211_TX_CTRL_MCAST_MLO_FIRST_TX) in ieee80211_tx_h_sequence()
850 tx->sdata->mld_mcast_seq += 0x10; in ieee80211_tx_h_sequence()
851 hdr->seq_ctrl = cpu_to_le16(tx->sdata->mld_mcast_seq); in ieee80211_tx_h_sequence()
859 * also use the global counter (802.11-2012 9.3.2.10). in ieee80211_tx_h_sequence()
861 if (!ieee80211_is_data_qos(hdr->frame_control) || in ieee80211_tx_h_sequence()
862 is_multicast_ether_addr(hdr->addr1)) { in ieee80211_tx_h_sequence()
864 info->flags |= IEEE80211_TX_CTL_ASSIGN_SEQ; in ieee80211_tx_h_sequence()
866 hdr->seq_ctrl = cpu_to_le16(tx->sdata->sequence_number); in ieee80211_tx_h_sequence()
867 tx->sdata->sequence_number += 0x10; in ieee80211_tx_h_sequence()
868 if (tx->sta) in ieee80211_tx_h_sequence()
869 tx->sta->deflink.tx_stats.msdu[IEEE80211_NUM_TIDS]++; in ieee80211_tx_h_sequence()
876 * above since they are not QoS-data frames. in ieee80211_tx_h_sequence()
878 if (!tx->sta) in ieee80211_tx_h_sequence()
881 /* include per-STA, per-TID sequence counter */ in ieee80211_tx_h_sequence()
883 tx->sta->deflink.tx_stats.msdu[tid]++; in ieee80211_tx_h_sequence()
885 hdr->seq_ctrl = ieee80211_tx_next_seq(tx->sta, tid); in ieee80211_tx_h_sequence()
894 struct ieee80211_local *local = tx->local; in ieee80211_fragment()
897 int per_fragm = frag_threshold - hdrlen - FCS_LEN; in ieee80211_fragment()
899 int rem = skb->len - hdrlen - per_fragm; in ieee80211_fragment()
902 return -EINVAL; in ieee80211_fragment()
911 rem -= fraglen; in ieee80211_fragment()
912 tmp = dev_alloc_skb(local->tx_headroom + in ieee80211_fragment()
917 return -ENOMEM; in ieee80211_fragment()
919 __skb_queue_tail(&tx->skbs, tmp); in ieee80211_fragment()
922 local->tx_headroom + IEEE80211_ENCRYPT_HEADROOM); in ieee80211_fragment()
925 memcpy(tmp->cb, skb->cb, sizeof(tmp->cb)); in ieee80211_fragment()
928 info->flags &= ~(IEEE80211_TX_CTL_CLEAR_PS_FILT | in ieee80211_fragment()
932 info->flags |= IEEE80211_TX_CTL_MORE_FRAMES; in ieee80211_fragment()
935 tmp->priority = skb->priority; in ieee80211_fragment()
936 tmp->dev = skb->dev; in ieee80211_fragment()
939 skb_put_data(tmp, skb->data, hdrlen); in ieee80211_fragment()
940 skb_put_data(tmp, skb->data + pos, fraglen); in ieee80211_fragment()
953 struct sk_buff *skb = tx->skb; in ieee80211_tx_h_fragment()
955 struct ieee80211_hdr *hdr = (void *)skb->data; in ieee80211_tx_h_fragment()
956 int frag_threshold = tx->local->hw.wiphy->frag_threshold; in ieee80211_tx_h_fragment()
960 /* no matter what happens, tx->skb moves to tx->skbs */ in ieee80211_tx_h_fragment()
961 __skb_queue_tail(&tx->skbs, skb); in ieee80211_tx_h_fragment()
962 tx->skb = NULL; in ieee80211_tx_h_fragment()
964 if (info->flags & IEEE80211_TX_CTL_DONTFRAG) in ieee80211_tx_h_fragment()
967 if (ieee80211_hw_check(&tx->local->hw, SUPPORTS_TX_FRAG)) in ieee80211_tx_h_fragment()
971 * Warn when submitting a fragmented A-MPDU frame and drop it. in ieee80211_tx_h_fragment()
975 if (WARN_ON(info->flags & IEEE80211_TX_CTL_AMPDU)) in ieee80211_tx_h_fragment()
978 hdrlen = ieee80211_hdrlen(hdr->frame_control); in ieee80211_tx_h_fragment()
981 if (WARN_ON(skb->len + FCS_LEN <= frag_threshold)) in ieee80211_tx_h_fragment()
986 * chain them (using skb as the first fragment) to skb->next. in ieee80211_tx_h_fragment()
988 * fragments from this list. When the low-level driver rejects one in ieee80211_tx_h_fragment()
998 skb_queue_walk(&tx->skbs, skb) { in ieee80211_tx_h_fragment()
1001 hdr = (void *)skb->data; in ieee80211_tx_h_fragment()
1004 if (!skb_queue_is_last(&tx->skbs, skb)) { in ieee80211_tx_h_fragment()
1005 hdr->frame_control |= morefrags; in ieee80211_tx_h_fragment()
1007 * No multi-rate retries for fragmented frames, that in ieee80211_tx_h_fragment()
1010 info->control.rates[1].idx = -1; in ieee80211_tx_h_fragment()
1011 info->control.rates[2].idx = -1; in ieee80211_tx_h_fragment()
1012 info->control.rates[3].idx = -1; in ieee80211_tx_h_fragment()
1014 info->flags &= ~IEEE80211_TX_CTL_RATE_CTRL_PROBE; in ieee80211_tx_h_fragment()
1016 hdr->frame_control &= ~morefrags; in ieee80211_tx_h_fragment()
1018 hdr->seq_ctrl |= cpu_to_le16(fragnum & IEEE80211_SCTL_FRAG); in ieee80211_tx_h_fragment()
1029 int ac = -1; in ieee80211_tx_h_stats() local
1031 if (!tx->sta) in ieee80211_tx_h_stats()
1034 skb_queue_walk(&tx->skbs, skb) { in ieee80211_tx_h_stats()
1035 ac = skb_get_queue_mapping(skb); in ieee80211_tx_h_stats()
1036 tx->sta->deflink.tx_stats.bytes[ac] += skb->len; in ieee80211_tx_h_stats()
1038 if (ac >= 0) in ieee80211_tx_h_stats()
1039 tx->sta->deflink.tx_stats.packets[ac]++; in ieee80211_tx_h_stats()
1047 if (!tx->key) in ieee80211_tx_h_encrypt()
1050 switch (tx->key->conf.cipher) { in ieee80211_tx_h_encrypt()
1085 skb_queue_walk(&tx->skbs, skb) { in ieee80211_tx_h_calculate_duration()
1086 hdr = (void *) skb->data; in ieee80211_tx_h_calculate_duration()
1087 if (unlikely(ieee80211_is_pspoll(hdr->frame_control))) in ieee80211_tx_h_calculate_duration()
1089 if (!skb_queue_is_last(&tx->skbs, skb)) { in ieee80211_tx_h_calculate_duration()
1090 struct sk_buff *next = skb_queue_next(&tx->skbs, skb); in ieee80211_tx_h_calculate_duration()
1091 next_len = next->len; in ieee80211_tx_h_calculate_duration()
1094 group_addr = is_multicast_ether_addr(hdr->addr1); in ieee80211_tx_h_calculate_duration()
1096 hdr->duration_id = in ieee80211_tx_h_calculate_duration()
1115 if (test_bit(HT_AGG_STATE_OPERATIONAL, &tid_tx->state)) { in ieee80211_tx_prep_agg()
1117 } else if (test_bit(HT_AGG_STATE_WANT_START, &tid_tx->state)) { in ieee80211_tx_prep_agg()
1119 * nothing -- this aggregation session is being started in ieee80211_tx_prep_agg()
1122 } else if (!tx->sta->sta.txq[tid]) { in ieee80211_tx_prep_agg()
1123 spin_lock(&tx->sta->lock); in ieee80211_tx_prep_agg()
1125 * Need to re-check now, because we may get here in ieee80211_tx_prep_agg()
1130 * queue yet -- if this happened we acquire the lock in ieee80211_tx_prep_agg()
1137 * before it was assigned) -- in this case it may in ieee80211_tx_prep_agg()
1142 tid_tx = rcu_dereference_protected_tid_tx(tx->sta, tid); in ieee80211_tx_prep_agg()
1146 } else if (test_bit(HT_AGG_STATE_OPERATIONAL, &tid_tx->state)) { in ieee80211_tx_prep_agg()
1150 if (info->flags & IEEE80211_TX_CTL_NO_PS_BUFFER) { in ieee80211_tx_prep_agg()
1151 clear_sta_flag(tx->sta, WLAN_STA_SP); in ieee80211_tx_prep_agg()
1152 ps_dbg(tx->sta->sdata, in ieee80211_tx_prep_agg()
1154 tx->sta->sta.addr, tx->sta->sta.aid); in ieee80211_tx_prep_agg()
1156 info->control.vif = &tx->sdata->vif; in ieee80211_tx_prep_agg()
1157 info->control.flags |= IEEE80211_TX_INTCFL_NEED_TXPROCESSING; in ieee80211_tx_prep_agg()
1158 info->flags &= ~IEEE80211_TX_TEMPORARY_FLAGS; in ieee80211_tx_prep_agg()
1159 __skb_queue_tail(&tid_tx->pending, skb); in ieee80211_tx_prep_agg()
1160 if (skb_queue_len(&tid_tx->pending) > STA_MAX_TX_BUFFER) in ieee80211_tx_prep_agg()
1161 purge_skb = __skb_dequeue(&tid_tx->pending); in ieee80211_tx_prep_agg()
1163 spin_unlock(&tx->sta->lock); in ieee80211_tx_prep_agg()
1166 ieee80211_free_txskb(&tx->local->hw, purge_skb); in ieee80211_tx_prep_agg()
1171 tid_tx->last_tx = jiffies; in ieee80211_tx_prep_agg()
1179 struct rate_control_ref *ref = sdata->local->rate_ctrl; in ieee80211_aggr_check()
1182 if (!ref || !(ref->ops->capa & RATE_CTRL_CAPA_AMPDU_TRIGGER)) in ieee80211_aggr_check()
1185 if (!sta || !sta->sta.deflink.ht_cap.ht_supported || in ieee80211_aggr_check()
1186 !sta->sta.wme || skb_get_queue_mapping(skb) == IEEE80211_AC_VO || in ieee80211_aggr_check()
1187 skb->protocol == sdata->control_port_protocol) in ieee80211_aggr_check()
1190 tid = skb->priority & IEEE80211_QOS_CTL_TID_MASK; in ieee80211_aggr_check()
1191 if (likely(sta->ampdu_mlme.tid_tx[tid])) in ieee80211_aggr_check()
1194 ieee80211_start_tx_ba_session(&sta->sta, tid, 0); in ieee80211_aggr_check()
1207 struct ieee80211_local *local = sdata->local; in ieee80211_tx_prepare()
1214 tx->skb = skb; in ieee80211_tx_prepare()
1215 tx->local = local; in ieee80211_tx_prepare()
1216 tx->sdata = sdata; in ieee80211_tx_prepare()
1217 __skb_queue_head_init(&tx->skbs); in ieee80211_tx_prepare()
1224 info->control.flags &= ~IEEE80211_TX_INTCFL_NEED_TXPROCESSING; in ieee80211_tx_prepare()
1226 hdr = (struct ieee80211_hdr *) skb->data; in ieee80211_tx_prepare()
1230 tx->sta = sta; in ieee80211_tx_prepare()
1232 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) { in ieee80211_tx_prepare()
1233 tx->sta = rcu_dereference(sdata->u.vlan.sta); in ieee80211_tx_prepare()
1234 if (!tx->sta && sdata->wdev.use_4addr) in ieee80211_tx_prepare()
1236 } else if (tx->sdata->control_port_protocol == tx->skb->protocol) { in ieee80211_tx_prepare()
1237 tx->sta = sta_info_get_bss(sdata, hdr->addr1); in ieee80211_tx_prepare()
1239 if (!tx->sta && !is_multicast_ether_addr(hdr->addr1)) { in ieee80211_tx_prepare()
1240 tx->sta = sta_info_get(sdata, hdr->addr1); in ieee80211_tx_prepare()
1245 if (tx->sta && ieee80211_is_data_qos(hdr->frame_control) && in ieee80211_tx_prepare()
1246 !ieee80211_is_qos_nullfunc(hdr->frame_control) && in ieee80211_tx_prepare()
1247 ieee80211_hw_check(&local->hw, AMPDU_AGGREGATION) && in ieee80211_tx_prepare()
1248 !ieee80211_hw_check(&local->hw, TX_AMPDU_SETUP_IN_HW)) { in ieee80211_tx_prepare()
1252 tid_tx = rcu_dereference(tx->sta->ampdu_mlme.tid_tx[tid]); in ieee80211_tx_prepare()
1254 ieee80211_aggr_check(sdata, tx->sta, skb); in ieee80211_tx_prepare()
1255 tid_tx = rcu_dereference(tx->sta->ampdu_mlme.tid_tx[tid]); in ieee80211_tx_prepare()
1269 if (is_multicast_ether_addr(hdr->addr1)) { in ieee80211_tx_prepare()
1270 tx->flags &= ~IEEE80211_TX_UNICAST; in ieee80211_tx_prepare()
1271 info->flags |= IEEE80211_TX_CTL_NO_ACK; in ieee80211_tx_prepare()
1273 tx->flags |= IEEE80211_TX_UNICAST; in ieee80211_tx_prepare()
1275 if (!(info->flags & IEEE80211_TX_CTL_DONTFRAG)) { in ieee80211_tx_prepare()
1276 if (!(tx->flags & IEEE80211_TX_UNICAST) || in ieee80211_tx_prepare()
1277 skb->len + FCS_LEN <= local->hw.wiphy->frag_threshold || in ieee80211_tx_prepare()
1278 info->flags & IEEE80211_TX_CTL_AMPDU) in ieee80211_tx_prepare()
1279 info->flags |= IEEE80211_TX_CTL_DONTFRAG; in ieee80211_tx_prepare()
1282 if (!tx->sta) in ieee80211_tx_prepare()
1283 info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT; in ieee80211_tx_prepare()
1284 else if (test_and_clear_sta_flag(tx->sta, WLAN_STA_CLEAR_PS_FILT)) { in ieee80211_tx_prepare()
1285 info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT; in ieee80211_tx_prepare()
1286 ieee80211_check_fast_xmit(tx->sta); in ieee80211_tx_prepare()
1289 info->flags |= IEEE80211_TX_CTL_FIRST_FRAGMENT; in ieee80211_tx_prepare()
1299 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; in ieee80211_get_txq()
1303 if ((info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM) || in ieee80211_get_txq()
1304 (info->control.flags & IEEE80211_TX_CTRL_PS_RESPONSE)) in ieee80211_get_txq()
1307 if (!(info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP) && in ieee80211_get_txq()
1308 unlikely(!ieee80211_is_data_present(hdr->frame_control))) { in ieee80211_get_txq()
1309 if ((!ieee80211_is_mgmt(hdr->frame_control) || in ieee80211_get_txq()
1311 vif->type == NL80211_IFTYPE_STATION) && in ieee80211_get_txq()
1312 sta && sta->uploaded) { in ieee80211_get_txq()
1315 * opt-in hardware flag. in ieee80211_get_txq()
1317 txq = sta->sta.txq[IEEE80211_NUM_TIDS]; in ieee80211_get_txq()
1320 u8 tid = skb->priority & IEEE80211_QOS_CTL_TID_MASK; in ieee80211_get_txq()
1322 if (!sta->uploaded) in ieee80211_get_txq()
1325 txq = sta->sta.txq[tid]; in ieee80211_get_txq()
1327 txq = vif->txq; in ieee80211_get_txq()
1342 IEEE80211_SKB_CB(skb)->control.enqueue_time = now; in ieee80211_set_skb_enqueue_time()
1347 return skb->len; in codel_skb_len_func()
1354 info = (const struct ieee80211_tx_info *)skb->cb; in codel_skb_time_func()
1355 return info->control.enqueue_time; in codel_skb_time_func()
1367 local = vif_to_sdata(txqi->txq.vif)->local; in codel_dequeue_func()
1368 fq = &local->fq; in codel_dequeue_func()
1370 if (cvars == &txqi->def_cvars) in codel_dequeue_func()
1371 flow = &txqi->tin.default_flow; in codel_dequeue_func()
1373 flow = &fq->flows[cvars - local->cvars]; in codel_dequeue_func()
1386 local = vif_to_sdata(txqi->txq.vif)->local; in codel_drop_func()
1387 hw = &local->hw; in codel_drop_func()
1404 cstats = &txqi->cstats; in fq_tin_dequeue_func()
1406 if (txqi->txq.sta) { in fq_tin_dequeue_func()
1407 struct sta_info *sta = container_of(txqi->txq.sta, in fq_tin_dequeue_func()
1409 cparams = &sta->cparams; in fq_tin_dequeue_func()
1411 cparams = &local->cparams; in fq_tin_dequeue_func()
1414 if (flow == &tin->default_flow) in fq_tin_dequeue_func()
1415 cvars = &txqi->def_cvars; in fq_tin_dequeue_func()
1417 cvars = &local->cvars[flow - fq->flows]; in fq_tin_dequeue_func()
1420 &flow->backlog, in fq_tin_dequeue_func()
1438 ieee80211_free_txskb(&local->hw, skb); in fq_skb_free_func()
1445 struct fq *fq = &local->fq; in ieee80211_txq_enqueue()
1446 struct fq_tin *tin = &txqi->tin; in ieee80211_txq_enqueue()
1451 spin_lock_bh(&fq->lock); in ieee80211_txq_enqueue()
1458 if (unlikely(txqi->txq.tid == IEEE80211_NUM_TIDS)) { in ieee80211_txq_enqueue()
1459 IEEE80211_SKB_CB(skb)->control.flags |= in ieee80211_txq_enqueue()
1461 __skb_queue_tail(&txqi->frags, skb); in ieee80211_txq_enqueue()
1466 spin_unlock_bh(&fq->lock); in ieee80211_txq_enqueue()
1475 return info->control.vif == data; in fq_vlan_filter_func()
1481 struct fq *fq = &local->fq; in ieee80211_txq_remove_vlan()
1486 if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_AP_VLAN)) in ieee80211_txq_remove_vlan()
1489 ap = container_of(sdata->bss, struct ieee80211_sub_if_data, u.ap); in ieee80211_txq_remove_vlan()
1491 if (!ap->vif.txq) in ieee80211_txq_remove_vlan()
1494 txqi = to_txq_info(ap->vif.txq); in ieee80211_txq_remove_vlan()
1495 tin = &txqi->tin; in ieee80211_txq_remove_vlan()
1497 spin_lock_bh(&fq->lock); in ieee80211_txq_remove_vlan()
1498 fq_tin_filter(fq, tin, fq_vlan_filter_func, &sdata->vif, in ieee80211_txq_remove_vlan()
1500 spin_unlock_bh(&fq->lock); in ieee80211_txq_remove_vlan()
1507 fq_tin_init(&txqi->tin); in ieee80211_txq_init()
1508 codel_vars_init(&txqi->def_cvars); in ieee80211_txq_init()
1509 codel_stats_init(&txqi->cstats); in ieee80211_txq_init()
1510 __skb_queue_head_init(&txqi->frags); in ieee80211_txq_init()
1511 INIT_LIST_HEAD(&txqi->schedule_order); in ieee80211_txq_init()
1513 txqi->txq.vif = &sdata->vif; in ieee80211_txq_init()
1516 sdata->vif.txq = &txqi->txq; in ieee80211_txq_init()
1517 txqi->txq.tid = 0; in ieee80211_txq_init()
1518 txqi->txq.ac = IEEE80211_AC_BE; in ieee80211_txq_init()
1524 if (sdata->vif.type == NL80211_IFTYPE_STATION) { in ieee80211_txq_init()
1526 if (!ieee80211_hw_check(&sdata->local->hw, in ieee80211_txq_init()
1529 } else if (!ieee80211_hw_check(&sdata->local->hw, in ieee80211_txq_init()
1534 txqi->txq.ac = IEEE80211_AC_VO; in ieee80211_txq_init()
1536 txqi->txq.ac = ieee80211_ac_from_tid(tid); in ieee80211_txq_init()
1539 txqi->txq.sta = &sta->sta; in ieee80211_txq_init()
1540 txqi->txq.tid = tid; in ieee80211_txq_init()
1541 sta->sta.txq[tid] = &txqi->txq; in ieee80211_txq_init()
1547 struct fq *fq = &local->fq; in ieee80211_txq_purge()
1548 struct fq_tin *tin = &txqi->tin; in ieee80211_txq_purge()
1550 spin_lock_bh(&fq->lock); in ieee80211_txq_purge()
1552 ieee80211_purge_tx_queue(&local->hw, &txqi->frags); in ieee80211_txq_purge()
1553 spin_unlock_bh(&fq->lock); in ieee80211_txq_purge()
1555 spin_lock_bh(&local->active_txq_lock[txqi->txq.ac]); in ieee80211_txq_purge()
1556 list_del_init(&txqi->schedule_order); in ieee80211_txq_purge()
1557 spin_unlock_bh(&local->active_txq_lock[txqi->txq.ac]); in ieee80211_txq_purge()
1562 if (local->hw.wiphy->txq_limit) in ieee80211_txq_set_params()
1563 local->fq.limit = local->hw.wiphy->txq_limit; in ieee80211_txq_set_params()
1565 local->hw.wiphy->txq_limit = local->fq.limit; in ieee80211_txq_set_params()
1567 if (local->hw.wiphy->txq_memory_limit) in ieee80211_txq_set_params()
1568 local->fq.memory_limit = local->hw.wiphy->txq_memory_limit; in ieee80211_txq_set_params()
1570 local->hw.wiphy->txq_memory_limit = local->fq.memory_limit; in ieee80211_txq_set_params()
1572 if (local->hw.wiphy->txq_quantum) in ieee80211_txq_set_params()
1573 local->fq.quantum = local->hw.wiphy->txq_quantum; in ieee80211_txq_set_params()
1575 local->hw.wiphy->txq_quantum = local->fq.quantum; in ieee80211_txq_set_params()
1580 struct fq *fq = &local->fq; in ieee80211_txq_setup_flows()
1592 * queue size. 4 Mbytes is 64 max-size aggregates in 802.11n. in ieee80211_txq_setup_flows()
1597 sband = local->hw.wiphy->bands[band]; in ieee80211_txq_setup_flows()
1601 supp_vht = supp_vht || sband->vht_cap.vht_supported; in ieee80211_txq_setup_flows()
1605 fq->memory_limit = 4 << 20; /* 4 Mbytes */ in ieee80211_txq_setup_flows()
1607 codel_params_init(&local->cparams); in ieee80211_txq_setup_flows()
1608 local->cparams.interval = MS2TIME(100); in ieee80211_txq_setup_flows()
1609 local->cparams.target = MS2TIME(20); in ieee80211_txq_setup_flows()
1610 local->cparams.ecn = true; in ieee80211_txq_setup_flows()
1612 local->cvars = kvcalloc(fq->flows_cnt, sizeof(local->cvars[0]), in ieee80211_txq_setup_flows()
1614 if (!local->cvars) { in ieee80211_txq_setup_flows()
1615 spin_lock_bh(&fq->lock); in ieee80211_txq_setup_flows()
1617 spin_unlock_bh(&fq->lock); in ieee80211_txq_setup_flows()
1618 return -ENOMEM; in ieee80211_txq_setup_flows()
1621 for (i = 0; i < fq->flows_cnt; i++) in ieee80211_txq_setup_flows()
1622 codel_vars_init(&local->cvars[i]); in ieee80211_txq_setup_flows()
1631 struct fq *fq = &local->fq; in ieee80211_txq_teardown_flows()
1633 kvfree(local->cvars); in ieee80211_txq_teardown_flows()
1634 local->cvars = NULL; in ieee80211_txq_teardown_flows()
1636 spin_lock_bh(&fq->lock); in ieee80211_txq_teardown_flows()
1638 spin_unlock_bh(&fq->lock); in ieee80211_txq_teardown_flows()
1649 if (sdata->vif.type == NL80211_IFTYPE_MONITOR) in ieee80211_queue_skb()
1652 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) in ieee80211_queue_skb()
1653 sdata = container_of(sdata->bss, in ieee80211_queue_skb()
1656 vif = &sdata->vif; in ieee80211_queue_skb()
1681 int q = info->hw_queue; in ieee80211_tx_frags()
1684 if (WARN_ON_ONCE(q >= local->hw.queues)) { in ieee80211_tx_frags()
1686 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_frags()
1691 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in ieee80211_tx_frags()
1692 if (local->queue_stop_reasons[q] || in ieee80211_tx_frags()
1693 (!txpending && !skb_queue_empty(&local->pending[q]))) { in ieee80211_tx_frags()
1694 if (unlikely(info->flags & in ieee80211_tx_frags()
1696 if (local->queue_stop_reasons[q] & in ieee80211_tx_frags()
1699 * Drop off-channel frames if queues in ieee80211_tx_frags()
1701 * than off-channel operation. Never in ieee80211_tx_frags()
1705 &local->queue_stop_reason_lock, in ieee80211_tx_frags()
1707 ieee80211_purge_tx_queue(&local->hw, in ieee80211_tx_frags()
1715 * later transmission from the tx-pending in ieee80211_tx_frags()
1720 &local->pending[q]); in ieee80211_tx_frags()
1723 &local->pending[q]); in ieee80211_tx_frags()
1725 spin_unlock_irqrestore(&local->queue_stop_reason_lock, in ieee80211_tx_frags()
1730 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_tx_frags()
1732 info->control.vif = vif; in ieee80211_tx_frags()
1733 control.sta = sta ? &sta->sta : NULL; in ieee80211_tx_frags()
1760 sdata = vif_to_sdata(info->control.vif); in __ieee80211_tx()
1761 if (sta && !sta->uploaded) in __ieee80211_tx()
1764 switch (sdata->vif.type) { in __ieee80211_tx()
1766 if (sdata->u.mntr.flags & MONITOR_FLAG_ACTIVE) { in __ieee80211_tx()
1767 vif = &sdata->vif; in __ieee80211_tx()
1770 sdata = rcu_dereference(local->monitor_sdata); in __ieee80211_tx()
1771 if (sdata && ieee80211_hw_check(&local->hw, WANT_MONITOR_VIF)) { in __ieee80211_tx()
1772 vif = &sdata->vif; in __ieee80211_tx()
1773 info->hw_queue = in __ieee80211_tx()
1774 vif->hw_queue[skb_get_queue_mapping(skb)]; in __ieee80211_tx()
1775 } else if (ieee80211_hw_check(&local->hw, QUEUE_CONTROL)) { in __ieee80211_tx()
1776 ieee80211_purge_tx_queue(&local->hw, skbs); in __ieee80211_tx()
1782 sdata = container_of(sdata->bss, in __ieee80211_tx()
1786 vif = &sdata->vif; in __ieee80211_tx()
1798 * Invoke TX handlers, return 0 on success and non-zero if the
1824 I802_DEBUG_INC(tx->local->tx_handlers_drop); in invoke_tx_handlers_early()
1825 if (tx->skb) in invoke_tx_handlers_early()
1826 ieee80211_free_txskb(&tx->local->hw, tx->skb); in invoke_tx_handlers_early()
1828 ieee80211_purge_tx_queue(&tx->local->hw, &tx->skbs); in invoke_tx_handlers_early()
1829 return -1; in invoke_tx_handlers_early()
1831 I802_DEBUG_INC(tx->local->tx_handlers_queued); in invoke_tx_handlers_early()
1832 return -1; in invoke_tx_handlers_early()
1844 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); in invoke_tx_handlers_late()
1847 if (!ieee80211_hw_check(&tx->local->hw, HAS_RATE_CONTROL)) in invoke_tx_handlers_late()
1850 if (unlikely(info->flags & IEEE80211_TX_INTFL_RETRANSMISSION)) { in invoke_tx_handlers_late()
1851 __skb_queue_tail(&tx->skbs, tx->skb); in invoke_tx_handlers_late()
1852 tx->skb = NULL; in invoke_tx_handlers_late()
1862 if (!ieee80211_hw_check(&tx->local->hw, HAS_RATE_CONTROL)) in invoke_tx_handlers_late()
1868 I802_DEBUG_INC(tx->local->tx_handlers_drop); in invoke_tx_handlers_late()
1869 if (tx->skb) in invoke_tx_handlers_late()
1870 ieee80211_free_txskb(&tx->local->hw, tx->skb); in invoke_tx_handlers_late()
1872 ieee80211_purge_tx_queue(&tx->local->hw, &tx->skbs); in invoke_tx_handlers_late()
1873 return -1; in invoke_tx_handlers_late()
1875 I802_DEBUG_INC(tx->local->tx_handlers_queued); in invoke_tx_handlers_late()
1876 return -1; in invoke_tx_handlers_late()
1903 info->band = band; in ieee80211_tx_prepare_skb()
1904 info->control.vif = vif; in ieee80211_tx_prepare_skb()
1905 info->hw_queue = vif->hw_queue[skb_get_queue_mapping(skb)]; in ieee80211_tx_prepare_skb()
1912 *sta = &tx.sta->sta; in ieee80211_tx_prepare_skb()
1936 struct ieee80211_local *local = sdata->local; in ieee80211_tx()
1942 if (unlikely(skb->len < 10)) { in ieee80211_tx()
1951 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx()
1958 if (!(info->flags & IEEE80211_TX_CTL_TX_OFFCHAN) || in ieee80211_tx()
1959 !ieee80211_hw_check(&local->hw, QUEUE_CONTROL)) in ieee80211_tx()
1960 info->hw_queue = in ieee80211_tx()
1961 sdata->vif.hw_queue[skb_get_queue_mapping(skb)]; in ieee80211_tx()
1988 struct ieee80211_local *local = sdata->local; in ieee80211_skb_resize()
1994 sdata->crypto_tx_tailroom_needed_cnt); in ieee80211_skb_resize()
1998 tail_need -= skb_tailroom(skb); in ieee80211_skb_resize()
2003 (!ieee80211_hw_check(&local->hw, SUPPORTS_CLONED_SKBS) || in ieee80211_skb_resize()
2005 I802_DEBUG_INC(local->tx_expand_skb_head_cloned); in ieee80211_skb_resize()
2007 I802_DEBUG_INC(local->tx_expand_skb_head); in ieee80211_skb_resize()
2012 wiphy_debug(local->hw.wiphy, in ieee80211_skb_resize()
2014 return -ENOMEM; in ieee80211_skb_resize()
2023 struct ieee80211_local *local = sdata->local; in ieee80211_xmit()
2025 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; in ieee80211_xmit()
2029 if (info->flags & IEEE80211_TX_INTFL_DONT_ENCRYPT) in ieee80211_xmit()
2031 else if (ieee80211_is_mgmt(hdr->frame_control)) in ieee80211_xmit()
2036 headroom = local->tx_headroom; in ieee80211_xmit()
2039 headroom -= skb_headroom(skb); in ieee80211_xmit()
2043 ieee80211_free_txskb(&local->hw, skb); in ieee80211_xmit()
2048 hdr = (struct ieee80211_hdr *) skb->data; in ieee80211_xmit()
2049 info->control.vif = &sdata->vif; in ieee80211_xmit()
2051 if (ieee80211_vif_is_mesh(&sdata->vif)) { in ieee80211_xmit()
2052 if (ieee80211_is_data(hdr->frame_control) && in ieee80211_xmit()
2053 is_unicast_ether_addr(hdr->addr1)) { in ieee80211_xmit()
2068 (struct ieee80211_radiotap_header *)skb->data; in ieee80211_validate_radiotap_len()
2071 if (unlikely(skb->len < sizeof(struct ieee80211_radiotap_header))) in ieee80211_validate_radiotap_len()
2075 if (unlikely(rthdr->it_version)) in ieee80211_validate_radiotap_len()
2079 if (unlikely(skb->len < ieee80211_get_radiotap_len(skb->data))) in ieee80211_validate_radiotap_len()
2088 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); in ieee80211_parse_tx_radiotap()
2091 (struct ieee80211_radiotap_header *) skb->data; in ieee80211_parse_tx_radiotap()
2093 int ret = ieee80211_radiotap_iterator_init(&iterator, rthdr, skb->len, in ieee80211_parse_tx_radiotap()
2108 info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT | in ieee80211_parse_tx_radiotap()
2113 * (ieee80211_radiotap_iterator_next returns -ENOENT when no more in ieee80211_parse_tx_radiotap()
2114 * entries present, or -EINVAL on error) in ieee80211_parse_tx_radiotap()
2135 * handed has the 32-bit FCS CRC at the end... in ieee80211_parse_tx_radiotap()
2140 if (skb->len < (iterator._max_length + FCS_LEN)) in ieee80211_parse_tx_radiotap()
2143 skb_trim(skb, skb->len - FCS_LEN); in ieee80211_parse_tx_radiotap()
2146 info->flags &= ~IEEE80211_TX_INTFL_DONT_ENCRYPT; in ieee80211_parse_tx_radiotap()
2148 info->flags &= ~IEEE80211_TX_CTL_DONTFRAG; in ieee80211_parse_tx_radiotap()
2154 info->flags |= IEEE80211_TX_CTL_NO_ACK; in ieee80211_parse_tx_radiotap()
2156 info->control.flags |= IEEE80211_TX_CTRL_NO_SEQNO; in ieee80211_parse_tx_radiotap()
2158 info->control.flags |= in ieee80211_parse_tx_radiotap()
2170 info->control.antennas |= BIT(*iterator.this_arg); in ieee80211_parse_tx_radiotap()
2198 info->flags |= IEEE80211_TX_CTL_LDPC; in ieee80211_parse_tx_radiotap()
2204 info->flags |= in ieee80211_parse_tx_radiotap()
2242 * Documentation/networking/mac80211-injection.rst in ieee80211_parse_tx_radiotap()
2251 if (ret != -ENOENT) /* ie, if we didn't simply run out of fields */ in ieee80211_parse_tx_radiotap()
2256 local->hw.wiphy->bands[info->band]; in ieee80211_parse_tx_radiotap()
2258 info->control.flags |= IEEE80211_TX_CTRL_RATE_INJECT; in ieee80211_parse_tx_radiotap()
2261 info->control.rates[i].idx = -1; in ieee80211_parse_tx_radiotap()
2262 info->control.rates[i].flags = 0; in ieee80211_parse_tx_radiotap()
2263 info->control.rates[i].count = 0; in ieee80211_parse_tx_radiotap()
2269 hweight8(info->control.antennas)) in ieee80211_parse_tx_radiotap()
2270 info->control.antennas = 0; in ieee80211_parse_tx_radiotap()
2272 info->control.rates[0].idx = rate; in ieee80211_parse_tx_radiotap()
2275 if (vht_nss > hweight8(info->control.antennas)) in ieee80211_parse_tx_radiotap()
2276 info->control.antennas = 0; in ieee80211_parse_tx_radiotap()
2278 ieee80211_rate_set_vht(info->control.rates, vht_mcs, in ieee80211_parse_tx_radiotap()
2281 for (i = 0; i < sband->n_bitrates; i++) { in ieee80211_parse_tx_radiotap()
2282 if (rate * 5 != sband->bitrates[i].bitrate) in ieee80211_parse_tx_radiotap()
2285 info->control.rates[0].idx = i; in ieee80211_parse_tx_radiotap()
2290 if (info->control.rates[0].idx < 0) in ieee80211_parse_tx_radiotap()
2291 info->control.flags &= ~IEEE80211_TX_CTRL_RATE_INJECT; in ieee80211_parse_tx_radiotap()
2293 info->control.rates[0].flags = rate_flags; in ieee80211_parse_tx_radiotap()
2294 info->control.rates[0].count = min_t(u8, rate_retries + 1, in ieee80211_parse_tx_radiotap()
2295 local->hw.max_rate_tries); in ieee80211_parse_tx_radiotap()
2304 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); in ieee80211_monitor_start_xmit()
2318 info->flags = IEEE80211_TX_CTL_REQ_TX_STATUS | in ieee80211_monitor_start_xmit()
2321 /* Sanity-check the length of the radiotap header */ in ieee80211_monitor_start_xmit()
2326 len_rthdr = ieee80211_get_radiotap_len(skb->data); in ieee80211_monitor_start_xmit()
2342 if (skb->len < len_rthdr + 2) in ieee80211_monitor_start_xmit()
2345 hdr = (struct ieee80211_hdr *)(skb->data + len_rthdr); in ieee80211_monitor_start_xmit()
2346 hdrlen = ieee80211_hdrlen(hdr->frame_control); in ieee80211_monitor_start_xmit()
2348 if (skb->len < len_rthdr + hdrlen) in ieee80211_monitor_start_xmit()
2352 * Initialize skb->protocol if the injected frame is a data frame in ieee80211_monitor_start_xmit()
2355 if (ieee80211_is_data(hdr->frame_control) && in ieee80211_monitor_start_xmit()
2356 skb->len >= len_rthdr + hdrlen + sizeof(rfc1042_header) + 2) { in ieee80211_monitor_start_xmit()
2360 skb->protocol = cpu_to_be16((payload[6] << 8) | in ieee80211_monitor_start_xmit()
2368 * we handle as though they are non-injected frames. in ieee80211_monitor_start_xmit()
2371 * VLAN support we have an nl80211-based mechanism. in ieee80211_monitor_start_xmit()
2374 * don't use nl80211-based management TX/RX. in ieee80211_monitor_start_xmit()
2376 list_for_each_entry_rcu(tmp_sdata, &local->interfaces, list) { in ieee80211_monitor_start_xmit()
2379 if (tmp_sdata->vif.type == NL80211_IFTYPE_MONITOR || in ieee80211_monitor_start_xmit()
2380 tmp_sdata->vif.type == NL80211_IFTYPE_AP_VLAN) in ieee80211_monitor_start_xmit()
2382 if (ether_addr_equal(tmp_sdata->vif.addr, hdr->addr2)) { in ieee80211_monitor_start_xmit()
2388 chanctx_conf = rcu_dereference(sdata->vif.bss_conf.chanctx_conf); in ieee80211_monitor_start_xmit()
2390 tmp_sdata = rcu_dereference(local->monitor_sdata); in ieee80211_monitor_start_xmit()
2393 rcu_dereference(tmp_sdata->vif.bss_conf.chanctx_conf); in ieee80211_monitor_start_xmit()
2397 chandef = &chanctx_conf->def; in ieee80211_monitor_start_xmit()
2405 if (!cfg80211_chandef_usable(local->hw.wiphy, chandef, in ieee80211_monitor_start_xmit()
2425 if (!cfg80211_reg_can_beacon(local->hw.wiphy, chandef, in ieee80211_monitor_start_xmit()
2426 sdata->vif.type)) in ieee80211_monitor_start_xmit()
2429 info->band = chandef->chan->band; in ieee80211_monitor_start_xmit()
2431 /* Initialize skb->priority according to frame type and TID class, in ieee80211_monitor_start_xmit()
2434 * skb-priority is preserved to assure frames injected with this in ieee80211_monitor_start_xmit()
2438 skb_set_queue_mapping(skb, ieee80211_ac_from_tid(skb->priority)); in ieee80211_monitor_start_xmit()
2465 u16 ethertype = (skb->data[12] << 8) | skb->data[13]; in ieee80211_is_tdls_setup()
2468 skb->len > 14 && in ieee80211_is_tdls_setup()
2469 skb->data[14] == WLAN_TDLS_SNAP_RFTYPE; in ieee80211_is_tdls_setup()
2478 switch (sdata->vif.type) { in ieee80211_lookup_ra_sta()
2480 sta = rcu_dereference(sdata->u.vlan.sta); in ieee80211_lookup_ra_sta()
2484 } else if (sdata->wdev.use_4addr) { in ieee80211_lookup_ra_sta()
2485 return -ENOLINK; in ieee80211_lookup_ra_sta()
2491 if (is_multicast_ether_addr(skb->data)) { in ieee80211_lookup_ra_sta()
2492 *sta_out = ERR_PTR(-ENOENT); in ieee80211_lookup_ra_sta()
2495 sta = sta_info_get_bss(sdata, skb->data); in ieee80211_lookup_ra_sta()
2504 if (sdata->wdev.wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS) { in ieee80211_lookup_ra_sta()
2505 sta = sta_info_get(sdata, skb->data); in ieee80211_lookup_ra_sta()
2514 * TDLS link during setup - throw out frames to in ieee80211_lookup_ra_sta()
2515 * peer. Allow TDLS-setup frames to unauthorized in ieee80211_lookup_ra_sta()
2516 * peers for the special case of a link teardown in ieee80211_lookup_ra_sta()
2521 return -EINVAL; in ieee80211_lookup_ra_sta()
2526 sta = sta_info_get(sdata, sdata->vif.cfg.ap_addr); in ieee80211_lookup_ra_sta()
2528 return -ENOLINK; in ieee80211_lookup_ra_sta()
2531 return -EINVAL; in ieee80211_lookup_ra_sta()
2534 *sta_out = sta ?: ERR_PTR(-ENOENT); in ieee80211_lookup_ra_sta()
2546 if (skb->sk) in ieee80211_store_ack_skb()
2555 spin_lock_irqsave(&local->ack_status_lock, flags); in ieee80211_store_ack_skb()
2556 id = idr_alloc(&local->ack_status_frames, ack_skb, in ieee80211_store_ack_skb()
2558 spin_unlock_irqrestore(&local->ack_status_lock, flags); in ieee80211_store_ack_skb()
2565 IEEE80211_SKB_CB(ack_skb)->ack.cookie = *cookie; in ieee80211_store_ack_skb()
2576 * ieee80211_build_hdr - build 802.11 header in the given frame
2589 * potential unsharing of the SKB - this needs to be interleaved with the
2592 * The function requires the read-side RCU lock held
2601 struct ieee80211_local *local = sdata->local; in ieee80211_build_hdr()
2624 if (local->force_tx_status) in ieee80211_build_hdr()
2630 ethertype = (skb->data[12] << 8) | skb->data[13]; in ieee80211_build_hdr()
2633 if (!ieee80211_vif_is_mld(&sdata->vif)) in ieee80211_build_hdr()
2635 rcu_dereference(sdata->vif.bss_conf.chanctx_conf); in ieee80211_build_hdr()
2637 switch (sdata->vif.type) { in ieee80211_build_hdr()
2639 if (sdata->wdev.use_4addr) { in ieee80211_build_hdr()
2642 memcpy(hdr.addr1, sta->sta.addr, ETH_ALEN); in ieee80211_build_hdr()
2643 memcpy(hdr.addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_build_hdr()
2644 memcpy(hdr.addr3, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2645 memcpy(hdr.addr4, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2648 wme_sta = sta->sta.wme; in ieee80211_build_hdr()
2650 if (!ieee80211_vif_is_mld(&sdata->vif)) { in ieee80211_build_hdr()
2654 ap_sdata = container_of(sdata->bss, in ieee80211_build_hdr()
2658 rcu_dereference(ap_sdata->vif.bss_conf.chanctx_conf); in ieee80211_build_hdr()
2660 if (sdata->wdev.use_4addr) in ieee80211_build_hdr()
2666 memcpy(hdr.addr1, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2668 if (ieee80211_vif_is_mld(&sdata->vif) && sta && !sta->sta.mlo) { in ieee80211_build_hdr()
2669 struct ieee80211_link_data *link; in ieee80211_build_hdr() local
2671 link_id = sta->deflink.link_id; in ieee80211_build_hdr()
2672 link = rcu_dereference(sdata->link[link_id]); in ieee80211_build_hdr()
2673 if (WARN_ON(!link)) { in ieee80211_build_hdr()
2674 ret = -ENOLINK; in ieee80211_build_hdr()
2677 memcpy(hdr.addr2, link->conf->addr, ETH_ALEN); in ieee80211_build_hdr()
2679 (sta && sta->sta.mlo)) { in ieee80211_build_hdr()
2680 memcpy(hdr.addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_build_hdr()
2684 conf = rcu_dereference(sdata->vif.link_conf[link_id]); in ieee80211_build_hdr()
2686 ret = -ENOLINK; in ieee80211_build_hdr()
2690 memcpy(hdr.addr2, conf->addr, ETH_ALEN); in ieee80211_build_hdr()
2693 memcpy(hdr.addr3, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2698 if (!is_multicast_ether_addr(skb->data)) { in ieee80211_build_hdr()
2702 mpath = mesh_path_lookup(sdata, skb->data); in ieee80211_build_hdr()
2705 next_hop = rcu_dereference(mpath->next_hop); in ieee80211_build_hdr()
2707 !(mpath->flags & (MESH_PATH_ACTIVE | in ieee80211_build_hdr()
2713 mppath = mpp_path_lookup(sdata, skb->data); in ieee80211_build_hdr()
2715 mppath->exp_time = jiffies; in ieee80211_build_hdr()
2719 mesh_path_del(sdata, mpath->dst); in ieee80211_build_hdr()
2728 if (ether_addr_equal(sdata->vif.addr, skb->data + ETH_ALEN) && in ieee80211_build_hdr()
2729 !(mppath && !ether_addr_equal(mppath->mpp, skb->data))) { in ieee80211_build_hdr()
2731 skb->data, skb->data + ETH_ALEN); in ieee80211_build_hdr()
2735 /* DS -> MBSS (802.11-2012 13.11.3.3). in ieee80211_build_hdr()
2741 const u8 *mesh_da = skb->data; in ieee80211_build_hdr()
2744 mesh_da = mppath->mpp; in ieee80211_build_hdr()
2746 mesh_da = mpath->dst; in ieee80211_build_hdr()
2749 mesh_da, sdata->vif.addr); in ieee80211_build_hdr()
2754 skb->data + ETH_ALEN, NULL); in ieee80211_build_hdr()
2758 sdata, &mesh_hdr, skb->data, in ieee80211_build_hdr()
2759 skb->data + ETH_ALEN); in ieee80211_build_hdr()
2768 memcpy(hdr.addr1, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2776 /* For TDLS only one link can be valid with peer STA */ in ieee80211_build_hdr()
2778 struct ieee80211_link_data *link; in ieee80211_build_hdr() local
2781 memcpy(hdr.addr1, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2782 memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2783 link = rcu_dereference(sdata->link[tdls_link_id]); in ieee80211_build_hdr()
2784 if (WARN_ON_ONCE(!link)) { in ieee80211_build_hdr()
2785 ret = -EINVAL; in ieee80211_build_hdr()
2788 memcpy(hdr.addr3, link->u.mgd.bssid, ETH_ALEN); in ieee80211_build_hdr()
2790 } else if (sdata->u.mgd.use_4addr && in ieee80211_build_hdr()
2791 cpu_to_be16(ethertype) != sdata->control_port_protocol) { in ieee80211_build_hdr()
2795 memcpy(hdr.addr1, sdata->deflink.u.mgd.bssid, ETH_ALEN); in ieee80211_build_hdr()
2796 memcpy(hdr.addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_build_hdr()
2797 memcpy(hdr.addr3, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2798 memcpy(hdr.addr4, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2803 memcpy(hdr.addr1, sdata->vif.cfg.ap_addr, ETH_ALEN); in ieee80211_build_hdr()
2804 memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2805 memcpy(hdr.addr3, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2811 memcpy(hdr.addr1, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2812 memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2818 memcpy(hdr.addr1, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2819 memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2820 memcpy(hdr.addr3, sdata->u.ibss.bssid, ETH_ALEN); in ieee80211_build_hdr()
2824 ret = -EINVAL; in ieee80211_build_hdr()
2829 if (!ieee80211_vif_is_mld(&sdata->vif)) { in ieee80211_build_hdr()
2830 ret = -ENOTCONN; in ieee80211_build_hdr()
2836 band = chanctx_conf->def.chan->band; in ieee80211_build_hdr()
2844 wme_sta = sta->sta.wme; in ieee80211_build_hdr()
2845 } else if (ieee80211_vif_is_mesh(&sdata->vif)) { in ieee80211_build_hdr()
2860 if (unlikely(!ieee80211_vif_is_mesh(&sdata->vif) && in ieee80211_build_hdr()
2861 (sdata->vif.type != NL80211_IFTYPE_OCB) && in ieee80211_build_hdr()
2863 (cpu_to_be16(ethertype) != sdata->control_port_protocol || in ieee80211_build_hdr()
2864 !ieee80211_is_our_addr(sdata, skb->data + ETH_ALEN, NULL)))) { in ieee80211_build_hdr()
2867 sdata->name, hdr.addr1); in ieee80211_build_hdr()
2870 I802_DEBUG_INC(local->tx_handlers_drop_unauth_port); in ieee80211_build_hdr()
2872 ret = -EPERM; in ieee80211_build_hdr()
2877 ((skb->sk && in ieee80211_build_hdr()
2878 skb_shinfo(skb)->tx_flags & SKBTX_WIFI_STATUS) || in ieee80211_build_hdr()
2888 ret = -ENOMEM; in ieee80211_build_hdr()
2900 skip_header_bytes -= 2; in ieee80211_build_hdr()
2904 skip_header_bytes -= 2; in ieee80211_build_hdr()
2911 head_need = hdrlen + encaps_len + meshhdrlen - skb_headroom(skb); in ieee80211_build_hdr()
2927 head_need += local->tx_headroom; in ieee80211_build_hdr()
2930 ieee80211_free_txskb(&local->hw, skb); in ieee80211_build_hdr()
2932 return ERR_PTR(-ENOMEM); in ieee80211_build_hdr()
2948 memcpy(skb_push(skb, hdrlen - 2), &hdr, hdrlen - 2); in ieee80211_build_hdr()
2962 info->flags = info_flags; in ieee80211_build_hdr()
2964 info->status_data = info_id; in ieee80211_build_hdr()
2965 info->status_data_idr = 1; in ieee80211_build_hdr()
2967 info->band = band; in ieee80211_build_hdr()
2987 net_info_ratelimited("%s: dropped frame to %pM with bad link ID request (%d vs. %d)\n", in ieee80211_build_hdr()
2988 sdata->name, hdr.addr1, in ieee80211_build_hdr()
2991 ret = -EINVAL; in ieee80211_build_hdr()
2996 info->control.flags = ctrl_flags; in ieee80211_build_hdr()
3005 * fast-xmit overview
3007 * The core idea of this fast-xmit is to remove per-packet checks by checking
3008 * them out of band. ieee80211_check_fast_xmit() implements the out-of-band
3009 * checks that are needed to get the sta->fast_tx pointer assigned, after which
3014 * Once assigned, the fast_tx data structure also caches the per-packet 802.11
3020 * since the per-packet code no longer checks the conditions. This is reflected
3028 struct ieee80211_local *local = sta->local; in ieee80211_check_fast_xmit()
3029 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_check_fast_xmit()
3034 if (!ieee80211_hw_check(&local->hw, SUPPORT_FAST_XMIT)) in ieee80211_check_fast_xmit()
3037 if (ieee80211_vif_is_mesh(&sdata->vif)) in ieee80211_check_fast_xmit()
3048 * key and the fast-tx assignment are done atomically, so the CPU that in ieee80211_check_fast_xmit()
3052 spin_lock_bh(&sta->lock); in ieee80211_check_fast_xmit()
3053 if (ieee80211_hw_check(&local->hw, SUPPORTS_PS) && in ieee80211_check_fast_xmit()
3054 !ieee80211_hw_check(&local->hw, SUPPORTS_DYNAMIC_PS) && in ieee80211_check_fast_xmit()
3055 sdata->vif.type == NL80211_IFTYPE_STATION) in ieee80211_check_fast_xmit()
3058 if (!test_sta_flag(sta, WLAN_STA_AUTHORIZED) || !sta->uploaded) in ieee80211_check_fast_xmit()
3067 if (sdata->noack_map) in ieee80211_check_fast_xmit()
3070 /* fast-xmit doesn't handle fragmentation at all */ in ieee80211_check_fast_xmit()
3071 if (local->hw.wiphy->frag_threshold != (u32)-1 && in ieee80211_check_fast_xmit()
3072 !ieee80211_hw_check(&local->hw, SUPPORTS_TX_FRAG)) in ieee80211_check_fast_xmit()
3075 if (!ieee80211_vif_is_mld(&sdata->vif)) { in ieee80211_check_fast_xmit()
3078 rcu_dereference(sdata->vif.bss_conf.chanctx_conf); in ieee80211_check_fast_xmit()
3083 build.band = chanctx_conf->def.chan->band; in ieee80211_check_fast_xmit()
3092 switch (sdata->vif.type) { in ieee80211_check_fast_xmit()
3097 memcpy(hdr->addr3, sdata->u.ibss.bssid, ETH_ALEN); in ieee80211_check_fast_xmit()
3102 /* For TDLS only one link can be valid with peer STA */ in ieee80211_check_fast_xmit()
3104 struct ieee80211_link_data *link; in ieee80211_check_fast_xmit() local
3110 link = rcu_dereference(sdata->link[tdls_link_id]); in ieee80211_check_fast_xmit()
3111 if (!WARN_ON_ONCE(!link)) in ieee80211_check_fast_xmit()
3112 memcpy(hdr->addr3, link->u.mgd.bssid, ETH_ALEN); in ieee80211_check_fast_xmit()
3118 if (sdata->u.mgd.use_4addr) { in ieee80211_check_fast_xmit()
3119 /* non-regular ethertype cannot use the fastpath */ in ieee80211_check_fast_xmit()
3123 memcpy(hdr->addr1, sdata->deflink.u.mgd.bssid, ETH_ALEN); in ieee80211_check_fast_xmit()
3124 memcpy(hdr->addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_check_fast_xmit()
3132 memcpy(hdr->addr1, sdata->vif.cfg.ap_addr, ETH_ALEN); in ieee80211_check_fast_xmit()
3138 if (sdata->wdev.use_4addr) { in ieee80211_check_fast_xmit()
3142 memcpy(hdr->addr1, sta->sta.addr, ETH_ALEN); in ieee80211_check_fast_xmit()
3143 memcpy(hdr->addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_check_fast_xmit()
3154 if (sta->sta.mlo || !ieee80211_vif_is_mld(&sdata->vif)) { in ieee80211_check_fast_xmit()
3155 memcpy(hdr->addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_check_fast_xmit()
3157 unsigned int link_id = sta->deflink.link_id; in ieee80211_check_fast_xmit()
3158 struct ieee80211_link_data *link; in ieee80211_check_fast_xmit() local
3161 link = rcu_dereference(sdata->link[link_id]); in ieee80211_check_fast_xmit()
3162 if (WARN_ON(!link)) { in ieee80211_check_fast_xmit()
3166 memcpy(hdr->addr2, link->conf->addr, ETH_ALEN); in ieee80211_check_fast_xmit()
3173 /* not handled on fast-xmit */ in ieee80211_check_fast_xmit()
3177 if (sta->sta.wme) { in ieee80211_check_fast_xmit()
3187 build.key = rcu_access_pointer(sta->ptk[sta->ptk_idx]); in ieee80211_check_fast_xmit()
3189 build.key = rcu_access_pointer(sdata->default_unicast_key); in ieee80211_check_fast_xmit()
3193 gen_iv = build.key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV; in ieee80211_check_fast_xmit()
3194 iv_spc = build.key->conf.flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE; in ieee80211_check_fast_xmit()
3195 mmic = build.key->conf.flags & in ieee80211_check_fast_xmit()
3200 if (!(build.key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) in ieee80211_check_fast_xmit()
3204 if (build.key->flags & KEY_FLAG_TAINTED) in ieee80211_check_fast_xmit()
3207 switch (build.key->conf.cipher) { in ieee80211_check_fast_xmit()
3223 /* cannot handle MMIC or IV generation in xmit-fast */ in ieee80211_check_fast_xmit()
3231 /* cannot handle IV generation in fast-xmit */ in ieee80211_check_fast_xmit()
3243 build.key->conf.cipher); in ieee80211_check_fast_xmit()
3254 hdr->frame_control = fc; in ieee80211_check_fast_xmit()
3265 old = rcu_dereference_protected(sta->fast_tx, in ieee80211_check_fast_xmit()
3266 lockdep_is_held(&sta->lock)); in ieee80211_check_fast_xmit()
3267 rcu_assign_pointer(sta->fast_tx, fast_tx); in ieee80211_check_fast_xmit()
3270 spin_unlock_bh(&sta->lock); in ieee80211_check_fast_xmit()
3278 list_for_each_entry_rcu(sta, &local->sta_list, list) in ieee80211_check_fast_xmit_all()
3285 struct ieee80211_local *local = sdata->local; in ieee80211_check_fast_xmit_iface()
3290 list_for_each_entry_rcu(sta, &local->sta_list, list) { in ieee80211_check_fast_xmit_iface()
3291 if (sdata != sta->sdata && in ieee80211_check_fast_xmit_iface()
3292 (!sta->sdata->bss || sta->sdata->bss != sdata->bss)) in ieee80211_check_fast_xmit_iface()
3304 spin_lock_bh(&sta->lock); in ieee80211_clear_fast_xmit()
3305 fast_tx = rcu_dereference_protected(sta->fast_tx, in ieee80211_clear_fast_xmit()
3306 lockdep_is_held(&sta->lock)); in ieee80211_clear_fast_xmit()
3307 RCU_INIT_POINTER(sta->fast_tx, NULL); in ieee80211_clear_fast_xmit()
3308 spin_unlock_bh(&sta->lock); in ieee80211_clear_fast_xmit()
3318 I802_DEBUG_INC(local->tx_expand_skb_head); in ieee80211_amsdu_realloc_pad()
3321 wiphy_debug(local->hw.wiphy, in ieee80211_amsdu_realloc_pad()
3334 struct ieee80211_local *local = sdata->local; in ieee80211_amsdu_prepare_head()
3338 int hdr_len = fast_tx->hdr_len - sizeof(rfc1042_header); in ieee80211_amsdu_prepare_head()
3339 int subframe_len = skb->len - hdr_len; in ieee80211_amsdu_prepare_head()
3344 if (info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE) in ieee80211_amsdu_prepare_head()
3347 if (info->control.flags & IEEE80211_TX_CTRL_AMSDU) in ieee80211_amsdu_prepare_head()
3352 local->hw.extra_tx_headroom)) in ieee80211_amsdu_prepare_head()
3360 h_80211_src = data + fast_tx->sa_offs; in ieee80211_amsdu_prepare_head()
3361 h_80211_dst = data + fast_tx->da_offs; in ieee80211_amsdu_prepare_head()
3363 amsdu_hdr->h_proto = cpu_to_be16(subframe_len); in ieee80211_amsdu_prepare_head()
3364 ether_addr_copy(amsdu_hdr->h_source, h_80211_src); in ieee80211_amsdu_prepare_head()
3365 ether_addr_copy(amsdu_hdr->h_dest, h_80211_dst); in ieee80211_amsdu_prepare_head()
3367 /* according to IEEE 802.11-2012 8.3.2 table 8-19, the outer SA/DA in ieee80211_amsdu_prepare_head()
3368 * fields needs to be changed to BSSID for A-MSDU frames depending in ieee80211_amsdu_prepare_head()
3371 switch (sdata->vif.type) { in ieee80211_amsdu_prepare_head()
3373 bssid = sdata->vif.cfg.ap_addr; in ieee80211_amsdu_prepare_head()
3377 bssid = sdata->vif.addr; in ieee80211_amsdu_prepare_head()
3383 if (bssid && ieee80211_has_fromds(hdr->frame_control)) in ieee80211_amsdu_prepare_head()
3386 if (bssid && ieee80211_has_tods(hdr->frame_control)) in ieee80211_amsdu_prepare_head()
3392 info->control.flags |= IEEE80211_TX_CTRL_AMSDU; in ieee80211_amsdu_prepare_head()
3403 struct ieee80211_local *local = sdata->local; in ieee80211_amsdu_aggregate()
3404 struct fq *fq = &local->fq; in ieee80211_amsdu_aggregate()
3407 u8 tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; in ieee80211_amsdu_aggregate()
3408 struct ieee80211_txq *txq = sta->sta.txq[tid]; in ieee80211_amsdu_aggregate()
3411 int subframe_len = skb->len - ETH_ALEN; in ieee80211_amsdu_aggregate()
3412 u8 max_subframes = sta->sta.max_amsdu_subframes; in ieee80211_amsdu_aggregate()
3413 int max_frags = local->hw.max_tx_fragments; in ieee80211_amsdu_aggregate()
3414 int max_amsdu_len = sta->sta.cur->max_amsdu_len; in ieee80211_amsdu_aggregate()
3424 if (!ieee80211_hw_check(&local->hw, TX_AMSDU)) in ieee80211_amsdu_aggregate()
3427 if (sdata->vif.offload_flags & IEEE80211_OFFLOAD_ENCAP_ENABLED) in ieee80211_amsdu_aggregate()
3430 if (ieee80211_vif_is_mesh(&sdata->vif)) in ieee80211_amsdu_aggregate()
3440 if (test_bit(IEEE80211_TXQ_NO_AMSDU, &txqi->flags)) in ieee80211_amsdu_aggregate()
3443 if (sta->sta.cur->max_rc_amsdu_len) in ieee80211_amsdu_aggregate()
3445 sta->sta.cur->max_rc_amsdu_len); in ieee80211_amsdu_aggregate()
3447 if (sta->sta.cur->max_tid_amsdu_len[tid]) in ieee80211_amsdu_aggregate()
3449 sta->sta.cur->max_tid_amsdu_len[tid]); in ieee80211_amsdu_aggregate()
3453 spin_lock_bh(&fq->lock); in ieee80211_amsdu_aggregate()
3459 tin = &txqi->tin; in ieee80211_amsdu_aggregate()
3461 head = skb_peek_tail(&flow->queue); in ieee80211_amsdu_aggregate()
3465 orig_truesize = head->truesize; in ieee80211_amsdu_aggregate()
3466 orig_len = head->len; in ieee80211_amsdu_aggregate()
3468 if (skb->len + head->len > max_amsdu_len) in ieee80211_amsdu_aggregate()
3471 nfrags = 1 + skb_shinfo(skb)->nr_frags; in ieee80211_amsdu_aggregate()
3472 nfrags += 1 + skb_shinfo(head)->nr_frags; in ieee80211_amsdu_aggregate()
3473 frag_tail = &skb_shinfo(head)->frag_list; in ieee80211_amsdu_aggregate()
3475 nfrags += 1 + skb_shinfo(*frag_tail)->nr_frags; in ieee80211_amsdu_aggregate()
3476 frag_tail = &(*frag_tail)->next; in ieee80211_amsdu_aggregate()
3493 * and frag_tail should be &skb_shinfo(head)->frag_list. in ieee80211_amsdu_aggregate()
3498 frag_tail = &skb_shinfo(head)->frag_list; in ieee80211_amsdu_aggregate()
3502 * padding to the next one, that's being added. Note that head->len in ieee80211_amsdu_aggregate()
3503 * is the length of the full A-MSDU, but that works since each time in ieee80211_amsdu_aggregate()
3507 hdrlen = fast_tx->hdr_len - sizeof(rfc1042_header); in ieee80211_amsdu_aggregate()
3508 if ((head->len - hdrlen) & 3) in ieee80211_amsdu_aggregate()
3509 pad = 4 - ((head->len - hdrlen) & 3); in ieee80211_amsdu_aggregate()
3527 head->len += skb->len; in ieee80211_amsdu_aggregate()
3528 head->data_len += skb->len; in ieee80211_amsdu_aggregate()
3532 fq->memory_usage += head->truesize - orig_truesize; in ieee80211_amsdu_aggregate()
3533 if (head->len != orig_len) { in ieee80211_amsdu_aggregate()
3534 flow->backlog += head->len - orig_len; in ieee80211_amsdu_aggregate()
3535 tin->backlog_bytes += head->len - orig_len; in ieee80211_amsdu_aggregate()
3538 spin_unlock_bh(&fq->lock); in ieee80211_amsdu_aggregate()
3553 struct sk_buff *skb = tx->skb; in ieee80211_xmit_fast_finish()
3555 struct ieee80211_hdr *hdr = (void *)skb->data; in ieee80211_xmit_fast_finish()
3558 if (!ieee80211_hw_check(&tx->local->hw, HAS_RATE_CONTROL) && in ieee80211_xmit_fast_finish()
3563 info->control.hw_key = &key->conf; in ieee80211_xmit_fast_finish()
3565 dev_sw_netstats_tx_add(skb->dev, 1, skb->len); in ieee80211_xmit_fast_finish()
3567 if (hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) { in ieee80211_xmit_fast_finish()
3568 tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; in ieee80211_xmit_fast_finish()
3569 hdr->seq_ctrl = ieee80211_tx_next_seq(sta, tid); in ieee80211_xmit_fast_finish()
3571 info->flags |= IEEE80211_TX_CTL_ASSIGN_SEQ; in ieee80211_xmit_fast_finish()
3572 hdr->seq_ctrl = cpu_to_le16(sdata->sequence_number); in ieee80211_xmit_fast_finish()
3573 sdata->sequence_number += 0x10; in ieee80211_xmit_fast_finish()
3576 if (skb_shinfo(skb)->gso_size) in ieee80211_xmit_fast_finish()
3577 sta->deflink.tx_stats.msdu[tid] += in ieee80211_xmit_fast_finish()
3578 DIV_ROUND_UP(skb->len, skb_shinfo(skb)->gso_size); in ieee80211_xmit_fast_finish()
3580 sta->deflink.tx_stats.msdu[tid]++; in ieee80211_xmit_fast_finish()
3582 info->hw_queue = sdata->vif.hw_queue[skb_get_queue_mapping(skb)]; in ieee80211_xmit_fast_finish()
3587 sta->deflink.tx_stats.bytes[skb_get_queue_mapping(skb)] += skb->len; in ieee80211_xmit_fast_finish()
3588 sta->deflink.tx_stats.packets[skb_get_queue_mapping(skb)]++; in ieee80211_xmit_fast_finish()
3592 u8 *crypto_hdr = skb->data + pn_offs; in ieee80211_xmit_fast_finish()
3594 switch (key->conf.cipher) { in ieee80211_xmit_fast_finish()
3599 pn = atomic64_inc_return(&key->conf.tx_pn); in ieee80211_xmit_fast_finish()
3602 crypto_hdr[3] = 0x20 | (key->conf.keyidx << 6); in ieee80211_xmit_fast_finish()
3617 if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN) in ieee80211_sdata_netdev_features()
3618 return sdata->vif.netdev_features; in ieee80211_sdata_netdev_features()
3620 if (!sdata->bss) in ieee80211_sdata_netdev_features()
3623 sdata = container_of(sdata->bss, struct ieee80211_sub_if_data, u.ap); in ieee80211_sdata_netdev_features()
3624 return sdata->vif.netdev_features; in ieee80211_sdata_netdev_features()
3646 if (skb->ip_summed == CHECKSUM_PARTIAL) { in ieee80211_tx_skb_fixup()
3649 if (skb->encapsulation) in ieee80211_tx_skb_fixup()
3672 struct ieee80211_local *local = sdata->local; in __ieee80211_xmit_fast()
3673 struct ieee80211_hdr *hdr = (void *)fast_tx->hdr; in __ieee80211_xmit_fast()
3677 int hw_headroom = sdata->local->hw.extra_tx_headroom; in __ieee80211_xmit_fast()
3678 int extra_head = fast_tx->hdr_len - (ETH_HLEN - 2); in __ieee80211_xmit_fast()
3684 if ((hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) && in __ieee80211_xmit_fast()
3688 /* will not be crypto-handled beyond what we do here, so use false in __ieee80211_xmit_fast()
3689 * as the may-encrypt argument for the resize to not account for in __ieee80211_xmit_fast()
3693 max_t(int, extra_head + hw_headroom - in __ieee80211_xmit_fast()
3699 memcpy(skb->data, fast_tx->hdr, fast_tx->hdr_len); in __ieee80211_xmit_fast()
3700 memcpy(skb->data + fast_tx->da_offs, da, ETH_ALEN); in __ieee80211_xmit_fast()
3701 memcpy(skb->data + fast_tx->sa_offs, sa, ETH_ALEN); in __ieee80211_xmit_fast()
3705 info->band = fast_tx->band; in __ieee80211_xmit_fast()
3706 info->control.vif = &sdata->vif; in __ieee80211_xmit_fast()
3707 info->flags = IEEE80211_TX_CTL_FIRST_FRAGMENT | in __ieee80211_xmit_fast()
3709 info->control.flags = IEEE80211_TX_CTRL_FAST_XMIT | in __ieee80211_xmit_fast()
3714 if (local->force_tx_status) in __ieee80211_xmit_fast()
3715 info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS; in __ieee80211_xmit_fast()
3718 if (hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) { in __ieee80211_xmit_fast()
3719 u8 tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; in __ieee80211_xmit_fast()
3730 tx.key = fast_tx->key; in __ieee80211_xmit_fast()
3736 r = ieee80211_xmit_fast_finish(sdata, sta, fast_tx->pn_offs, in __ieee80211_xmit_fast()
3737 fast_tx->key, &tx); in __ieee80211_xmit_fast()
3742 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) in __ieee80211_xmit_fast()
3743 sdata = container_of(sdata->bss, in __ieee80211_xmit_fast()
3747 ieee80211_tx_frags(local, &sdata->vif, sta, &tx.skbs, false); in __ieee80211_xmit_fast()
3759 u16 ethertype = (skb->data[12] << 8) | skb->data[13]; in ieee80211_xmit_fast()
3760 struct ieee80211_hdr *hdr = (void *)fast_tx->hdr; in ieee80211_xmit_fast()
3767 if (cpu_to_be16(ethertype) == sdata->control_port_protocol) in ieee80211_xmit_fast()
3775 if (skb->sk && skb_shinfo(skb)->tx_flags & SKBTX_WIFI_STATUS) in ieee80211_xmit_fast()
3778 if (hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) { in ieee80211_xmit_fast()
3779 tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; in ieee80211_xmit_fast()
3780 tid_tx = rcu_dereference(sta->ampdu_mlme.tid_tx[tid]); in ieee80211_xmit_fast()
3782 if (!test_bit(HT_AGG_STATE_OPERATIONAL, &tid_tx->state)) in ieee80211_xmit_fast()
3784 if (tid_tx->timeout) in ieee80211_xmit_fast()
3785 tid_tx->last_tx = jiffies; in ieee80211_xmit_fast()
3789 memcpy(ð, skb->data, ETH_HLEN - 2); in ieee80211_xmit_fast()
3812 struct fq *fq = &local->fq; in ieee80211_tx_dequeue()
3813 struct fq_tin *tin = &txqi->tin; in ieee80211_tx_dequeue()
3817 struct ieee80211_vif *vif = txq->vif; in ieee80211_tx_dequeue()
3818 int q = vif->hw_queue[txq->ac]; in ieee80211_tx_dequeue()
3828 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in ieee80211_tx_dequeue()
3829 q_stopped = local->queue_stop_reasons[q]; in ieee80211_tx_dequeue()
3830 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_tx_dequeue()
3834 set_bit(IEEE80211_TXQ_DIRTY, &txqi->flags); in ieee80211_tx_dequeue()
3838 spin_lock_bh(&fq->lock); in ieee80211_tx_dequeue()
3841 skb = __skb_dequeue(&txqi->frags); in ieee80211_tx_dequeue()
3843 if (!(IEEE80211_SKB_CB(skb)->control.flags & in ieee80211_tx_dequeue()
3846 IEEE80211_SKB_CB(skb)->control.flags &= in ieee80211_tx_dequeue()
3849 if (unlikely(test_bit(IEEE80211_TXQ_STOP, &txqi->flags))) in ieee80211_tx_dequeue()
3858 spin_unlock_bh(&fq->lock); in ieee80211_tx_dequeue()
3860 hdr = (struct ieee80211_hdr *)skb->data; in ieee80211_tx_dequeue()
3867 tx.sdata = vif_to_sdata(info->control.vif); in ieee80211_tx_dequeue()
3869 if (txq->sta) { in ieee80211_tx_dequeue()
3870 tx.sta = container_of(txq->sta, struct sta_info, sta); in ieee80211_tx_dequeue()
3875 if (unlikely(!(info->flags & IEEE80211_TX_CTL_INJECTED) && in ieee80211_tx_dequeue()
3876 ieee80211_is_data(hdr->frame_control) && in ieee80211_tx_dequeue()
3877 !ieee80211_vif_is_mesh(&tx.sdata->vif) && in ieee80211_tx_dequeue()
3878 tx.sdata->vif.type != NL80211_IFTYPE_OCB && in ieee80211_tx_dequeue()
3879 !is_multicast_ether_addr(hdr->addr1) && in ieee80211_tx_dequeue()
3881 (!(info->control.flags & in ieee80211_tx_dequeue()
3883 !ieee80211_is_our_addr(tx.sdata, hdr->addr2, in ieee80211_tx_dequeue()
3885 I802_DEBUG_INC(local->tx_handlers_drop_unauth_port); in ieee80211_tx_dequeue()
3886 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_dequeue()
3897 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_dequeue()
3901 if (test_bit(IEEE80211_TXQ_AMPDU, &txqi->flags)) in ieee80211_tx_dequeue()
3902 info->flags |= (IEEE80211_TX_CTL_AMPDU | in ieee80211_tx_dequeue()
3905 if (info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP) { in ieee80211_tx_dequeue()
3906 if (!ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL)) { in ieee80211_tx_dequeue()
3909 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_dequeue()
3916 if (info->control.flags & IEEE80211_TX_CTRL_FAST_XMIT) { in ieee80211_tx_dequeue()
3917 struct sta_info *sta = container_of(txq->sta, struct sta_info, in ieee80211_tx_dequeue()
3922 (tx.key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)) in ieee80211_tx_dequeue()
3923 pn_offs = ieee80211_hdrlen(hdr->frame_control); in ieee80211_tx_dequeue()
3925 r = ieee80211_xmit_fast_finish(sta->sdata, sta, pn_offs, in ieee80211_tx_dequeue()
3928 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_dequeue()
3939 spin_lock_bh(&fq->lock); in ieee80211_tx_dequeue()
3940 skb_queue_splice_tail(&tx.skbs, &txqi->frags); in ieee80211_tx_dequeue()
3941 spin_unlock_bh(&fq->lock); in ieee80211_tx_dequeue()
3946 !ieee80211_hw_check(&local->hw, TX_FRAG_LIST)) { in ieee80211_tx_dequeue()
3948 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_dequeue()
3953 switch (tx.sdata->vif.type) { in ieee80211_tx_dequeue()
3955 if (tx.sdata->u.mntr.flags & MONITOR_FLAG_ACTIVE) { in ieee80211_tx_dequeue()
3956 vif = &tx.sdata->vif; in ieee80211_tx_dequeue()
3959 tx.sdata = rcu_dereference(local->monitor_sdata); in ieee80211_tx_dequeue()
3961 ieee80211_hw_check(&local->hw, WANT_MONITOR_VIF)) { in ieee80211_tx_dequeue()
3962 vif = &tx.sdata->vif; in ieee80211_tx_dequeue()
3963 info->hw_queue = in ieee80211_tx_dequeue()
3964 vif->hw_queue[skb_get_queue_mapping(skb)]; in ieee80211_tx_dequeue()
3965 } else if (ieee80211_hw_check(&local->hw, QUEUE_CONTROL)) { in ieee80211_tx_dequeue()
3966 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_dequeue()
3969 info->control.vif = NULL; in ieee80211_tx_dequeue()
3974 tx.sdata = container_of(tx.sdata->bss, in ieee80211_tx_dequeue()
3978 vif = &tx.sdata->vif; in ieee80211_tx_dequeue()
3983 info->control.vif = vif; in ieee80211_tx_dequeue()
3986 wiphy_ext_feature_isset(local->hw.wiphy, NL80211_EXT_FEATURE_AQL)) { in ieee80211_tx_dequeue()
3987 bool ampdu = txq->ac != IEEE80211_AC_VO; in ieee80211_tx_dequeue()
3990 airtime = ieee80211_calc_expected_tx_airtime(hw, vif, txq->sta, in ieee80211_tx_dequeue()
3991 skb->len, ampdu); in ieee80211_tx_dequeue()
3995 txq->ac, in ieee80211_tx_dequeue()
4004 spin_unlock_bh(&fq->lock); in ieee80211_tx_dequeue()
4010 static inline s32 ieee80211_sta_deficit(struct sta_info *sta, u8 ac) in ieee80211_sta_deficit() argument
4012 struct airtime_info *air_info = &sta->airtime[ac]; in ieee80211_sta_deficit()
4014 return air_info->deficit - atomic_read(&air_info->aql_tx_pending); in ieee80211_sta_deficit()
4022 if (!txqi->txq.sta) in ieee80211_txq_set_active()
4025 sta = container_of(txqi->txq.sta, struct sta_info, sta); in ieee80211_txq_set_active()
4026 sta->airtime[txqi->txq.ac].last_active = jiffies; in ieee80211_txq_set_active()
4034 if (!txqi->txq.sta) in ieee80211_txq_keep_active()
4037 sta = container_of(txqi->txq.sta, struct sta_info, sta); in ieee80211_txq_keep_active()
4038 if (ieee80211_sta_deficit(sta, txqi->txq.ac) >= 0) in ieee80211_txq_keep_active()
4041 return ieee80211_sta_keep_active(sta, txqi->txq.ac); in ieee80211_txq_keep_active()
4044 struct ieee80211_txq *ieee80211_next_txq(struct ieee80211_hw *hw, u8 ac) in ieee80211_next_txq() argument
4051 spin_lock_bh(&local->active_txq_lock[ac]); in ieee80211_next_txq()
4053 if (!local->schedule_round[ac]) in ieee80211_next_txq()
4057 txqi = list_first_entry_or_null(&local->active_txqs[ac], in ieee80211_next_txq()
4073 if (txqi->txq.sta) { in ieee80211_next_txq()
4074 struct sta_info *sta = container_of(txqi->txq.sta, in ieee80211_next_txq()
4076 bool aql_check = ieee80211_txq_airtime_check(hw, &txqi->txq); in ieee80211_next_txq()
4077 s32 deficit = ieee80211_sta_deficit(sta, txqi->txq.ac); in ieee80211_next_txq()
4083 sta->airtime[txqi->txq.ac].deficit += in ieee80211_next_txq()
4084 sta->airtime_weight; in ieee80211_next_txq()
4087 list_move_tail(&txqi->schedule_order, in ieee80211_next_txq()
4088 &local->active_txqs[txqi->txq.ac]); in ieee80211_next_txq()
4093 if (txqi->schedule_round == local->schedule_round[ac]) in ieee80211_next_txq()
4096 list_del_init(&txqi->schedule_order); in ieee80211_next_txq()
4097 txqi->schedule_round = local->schedule_round[ac]; in ieee80211_next_txq()
4098 ret = &txqi->txq; in ieee80211_next_txq()
4101 spin_unlock_bh(&local->active_txq_lock[ac]); in ieee80211_next_txq()
4114 spin_lock_bh(&local->active_txq_lock[txq->ac]); in __ieee80211_schedule_txq()
4117 if (list_empty(&txqi->schedule_order) && in __ieee80211_schedule_txq()
4126 if (txqi->txq.sta && local->airtime_flags && has_queue && in __ieee80211_schedule_txq()
4127 wiphy_ext_feature_isset(local->hw.wiphy, in __ieee80211_schedule_txq()
4129 list_add(&txqi->schedule_order, in __ieee80211_schedule_txq()
4130 &local->active_txqs[txq->ac]); in __ieee80211_schedule_txq()
4132 list_add_tail(&txqi->schedule_order, in __ieee80211_schedule_txq()
4133 &local->active_txqs[txq->ac]); in __ieee80211_schedule_txq()
4138 spin_unlock_bh(&local->active_txq_lock[txq->ac]); in __ieee80211_schedule_txq()
4150 if (!wiphy_ext_feature_isset(local->hw.wiphy, NL80211_EXT_FEATURE_AQL)) in ieee80211_txq_airtime_check()
4156 if (!txq->sta) in ieee80211_txq_airtime_check()
4159 if (unlikely(txq->tid == IEEE80211_NUM_TIDS)) in ieee80211_txq_airtime_check()
4162 sta = container_of(txq->sta, struct sta_info, sta); in ieee80211_txq_airtime_check()
4163 if (atomic_read(&sta->airtime[txq->ac].aql_tx_pending) < in ieee80211_txq_airtime_check()
4164 sta->airtime[txq->ac].aql_limit_low) in ieee80211_txq_airtime_check()
4167 if (atomic_read(&local->aql_total_pending_airtime) < in ieee80211_txq_airtime_check()
4168 local->aql_threshold && in ieee80211_txq_airtime_check()
4169 atomic_read(&sta->airtime[txq->ac].aql_tx_pending) < in ieee80211_txq_airtime_check()
4170 sta->airtime[txq->ac].aql_limit_high) in ieee80211_txq_airtime_check()
4178 ieee80211_txq_schedule_airtime_check(struct ieee80211_local *local, u8 ac) in ieee80211_txq_schedule_airtime_check() argument
4184 if (!wiphy_ext_feature_isset(local->hw.wiphy, NL80211_EXT_FEATURE_AQL)) in ieee80211_txq_schedule_airtime_check()
4187 list_for_each_entry(txq, &local->active_txqs[ac], schedule_order) in ieee80211_txq_schedule_airtime_check()
4190 aql_limit = (num_txq - 1) * local->aql_txq_limit_low[ac] / 2 + in ieee80211_txq_schedule_airtime_check()
4191 local->aql_txq_limit_high[ac]; in ieee80211_txq_schedule_airtime_check()
4193 return atomic_read(&local->aql_ac_pending_airtime[ac]) < aql_limit; in ieee80211_txq_schedule_airtime_check()
4202 u8 ac = txq->ac; in ieee80211_txq_may_transmit() local
4204 spin_lock_bh(&local->active_txq_lock[ac]); in ieee80211_txq_may_transmit()
4206 if (!txqi->txq.sta) in ieee80211_txq_may_transmit()
4209 if (list_empty(&txqi->schedule_order)) in ieee80211_txq_may_transmit()
4212 if (!ieee80211_txq_schedule_airtime_check(local, ac)) in ieee80211_txq_may_transmit()
4215 list_for_each_entry_safe(iter, tmp, &local->active_txqs[ac], in ieee80211_txq_may_transmit()
4220 if (!iter->txq.sta) { in ieee80211_txq_may_transmit()
4221 list_move_tail(&iter->schedule_order, in ieee80211_txq_may_transmit()
4222 &local->active_txqs[ac]); in ieee80211_txq_may_transmit()
4225 sta = container_of(iter->txq.sta, struct sta_info, sta); in ieee80211_txq_may_transmit()
4226 if (ieee80211_sta_deficit(sta, ac) < 0) in ieee80211_txq_may_transmit()
4227 sta->airtime[ac].deficit += sta->airtime_weight; in ieee80211_txq_may_transmit()
4228 list_move_tail(&iter->schedule_order, &local->active_txqs[ac]); in ieee80211_txq_may_transmit()
4231 sta = container_of(txqi->txq.sta, struct sta_info, sta); in ieee80211_txq_may_transmit()
4232 if (sta->airtime[ac].deficit >= 0) in ieee80211_txq_may_transmit()
4235 sta->airtime[ac].deficit += sta->airtime_weight; in ieee80211_txq_may_transmit()
4236 list_move_tail(&txqi->schedule_order, &local->active_txqs[ac]); in ieee80211_txq_may_transmit()
4237 spin_unlock_bh(&local->active_txq_lock[ac]); in ieee80211_txq_may_transmit()
4241 if (!list_empty(&txqi->schedule_order)) in ieee80211_txq_may_transmit()
4242 list_del_init(&txqi->schedule_order); in ieee80211_txq_may_transmit()
4243 spin_unlock_bh(&local->active_txq_lock[ac]); in ieee80211_txq_may_transmit()
4249 void ieee80211_txq_schedule_start(struct ieee80211_hw *hw, u8 ac) in ieee80211_txq_schedule_start() argument
4253 spin_lock_bh(&local->active_txq_lock[ac]); in ieee80211_txq_schedule_start()
4255 if (ieee80211_txq_schedule_airtime_check(local, ac)) { in ieee80211_txq_schedule_start()
4256 local->schedule_round[ac]++; in ieee80211_txq_schedule_start()
4257 if (!local->schedule_round[ac]) in ieee80211_txq_schedule_start()
4258 local->schedule_round[ac]++; in ieee80211_txq_schedule_start()
4260 local->schedule_round[ac] = 0; in ieee80211_txq_schedule_start()
4263 spin_unlock_bh(&local->active_txq_lock[ac]); in ieee80211_txq_schedule_start()
4274 struct ieee80211_local *local = sdata->local; in __ieee80211_subif_start_xmit()
4277 int len = skb->len; in __ieee80211_subif_start_xmit()
4279 if (unlikely(!ieee80211_sdata_running(sdata) || skb->len < ETH_HLEN)) { in __ieee80211_subif_start_xmit()
4284 sk_pacing_shift_update(skb->sk, sdata->local->hw.tx_sk_pacing_shift); in __ieee80211_subif_start_xmit()
4288 if (ieee80211_vif_is_mesh(&sdata->vif) && in __ieee80211_subif_start_xmit()
4289 ieee80211_hw_check(&local->hw, SUPPORT_FAST_XMIT) && in __ieee80211_subif_start_xmit()
4305 fast_tx = rcu_dereference(sta->fast_tx); in __ieee80211_subif_start_xmit()
4312 /* the frame could be fragmented, software-encrypted, and other in __ieee80211_subif_start_xmit()
4325 if (skb->protocol == sdata->control_port_protocol) in __ieee80211_subif_start_xmit()
4335 dev_sw_netstats_tx_add(dev, 1, skb->len); in __ieee80211_subif_start_xmit()
4358 eth = (void *)skb->data; in ieee80211_change_da()
4359 ether_addr_copy(eth->h_dest, sta->sta.addr); in ieee80211_change_da()
4368 const struct ethhdr *eth = (void *)skb->data; in ieee80211_multicast_to_unicast()
4369 const struct vlan_ethhdr *ethvlan = (void *)skb->data; in ieee80211_multicast_to_unicast()
4372 switch (sdata->vif.type) { in ieee80211_multicast_to_unicast()
4374 if (sdata->u.vlan.sta) in ieee80211_multicast_to_unicast()
4376 if (sdata->wdev.use_4addr) in ieee80211_multicast_to_unicast()
4381 if (!sdata->bss->multicast_to_unicast) in ieee80211_multicast_to_unicast()
4389 ethertype = eth->h_proto; in ieee80211_multicast_to_unicast()
4390 if (ethertype == htons(ETH_P_8021Q) && skb->len >= VLAN_ETH_HLEN) in ieee80211_multicast_to_unicast()
4391 ethertype = ethvlan->h_vlan_encapsulated_proto; in ieee80211_multicast_to_unicast()
4409 struct ieee80211_local *local = sdata->local; in ieee80211_convert_to_unicast()
4410 const struct ethhdr *eth = (struct ethhdr *)skb->data; in ieee80211_convert_to_unicast()
4416 list_for_each_entry_rcu(sta, &local->sta_list, list) { in ieee80211_convert_to_unicast()
4417 if (sdata != sta->sdata) in ieee80211_convert_to_unicast()
4418 /* AP-VLAN mismatch */ in ieee80211_convert_to_unicast()
4420 if (unlikely(ether_addr_equal(eth->h_source, sta->sta.addr))) in ieee80211_convert_to_unicast()
4466 __ieee80211_subif_start_xmit(out, sdata->dev, 0, ctrl_flags, NULL); in ieee80211_mlo_multicast_tx_one()
4473 unsigned long links = sdata->vif.active_links; in ieee80211_mlo_multicast_tx()
4474 unsigned int link; in ieee80211_mlo_multicast_tx() local
4481 __ieee80211_subif_start_xmit(skb, sdata->dev, 0, ctrl_flags, in ieee80211_mlo_multicast_tx()
4486 for_each_set_bit(link, &links, IEEE80211_MLD_MAX_NUM_LINKS) { in ieee80211_mlo_multicast_tx()
4487 ieee80211_mlo_multicast_tx_one(sdata, skb, ctrl_flags, link); in ieee80211_mlo_multicast_tx()
4494 * ieee80211_subif_start_xmit - netif start_xmit function for 802.3 vifs
4506 const struct ethhdr *eth = (void *)skb->data; in ieee80211_subif_start_xmit()
4508 if (likely(!is_multicast_ether_addr(eth->h_dest))) in ieee80211_subif_start_xmit()
4525 } else if (ieee80211_vif_is_mld(&sdata->vif) && in ieee80211_subif_start_xmit()
4526 sdata->vif.type == NL80211_IFTYPE_AP && in ieee80211_subif_start_xmit()
4527 !ieee80211_hw_check(&sdata->local->hw, MLO_MCAST_MULTI_LINK_TX)) { in ieee80211_subif_start_xmit()
4545 struct ieee80211_local *local = sdata->local; in __ieee80211_tx_8023()
4550 int q = info->hw_queue; in __ieee80211_tx_8023()
4552 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in __ieee80211_tx_8023()
4554 if (local->queue_stop_reasons[q] || in __ieee80211_tx_8023()
4555 (!txpending && !skb_queue_empty(&local->pending[q]))) { in __ieee80211_tx_8023()
4557 skb_queue_head(&local->pending[q], skb); in __ieee80211_tx_8023()
4559 skb_queue_tail(&local->pending[q], skb); in __ieee80211_tx_8023()
4561 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in __ieee80211_tx_8023()
4566 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in __ieee80211_tx_8023()
4568 if (sta && sta->uploaded) in __ieee80211_tx_8023()
4569 pubsta = &sta->sta; in __ieee80211_tx_8023()
4582 struct ieee80211_local *local = sdata->local; in ieee80211_tx_8023()
4603 struct ieee80211_local *local = sdata->local; in ieee80211_8023_xmit()
4613 if (unlikely(test_bit(SCAN_SW_SCANNING, &local->scanning)) && in ieee80211_8023_xmit()
4614 test_bit(SDATA_STATE_OFFCHANNEL, &sdata->state)) in ieee80211_8023_xmit()
4623 tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; in ieee80211_8023_xmit()
4624 tid_tx = rcu_dereference(sta->ampdu_mlme.tid_tx[tid]); in ieee80211_8023_xmit()
4626 if (!test_bit(HT_AGG_STATE_OPERATIONAL, &tid_tx->state)) { in ieee80211_8023_xmit()
4627 /* fall back to non-offload slow path */ in ieee80211_8023_xmit()
4634 if (tid_tx->timeout) in ieee80211_8023_xmit()
4635 tid_tx->last_tx = jiffies; in ieee80211_8023_xmit()
4645 info->hw_queue = sdata->vif.hw_queue[queue]; in ieee80211_8023_xmit()
4647 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) in ieee80211_8023_xmit()
4648 sdata = container_of(sdata->bss, in ieee80211_8023_xmit()
4651 info->flags |= IEEE80211_TX_CTL_HW_80211_ENCAP; in ieee80211_8023_xmit()
4652 info->control.vif = &sdata->vif; in ieee80211_8023_xmit()
4655 info->control.hw_key = &key->conf; in ieee80211_8023_xmit()
4659 len += seg->len; in ieee80211_8023_xmit()
4664 if (unlikely(skb->sk && in ieee80211_8023_xmit()
4665 skb_shinfo(skb)->tx_flags & SKBTX_WIFI_STATUS)) { in ieee80211_8023_xmit()
4666 info->status_data = ieee80211_store_ack_skb(local, skb, in ieee80211_8023_xmit()
4667 &info->flags, NULL); in ieee80211_8023_xmit()
4668 if (info->status_data) in ieee80211_8023_xmit()
4669 info->status_data_idr = 1; in ieee80211_8023_xmit()
4673 sta->deflink.tx_stats.packets[queue] += skbs; in ieee80211_8023_xmit()
4674 sta->deflink.tx_stats.bytes[queue] += len; in ieee80211_8023_xmit()
4690 struct ethhdr *ehdr = (struct ethhdr *)skb->data; in ieee80211_subif_start_xmit_8023()
4694 if (unlikely(!ieee80211_sdata_running(sdata) || skb->len < ETH_HLEN)) { in ieee80211_subif_start_xmit_8023()
4706 if (unlikely(IS_ERR_OR_NULL(sta) || !sta->uploaded || in ieee80211_subif_start_xmit_8023()
4708 sdata->control_port_protocol == ehdr->h_proto)) in ieee80211_subif_start_xmit_8023()
4711 key = rcu_dereference(sta->ptk[sta->ptk_idx]); in ieee80211_subif_start_xmit_8023()
4713 key = rcu_dereference(sdata->default_unicast_key); in ieee80211_subif_start_xmit_8023()
4715 if (key && (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) || in ieee80211_subif_start_xmit_8023()
4716 key->conf.cipher == WLAN_CIPHER_SUITE_TKIP)) in ieee80211_subif_start_xmit_8023()
4719 sk_pacing_shift_update(skb->sk, sdata->local->hw.tx_sk_pacing_shift); in ieee80211_subif_start_xmit_8023()
4737 .local = sdata->local, in ieee80211_build_data_template()
4746 skb = ERR_PTR(-EINVAL); in ieee80211_build_data_template()
4755 hdr = (void *)skb->data; in ieee80211_build_data_template()
4756 tx.sta = sta_info_get(sdata, hdr->addr1); in ieee80211_build_data_template()
4762 return ERR_PTR(-EINVAL); in ieee80211_build_data_template()
4779 for (i = 0; i < local->hw.queues; i++) { in ieee80211_clear_tx_pending()
4780 while ((skb = skb_dequeue(&local->pending[i])) != NULL) in ieee80211_clear_tx_pending()
4781 ieee80211_free_txskb(&local->hw, skb); in ieee80211_clear_tx_pending()
4787 * which in this case means re-queued -- take as an indication to stop sending
4800 sdata = vif_to_sdata(info->control.vif); in ieee80211_tx_pending_skb()
4802 if (info->control.flags & IEEE80211_TX_INTCFL_NEED_TXPROCESSING) { in ieee80211_tx_pending_skb()
4803 /* update band only for non-MLD */ in ieee80211_tx_pending_skb()
4804 if (!ieee80211_vif_is_mld(&sdata->vif)) { in ieee80211_tx_pending_skb()
4806 rcu_dereference(sdata->vif.bss_conf.chanctx_conf); in ieee80211_tx_pending_skb()
4811 info->band = chanctx_conf->def.chan->band; in ieee80211_tx_pending_skb()
4814 } else if (info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP) { in ieee80211_tx_pending_skb()
4820 if (IS_ERR(sta) || (sta && !sta->uploaded)) in ieee80211_tx_pending_skb()
4830 hdr = (struct ieee80211_hdr *)skb->data; in ieee80211_tx_pending_skb()
4831 sta = sta_info_get(sdata, hdr->addr1); in ieee80211_tx_pending_skb()
4852 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in ieee80211_tx_pending()
4853 for (i = 0; i < local->hw.queues; i++) { in ieee80211_tx_pending()
4858 if (local->queue_stop_reasons[i] || in ieee80211_tx_pending()
4859 skb_queue_empty(&local->pending[i])) in ieee80211_tx_pending()
4862 while (!skb_queue_empty(&local->pending[i])) { in ieee80211_tx_pending()
4863 struct sk_buff *skb = __skb_dequeue(&local->pending[i]); in ieee80211_tx_pending()
4866 if (WARN_ON(!info->control.vif)) { in ieee80211_tx_pending()
4867 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_pending()
4871 spin_unlock_irqrestore(&local->queue_stop_reason_lock, in ieee80211_tx_pending()
4875 spin_lock_irqsave(&local->queue_stop_reason_lock, in ieee80211_tx_pending()
4881 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_tx_pending()
4889 struct ieee80211_link_data *link, in __ieee80211_beacon_add_tim() argument
4896 struct ieee80211_bss_conf *link_conf = link->conf; in __ieee80211_beacon_add_tim()
4900 if (atomic_read(&ps->num_sta_ps) > 0) in __ieee80211_beacon_add_tim()
4902 * checking byte-for-byte */ in __ieee80211_beacon_add_tim()
4903 have_bits = !bitmap_empty((unsigned long *)ps->tim, in __ieee80211_beacon_add_tim()
4906 if (ps->dtim_count == 0) in __ieee80211_beacon_add_tim()
4907 ps->dtim_count = link_conf->dtim_period - 1; in __ieee80211_beacon_add_tim()
4909 ps->dtim_count--; in __ieee80211_beacon_add_tim()
4915 *pos++ = ps->dtim_count; in __ieee80211_beacon_add_tim()
4916 *pos++ = link_conf->dtim_period; in __ieee80211_beacon_add_tim()
4918 if (ps->dtim_count == 0 && !skb_queue_empty(&ps->bc_buf)) in __ieee80211_beacon_add_tim()
4921 ps->dtim_bc_mc = aid0 == 1; in __ieee80211_beacon_add_tim()
4925 * (N1 x 8) - 1 in the bitmap are 0 and number N2 so that bits in __ieee80211_beacon_add_tim()
4929 if (ps->tim[i]) { in __ieee80211_beacon_add_tim()
4935 for (i = IEEE80211_MAX_TIM_LEN - 1; i >= n1; i--) { in __ieee80211_beacon_add_tim()
4936 if (ps->tim[i]) { in __ieee80211_beacon_add_tim()
4945 skb_put_data(skb, ps->tim + n1, n2 - n1 + 1); in __ieee80211_beacon_add_tim()
4947 tim[1] = n2 - n1 + 4; in __ieee80211_beacon_add_tim()
4951 if (ieee80211_get_link_sband(link)->band != NL80211_BAND_S1GHZ) { in __ieee80211_beacon_add_tim()
4960 struct ieee80211_link_data *link, in ieee80211_beacon_add_tim() argument
4964 struct ieee80211_local *local = sdata->local; in ieee80211_beacon_add_tim()
4970 * sta_lock to guarantee consistent and race-free update in ieee80211_beacon_add_tim()
4973 if (local->tim_in_locked_section) { in ieee80211_beacon_add_tim()
4974 __ieee80211_beacon_add_tim(sdata, link, ps, skb, is_template); in ieee80211_beacon_add_tim()
4976 spin_lock_bh(&local->tim_lock); in ieee80211_beacon_add_tim()
4977 __ieee80211_beacon_add_tim(sdata, link, ps, skb, is_template); in ieee80211_beacon_add_tim()
4978 spin_unlock_bh(&local->tim_lock); in ieee80211_beacon_add_tim()
4986 struct ieee80211_link_data *link) in ieee80211_set_beacon_cntdwn() argument
4994 switch (sdata->vif.type) { in ieee80211_set_beacon_cntdwn()
4996 beacon_data = beacon->tail; in ieee80211_set_beacon_cntdwn()
4997 beacon_data_len = beacon->tail_len; in ieee80211_set_beacon_cntdwn()
5000 beacon_data = beacon->head; in ieee80211_set_beacon_cntdwn()
5001 beacon_data_len = beacon->head_len; in ieee80211_set_beacon_cntdwn()
5004 beacon_data = beacon->head; in ieee80211_set_beacon_cntdwn()
5005 beacon_data_len = beacon->head_len; in ieee80211_set_beacon_cntdwn()
5011 resp = rcu_dereference(link->u.ap.probe_resp); in ieee80211_set_beacon_cntdwn()
5013 bcn_offsets = beacon->cntdwn_counter_offsets; in ieee80211_set_beacon_cntdwn()
5014 count = beacon->cntdwn_current_counter; in ieee80211_set_beacon_cntdwn()
5015 if (link->conf->csa_active) in ieee80211_set_beacon_cntdwn()
5025 if (sdata->vif.type == NL80211_IFTYPE_AP && resp) { in ieee80211_set_beacon_cntdwn()
5026 u16 *resp_offsets = resp->cntdwn_counter_offsets; in ieee80211_set_beacon_cntdwn()
5028 resp->data[resp_offsets[i]] = count; in ieee80211_set_beacon_cntdwn()
5035 beacon->cntdwn_current_counter--; in __ieee80211_beacon_update_cntdwn()
5038 WARN_ON_ONCE(!beacon->cntdwn_current_counter); in __ieee80211_beacon_update_cntdwn()
5040 return beacon->cntdwn_current_counter; in __ieee80211_beacon_update_cntdwn()
5046 struct ieee80211_link_data *link; in ieee80211_beacon_update_cntdwn() local
5055 link = rcu_dereference(sdata->link[link_id]); in ieee80211_beacon_update_cntdwn()
5056 if (!link) in ieee80211_beacon_update_cntdwn()
5059 if (sdata->vif.type == NL80211_IFTYPE_AP) in ieee80211_beacon_update_cntdwn()
5060 beacon = rcu_dereference(link->u.ap.beacon); in ieee80211_beacon_update_cntdwn()
5061 else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) in ieee80211_beacon_update_cntdwn()
5062 beacon = rcu_dereference(sdata->u.ibss.presp); in ieee80211_beacon_update_cntdwn()
5063 else if (ieee80211_vif_is_mesh(&sdata->vif)) in ieee80211_beacon_update_cntdwn()
5064 beacon = rcu_dereference(sdata->u.mesh.beacon); in ieee80211_beacon_update_cntdwn()
5084 if (sdata->vif.type == NL80211_IFTYPE_AP) in ieee80211_beacon_set_cntdwn()
5085 beacon = rcu_dereference(sdata->deflink.u.ap.beacon); in ieee80211_beacon_set_cntdwn()
5086 else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) in ieee80211_beacon_set_cntdwn()
5087 beacon = rcu_dereference(sdata->u.ibss.presp); in ieee80211_beacon_set_cntdwn()
5088 else if (ieee80211_vif_is_mesh(&sdata->vif)) in ieee80211_beacon_set_cntdwn()
5089 beacon = rcu_dereference(sdata->u.mesh.beacon); in ieee80211_beacon_set_cntdwn()
5094 if (counter < beacon->cntdwn_current_counter) in ieee80211_beacon_set_cntdwn()
5095 beacon->cntdwn_current_counter = counter; in ieee80211_beacon_set_cntdwn()
5106 struct ieee80211_link_data *link; in ieee80211_beacon_cntdwn_is_complete() local
5120 link = rcu_dereference(sdata->link[link_id]); in ieee80211_beacon_cntdwn_is_complete()
5121 if (!link) in ieee80211_beacon_cntdwn_is_complete()
5124 if (vif->type == NL80211_IFTYPE_AP) { in ieee80211_beacon_cntdwn_is_complete()
5125 beacon = rcu_dereference(link->u.ap.beacon); in ieee80211_beacon_cntdwn_is_complete()
5126 if (WARN_ON(!beacon || !beacon->tail)) in ieee80211_beacon_cntdwn_is_complete()
5128 beacon_data = beacon->tail; in ieee80211_beacon_cntdwn_is_complete()
5129 beacon_data_len = beacon->tail_len; in ieee80211_beacon_cntdwn_is_complete()
5130 } else if (vif->type == NL80211_IFTYPE_ADHOC) { in ieee80211_beacon_cntdwn_is_complete()
5131 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; in ieee80211_beacon_cntdwn_is_complete()
5133 beacon = rcu_dereference(ifibss->presp); in ieee80211_beacon_cntdwn_is_complete()
5137 beacon_data = beacon->head; in ieee80211_beacon_cntdwn_is_complete()
5138 beacon_data_len = beacon->head_len; in ieee80211_beacon_cntdwn_is_complete()
5139 } else if (vif->type == NL80211_IFTYPE_MESH_POINT) { in ieee80211_beacon_cntdwn_is_complete()
5140 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; in ieee80211_beacon_cntdwn_is_complete()
5142 beacon = rcu_dereference(ifmsh->beacon); in ieee80211_beacon_cntdwn_is_complete()
5146 beacon_data = beacon->head; in ieee80211_beacon_cntdwn_is_complete()
5147 beacon_data_len = beacon->head_len; in ieee80211_beacon_cntdwn_is_complete()
5153 if (!beacon->cntdwn_counter_offsets[0]) in ieee80211_beacon_cntdwn_is_complete()
5156 if (WARN_ON_ONCE(beacon->cntdwn_counter_offsets[0] > beacon_data_len)) in ieee80211_beacon_cntdwn_is_complete()
5159 if (beacon_data[beacon->cntdwn_counter_offsets[0]] == 1) in ieee80211_beacon_cntdwn_is_complete()
5172 struct ieee80211_link_data *link) in ieee80211_beacon_protect() argument
5179 tx.key = rcu_dereference(link->default_beacon_key); in ieee80211_beacon_protect()
5183 if (unlikely(tx.key->flags & KEY_FLAG_TAINTED)) { in ieee80211_beacon_protect()
5185 return -EINVAL; in ieee80211_beacon_protect()
5188 if (!(tx.key->conf.flags & IEEE80211_KEY_FLAG_SW_MGMT_TX) && in ieee80211_beacon_protect()
5189 tx.key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) in ieee80211_beacon_protect()
5190 IEEE80211_SKB_CB(skb)->control.hw_key = &tx.key->conf; in ieee80211_beacon_protect()
5201 return -EINVAL; in ieee80211_beacon_protect()
5209 struct ieee80211_link_data *link, in ieee80211_beacon_get_finish() argument
5227 u16 csa_off = beacon->cntdwn_counter_offsets[i]; in ieee80211_beacon_get_finish()
5232 offs->cntdwn_counter_offs[i] = csa_off_base + csa_off; in ieee80211_beacon_get_finish()
5236 band = chanctx_conf->def.chan->band; in ieee80211_beacon_get_finish()
5238 info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; in ieee80211_beacon_get_finish()
5239 info->flags |= IEEE80211_TX_CTL_NO_ACK; in ieee80211_beacon_get_finish()
5240 info->band = band; in ieee80211_beacon_get_finish()
5244 txrc.sband = local->hw.wiphy->bands[band]; in ieee80211_beacon_get_finish()
5245 txrc.bss_conf = link->conf; in ieee80211_beacon_get_finish()
5247 txrc.reported_rate.idx = -1; in ieee80211_beacon_get_finish()
5248 if (sdata->beacon_rate_set && sdata->beacon_rateidx_mask[band]) in ieee80211_beacon_get_finish()
5249 txrc.rate_idx_mask = sdata->beacon_rateidx_mask[band]; in ieee80211_beacon_get_finish()
5251 txrc.rate_idx_mask = sdata->rc_rateidx_mask[band]; in ieee80211_beacon_get_finish()
5255 info->control.vif = vif; in ieee80211_beacon_get_finish()
5256 info->control.flags |= u32_encode_bits(link->link_id, in ieee80211_beacon_get_finish()
5258 info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT | in ieee80211_beacon_get_finish()
5267 if (!beacon->mbssid_ies || !beacon->mbssid_ies->cnt || in ieee80211_beacon_add_mbssid()
5268 i > beacon->mbssid_ies->cnt) in ieee80211_beacon_add_mbssid()
5271 if (i < beacon->mbssid_ies->cnt) { in ieee80211_beacon_add_mbssid()
5272 skb_put_data(skb, beacon->mbssid_ies->elem[i].data, in ieee80211_beacon_add_mbssid()
5273 beacon->mbssid_ies->elem[i].len); in ieee80211_beacon_add_mbssid()
5275 if (beacon->rnr_ies && beacon->rnr_ies->cnt) { in ieee80211_beacon_add_mbssid()
5276 skb_put_data(skb, beacon->rnr_ies->elem[i].data, in ieee80211_beacon_add_mbssid()
5277 beacon->rnr_ies->elem[i].len); in ieee80211_beacon_add_mbssid()
5279 for (i = beacon->mbssid_ies->cnt; i < beacon->rnr_ies->cnt; i++) in ieee80211_beacon_add_mbssid()
5280 skb_put_data(skb, beacon->rnr_ies->elem[i].data, in ieee80211_beacon_add_mbssid()
5281 beacon->rnr_ies->elem[i].len); in ieee80211_beacon_add_mbssid()
5286 /* i == beacon->mbssid_ies->cnt, include all MBSSID elements */ in ieee80211_beacon_add_mbssid()
5287 for (i = 0; i < beacon->mbssid_ies->cnt; i++) in ieee80211_beacon_add_mbssid()
5288 skb_put_data(skb, beacon->mbssid_ies->elem[i].data, in ieee80211_beacon_add_mbssid()
5289 beacon->mbssid_ies->elem[i].len); in ieee80211_beacon_add_mbssid()
5295 struct ieee80211_link_data *link, in ieee80211_beacon_get_ap() argument
5304 struct ieee80211_if_ap *ap = &sdata->u.ap; in ieee80211_beacon_get_ap()
5309 if (beacon->cntdwn_counter_offsets[0]) { in ieee80211_beacon_get_ap()
5311 ieee80211_beacon_update_cntdwn(vif, link->link_id); in ieee80211_beacon_get_ap()
5313 ieee80211_set_beacon_cntdwn(sdata, beacon, link); in ieee80211_beacon_get_ap()
5319 mbssid_len = ieee80211_get_mbssid_beacon_len(beacon->mbssid_ies, in ieee80211_beacon_get_ap()
5320 beacon->rnr_ies, in ieee80211_beacon_get_ap()
5323 skb = dev_alloc_skb(local->tx_headroom + beacon->head_len + in ieee80211_beacon_get_ap()
5324 beacon->tail_len + 256 + in ieee80211_beacon_get_ap()
5325 local->hw.extra_beacon_tailroom + mbssid_len); in ieee80211_beacon_get_ap()
5329 skb_reserve(skb, local->tx_headroom); in ieee80211_beacon_get_ap()
5330 skb_put_data(skb, beacon->head, beacon->head_len); in ieee80211_beacon_get_ap()
5332 ieee80211_beacon_add_tim(sdata, link, &ap->ps, skb, is_template); in ieee80211_beacon_get_ap()
5335 offs->tim_offset = beacon->head_len; in ieee80211_beacon_get_ap()
5336 offs->tim_length = skb->len - beacon->head_len; in ieee80211_beacon_get_ap()
5337 offs->cntdwn_counter_offs[0] = beacon->cntdwn_counter_offsets[0]; in ieee80211_beacon_get_ap()
5341 offs->mbssid_off = skb->len - mbssid_len; in ieee80211_beacon_get_ap()
5345 csa_off_base = skb->len; in ieee80211_beacon_get_ap()
5348 if (beacon->tail) in ieee80211_beacon_get_ap()
5349 skb_put_data(skb, beacon->tail, beacon->tail_len); in ieee80211_beacon_get_ap()
5351 if (ieee80211_beacon_protect(skb, local, sdata, link) < 0) { in ieee80211_beacon_get_ap()
5356 ieee80211_beacon_get_finish(hw, vif, link, offs, beacon, skb, in ieee80211_beacon_get_ap()
5364 struct ieee80211_link_data *link, in ieee80211_beacon_get_ap_ema_list() argument
5371 if (!beacon->mbssid_ies || !beacon->mbssid_ies->cnt) in ieee80211_beacon_get_ap_ema_list()
5374 ema = kzalloc(struct_size(ema, bcn, beacon->mbssid_ies->cnt), in ieee80211_beacon_get_ap_ema_list()
5379 for (ema->cnt = 0; ema->cnt < beacon->mbssid_ies->cnt; ema->cnt++) { in ieee80211_beacon_get_ap_ema_list()
5380 ema->bcn[ema->cnt].skb = in ieee80211_beacon_get_ap_ema_list()
5381 ieee80211_beacon_get_ap(hw, vif, link, in ieee80211_beacon_get_ap_ema_list()
5382 &ema->bcn[ema->cnt].offs, in ieee80211_beacon_get_ap_ema_list()
5384 chanctx_conf, ema->cnt); in ieee80211_beacon_get_ap_ema_list()
5385 if (!ema->bcn[ema->cnt].skb) in ieee80211_beacon_get_ap_ema_list()
5389 if (ema->cnt == beacon->mbssid_ies->cnt) in ieee80211_beacon_get_ap_ema_list()
5396 #define IEEE80211_INCLUDE_ALL_MBSSID_ELEMS -1
5412 struct ieee80211_link_data *link; in __ieee80211_beacon_get() local
5417 link = rcu_dereference(sdata->link[link_id]); in __ieee80211_beacon_get()
5418 if (!link) in __ieee80211_beacon_get()
5421 rcu_dereference(link->conf->chanctx_conf); in __ieee80211_beacon_get()
5429 if (sdata->vif.type == NL80211_IFTYPE_AP) { in __ieee80211_beacon_get()
5430 beacon = rcu_dereference(link->u.ap.beacon); in __ieee80211_beacon_get()
5436 ieee80211_beacon_get_ap_ema_list(hw, vif, link, in __ieee80211_beacon_get()
5442 if (beacon->mbssid_ies && beacon->mbssid_ies->cnt) { in __ieee80211_beacon_get()
5443 if (ema_index >= beacon->mbssid_ies->cnt) in __ieee80211_beacon_get()
5447 ema_index = beacon->mbssid_ies->cnt; in __ieee80211_beacon_get()
5452 skb = ieee80211_beacon_get_ap(hw, vif, link, offs, in __ieee80211_beacon_get()
5457 } else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) { in __ieee80211_beacon_get()
5458 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; in __ieee80211_beacon_get()
5461 beacon = rcu_dereference(ifibss->presp); in __ieee80211_beacon_get()
5465 if (beacon->cntdwn_counter_offsets[0]) { in __ieee80211_beacon_get()
5469 ieee80211_set_beacon_cntdwn(sdata, beacon, link); in __ieee80211_beacon_get()
5472 skb = dev_alloc_skb(local->tx_headroom + beacon->head_len + in __ieee80211_beacon_get()
5473 local->hw.extra_beacon_tailroom); in __ieee80211_beacon_get()
5476 skb_reserve(skb, local->tx_headroom); in __ieee80211_beacon_get()
5477 skb_put_data(skb, beacon->head, beacon->head_len); in __ieee80211_beacon_get()
5479 hdr = (struct ieee80211_hdr *) skb->data; in __ieee80211_beacon_get()
5480 hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | in __ieee80211_beacon_get()
5483 ieee80211_beacon_get_finish(hw, vif, link, offs, beacon, skb, in __ieee80211_beacon_get()
5485 } else if (ieee80211_vif_is_mesh(&sdata->vif)) { in __ieee80211_beacon_get()
5486 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; in __ieee80211_beacon_get()
5488 beacon = rcu_dereference(ifmsh->beacon); in __ieee80211_beacon_get()
5492 if (beacon->cntdwn_counter_offsets[0]) { in __ieee80211_beacon_get()
5501 ieee80211_set_beacon_cntdwn(sdata, beacon, link); in __ieee80211_beacon_get()
5504 if (ifmsh->sync_ops) in __ieee80211_beacon_get()
5505 ifmsh->sync_ops->adjust_tsf(sdata, beacon); in __ieee80211_beacon_get()
5507 skb = dev_alloc_skb(local->tx_headroom + in __ieee80211_beacon_get()
5508 beacon->head_len + in __ieee80211_beacon_get()
5510 beacon->tail_len + in __ieee80211_beacon_get()
5511 local->hw.extra_beacon_tailroom); in __ieee80211_beacon_get()
5514 skb_reserve(skb, local->tx_headroom); in __ieee80211_beacon_get()
5515 skb_put_data(skb, beacon->head, beacon->head_len); in __ieee80211_beacon_get()
5516 ieee80211_beacon_add_tim(sdata, link, &ifmsh->ps, skb, in __ieee80211_beacon_get()
5520 offs->tim_offset = beacon->head_len; in __ieee80211_beacon_get()
5521 offs->tim_length = skb->len - beacon->head_len; in __ieee80211_beacon_get()
5524 skb_put_data(skb, beacon->tail, beacon->tail_len); in __ieee80211_beacon_get()
5525 ieee80211_beacon_get_finish(hw, vif, link, offs, beacon, skb, in __ieee80211_beacon_get()
5567 for (i = 0; i < ema_beacons->cnt; i++) in ieee80211_beacon_free_ema_list()
5568 kfree_skb(ema_beacons->bcn[i].skb); in ieee80211_beacon_free_ema_list()
5610 !hw_to_local(hw)->monitors) in ieee80211_beacon_get_tim()
5632 if (sdata->vif.type != NL80211_IFTYPE_AP) in ieee80211_proberesp_get()
5636 presp = rcu_dereference(sdata->deflink.u.ap.probe_resp); in ieee80211_proberesp_get()
5640 skb = dev_alloc_skb(presp->len); in ieee80211_proberesp_get()
5644 skb_put_data(skb, presp->data, presp->len); in ieee80211_proberesp_get()
5646 hdr = (struct ieee80211_hdr *) skb->data; in ieee80211_proberesp_get()
5647 memset(hdr->addr1, 0, sizeof(hdr->addr1)); in ieee80211_proberesp_get()
5662 if (sdata->vif.type != NL80211_IFTYPE_AP) in ieee80211_get_fils_discovery_tmpl()
5666 tmpl = rcu_dereference(sdata->deflink.u.ap.fils_discovery); in ieee80211_get_fils_discovery_tmpl()
5672 skb = dev_alloc_skb(sdata->local->hw.extra_tx_headroom + tmpl->len); in ieee80211_get_fils_discovery_tmpl()
5674 skb_reserve(skb, sdata->local->hw.extra_tx_headroom); in ieee80211_get_fils_discovery_tmpl()
5675 skb_put_data(skb, tmpl->data, tmpl->len); in ieee80211_get_fils_discovery_tmpl()
5691 if (sdata->vif.type != NL80211_IFTYPE_AP) in ieee80211_get_unsol_bcast_probe_resp_tmpl()
5695 tmpl = rcu_dereference(sdata->deflink.u.ap.unsol_bcast_probe_resp); in ieee80211_get_unsol_bcast_probe_resp_tmpl()
5701 skb = dev_alloc_skb(sdata->local->hw.extra_tx_headroom + tmpl->len); in ieee80211_get_unsol_bcast_probe_resp_tmpl()
5703 skb_reserve(skb, sdata->local->hw.extra_tx_headroom); in ieee80211_get_unsol_bcast_probe_resp_tmpl()
5704 skb_put_data(skb, tmpl->data, tmpl->len); in ieee80211_get_unsol_bcast_probe_resp_tmpl()
5720 if (WARN_ON(vif->type != NL80211_IFTYPE_STATION)) in ieee80211_pspoll_get()
5724 local = sdata->local; in ieee80211_pspoll_get()
5726 skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*pspoll)); in ieee80211_pspoll_get()
5730 skb_reserve(skb, local->hw.extra_tx_headroom); in ieee80211_pspoll_get()
5733 pspoll->frame_control = cpu_to_le16(IEEE80211_FTYPE_CTL | in ieee80211_pspoll_get()
5735 pspoll->aid = cpu_to_le16(sdata->vif.cfg.aid); in ieee80211_pspoll_get()
5737 /* aid in PS-Poll has its two MSBs each set to 1 */ in ieee80211_pspoll_get()
5738 pspoll->aid |= cpu_to_le16(1 << 15 | 1 << 14); in ieee80211_pspoll_get()
5740 memcpy(pspoll->bssid, sdata->deflink.u.mgd.bssid, ETH_ALEN); in ieee80211_pspoll_get()
5741 memcpy(pspoll->ta, vif->addr, ETH_ALEN); in ieee80211_pspoll_get()
5752 struct ieee80211_local *local = sdata->local; in ieee80211_nullfunc_get()
5753 struct ieee80211_link_data *link = NULL; in ieee80211_nullfunc_get() local
5758 if (WARN_ON(vif->type != NL80211_IFTYPE_STATION)) in ieee80211_nullfunc_get()
5761 skb = dev_alloc_skb(local->hw.extra_tx_headroom + in ieee80211_nullfunc_get()
5770 sta = sta_info_get(sdata, vif->cfg.ap_addr); in ieee80211_nullfunc_get()
5771 qos = sta && sta->sta.wme; in ieee80211_nullfunc_get()
5775 link = rcu_dereference(sdata->link[link_id]); in ieee80211_nullfunc_get()
5776 if (WARN_ON_ONCE(!link)) { in ieee80211_nullfunc_get()
5783 skb_reserve(skb, local->hw.extra_tx_headroom); in ieee80211_nullfunc_get()
5786 nullfunc->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA | in ieee80211_nullfunc_get()
5795 nullfunc->frame_control |= in ieee80211_nullfunc_get()
5797 skb->priority = 7; in ieee80211_nullfunc_get()
5802 if (link) { in ieee80211_nullfunc_get()
5803 memcpy(nullfunc->addr1, link->conf->bssid, ETH_ALEN); in ieee80211_nullfunc_get()
5804 memcpy(nullfunc->addr2, link->conf->addr, ETH_ALEN); in ieee80211_nullfunc_get()
5805 memcpy(nullfunc->addr3, link->conf->bssid, ETH_ALEN); in ieee80211_nullfunc_get()
5807 memcpy(nullfunc->addr1, vif->cfg.ap_addr, ETH_ALEN); in ieee80211_nullfunc_get()
5808 memcpy(nullfunc->addr2, vif->addr, ETH_ALEN); in ieee80211_nullfunc_get()
5809 memcpy(nullfunc->addr3, vif->cfg.ap_addr, ETH_ALEN); in ieee80211_nullfunc_get()
5830 skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*hdr) + in ieee80211_probereq_get()
5835 skb_reserve(skb, local->hw.extra_tx_headroom); in ieee80211_probereq_get()
5838 hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | in ieee80211_probereq_get()
5840 eth_broadcast_addr(hdr->addr1); in ieee80211_probereq_get()
5841 memcpy(hdr->addr2, src_addr, ETH_ALEN); in ieee80211_probereq_get()
5842 eth_broadcast_addr(hdr->addr3); in ieee80211_probereq_get()
5862 rts->frame_control = in ieee80211_rts_get()
5864 rts->duration = ieee80211_rts_duration(hw, vif, frame_len, in ieee80211_rts_get()
5866 memcpy(rts->ra, hdr->addr1, sizeof(rts->ra)); in ieee80211_rts_get()
5867 memcpy(rts->ta, hdr->addr2, sizeof(rts->ta)); in ieee80211_rts_get()
5878 cts->frame_control = in ieee80211_ctstoself_get()
5880 cts->duration = ieee80211_ctstoself_duration(hw, vif, in ieee80211_ctstoself_get()
5882 memcpy(cts->ra, hdr->addr1, sizeof(cts->ra)); in ieee80211_ctstoself_get()
5901 chanctx_conf = rcu_dereference(sdata->vif.bss_conf.chanctx_conf); in ieee80211_get_buffered_bc()
5906 if (sdata->vif.type == NL80211_IFTYPE_AP) { in ieee80211_get_buffered_bc()
5908 rcu_dereference(sdata->deflink.u.ap.beacon); in ieee80211_get_buffered_bc()
5910 if (!beacon || !beacon->head) in ieee80211_get_buffered_bc()
5913 ps = &sdata->u.ap.ps; in ieee80211_get_buffered_bc()
5914 } else if (ieee80211_vif_is_mesh(&sdata->vif)) { in ieee80211_get_buffered_bc()
5915 ps = &sdata->u.mesh.ps; in ieee80211_get_buffered_bc()
5920 if (ps->dtim_count != 0 || !ps->dtim_bc_mc) in ieee80211_get_buffered_bc()
5924 skb = skb_dequeue(&ps->bc_buf); in ieee80211_get_buffered_bc()
5927 local->total_ps_buffered--; in ieee80211_get_buffered_bc()
5929 if (!skb_queue_empty(&ps->bc_buf) && skb->len >= 2) { in ieee80211_get_buffered_bc()
5931 (struct ieee80211_hdr *) skb->data; in ieee80211_get_buffered_bc()
5935 hdr->frame_control |= in ieee80211_get_buffered_bc()
5939 if (sdata->vif.type == NL80211_IFTYPE_AP) in ieee80211_get_buffered_bc()
5940 sdata = IEEE80211_DEV_TO_SUB_IF(skb->dev); in ieee80211_get_buffered_bc()
5949 info->band = chanctx_conf->def.chan->band; in ieee80211_get_buffered_bc()
5963 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_reserve_tid()
5964 struct ieee80211_local *local = sdata->local; in ieee80211_reserve_tid()
5968 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_reserve_tid()
5971 switch (sdata->vif.type) { in ieee80211_reserve_tid()
5978 return -EINVAL; in ieee80211_reserve_tid()
5982 return -EINVAL; in ieee80211_reserve_tid()
5984 if (sta->reserved_tid == tid) { in ieee80211_reserve_tid()
5989 if (sta->reserved_tid != IEEE80211_TID_UNRESERVED) { in ieee80211_reserve_tid()
5991 ret = -EALREADY; in ieee80211_reserve_tid()
5995 ieee80211_stop_vif_queues(sdata->local, sdata, in ieee80211_reserve_tid()
6001 if (ieee80211_hw_check(&local->hw, AMPDU_AGGREGATION)) { in ieee80211_reserve_tid()
6007 queues = BIT(sdata->vif.hw_queue[ieee802_1d_to_ac[tid]]); in ieee80211_reserve_tid()
6010 sta->reserved_tid = tid; in ieee80211_reserve_tid()
6015 if (ieee80211_hw_check(&local->hw, AMPDU_AGGREGATION)) in ieee80211_reserve_tid()
6027 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_unreserve_tid()
6029 lockdep_assert_wiphy(sdata->local->hw.wiphy); in ieee80211_unreserve_tid()
6032 switch (sdata->vif.type) { in ieee80211_unreserve_tid()
6042 if (tid != sta->reserved_tid) { in ieee80211_unreserve_tid()
6047 sta->reserved_tid = IEEE80211_TID_UNRESERVED; in ieee80211_unreserve_tid()
6055 const struct ieee80211_hdr *hdr = (void *)skb->data; in __ieee80211_tx_skb_tid_band()
6056 int ac = ieee80211_ac_from_tid(tid); in __ieee80211_tx_skb_tid_band() local
6057 unsigned int link; in __ieee80211_tx_skb_tid_band() local
6060 skb_set_queue_mapping(skb, ac); in __ieee80211_tx_skb_tid_band()
6061 skb->priority = tid; in __ieee80211_tx_skb_tid_band()
6063 skb->dev = sdata->dev; in __ieee80211_tx_skb_tid_band()
6069 if (!ieee80211_vif_is_mld(&sdata->vif)) { in __ieee80211_tx_skb_tid_band()
6070 link = 0; in __ieee80211_tx_skb_tid_band()
6072 link = link_id; in __ieee80211_tx_skb_tid_band()
6073 } else if (memcmp(sdata->vif.addr, hdr->addr2, ETH_ALEN) == 0) { in __ieee80211_tx_skb_tid_band()
6075 link = IEEE80211_LINK_UNSPECIFIED; in __ieee80211_tx_skb_tid_band()
6077 /* otherwise must be addressed from a link */ in __ieee80211_tx_skb_tid_band()
6079 for (link = 0; link < ARRAY_SIZE(sdata->vif.link_conf); link++) { in __ieee80211_tx_skb_tid_band()
6082 link_conf = rcu_dereference(sdata->vif.link_conf[link]); in __ieee80211_tx_skb_tid_band()
6085 if (memcmp(link_conf->addr, hdr->addr2, ETH_ALEN) == 0) in __ieee80211_tx_skb_tid_band()
6090 if (WARN_ON_ONCE(link == ARRAY_SIZE(sdata->vif.link_conf))) in __ieee80211_tx_skb_tid_band()
6091 link = ffs(sdata->vif.active_links) - 1; in __ieee80211_tx_skb_tid_band()
6094 IEEE80211_SKB_CB(skb)->control.flags |= in __ieee80211_tx_skb_tid_band()
6095 u32_encode_bits(link, IEEE80211_TX_CTRL_MLO_LINK); in __ieee80211_tx_skb_tid_band()
6103 IEEE80211_SKB_CB(skb)->band = band; in __ieee80211_tx_skb_tid_band()
6115 if (!ieee80211_vif_is_mld(&sdata->vif)) { in ieee80211_tx_skb_tid()
6118 rcu_dereference(sdata->vif.bss_conf.chanctx_conf); in ieee80211_tx_skb_tid()
6124 band = chanctx_conf->def.chan->band; in ieee80211_tx_skb_tid()
6127 !(sdata->vif.active_links & BIT(link_id))); in ieee80211_tx_skb_tid()
6142 struct ieee80211_local *local = sdata->local; in ieee80211_tx_control_port()
6151 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_tx_control_port()
6154 * or Pre-Authentication in ieee80211_tx_control_port()
6156 if (proto != sdata->control_port_protocol && in ieee80211_tx_control_port()
6158 return -EINVAL; in ieee80211_tx_control_port()
6160 if (proto == sdata->control_port_protocol) in ieee80211_tx_control_port()
6172 skb = dev_alloc_skb(local->hw.extra_tx_headroom + in ieee80211_tx_control_port()
6175 return -ENOMEM; in ieee80211_tx_control_port()
6177 skb_reserve(skb, local->hw.extra_tx_headroom + sizeof(struct ethhdr)); in ieee80211_tx_control_port()
6182 memcpy(ehdr->h_dest, dest, ETH_ALEN); in ieee80211_tx_control_port()
6188 memcpy(ehdr->h_source, sdata->vif.addr, ETH_ALEN); in ieee80211_tx_control_port()
6196 link_conf = rcu_dereference(sdata->vif.link_conf[link_id]); in ieee80211_tx_control_port()
6200 return -ENOLINK; in ieee80211_tx_control_port()
6202 memcpy(ehdr->h_source, link_conf->addr, ETH_ALEN); in ieee80211_tx_control_port()
6206 ehdr->h_proto = proto; in ieee80211_tx_control_port()
6208 skb->dev = dev; in ieee80211_tx_control_port()
6209 skb->protocol = proto; in ieee80211_tx_control_port()
6213 if (local->hw.queues < IEEE80211_NUM_ACS) in ieee80211_tx_control_port()
6235 * the link ID has been selected already in ieee80211_tx_control_port()
6237 if (sta && sta->sta.mlo) in ieee80211_tx_control_port()
6238 memcpy(ehdr->h_source, sdata->vif.addr, ETH_ALEN); in ieee80211_tx_control_port()
6244 __ieee80211_subif_start_xmit(skb, skb->dev, flags, ctrl_flags, cookie); in ieee80211_tx_control_port()
6254 struct ieee80211_local *local = sdata->local; in ieee80211_probe_mesh_link()
6257 skb = dev_alloc_skb(local->hw.extra_tx_headroom + len + in ieee80211_probe_mesh_link()
6261 return -ENOMEM; in ieee80211_probe_mesh_link()
6263 skb_reserve(skb, local->hw.extra_tx_headroom); in ieee80211_probe_mesh_link()
6266 skb->dev = dev; in ieee80211_probe_mesh_link()
6267 skb->protocol = htons(ETH_P_802_3); in ieee80211_probe_mesh_link()
6272 __ieee80211_subif_start_xmit(skb, skb->dev, 0, in ieee80211_probe_mesh_link()