Lines Matching +full:led +full:- +full:7 +full:seg
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"
33 #include "led.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()
369 list_for_each_entry_rcu(sta, &local->sta_list, list) { in purge_old_ps_buffers()
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()
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()
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()
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()
1031 if (!tx->sta) in ieee80211_tx_h_stats()
1034 skb_queue_walk(&tx->skbs, skb) { in ieee80211_tx_h_stats()
1036 tx->sta->deflink.tx_stats.bytes[ac] += skb->len; 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()
1186 (!sta->sta.valid_links && !sta->sta.deflink.ht_cap.ht_supported) || in ieee80211_aggr_check()
1187 !sta->sta.wme || skb_get_queue_mapping(skb) == IEEE80211_AC_VO || in ieee80211_aggr_check()
1188 skb->protocol == sdata->control_port_protocol) in ieee80211_aggr_check()
1191 tid = skb->priority & IEEE80211_QOS_CTL_TID_MASK; in ieee80211_aggr_check()
1192 if (likely(sta->ampdu_mlme.tid_tx[tid])) in ieee80211_aggr_check()
1195 ieee80211_start_tx_ba_session(&sta->sta, tid, 0); in ieee80211_aggr_check()
1208 struct ieee80211_local *local = sdata->local; in ieee80211_tx_prepare()
1215 tx->skb = skb; in ieee80211_tx_prepare()
1216 tx->local = local; in ieee80211_tx_prepare()
1217 tx->sdata = sdata; in ieee80211_tx_prepare()
1218 __skb_queue_head_init(&tx->skbs); in ieee80211_tx_prepare()
1225 info->control.flags &= ~IEEE80211_TX_INTCFL_NEED_TXPROCESSING; in ieee80211_tx_prepare()
1227 hdr = (struct ieee80211_hdr *) skb->data; in ieee80211_tx_prepare()
1231 tx->sta = sta; in ieee80211_tx_prepare()
1233 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) { in ieee80211_tx_prepare()
1234 tx->sta = rcu_dereference(sdata->u.vlan.sta); in ieee80211_tx_prepare()
1235 if (!tx->sta && sdata->wdev.use_4addr) in ieee80211_tx_prepare()
1237 } else if (tx->sdata->control_port_protocol == tx->skb->protocol) { in ieee80211_tx_prepare()
1238 tx->sta = sta_info_get_bss(sdata, hdr->addr1); in ieee80211_tx_prepare()
1240 if (!tx->sta && !is_multicast_ether_addr(hdr->addr1)) { in ieee80211_tx_prepare()
1241 tx->sta = sta_info_get(sdata, hdr->addr1); in ieee80211_tx_prepare()
1246 if (tx->sta && ieee80211_is_data_qos(hdr->frame_control) && in ieee80211_tx_prepare()
1247 !ieee80211_is_qos_nullfunc(hdr->frame_control) && in ieee80211_tx_prepare()
1248 ieee80211_hw_check(&local->hw, AMPDU_AGGREGATION) && in ieee80211_tx_prepare()
1249 !ieee80211_hw_check(&local->hw, TX_AMPDU_SETUP_IN_HW)) { in ieee80211_tx_prepare()
1253 tid_tx = rcu_dereference(tx->sta->ampdu_mlme.tid_tx[tid]); in ieee80211_tx_prepare()
1255 ieee80211_aggr_check(sdata, tx->sta, skb); in ieee80211_tx_prepare()
1256 tid_tx = rcu_dereference(tx->sta->ampdu_mlme.tid_tx[tid]); in ieee80211_tx_prepare()
1270 if (is_multicast_ether_addr(hdr->addr1)) { in ieee80211_tx_prepare()
1271 tx->flags &= ~IEEE80211_TX_UNICAST; in ieee80211_tx_prepare()
1272 info->flags |= IEEE80211_TX_CTL_NO_ACK; in ieee80211_tx_prepare()
1274 tx->flags |= IEEE80211_TX_UNICAST; in ieee80211_tx_prepare()
1276 if (!(info->flags & IEEE80211_TX_CTL_DONTFRAG)) { in ieee80211_tx_prepare()
1277 if (!(tx->flags & IEEE80211_TX_UNICAST) || in ieee80211_tx_prepare()
1278 skb->len + FCS_LEN <= local->hw.wiphy->frag_threshold || in ieee80211_tx_prepare()
1279 info->flags & IEEE80211_TX_CTL_AMPDU) in ieee80211_tx_prepare()
1280 info->flags |= IEEE80211_TX_CTL_DONTFRAG; in ieee80211_tx_prepare()
1283 if (!tx->sta) in ieee80211_tx_prepare()
1284 info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT; in ieee80211_tx_prepare()
1285 else if (test_and_clear_sta_flag(tx->sta, WLAN_STA_CLEAR_PS_FILT)) { in ieee80211_tx_prepare()
1286 info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT; in ieee80211_tx_prepare()
1287 ieee80211_check_fast_xmit(tx->sta); in ieee80211_tx_prepare()
1290 info->flags |= IEEE80211_TX_CTL_FIRST_FRAGMENT; in ieee80211_tx_prepare()
1300 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; in ieee80211_get_txq()
1304 if ((info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM) || in ieee80211_get_txq()
1305 (info->control.flags & IEEE80211_TX_CTRL_PS_RESPONSE)) in ieee80211_get_txq()
1308 if (!(info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP) && in ieee80211_get_txq()
1309 unlikely(!ieee80211_is_data_present(hdr->frame_control))) { in ieee80211_get_txq()
1310 if ((!ieee80211_is_mgmt(hdr->frame_control) || in ieee80211_get_txq()
1312 vif->type == NL80211_IFTYPE_STATION) && in ieee80211_get_txq()
1313 sta && sta->uploaded) { in ieee80211_get_txq()
1316 * opt-in hardware flag. in ieee80211_get_txq()
1318 txq = sta->sta.txq[IEEE80211_NUM_TIDS]; in ieee80211_get_txq()
1321 u8 tid = skb->priority & IEEE80211_QOS_CTL_TID_MASK; in ieee80211_get_txq()
1323 if (!sta->uploaded) in ieee80211_get_txq()
1326 txq = sta->sta.txq[tid]; in ieee80211_get_txq()
1328 txq = vif->txq; in ieee80211_get_txq()
1343 IEEE80211_SKB_CB(skb)->control.enqueue_time = now; in ieee80211_set_skb_enqueue_time()
1348 return skb->len; in codel_skb_len_func()
1355 info = (const struct ieee80211_tx_info *)skb->cb; in codel_skb_time_func()
1356 return info->control.enqueue_time; in codel_skb_time_func()
1368 local = vif_to_sdata(txqi->txq.vif)->local; in codel_dequeue_func()
1369 fq = &local->fq; in codel_dequeue_func()
1371 if (cvars == &txqi->def_cvars) in codel_dequeue_func()
1372 flow = &txqi->tin.default_flow; in codel_dequeue_func()
1374 flow = &fq->flows[cvars - local->cvars]; in codel_dequeue_func()
1387 local = vif_to_sdata(txqi->txq.vif)->local; in codel_drop_func()
1388 hw = &local->hw; in codel_drop_func()
1405 cstats = &txqi->cstats; in fq_tin_dequeue_func()
1407 if (txqi->txq.sta) { in fq_tin_dequeue_func()
1408 struct sta_info *sta = container_of(txqi->txq.sta, in fq_tin_dequeue_func()
1410 cparams = &sta->cparams; in fq_tin_dequeue_func()
1412 cparams = &local->cparams; in fq_tin_dequeue_func()
1415 if (flow == &tin->default_flow) in fq_tin_dequeue_func()
1416 cvars = &txqi->def_cvars; in fq_tin_dequeue_func()
1418 cvars = &local->cvars[flow - fq->flows]; in fq_tin_dequeue_func()
1421 &flow->backlog, in fq_tin_dequeue_func()
1439 ieee80211_free_txskb(&local->hw, skb); in fq_skb_free_func()
1446 struct fq *fq = &local->fq; in ieee80211_txq_enqueue()
1447 struct fq_tin *tin = &txqi->tin; in ieee80211_txq_enqueue()
1452 spin_lock_bh(&fq->lock); in ieee80211_txq_enqueue()
1459 if (unlikely(txqi->txq.tid == IEEE80211_NUM_TIDS)) { in ieee80211_txq_enqueue()
1460 IEEE80211_SKB_CB(skb)->control.flags |= in ieee80211_txq_enqueue()
1462 __skb_queue_tail(&txqi->frags, skb); in ieee80211_txq_enqueue()
1467 spin_unlock_bh(&fq->lock); in ieee80211_txq_enqueue()
1476 return info->control.vif == data; in fq_vlan_filter_func()
1482 struct fq *fq = &local->fq; in ieee80211_txq_remove_vlan()
1487 if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_AP_VLAN)) in ieee80211_txq_remove_vlan()
1490 ap = container_of(sdata->bss, struct ieee80211_sub_if_data, u.ap); in ieee80211_txq_remove_vlan()
1492 if (!ap->vif.txq) in ieee80211_txq_remove_vlan()
1495 txqi = to_txq_info(ap->vif.txq); in ieee80211_txq_remove_vlan()
1496 tin = &txqi->tin; in ieee80211_txq_remove_vlan()
1498 spin_lock_bh(&fq->lock); in ieee80211_txq_remove_vlan()
1499 fq_tin_filter(fq, tin, fq_vlan_filter_func, &sdata->vif, in ieee80211_txq_remove_vlan()
1501 spin_unlock_bh(&fq->lock); in ieee80211_txq_remove_vlan()
1508 fq_tin_init(&txqi->tin); in ieee80211_txq_init()
1509 codel_vars_init(&txqi->def_cvars); in ieee80211_txq_init()
1510 codel_stats_init(&txqi->cstats); in ieee80211_txq_init()
1511 __skb_queue_head_init(&txqi->frags); in ieee80211_txq_init()
1512 INIT_LIST_HEAD(&txqi->schedule_order); in ieee80211_txq_init()
1514 txqi->txq.vif = &sdata->vif; in ieee80211_txq_init()
1517 sdata->vif.txq = &txqi->txq; in ieee80211_txq_init()
1518 txqi->txq.tid = 0; in ieee80211_txq_init()
1519 txqi->txq.ac = IEEE80211_AC_BE; in ieee80211_txq_init()
1525 if (sdata->vif.type == NL80211_IFTYPE_STATION) { in ieee80211_txq_init()
1527 if (!ieee80211_hw_check(&sdata->local->hw, in ieee80211_txq_init()
1530 } else if (!ieee80211_hw_check(&sdata->local->hw, in ieee80211_txq_init()
1535 txqi->txq.ac = IEEE80211_AC_VO; in ieee80211_txq_init()
1537 txqi->txq.ac = ieee80211_ac_from_tid(tid); in ieee80211_txq_init()
1540 txqi->txq.sta = &sta->sta; in ieee80211_txq_init()
1541 txqi->txq.tid = tid; in ieee80211_txq_init()
1542 sta->sta.txq[tid] = &txqi->txq; in ieee80211_txq_init()
1548 struct fq *fq = &local->fq; in ieee80211_txq_purge()
1549 struct fq_tin *tin = &txqi->tin; in ieee80211_txq_purge()
1551 spin_lock_bh(&fq->lock); in ieee80211_txq_purge()
1553 ieee80211_purge_tx_queue(&local->hw, &txqi->frags); in ieee80211_txq_purge()
1554 spin_unlock_bh(&fq->lock); in ieee80211_txq_purge()
1556 spin_lock_bh(&local->active_txq_lock[txqi->txq.ac]); in ieee80211_txq_purge()
1557 list_del_init(&txqi->schedule_order); in ieee80211_txq_purge()
1558 spin_unlock_bh(&local->active_txq_lock[txqi->txq.ac]); in ieee80211_txq_purge()
1563 if (local->hw.wiphy->txq_limit) in ieee80211_txq_set_params()
1564 local->fq.limit = local->hw.wiphy->txq_limit; in ieee80211_txq_set_params()
1566 local->hw.wiphy->txq_limit = local->fq.limit; in ieee80211_txq_set_params()
1568 if (local->hw.wiphy->txq_memory_limit) in ieee80211_txq_set_params()
1569 local->fq.memory_limit = local->hw.wiphy->txq_memory_limit; in ieee80211_txq_set_params()
1571 local->hw.wiphy->txq_memory_limit = local->fq.memory_limit; in ieee80211_txq_set_params()
1573 if (local->hw.wiphy->txq_quantum) in ieee80211_txq_set_params()
1574 local->fq.quantum = local->hw.wiphy->txq_quantum; in ieee80211_txq_set_params()
1576 local->hw.wiphy->txq_quantum = local->fq.quantum; in ieee80211_txq_set_params()
1581 struct fq *fq = &local->fq; in ieee80211_txq_setup_flows()
1593 * queue size. 4 Mbytes is 64 max-size aggregates in 802.11n. in ieee80211_txq_setup_flows()
1598 sband = local->hw.wiphy->bands[band]; in ieee80211_txq_setup_flows()
1602 supp_vht = supp_vht || sband->vht_cap.vht_supported; in ieee80211_txq_setup_flows()
1606 fq->memory_limit = 4 << 20; /* 4 Mbytes */ in ieee80211_txq_setup_flows()
1608 codel_params_init(&local->cparams); in ieee80211_txq_setup_flows()
1609 local->cparams.interval = MS2TIME(100); in ieee80211_txq_setup_flows()
1610 local->cparams.target = MS2TIME(20); in ieee80211_txq_setup_flows()
1611 local->cparams.ecn = true; in ieee80211_txq_setup_flows()
1613 local->cvars = kvcalloc(fq->flows_cnt, sizeof(local->cvars[0]), in ieee80211_txq_setup_flows()
1615 if (!local->cvars) { in ieee80211_txq_setup_flows()
1616 spin_lock_bh(&fq->lock); in ieee80211_txq_setup_flows()
1618 spin_unlock_bh(&fq->lock); in ieee80211_txq_setup_flows()
1619 return -ENOMEM; in ieee80211_txq_setup_flows()
1622 for (i = 0; i < fq->flows_cnt; i++) in ieee80211_txq_setup_flows()
1623 codel_vars_init(&local->cvars[i]); in ieee80211_txq_setup_flows()
1632 struct fq *fq = &local->fq; in ieee80211_txq_teardown_flows()
1634 kvfree(local->cvars); in ieee80211_txq_teardown_flows()
1635 local->cvars = NULL; in ieee80211_txq_teardown_flows()
1637 spin_lock_bh(&fq->lock); in ieee80211_txq_teardown_flows()
1639 spin_unlock_bh(&fq->lock); in ieee80211_txq_teardown_flows()
1650 if (sdata->vif.type == NL80211_IFTYPE_MONITOR) in ieee80211_queue_skb()
1653 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) in ieee80211_queue_skb()
1654 sdata = container_of(sdata->bss, in ieee80211_queue_skb()
1657 vif = &sdata->vif; in ieee80211_queue_skb()
1682 int q = info->hw_queue; in ieee80211_tx_frags()
1685 if (WARN_ON_ONCE(q >= local->hw.queues)) { in ieee80211_tx_frags()
1687 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_frags()
1692 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in ieee80211_tx_frags()
1693 if (local->queue_stop_reasons[q] || in ieee80211_tx_frags()
1694 (!txpending && !skb_queue_empty(&local->pending[q]))) { in ieee80211_tx_frags()
1695 if (unlikely(info->flags & in ieee80211_tx_frags()
1697 if (local->queue_stop_reasons[q] & in ieee80211_tx_frags()
1700 * Drop off-channel frames if queues in ieee80211_tx_frags()
1702 * than off-channel operation. Never in ieee80211_tx_frags()
1706 &local->queue_stop_reason_lock, in ieee80211_tx_frags()
1708 ieee80211_purge_tx_queue(&local->hw, in ieee80211_tx_frags()
1716 * later transmission from the tx-pending in ieee80211_tx_frags()
1721 &local->pending[q]); in ieee80211_tx_frags()
1724 &local->pending[q]); in ieee80211_tx_frags()
1726 spin_unlock_irqrestore(&local->queue_stop_reason_lock, in ieee80211_tx_frags()
1731 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_tx_frags()
1733 info->control.vif = vif; in ieee80211_tx_frags()
1734 control.sta = sta ? &sta->sta : NULL; in ieee80211_tx_frags()
1761 sdata = vif_to_sdata(info->control.vif); in __ieee80211_tx()
1762 if (sta && !sta->uploaded) in __ieee80211_tx()
1765 switch (sdata->vif.type) { in __ieee80211_tx()
1767 if ((sdata->u.mntr.flags & MONITOR_FLAG_ACTIVE) || in __ieee80211_tx()
1768 ieee80211_hw_check(&local->hw, NO_VIRTUAL_MONITOR)) { in __ieee80211_tx()
1769 vif = &sdata->vif; in __ieee80211_tx()
1772 sdata = rcu_dereference(local->monitor_sdata); in __ieee80211_tx()
1773 if (sdata && ieee80211_hw_check(&local->hw, WANT_MONITOR_VIF)) { in __ieee80211_tx()
1774 vif = &sdata->vif; in __ieee80211_tx()
1775 info->hw_queue = in __ieee80211_tx()
1776 vif->hw_queue[skb_get_queue_mapping(skb)]; in __ieee80211_tx()
1777 } else if (ieee80211_hw_check(&local->hw, QUEUE_CONTROL)) { in __ieee80211_tx()
1778 ieee80211_purge_tx_queue(&local->hw, skbs); in __ieee80211_tx()
1784 sdata = container_of(sdata->bss, in __ieee80211_tx()
1788 vif = &sdata->vif; in __ieee80211_tx()
1800 * Invoke TX handlers, return 0 on success and non-zero if the
1826 I802_DEBUG_INC(tx->local->tx_handlers_drop); in invoke_tx_handlers_early()
1827 if (tx->skb) in invoke_tx_handlers_early()
1828 ieee80211_free_txskb(&tx->local->hw, tx->skb); in invoke_tx_handlers_early()
1830 ieee80211_purge_tx_queue(&tx->local->hw, &tx->skbs); in invoke_tx_handlers_early()
1831 return -1; in invoke_tx_handlers_early()
1833 I802_DEBUG_INC(tx->local->tx_handlers_queued); in invoke_tx_handlers_early()
1834 return -1; in invoke_tx_handlers_early()
1846 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); in invoke_tx_handlers_late()
1849 if (!ieee80211_hw_check(&tx->local->hw, HAS_RATE_CONTROL)) in invoke_tx_handlers_late()
1852 if (unlikely(info->flags & IEEE80211_TX_INTFL_RETRANSMISSION)) { in invoke_tx_handlers_late()
1853 __skb_queue_tail(&tx->skbs, tx->skb); in invoke_tx_handlers_late()
1854 tx->skb = NULL; in invoke_tx_handlers_late()
1864 if (!ieee80211_hw_check(&tx->local->hw, HAS_RATE_CONTROL)) in invoke_tx_handlers_late()
1870 I802_DEBUG_INC(tx->local->tx_handlers_drop); in invoke_tx_handlers_late()
1871 if (tx->skb) in invoke_tx_handlers_late()
1872 ieee80211_free_txskb(&tx->local->hw, tx->skb); in invoke_tx_handlers_late()
1874 ieee80211_purge_tx_queue(&tx->local->hw, &tx->skbs); in invoke_tx_handlers_late()
1875 return -1; in invoke_tx_handlers_late()
1877 I802_DEBUG_INC(tx->local->tx_handlers_queued); in invoke_tx_handlers_late()
1878 return -1; in invoke_tx_handlers_late()
1905 info->band = band; in ieee80211_tx_prepare_skb()
1906 info->control.vif = vif; in ieee80211_tx_prepare_skb()
1907 info->hw_queue = vif->hw_queue[skb_get_queue_mapping(skb)]; in ieee80211_tx_prepare_skb()
1914 *sta = &tx.sta->sta; in ieee80211_tx_prepare_skb()
1938 struct ieee80211_local *local = sdata->local; in ieee80211_tx()
1944 if (unlikely(skb->len < 10)) { in ieee80211_tx()
1953 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx()
1960 if (!(info->flags & IEEE80211_TX_CTL_TX_OFFCHAN) || in ieee80211_tx()
1961 !ieee80211_hw_check(&local->hw, QUEUE_CONTROL)) in ieee80211_tx()
1962 info->hw_queue = in ieee80211_tx()
1963 sdata->vif.hw_queue[skb_get_queue_mapping(skb)]; in ieee80211_tx()
1990 struct ieee80211_local *local = sdata->local; in ieee80211_skb_resize()
1996 sdata->crypto_tx_tailroom_needed_cnt); in ieee80211_skb_resize()
2000 tail_need -= skb_tailroom(skb); in ieee80211_skb_resize()
2005 (!ieee80211_hw_check(&local->hw, SUPPORTS_CLONED_SKBS) || in ieee80211_skb_resize()
2007 I802_DEBUG_INC(local->tx_expand_skb_head_cloned); in ieee80211_skb_resize()
2009 I802_DEBUG_INC(local->tx_expand_skb_head); in ieee80211_skb_resize()
2014 wiphy_debug(local->hw.wiphy, in ieee80211_skb_resize()
2016 return -ENOMEM; in ieee80211_skb_resize()
2025 struct ieee80211_local *local = sdata->local; in ieee80211_xmit()
2027 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; in ieee80211_xmit()
2031 if (info->flags & IEEE80211_TX_INTFL_DONT_ENCRYPT) in ieee80211_xmit()
2033 else if (ieee80211_is_mgmt(hdr->frame_control)) in ieee80211_xmit()
2038 headroom = local->tx_headroom; in ieee80211_xmit()
2041 headroom -= skb_headroom(skb); in ieee80211_xmit()
2045 ieee80211_free_txskb(&local->hw, skb); in ieee80211_xmit()
2050 hdr = (struct ieee80211_hdr *) skb->data; in ieee80211_xmit()
2051 info->control.vif = &sdata->vif; in ieee80211_xmit()
2053 if (ieee80211_vif_is_mesh(&sdata->vif)) { in ieee80211_xmit()
2054 if (ieee80211_is_data(hdr->frame_control) && in ieee80211_xmit()
2055 is_unicast_ether_addr(hdr->addr1)) { in ieee80211_xmit()
2070 (struct ieee80211_radiotap_header *)skb->data; in ieee80211_validate_radiotap_len()
2073 if (unlikely(skb->len < sizeof(struct ieee80211_radiotap_header))) in ieee80211_validate_radiotap_len()
2077 if (unlikely(rthdr->it_version)) in ieee80211_validate_radiotap_len()
2081 if (unlikely(skb->len < ieee80211_get_radiotap_len(skb->data))) in ieee80211_validate_radiotap_len()
2090 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); in ieee80211_parse_tx_radiotap()
2093 (struct ieee80211_radiotap_header *) skb->data; in ieee80211_parse_tx_radiotap()
2095 int ret = ieee80211_radiotap_iterator_init(&iterator, rthdr, skb->len, in ieee80211_parse_tx_radiotap()
2110 info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT | in ieee80211_parse_tx_radiotap()
2115 * (ieee80211_radiotap_iterator_next returns -ENOENT when no more in ieee80211_parse_tx_radiotap()
2116 * entries present, or -EINVAL on error) in ieee80211_parse_tx_radiotap()
2137 * handed has the 32-bit FCS CRC at the end... in ieee80211_parse_tx_radiotap()
2142 if (skb->len < (iterator._max_length + FCS_LEN)) in ieee80211_parse_tx_radiotap()
2145 skb_trim(skb, skb->len - FCS_LEN); in ieee80211_parse_tx_radiotap()
2148 info->flags &= ~IEEE80211_TX_INTFL_DONT_ENCRYPT; in ieee80211_parse_tx_radiotap()
2150 info->flags &= ~IEEE80211_TX_CTL_DONTFRAG; in ieee80211_parse_tx_radiotap()
2156 info->flags |= IEEE80211_TX_CTL_NO_ACK; in ieee80211_parse_tx_radiotap()
2158 info->control.flags |= IEEE80211_TX_CTRL_NO_SEQNO; in ieee80211_parse_tx_radiotap()
2160 info->control.flags |= in ieee80211_parse_tx_radiotap()
2172 info->control.antennas |= BIT(*iterator.this_arg); in ieee80211_parse_tx_radiotap()
2200 info->flags |= IEEE80211_TX_CTL_LDPC; in ieee80211_parse_tx_radiotap()
2206 info->flags |= in ieee80211_parse_tx_radiotap()
2244 * Documentation/networking/mac80211-injection.rst in ieee80211_parse_tx_radiotap()
2253 if (ret != -ENOENT) /* ie, if we didn't simply run out of fields */ in ieee80211_parse_tx_radiotap()
2258 local->hw.wiphy->bands[info->band]; in ieee80211_parse_tx_radiotap()
2260 info->control.flags |= IEEE80211_TX_CTRL_RATE_INJECT; in ieee80211_parse_tx_radiotap()
2263 info->control.rates[i].idx = -1; in ieee80211_parse_tx_radiotap()
2264 info->control.rates[i].flags = 0; in ieee80211_parse_tx_radiotap()
2265 info->control.rates[i].count = 0; in ieee80211_parse_tx_radiotap()
2271 hweight8(info->control.antennas)) in ieee80211_parse_tx_radiotap()
2272 info->control.antennas = 0; in ieee80211_parse_tx_radiotap()
2274 info->control.rates[0].idx = rate; in ieee80211_parse_tx_radiotap()
2277 if (vht_nss > hweight8(info->control.antennas)) in ieee80211_parse_tx_radiotap()
2278 info->control.antennas = 0; in ieee80211_parse_tx_radiotap()
2280 ieee80211_rate_set_vht(info->control.rates, vht_mcs, in ieee80211_parse_tx_radiotap()
2283 for (i = 0; i < sband->n_bitrates; i++) { in ieee80211_parse_tx_radiotap()
2284 if (rate * 5 != sband->bitrates[i].bitrate) in ieee80211_parse_tx_radiotap()
2287 info->control.rates[0].idx = i; in ieee80211_parse_tx_radiotap()
2292 if (info->control.rates[0].idx < 0) in ieee80211_parse_tx_radiotap()
2293 info->control.flags &= ~IEEE80211_TX_CTRL_RATE_INJECT; in ieee80211_parse_tx_radiotap()
2295 info->control.rates[0].flags = rate_flags; in ieee80211_parse_tx_radiotap()
2296 info->control.rates[0].count = min_t(u8, rate_retries + 1, in ieee80211_parse_tx_radiotap()
2297 local->hw.max_rate_tries); in ieee80211_parse_tx_radiotap()
2306 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); in ieee80211_monitor_start_xmit()
2320 info->flags = IEEE80211_TX_CTL_REQ_TX_STATUS | in ieee80211_monitor_start_xmit()
2323 /* Sanity-check the length of the radiotap header */ in ieee80211_monitor_start_xmit()
2328 len_rthdr = ieee80211_get_radiotap_len(skb->data); in ieee80211_monitor_start_xmit()
2344 if (skb->len < len_rthdr + 2) in ieee80211_monitor_start_xmit()
2347 hdr = (struct ieee80211_hdr *)(skb->data + len_rthdr); in ieee80211_monitor_start_xmit()
2348 hdrlen = ieee80211_hdrlen(hdr->frame_control); in ieee80211_monitor_start_xmit()
2350 if (skb->len < len_rthdr + hdrlen) in ieee80211_monitor_start_xmit()
2354 * Initialize skb->protocol if the injected frame is a data frame in ieee80211_monitor_start_xmit()
2357 if (ieee80211_is_data(hdr->frame_control) && in ieee80211_monitor_start_xmit()
2358 skb->len >= len_rthdr + hdrlen + sizeof(rfc1042_header) + 2) { in ieee80211_monitor_start_xmit()
2362 skb->protocol = cpu_to_be16((payload[6] << 8) | in ieee80211_monitor_start_xmit()
2363 payload[7]); in ieee80211_monitor_start_xmit()
2370 * we handle as though they are non-injected frames. in ieee80211_monitor_start_xmit()
2373 * VLAN support we have an nl80211-based mechanism. in ieee80211_monitor_start_xmit()
2376 * don't use nl80211-based management TX/RX. in ieee80211_monitor_start_xmit()
2378 list_for_each_entry_rcu(tmp_sdata, &local->interfaces, list) { in ieee80211_monitor_start_xmit()
2381 if (tmp_sdata->vif.type == NL80211_IFTYPE_MONITOR || in ieee80211_monitor_start_xmit()
2382 tmp_sdata->vif.type == NL80211_IFTYPE_AP_VLAN) in ieee80211_monitor_start_xmit()
2384 if (ether_addr_equal(tmp_sdata->vif.addr, hdr->addr2)) { in ieee80211_monitor_start_xmit()
2390 chanctx_conf = rcu_dereference(sdata->vif.bss_conf.chanctx_conf); in ieee80211_monitor_start_xmit()
2392 tmp_sdata = rcu_dereference(local->monitor_sdata); in ieee80211_monitor_start_xmit()
2395 rcu_dereference(tmp_sdata->vif.bss_conf.chanctx_conf); in ieee80211_monitor_start_xmit()
2399 chandef = &chanctx_conf->def; in ieee80211_monitor_start_xmit()
2407 if (!cfg80211_chandef_usable(local->hw.wiphy, chandef, in ieee80211_monitor_start_xmit()
2427 if (!cfg80211_reg_can_beacon(local->hw.wiphy, chandef, in ieee80211_monitor_start_xmit()
2428 sdata->vif.type)) in ieee80211_monitor_start_xmit()
2431 info->band = chandef->chan->band; in ieee80211_monitor_start_xmit()
2433 /* Initialize skb->priority according to frame type and TID class, in ieee80211_monitor_start_xmit()
2436 * skb-priority is preserved to assure frames injected with this in ieee80211_monitor_start_xmit()
2440 skb_set_queue_mapping(skb, ieee80211_ac_from_tid(skb->priority)); in ieee80211_monitor_start_xmit()
2467 u16 ethertype = (skb->data[12] << 8) | skb->data[13]; in ieee80211_is_tdls_setup()
2470 skb->len > 14 && in ieee80211_is_tdls_setup()
2471 skb->data[14] == WLAN_TDLS_SNAP_RFTYPE; in ieee80211_is_tdls_setup()
2480 switch (sdata->vif.type) { in ieee80211_lookup_ra_sta()
2482 sta = rcu_dereference(sdata->u.vlan.sta); in ieee80211_lookup_ra_sta()
2486 } else if (sdata->wdev.use_4addr) { in ieee80211_lookup_ra_sta()
2487 return -ENOLINK; in ieee80211_lookup_ra_sta()
2493 if (is_multicast_ether_addr(skb->data)) { in ieee80211_lookup_ra_sta()
2494 *sta_out = ERR_PTR(-ENOENT); in ieee80211_lookup_ra_sta()
2497 sta = sta_info_get_bss(sdata, skb->data); in ieee80211_lookup_ra_sta()
2506 if (sdata->wdev.wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS) { in ieee80211_lookup_ra_sta()
2507 sta = sta_info_get(sdata, skb->data); in ieee80211_lookup_ra_sta()
2516 * TDLS link during setup - throw out frames to in ieee80211_lookup_ra_sta()
2517 * peer. Allow TDLS-setup frames to unauthorized in ieee80211_lookup_ra_sta()
2523 return -EINVAL; in ieee80211_lookup_ra_sta()
2528 sta = sta_info_get(sdata, sdata->vif.cfg.ap_addr); in ieee80211_lookup_ra_sta()
2530 return -ENOLINK; in ieee80211_lookup_ra_sta()
2533 return -EINVAL; in ieee80211_lookup_ra_sta()
2536 *sta_out = sta ?: ERR_PTR(-ENOENT); in ieee80211_lookup_ra_sta()
2548 if (skb->sk) in ieee80211_store_ack_skb()
2557 spin_lock_irqsave(&local->ack_status_lock, flags); in ieee80211_store_ack_skb()
2558 id = idr_alloc(&local->ack_status_frames, ack_skb, in ieee80211_store_ack_skb()
2560 spin_unlock_irqrestore(&local->ack_status_lock, flags); in ieee80211_store_ack_skb()
2567 IEEE80211_SKB_CB(ack_skb)->ack.cookie = *cookie; in ieee80211_store_ack_skb()
2578 * ieee80211_build_hdr - build 802.11 header in the given frame
2591 * potential unsharing of the SKB - this needs to be interleaved with the
2594 * The function requires the read-side RCU lock held
2603 struct ieee80211_local *local = sdata->local; in ieee80211_build_hdr()
2626 if (local->force_tx_status) in ieee80211_build_hdr()
2632 ethertype = (skb->data[12] << 8) | skb->data[13]; in ieee80211_build_hdr()
2635 if (!ieee80211_vif_is_mld(&sdata->vif)) in ieee80211_build_hdr()
2637 rcu_dereference(sdata->vif.bss_conf.chanctx_conf); in ieee80211_build_hdr()
2639 switch (sdata->vif.type) { in ieee80211_build_hdr()
2641 if (sdata->wdev.use_4addr) { in ieee80211_build_hdr()
2644 memcpy(hdr.addr1, sta->sta.addr, ETH_ALEN); in ieee80211_build_hdr()
2645 memcpy(hdr.addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_build_hdr()
2646 memcpy(hdr.addr3, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2647 memcpy(hdr.addr4, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2650 wme_sta = sta->sta.wme; in ieee80211_build_hdr()
2652 if (!ieee80211_vif_is_mld(&sdata->vif)) { in ieee80211_build_hdr()
2656 ap_sdata = container_of(sdata->bss, in ieee80211_build_hdr()
2660 rcu_dereference(ap_sdata->vif.bss_conf.chanctx_conf); in ieee80211_build_hdr()
2662 if (sdata->wdev.use_4addr) in ieee80211_build_hdr()
2668 memcpy(hdr.addr1, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2670 if (ieee80211_vif_is_mld(&sdata->vif) && sta && !sta->sta.mlo) { in ieee80211_build_hdr()
2673 link_id = sta->deflink.link_id; in ieee80211_build_hdr()
2674 link = rcu_dereference(sdata->link[link_id]); in ieee80211_build_hdr()
2676 ret = -ENOLINK; in ieee80211_build_hdr()
2679 memcpy(hdr.addr2, link->conf->addr, ETH_ALEN); in ieee80211_build_hdr()
2681 (sta && sta->sta.mlo)) { in ieee80211_build_hdr()
2682 memcpy(hdr.addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_build_hdr()
2686 conf = rcu_dereference(sdata->vif.link_conf[link_id]); in ieee80211_build_hdr()
2688 ret = -ENOLINK; in ieee80211_build_hdr()
2692 memcpy(hdr.addr2, conf->addr, ETH_ALEN); in ieee80211_build_hdr()
2695 memcpy(hdr.addr3, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2700 if (!is_multicast_ether_addr(skb->data)) { in ieee80211_build_hdr()
2704 mpath = mesh_path_lookup(sdata, skb->data); in ieee80211_build_hdr()
2707 next_hop = rcu_dereference(mpath->next_hop); in ieee80211_build_hdr()
2709 !(mpath->flags & (MESH_PATH_ACTIVE | in ieee80211_build_hdr()
2715 mppath = mpp_path_lookup(sdata, skb->data); in ieee80211_build_hdr()
2717 mppath->exp_time = jiffies; in ieee80211_build_hdr()
2721 mesh_path_del(sdata, mpath->dst); in ieee80211_build_hdr()
2730 if (ether_addr_equal(sdata->vif.addr, skb->data + ETH_ALEN) && in ieee80211_build_hdr()
2731 !(mppath && !ether_addr_equal(mppath->mpp, skb->data))) { in ieee80211_build_hdr()
2733 skb->data, skb->data + ETH_ALEN); in ieee80211_build_hdr()
2737 /* DS -> MBSS (802.11-2012 13.11.3.3). in ieee80211_build_hdr()
2743 const u8 *mesh_da = skb->data; in ieee80211_build_hdr()
2746 mesh_da = mppath->mpp; in ieee80211_build_hdr()
2748 mesh_da = mpath->dst; in ieee80211_build_hdr()
2751 mesh_da, sdata->vif.addr); in ieee80211_build_hdr()
2756 skb->data + ETH_ALEN, NULL); in ieee80211_build_hdr()
2760 sdata, &mesh_hdr, skb->data, in ieee80211_build_hdr()
2761 skb->data + ETH_ALEN); in ieee80211_build_hdr()
2770 memcpy(hdr.addr1, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2783 memcpy(hdr.addr1, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2784 memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2785 link = rcu_dereference(sdata->link[tdls_link_id]); in ieee80211_build_hdr()
2787 ret = -EINVAL; in ieee80211_build_hdr()
2790 memcpy(hdr.addr3, link->u.mgd.bssid, ETH_ALEN); in ieee80211_build_hdr()
2792 } else if (sdata->u.mgd.use_4addr && in ieee80211_build_hdr()
2793 cpu_to_be16(ethertype) != sdata->control_port_protocol) { in ieee80211_build_hdr()
2797 memcpy(hdr.addr1, sdata->deflink.u.mgd.bssid, ETH_ALEN); in ieee80211_build_hdr()
2798 memcpy(hdr.addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_build_hdr()
2799 memcpy(hdr.addr3, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2800 memcpy(hdr.addr4, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2805 memcpy(hdr.addr1, sdata->vif.cfg.ap_addr, ETH_ALEN); in ieee80211_build_hdr()
2806 memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2807 memcpy(hdr.addr3, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2813 memcpy(hdr.addr1, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2814 memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2820 memcpy(hdr.addr1, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2821 memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2822 memcpy(hdr.addr3, sdata->u.ibss.bssid, ETH_ALEN); in ieee80211_build_hdr()
2826 ret = -EINVAL; in ieee80211_build_hdr()
2831 if (!ieee80211_vif_is_mld(&sdata->vif)) { in ieee80211_build_hdr()
2832 ret = -ENOTCONN; in ieee80211_build_hdr()
2838 band = chanctx_conf->def.chan->band; in ieee80211_build_hdr()
2846 wme_sta = sta->sta.wme; in ieee80211_build_hdr()
2847 } else if (ieee80211_vif_is_mesh(&sdata->vif)) { in ieee80211_build_hdr()
2862 if (unlikely(!ieee80211_vif_is_mesh(&sdata->vif) && in ieee80211_build_hdr()
2863 (sdata->vif.type != NL80211_IFTYPE_OCB) && in ieee80211_build_hdr()
2865 (cpu_to_be16(ethertype) != sdata->control_port_protocol || in ieee80211_build_hdr()
2866 !ieee80211_is_our_addr(sdata, skb->data + ETH_ALEN, NULL)))) { in ieee80211_build_hdr()
2869 sdata->name, hdr.addr1); in ieee80211_build_hdr()
2872 I802_DEBUG_INC(local->tx_handlers_drop_unauth_port); in ieee80211_build_hdr()
2874 ret = -EPERM; in ieee80211_build_hdr()
2879 ((skb->sk && in ieee80211_build_hdr()
2880 skb_shinfo(skb)->tx_flags & SKBTX_WIFI_STATUS) || in ieee80211_build_hdr()
2890 ret = -ENOMEM; in ieee80211_build_hdr()
2902 skip_header_bytes -= 2; in ieee80211_build_hdr()
2906 skip_header_bytes -= 2; in ieee80211_build_hdr()
2913 head_need = hdrlen + encaps_len + meshhdrlen - skb_headroom(skb); in ieee80211_build_hdr()
2929 head_need += local->tx_headroom; in ieee80211_build_hdr()
2932 ieee80211_free_txskb(&local->hw, skb); in ieee80211_build_hdr()
2934 return ERR_PTR(-ENOMEM); in ieee80211_build_hdr()
2950 memcpy(skb_push(skb, hdrlen - 2), &hdr, hdrlen - 2); in ieee80211_build_hdr()
2964 info->flags = info_flags; in ieee80211_build_hdr()
2966 info->status_data = info_id; in ieee80211_build_hdr()
2967 info->status_data_idr = 1; in ieee80211_build_hdr()
2969 info->band = band; in ieee80211_build_hdr()
2990 sdata->name, hdr.addr1, in ieee80211_build_hdr()
2993 ret = -EINVAL; in ieee80211_build_hdr()
2998 info->control.flags = ctrl_flags; in ieee80211_build_hdr()
3007 * fast-xmit overview
3009 * The core idea of this fast-xmit is to remove per-packet checks by checking
3010 * them out of band. ieee80211_check_fast_xmit() implements the out-of-band
3011 * checks that are needed to get the sta->fast_tx pointer assigned, after which
3016 * Once assigned, the fast_tx data structure also caches the per-packet 802.11
3022 * since the per-packet code no longer checks the conditions. This is reflected
3030 struct ieee80211_local *local = sta->local; in ieee80211_check_fast_xmit()
3031 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_check_fast_xmit()
3036 if (!ieee80211_hw_check(&local->hw, SUPPORT_FAST_XMIT)) in ieee80211_check_fast_xmit()
3039 if (ieee80211_vif_is_mesh(&sdata->vif)) in ieee80211_check_fast_xmit()
3050 * key and the fast-tx assignment are done atomically, so the CPU that in ieee80211_check_fast_xmit()
3054 spin_lock_bh(&sta->lock); in ieee80211_check_fast_xmit()
3055 if (ieee80211_hw_check(&local->hw, SUPPORTS_PS) && in ieee80211_check_fast_xmit()
3056 !ieee80211_hw_check(&local->hw, SUPPORTS_DYNAMIC_PS) && in ieee80211_check_fast_xmit()
3057 sdata->vif.type == NL80211_IFTYPE_STATION) in ieee80211_check_fast_xmit()
3060 if (!test_sta_flag(sta, WLAN_STA_AUTHORIZED) || !sta->uploaded) in ieee80211_check_fast_xmit()
3069 if (sdata->noack_map) in ieee80211_check_fast_xmit()
3072 /* fast-xmit doesn't handle fragmentation at all */ in ieee80211_check_fast_xmit()
3073 if (local->hw.wiphy->frag_threshold != (u32)-1 && in ieee80211_check_fast_xmit()
3074 !ieee80211_hw_check(&local->hw, SUPPORTS_TX_FRAG)) in ieee80211_check_fast_xmit()
3077 if (!ieee80211_vif_is_mld(&sdata->vif)) { in ieee80211_check_fast_xmit()
3080 rcu_dereference(sdata->vif.bss_conf.chanctx_conf); in ieee80211_check_fast_xmit()
3085 build.band = chanctx_conf->def.chan->band; in ieee80211_check_fast_xmit()
3094 switch (sdata->vif.type) { in ieee80211_check_fast_xmit()
3099 memcpy(hdr->addr3, sdata->u.ibss.bssid, ETH_ALEN); in ieee80211_check_fast_xmit()
3112 link = rcu_dereference(sdata->link[tdls_link_id]); in ieee80211_check_fast_xmit()
3114 memcpy(hdr->addr3, link->u.mgd.bssid, ETH_ALEN); in ieee80211_check_fast_xmit()
3120 if (sdata->u.mgd.use_4addr) { in ieee80211_check_fast_xmit()
3121 /* non-regular ethertype cannot use the fastpath */ in ieee80211_check_fast_xmit()
3125 memcpy(hdr->addr1, sdata->deflink.u.mgd.bssid, ETH_ALEN); in ieee80211_check_fast_xmit()
3126 memcpy(hdr->addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_check_fast_xmit()
3134 memcpy(hdr->addr1, sdata->vif.cfg.ap_addr, ETH_ALEN); in ieee80211_check_fast_xmit()
3140 if (sdata->wdev.use_4addr) { in ieee80211_check_fast_xmit()
3144 memcpy(hdr->addr1, sta->sta.addr, ETH_ALEN); in ieee80211_check_fast_xmit()
3145 memcpy(hdr->addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_check_fast_xmit()
3156 if (sta->sta.mlo || !ieee80211_vif_is_mld(&sdata->vif)) { in ieee80211_check_fast_xmit()
3157 memcpy(hdr->addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_check_fast_xmit()
3159 unsigned int link_id = sta->deflink.link_id; in ieee80211_check_fast_xmit()
3163 link = rcu_dereference(sdata->link[link_id]); in ieee80211_check_fast_xmit()
3168 memcpy(hdr->addr2, link->conf->addr, ETH_ALEN); in ieee80211_check_fast_xmit()
3175 /* not handled on fast-xmit */ in ieee80211_check_fast_xmit()
3179 if (sta->sta.wme) { in ieee80211_check_fast_xmit()
3189 build.key = rcu_access_pointer(sta->ptk[sta->ptk_idx]); in ieee80211_check_fast_xmit()
3191 build.key = rcu_access_pointer(sdata->default_unicast_key); in ieee80211_check_fast_xmit()
3195 gen_iv = build.key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV; in ieee80211_check_fast_xmit()
3196 iv_spc = build.key->conf.flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE; in ieee80211_check_fast_xmit()
3197 mmic = build.key->conf.flags & in ieee80211_check_fast_xmit()
3202 if (!(build.key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) in ieee80211_check_fast_xmit()
3206 if (build.key->flags & KEY_FLAG_TAINTED) in ieee80211_check_fast_xmit()
3209 switch (build.key->conf.cipher) { in ieee80211_check_fast_xmit()
3225 /* cannot handle MMIC or IV generation in xmit-fast */ in ieee80211_check_fast_xmit()
3233 /* cannot handle IV generation in fast-xmit */ in ieee80211_check_fast_xmit()
3245 build.key->conf.cipher); in ieee80211_check_fast_xmit()
3256 hdr->frame_control = fc; in ieee80211_check_fast_xmit()
3267 old = rcu_dereference_protected(sta->fast_tx, in ieee80211_check_fast_xmit()
3268 lockdep_is_held(&sta->lock)); in ieee80211_check_fast_xmit()
3269 rcu_assign_pointer(sta->fast_tx, fast_tx); in ieee80211_check_fast_xmit()
3272 spin_unlock_bh(&sta->lock); in ieee80211_check_fast_xmit()
3280 list_for_each_entry_rcu(sta, &local->sta_list, list) in ieee80211_check_fast_xmit_all()
3287 struct ieee80211_local *local = sdata->local; in ieee80211_check_fast_xmit_iface()
3292 list_for_each_entry_rcu(sta, &local->sta_list, list) { in ieee80211_check_fast_xmit_iface()
3293 if (sdata != sta->sdata && in ieee80211_check_fast_xmit_iface()
3294 (!sta->sdata->bss || sta->sdata->bss != sdata->bss)) in ieee80211_check_fast_xmit_iface()
3306 spin_lock_bh(&sta->lock); in ieee80211_clear_fast_xmit()
3307 fast_tx = rcu_dereference_protected(sta->fast_tx, in ieee80211_clear_fast_xmit()
3308 lockdep_is_held(&sta->lock)); in ieee80211_clear_fast_xmit()
3309 RCU_INIT_POINTER(sta->fast_tx, NULL); in ieee80211_clear_fast_xmit()
3310 spin_unlock_bh(&sta->lock); in ieee80211_clear_fast_xmit()
3320 I802_DEBUG_INC(local->tx_expand_skb_head); in ieee80211_amsdu_realloc_pad()
3323 wiphy_debug(local->hw.wiphy, in ieee80211_amsdu_realloc_pad()
3336 struct ieee80211_local *local = sdata->local; in ieee80211_amsdu_prepare_head()
3340 int hdr_len = fast_tx->hdr_len - sizeof(rfc1042_header); in ieee80211_amsdu_prepare_head()
3341 int subframe_len = skb->len - hdr_len; in ieee80211_amsdu_prepare_head()
3346 if (info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE) in ieee80211_amsdu_prepare_head()
3349 if (info->control.flags & IEEE80211_TX_CTRL_AMSDU) in ieee80211_amsdu_prepare_head()
3354 local->hw.extra_tx_headroom)) in ieee80211_amsdu_prepare_head()
3362 h_80211_src = data + fast_tx->sa_offs; in ieee80211_amsdu_prepare_head()
3363 h_80211_dst = data + fast_tx->da_offs; in ieee80211_amsdu_prepare_head()
3365 amsdu_hdr->h_proto = cpu_to_be16(subframe_len); in ieee80211_amsdu_prepare_head()
3366 ether_addr_copy(amsdu_hdr->h_source, h_80211_src); in ieee80211_amsdu_prepare_head()
3367 ether_addr_copy(amsdu_hdr->h_dest, h_80211_dst); in ieee80211_amsdu_prepare_head()
3369 /* according to IEEE 802.11-2012 8.3.2 table 8-19, the outer SA/DA in ieee80211_amsdu_prepare_head()
3370 * fields needs to be changed to BSSID for A-MSDU frames depending in ieee80211_amsdu_prepare_head()
3373 switch (sdata->vif.type) { in ieee80211_amsdu_prepare_head()
3375 bssid = sdata->vif.cfg.ap_addr; in ieee80211_amsdu_prepare_head()
3379 bssid = sdata->vif.addr; in ieee80211_amsdu_prepare_head()
3385 if (bssid && ieee80211_has_fromds(hdr->frame_control)) in ieee80211_amsdu_prepare_head()
3388 if (bssid && ieee80211_has_tods(hdr->frame_control)) in ieee80211_amsdu_prepare_head()
3394 info->control.flags |= IEEE80211_TX_CTRL_AMSDU; in ieee80211_amsdu_prepare_head()
3405 struct ieee80211_local *local = sdata->local; in ieee80211_amsdu_aggregate()
3406 struct fq *fq = &local->fq; in ieee80211_amsdu_aggregate()
3409 u8 tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; in ieee80211_amsdu_aggregate()
3410 struct ieee80211_txq *txq = sta->sta.txq[tid]; in ieee80211_amsdu_aggregate()
3413 int subframe_len = skb->len - ETH_ALEN; in ieee80211_amsdu_aggregate()
3414 u8 max_subframes = sta->sta.max_amsdu_subframes; in ieee80211_amsdu_aggregate()
3415 int max_frags = local->hw.max_tx_fragments; in ieee80211_amsdu_aggregate()
3416 int max_amsdu_len = sta->sta.cur->max_amsdu_len; in ieee80211_amsdu_aggregate()
3426 if (!ieee80211_hw_check(&local->hw, TX_AMSDU)) in ieee80211_amsdu_aggregate()
3429 if (sdata->vif.offload_flags & IEEE80211_OFFLOAD_ENCAP_ENABLED) in ieee80211_amsdu_aggregate()
3432 if (ieee80211_vif_is_mesh(&sdata->vif)) in ieee80211_amsdu_aggregate()
3442 if (test_bit(IEEE80211_TXQ_NO_AMSDU, &txqi->flags)) in ieee80211_amsdu_aggregate()
3445 if (sta->sta.cur->max_rc_amsdu_len) in ieee80211_amsdu_aggregate()
3447 sta->sta.cur->max_rc_amsdu_len); in ieee80211_amsdu_aggregate()
3449 if (sta->sta.cur->max_tid_amsdu_len[tid]) in ieee80211_amsdu_aggregate()
3451 sta->sta.cur->max_tid_amsdu_len[tid]); in ieee80211_amsdu_aggregate()
3455 spin_lock_bh(&fq->lock); in ieee80211_amsdu_aggregate()
3461 tin = &txqi->tin; in ieee80211_amsdu_aggregate()
3463 head = skb_peek_tail(&flow->queue); in ieee80211_amsdu_aggregate()
3467 orig_truesize = head->truesize; in ieee80211_amsdu_aggregate()
3468 orig_len = head->len; in ieee80211_amsdu_aggregate()
3470 if (skb->len + head->len > max_amsdu_len) in ieee80211_amsdu_aggregate()
3473 nfrags = 1 + skb_shinfo(skb)->nr_frags; in ieee80211_amsdu_aggregate()
3474 nfrags += 1 + skb_shinfo(head)->nr_frags; in ieee80211_amsdu_aggregate()
3475 frag_tail = &skb_shinfo(head)->frag_list; in ieee80211_amsdu_aggregate()
3477 nfrags += 1 + skb_shinfo(*frag_tail)->nr_frags; in ieee80211_amsdu_aggregate()
3478 frag_tail = &(*frag_tail)->next; in ieee80211_amsdu_aggregate()
3495 * and frag_tail should be &skb_shinfo(head)->frag_list. in ieee80211_amsdu_aggregate()
3500 frag_tail = &skb_shinfo(head)->frag_list; in ieee80211_amsdu_aggregate()
3504 * padding to the next one, that's being added. Note that head->len in ieee80211_amsdu_aggregate()
3505 * is the length of the full A-MSDU, but that works since each time in ieee80211_amsdu_aggregate()
3509 hdrlen = fast_tx->hdr_len - sizeof(rfc1042_header); in ieee80211_amsdu_aggregate()
3510 if ((head->len - hdrlen) & 3) in ieee80211_amsdu_aggregate()
3511 pad = 4 - ((head->len - hdrlen) & 3); in ieee80211_amsdu_aggregate()
3529 head->len += skb->len; in ieee80211_amsdu_aggregate()
3530 head->data_len += skb->len; in ieee80211_amsdu_aggregate()
3534 fq->memory_usage += head->truesize - orig_truesize; in ieee80211_amsdu_aggregate()
3535 if (head->len != orig_len) { in ieee80211_amsdu_aggregate()
3536 flow->backlog += head->len - orig_len; in ieee80211_amsdu_aggregate()
3537 tin->backlog_bytes += head->len - orig_len; in ieee80211_amsdu_aggregate()
3540 spin_unlock_bh(&fq->lock); in ieee80211_amsdu_aggregate()
3555 struct sk_buff *skb = tx->skb; in ieee80211_xmit_fast_finish()
3557 struct ieee80211_hdr *hdr = (void *)skb->data; in ieee80211_xmit_fast_finish()
3560 if (!ieee80211_hw_check(&tx->local->hw, HAS_RATE_CONTROL) && in ieee80211_xmit_fast_finish()
3565 info->control.hw_key = &key->conf; in ieee80211_xmit_fast_finish()
3567 dev_sw_netstats_tx_add(skb->dev, 1, skb->len); in ieee80211_xmit_fast_finish()
3569 if (hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) { in ieee80211_xmit_fast_finish()
3570 tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; in ieee80211_xmit_fast_finish()
3571 hdr->seq_ctrl = ieee80211_tx_next_seq(sta, tid); in ieee80211_xmit_fast_finish()
3573 info->flags |= IEEE80211_TX_CTL_ASSIGN_SEQ; in ieee80211_xmit_fast_finish()
3574 hdr->seq_ctrl = cpu_to_le16(sdata->sequence_number); in ieee80211_xmit_fast_finish()
3575 sdata->sequence_number += 0x10; in ieee80211_xmit_fast_finish()
3578 if (skb_shinfo(skb)->gso_size) in ieee80211_xmit_fast_finish()
3579 sta->deflink.tx_stats.msdu[tid] += in ieee80211_xmit_fast_finish()
3580 DIV_ROUND_UP(skb->len, skb_shinfo(skb)->gso_size); in ieee80211_xmit_fast_finish()
3582 sta->deflink.tx_stats.msdu[tid]++; in ieee80211_xmit_fast_finish()
3584 info->hw_queue = sdata->vif.hw_queue[skb_get_queue_mapping(skb)]; in ieee80211_xmit_fast_finish()
3589 sta->deflink.tx_stats.bytes[skb_get_queue_mapping(skb)] += skb->len; in ieee80211_xmit_fast_finish()
3590 sta->deflink.tx_stats.packets[skb_get_queue_mapping(skb)]++; in ieee80211_xmit_fast_finish()
3594 u8 *crypto_hdr = skb->data + pn_offs; in ieee80211_xmit_fast_finish()
3596 switch (key->conf.cipher) { in ieee80211_xmit_fast_finish()
3601 pn = atomic64_inc_return(&key->conf.tx_pn); in ieee80211_xmit_fast_finish()
3604 crypto_hdr[3] = 0x20 | (key->conf.keyidx << 6); in ieee80211_xmit_fast_finish()
3608 crypto_hdr[7] = pn >> 40; in ieee80211_xmit_fast_finish()
3619 if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN) in ieee80211_sdata_netdev_features()
3620 return sdata->vif.netdev_features; in ieee80211_sdata_netdev_features()
3622 if (!sdata->bss) in ieee80211_sdata_netdev_features()
3625 sdata = container_of(sdata->bss, struct ieee80211_sub_if_data, u.ap); in ieee80211_sdata_netdev_features()
3626 return sdata->vif.netdev_features; in ieee80211_sdata_netdev_features()
3648 if (skb->ip_summed == CHECKSUM_PARTIAL) { in ieee80211_tx_skb_fixup()
3651 if (skb->encapsulation) in ieee80211_tx_skb_fixup()
3674 struct ieee80211_local *local = sdata->local; in __ieee80211_xmit_fast()
3675 struct ieee80211_hdr *hdr = (void *)fast_tx->hdr; in __ieee80211_xmit_fast()
3679 int hw_headroom = sdata->local->hw.extra_tx_headroom; in __ieee80211_xmit_fast()
3680 int extra_head = fast_tx->hdr_len - (ETH_HLEN - 2); in __ieee80211_xmit_fast()
3686 if ((hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) && in __ieee80211_xmit_fast()
3690 /* will not be crypto-handled beyond what we do here, so use false in __ieee80211_xmit_fast()
3691 * as the may-encrypt argument for the resize to not account for in __ieee80211_xmit_fast()
3695 max_t(int, extra_head + hw_headroom - in __ieee80211_xmit_fast()
3701 memcpy(skb->data, fast_tx->hdr, fast_tx->hdr_len); in __ieee80211_xmit_fast()
3702 memcpy(skb->data + fast_tx->da_offs, da, ETH_ALEN); in __ieee80211_xmit_fast()
3703 memcpy(skb->data + fast_tx->sa_offs, sa, ETH_ALEN); in __ieee80211_xmit_fast()
3707 info->band = fast_tx->band; in __ieee80211_xmit_fast()
3708 info->control.vif = &sdata->vif; in __ieee80211_xmit_fast()
3709 info->flags = IEEE80211_TX_CTL_FIRST_FRAGMENT | in __ieee80211_xmit_fast()
3711 info->control.flags = IEEE80211_TX_CTRL_FAST_XMIT | in __ieee80211_xmit_fast()
3716 if (local->force_tx_status) in __ieee80211_xmit_fast()
3717 info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS; in __ieee80211_xmit_fast()
3720 if (hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) { in __ieee80211_xmit_fast()
3721 u8 tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; in __ieee80211_xmit_fast()
3732 tx.key = fast_tx->key; in __ieee80211_xmit_fast()
3738 r = ieee80211_xmit_fast_finish(sdata, sta, fast_tx->pn_offs, in __ieee80211_xmit_fast()
3739 fast_tx->key, &tx); in __ieee80211_xmit_fast()
3744 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) in __ieee80211_xmit_fast()
3745 sdata = container_of(sdata->bss, in __ieee80211_xmit_fast()
3749 ieee80211_tx_frags(local, &sdata->vif, sta, &tx.skbs, false); in __ieee80211_xmit_fast()
3761 u16 ethertype = (skb->data[12] << 8) | skb->data[13]; in ieee80211_xmit_fast()
3762 struct ieee80211_hdr *hdr = (void *)fast_tx->hdr; in ieee80211_xmit_fast()
3769 if (cpu_to_be16(ethertype) == sdata->control_port_protocol) in ieee80211_xmit_fast()
3777 if (skb->sk && skb_shinfo(skb)->tx_flags & SKBTX_WIFI_STATUS) in ieee80211_xmit_fast()
3780 if (hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) { in ieee80211_xmit_fast()
3781 tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; in ieee80211_xmit_fast()
3782 tid_tx = rcu_dereference(sta->ampdu_mlme.tid_tx[tid]); in ieee80211_xmit_fast()
3784 if (!test_bit(HT_AGG_STATE_OPERATIONAL, &tid_tx->state)) in ieee80211_xmit_fast()
3786 if (tid_tx->timeout) in ieee80211_xmit_fast()
3787 tid_tx->last_tx = jiffies; in ieee80211_xmit_fast()
3791 memcpy(ð, skb->data, ETH_HLEN - 2); in ieee80211_xmit_fast()
3814 struct fq *fq = &local->fq; in ieee80211_tx_dequeue()
3815 struct fq_tin *tin = &txqi->tin; in ieee80211_tx_dequeue()
3819 struct ieee80211_vif *vif = txq->vif; in ieee80211_tx_dequeue()
3820 int q = vif->hw_queue[txq->ac]; in ieee80211_tx_dequeue()
3830 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in ieee80211_tx_dequeue()
3831 q_stopped = local->queue_stop_reasons[q]; in ieee80211_tx_dequeue()
3832 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_tx_dequeue()
3836 set_bit(IEEE80211_TXQ_DIRTY, &txqi->flags); in ieee80211_tx_dequeue()
3840 spin_lock_bh(&fq->lock); in ieee80211_tx_dequeue()
3843 skb = __skb_dequeue(&txqi->frags); in ieee80211_tx_dequeue()
3845 if (!(IEEE80211_SKB_CB(skb)->control.flags & in ieee80211_tx_dequeue()
3848 IEEE80211_SKB_CB(skb)->control.flags &= in ieee80211_tx_dequeue()
3851 if (unlikely(test_bit(IEEE80211_TXQ_STOP, &txqi->flags))) in ieee80211_tx_dequeue()
3860 spin_unlock_bh(&fq->lock); in ieee80211_tx_dequeue()
3862 hdr = (struct ieee80211_hdr *)skb->data; in ieee80211_tx_dequeue()
3869 tx.sdata = vif_to_sdata(info->control.vif); in ieee80211_tx_dequeue()
3871 if (txq->sta) { in ieee80211_tx_dequeue()
3872 tx.sta = container_of(txq->sta, struct sta_info, sta); in ieee80211_tx_dequeue()
3877 if (unlikely(!(info->flags & IEEE80211_TX_CTL_INJECTED) && in ieee80211_tx_dequeue()
3878 ieee80211_is_data(hdr->frame_control) && in ieee80211_tx_dequeue()
3879 !ieee80211_vif_is_mesh(&tx.sdata->vif) && in ieee80211_tx_dequeue()
3880 tx.sdata->vif.type != NL80211_IFTYPE_OCB && in ieee80211_tx_dequeue()
3881 !is_multicast_ether_addr(hdr->addr1) && in ieee80211_tx_dequeue()
3883 (!(info->control.flags & in ieee80211_tx_dequeue()
3885 !ieee80211_is_our_addr(tx.sdata, hdr->addr2, in ieee80211_tx_dequeue()
3887 I802_DEBUG_INC(local->tx_handlers_drop_unauth_port); in ieee80211_tx_dequeue()
3888 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_dequeue()
3899 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_dequeue()
3903 if (test_bit(IEEE80211_TXQ_AMPDU, &txqi->flags)) in ieee80211_tx_dequeue()
3904 info->flags |= (IEEE80211_TX_CTL_AMPDU | in ieee80211_tx_dequeue()
3907 if (info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP) { in ieee80211_tx_dequeue()
3908 if (!ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL)) { in ieee80211_tx_dequeue()
3911 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_dequeue()
3918 if (info->control.flags & IEEE80211_TX_CTRL_FAST_XMIT) { in ieee80211_tx_dequeue()
3919 struct sta_info *sta = container_of(txq->sta, struct sta_info, in ieee80211_tx_dequeue()
3924 (tx.key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)) in ieee80211_tx_dequeue()
3925 pn_offs = ieee80211_hdrlen(hdr->frame_control); in ieee80211_tx_dequeue()
3927 r = ieee80211_xmit_fast_finish(sta->sdata, sta, pn_offs, in ieee80211_tx_dequeue()
3930 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_dequeue()
3941 spin_lock_bh(&fq->lock); in ieee80211_tx_dequeue()
3942 skb_queue_splice_tail(&tx.skbs, &txqi->frags); in ieee80211_tx_dequeue()
3943 spin_unlock_bh(&fq->lock); in ieee80211_tx_dequeue()
3948 !ieee80211_hw_check(&local->hw, TX_FRAG_LIST)) { in ieee80211_tx_dequeue()
3950 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_dequeue()
3955 switch (tx.sdata->vif.type) { in ieee80211_tx_dequeue()
3957 if ((tx.sdata->u.mntr.flags & MONITOR_FLAG_ACTIVE) || in ieee80211_tx_dequeue()
3958 ieee80211_hw_check(&local->hw, NO_VIRTUAL_MONITOR)) { in ieee80211_tx_dequeue()
3959 vif = &tx.sdata->vif; in ieee80211_tx_dequeue()
3962 tx.sdata = rcu_dereference(local->monitor_sdata); in ieee80211_tx_dequeue()
3964 ieee80211_hw_check(&local->hw, WANT_MONITOR_VIF)) { in ieee80211_tx_dequeue()
3965 vif = &tx.sdata->vif; in ieee80211_tx_dequeue()
3966 info->hw_queue = in ieee80211_tx_dequeue()
3967 vif->hw_queue[skb_get_queue_mapping(skb)]; in ieee80211_tx_dequeue()
3968 } else if (ieee80211_hw_check(&local->hw, QUEUE_CONTROL)) { in ieee80211_tx_dequeue()
3969 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_dequeue()
3972 info->control.vif = NULL; in ieee80211_tx_dequeue()
3977 tx.sdata = container_of(tx.sdata->bss, in ieee80211_tx_dequeue()
3981 vif = &tx.sdata->vif; in ieee80211_tx_dequeue()
3986 info->control.vif = vif; in ieee80211_tx_dequeue()
3989 wiphy_ext_feature_isset(local->hw.wiphy, NL80211_EXT_FEATURE_AQL)) { in ieee80211_tx_dequeue()
3990 bool ampdu = txq->ac != IEEE80211_AC_VO; in ieee80211_tx_dequeue()
3993 airtime = ieee80211_calc_expected_tx_airtime(hw, vif, txq->sta, in ieee80211_tx_dequeue()
3994 skb->len, ampdu); in ieee80211_tx_dequeue()
3998 txq->ac, in ieee80211_tx_dequeue()
4007 spin_unlock_bh(&fq->lock); in ieee80211_tx_dequeue()
4015 struct airtime_info *air_info = &sta->airtime[ac]; in ieee80211_sta_deficit()
4017 return air_info->deficit - atomic_read(&air_info->aql_tx_pending); in ieee80211_sta_deficit()
4025 if (!txqi->txq.sta) in ieee80211_txq_set_active()
4028 sta = container_of(txqi->txq.sta, struct sta_info, sta); in ieee80211_txq_set_active()
4029 sta->airtime[txqi->txq.ac].last_active = jiffies; in ieee80211_txq_set_active()
4037 if (!txqi->txq.sta) in ieee80211_txq_keep_active()
4040 sta = container_of(txqi->txq.sta, struct sta_info, sta); in ieee80211_txq_keep_active()
4041 if (ieee80211_sta_deficit(sta, txqi->txq.ac) >= 0) in ieee80211_txq_keep_active()
4044 return ieee80211_sta_keep_active(sta, txqi->txq.ac); in ieee80211_txq_keep_active()
4054 spin_lock_bh(&local->active_txq_lock[ac]); in ieee80211_next_txq()
4056 if (!local->schedule_round[ac]) in ieee80211_next_txq()
4060 txqi = list_first_entry_or_null(&local->active_txqs[ac], in ieee80211_next_txq()
4076 if (txqi->txq.sta) { in ieee80211_next_txq()
4077 struct sta_info *sta = container_of(txqi->txq.sta, in ieee80211_next_txq()
4079 bool aql_check = ieee80211_txq_airtime_check(hw, &txqi->txq); in ieee80211_next_txq()
4080 s32 deficit = ieee80211_sta_deficit(sta, txqi->txq.ac); in ieee80211_next_txq()
4086 sta->airtime[txqi->txq.ac].deficit += in ieee80211_next_txq()
4087 sta->airtime_weight; in ieee80211_next_txq()
4090 list_move_tail(&txqi->schedule_order, in ieee80211_next_txq()
4091 &local->active_txqs[txqi->txq.ac]); in ieee80211_next_txq()
4096 if (txqi->schedule_round == local->schedule_round[ac]) in ieee80211_next_txq()
4099 list_del_init(&txqi->schedule_order); in ieee80211_next_txq()
4100 txqi->schedule_round = local->schedule_round[ac]; in ieee80211_next_txq()
4101 ret = &txqi->txq; in ieee80211_next_txq()
4104 spin_unlock_bh(&local->active_txq_lock[ac]); in ieee80211_next_txq()
4117 spin_lock_bh(&local->active_txq_lock[txq->ac]); in __ieee80211_schedule_txq()
4120 if (list_empty(&txqi->schedule_order) && in __ieee80211_schedule_txq()
4129 if (txqi->txq.sta && local->airtime_flags && has_queue && in __ieee80211_schedule_txq()
4130 wiphy_ext_feature_isset(local->hw.wiphy, in __ieee80211_schedule_txq()
4132 list_add(&txqi->schedule_order, in __ieee80211_schedule_txq()
4133 &local->active_txqs[txq->ac]); in __ieee80211_schedule_txq()
4135 list_add_tail(&txqi->schedule_order, in __ieee80211_schedule_txq()
4136 &local->active_txqs[txq->ac]); in __ieee80211_schedule_txq()
4141 spin_unlock_bh(&local->active_txq_lock[txq->ac]); in __ieee80211_schedule_txq()
4153 if (!wiphy_ext_feature_isset(local->hw.wiphy, NL80211_EXT_FEATURE_AQL)) in ieee80211_txq_airtime_check()
4159 if (!txq->sta) in ieee80211_txq_airtime_check()
4162 if (unlikely(txq->tid == IEEE80211_NUM_TIDS)) in ieee80211_txq_airtime_check()
4165 sta = container_of(txq->sta, struct sta_info, sta); in ieee80211_txq_airtime_check()
4166 if (atomic_read(&sta->airtime[txq->ac].aql_tx_pending) < in ieee80211_txq_airtime_check()
4167 sta->airtime[txq->ac].aql_limit_low) in ieee80211_txq_airtime_check()
4170 if (atomic_read(&local->aql_total_pending_airtime) < in ieee80211_txq_airtime_check()
4171 local->aql_threshold && in ieee80211_txq_airtime_check()
4172 atomic_read(&sta->airtime[txq->ac].aql_tx_pending) < in ieee80211_txq_airtime_check()
4173 sta->airtime[txq->ac].aql_limit_high) in ieee80211_txq_airtime_check()
4187 if (!wiphy_ext_feature_isset(local->hw.wiphy, NL80211_EXT_FEATURE_AQL)) in ieee80211_txq_schedule_airtime_check()
4190 list_for_each_entry(txq, &local->active_txqs[ac], schedule_order) in ieee80211_txq_schedule_airtime_check()
4193 aql_limit = (num_txq - 1) * local->aql_txq_limit_low[ac] / 2 + in ieee80211_txq_schedule_airtime_check()
4194 local->aql_txq_limit_high[ac]; in ieee80211_txq_schedule_airtime_check()
4196 return atomic_read(&local->aql_ac_pending_airtime[ac]) < aql_limit; in ieee80211_txq_schedule_airtime_check()
4205 u8 ac = txq->ac; in ieee80211_txq_may_transmit()
4207 spin_lock_bh(&local->active_txq_lock[ac]); in ieee80211_txq_may_transmit()
4209 if (!txqi->txq.sta) in ieee80211_txq_may_transmit()
4212 if (list_empty(&txqi->schedule_order)) in ieee80211_txq_may_transmit()
4218 list_for_each_entry_safe(iter, tmp, &local->active_txqs[ac], in ieee80211_txq_may_transmit()
4223 if (!iter->txq.sta) { in ieee80211_txq_may_transmit()
4224 list_move_tail(&iter->schedule_order, in ieee80211_txq_may_transmit()
4225 &local->active_txqs[ac]); in ieee80211_txq_may_transmit()
4228 sta = container_of(iter->txq.sta, struct sta_info, sta); in ieee80211_txq_may_transmit()
4230 sta->airtime[ac].deficit += sta->airtime_weight; in ieee80211_txq_may_transmit()
4231 list_move_tail(&iter->schedule_order, &local->active_txqs[ac]); in ieee80211_txq_may_transmit()
4234 sta = container_of(txqi->txq.sta, struct sta_info, sta); in ieee80211_txq_may_transmit()
4235 if (sta->airtime[ac].deficit >= 0) in ieee80211_txq_may_transmit()
4238 sta->airtime[ac].deficit += sta->airtime_weight; in ieee80211_txq_may_transmit()
4239 list_move_tail(&txqi->schedule_order, &local->active_txqs[ac]); in ieee80211_txq_may_transmit()
4240 spin_unlock_bh(&local->active_txq_lock[ac]); in ieee80211_txq_may_transmit()
4244 if (!list_empty(&txqi->schedule_order)) in ieee80211_txq_may_transmit()
4245 list_del_init(&txqi->schedule_order); in ieee80211_txq_may_transmit()
4246 spin_unlock_bh(&local->active_txq_lock[ac]); in ieee80211_txq_may_transmit()
4256 spin_lock_bh(&local->active_txq_lock[ac]); in ieee80211_txq_schedule_start()
4259 local->schedule_round[ac]++; in ieee80211_txq_schedule_start()
4260 if (!local->schedule_round[ac]) in ieee80211_txq_schedule_start()
4261 local->schedule_round[ac]++; in ieee80211_txq_schedule_start()
4263 local->schedule_round[ac] = 0; in ieee80211_txq_schedule_start()
4266 spin_unlock_bh(&local->active_txq_lock[ac]); in ieee80211_txq_schedule_start()
4277 struct ieee80211_local *local = sdata->local; in __ieee80211_subif_start_xmit()
4280 int len = skb->len; in __ieee80211_subif_start_xmit()
4282 if (unlikely(!ieee80211_sdata_running(sdata) || skb->len < ETH_HLEN)) { in __ieee80211_subif_start_xmit()
4287 sk_pacing_shift_update(skb->sk, sdata->local->hw.tx_sk_pacing_shift); in __ieee80211_subif_start_xmit()
4291 if (ieee80211_vif_is_mesh(&sdata->vif) && in __ieee80211_subif_start_xmit()
4292 ieee80211_hw_check(&local->hw, SUPPORT_FAST_XMIT) && in __ieee80211_subif_start_xmit()
4308 fast_tx = rcu_dereference(sta->fast_tx); in __ieee80211_subif_start_xmit()
4315 /* the frame could be fragmented, software-encrypted, and other in __ieee80211_subif_start_xmit()
4328 if (skb->protocol == sdata->control_port_protocol) in __ieee80211_subif_start_xmit()
4338 dev_sw_netstats_tx_add(dev, 1, skb->len); in __ieee80211_subif_start_xmit()
4361 eth = (void *)skb->data; in ieee80211_change_da()
4362 ether_addr_copy(eth->h_dest, sta->sta.addr); in ieee80211_change_da()
4371 const struct ethhdr *eth = (void *)skb->data; in ieee80211_multicast_to_unicast()
4372 const struct vlan_ethhdr *ethvlan = (void *)skb->data; in ieee80211_multicast_to_unicast()
4375 switch (sdata->vif.type) { in ieee80211_multicast_to_unicast()
4377 if (sdata->u.vlan.sta) in ieee80211_multicast_to_unicast()
4379 if (sdata->wdev.use_4addr) in ieee80211_multicast_to_unicast()
4384 if (!sdata->bss->multicast_to_unicast) in ieee80211_multicast_to_unicast()
4392 ethertype = eth->h_proto; in ieee80211_multicast_to_unicast()
4393 if (ethertype == htons(ETH_P_8021Q) && skb->len >= VLAN_ETH_HLEN) in ieee80211_multicast_to_unicast()
4394 ethertype = ethvlan->h_vlan_encapsulated_proto; in ieee80211_multicast_to_unicast()
4412 struct ieee80211_local *local = sdata->local; in ieee80211_convert_to_unicast()
4413 const struct ethhdr *eth = (struct ethhdr *)skb->data; in ieee80211_convert_to_unicast()
4419 list_for_each_entry_rcu(sta, &local->sta_list, list) { in ieee80211_convert_to_unicast()
4420 if (sdata != sta->sdata) in ieee80211_convert_to_unicast()
4421 /* AP-VLAN mismatch */ in ieee80211_convert_to_unicast()
4423 if (unlikely(ether_addr_equal(eth->h_source, sta->sta.addr))) in ieee80211_convert_to_unicast()
4469 __ieee80211_subif_start_xmit(out, sdata->dev, 0, ctrl_flags, NULL); in ieee80211_mlo_multicast_tx_one()
4476 unsigned long links = sdata->vif.active_links; in ieee80211_mlo_multicast_tx()
4484 __ieee80211_subif_start_xmit(skb, sdata->dev, 0, ctrl_flags, in ieee80211_mlo_multicast_tx()
4497 * ieee80211_subif_start_xmit - netif start_xmit function for 802.3 vifs
4509 const struct ethhdr *eth = (void *)skb->data; in ieee80211_subif_start_xmit()
4511 if (likely(!is_multicast_ether_addr(eth->h_dest))) in ieee80211_subif_start_xmit()
4528 } else if (ieee80211_vif_is_mld(&sdata->vif) && in ieee80211_subif_start_xmit()
4529 sdata->vif.type == NL80211_IFTYPE_AP && in ieee80211_subif_start_xmit()
4530 !ieee80211_hw_check(&sdata->local->hw, MLO_MCAST_MULTI_LINK_TX)) { in ieee80211_subif_start_xmit()
4548 struct ieee80211_local *local = sdata->local; in __ieee80211_tx_8023()
4553 int q = info->hw_queue; in __ieee80211_tx_8023()
4555 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in __ieee80211_tx_8023()
4557 if (local->queue_stop_reasons[q] || in __ieee80211_tx_8023()
4558 (!txpending && !skb_queue_empty(&local->pending[q]))) { in __ieee80211_tx_8023()
4560 skb_queue_head(&local->pending[q], skb); in __ieee80211_tx_8023()
4562 skb_queue_tail(&local->pending[q], skb); in __ieee80211_tx_8023()
4564 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in __ieee80211_tx_8023()
4569 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in __ieee80211_tx_8023()
4571 if (sta && sta->uploaded) in __ieee80211_tx_8023()
4572 pubsta = &sta->sta; in __ieee80211_tx_8023()
4585 struct ieee80211_local *local = sdata->local; in ieee80211_tx_8023()
4606 struct ieee80211_local *local = sdata->local; in ieee80211_8023_xmit()
4608 struct sk_buff *seg, *next; in ieee80211_8023_xmit() local
4616 if (unlikely(test_bit(SCAN_SW_SCANNING, &local->scanning)) && in ieee80211_8023_xmit()
4617 test_bit(SDATA_STATE_OFFCHANNEL, &sdata->state)) in ieee80211_8023_xmit()
4626 tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; in ieee80211_8023_xmit()
4627 tid_tx = rcu_dereference(sta->ampdu_mlme.tid_tx[tid]); in ieee80211_8023_xmit()
4629 if (!test_bit(HT_AGG_STATE_OPERATIONAL, &tid_tx->state)) { in ieee80211_8023_xmit()
4630 /* fall back to non-offload slow path */ in ieee80211_8023_xmit()
4637 if (tid_tx->timeout) in ieee80211_8023_xmit()
4638 tid_tx->last_tx = jiffies; in ieee80211_8023_xmit()
4648 info->hw_queue = sdata->vif.hw_queue[queue]; in ieee80211_8023_xmit()
4650 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) in ieee80211_8023_xmit()
4651 sdata = container_of(sdata->bss, in ieee80211_8023_xmit()
4654 info->flags |= IEEE80211_TX_CTL_HW_80211_ENCAP; in ieee80211_8023_xmit()
4655 info->control.vif = &sdata->vif; in ieee80211_8023_xmit()
4658 info->control.hw_key = &key->conf; in ieee80211_8023_xmit()
4660 skb_list_walk_safe(skb, seg, next) { in ieee80211_8023_xmit()
4662 len += seg->len; in ieee80211_8023_xmit()
4663 if (seg != skb) in ieee80211_8023_xmit()
4664 memcpy(IEEE80211_SKB_CB(seg), info, sizeof(*info)); in ieee80211_8023_xmit()
4667 if (unlikely(skb->sk && in ieee80211_8023_xmit()
4668 skb_shinfo(skb)->tx_flags & SKBTX_WIFI_STATUS)) { in ieee80211_8023_xmit()
4669 info->status_data = ieee80211_store_ack_skb(local, skb, in ieee80211_8023_xmit()
4670 &info->flags, NULL); in ieee80211_8023_xmit()
4671 if (info->status_data) in ieee80211_8023_xmit()
4672 info->status_data_idr = 1; in ieee80211_8023_xmit()
4676 sta->deflink.tx_stats.packets[queue] += skbs; in ieee80211_8023_xmit()
4677 sta->deflink.tx_stats.bytes[queue] += len; in ieee80211_8023_xmit()
4693 struct ethhdr *ehdr = (struct ethhdr *)skb->data; in ieee80211_subif_start_xmit_8023()
4697 if (unlikely(!ieee80211_sdata_running(sdata) || skb->len < ETH_HLEN)) { in ieee80211_subif_start_xmit_8023()
4709 if (unlikely(IS_ERR_OR_NULL(sta) || !sta->uploaded || in ieee80211_subif_start_xmit_8023()
4711 sdata->control_port_protocol == ehdr->h_proto)) in ieee80211_subif_start_xmit_8023()
4714 key = rcu_dereference(sta->ptk[sta->ptk_idx]); in ieee80211_subif_start_xmit_8023()
4716 key = rcu_dereference(sdata->default_unicast_key); in ieee80211_subif_start_xmit_8023()
4718 if (key && (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) || in ieee80211_subif_start_xmit_8023()
4719 key->conf.cipher == WLAN_CIPHER_SUITE_TKIP)) in ieee80211_subif_start_xmit_8023()
4722 sk_pacing_shift_update(skb->sk, sdata->local->hw.tx_sk_pacing_shift); in ieee80211_subif_start_xmit_8023()
4740 .local = sdata->local, in ieee80211_build_data_template()
4749 skb = ERR_PTR(-EINVAL); in ieee80211_build_data_template()
4758 hdr = (void *)skb->data; in ieee80211_build_data_template()
4759 tx.sta = sta_info_get(sdata, hdr->addr1); in ieee80211_build_data_template()
4765 return ERR_PTR(-EINVAL); in ieee80211_build_data_template()
4782 for (i = 0; i < local->hw.queues; i++) { in ieee80211_clear_tx_pending()
4783 while ((skb = skb_dequeue(&local->pending[i])) != NULL) in ieee80211_clear_tx_pending()
4784 ieee80211_free_txskb(&local->hw, skb); in ieee80211_clear_tx_pending()
4790 * which in this case means re-queued -- take as an indication to stop sending
4803 sdata = vif_to_sdata(info->control.vif); in ieee80211_tx_pending_skb()
4805 if (info->control.flags & IEEE80211_TX_INTCFL_NEED_TXPROCESSING) { in ieee80211_tx_pending_skb()
4806 /* update band only for non-MLD */ in ieee80211_tx_pending_skb()
4807 if (!ieee80211_vif_is_mld(&sdata->vif)) { in ieee80211_tx_pending_skb()
4809 rcu_dereference(sdata->vif.bss_conf.chanctx_conf); in ieee80211_tx_pending_skb()
4814 info->band = chanctx_conf->def.chan->band; in ieee80211_tx_pending_skb()
4817 } else if (info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP) { in ieee80211_tx_pending_skb()
4823 if (IS_ERR(sta) || (sta && !sta->uploaded)) in ieee80211_tx_pending_skb()
4833 hdr = (struct ieee80211_hdr *)skb->data; in ieee80211_tx_pending_skb()
4834 sta = sta_info_get(sdata, hdr->addr1); in ieee80211_tx_pending_skb()
4855 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in ieee80211_tx_pending()
4856 for (i = 0; i < local->hw.queues; i++) { in ieee80211_tx_pending()
4861 if (local->queue_stop_reasons[i] || in ieee80211_tx_pending()
4862 skb_queue_empty(&local->pending[i])) in ieee80211_tx_pending()
4865 while (!skb_queue_empty(&local->pending[i])) { in ieee80211_tx_pending()
4866 struct sk_buff *skb = __skb_dequeue(&local->pending[i]); in ieee80211_tx_pending()
4869 if (WARN_ON(!info->control.vif)) { in ieee80211_tx_pending()
4870 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_pending()
4874 spin_unlock_irqrestore(&local->queue_stop_reason_lock, in ieee80211_tx_pending()
4878 spin_lock_irqsave(&local->queue_stop_reason_lock, in ieee80211_tx_pending()
4884 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_tx_pending()
4899 struct ieee80211_bss_conf *link_conf = link->conf; in __ieee80211_beacon_add_tim()
4903 if (atomic_read(&ps->num_sta_ps) > 0) in __ieee80211_beacon_add_tim()
4905 * checking byte-for-byte */ in __ieee80211_beacon_add_tim()
4906 have_bits = !bitmap_empty((unsigned long *)ps->tim, in __ieee80211_beacon_add_tim()
4909 if (ps->dtim_count == 0) in __ieee80211_beacon_add_tim()
4910 ps->dtim_count = link_conf->dtim_period - 1; in __ieee80211_beacon_add_tim()
4912 ps->dtim_count--; in __ieee80211_beacon_add_tim()
4918 *pos++ = ps->dtim_count; in __ieee80211_beacon_add_tim()
4919 *pos++ = link_conf->dtim_period; in __ieee80211_beacon_add_tim()
4921 if (ps->dtim_count == 0 && !skb_queue_empty(&ps->bc_buf)) in __ieee80211_beacon_add_tim()
4924 ps->dtim_bc_mc = aid0 == 1; in __ieee80211_beacon_add_tim()
4928 * (N1 x 8) - 1 in the bitmap are 0 and number N2 so that bits in __ieee80211_beacon_add_tim()
4932 if (ps->tim[i]) { in __ieee80211_beacon_add_tim()
4938 for (i = IEEE80211_MAX_TIM_LEN - 1; i >= n1; i--) { in __ieee80211_beacon_add_tim()
4939 if (ps->tim[i]) { in __ieee80211_beacon_add_tim()
4948 skb_put_data(skb, ps->tim + n1, n2 - n1 + 1); in __ieee80211_beacon_add_tim()
4950 tim[1] = n2 - n1 + 4; in __ieee80211_beacon_add_tim()
4954 if (ieee80211_get_link_sband(link)->band != NL80211_BAND_S1GHZ) { in __ieee80211_beacon_add_tim()
4967 struct ieee80211_local *local = sdata->local; in ieee80211_beacon_add_tim()
4973 * sta_lock to guarantee consistent and race-free update in ieee80211_beacon_add_tim()
4976 if (local->tim_in_locked_section) { in ieee80211_beacon_add_tim()
4979 spin_lock_bh(&local->tim_lock); in ieee80211_beacon_add_tim()
4981 spin_unlock_bh(&local->tim_lock); in ieee80211_beacon_add_tim()
4997 switch (sdata->vif.type) { in ieee80211_set_beacon_cntdwn()
4999 beacon_data = beacon->tail; in ieee80211_set_beacon_cntdwn()
5000 beacon_data_len = beacon->tail_len; in ieee80211_set_beacon_cntdwn()
5003 beacon_data = beacon->head; in ieee80211_set_beacon_cntdwn()
5004 beacon_data_len = beacon->head_len; in ieee80211_set_beacon_cntdwn()
5007 beacon_data = beacon->head; in ieee80211_set_beacon_cntdwn()
5008 beacon_data_len = beacon->head_len; in ieee80211_set_beacon_cntdwn()
5014 resp = rcu_dereference(link->u.ap.probe_resp); in ieee80211_set_beacon_cntdwn()
5016 bcn_offsets = beacon->cntdwn_counter_offsets; in ieee80211_set_beacon_cntdwn()
5017 count = beacon->cntdwn_current_counter; in ieee80211_set_beacon_cntdwn()
5018 if (link->conf->csa_active) in ieee80211_set_beacon_cntdwn()
5028 if (sdata->vif.type == NL80211_IFTYPE_AP && resp) { in ieee80211_set_beacon_cntdwn()
5029 u16 *resp_offsets = resp->cntdwn_counter_offsets; in ieee80211_set_beacon_cntdwn()
5031 resp->data[resp_offsets[i]] = count; in ieee80211_set_beacon_cntdwn()
5038 beacon->cntdwn_current_counter--; in __ieee80211_beacon_update_cntdwn()
5041 WARN_ON_ONCE(!beacon->cntdwn_current_counter); in __ieee80211_beacon_update_cntdwn()
5043 return beacon->cntdwn_current_counter; in __ieee80211_beacon_update_cntdwn()
5058 link = rcu_dereference(sdata->link[link_id]); in ieee80211_beacon_update_cntdwn()
5062 if (sdata->vif.type == NL80211_IFTYPE_AP) in ieee80211_beacon_update_cntdwn()
5063 beacon = rcu_dereference(link->u.ap.beacon); in ieee80211_beacon_update_cntdwn()
5064 else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) in ieee80211_beacon_update_cntdwn()
5065 beacon = rcu_dereference(sdata->u.ibss.presp); in ieee80211_beacon_update_cntdwn()
5066 else if (ieee80211_vif_is_mesh(&sdata->vif)) in ieee80211_beacon_update_cntdwn()
5067 beacon = rcu_dereference(sdata->u.mesh.beacon); in ieee80211_beacon_update_cntdwn()
5087 if (sdata->vif.type == NL80211_IFTYPE_AP) in ieee80211_beacon_set_cntdwn()
5088 beacon = rcu_dereference(sdata->deflink.u.ap.beacon); in ieee80211_beacon_set_cntdwn()
5089 else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) in ieee80211_beacon_set_cntdwn()
5090 beacon = rcu_dereference(sdata->u.ibss.presp); in ieee80211_beacon_set_cntdwn()
5091 else if (ieee80211_vif_is_mesh(&sdata->vif)) in ieee80211_beacon_set_cntdwn()
5092 beacon = rcu_dereference(sdata->u.mesh.beacon); in ieee80211_beacon_set_cntdwn()
5097 if (counter < beacon->cntdwn_current_counter) in ieee80211_beacon_set_cntdwn()
5098 beacon->cntdwn_current_counter = counter; in ieee80211_beacon_set_cntdwn()
5123 link = rcu_dereference(sdata->link[link_id]); in ieee80211_beacon_cntdwn_is_complete()
5127 if (vif->type == NL80211_IFTYPE_AP) { in ieee80211_beacon_cntdwn_is_complete()
5128 beacon = rcu_dereference(link->u.ap.beacon); in ieee80211_beacon_cntdwn_is_complete()
5129 if (WARN_ON(!beacon || !beacon->tail)) in ieee80211_beacon_cntdwn_is_complete()
5131 beacon_data = beacon->tail; in ieee80211_beacon_cntdwn_is_complete()
5132 beacon_data_len = beacon->tail_len; in ieee80211_beacon_cntdwn_is_complete()
5133 } else if (vif->type == NL80211_IFTYPE_ADHOC) { in ieee80211_beacon_cntdwn_is_complete()
5134 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; in ieee80211_beacon_cntdwn_is_complete()
5136 beacon = rcu_dereference(ifibss->presp); in ieee80211_beacon_cntdwn_is_complete()
5140 beacon_data = beacon->head; in ieee80211_beacon_cntdwn_is_complete()
5141 beacon_data_len = beacon->head_len; in ieee80211_beacon_cntdwn_is_complete()
5142 } else if (vif->type == NL80211_IFTYPE_MESH_POINT) { in ieee80211_beacon_cntdwn_is_complete()
5143 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; in ieee80211_beacon_cntdwn_is_complete()
5145 beacon = rcu_dereference(ifmsh->beacon); in ieee80211_beacon_cntdwn_is_complete()
5149 beacon_data = beacon->head; in ieee80211_beacon_cntdwn_is_complete()
5150 beacon_data_len = beacon->head_len; in ieee80211_beacon_cntdwn_is_complete()
5156 if (!beacon->cntdwn_counter_offsets[0]) in ieee80211_beacon_cntdwn_is_complete()
5159 if (WARN_ON_ONCE(beacon->cntdwn_counter_offsets[0] > beacon_data_len)) in ieee80211_beacon_cntdwn_is_complete()
5162 if (beacon_data[beacon->cntdwn_counter_offsets[0]] == 1) in ieee80211_beacon_cntdwn_is_complete()
5182 tx.key = rcu_dereference(link->default_beacon_key); in ieee80211_beacon_protect()
5186 if (unlikely(tx.key->flags & KEY_FLAG_TAINTED)) { in ieee80211_beacon_protect()
5188 return -EINVAL; in ieee80211_beacon_protect()
5191 if (!(tx.key->conf.flags & IEEE80211_KEY_FLAG_SW_MGMT_TX) && in ieee80211_beacon_protect()
5192 tx.key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) in ieee80211_beacon_protect()
5193 IEEE80211_SKB_CB(skb)->control.hw_key = &tx.key->conf; in ieee80211_beacon_protect()
5204 return -EINVAL; in ieee80211_beacon_protect()
5230 u16 csa_off = beacon->cntdwn_counter_offsets[i]; in ieee80211_beacon_get_finish()
5235 offs->cntdwn_counter_offs[i] = csa_off_base + csa_off; in ieee80211_beacon_get_finish()
5239 band = chanctx_conf->def.chan->band; in ieee80211_beacon_get_finish()
5241 info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; in ieee80211_beacon_get_finish()
5242 info->flags |= IEEE80211_TX_CTL_NO_ACK; in ieee80211_beacon_get_finish()
5243 info->band = band; in ieee80211_beacon_get_finish()
5247 txrc.sband = local->hw.wiphy->bands[band]; in ieee80211_beacon_get_finish()
5248 txrc.bss_conf = link->conf; in ieee80211_beacon_get_finish()
5250 txrc.reported_rate.idx = -1; in ieee80211_beacon_get_finish()
5251 if (sdata->beacon_rate_set && sdata->beacon_rateidx_mask[band]) in ieee80211_beacon_get_finish()
5252 txrc.rate_idx_mask = sdata->beacon_rateidx_mask[band]; in ieee80211_beacon_get_finish()
5254 txrc.rate_idx_mask = sdata->rc_rateidx_mask[band]; in ieee80211_beacon_get_finish()
5258 info->control.vif = vif; in ieee80211_beacon_get_finish()
5259 info->control.flags |= u32_encode_bits(link->link_id, in ieee80211_beacon_get_finish()
5261 info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT | in ieee80211_beacon_get_finish()
5270 if (!beacon->mbssid_ies || !beacon->mbssid_ies->cnt || in ieee80211_beacon_add_mbssid()
5271 i > beacon->mbssid_ies->cnt) in ieee80211_beacon_add_mbssid()
5274 if (i < beacon->mbssid_ies->cnt) { in ieee80211_beacon_add_mbssid()
5275 skb_put_data(skb, beacon->mbssid_ies->elem[i].data, in ieee80211_beacon_add_mbssid()
5276 beacon->mbssid_ies->elem[i].len); in ieee80211_beacon_add_mbssid()
5278 if (beacon->rnr_ies && beacon->rnr_ies->cnt) { in ieee80211_beacon_add_mbssid()
5279 skb_put_data(skb, beacon->rnr_ies->elem[i].data, in ieee80211_beacon_add_mbssid()
5280 beacon->rnr_ies->elem[i].len); in ieee80211_beacon_add_mbssid()
5282 for (i = beacon->mbssid_ies->cnt; i < beacon->rnr_ies->cnt; i++) in ieee80211_beacon_add_mbssid()
5283 skb_put_data(skb, beacon->rnr_ies->elem[i].data, in ieee80211_beacon_add_mbssid()
5284 beacon->rnr_ies->elem[i].len); in ieee80211_beacon_add_mbssid()
5289 /* i == beacon->mbssid_ies->cnt, include all MBSSID elements */ in ieee80211_beacon_add_mbssid()
5290 for (i = 0; i < beacon->mbssid_ies->cnt; i++) in ieee80211_beacon_add_mbssid()
5291 skb_put_data(skb, beacon->mbssid_ies->elem[i].data, in ieee80211_beacon_add_mbssid()
5292 beacon->mbssid_ies->elem[i].len); in ieee80211_beacon_add_mbssid()
5307 struct ieee80211_if_ap *ap = &sdata->u.ap; in ieee80211_beacon_get_ap()
5312 if (beacon->cntdwn_counter_offsets[0]) { in ieee80211_beacon_get_ap()
5314 ieee80211_beacon_update_cntdwn(vif, link->link_id); in ieee80211_beacon_get_ap()
5322 mbssid_len = ieee80211_get_mbssid_beacon_len(beacon->mbssid_ies, in ieee80211_beacon_get_ap()
5323 beacon->rnr_ies, in ieee80211_beacon_get_ap()
5326 skb = dev_alloc_skb(local->tx_headroom + beacon->head_len + in ieee80211_beacon_get_ap()
5327 beacon->tail_len + 256 + in ieee80211_beacon_get_ap()
5328 local->hw.extra_beacon_tailroom + mbssid_len); in ieee80211_beacon_get_ap()
5332 skb_reserve(skb, local->tx_headroom); in ieee80211_beacon_get_ap()
5333 skb_put_data(skb, beacon->head, beacon->head_len); in ieee80211_beacon_get_ap()
5335 ieee80211_beacon_add_tim(sdata, link, &ap->ps, skb, is_template); in ieee80211_beacon_get_ap()
5338 offs->tim_offset = beacon->head_len; in ieee80211_beacon_get_ap()
5339 offs->tim_length = skb->len - beacon->head_len; in ieee80211_beacon_get_ap()
5340 offs->cntdwn_counter_offs[0] = beacon->cntdwn_counter_offsets[0]; in ieee80211_beacon_get_ap()
5344 offs->mbssid_off = skb->len - mbssid_len; in ieee80211_beacon_get_ap()
5348 csa_off_base = skb->len; in ieee80211_beacon_get_ap()
5351 if (beacon->tail) in ieee80211_beacon_get_ap()
5352 skb_put_data(skb, beacon->tail, beacon->tail_len); in ieee80211_beacon_get_ap()
5374 if (!beacon->mbssid_ies || !beacon->mbssid_ies->cnt) in ieee80211_beacon_get_ap_ema_list()
5377 ema = kzalloc(struct_size(ema, bcn, beacon->mbssid_ies->cnt), in ieee80211_beacon_get_ap_ema_list()
5382 for (ema->cnt = 0; ema->cnt < beacon->mbssid_ies->cnt; ema->cnt++) { in ieee80211_beacon_get_ap_ema_list()
5383 ema->bcn[ema->cnt].skb = in ieee80211_beacon_get_ap_ema_list()
5385 &ema->bcn[ema->cnt].offs, in ieee80211_beacon_get_ap_ema_list()
5387 chanctx_conf, ema->cnt); in ieee80211_beacon_get_ap_ema_list()
5388 if (!ema->bcn[ema->cnt].skb) in ieee80211_beacon_get_ap_ema_list()
5392 if (ema->cnt == beacon->mbssid_ies->cnt) in ieee80211_beacon_get_ap_ema_list()
5399 #define IEEE80211_INCLUDE_ALL_MBSSID_ELEMS -1
5420 link = rcu_dereference(sdata->link[link_id]); in __ieee80211_beacon_get()
5424 rcu_dereference(link->conf->chanctx_conf); in __ieee80211_beacon_get()
5432 if (sdata->vif.type == NL80211_IFTYPE_AP) { in __ieee80211_beacon_get()
5433 beacon = rcu_dereference(link->u.ap.beacon); in __ieee80211_beacon_get()
5445 if (beacon->mbssid_ies && beacon->mbssid_ies->cnt) { in __ieee80211_beacon_get()
5446 if (ema_index >= beacon->mbssid_ies->cnt) in __ieee80211_beacon_get()
5450 ema_index = beacon->mbssid_ies->cnt; in __ieee80211_beacon_get()
5460 } else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) { in __ieee80211_beacon_get()
5461 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; in __ieee80211_beacon_get()
5464 beacon = rcu_dereference(ifibss->presp); in __ieee80211_beacon_get()
5468 if (beacon->cntdwn_counter_offsets[0]) { in __ieee80211_beacon_get()
5475 skb = dev_alloc_skb(local->tx_headroom + beacon->head_len + in __ieee80211_beacon_get()
5476 local->hw.extra_beacon_tailroom); in __ieee80211_beacon_get()
5479 skb_reserve(skb, local->tx_headroom); in __ieee80211_beacon_get()
5480 skb_put_data(skb, beacon->head, beacon->head_len); in __ieee80211_beacon_get()
5482 hdr = (struct ieee80211_hdr *) skb->data; in __ieee80211_beacon_get()
5483 hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | in __ieee80211_beacon_get()
5488 } else if (ieee80211_vif_is_mesh(&sdata->vif)) { in __ieee80211_beacon_get()
5489 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; in __ieee80211_beacon_get()
5491 beacon = rcu_dereference(ifmsh->beacon); in __ieee80211_beacon_get()
5495 if (beacon->cntdwn_counter_offsets[0]) { in __ieee80211_beacon_get()
5507 if (ifmsh->sync_ops) in __ieee80211_beacon_get()
5508 ifmsh->sync_ops->adjust_tsf(sdata, beacon); in __ieee80211_beacon_get()
5510 skb = dev_alloc_skb(local->tx_headroom + in __ieee80211_beacon_get()
5511 beacon->head_len + in __ieee80211_beacon_get()
5513 beacon->tail_len + in __ieee80211_beacon_get()
5514 local->hw.extra_beacon_tailroom); in __ieee80211_beacon_get()
5517 skb_reserve(skb, local->tx_headroom); in __ieee80211_beacon_get()
5518 skb_put_data(skb, beacon->head, beacon->head_len); in __ieee80211_beacon_get()
5519 ieee80211_beacon_add_tim(sdata, link, &ifmsh->ps, skb, in __ieee80211_beacon_get()
5523 offs->tim_offset = beacon->head_len; in __ieee80211_beacon_get()
5524 offs->tim_length = skb->len - beacon->head_len; in __ieee80211_beacon_get()
5527 skb_put_data(skb, beacon->tail, beacon->tail_len); in __ieee80211_beacon_get()
5570 for (i = 0; i < ema_beacons->cnt; i++) in ieee80211_beacon_free_ema_list()
5571 kfree_skb(ema_beacons->bcn[i].skb); in ieee80211_beacon_free_ema_list()
5613 !hw_to_local(hw)->monitors) in ieee80211_beacon_get_tim()
5635 if (sdata->vif.type != NL80211_IFTYPE_AP) in ieee80211_proberesp_get()
5639 presp = rcu_dereference(sdata->deflink.u.ap.probe_resp); in ieee80211_proberesp_get()
5643 skb = dev_alloc_skb(presp->len); in ieee80211_proberesp_get()
5647 skb_put_data(skb, presp->data, presp->len); in ieee80211_proberesp_get()
5649 hdr = (struct ieee80211_hdr *) skb->data; in ieee80211_proberesp_get()
5650 memset(hdr->addr1, 0, sizeof(hdr->addr1)); in ieee80211_proberesp_get()
5665 if (sdata->vif.type != NL80211_IFTYPE_AP) in ieee80211_get_fils_discovery_tmpl()
5669 tmpl = rcu_dereference(sdata->deflink.u.ap.fils_discovery); in ieee80211_get_fils_discovery_tmpl()
5675 skb = dev_alloc_skb(sdata->local->hw.extra_tx_headroom + tmpl->len); in ieee80211_get_fils_discovery_tmpl()
5677 skb_reserve(skb, sdata->local->hw.extra_tx_headroom); in ieee80211_get_fils_discovery_tmpl()
5678 skb_put_data(skb, tmpl->data, tmpl->len); in ieee80211_get_fils_discovery_tmpl()
5694 if (sdata->vif.type != NL80211_IFTYPE_AP) in ieee80211_get_unsol_bcast_probe_resp_tmpl()
5698 tmpl = rcu_dereference(sdata->deflink.u.ap.unsol_bcast_probe_resp); in ieee80211_get_unsol_bcast_probe_resp_tmpl()
5704 skb = dev_alloc_skb(sdata->local->hw.extra_tx_headroom + tmpl->len); in ieee80211_get_unsol_bcast_probe_resp_tmpl()
5706 skb_reserve(skb, sdata->local->hw.extra_tx_headroom); in ieee80211_get_unsol_bcast_probe_resp_tmpl()
5707 skb_put_data(skb, tmpl->data, tmpl->len); in ieee80211_get_unsol_bcast_probe_resp_tmpl()
5723 if (WARN_ON(vif->type != NL80211_IFTYPE_STATION)) in ieee80211_pspoll_get()
5727 local = sdata->local; in ieee80211_pspoll_get()
5729 skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*pspoll)); in ieee80211_pspoll_get()
5733 skb_reserve(skb, local->hw.extra_tx_headroom); in ieee80211_pspoll_get()
5736 pspoll->frame_control = cpu_to_le16(IEEE80211_FTYPE_CTL | in ieee80211_pspoll_get()
5738 pspoll->aid = cpu_to_le16(sdata->vif.cfg.aid); in ieee80211_pspoll_get()
5740 /* aid in PS-Poll has its two MSBs each set to 1 */ in ieee80211_pspoll_get()
5741 pspoll->aid |= cpu_to_le16(1 << 15 | 1 << 14); in ieee80211_pspoll_get()
5743 memcpy(pspoll->bssid, sdata->deflink.u.mgd.bssid, ETH_ALEN); in ieee80211_pspoll_get()
5744 memcpy(pspoll->ta, vif->addr, ETH_ALEN); in ieee80211_pspoll_get()
5755 struct ieee80211_local *local = sdata->local; in ieee80211_nullfunc_get()
5761 if (WARN_ON(vif->type != NL80211_IFTYPE_STATION)) in ieee80211_nullfunc_get()
5764 skb = dev_alloc_skb(local->hw.extra_tx_headroom + in ieee80211_nullfunc_get()
5773 sta = sta_info_get(sdata, vif->cfg.ap_addr); in ieee80211_nullfunc_get()
5774 qos = sta && sta->sta.wme; in ieee80211_nullfunc_get()
5778 link = rcu_dereference(sdata->link[link_id]); in ieee80211_nullfunc_get()
5786 skb_reserve(skb, local->hw.extra_tx_headroom); in ieee80211_nullfunc_get()
5789 nullfunc->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA | in ieee80211_nullfunc_get()
5793 __le16 qoshdr = cpu_to_le16(7); in ieee80211_nullfunc_get()
5798 nullfunc->frame_control |= in ieee80211_nullfunc_get()
5800 skb->priority = 7; in ieee80211_nullfunc_get()
5806 memcpy(nullfunc->addr1, link->conf->bssid, ETH_ALEN); in ieee80211_nullfunc_get()
5807 memcpy(nullfunc->addr2, link->conf->addr, ETH_ALEN); in ieee80211_nullfunc_get()
5808 memcpy(nullfunc->addr3, link->conf->bssid, ETH_ALEN); in ieee80211_nullfunc_get()
5810 memcpy(nullfunc->addr1, vif->cfg.ap_addr, ETH_ALEN); in ieee80211_nullfunc_get()
5811 memcpy(nullfunc->addr2, vif->addr, ETH_ALEN); in ieee80211_nullfunc_get()
5812 memcpy(nullfunc->addr3, vif->cfg.ap_addr, ETH_ALEN); in ieee80211_nullfunc_get()
5833 skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*hdr) + in ieee80211_probereq_get()
5838 skb_reserve(skb, local->hw.extra_tx_headroom); in ieee80211_probereq_get()
5841 hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | in ieee80211_probereq_get()
5843 eth_broadcast_addr(hdr->addr1); in ieee80211_probereq_get()
5844 memcpy(hdr->addr2, src_addr, ETH_ALEN); in ieee80211_probereq_get()
5845 eth_broadcast_addr(hdr->addr3); in ieee80211_probereq_get()
5865 rts->frame_control = in ieee80211_rts_get()
5867 rts->duration = ieee80211_rts_duration(hw, vif, frame_len, in ieee80211_rts_get()
5869 memcpy(rts->ra, hdr->addr1, sizeof(rts->ra)); in ieee80211_rts_get()
5870 memcpy(rts->ta, hdr->addr2, sizeof(rts->ta)); in ieee80211_rts_get()
5881 cts->frame_control = in ieee80211_ctstoself_get()
5883 cts->duration = ieee80211_ctstoself_duration(hw, vif, in ieee80211_ctstoself_get()
5885 memcpy(cts->ra, hdr->addr1, sizeof(cts->ra)); in ieee80211_ctstoself_get()
5904 chanctx_conf = rcu_dereference(sdata->vif.bss_conf.chanctx_conf); in ieee80211_get_buffered_bc()
5909 if (sdata->vif.type == NL80211_IFTYPE_AP) { in ieee80211_get_buffered_bc()
5911 rcu_dereference(sdata->deflink.u.ap.beacon); in ieee80211_get_buffered_bc()
5913 if (!beacon || !beacon->head) in ieee80211_get_buffered_bc()
5916 ps = &sdata->u.ap.ps; in ieee80211_get_buffered_bc()
5917 } else if (ieee80211_vif_is_mesh(&sdata->vif)) { in ieee80211_get_buffered_bc()
5918 ps = &sdata->u.mesh.ps; in ieee80211_get_buffered_bc()
5923 if (ps->dtim_count != 0 || !ps->dtim_bc_mc) in ieee80211_get_buffered_bc()
5927 skb = skb_dequeue(&ps->bc_buf); in ieee80211_get_buffered_bc()
5930 local->total_ps_buffered--; in ieee80211_get_buffered_bc()
5932 if (!skb_queue_empty(&ps->bc_buf) && skb->len >= 2) { in ieee80211_get_buffered_bc()
5934 (struct ieee80211_hdr *) skb->data; in ieee80211_get_buffered_bc()
5938 hdr->frame_control |= in ieee80211_get_buffered_bc()
5942 if (sdata->vif.type == NL80211_IFTYPE_AP) in ieee80211_get_buffered_bc()
5943 sdata = IEEE80211_DEV_TO_SUB_IF(skb->dev); in ieee80211_get_buffered_bc()
5952 info->band = chanctx_conf->def.chan->band; in ieee80211_get_buffered_bc()
5966 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_reserve_tid()
5967 struct ieee80211_local *local = sdata->local; in ieee80211_reserve_tid()
5971 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_reserve_tid()
5974 switch (sdata->vif.type) { in ieee80211_reserve_tid()
5981 return -EINVAL; in ieee80211_reserve_tid()
5985 return -EINVAL; in ieee80211_reserve_tid()
5987 if (sta->reserved_tid == tid) { in ieee80211_reserve_tid()
5992 if (sta->reserved_tid != IEEE80211_TID_UNRESERVED) { in ieee80211_reserve_tid()
5994 ret = -EALREADY; in ieee80211_reserve_tid()
5998 ieee80211_stop_vif_queues(sdata->local, sdata, in ieee80211_reserve_tid()
6004 if (ieee80211_hw_check(&local->hw, AMPDU_AGGREGATION)) { in ieee80211_reserve_tid()
6010 queues = BIT(sdata->vif.hw_queue[ieee802_1d_to_ac[tid]]); in ieee80211_reserve_tid()
6013 sta->reserved_tid = tid; in ieee80211_reserve_tid()
6018 if (ieee80211_hw_check(&local->hw, AMPDU_AGGREGATION)) in ieee80211_reserve_tid()
6030 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_unreserve_tid()
6032 lockdep_assert_wiphy(sdata->local->hw.wiphy); in ieee80211_unreserve_tid()
6035 switch (sdata->vif.type) { in ieee80211_unreserve_tid()
6045 if (tid != sta->reserved_tid) { in ieee80211_unreserve_tid()
6050 sta->reserved_tid = IEEE80211_TID_UNRESERVED; in ieee80211_unreserve_tid()
6058 const struct ieee80211_hdr *hdr = (void *)skb->data; in __ieee80211_tx_skb_tid_band()
6064 skb->priority = tid; in __ieee80211_tx_skb_tid_band()
6066 skb->dev = sdata->dev; in __ieee80211_tx_skb_tid_band()
6072 if (!ieee80211_vif_is_mld(&sdata->vif)) { in __ieee80211_tx_skb_tid_band()
6076 } else if (memcmp(sdata->vif.addr, hdr->addr2, ETH_ALEN) == 0) { in __ieee80211_tx_skb_tid_band()
6082 for (link = 0; link < ARRAY_SIZE(sdata->vif.link_conf); link++) { in __ieee80211_tx_skb_tid_band()
6085 link_conf = rcu_dereference(sdata->vif.link_conf[link]); in __ieee80211_tx_skb_tid_band()
6088 if (memcmp(link_conf->addr, hdr->addr2, ETH_ALEN) == 0) in __ieee80211_tx_skb_tid_band()
6093 if (WARN_ON_ONCE(link == ARRAY_SIZE(sdata->vif.link_conf))) in __ieee80211_tx_skb_tid_band()
6094 link = ffs(sdata->vif.active_links) - 1; in __ieee80211_tx_skb_tid_band()
6097 IEEE80211_SKB_CB(skb)->control.flags |= in __ieee80211_tx_skb_tid_band()
6106 IEEE80211_SKB_CB(skb)->band = band; in __ieee80211_tx_skb_tid_band()
6118 if (!ieee80211_vif_is_mld(&sdata->vif)) { in ieee80211_tx_skb_tid()
6121 rcu_dereference(sdata->vif.bss_conf.chanctx_conf); in ieee80211_tx_skb_tid()
6127 band = chanctx_conf->def.chan->band; in ieee80211_tx_skb_tid()
6130 !(sdata->vif.active_links & BIT(link_id))); in ieee80211_tx_skb_tid()
6145 struct ieee80211_local *local = sdata->local; in ieee80211_tx_control_port()
6154 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_tx_control_port()
6157 * or Pre-Authentication in ieee80211_tx_control_port()
6159 if (proto != sdata->control_port_protocol && in ieee80211_tx_control_port()
6161 return -EINVAL; in ieee80211_tx_control_port()
6163 if (proto == sdata->control_port_protocol) in ieee80211_tx_control_port()
6175 skb = dev_alloc_skb(local->hw.extra_tx_headroom + in ieee80211_tx_control_port()
6178 return -ENOMEM; in ieee80211_tx_control_port()
6180 skb_reserve(skb, local->hw.extra_tx_headroom + sizeof(struct ethhdr)); in ieee80211_tx_control_port()
6185 memcpy(ehdr->h_dest, dest, ETH_ALEN); in ieee80211_tx_control_port()
6191 memcpy(ehdr->h_source, sdata->vif.addr, ETH_ALEN); in ieee80211_tx_control_port()
6199 link_conf = rcu_dereference(sdata->vif.link_conf[link_id]); in ieee80211_tx_control_port()
6203 return -ENOLINK; in ieee80211_tx_control_port()
6205 memcpy(ehdr->h_source, link_conf->addr, ETH_ALEN); in ieee80211_tx_control_port()
6209 ehdr->h_proto = proto; in ieee80211_tx_control_port()
6211 skb->dev = dev; in ieee80211_tx_control_port()
6212 skb->protocol = proto; in ieee80211_tx_control_port()
6216 if (local->hw.queues < IEEE80211_NUM_ACS) in ieee80211_tx_control_port()
6240 if (sta && sta->sta.mlo) in ieee80211_tx_control_port()
6241 memcpy(ehdr->h_source, sdata->vif.addr, ETH_ALEN); in ieee80211_tx_control_port()
6247 __ieee80211_subif_start_xmit(skb, skb->dev, flags, ctrl_flags, cookie); in ieee80211_tx_control_port()
6257 struct ieee80211_local *local = sdata->local; in ieee80211_probe_mesh_link()
6260 skb = dev_alloc_skb(local->hw.extra_tx_headroom + len + in ieee80211_probe_mesh_link()
6264 return -ENOMEM; in ieee80211_probe_mesh_link()
6266 skb_reserve(skb, local->hw.extra_tx_headroom); in ieee80211_probe_mesh_link()
6269 skb->dev = dev; in ieee80211_probe_mesh_link()
6270 skb->protocol = htons(ETH_P_802_3); in ieee80211_probe_mesh_link()
6275 __ieee80211_subif_start_xmit(skb, skb->dev, 0, in ieee80211_probe_mesh_link()