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 <[email protected]>
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()
1185 if (!sta || !sta->sta.deflink.ht_cap.ht_supported || in ieee80211_aggr_check()
1186 !sta->sta.wme || skb_get_queue_mapping(skb) == IEEE80211_AC_VO || in ieee80211_aggr_check()
1187 skb->protocol == sdata->control_port_protocol) in ieee80211_aggr_check()
1190 tid = skb->priority & IEEE80211_QOS_CTL_TID_MASK; in ieee80211_aggr_check()
1191 if (likely(sta->ampdu_mlme.tid_tx[tid])) in ieee80211_aggr_check()
1194 ieee80211_start_tx_ba_session(&sta->sta, tid, 0); in ieee80211_aggr_check()
1207 struct ieee80211_local *local = sdata->local; in ieee80211_tx_prepare()
1214 tx->skb = skb; in ieee80211_tx_prepare()
1215 tx->local = local; in ieee80211_tx_prepare()
1216 tx->sdata = sdata; in ieee80211_tx_prepare()
1217 __skb_queue_head_init(&tx->skbs); in ieee80211_tx_prepare()
1224 info->control.flags &= ~IEEE80211_TX_INTCFL_NEED_TXPROCESSING; in ieee80211_tx_prepare()
1226 hdr = (struct ieee80211_hdr *) skb->data; in ieee80211_tx_prepare()
1230 tx->sta = sta; in ieee80211_tx_prepare()
1232 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) { in ieee80211_tx_prepare()
1233 tx->sta = rcu_dereference(sdata->u.vlan.sta); in ieee80211_tx_prepare()
1234 if (!tx->sta && sdata->wdev.use_4addr) in ieee80211_tx_prepare()
1236 } else if (tx->sdata->control_port_protocol == tx->skb->protocol) { in ieee80211_tx_prepare()
1237 tx->sta = sta_info_get_bss(sdata, hdr->addr1); in ieee80211_tx_prepare()
1239 if (!tx->sta && !is_multicast_ether_addr(hdr->addr1)) { in ieee80211_tx_prepare()
1240 tx->sta = sta_info_get(sdata, hdr->addr1); in ieee80211_tx_prepare()
1245 if (tx->sta && ieee80211_is_data_qos(hdr->frame_control) && in ieee80211_tx_prepare()
1246 !ieee80211_is_qos_nullfunc(hdr->frame_control) && in ieee80211_tx_prepare()
1247 ieee80211_hw_check(&local->hw, AMPDU_AGGREGATION) && in ieee80211_tx_prepare()
1248 !ieee80211_hw_check(&local->hw, TX_AMPDU_SETUP_IN_HW)) { in ieee80211_tx_prepare()
1252 tid_tx = rcu_dereference(tx->sta->ampdu_mlme.tid_tx[tid]); in ieee80211_tx_prepare()
1254 ieee80211_aggr_check(sdata, tx->sta, skb); in ieee80211_tx_prepare()
1255 tid_tx = rcu_dereference(tx->sta->ampdu_mlme.tid_tx[tid]); in ieee80211_tx_prepare()
1269 if (is_multicast_ether_addr(hdr->addr1)) { in ieee80211_tx_prepare()
1270 tx->flags &= ~IEEE80211_TX_UNICAST; in ieee80211_tx_prepare()
1271 info->flags |= IEEE80211_TX_CTL_NO_ACK; in ieee80211_tx_prepare()
1273 tx->flags |= IEEE80211_TX_UNICAST; in ieee80211_tx_prepare()
1275 if (!(info->flags & IEEE80211_TX_CTL_DONTFRAG)) { in ieee80211_tx_prepare()
1276 if (!(tx->flags & IEEE80211_TX_UNICAST) || in ieee80211_tx_prepare()
1277 skb->len + FCS_LEN <= local->hw.wiphy->frag_threshold || in ieee80211_tx_prepare()
1278 info->flags & IEEE80211_TX_CTL_AMPDU) in ieee80211_tx_prepare()
1279 info->flags |= IEEE80211_TX_CTL_DONTFRAG; in ieee80211_tx_prepare()
1282 if (!tx->sta) in ieee80211_tx_prepare()
1283 info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT; in ieee80211_tx_prepare()
1284 else if (test_and_clear_sta_flag(tx->sta, WLAN_STA_CLEAR_PS_FILT)) { in ieee80211_tx_prepare()
1285 info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT; in ieee80211_tx_prepare()
1286 ieee80211_check_fast_xmit(tx->sta); in ieee80211_tx_prepare()
1289 info->flags |= IEEE80211_TX_CTL_FIRST_FRAGMENT; in ieee80211_tx_prepare()
1299 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; in ieee80211_get_txq()
1303 if ((info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM) || in ieee80211_get_txq()
1304 (info->control.flags & IEEE80211_TX_CTRL_PS_RESPONSE)) in ieee80211_get_txq()
1307 if (!(info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP) && in ieee80211_get_txq()
1308 unlikely(!ieee80211_is_data_present(hdr->frame_control))) { in ieee80211_get_txq()
1309 if ((!ieee80211_is_mgmt(hdr->frame_control) || in ieee80211_get_txq()
1311 vif->type == NL80211_IFTYPE_STATION) && in ieee80211_get_txq()
1312 sta && sta->uploaded) { in ieee80211_get_txq()
1315 * opt-in hardware flag. in ieee80211_get_txq()
1317 txq = sta->sta.txq[IEEE80211_NUM_TIDS]; in ieee80211_get_txq()
1320 u8 tid = skb->priority & IEEE80211_QOS_CTL_TID_MASK; in ieee80211_get_txq()
1322 if (!sta->uploaded) in ieee80211_get_txq()
1325 txq = sta->sta.txq[tid]; in ieee80211_get_txq()
1327 txq = vif->txq; in ieee80211_get_txq()
1342 IEEE80211_SKB_CB(skb)->control.enqueue_time = now; in ieee80211_set_skb_enqueue_time()
1347 return skb->len; in codel_skb_len_func()
1354 info = (const struct ieee80211_tx_info *)skb->cb; in codel_skb_time_func()
1355 return info->control.enqueue_time; in codel_skb_time_func()
1367 local = vif_to_sdata(txqi->txq.vif)->local; in codel_dequeue_func()
1368 fq = &local->fq; in codel_dequeue_func()
1370 if (cvars == &txqi->def_cvars) in codel_dequeue_func()
1371 flow = &txqi->tin.default_flow; in codel_dequeue_func()
1373 flow = &fq->flows[cvars - local->cvars]; in codel_dequeue_func()
1386 local = vif_to_sdata(txqi->txq.vif)->local; in codel_drop_func()
1387 hw = &local->hw; in codel_drop_func()
1404 cstats = &txqi->cstats; in fq_tin_dequeue_func()
1406 if (txqi->txq.sta) { in fq_tin_dequeue_func()
1407 struct sta_info *sta = container_of(txqi->txq.sta, in fq_tin_dequeue_func()
1409 cparams = &sta->cparams; in fq_tin_dequeue_func()
1411 cparams = &local->cparams; in fq_tin_dequeue_func()
1414 if (flow == &tin->default_flow) in fq_tin_dequeue_func()
1415 cvars = &txqi->def_cvars; in fq_tin_dequeue_func()
1417 cvars = &local->cvars[flow - fq->flows]; in fq_tin_dequeue_func()
1420 &flow->backlog, in fq_tin_dequeue_func()
1438 ieee80211_free_txskb(&local->hw, skb); in fq_skb_free_func()
1445 struct fq *fq = &local->fq; in ieee80211_txq_enqueue()
1446 struct fq_tin *tin = &txqi->tin; in ieee80211_txq_enqueue()
1451 spin_lock_bh(&fq->lock); in ieee80211_txq_enqueue()
1458 if (unlikely(txqi->txq.tid == IEEE80211_NUM_TIDS)) { in ieee80211_txq_enqueue()
1459 IEEE80211_SKB_CB(skb)->control.flags |= in ieee80211_txq_enqueue()
1461 __skb_queue_tail(&txqi->frags, skb); in ieee80211_txq_enqueue()
1466 spin_unlock_bh(&fq->lock); in ieee80211_txq_enqueue()
1475 return info->control.vif == data; in fq_vlan_filter_func()
1481 struct fq *fq = &local->fq; in ieee80211_txq_remove_vlan()
1486 if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_AP_VLAN)) in ieee80211_txq_remove_vlan()
1489 ap = container_of(sdata->bss, struct ieee80211_sub_if_data, u.ap); in ieee80211_txq_remove_vlan()
1491 if (!ap->vif.txq) in ieee80211_txq_remove_vlan()
1494 txqi = to_txq_info(ap->vif.txq); in ieee80211_txq_remove_vlan()
1495 tin = &txqi->tin; in ieee80211_txq_remove_vlan()
1497 spin_lock_bh(&fq->lock); in ieee80211_txq_remove_vlan()
1498 fq_tin_filter(fq, tin, fq_vlan_filter_func, &sdata->vif, in ieee80211_txq_remove_vlan()
1500 spin_unlock_bh(&fq->lock); in ieee80211_txq_remove_vlan()
1507 fq_tin_init(&txqi->tin); in ieee80211_txq_init()
1508 codel_vars_init(&txqi->def_cvars); in ieee80211_txq_init()
1509 codel_stats_init(&txqi->cstats); in ieee80211_txq_init()
1510 __skb_queue_head_init(&txqi->frags); in ieee80211_txq_init()
1511 INIT_LIST_HEAD(&txqi->schedule_order); in ieee80211_txq_init()
1513 txqi->txq.vif = &sdata->vif; in ieee80211_txq_init()
1516 sdata->vif.txq = &txqi->txq; in ieee80211_txq_init()
1517 txqi->txq.tid = 0; in ieee80211_txq_init()
1518 txqi->txq.ac = IEEE80211_AC_BE; in ieee80211_txq_init()
1524 if (sdata->vif.type == NL80211_IFTYPE_STATION) { in ieee80211_txq_init()
1526 if (!ieee80211_hw_check(&sdata->local->hw, in ieee80211_txq_init()
1529 } else if (!ieee80211_hw_check(&sdata->local->hw, in ieee80211_txq_init()
1534 txqi->txq.ac = IEEE80211_AC_VO; in ieee80211_txq_init()
1536 txqi->txq.ac = ieee80211_ac_from_tid(tid); in ieee80211_txq_init()
1539 txqi->txq.sta = &sta->sta; in ieee80211_txq_init()
1540 txqi->txq.tid = tid; in ieee80211_txq_init()
1541 sta->sta.txq[tid] = &txqi->txq; in ieee80211_txq_init()
1547 struct fq *fq = &local->fq; in ieee80211_txq_purge()
1548 struct fq_tin *tin = &txqi->tin; in ieee80211_txq_purge()
1550 spin_lock_bh(&fq->lock); in ieee80211_txq_purge()
1552 ieee80211_purge_tx_queue(&local->hw, &txqi->frags); in ieee80211_txq_purge()
1553 spin_unlock_bh(&fq->lock); in ieee80211_txq_purge()
1555 spin_lock_bh(&local->active_txq_lock[txqi->txq.ac]); in ieee80211_txq_purge()
1556 list_del_init(&txqi->schedule_order); in ieee80211_txq_purge()
1557 spin_unlock_bh(&local->active_txq_lock[txqi->txq.ac]); in ieee80211_txq_purge()
1562 if (local->hw.wiphy->txq_limit) in ieee80211_txq_set_params()
1563 local->fq.limit = local->hw.wiphy->txq_limit; in ieee80211_txq_set_params()
1565 local->hw.wiphy->txq_limit = local->fq.limit; in ieee80211_txq_set_params()
1567 if (local->hw.wiphy->txq_memory_limit) in ieee80211_txq_set_params()
1568 local->fq.memory_limit = local->hw.wiphy->txq_memory_limit; in ieee80211_txq_set_params()
1570 local->hw.wiphy->txq_memory_limit = local->fq.memory_limit; in ieee80211_txq_set_params()
1572 if (local->hw.wiphy->txq_quantum) in ieee80211_txq_set_params()
1573 local->fq.quantum = local->hw.wiphy->txq_quantum; in ieee80211_txq_set_params()
1575 local->hw.wiphy->txq_quantum = local->fq.quantum; in ieee80211_txq_set_params()
1580 struct fq *fq = &local->fq; in ieee80211_txq_setup_flows()
1592 * queue size. 4 Mbytes is 64 max-size aggregates in 802.11n. in ieee80211_txq_setup_flows()
1597 sband = local->hw.wiphy->bands[band]; in ieee80211_txq_setup_flows()
1601 supp_vht = supp_vht || sband->vht_cap.vht_supported; in ieee80211_txq_setup_flows()
1605 fq->memory_limit = 4 << 20; /* 4 Mbytes */ in ieee80211_txq_setup_flows()
1607 codel_params_init(&local->cparams); in ieee80211_txq_setup_flows()
1608 local->cparams.interval = MS2TIME(100); in ieee80211_txq_setup_flows()
1609 local->cparams.target = MS2TIME(20); in ieee80211_txq_setup_flows()
1610 local->cparams.ecn = true; in ieee80211_txq_setup_flows()
1612 local->cvars = kvcalloc(fq->flows_cnt, sizeof(local->cvars[0]), in ieee80211_txq_setup_flows()
1614 if (!local->cvars) { in ieee80211_txq_setup_flows()
1615 spin_lock_bh(&fq->lock); in ieee80211_txq_setup_flows()
1617 spin_unlock_bh(&fq->lock); in ieee80211_txq_setup_flows()
1618 return -ENOMEM; in ieee80211_txq_setup_flows()
1621 for (i = 0; i < fq->flows_cnt; i++) in ieee80211_txq_setup_flows()
1622 codel_vars_init(&local->cvars[i]); in ieee80211_txq_setup_flows()
1631 struct fq *fq = &local->fq; in ieee80211_txq_teardown_flows()
1633 kvfree(local->cvars); in ieee80211_txq_teardown_flows()
1634 local->cvars = NULL; in ieee80211_txq_teardown_flows()
1636 spin_lock_bh(&fq->lock); in ieee80211_txq_teardown_flows()
1638 spin_unlock_bh(&fq->lock); in ieee80211_txq_teardown_flows()
1649 if (sdata->vif.type == NL80211_IFTYPE_MONITOR) in ieee80211_queue_skb()
1652 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) in ieee80211_queue_skb()
1653 sdata = container_of(sdata->bss, in ieee80211_queue_skb()
1656 vif = &sdata->vif; in ieee80211_queue_skb()
1681 int q = info->hw_queue; in ieee80211_tx_frags()
1684 if (WARN_ON_ONCE(q >= local->hw.queues)) { in ieee80211_tx_frags()
1686 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_frags()
1691 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in ieee80211_tx_frags()
1692 if (local->queue_stop_reasons[q] || in ieee80211_tx_frags()
1693 (!txpending && !skb_queue_empty(&local->pending[q]))) { in ieee80211_tx_frags()
1694 if (unlikely(info->flags & in ieee80211_tx_frags()
1696 if (local->queue_stop_reasons[q] & in ieee80211_tx_frags()
1699 * Drop off-channel frames if queues in ieee80211_tx_frags()
1701 * than off-channel operation. Never in ieee80211_tx_frags()
1705 &local->queue_stop_reason_lock, in ieee80211_tx_frags()
1707 ieee80211_purge_tx_queue(&local->hw, in ieee80211_tx_frags()
1715 * later transmission from the tx-pending in ieee80211_tx_frags()
1720 &local->pending[q]); in ieee80211_tx_frags()
1723 &local->pending[q]); in ieee80211_tx_frags()
1725 spin_unlock_irqrestore(&local->queue_stop_reason_lock, in ieee80211_tx_frags()
1730 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_tx_frags()
1732 info->control.vif = vif; in ieee80211_tx_frags()
1733 control.sta = sta ? &sta->sta : NULL; in ieee80211_tx_frags()
1760 sdata = vif_to_sdata(info->control.vif); in __ieee80211_tx()
1761 if (sta && !sta->uploaded) in __ieee80211_tx()
1764 switch (sdata->vif.type) { in __ieee80211_tx()
1766 if ((sdata->u.mntr.flags & MONITOR_FLAG_ACTIVE) || in __ieee80211_tx()
1767 ieee80211_hw_check(&local->hw, NO_VIRTUAL_MONITOR)) { in __ieee80211_tx()
1768 vif = &sdata->vif; in __ieee80211_tx()
1771 sdata = rcu_dereference(local->monitor_sdata); in __ieee80211_tx()
1772 if (sdata && ieee80211_hw_check(&local->hw, WANT_MONITOR_VIF)) { in __ieee80211_tx()
1773 vif = &sdata->vif; in __ieee80211_tx()
1774 info->hw_queue = in __ieee80211_tx()
1775 vif->hw_queue[skb_get_queue_mapping(skb)]; in __ieee80211_tx()
1776 } else if (ieee80211_hw_check(&local->hw, QUEUE_CONTROL)) { in __ieee80211_tx()
1777 ieee80211_purge_tx_queue(&local->hw, skbs); in __ieee80211_tx()
1783 sdata = container_of(sdata->bss, in __ieee80211_tx()
1787 vif = &sdata->vif; in __ieee80211_tx()
1799 * Invoke TX handlers, return 0 on success and non-zero if the
1825 I802_DEBUG_INC(tx->local->tx_handlers_drop); in invoke_tx_handlers_early()
1826 if (tx->skb) in invoke_tx_handlers_early()
1827 ieee80211_free_txskb(&tx->local->hw, tx->skb); in invoke_tx_handlers_early()
1829 ieee80211_purge_tx_queue(&tx->local->hw, &tx->skbs); in invoke_tx_handlers_early()
1830 return -1; in invoke_tx_handlers_early()
1832 I802_DEBUG_INC(tx->local->tx_handlers_queued); in invoke_tx_handlers_early()
1833 return -1; in invoke_tx_handlers_early()
1845 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); in invoke_tx_handlers_late()
1848 if (!ieee80211_hw_check(&tx->local->hw, HAS_RATE_CONTROL)) in invoke_tx_handlers_late()
1851 if (unlikely(info->flags & IEEE80211_TX_INTFL_RETRANSMISSION)) { in invoke_tx_handlers_late()
1852 __skb_queue_tail(&tx->skbs, tx->skb); in invoke_tx_handlers_late()
1853 tx->skb = NULL; in invoke_tx_handlers_late()
1863 if (!ieee80211_hw_check(&tx->local->hw, HAS_RATE_CONTROL)) in invoke_tx_handlers_late()
1869 I802_DEBUG_INC(tx->local->tx_handlers_drop); in invoke_tx_handlers_late()
1870 if (tx->skb) in invoke_tx_handlers_late()
1871 ieee80211_free_txskb(&tx->local->hw, tx->skb); in invoke_tx_handlers_late()
1873 ieee80211_purge_tx_queue(&tx->local->hw, &tx->skbs); in invoke_tx_handlers_late()
1874 return -1; in invoke_tx_handlers_late()
1876 I802_DEBUG_INC(tx->local->tx_handlers_queued); in invoke_tx_handlers_late()
1877 return -1; in invoke_tx_handlers_late()
1904 info->band = band; in ieee80211_tx_prepare_skb()
1905 info->control.vif = vif; in ieee80211_tx_prepare_skb()
1906 info->hw_queue = vif->hw_queue[skb_get_queue_mapping(skb)]; in ieee80211_tx_prepare_skb()
1913 *sta = &tx.sta->sta; in ieee80211_tx_prepare_skb()
1937 struct ieee80211_local *local = sdata->local; in ieee80211_tx()
1943 if (unlikely(skb->len < 10)) { in ieee80211_tx()
1952 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx()
1959 if (!(info->flags & IEEE80211_TX_CTL_TX_OFFCHAN) || in ieee80211_tx()
1960 !ieee80211_hw_check(&local->hw, QUEUE_CONTROL)) in ieee80211_tx()
1961 info->hw_queue = in ieee80211_tx()
1962 sdata->vif.hw_queue[skb_get_queue_mapping(skb)]; in ieee80211_tx()
1989 struct ieee80211_local *local = sdata->local; in ieee80211_skb_resize()
1995 sdata->crypto_tx_tailroom_needed_cnt); in ieee80211_skb_resize()
1999 tail_need -= skb_tailroom(skb); in ieee80211_skb_resize()
2004 (!ieee80211_hw_check(&local->hw, SUPPORTS_CLONED_SKBS) || in ieee80211_skb_resize()
2006 I802_DEBUG_INC(local->tx_expand_skb_head_cloned); in ieee80211_skb_resize()
2008 I802_DEBUG_INC(local->tx_expand_skb_head); in ieee80211_skb_resize()
2013 wiphy_debug(local->hw.wiphy, in ieee80211_skb_resize()
2015 return -ENOMEM; in ieee80211_skb_resize()
2024 struct ieee80211_local *local = sdata->local; in ieee80211_xmit()
2026 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; in ieee80211_xmit()
2030 if (info->flags & IEEE80211_TX_INTFL_DONT_ENCRYPT) in ieee80211_xmit()
2032 else if (ieee80211_is_mgmt(hdr->frame_control)) in ieee80211_xmit()
2037 headroom = local->tx_headroom; in ieee80211_xmit()
2040 headroom -= skb_headroom(skb); in ieee80211_xmit()
2044 ieee80211_free_txskb(&local->hw, skb); in ieee80211_xmit()
2049 hdr = (struct ieee80211_hdr *) skb->data; in ieee80211_xmit()
2050 info->control.vif = &sdata->vif; in ieee80211_xmit()
2052 if (ieee80211_vif_is_mesh(&sdata->vif)) { in ieee80211_xmit()
2053 if (ieee80211_is_data(hdr->frame_control) && in ieee80211_xmit()
2054 is_unicast_ether_addr(hdr->addr1)) { in ieee80211_xmit()
2069 (struct ieee80211_radiotap_header *)skb->data; in ieee80211_validate_radiotap_len()
2072 if (unlikely(skb->len < sizeof(struct ieee80211_radiotap_header))) in ieee80211_validate_radiotap_len()
2076 if (unlikely(rthdr->it_version)) in ieee80211_validate_radiotap_len()
2080 if (unlikely(skb->len < ieee80211_get_radiotap_len(skb->data))) in ieee80211_validate_radiotap_len()
2089 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); in ieee80211_parse_tx_radiotap()
2092 (struct ieee80211_radiotap_header *) skb->data; in ieee80211_parse_tx_radiotap()
2094 int ret = ieee80211_radiotap_iterator_init(&iterator, rthdr, skb->len, in ieee80211_parse_tx_radiotap()
2109 info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT | in ieee80211_parse_tx_radiotap()
2114 * (ieee80211_radiotap_iterator_next returns -ENOENT when no more in ieee80211_parse_tx_radiotap()
2115 * entries present, or -EINVAL on error) in ieee80211_parse_tx_radiotap()
2136 * handed has the 32-bit FCS CRC at the end... in ieee80211_parse_tx_radiotap()
2141 if (skb->len < (iterator._max_length + FCS_LEN)) in ieee80211_parse_tx_radiotap()
2144 skb_trim(skb, skb->len - FCS_LEN); in ieee80211_parse_tx_radiotap()
2147 info->flags &= ~IEEE80211_TX_INTFL_DONT_ENCRYPT; in ieee80211_parse_tx_radiotap()
2149 info->flags &= ~IEEE80211_TX_CTL_DONTFRAG; in ieee80211_parse_tx_radiotap()
2155 info->flags |= IEEE80211_TX_CTL_NO_ACK; in ieee80211_parse_tx_radiotap()
2157 info->control.flags |= IEEE80211_TX_CTRL_NO_SEQNO; in ieee80211_parse_tx_radiotap()
2159 info->control.flags |= in ieee80211_parse_tx_radiotap()
2171 info->control.antennas |= BIT(*iterator.this_arg); in ieee80211_parse_tx_radiotap()
2199 info->flags |= IEEE80211_TX_CTL_LDPC; in ieee80211_parse_tx_radiotap()
2205 info->flags |= in ieee80211_parse_tx_radiotap()
2243 * Documentation/networking/mac80211-injection.rst in ieee80211_parse_tx_radiotap()
2252 if (ret != -ENOENT) /* ie, if we didn't simply run out of fields */ in ieee80211_parse_tx_radiotap()
2257 local->hw.wiphy->bands[info->band]; in ieee80211_parse_tx_radiotap()
2259 info->control.flags |= IEEE80211_TX_CTRL_RATE_INJECT; in ieee80211_parse_tx_radiotap()
2262 info->control.rates[i].idx = -1; in ieee80211_parse_tx_radiotap()
2263 info->control.rates[i].flags = 0; in ieee80211_parse_tx_radiotap()
2264 info->control.rates[i].count = 0; in ieee80211_parse_tx_radiotap()
2270 hweight8(info->control.antennas)) in ieee80211_parse_tx_radiotap()
2271 info->control.antennas = 0; in ieee80211_parse_tx_radiotap()
2273 info->control.rates[0].idx = rate; in ieee80211_parse_tx_radiotap()
2276 if (vht_nss > hweight8(info->control.antennas)) in ieee80211_parse_tx_radiotap()
2277 info->control.antennas = 0; in ieee80211_parse_tx_radiotap()
2279 ieee80211_rate_set_vht(info->control.rates, vht_mcs, in ieee80211_parse_tx_radiotap()
2282 for (i = 0; i < sband->n_bitrates; i++) { in ieee80211_parse_tx_radiotap()
2283 if (rate * 5 != sband->bitrates[i].bitrate) in ieee80211_parse_tx_radiotap()
2286 info->control.rates[0].idx = i; in ieee80211_parse_tx_radiotap()
2291 if (info->control.rates[0].idx < 0) in ieee80211_parse_tx_radiotap()
2292 info->control.flags &= ~IEEE80211_TX_CTRL_RATE_INJECT; in ieee80211_parse_tx_radiotap()
2294 info->control.rates[0].flags = rate_flags; in ieee80211_parse_tx_radiotap()
2295 info->control.rates[0].count = min_t(u8, rate_retries + 1, in ieee80211_parse_tx_radiotap()
2296 local->hw.max_rate_tries); in ieee80211_parse_tx_radiotap()
2305 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); in ieee80211_monitor_start_xmit()
2319 info->flags = IEEE80211_TX_CTL_REQ_TX_STATUS | in ieee80211_monitor_start_xmit()
2322 /* Sanity-check the length of the radiotap header */ in ieee80211_monitor_start_xmit()
2327 len_rthdr = ieee80211_get_radiotap_len(skb->data); in ieee80211_monitor_start_xmit()
2343 if (skb->len < len_rthdr + 2) in ieee80211_monitor_start_xmit()
2346 hdr = (struct ieee80211_hdr *)(skb->data + len_rthdr); in ieee80211_monitor_start_xmit()
2347 hdrlen = ieee80211_hdrlen(hdr->frame_control); in ieee80211_monitor_start_xmit()
2349 if (skb->len < len_rthdr + hdrlen) in ieee80211_monitor_start_xmit()
2353 * Initialize skb->protocol if the injected frame is a data frame in ieee80211_monitor_start_xmit()
2356 if (ieee80211_is_data(hdr->frame_control) && in ieee80211_monitor_start_xmit()
2357 skb->len >= len_rthdr + hdrlen + sizeof(rfc1042_header) + 2) { in ieee80211_monitor_start_xmit()
2361 skb->protocol = cpu_to_be16((payload[6] << 8) | in ieee80211_monitor_start_xmit()
2362 payload[7]); in ieee80211_monitor_start_xmit()
2369 * we handle as though they are non-injected frames. in ieee80211_monitor_start_xmit()
2372 * VLAN support we have an nl80211-based mechanism. in ieee80211_monitor_start_xmit()
2375 * don't use nl80211-based management TX/RX. in ieee80211_monitor_start_xmit()
2377 list_for_each_entry_rcu(tmp_sdata, &local->interfaces, list) { in ieee80211_monitor_start_xmit()
2380 if (tmp_sdata->vif.type == NL80211_IFTYPE_MONITOR || in ieee80211_monitor_start_xmit()
2381 tmp_sdata->vif.type == NL80211_IFTYPE_AP_VLAN) in ieee80211_monitor_start_xmit()
2383 if (ether_addr_equal(tmp_sdata->vif.addr, hdr->addr2)) { in ieee80211_monitor_start_xmit()
2389 chanctx_conf = rcu_dereference(sdata->vif.bss_conf.chanctx_conf); in ieee80211_monitor_start_xmit()
2391 tmp_sdata = rcu_dereference(local->monitor_sdata); in ieee80211_monitor_start_xmit()
2394 rcu_dereference(tmp_sdata->vif.bss_conf.chanctx_conf); in ieee80211_monitor_start_xmit()
2398 chandef = &chanctx_conf->def; in ieee80211_monitor_start_xmit()
2406 if (!cfg80211_chandef_usable(local->hw.wiphy, chandef, in ieee80211_monitor_start_xmit()
2426 if (!cfg80211_reg_can_beacon(local->hw.wiphy, chandef, in ieee80211_monitor_start_xmit()
2427 sdata->vif.type)) in ieee80211_monitor_start_xmit()
2430 info->band = chandef->chan->band; in ieee80211_monitor_start_xmit()
2432 /* Initialize skb->priority according to frame type and TID class, in ieee80211_monitor_start_xmit()
2435 * skb-priority is preserved to assure frames injected with this in ieee80211_monitor_start_xmit()
2439 skb_set_queue_mapping(skb, ieee80211_ac_from_tid(skb->priority)); in ieee80211_monitor_start_xmit()
2466 u16 ethertype = (skb->data[12] << 8) | skb->data[13]; in ieee80211_is_tdls_setup()
2469 skb->len > 14 && in ieee80211_is_tdls_setup()
2470 skb->data[14] == WLAN_TDLS_SNAP_RFTYPE; in ieee80211_is_tdls_setup()
2479 switch (sdata->vif.type) { in ieee80211_lookup_ra_sta()
2481 sta = rcu_dereference(sdata->u.vlan.sta); in ieee80211_lookup_ra_sta()
2485 } else if (sdata->wdev.use_4addr) { in ieee80211_lookup_ra_sta()
2486 return -ENOLINK; in ieee80211_lookup_ra_sta()
2492 if (is_multicast_ether_addr(skb->data)) { in ieee80211_lookup_ra_sta()
2493 *sta_out = ERR_PTR(-ENOENT); in ieee80211_lookup_ra_sta()
2496 sta = sta_info_get_bss(sdata, skb->data); in ieee80211_lookup_ra_sta()
2505 if (sdata->wdev.wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS) { in ieee80211_lookup_ra_sta()
2506 sta = sta_info_get(sdata, skb->data); in ieee80211_lookup_ra_sta()
2515 * TDLS link during setup - throw out frames to in ieee80211_lookup_ra_sta()
2516 * peer. Allow TDLS-setup frames to unauthorized in ieee80211_lookup_ra_sta()
2522 return -EINVAL; in ieee80211_lookup_ra_sta()
2527 sta = sta_info_get(sdata, sdata->vif.cfg.ap_addr); in ieee80211_lookup_ra_sta()
2529 return -ENOLINK; in ieee80211_lookup_ra_sta()
2532 return -EINVAL; in ieee80211_lookup_ra_sta()
2535 *sta_out = sta ?: ERR_PTR(-ENOENT); in ieee80211_lookup_ra_sta()
2547 if (skb->sk) in ieee80211_store_ack_skb()
2556 spin_lock_irqsave(&local->ack_status_lock, flags); in ieee80211_store_ack_skb()
2557 id = idr_alloc(&local->ack_status_frames, ack_skb, in ieee80211_store_ack_skb()
2559 spin_unlock_irqrestore(&local->ack_status_lock, flags); in ieee80211_store_ack_skb()
2566 IEEE80211_SKB_CB(ack_skb)->ack.cookie = *cookie; in ieee80211_store_ack_skb()
2577 * ieee80211_build_hdr - build 802.11 header in the given frame
2590 * potential unsharing of the SKB - this needs to be interleaved with the
2593 * The function requires the read-side RCU lock held
2602 struct ieee80211_local *local = sdata->local; in ieee80211_build_hdr()
2625 if (local->force_tx_status) in ieee80211_build_hdr()
2631 ethertype = (skb->data[12] << 8) | skb->data[13]; in ieee80211_build_hdr()
2634 if (!ieee80211_vif_is_mld(&sdata->vif)) in ieee80211_build_hdr()
2636 rcu_dereference(sdata->vif.bss_conf.chanctx_conf); in ieee80211_build_hdr()
2638 switch (sdata->vif.type) { in ieee80211_build_hdr()
2640 if (sdata->wdev.use_4addr) { in ieee80211_build_hdr()
2643 memcpy(hdr.addr1, sta->sta.addr, ETH_ALEN); in ieee80211_build_hdr()
2644 memcpy(hdr.addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_build_hdr()
2645 memcpy(hdr.addr3, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2646 memcpy(hdr.addr4, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2649 wme_sta = sta->sta.wme; in ieee80211_build_hdr()
2651 if (!ieee80211_vif_is_mld(&sdata->vif)) { in ieee80211_build_hdr()
2655 ap_sdata = container_of(sdata->bss, in ieee80211_build_hdr()
2659 rcu_dereference(ap_sdata->vif.bss_conf.chanctx_conf); in ieee80211_build_hdr()
2661 if (sdata->wdev.use_4addr) in ieee80211_build_hdr()
2667 memcpy(hdr.addr1, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2669 if (ieee80211_vif_is_mld(&sdata->vif) && sta && !sta->sta.mlo) { in ieee80211_build_hdr()
2672 link_id = sta->deflink.link_id; in ieee80211_build_hdr()
2673 link = rcu_dereference(sdata->link[link_id]); in ieee80211_build_hdr()
2675 ret = -ENOLINK; in ieee80211_build_hdr()
2678 memcpy(hdr.addr2, link->conf->addr, ETH_ALEN); in ieee80211_build_hdr()
2680 (sta && sta->sta.mlo)) { in ieee80211_build_hdr()
2681 memcpy(hdr.addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_build_hdr()
2685 conf = rcu_dereference(sdata->vif.link_conf[link_id]); in ieee80211_build_hdr()
2687 ret = -ENOLINK; in ieee80211_build_hdr()
2691 memcpy(hdr.addr2, conf->addr, ETH_ALEN); in ieee80211_build_hdr()
2694 memcpy(hdr.addr3, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2699 if (!is_multicast_ether_addr(skb->data)) { in ieee80211_build_hdr()
2703 mpath = mesh_path_lookup(sdata, skb->data); in ieee80211_build_hdr()
2706 next_hop = rcu_dereference(mpath->next_hop); in ieee80211_build_hdr()
2708 !(mpath->flags & (MESH_PATH_ACTIVE | in ieee80211_build_hdr()
2714 mppath = mpp_path_lookup(sdata, skb->data); in ieee80211_build_hdr()
2716 mppath->exp_time = jiffies; in ieee80211_build_hdr()
2720 mesh_path_del(sdata, mpath->dst); in ieee80211_build_hdr()
2729 if (ether_addr_equal(sdata->vif.addr, skb->data + ETH_ALEN) && in ieee80211_build_hdr()
2730 !(mppath && !ether_addr_equal(mppath->mpp, skb->data))) { in ieee80211_build_hdr()
2732 skb->data, skb->data + ETH_ALEN); in ieee80211_build_hdr()
2736 /* DS -> MBSS (802.11-2012 13.11.3.3). in ieee80211_build_hdr()
2742 const u8 *mesh_da = skb->data; in ieee80211_build_hdr()
2745 mesh_da = mppath->mpp; in ieee80211_build_hdr()
2747 mesh_da = mpath->dst; in ieee80211_build_hdr()
2750 mesh_da, sdata->vif.addr); in ieee80211_build_hdr()
2755 skb->data + ETH_ALEN, NULL); in ieee80211_build_hdr()
2759 sdata, &mesh_hdr, skb->data, in ieee80211_build_hdr()
2760 skb->data + ETH_ALEN); in ieee80211_build_hdr()
2769 memcpy(hdr.addr1, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2782 memcpy(hdr.addr1, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2783 memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2784 link = rcu_dereference(sdata->link[tdls_link_id]); in ieee80211_build_hdr()
2786 ret = -EINVAL; in ieee80211_build_hdr()
2789 memcpy(hdr.addr3, link->u.mgd.bssid, ETH_ALEN); in ieee80211_build_hdr()
2791 } else if (sdata->u.mgd.use_4addr && in ieee80211_build_hdr()
2792 cpu_to_be16(ethertype) != sdata->control_port_protocol) { in ieee80211_build_hdr()
2796 memcpy(hdr.addr1, sdata->deflink.u.mgd.bssid, ETH_ALEN); in ieee80211_build_hdr()
2797 memcpy(hdr.addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_build_hdr()
2798 memcpy(hdr.addr3, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2799 memcpy(hdr.addr4, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2804 memcpy(hdr.addr1, sdata->vif.cfg.ap_addr, ETH_ALEN); in ieee80211_build_hdr()
2805 memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2806 memcpy(hdr.addr3, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2812 memcpy(hdr.addr1, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2813 memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2819 memcpy(hdr.addr1, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2820 memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2821 memcpy(hdr.addr3, sdata->u.ibss.bssid, ETH_ALEN); in ieee80211_build_hdr()
2825 ret = -EINVAL; in ieee80211_build_hdr()
2830 if (!ieee80211_vif_is_mld(&sdata->vif)) { in ieee80211_build_hdr()
2831 ret = -ENOTCONN; in ieee80211_build_hdr()
2837 band = chanctx_conf->def.chan->band; in ieee80211_build_hdr()
2845 wme_sta = sta->sta.wme; in ieee80211_build_hdr()
2846 } else if (ieee80211_vif_is_mesh(&sdata->vif)) { in ieee80211_build_hdr()
2861 if (unlikely(!ieee80211_vif_is_mesh(&sdata->vif) && in ieee80211_build_hdr()
2862 (sdata->vif.type != NL80211_IFTYPE_OCB) && in ieee80211_build_hdr()
2864 (cpu_to_be16(ethertype) != sdata->control_port_protocol || in ieee80211_build_hdr()
2865 !ieee80211_is_our_addr(sdata, skb->data + ETH_ALEN, NULL)))) { in ieee80211_build_hdr()
2868 sdata->name, hdr.addr1); in ieee80211_build_hdr()
2871 I802_DEBUG_INC(local->tx_handlers_drop_unauth_port); in ieee80211_build_hdr()
2873 ret = -EPERM; in ieee80211_build_hdr()
2878 ((skb->sk && in ieee80211_build_hdr()
2879 skb_shinfo(skb)->tx_flags & SKBTX_WIFI_STATUS) || in ieee80211_build_hdr()
2889 ret = -ENOMEM; in ieee80211_build_hdr()
2901 skip_header_bytes -= 2; in ieee80211_build_hdr()
2905 skip_header_bytes -= 2; in ieee80211_build_hdr()
2912 head_need = hdrlen + encaps_len + meshhdrlen - skb_headroom(skb); in ieee80211_build_hdr()
2928 head_need += local->tx_headroom; in ieee80211_build_hdr()
2931 ieee80211_free_txskb(&local->hw, skb); in ieee80211_build_hdr()
2933 return ERR_PTR(-ENOMEM); in ieee80211_build_hdr()
2949 memcpy(skb_push(skb, hdrlen - 2), &hdr, hdrlen - 2); in ieee80211_build_hdr()
2963 info->flags = info_flags; in ieee80211_build_hdr()
2965 info->status_data = info_id; in ieee80211_build_hdr()
2966 info->status_data_idr = 1; in ieee80211_build_hdr()
2968 info->band = band; in ieee80211_build_hdr()
2989 sdata->name, hdr.addr1, in ieee80211_build_hdr()
2992 ret = -EINVAL; in ieee80211_build_hdr()
2997 info->control.flags = ctrl_flags; in ieee80211_build_hdr()
3006 * fast-xmit overview
3008 * The core idea of this fast-xmit is to remove per-packet checks by checking
3009 * them out of band. ieee80211_check_fast_xmit() implements the out-of-band
3010 * checks that are needed to get the sta->fast_tx pointer assigned, after which
3015 * Once assigned, the fast_tx data structure also caches the per-packet 802.11
3021 * since the per-packet code no longer checks the conditions. This is reflected
3029 struct ieee80211_local *local = sta->local; in ieee80211_check_fast_xmit()
3030 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_check_fast_xmit()
3035 if (!ieee80211_hw_check(&local->hw, SUPPORT_FAST_XMIT)) in ieee80211_check_fast_xmit()
3038 if (ieee80211_vif_is_mesh(&sdata->vif)) in ieee80211_check_fast_xmit()
3049 * key and the fast-tx assignment are done atomically, so the CPU that in ieee80211_check_fast_xmit()
3053 spin_lock_bh(&sta->lock); in ieee80211_check_fast_xmit()
3054 if (ieee80211_hw_check(&local->hw, SUPPORTS_PS) && in ieee80211_check_fast_xmit()
3055 !ieee80211_hw_check(&local->hw, SUPPORTS_DYNAMIC_PS) && in ieee80211_check_fast_xmit()
3056 sdata->vif.type == NL80211_IFTYPE_STATION) in ieee80211_check_fast_xmit()
3059 if (!test_sta_flag(sta, WLAN_STA_AUTHORIZED) || !sta->uploaded) in ieee80211_check_fast_xmit()
3068 if (sdata->noack_map) in ieee80211_check_fast_xmit()
3071 /* fast-xmit doesn't handle fragmentation at all */ in ieee80211_check_fast_xmit()
3072 if (local->hw.wiphy->frag_threshold != (u32)-1 && in ieee80211_check_fast_xmit()
3073 !ieee80211_hw_check(&local->hw, SUPPORTS_TX_FRAG)) in ieee80211_check_fast_xmit()
3076 if (!ieee80211_vif_is_mld(&sdata->vif)) { in ieee80211_check_fast_xmit()
3079 rcu_dereference(sdata->vif.bss_conf.chanctx_conf); in ieee80211_check_fast_xmit()
3084 build.band = chanctx_conf->def.chan->band; in ieee80211_check_fast_xmit()
3093 switch (sdata->vif.type) { in ieee80211_check_fast_xmit()
3098 memcpy(hdr->addr3, sdata->u.ibss.bssid, ETH_ALEN); in ieee80211_check_fast_xmit()
3111 link = rcu_dereference(sdata->link[tdls_link_id]); in ieee80211_check_fast_xmit()
3113 memcpy(hdr->addr3, link->u.mgd.bssid, ETH_ALEN); in ieee80211_check_fast_xmit()
3119 if (sdata->u.mgd.use_4addr) { in ieee80211_check_fast_xmit()
3120 /* non-regular ethertype cannot use the fastpath */ in ieee80211_check_fast_xmit()
3124 memcpy(hdr->addr1, sdata->deflink.u.mgd.bssid, ETH_ALEN); in ieee80211_check_fast_xmit()
3125 memcpy(hdr->addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_check_fast_xmit()
3133 memcpy(hdr->addr1, sdata->vif.cfg.ap_addr, ETH_ALEN); in ieee80211_check_fast_xmit()
3139 if (sdata->wdev.use_4addr) { in ieee80211_check_fast_xmit()
3143 memcpy(hdr->addr1, sta->sta.addr, ETH_ALEN); in ieee80211_check_fast_xmit()
3144 memcpy(hdr->addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_check_fast_xmit()
3155 if (sta->sta.mlo || !ieee80211_vif_is_mld(&sdata->vif)) { in ieee80211_check_fast_xmit()
3156 memcpy(hdr->addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_check_fast_xmit()
3158 unsigned int link_id = sta->deflink.link_id; in ieee80211_check_fast_xmit()
3162 link = rcu_dereference(sdata->link[link_id]); in ieee80211_check_fast_xmit()
3167 memcpy(hdr->addr2, link->conf->addr, ETH_ALEN); in ieee80211_check_fast_xmit()
3174 /* not handled on fast-xmit */ in ieee80211_check_fast_xmit()
3178 if (sta->sta.wme) { in ieee80211_check_fast_xmit()
3188 build.key = rcu_access_pointer(sta->ptk[sta->ptk_idx]); in ieee80211_check_fast_xmit()
3190 build.key = rcu_access_pointer(sdata->default_unicast_key); in ieee80211_check_fast_xmit()
3194 gen_iv = build.key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV; in ieee80211_check_fast_xmit()
3195 iv_spc = build.key->conf.flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE; in ieee80211_check_fast_xmit()
3196 mmic = build.key->conf.flags & in ieee80211_check_fast_xmit()
3201 if (!(build.key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) in ieee80211_check_fast_xmit()
3205 if (build.key->flags & KEY_FLAG_TAINTED) in ieee80211_check_fast_xmit()
3208 switch (build.key->conf.cipher) { in ieee80211_check_fast_xmit()
3224 /* cannot handle MMIC or IV generation in xmit-fast */ in ieee80211_check_fast_xmit()
3232 /* cannot handle IV generation in fast-xmit */ in ieee80211_check_fast_xmit()
3244 build.key->conf.cipher); in ieee80211_check_fast_xmit()
3255 hdr->frame_control = fc; in ieee80211_check_fast_xmit()
3266 old = rcu_dereference_protected(sta->fast_tx, in ieee80211_check_fast_xmit()
3267 lockdep_is_held(&sta->lock)); in ieee80211_check_fast_xmit()
3268 rcu_assign_pointer(sta->fast_tx, fast_tx); in ieee80211_check_fast_xmit()
3271 spin_unlock_bh(&sta->lock); in ieee80211_check_fast_xmit()
3279 list_for_each_entry_rcu(sta, &local->sta_list, list) in ieee80211_check_fast_xmit_all()
3286 struct ieee80211_local *local = sdata->local; in ieee80211_check_fast_xmit_iface()
3291 list_for_each_entry_rcu(sta, &local->sta_list, list) { in ieee80211_check_fast_xmit_iface()
3292 if (sdata != sta->sdata && in ieee80211_check_fast_xmit_iface()
3293 (!sta->sdata->bss || sta->sdata->bss != sdata->bss)) in ieee80211_check_fast_xmit_iface()
3305 spin_lock_bh(&sta->lock); in ieee80211_clear_fast_xmit()
3306 fast_tx = rcu_dereference_protected(sta->fast_tx, in ieee80211_clear_fast_xmit()
3307 lockdep_is_held(&sta->lock)); in ieee80211_clear_fast_xmit()
3308 RCU_INIT_POINTER(sta->fast_tx, NULL); in ieee80211_clear_fast_xmit()
3309 spin_unlock_bh(&sta->lock); in ieee80211_clear_fast_xmit()
3319 I802_DEBUG_INC(local->tx_expand_skb_head); in ieee80211_amsdu_realloc_pad()
3322 wiphy_debug(local->hw.wiphy, in ieee80211_amsdu_realloc_pad()
3335 struct ieee80211_local *local = sdata->local; in ieee80211_amsdu_prepare_head()
3339 int hdr_len = fast_tx->hdr_len - sizeof(rfc1042_header); in ieee80211_amsdu_prepare_head()
3340 int subframe_len = skb->len - hdr_len; in ieee80211_amsdu_prepare_head()
3345 if (info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE) in ieee80211_amsdu_prepare_head()
3348 if (info->control.flags & IEEE80211_TX_CTRL_AMSDU) in ieee80211_amsdu_prepare_head()
3353 local->hw.extra_tx_headroom)) in ieee80211_amsdu_prepare_head()
3361 h_80211_src = data + fast_tx->sa_offs; in ieee80211_amsdu_prepare_head()
3362 h_80211_dst = data + fast_tx->da_offs; in ieee80211_amsdu_prepare_head()
3364 amsdu_hdr->h_proto = cpu_to_be16(subframe_len); in ieee80211_amsdu_prepare_head()
3365 ether_addr_copy(amsdu_hdr->h_source, h_80211_src); in ieee80211_amsdu_prepare_head()
3366 ether_addr_copy(amsdu_hdr->h_dest, h_80211_dst); in ieee80211_amsdu_prepare_head()
3368 /* according to IEEE 802.11-2012 8.3.2 table 8-19, the outer SA/DA in ieee80211_amsdu_prepare_head()
3369 * fields needs to be changed to BSSID for A-MSDU frames depending in ieee80211_amsdu_prepare_head()
3372 switch (sdata->vif.type) { in ieee80211_amsdu_prepare_head()
3374 bssid = sdata->vif.cfg.ap_addr; in ieee80211_amsdu_prepare_head()
3378 bssid = sdata->vif.addr; in ieee80211_amsdu_prepare_head()
3384 if (bssid && ieee80211_has_fromds(hdr->frame_control)) in ieee80211_amsdu_prepare_head()
3387 if (bssid && ieee80211_has_tods(hdr->frame_control)) in ieee80211_amsdu_prepare_head()
3393 info->control.flags |= IEEE80211_TX_CTRL_AMSDU; in ieee80211_amsdu_prepare_head()
3404 struct ieee80211_local *local = sdata->local; in ieee80211_amsdu_aggregate()
3405 struct fq *fq = &local->fq; in ieee80211_amsdu_aggregate()
3408 u8 tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; in ieee80211_amsdu_aggregate()
3409 struct ieee80211_txq *txq = sta->sta.txq[tid]; in ieee80211_amsdu_aggregate()
3412 int subframe_len = skb->len - ETH_ALEN; in ieee80211_amsdu_aggregate()
3413 u8 max_subframes = sta->sta.max_amsdu_subframes; in ieee80211_amsdu_aggregate()
3414 int max_frags = local->hw.max_tx_fragments; in ieee80211_amsdu_aggregate()
3415 int max_amsdu_len = sta->sta.cur->max_amsdu_len; in ieee80211_amsdu_aggregate()
3425 if (!ieee80211_hw_check(&local->hw, TX_AMSDU)) in ieee80211_amsdu_aggregate()
3428 if (sdata->vif.offload_flags & IEEE80211_OFFLOAD_ENCAP_ENABLED) in ieee80211_amsdu_aggregate()
3431 if (ieee80211_vif_is_mesh(&sdata->vif)) in ieee80211_amsdu_aggregate()
3441 if (test_bit(IEEE80211_TXQ_NO_AMSDU, &txqi->flags)) in ieee80211_amsdu_aggregate()
3444 if (sta->sta.cur->max_rc_amsdu_len) in ieee80211_amsdu_aggregate()
3446 sta->sta.cur->max_rc_amsdu_len); in ieee80211_amsdu_aggregate()
3448 if (sta->sta.cur->max_tid_amsdu_len[tid]) in ieee80211_amsdu_aggregate()
3450 sta->sta.cur->max_tid_amsdu_len[tid]); in ieee80211_amsdu_aggregate()
3454 spin_lock_bh(&fq->lock); in ieee80211_amsdu_aggregate()
3460 tin = &txqi->tin; in ieee80211_amsdu_aggregate()
3462 head = skb_peek_tail(&flow->queue); in ieee80211_amsdu_aggregate()
3466 orig_truesize = head->truesize; in ieee80211_amsdu_aggregate()
3467 orig_len = head->len; in ieee80211_amsdu_aggregate()
3469 if (skb->len + head->len > max_amsdu_len) in ieee80211_amsdu_aggregate()
3472 nfrags = 1 + skb_shinfo(skb)->nr_frags; in ieee80211_amsdu_aggregate()
3473 nfrags += 1 + skb_shinfo(head)->nr_frags; in ieee80211_amsdu_aggregate()
3474 frag_tail = &skb_shinfo(head)->frag_list; in ieee80211_amsdu_aggregate()
3476 nfrags += 1 + skb_shinfo(*frag_tail)->nr_frags; in ieee80211_amsdu_aggregate()
3477 frag_tail = &(*frag_tail)->next; in ieee80211_amsdu_aggregate()
3494 * and frag_tail should be &skb_shinfo(head)->frag_list. in ieee80211_amsdu_aggregate()
3499 frag_tail = &skb_shinfo(head)->frag_list; in ieee80211_amsdu_aggregate()
3503 * padding to the next one, that's being added. Note that head->len in ieee80211_amsdu_aggregate()
3504 * is the length of the full A-MSDU, but that works since each time in ieee80211_amsdu_aggregate()
3508 hdrlen = fast_tx->hdr_len - sizeof(rfc1042_header); in ieee80211_amsdu_aggregate()
3509 if ((head->len - hdrlen) & 3) in ieee80211_amsdu_aggregate()
3510 pad = 4 - ((head->len - hdrlen) & 3); in ieee80211_amsdu_aggregate()
3528 head->len += skb->len; in ieee80211_amsdu_aggregate()
3529 head->data_len += skb->len; in ieee80211_amsdu_aggregate()
3533 fq->memory_usage += head->truesize - orig_truesize; in ieee80211_amsdu_aggregate()
3534 if (head->len != orig_len) { in ieee80211_amsdu_aggregate()
3535 flow->backlog += head->len - orig_len; in ieee80211_amsdu_aggregate()
3536 tin->backlog_bytes += head->len - orig_len; in ieee80211_amsdu_aggregate()
3539 spin_unlock_bh(&fq->lock); in ieee80211_amsdu_aggregate()
3554 struct sk_buff *skb = tx->skb; in ieee80211_xmit_fast_finish()
3556 struct ieee80211_hdr *hdr = (void *)skb->data; in ieee80211_xmit_fast_finish()
3559 if (!ieee80211_hw_check(&tx->local->hw, HAS_RATE_CONTROL) && in ieee80211_xmit_fast_finish()
3564 info->control.hw_key = &key->conf; in ieee80211_xmit_fast_finish()
3566 dev_sw_netstats_tx_add(skb->dev, 1, skb->len); in ieee80211_xmit_fast_finish()
3568 if (hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) { in ieee80211_xmit_fast_finish()
3569 tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; in ieee80211_xmit_fast_finish()
3570 hdr->seq_ctrl = ieee80211_tx_next_seq(sta, tid); in ieee80211_xmit_fast_finish()
3572 info->flags |= IEEE80211_TX_CTL_ASSIGN_SEQ; in ieee80211_xmit_fast_finish()
3573 hdr->seq_ctrl = cpu_to_le16(sdata->sequence_number); in ieee80211_xmit_fast_finish()
3574 sdata->sequence_number += 0x10; in ieee80211_xmit_fast_finish()
3577 if (skb_shinfo(skb)->gso_size) in ieee80211_xmit_fast_finish()
3578 sta->deflink.tx_stats.msdu[tid] += in ieee80211_xmit_fast_finish()
3579 DIV_ROUND_UP(skb->len, skb_shinfo(skb)->gso_size); in ieee80211_xmit_fast_finish()
3581 sta->deflink.tx_stats.msdu[tid]++; in ieee80211_xmit_fast_finish()
3583 info->hw_queue = sdata->vif.hw_queue[skb_get_queue_mapping(skb)]; in ieee80211_xmit_fast_finish()
3588 sta->deflink.tx_stats.bytes[skb_get_queue_mapping(skb)] += skb->len; in ieee80211_xmit_fast_finish()
3589 sta->deflink.tx_stats.packets[skb_get_queue_mapping(skb)]++; in ieee80211_xmit_fast_finish()
3593 u8 *crypto_hdr = skb->data + pn_offs; in ieee80211_xmit_fast_finish()
3595 switch (key->conf.cipher) { in ieee80211_xmit_fast_finish()
3600 pn = atomic64_inc_return(&key->conf.tx_pn); in ieee80211_xmit_fast_finish()
3603 crypto_hdr[3] = 0x20 | (key->conf.keyidx << 6); in ieee80211_xmit_fast_finish()
3607 crypto_hdr[7] = pn >> 40; in ieee80211_xmit_fast_finish()
3618 if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN) in ieee80211_sdata_netdev_features()
3619 return sdata->vif.netdev_features; in ieee80211_sdata_netdev_features()
3621 if (!sdata->bss) in ieee80211_sdata_netdev_features()
3624 sdata = container_of(sdata->bss, struct ieee80211_sub_if_data, u.ap); in ieee80211_sdata_netdev_features()
3625 return sdata->vif.netdev_features; in ieee80211_sdata_netdev_features()
3647 if (skb->ip_summed == CHECKSUM_PARTIAL) { in ieee80211_tx_skb_fixup()
3650 if (skb->encapsulation) in ieee80211_tx_skb_fixup()
3673 struct ieee80211_local *local = sdata->local; in __ieee80211_xmit_fast()
3674 struct ieee80211_hdr *hdr = (void *)fast_tx->hdr; in __ieee80211_xmit_fast()
3678 int hw_headroom = sdata->local->hw.extra_tx_headroom; in __ieee80211_xmit_fast()
3679 int extra_head = fast_tx->hdr_len - (ETH_HLEN - 2); in __ieee80211_xmit_fast()
3685 if ((hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) && in __ieee80211_xmit_fast()
3689 /* will not be crypto-handled beyond what we do here, so use false in __ieee80211_xmit_fast()
3690 * as the may-encrypt argument for the resize to not account for in __ieee80211_xmit_fast()
3694 max_t(int, extra_head + hw_headroom - in __ieee80211_xmit_fast()
3700 memcpy(skb->data, fast_tx->hdr, fast_tx->hdr_len); in __ieee80211_xmit_fast()
3701 memcpy(skb->data + fast_tx->da_offs, da, ETH_ALEN); in __ieee80211_xmit_fast()
3702 memcpy(skb->data + fast_tx->sa_offs, sa, ETH_ALEN); in __ieee80211_xmit_fast()
3706 info->band = fast_tx->band; in __ieee80211_xmit_fast()
3707 info->control.vif = &sdata->vif; in __ieee80211_xmit_fast()
3708 info->flags = IEEE80211_TX_CTL_FIRST_FRAGMENT | in __ieee80211_xmit_fast()
3710 info->control.flags = IEEE80211_TX_CTRL_FAST_XMIT | in __ieee80211_xmit_fast()
3715 if (local->force_tx_status) in __ieee80211_xmit_fast()
3716 info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS; in __ieee80211_xmit_fast()
3719 if (hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) { in __ieee80211_xmit_fast()
3720 u8 tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; in __ieee80211_xmit_fast()
3731 tx.key = fast_tx->key; in __ieee80211_xmit_fast()
3737 r = ieee80211_xmit_fast_finish(sdata, sta, fast_tx->pn_offs, in __ieee80211_xmit_fast()
3738 fast_tx->key, &tx); in __ieee80211_xmit_fast()
3743 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) in __ieee80211_xmit_fast()
3744 sdata = container_of(sdata->bss, in __ieee80211_xmit_fast()
3748 ieee80211_tx_frags(local, &sdata->vif, sta, &tx.skbs, false); in __ieee80211_xmit_fast()
3760 u16 ethertype = (skb->data[12] << 8) | skb->data[13]; in ieee80211_xmit_fast()
3761 struct ieee80211_hdr *hdr = (void *)fast_tx->hdr; in ieee80211_xmit_fast()
3768 if (cpu_to_be16(ethertype) == sdata->control_port_protocol) in ieee80211_xmit_fast()
3776 if (skb->sk && skb_shinfo(skb)->tx_flags & SKBTX_WIFI_STATUS) in ieee80211_xmit_fast()
3779 if (hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) { in ieee80211_xmit_fast()
3780 tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; in ieee80211_xmit_fast()
3781 tid_tx = rcu_dereference(sta->ampdu_mlme.tid_tx[tid]); in ieee80211_xmit_fast()
3783 if (!test_bit(HT_AGG_STATE_OPERATIONAL, &tid_tx->state)) in ieee80211_xmit_fast()
3785 if (tid_tx->timeout) in ieee80211_xmit_fast()
3786 tid_tx->last_tx = jiffies; in ieee80211_xmit_fast()
3790 memcpy(ð, skb->data, ETH_HLEN - 2); in ieee80211_xmit_fast()
3813 struct fq *fq = &local->fq; in ieee80211_tx_dequeue()
3814 struct fq_tin *tin = &txqi->tin; in ieee80211_tx_dequeue()
3818 struct ieee80211_vif *vif = txq->vif; in ieee80211_tx_dequeue()
3819 int q = vif->hw_queue[txq->ac]; in ieee80211_tx_dequeue()
3829 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in ieee80211_tx_dequeue()
3830 q_stopped = local->queue_stop_reasons[q]; in ieee80211_tx_dequeue()
3831 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_tx_dequeue()
3835 set_bit(IEEE80211_TXQ_DIRTY, &txqi->flags); in ieee80211_tx_dequeue()
3839 spin_lock_bh(&fq->lock); in ieee80211_tx_dequeue()
3842 skb = __skb_dequeue(&txqi->frags); in ieee80211_tx_dequeue()
3844 if (!(IEEE80211_SKB_CB(skb)->control.flags & in ieee80211_tx_dequeue()
3847 IEEE80211_SKB_CB(skb)->control.flags &= in ieee80211_tx_dequeue()
3850 if (unlikely(test_bit(IEEE80211_TXQ_STOP, &txqi->flags))) in ieee80211_tx_dequeue()
3859 spin_unlock_bh(&fq->lock); in ieee80211_tx_dequeue()
3861 hdr = (struct ieee80211_hdr *)skb->data; in ieee80211_tx_dequeue()
3868 tx.sdata = vif_to_sdata(info->control.vif); in ieee80211_tx_dequeue()
3870 if (txq->sta) { in ieee80211_tx_dequeue()
3871 tx.sta = container_of(txq->sta, struct sta_info, sta); in ieee80211_tx_dequeue()
3876 if (unlikely(!(info->flags & IEEE80211_TX_CTL_INJECTED) && in ieee80211_tx_dequeue()
3877 ieee80211_is_data(hdr->frame_control) && in ieee80211_tx_dequeue()
3878 !ieee80211_vif_is_mesh(&tx.sdata->vif) && in ieee80211_tx_dequeue()
3879 tx.sdata->vif.type != NL80211_IFTYPE_OCB && in ieee80211_tx_dequeue()
3880 !is_multicast_ether_addr(hdr->addr1) && in ieee80211_tx_dequeue()
3882 (!(info->control.flags & in ieee80211_tx_dequeue()
3884 !ieee80211_is_our_addr(tx.sdata, hdr->addr2, in ieee80211_tx_dequeue()
3886 I802_DEBUG_INC(local->tx_handlers_drop_unauth_port); in ieee80211_tx_dequeue()
3887 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_dequeue()
3898 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_dequeue()
3902 if (test_bit(IEEE80211_TXQ_AMPDU, &txqi->flags)) in ieee80211_tx_dequeue()
3903 info->flags |= (IEEE80211_TX_CTL_AMPDU | in ieee80211_tx_dequeue()
3906 if (info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP) { in ieee80211_tx_dequeue()
3907 if (!ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL)) { in ieee80211_tx_dequeue()
3910 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_dequeue()
3917 if (info->control.flags & IEEE80211_TX_CTRL_FAST_XMIT) { in ieee80211_tx_dequeue()
3918 struct sta_info *sta = container_of(txq->sta, struct sta_info, in ieee80211_tx_dequeue()
3923 (tx.key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)) in ieee80211_tx_dequeue()
3924 pn_offs = ieee80211_hdrlen(hdr->frame_control); in ieee80211_tx_dequeue()
3926 r = ieee80211_xmit_fast_finish(sta->sdata, sta, pn_offs, in ieee80211_tx_dequeue()
3929 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_dequeue()
3940 spin_lock_bh(&fq->lock); in ieee80211_tx_dequeue()
3941 skb_queue_splice_tail(&tx.skbs, &txqi->frags); in ieee80211_tx_dequeue()
3942 spin_unlock_bh(&fq->lock); in ieee80211_tx_dequeue()
3947 !ieee80211_hw_check(&local->hw, TX_FRAG_LIST)) { in ieee80211_tx_dequeue()
3949 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_dequeue()
3954 switch (tx.sdata->vif.type) { in ieee80211_tx_dequeue()
3956 if ((tx.sdata->u.mntr.flags & MONITOR_FLAG_ACTIVE) || in ieee80211_tx_dequeue()
3957 ieee80211_hw_check(&local->hw, NO_VIRTUAL_MONITOR)) { in ieee80211_tx_dequeue()
3958 vif = &tx.sdata->vif; in ieee80211_tx_dequeue()
3961 tx.sdata = rcu_dereference(local->monitor_sdata); in ieee80211_tx_dequeue()
3963 ieee80211_hw_check(&local->hw, WANT_MONITOR_VIF)) { in ieee80211_tx_dequeue()
3964 vif = &tx.sdata->vif; in ieee80211_tx_dequeue()
3965 info->hw_queue = in ieee80211_tx_dequeue()
3966 vif->hw_queue[skb_get_queue_mapping(skb)]; in ieee80211_tx_dequeue()
3967 } else if (ieee80211_hw_check(&local->hw, QUEUE_CONTROL)) { in ieee80211_tx_dequeue()
3968 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_dequeue()
3971 info->control.vif = NULL; in ieee80211_tx_dequeue()
3976 tx.sdata = container_of(tx.sdata->bss, in ieee80211_tx_dequeue()
3980 vif = &tx.sdata->vif; in ieee80211_tx_dequeue()
3985 info->control.vif = vif; in ieee80211_tx_dequeue()
3988 wiphy_ext_feature_isset(local->hw.wiphy, NL80211_EXT_FEATURE_AQL)) { in ieee80211_tx_dequeue()
3989 bool ampdu = txq->ac != IEEE80211_AC_VO; in ieee80211_tx_dequeue()
3992 airtime = ieee80211_calc_expected_tx_airtime(hw, vif, txq->sta, in ieee80211_tx_dequeue()
3993 skb->len, ampdu); in ieee80211_tx_dequeue()
3997 txq->ac, in ieee80211_tx_dequeue()
4006 spin_unlock_bh(&fq->lock); in ieee80211_tx_dequeue()
4014 struct airtime_info *air_info = &sta->airtime[ac]; in ieee80211_sta_deficit()
4016 return air_info->deficit - atomic_read(&air_info->aql_tx_pending); in ieee80211_sta_deficit()
4024 if (!txqi->txq.sta) in ieee80211_txq_set_active()
4027 sta = container_of(txqi->txq.sta, struct sta_info, sta); in ieee80211_txq_set_active()
4028 sta->airtime[txqi->txq.ac].last_active = jiffies; in ieee80211_txq_set_active()
4036 if (!txqi->txq.sta) in ieee80211_txq_keep_active()
4039 sta = container_of(txqi->txq.sta, struct sta_info, sta); in ieee80211_txq_keep_active()
4040 if (ieee80211_sta_deficit(sta, txqi->txq.ac) >= 0) in ieee80211_txq_keep_active()
4043 return ieee80211_sta_keep_active(sta, txqi->txq.ac); in ieee80211_txq_keep_active()
4053 spin_lock_bh(&local->active_txq_lock[ac]); in ieee80211_next_txq()
4055 if (!local->schedule_round[ac]) in ieee80211_next_txq()
4059 txqi = list_first_entry_or_null(&local->active_txqs[ac], in ieee80211_next_txq()
4075 if (txqi->txq.sta) { in ieee80211_next_txq()
4076 struct sta_info *sta = container_of(txqi->txq.sta, in ieee80211_next_txq()
4078 bool aql_check = ieee80211_txq_airtime_check(hw, &txqi->txq); in ieee80211_next_txq()
4079 s32 deficit = ieee80211_sta_deficit(sta, txqi->txq.ac); in ieee80211_next_txq()
4085 sta->airtime[txqi->txq.ac].deficit += in ieee80211_next_txq()
4086 sta->airtime_weight; in ieee80211_next_txq()
4089 list_move_tail(&txqi->schedule_order, in ieee80211_next_txq()
4090 &local->active_txqs[txqi->txq.ac]); in ieee80211_next_txq()
4095 if (txqi->schedule_round == local->schedule_round[ac]) in ieee80211_next_txq()
4098 list_del_init(&txqi->schedule_order); in ieee80211_next_txq()
4099 txqi->schedule_round = local->schedule_round[ac]; in ieee80211_next_txq()
4100 ret = &txqi->txq; in ieee80211_next_txq()
4103 spin_unlock_bh(&local->active_txq_lock[ac]); in ieee80211_next_txq()
4116 spin_lock_bh(&local->active_txq_lock[txq->ac]); in __ieee80211_schedule_txq()
4119 if (list_empty(&txqi->schedule_order) && in __ieee80211_schedule_txq()
4128 if (txqi->txq.sta && local->airtime_flags && has_queue && in __ieee80211_schedule_txq()
4129 wiphy_ext_feature_isset(local->hw.wiphy, in __ieee80211_schedule_txq()
4131 list_add(&txqi->schedule_order, in __ieee80211_schedule_txq()
4132 &local->active_txqs[txq->ac]); in __ieee80211_schedule_txq()
4134 list_add_tail(&txqi->schedule_order, in __ieee80211_schedule_txq()
4135 &local->active_txqs[txq->ac]); in __ieee80211_schedule_txq()
4140 spin_unlock_bh(&local->active_txq_lock[txq->ac]); in __ieee80211_schedule_txq()
4152 if (!wiphy_ext_feature_isset(local->hw.wiphy, NL80211_EXT_FEATURE_AQL)) in ieee80211_txq_airtime_check()
4158 if (!txq->sta) in ieee80211_txq_airtime_check()
4161 if (unlikely(txq->tid == IEEE80211_NUM_TIDS)) in ieee80211_txq_airtime_check()
4164 sta = container_of(txq->sta, struct sta_info, sta); in ieee80211_txq_airtime_check()
4165 if (atomic_read(&sta->airtime[txq->ac].aql_tx_pending) < in ieee80211_txq_airtime_check()
4166 sta->airtime[txq->ac].aql_limit_low) in ieee80211_txq_airtime_check()
4169 if (atomic_read(&local->aql_total_pending_airtime) < in ieee80211_txq_airtime_check()
4170 local->aql_threshold && in ieee80211_txq_airtime_check()
4171 atomic_read(&sta->airtime[txq->ac].aql_tx_pending) < in ieee80211_txq_airtime_check()
4172 sta->airtime[txq->ac].aql_limit_high) in ieee80211_txq_airtime_check()
4186 if (!wiphy_ext_feature_isset(local->hw.wiphy, NL80211_EXT_FEATURE_AQL)) in ieee80211_txq_schedule_airtime_check()
4189 list_for_each_entry(txq, &local->active_txqs[ac], schedule_order) in ieee80211_txq_schedule_airtime_check()
4192 aql_limit = (num_txq - 1) * local->aql_txq_limit_low[ac] / 2 + in ieee80211_txq_schedule_airtime_check()
4193 local->aql_txq_limit_high[ac]; in ieee80211_txq_schedule_airtime_check()
4195 return atomic_read(&local->aql_ac_pending_airtime[ac]) < aql_limit; in ieee80211_txq_schedule_airtime_check()
4204 u8 ac = txq->ac; in ieee80211_txq_may_transmit()
4206 spin_lock_bh(&local->active_txq_lock[ac]); in ieee80211_txq_may_transmit()
4208 if (!txqi->txq.sta) in ieee80211_txq_may_transmit()
4211 if (list_empty(&txqi->schedule_order)) in ieee80211_txq_may_transmit()
4217 list_for_each_entry_safe(iter, tmp, &local->active_txqs[ac], in ieee80211_txq_may_transmit()
4222 if (!iter->txq.sta) { in ieee80211_txq_may_transmit()
4223 list_move_tail(&iter->schedule_order, in ieee80211_txq_may_transmit()
4224 &local->active_txqs[ac]); in ieee80211_txq_may_transmit()
4227 sta = container_of(iter->txq.sta, struct sta_info, sta); in ieee80211_txq_may_transmit()
4229 sta->airtime[ac].deficit += sta->airtime_weight; in ieee80211_txq_may_transmit()
4230 list_move_tail(&iter->schedule_order, &local->active_txqs[ac]); in ieee80211_txq_may_transmit()
4233 sta = container_of(txqi->txq.sta, struct sta_info, sta); in ieee80211_txq_may_transmit()
4234 if (sta->airtime[ac].deficit >= 0) in ieee80211_txq_may_transmit()
4237 sta->airtime[ac].deficit += sta->airtime_weight; in ieee80211_txq_may_transmit()
4238 list_move_tail(&txqi->schedule_order, &local->active_txqs[ac]); in ieee80211_txq_may_transmit()
4239 spin_unlock_bh(&local->active_txq_lock[ac]); in ieee80211_txq_may_transmit()
4243 if (!list_empty(&txqi->schedule_order)) in ieee80211_txq_may_transmit()
4244 list_del_init(&txqi->schedule_order); in ieee80211_txq_may_transmit()
4245 spin_unlock_bh(&local->active_txq_lock[ac]); in ieee80211_txq_may_transmit()
4255 spin_lock_bh(&local->active_txq_lock[ac]); in ieee80211_txq_schedule_start()
4258 local->schedule_round[ac]++; in ieee80211_txq_schedule_start()
4259 if (!local->schedule_round[ac]) in ieee80211_txq_schedule_start()
4260 local->schedule_round[ac]++; in ieee80211_txq_schedule_start()
4262 local->schedule_round[ac] = 0; in ieee80211_txq_schedule_start()
4265 spin_unlock_bh(&local->active_txq_lock[ac]); in ieee80211_txq_schedule_start()
4276 struct ieee80211_local *local = sdata->local; in __ieee80211_subif_start_xmit()
4279 int len = skb->len; in __ieee80211_subif_start_xmit()
4281 if (unlikely(!ieee80211_sdata_running(sdata) || skb->len < ETH_HLEN)) { in __ieee80211_subif_start_xmit()
4286 sk_pacing_shift_update(skb->sk, sdata->local->hw.tx_sk_pacing_shift); in __ieee80211_subif_start_xmit()
4290 if (ieee80211_vif_is_mesh(&sdata->vif) && in __ieee80211_subif_start_xmit()
4291 ieee80211_hw_check(&local->hw, SUPPORT_FAST_XMIT) && in __ieee80211_subif_start_xmit()
4307 fast_tx = rcu_dereference(sta->fast_tx); in __ieee80211_subif_start_xmit()
4314 /* the frame could be fragmented, software-encrypted, and other in __ieee80211_subif_start_xmit()
4327 if (skb->protocol == sdata->control_port_protocol) in __ieee80211_subif_start_xmit()
4337 dev_sw_netstats_tx_add(dev, 1, skb->len); in __ieee80211_subif_start_xmit()
4360 eth = (void *)skb->data; in ieee80211_change_da()
4361 ether_addr_copy(eth->h_dest, sta->sta.addr); in ieee80211_change_da()
4370 const struct ethhdr *eth = (void *)skb->data; in ieee80211_multicast_to_unicast()
4371 const struct vlan_ethhdr *ethvlan = (void *)skb->data; in ieee80211_multicast_to_unicast()
4374 switch (sdata->vif.type) { in ieee80211_multicast_to_unicast()
4376 if (sdata->u.vlan.sta) in ieee80211_multicast_to_unicast()
4378 if (sdata->wdev.use_4addr) in ieee80211_multicast_to_unicast()
4383 if (!sdata->bss->multicast_to_unicast) in ieee80211_multicast_to_unicast()
4391 ethertype = eth->h_proto; in ieee80211_multicast_to_unicast()
4392 if (ethertype == htons(ETH_P_8021Q) && skb->len >= VLAN_ETH_HLEN) in ieee80211_multicast_to_unicast()
4393 ethertype = ethvlan->h_vlan_encapsulated_proto; in ieee80211_multicast_to_unicast()
4411 struct ieee80211_local *local = sdata->local; in ieee80211_convert_to_unicast()
4412 const struct ethhdr *eth = (struct ethhdr *)skb->data; in ieee80211_convert_to_unicast()
4418 list_for_each_entry_rcu(sta, &local->sta_list, list) { in ieee80211_convert_to_unicast()
4419 if (sdata != sta->sdata) in ieee80211_convert_to_unicast()
4420 /* AP-VLAN mismatch */ in ieee80211_convert_to_unicast()
4422 if (unlikely(ether_addr_equal(eth->h_source, sta->sta.addr))) in ieee80211_convert_to_unicast()
4468 __ieee80211_subif_start_xmit(out, sdata->dev, 0, ctrl_flags, NULL); in ieee80211_mlo_multicast_tx_one()
4475 unsigned long links = sdata->vif.active_links; in ieee80211_mlo_multicast_tx()
4483 __ieee80211_subif_start_xmit(skb, sdata->dev, 0, ctrl_flags, in ieee80211_mlo_multicast_tx()
4496 * ieee80211_subif_start_xmit - netif start_xmit function for 802.3 vifs
4508 const struct ethhdr *eth = (void *)skb->data; in ieee80211_subif_start_xmit()
4510 if (likely(!is_multicast_ether_addr(eth->h_dest))) in ieee80211_subif_start_xmit()
4527 } else if (ieee80211_vif_is_mld(&sdata->vif) && in ieee80211_subif_start_xmit()
4528 sdata->vif.type == NL80211_IFTYPE_AP && in ieee80211_subif_start_xmit()
4529 !ieee80211_hw_check(&sdata->local->hw, MLO_MCAST_MULTI_LINK_TX)) { in ieee80211_subif_start_xmit()
4547 struct ieee80211_local *local = sdata->local; in __ieee80211_tx_8023()
4552 int q = info->hw_queue; in __ieee80211_tx_8023()
4554 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in __ieee80211_tx_8023()
4556 if (local->queue_stop_reasons[q] || in __ieee80211_tx_8023()
4557 (!txpending && !skb_queue_empty(&local->pending[q]))) { in __ieee80211_tx_8023()
4559 skb_queue_head(&local->pending[q], skb); in __ieee80211_tx_8023()
4561 skb_queue_tail(&local->pending[q], skb); in __ieee80211_tx_8023()
4563 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in __ieee80211_tx_8023()
4568 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in __ieee80211_tx_8023()
4570 if (sta && sta->uploaded) in __ieee80211_tx_8023()
4571 pubsta = &sta->sta; in __ieee80211_tx_8023()
4584 struct ieee80211_local *local = sdata->local; in ieee80211_tx_8023()
4605 struct ieee80211_local *local = sdata->local; in ieee80211_8023_xmit()
4607 struct sk_buff *seg, *next; in ieee80211_8023_xmit() local
4615 if (unlikely(test_bit(SCAN_SW_SCANNING, &local->scanning)) && in ieee80211_8023_xmit()
4616 test_bit(SDATA_STATE_OFFCHANNEL, &sdata->state)) in ieee80211_8023_xmit()
4625 tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; in ieee80211_8023_xmit()
4626 tid_tx = rcu_dereference(sta->ampdu_mlme.tid_tx[tid]); in ieee80211_8023_xmit()
4628 if (!test_bit(HT_AGG_STATE_OPERATIONAL, &tid_tx->state)) { in ieee80211_8023_xmit()
4629 /* fall back to non-offload slow path */ in ieee80211_8023_xmit()
4636 if (tid_tx->timeout) in ieee80211_8023_xmit()
4637 tid_tx->last_tx = jiffies; in ieee80211_8023_xmit()
4647 info->hw_queue = sdata->vif.hw_queue[queue]; in ieee80211_8023_xmit()
4649 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) in ieee80211_8023_xmit()
4650 sdata = container_of(sdata->bss, in ieee80211_8023_xmit()
4653 info->flags |= IEEE80211_TX_CTL_HW_80211_ENCAP; in ieee80211_8023_xmit()
4654 info->control.vif = &sdata->vif; in ieee80211_8023_xmit()
4657 info->control.hw_key = &key->conf; in ieee80211_8023_xmit()
4659 skb_list_walk_safe(skb, seg, next) { in ieee80211_8023_xmit()
4661 len += seg->len; in ieee80211_8023_xmit()
4662 if (seg != skb) in ieee80211_8023_xmit()
4663 memcpy(IEEE80211_SKB_CB(seg), info, sizeof(*info)); in ieee80211_8023_xmit()
4666 if (unlikely(skb->sk && in ieee80211_8023_xmit()
4667 skb_shinfo(skb)->tx_flags & SKBTX_WIFI_STATUS)) { in ieee80211_8023_xmit()
4668 info->status_data = ieee80211_store_ack_skb(local, skb, in ieee80211_8023_xmit()
4669 &info->flags, NULL); in ieee80211_8023_xmit()
4670 if (info->status_data) in ieee80211_8023_xmit()
4671 info->status_data_idr = 1; in ieee80211_8023_xmit()
4675 sta->deflink.tx_stats.packets[queue] += skbs; in ieee80211_8023_xmit()
4676 sta->deflink.tx_stats.bytes[queue] += len; in ieee80211_8023_xmit()
4692 struct ethhdr *ehdr = (struct ethhdr *)skb->data; in ieee80211_subif_start_xmit_8023()
4696 if (unlikely(!ieee80211_sdata_running(sdata) || skb->len < ETH_HLEN)) { in ieee80211_subif_start_xmit_8023()
4708 if (unlikely(IS_ERR_OR_NULL(sta) || !sta->uploaded || in ieee80211_subif_start_xmit_8023()
4710 sdata->control_port_protocol == ehdr->h_proto)) in ieee80211_subif_start_xmit_8023()
4713 key = rcu_dereference(sta->ptk[sta->ptk_idx]); in ieee80211_subif_start_xmit_8023()
4715 key = rcu_dereference(sdata->default_unicast_key); in ieee80211_subif_start_xmit_8023()
4717 if (key && (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) || in ieee80211_subif_start_xmit_8023()
4718 key->conf.cipher == WLAN_CIPHER_SUITE_TKIP)) in ieee80211_subif_start_xmit_8023()
4721 sk_pacing_shift_update(skb->sk, sdata->local->hw.tx_sk_pacing_shift); in ieee80211_subif_start_xmit_8023()
4739 .local = sdata->local, in ieee80211_build_data_template()
4748 skb = ERR_PTR(-EINVAL); in ieee80211_build_data_template()
4757 hdr = (void *)skb->data; in ieee80211_build_data_template()
4758 tx.sta = sta_info_get(sdata, hdr->addr1); in ieee80211_build_data_template()
4764 return ERR_PTR(-EINVAL); in ieee80211_build_data_template()
4781 for (i = 0; i < local->hw.queues; i++) { in ieee80211_clear_tx_pending()
4782 while ((skb = skb_dequeue(&local->pending[i])) != NULL) in ieee80211_clear_tx_pending()
4783 ieee80211_free_txskb(&local->hw, skb); in ieee80211_clear_tx_pending()
4789 * which in this case means re-queued -- take as an indication to stop sending
4802 sdata = vif_to_sdata(info->control.vif); in ieee80211_tx_pending_skb()
4804 if (info->control.flags & IEEE80211_TX_INTCFL_NEED_TXPROCESSING) { in ieee80211_tx_pending_skb()
4805 /* update band only for non-MLD */ in ieee80211_tx_pending_skb()
4806 if (!ieee80211_vif_is_mld(&sdata->vif)) { in ieee80211_tx_pending_skb()
4808 rcu_dereference(sdata->vif.bss_conf.chanctx_conf); in ieee80211_tx_pending_skb()
4813 info->band = chanctx_conf->def.chan->band; in ieee80211_tx_pending_skb()
4816 } else if (info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP) { in ieee80211_tx_pending_skb()
4822 if (IS_ERR(sta) || (sta && !sta->uploaded)) in ieee80211_tx_pending_skb()
4832 hdr = (struct ieee80211_hdr *)skb->data; in ieee80211_tx_pending_skb()
4833 sta = sta_info_get(sdata, hdr->addr1); in ieee80211_tx_pending_skb()
4854 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in ieee80211_tx_pending()
4855 for (i = 0; i < local->hw.queues; i++) { in ieee80211_tx_pending()
4860 if (local->queue_stop_reasons[i] || in ieee80211_tx_pending()
4861 skb_queue_empty(&local->pending[i])) in ieee80211_tx_pending()
4864 while (!skb_queue_empty(&local->pending[i])) { in ieee80211_tx_pending()
4865 struct sk_buff *skb = __skb_dequeue(&local->pending[i]); in ieee80211_tx_pending()
4868 if (WARN_ON(!info->control.vif)) { in ieee80211_tx_pending()
4869 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_pending()
4873 spin_unlock_irqrestore(&local->queue_stop_reason_lock, in ieee80211_tx_pending()
4877 spin_lock_irqsave(&local->queue_stop_reason_lock, in ieee80211_tx_pending()
4883 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_tx_pending()
4898 struct ieee80211_bss_conf *link_conf = link->conf; in __ieee80211_beacon_add_tim()
4902 if (atomic_read(&ps->num_sta_ps) > 0) in __ieee80211_beacon_add_tim()
4904 * checking byte-for-byte */ in __ieee80211_beacon_add_tim()
4905 have_bits = !bitmap_empty((unsigned long *)ps->tim, in __ieee80211_beacon_add_tim()
4908 if (ps->dtim_count == 0) in __ieee80211_beacon_add_tim()
4909 ps->dtim_count = link_conf->dtim_period - 1; in __ieee80211_beacon_add_tim()
4911 ps->dtim_count--; in __ieee80211_beacon_add_tim()
4917 *pos++ = ps->dtim_count; in __ieee80211_beacon_add_tim()
4918 *pos++ = link_conf->dtim_period; in __ieee80211_beacon_add_tim()
4920 if (ps->dtim_count == 0 && !skb_queue_empty(&ps->bc_buf)) in __ieee80211_beacon_add_tim()
4923 ps->dtim_bc_mc = aid0 == 1; in __ieee80211_beacon_add_tim()
4927 * (N1 x 8) - 1 in the bitmap are 0 and number N2 so that bits in __ieee80211_beacon_add_tim()
4931 if (ps->tim[i]) { in __ieee80211_beacon_add_tim()
4937 for (i = IEEE80211_MAX_TIM_LEN - 1; i >= n1; i--) { in __ieee80211_beacon_add_tim()
4938 if (ps->tim[i]) { in __ieee80211_beacon_add_tim()
4947 skb_put_data(skb, ps->tim + n1, n2 - n1 + 1); in __ieee80211_beacon_add_tim()
4949 tim[1] = n2 - n1 + 4; in __ieee80211_beacon_add_tim()
4953 if (ieee80211_get_link_sband(link)->band != NL80211_BAND_S1GHZ) { in __ieee80211_beacon_add_tim()
4966 struct ieee80211_local *local = sdata->local; in ieee80211_beacon_add_tim()
4972 * sta_lock to guarantee consistent and race-free update in ieee80211_beacon_add_tim()
4975 if (local->tim_in_locked_section) { in ieee80211_beacon_add_tim()
4978 spin_lock_bh(&local->tim_lock); in ieee80211_beacon_add_tim()
4980 spin_unlock_bh(&local->tim_lock); in ieee80211_beacon_add_tim()
4996 switch (sdata->vif.type) { in ieee80211_set_beacon_cntdwn()
4998 beacon_data = beacon->tail; in ieee80211_set_beacon_cntdwn()
4999 beacon_data_len = beacon->tail_len; in ieee80211_set_beacon_cntdwn()
5002 beacon_data = beacon->head; in ieee80211_set_beacon_cntdwn()
5003 beacon_data_len = beacon->head_len; in ieee80211_set_beacon_cntdwn()
5006 beacon_data = beacon->head; in ieee80211_set_beacon_cntdwn()
5007 beacon_data_len = beacon->head_len; in ieee80211_set_beacon_cntdwn()
5013 resp = rcu_dereference(link->u.ap.probe_resp); in ieee80211_set_beacon_cntdwn()
5015 bcn_offsets = beacon->cntdwn_counter_offsets; in ieee80211_set_beacon_cntdwn()
5016 count = beacon->cntdwn_current_counter; in ieee80211_set_beacon_cntdwn()
5017 if (link->conf->csa_active) in ieee80211_set_beacon_cntdwn()
5027 if (sdata->vif.type == NL80211_IFTYPE_AP && resp) { in ieee80211_set_beacon_cntdwn()
5028 u16 *resp_offsets = resp->cntdwn_counter_offsets; in ieee80211_set_beacon_cntdwn()
5030 resp->data[resp_offsets[i]] = count; in ieee80211_set_beacon_cntdwn()
5037 beacon->cntdwn_current_counter--; in __ieee80211_beacon_update_cntdwn()
5040 WARN_ON_ONCE(!beacon->cntdwn_current_counter); in __ieee80211_beacon_update_cntdwn()
5042 return beacon->cntdwn_current_counter; in __ieee80211_beacon_update_cntdwn()
5057 link = rcu_dereference(sdata->link[link_id]); in ieee80211_beacon_update_cntdwn()
5061 if (sdata->vif.type == NL80211_IFTYPE_AP) in ieee80211_beacon_update_cntdwn()
5062 beacon = rcu_dereference(link->u.ap.beacon); in ieee80211_beacon_update_cntdwn()
5063 else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) in ieee80211_beacon_update_cntdwn()
5064 beacon = rcu_dereference(sdata->u.ibss.presp); in ieee80211_beacon_update_cntdwn()
5065 else if (ieee80211_vif_is_mesh(&sdata->vif)) in ieee80211_beacon_update_cntdwn()
5066 beacon = rcu_dereference(sdata->u.mesh.beacon); in ieee80211_beacon_update_cntdwn()
5086 if (sdata->vif.type == NL80211_IFTYPE_AP) in ieee80211_beacon_set_cntdwn()
5087 beacon = rcu_dereference(sdata->deflink.u.ap.beacon); in ieee80211_beacon_set_cntdwn()
5088 else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) in ieee80211_beacon_set_cntdwn()
5089 beacon = rcu_dereference(sdata->u.ibss.presp); in ieee80211_beacon_set_cntdwn()
5090 else if (ieee80211_vif_is_mesh(&sdata->vif)) in ieee80211_beacon_set_cntdwn()
5091 beacon = rcu_dereference(sdata->u.mesh.beacon); in ieee80211_beacon_set_cntdwn()
5096 if (counter < beacon->cntdwn_current_counter) in ieee80211_beacon_set_cntdwn()
5097 beacon->cntdwn_current_counter = counter; in ieee80211_beacon_set_cntdwn()
5122 link = rcu_dereference(sdata->link[link_id]); in ieee80211_beacon_cntdwn_is_complete()
5126 if (vif->type == NL80211_IFTYPE_AP) { in ieee80211_beacon_cntdwn_is_complete()
5127 beacon = rcu_dereference(link->u.ap.beacon); in ieee80211_beacon_cntdwn_is_complete()
5128 if (WARN_ON(!beacon || !beacon->tail)) in ieee80211_beacon_cntdwn_is_complete()
5130 beacon_data = beacon->tail; in ieee80211_beacon_cntdwn_is_complete()
5131 beacon_data_len = beacon->tail_len; in ieee80211_beacon_cntdwn_is_complete()
5132 } else if (vif->type == NL80211_IFTYPE_ADHOC) { in ieee80211_beacon_cntdwn_is_complete()
5133 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; in ieee80211_beacon_cntdwn_is_complete()
5135 beacon = rcu_dereference(ifibss->presp); in ieee80211_beacon_cntdwn_is_complete()
5139 beacon_data = beacon->head; in ieee80211_beacon_cntdwn_is_complete()
5140 beacon_data_len = beacon->head_len; in ieee80211_beacon_cntdwn_is_complete()
5141 } else if (vif->type == NL80211_IFTYPE_MESH_POINT) { in ieee80211_beacon_cntdwn_is_complete()
5142 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; in ieee80211_beacon_cntdwn_is_complete()
5144 beacon = rcu_dereference(ifmsh->beacon); in ieee80211_beacon_cntdwn_is_complete()
5148 beacon_data = beacon->head; in ieee80211_beacon_cntdwn_is_complete()
5149 beacon_data_len = beacon->head_len; in ieee80211_beacon_cntdwn_is_complete()
5155 if (!beacon->cntdwn_counter_offsets[0]) in ieee80211_beacon_cntdwn_is_complete()
5158 if (WARN_ON_ONCE(beacon->cntdwn_counter_offsets[0] > beacon_data_len)) in ieee80211_beacon_cntdwn_is_complete()
5161 if (beacon_data[beacon->cntdwn_counter_offsets[0]] == 1) in ieee80211_beacon_cntdwn_is_complete()
5181 tx.key = rcu_dereference(link->default_beacon_key); in ieee80211_beacon_protect()
5185 if (unlikely(tx.key->flags & KEY_FLAG_TAINTED)) { in ieee80211_beacon_protect()
5187 return -EINVAL; in ieee80211_beacon_protect()
5190 if (!(tx.key->conf.flags & IEEE80211_KEY_FLAG_SW_MGMT_TX) && in ieee80211_beacon_protect()
5191 tx.key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) in ieee80211_beacon_protect()
5192 IEEE80211_SKB_CB(skb)->control.hw_key = &tx.key->conf; in ieee80211_beacon_protect()
5203 return -EINVAL; in ieee80211_beacon_protect()
5229 u16 csa_off = beacon->cntdwn_counter_offsets[i]; in ieee80211_beacon_get_finish()
5234 offs->cntdwn_counter_offs[i] = csa_off_base + csa_off; in ieee80211_beacon_get_finish()
5238 band = chanctx_conf->def.chan->band; in ieee80211_beacon_get_finish()
5240 info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; in ieee80211_beacon_get_finish()
5241 info->flags |= IEEE80211_TX_CTL_NO_ACK; in ieee80211_beacon_get_finish()
5242 info->band = band; in ieee80211_beacon_get_finish()
5246 txrc.sband = local->hw.wiphy->bands[band]; in ieee80211_beacon_get_finish()
5247 txrc.bss_conf = link->conf; in ieee80211_beacon_get_finish()
5249 txrc.reported_rate.idx = -1; in ieee80211_beacon_get_finish()
5250 if (sdata->beacon_rate_set && sdata->beacon_rateidx_mask[band]) in ieee80211_beacon_get_finish()
5251 txrc.rate_idx_mask = sdata->beacon_rateidx_mask[band]; in ieee80211_beacon_get_finish()
5253 txrc.rate_idx_mask = sdata->rc_rateidx_mask[band]; in ieee80211_beacon_get_finish()
5257 info->control.vif = vif; in ieee80211_beacon_get_finish()
5258 info->control.flags |= u32_encode_bits(link->link_id, in ieee80211_beacon_get_finish()
5260 info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT | in ieee80211_beacon_get_finish()
5269 if (!beacon->mbssid_ies || !beacon->mbssid_ies->cnt || in ieee80211_beacon_add_mbssid()
5270 i > beacon->mbssid_ies->cnt) in ieee80211_beacon_add_mbssid()
5273 if (i < beacon->mbssid_ies->cnt) { in ieee80211_beacon_add_mbssid()
5274 skb_put_data(skb, beacon->mbssid_ies->elem[i].data, in ieee80211_beacon_add_mbssid()
5275 beacon->mbssid_ies->elem[i].len); in ieee80211_beacon_add_mbssid()
5277 if (beacon->rnr_ies && beacon->rnr_ies->cnt) { in ieee80211_beacon_add_mbssid()
5278 skb_put_data(skb, beacon->rnr_ies->elem[i].data, in ieee80211_beacon_add_mbssid()
5279 beacon->rnr_ies->elem[i].len); in ieee80211_beacon_add_mbssid()
5281 for (i = beacon->mbssid_ies->cnt; i < beacon->rnr_ies->cnt; i++) in ieee80211_beacon_add_mbssid()
5282 skb_put_data(skb, beacon->rnr_ies->elem[i].data, in ieee80211_beacon_add_mbssid()
5283 beacon->rnr_ies->elem[i].len); in ieee80211_beacon_add_mbssid()
5288 /* i == beacon->mbssid_ies->cnt, include all MBSSID elements */ in ieee80211_beacon_add_mbssid()
5289 for (i = 0; i < beacon->mbssid_ies->cnt; i++) in ieee80211_beacon_add_mbssid()
5290 skb_put_data(skb, beacon->mbssid_ies->elem[i].data, in ieee80211_beacon_add_mbssid()
5291 beacon->mbssid_ies->elem[i].len); in ieee80211_beacon_add_mbssid()
5306 struct ieee80211_if_ap *ap = &sdata->u.ap; in ieee80211_beacon_get_ap()
5311 if (beacon->cntdwn_counter_offsets[0]) { in ieee80211_beacon_get_ap()
5313 ieee80211_beacon_update_cntdwn(vif, link->link_id); in ieee80211_beacon_get_ap()
5321 mbssid_len = ieee80211_get_mbssid_beacon_len(beacon->mbssid_ies, in ieee80211_beacon_get_ap()
5322 beacon->rnr_ies, in ieee80211_beacon_get_ap()
5325 skb = dev_alloc_skb(local->tx_headroom + beacon->head_len + in ieee80211_beacon_get_ap()
5326 beacon->tail_len + 256 + in ieee80211_beacon_get_ap()
5327 local->hw.extra_beacon_tailroom + mbssid_len); in ieee80211_beacon_get_ap()
5331 skb_reserve(skb, local->tx_headroom); in ieee80211_beacon_get_ap()
5332 skb_put_data(skb, beacon->head, beacon->head_len); in ieee80211_beacon_get_ap()
5334 ieee80211_beacon_add_tim(sdata, link, &ap->ps, skb, is_template); in ieee80211_beacon_get_ap()
5337 offs->tim_offset = beacon->head_len; in ieee80211_beacon_get_ap()
5338 offs->tim_length = skb->len - beacon->head_len; in ieee80211_beacon_get_ap()
5339 offs->cntdwn_counter_offs[0] = beacon->cntdwn_counter_offsets[0]; in ieee80211_beacon_get_ap()
5343 offs->mbssid_off = skb->len - mbssid_len; in ieee80211_beacon_get_ap()
5347 csa_off_base = skb->len; in ieee80211_beacon_get_ap()
5350 if (beacon->tail) in ieee80211_beacon_get_ap()
5351 skb_put_data(skb, beacon->tail, beacon->tail_len); in ieee80211_beacon_get_ap()
5373 if (!beacon->mbssid_ies || !beacon->mbssid_ies->cnt) in ieee80211_beacon_get_ap_ema_list()
5376 ema = kzalloc(struct_size(ema, bcn, beacon->mbssid_ies->cnt), in ieee80211_beacon_get_ap_ema_list()
5381 for (ema->cnt = 0; ema->cnt < beacon->mbssid_ies->cnt; ema->cnt++) { in ieee80211_beacon_get_ap_ema_list()
5382 ema->bcn[ema->cnt].skb = in ieee80211_beacon_get_ap_ema_list()
5384 &ema->bcn[ema->cnt].offs, in ieee80211_beacon_get_ap_ema_list()
5386 chanctx_conf, ema->cnt); in ieee80211_beacon_get_ap_ema_list()
5387 if (!ema->bcn[ema->cnt].skb) in ieee80211_beacon_get_ap_ema_list()
5391 if (ema->cnt == beacon->mbssid_ies->cnt) in ieee80211_beacon_get_ap_ema_list()
5398 #define IEEE80211_INCLUDE_ALL_MBSSID_ELEMS -1
5419 link = rcu_dereference(sdata->link[link_id]); in __ieee80211_beacon_get()
5423 rcu_dereference(link->conf->chanctx_conf); in __ieee80211_beacon_get()
5431 if (sdata->vif.type == NL80211_IFTYPE_AP) { in __ieee80211_beacon_get()
5432 beacon = rcu_dereference(link->u.ap.beacon); in __ieee80211_beacon_get()
5444 if (beacon->mbssid_ies && beacon->mbssid_ies->cnt) { in __ieee80211_beacon_get()
5445 if (ema_index >= beacon->mbssid_ies->cnt) in __ieee80211_beacon_get()
5449 ema_index = beacon->mbssid_ies->cnt; in __ieee80211_beacon_get()
5459 } else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) { in __ieee80211_beacon_get()
5460 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; in __ieee80211_beacon_get()
5463 beacon = rcu_dereference(ifibss->presp); in __ieee80211_beacon_get()
5467 if (beacon->cntdwn_counter_offsets[0]) { in __ieee80211_beacon_get()
5474 skb = dev_alloc_skb(local->tx_headroom + beacon->head_len + in __ieee80211_beacon_get()
5475 local->hw.extra_beacon_tailroom); in __ieee80211_beacon_get()
5478 skb_reserve(skb, local->tx_headroom); in __ieee80211_beacon_get()
5479 skb_put_data(skb, beacon->head, beacon->head_len); in __ieee80211_beacon_get()
5481 hdr = (struct ieee80211_hdr *) skb->data; in __ieee80211_beacon_get()
5482 hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | in __ieee80211_beacon_get()
5487 } else if (ieee80211_vif_is_mesh(&sdata->vif)) { in __ieee80211_beacon_get()
5488 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; in __ieee80211_beacon_get()
5490 beacon = rcu_dereference(ifmsh->beacon); in __ieee80211_beacon_get()
5494 if (beacon->cntdwn_counter_offsets[0]) { in __ieee80211_beacon_get()
5506 if (ifmsh->sync_ops) in __ieee80211_beacon_get()
5507 ifmsh->sync_ops->adjust_tsf(sdata, beacon); in __ieee80211_beacon_get()
5509 skb = dev_alloc_skb(local->tx_headroom + in __ieee80211_beacon_get()
5510 beacon->head_len + in __ieee80211_beacon_get()
5512 beacon->tail_len + in __ieee80211_beacon_get()
5513 local->hw.extra_beacon_tailroom); in __ieee80211_beacon_get()
5516 skb_reserve(skb, local->tx_headroom); in __ieee80211_beacon_get()
5517 skb_put_data(skb, beacon->head, beacon->head_len); in __ieee80211_beacon_get()
5518 ieee80211_beacon_add_tim(sdata, link, &ifmsh->ps, skb, in __ieee80211_beacon_get()
5522 offs->tim_offset = beacon->head_len; in __ieee80211_beacon_get()
5523 offs->tim_length = skb->len - beacon->head_len; in __ieee80211_beacon_get()
5526 skb_put_data(skb, beacon->tail, beacon->tail_len); in __ieee80211_beacon_get()
5569 for (i = 0; i < ema_beacons->cnt; i++) in ieee80211_beacon_free_ema_list()
5570 kfree_skb(ema_beacons->bcn[i].skb); in ieee80211_beacon_free_ema_list()
5612 !hw_to_local(hw)->monitors) in ieee80211_beacon_get_tim()
5634 if (sdata->vif.type != NL80211_IFTYPE_AP) in ieee80211_proberesp_get()
5638 presp = rcu_dereference(sdata->deflink.u.ap.probe_resp); in ieee80211_proberesp_get()
5642 skb = dev_alloc_skb(presp->len); in ieee80211_proberesp_get()
5646 skb_put_data(skb, presp->data, presp->len); in ieee80211_proberesp_get()
5648 hdr = (struct ieee80211_hdr *) skb->data; in ieee80211_proberesp_get()
5649 memset(hdr->addr1, 0, sizeof(hdr->addr1)); in ieee80211_proberesp_get()
5664 if (sdata->vif.type != NL80211_IFTYPE_AP) in ieee80211_get_fils_discovery_tmpl()
5668 tmpl = rcu_dereference(sdata->deflink.u.ap.fils_discovery); in ieee80211_get_fils_discovery_tmpl()
5674 skb = dev_alloc_skb(sdata->local->hw.extra_tx_headroom + tmpl->len); in ieee80211_get_fils_discovery_tmpl()
5676 skb_reserve(skb, sdata->local->hw.extra_tx_headroom); in ieee80211_get_fils_discovery_tmpl()
5677 skb_put_data(skb, tmpl->data, tmpl->len); in ieee80211_get_fils_discovery_tmpl()
5693 if (sdata->vif.type != NL80211_IFTYPE_AP) in ieee80211_get_unsol_bcast_probe_resp_tmpl()
5697 tmpl = rcu_dereference(sdata->deflink.u.ap.unsol_bcast_probe_resp); in ieee80211_get_unsol_bcast_probe_resp_tmpl()
5703 skb = dev_alloc_skb(sdata->local->hw.extra_tx_headroom + tmpl->len); in ieee80211_get_unsol_bcast_probe_resp_tmpl()
5705 skb_reserve(skb, sdata->local->hw.extra_tx_headroom); in ieee80211_get_unsol_bcast_probe_resp_tmpl()
5706 skb_put_data(skb, tmpl->data, tmpl->len); in ieee80211_get_unsol_bcast_probe_resp_tmpl()
5722 if (WARN_ON(vif->type != NL80211_IFTYPE_STATION)) in ieee80211_pspoll_get()
5726 local = sdata->local; in ieee80211_pspoll_get()
5728 skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*pspoll)); in ieee80211_pspoll_get()
5732 skb_reserve(skb, local->hw.extra_tx_headroom); in ieee80211_pspoll_get()
5735 pspoll->frame_control = cpu_to_le16(IEEE80211_FTYPE_CTL | in ieee80211_pspoll_get()
5737 pspoll->aid = cpu_to_le16(sdata->vif.cfg.aid); in ieee80211_pspoll_get()
5739 /* aid in PS-Poll has its two MSBs each set to 1 */ in ieee80211_pspoll_get()
5740 pspoll->aid |= cpu_to_le16(1 << 15 | 1 << 14); in ieee80211_pspoll_get()
5742 memcpy(pspoll->bssid, sdata->deflink.u.mgd.bssid, ETH_ALEN); in ieee80211_pspoll_get()
5743 memcpy(pspoll->ta, vif->addr, ETH_ALEN); in ieee80211_pspoll_get()
5754 struct ieee80211_local *local = sdata->local; in ieee80211_nullfunc_get()
5760 if (WARN_ON(vif->type != NL80211_IFTYPE_STATION)) in ieee80211_nullfunc_get()
5763 skb = dev_alloc_skb(local->hw.extra_tx_headroom + in ieee80211_nullfunc_get()
5772 sta = sta_info_get(sdata, vif->cfg.ap_addr); in ieee80211_nullfunc_get()
5773 qos = sta && sta->sta.wme; in ieee80211_nullfunc_get()
5777 link = rcu_dereference(sdata->link[link_id]); in ieee80211_nullfunc_get()
5785 skb_reserve(skb, local->hw.extra_tx_headroom); in ieee80211_nullfunc_get()
5788 nullfunc->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA | in ieee80211_nullfunc_get()
5792 __le16 qoshdr = cpu_to_le16(7); in ieee80211_nullfunc_get()
5797 nullfunc->frame_control |= in ieee80211_nullfunc_get()
5799 skb->priority = 7; in ieee80211_nullfunc_get()
5805 memcpy(nullfunc->addr1, link->conf->bssid, ETH_ALEN); in ieee80211_nullfunc_get()
5806 memcpy(nullfunc->addr2, link->conf->addr, ETH_ALEN); in ieee80211_nullfunc_get()
5807 memcpy(nullfunc->addr3, link->conf->bssid, ETH_ALEN); in ieee80211_nullfunc_get()
5809 memcpy(nullfunc->addr1, vif->cfg.ap_addr, ETH_ALEN); in ieee80211_nullfunc_get()
5810 memcpy(nullfunc->addr2, vif->addr, ETH_ALEN); in ieee80211_nullfunc_get()
5811 memcpy(nullfunc->addr3, vif->cfg.ap_addr, ETH_ALEN); in ieee80211_nullfunc_get()
5832 skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*hdr) + in ieee80211_probereq_get()
5837 skb_reserve(skb, local->hw.extra_tx_headroom); in ieee80211_probereq_get()
5840 hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | in ieee80211_probereq_get()
5842 eth_broadcast_addr(hdr->addr1); in ieee80211_probereq_get()
5843 memcpy(hdr->addr2, src_addr, ETH_ALEN); in ieee80211_probereq_get()
5844 eth_broadcast_addr(hdr->addr3); in ieee80211_probereq_get()
5864 rts->frame_control = in ieee80211_rts_get()
5866 rts->duration = ieee80211_rts_duration(hw, vif, frame_len, in ieee80211_rts_get()
5868 memcpy(rts->ra, hdr->addr1, sizeof(rts->ra)); in ieee80211_rts_get()
5869 memcpy(rts->ta, hdr->addr2, sizeof(rts->ta)); in ieee80211_rts_get()
5880 cts->frame_control = in ieee80211_ctstoself_get()
5882 cts->duration = ieee80211_ctstoself_duration(hw, vif, in ieee80211_ctstoself_get()
5884 memcpy(cts->ra, hdr->addr1, sizeof(cts->ra)); in ieee80211_ctstoself_get()
5903 chanctx_conf = rcu_dereference(sdata->vif.bss_conf.chanctx_conf); in ieee80211_get_buffered_bc()
5908 if (sdata->vif.type == NL80211_IFTYPE_AP) { in ieee80211_get_buffered_bc()
5910 rcu_dereference(sdata->deflink.u.ap.beacon); in ieee80211_get_buffered_bc()
5912 if (!beacon || !beacon->head) in ieee80211_get_buffered_bc()
5915 ps = &sdata->u.ap.ps; in ieee80211_get_buffered_bc()
5916 } else if (ieee80211_vif_is_mesh(&sdata->vif)) { in ieee80211_get_buffered_bc()
5917 ps = &sdata->u.mesh.ps; in ieee80211_get_buffered_bc()
5922 if (ps->dtim_count != 0 || !ps->dtim_bc_mc) in ieee80211_get_buffered_bc()
5926 skb = skb_dequeue(&ps->bc_buf); in ieee80211_get_buffered_bc()
5929 local->total_ps_buffered--; in ieee80211_get_buffered_bc()
5931 if (!skb_queue_empty(&ps->bc_buf) && skb->len >= 2) { in ieee80211_get_buffered_bc()
5933 (struct ieee80211_hdr *) skb->data; in ieee80211_get_buffered_bc()
5937 hdr->frame_control |= in ieee80211_get_buffered_bc()
5941 if (sdata->vif.type == NL80211_IFTYPE_AP) in ieee80211_get_buffered_bc()
5942 sdata = IEEE80211_DEV_TO_SUB_IF(skb->dev); in ieee80211_get_buffered_bc()
5951 info->band = chanctx_conf->def.chan->band; in ieee80211_get_buffered_bc()
5965 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_reserve_tid()
5966 struct ieee80211_local *local = sdata->local; in ieee80211_reserve_tid()
5970 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_reserve_tid()
5973 switch (sdata->vif.type) { in ieee80211_reserve_tid()
5980 return -EINVAL; in ieee80211_reserve_tid()
5984 return -EINVAL; in ieee80211_reserve_tid()
5986 if (sta->reserved_tid == tid) { in ieee80211_reserve_tid()
5991 if (sta->reserved_tid != IEEE80211_TID_UNRESERVED) { in ieee80211_reserve_tid()
5993 ret = -EALREADY; in ieee80211_reserve_tid()
5997 ieee80211_stop_vif_queues(sdata->local, sdata, in ieee80211_reserve_tid()
6003 if (ieee80211_hw_check(&local->hw, AMPDU_AGGREGATION)) { in ieee80211_reserve_tid()
6009 queues = BIT(sdata->vif.hw_queue[ieee802_1d_to_ac[tid]]); in ieee80211_reserve_tid()
6012 sta->reserved_tid = tid; in ieee80211_reserve_tid()
6017 if (ieee80211_hw_check(&local->hw, AMPDU_AGGREGATION)) in ieee80211_reserve_tid()
6029 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_unreserve_tid()
6031 lockdep_assert_wiphy(sdata->local->hw.wiphy); in ieee80211_unreserve_tid()
6034 switch (sdata->vif.type) { in ieee80211_unreserve_tid()
6044 if (tid != sta->reserved_tid) { in ieee80211_unreserve_tid()
6049 sta->reserved_tid = IEEE80211_TID_UNRESERVED; in ieee80211_unreserve_tid()
6057 const struct ieee80211_hdr *hdr = (void *)skb->data; in __ieee80211_tx_skb_tid_band()
6063 skb->priority = tid; in __ieee80211_tx_skb_tid_band()
6065 skb->dev = sdata->dev; in __ieee80211_tx_skb_tid_band()
6071 if (!ieee80211_vif_is_mld(&sdata->vif)) { in __ieee80211_tx_skb_tid_band()
6075 } else if (memcmp(sdata->vif.addr, hdr->addr2, ETH_ALEN) == 0) { in __ieee80211_tx_skb_tid_band()
6081 for (link = 0; link < ARRAY_SIZE(sdata->vif.link_conf); link++) { in __ieee80211_tx_skb_tid_band()
6084 link_conf = rcu_dereference(sdata->vif.link_conf[link]); in __ieee80211_tx_skb_tid_band()
6087 if (memcmp(link_conf->addr, hdr->addr2, ETH_ALEN) == 0) in __ieee80211_tx_skb_tid_band()
6092 if (WARN_ON_ONCE(link == ARRAY_SIZE(sdata->vif.link_conf))) in __ieee80211_tx_skb_tid_band()
6093 link = ffs(sdata->vif.active_links) - 1; in __ieee80211_tx_skb_tid_band()
6096 IEEE80211_SKB_CB(skb)->control.flags |= in __ieee80211_tx_skb_tid_band()
6105 IEEE80211_SKB_CB(skb)->band = band; in __ieee80211_tx_skb_tid_band()
6117 if (!ieee80211_vif_is_mld(&sdata->vif)) { in ieee80211_tx_skb_tid()
6120 rcu_dereference(sdata->vif.bss_conf.chanctx_conf); in ieee80211_tx_skb_tid()
6126 band = chanctx_conf->def.chan->band; in ieee80211_tx_skb_tid()
6129 !(sdata->vif.active_links & BIT(link_id))); in ieee80211_tx_skb_tid()
6144 struct ieee80211_local *local = sdata->local; in ieee80211_tx_control_port()
6153 lockdep_assert_wiphy(local->hw.wiphy); in ieee80211_tx_control_port()
6156 * or Pre-Authentication in ieee80211_tx_control_port()
6158 if (proto != sdata->control_port_protocol && in ieee80211_tx_control_port()
6160 return -EINVAL; in ieee80211_tx_control_port()
6162 if (proto == sdata->control_port_protocol) in ieee80211_tx_control_port()
6174 skb = dev_alloc_skb(local->hw.extra_tx_headroom + in ieee80211_tx_control_port()
6177 return -ENOMEM; in ieee80211_tx_control_port()
6179 skb_reserve(skb, local->hw.extra_tx_headroom + sizeof(struct ethhdr)); in ieee80211_tx_control_port()
6184 memcpy(ehdr->h_dest, dest, ETH_ALEN); in ieee80211_tx_control_port()
6190 memcpy(ehdr->h_source, sdata->vif.addr, ETH_ALEN); in ieee80211_tx_control_port()
6198 link_conf = rcu_dereference(sdata->vif.link_conf[link_id]); in ieee80211_tx_control_port()
6202 return -ENOLINK; in ieee80211_tx_control_port()
6204 memcpy(ehdr->h_source, link_conf->addr, ETH_ALEN); in ieee80211_tx_control_port()
6208 ehdr->h_proto = proto; in ieee80211_tx_control_port()
6210 skb->dev = dev; in ieee80211_tx_control_port()
6211 skb->protocol = proto; in ieee80211_tx_control_port()
6215 if (local->hw.queues < IEEE80211_NUM_ACS) in ieee80211_tx_control_port()
6239 if (sta && sta->sta.mlo) in ieee80211_tx_control_port()
6240 memcpy(ehdr->h_source, sdata->vif.addr, ETH_ALEN); in ieee80211_tx_control_port()
6246 __ieee80211_subif_start_xmit(skb, skb->dev, flags, ctrl_flags, cookie); in ieee80211_tx_control_port()
6256 struct ieee80211_local *local = sdata->local; in ieee80211_probe_mesh_link()
6259 skb = dev_alloc_skb(local->hw.extra_tx_headroom + len + in ieee80211_probe_mesh_link()
6263 return -ENOMEM; in ieee80211_probe_mesh_link()
6265 skb_reserve(skb, local->hw.extra_tx_headroom); in ieee80211_probe_mesh_link()
6268 skb->dev = dev; in ieee80211_probe_mesh_link()
6269 skb->protocol = htons(ETH_P_802_3); in ieee80211_probe_mesh_link()
6274 __ieee80211_subif_start_xmit(skb, skb->dev, 0, in ieee80211_probe_mesh_link()