Lines Matching +full:out +full:- +full:of +full:- +full:band

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright 2002-2005, Instant802 Networks, Inc.
4 * Copyright 2005-2006, Devicescape Software, Inc.
5 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
7 * Copyright 2013-2014 Intel Mobile Communications GmbH
8 * Copyright (C) 2018-2021 Intel Corporation
32 #include "driver-ops.h"
48 struct ieee80211_local *local = tx->local; in ieee80211_duration()
56 if (tx->rate.flags & (IEEE80211_TX_RC_MCS | IEEE80211_TX_RC_VHT_MCS)) in ieee80211_duration()
60 chanctx_conf = rcu_dereference(tx->sdata->vif.chanctx_conf); in ieee80211_duration()
62 shift = ieee80211_chandef_get_shift(&chanctx_conf->def); in ieee80211_duration()
63 rate_flags = ieee80211_chandef_rate_flags(&chanctx_conf->def); in ieee80211_duration()
68 if (WARN_ON_ONCE(tx->rate.idx < 0)) in ieee80211_duration()
71 sband = local->hw.wiphy->bands[info->band]; in ieee80211_duration()
72 txrate = &sband->bitrates[tx->rate.idx]; in ieee80211_duration()
74 erp = txrate->flags & IEEE80211_RATE_ERP_G; in ieee80211_duration()
77 if (sband->band == NL80211_BAND_S1GHZ) in ieee80211_duration()
82 * - during CFP: 32768 in ieee80211_duration()
83 * - during contention period: in ieee80211_duration()
91 * - control response frame (CTS or ACK) shall be transmitted using the in ieee80211_duration()
97 hdr = (struct ieee80211_hdr *)skb->data; in ieee80211_duration()
98 if (ieee80211_is_ctl(hdr->frame_control)) { in ieee80211_duration()
105 * CTS: duration of immediately previous RTS minus time in ieee80211_duration()
120 if (group_addr) /* Group address as the destination - no ACK */ in ieee80211_duration()
126 * basic rate set that is less than or equal to the rate of the in ieee80211_duration()
129 * the highest mandatory rate of the PHY that is less than or equal to in ieee80211_duration()
130 * the rate of the previous frame is used. in ieee80211_duration()
133 rate = -1; in ieee80211_duration()
135 mrate = sband->bitrates[0].bitrate; in ieee80211_duration()
136 for (i = 0; i < sband->n_bitrates; i++) { in ieee80211_duration()
137 struct ieee80211_rate *r = &sband->bitrates[i]; in ieee80211_duration()
139 if (r->bitrate > txrate->bitrate) in ieee80211_duration()
142 if ((rate_flags & r->flags) != rate_flags) in ieee80211_duration()
145 if (tx->sdata->vif.bss_conf.basic_rates & BIT(i)) in ieee80211_duration()
146 rate = DIV_ROUND_UP(r->bitrate, 1 << shift); in ieee80211_duration()
148 switch (sband->band) { in ieee80211_duration()
151 if (tx->sdata->flags & IEEE80211_SDATA_OPERATING_GMODE) in ieee80211_duration()
155 if (r->flags & flag) in ieee80211_duration()
156 mrate = r->bitrate; in ieee80211_duration()
161 if (r->flags & IEEE80211_RATE_MANDATORY_A) in ieee80211_duration()
162 mrate = r->bitrate; in ieee80211_duration()
172 if (rate == -1) { in ieee80211_duration()
179 if (ieee80211_is_data_qos(hdr->frame_control) && in ieee80211_duration()
184 * (10 bytes + 4-byte FCS = 112 bits) plus SIFS; rounded up in ieee80211_duration()
186 dur = ieee80211_frame_duration(sband->band, 10, rate, erp, in ieee80211_duration()
187 tx->sdata->vif.bss_conf.use_short_preamble, in ieee80211_duration()
195 dur += ieee80211_frame_duration(sband->band, next_frag_len, in ieee80211_duration()
196 txrate->bitrate, erp, in ieee80211_duration()
197 tx->sdata->vif.bss_conf.use_short_preamble, in ieee80211_duration()
208 struct ieee80211_local *local = tx->local; in ieee80211_tx_h_dynamic_ps()
210 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); in ieee80211_tx_h_dynamic_ps()
213 if (!ieee80211_hw_check(&local->hw, SUPPORTS_PS)) in ieee80211_tx_h_dynamic_ps()
217 if (ieee80211_hw_check(&local->hw, SUPPORTS_DYNAMIC_PS)) in ieee80211_tx_h_dynamic_ps()
221 if (local->hw.conf.dynamic_ps_timeout <= 0) in ieee80211_tx_h_dynamic_ps()
225 if (local->scanning) in ieee80211_tx_h_dynamic_ps()
228 if (!local->ps_sdata) in ieee80211_tx_h_dynamic_ps()
232 if (local->quiescing) in ieee80211_tx_h_dynamic_ps()
236 if (tx->sdata->vif.type != NL80211_IFTYPE_STATION) in ieee80211_tx_h_dynamic_ps()
239 if (unlikely(info->flags & IEEE80211_TX_INTFL_OFFCHAN_TX_OK)) in ieee80211_tx_h_dynamic_ps()
242 ifmgd = &tx->sdata->u.mgd; in ieee80211_tx_h_dynamic_ps()
245 * Don't wakeup from power save if u-apsd is enabled, voip ac has in ieee80211_tx_h_dynamic_ps()
246 * u-apsd enabled and the frame is in voip class. This effectively in ieee80211_tx_h_dynamic_ps()
247 * means that even if all access categories have u-apsd enabled, in in ieee80211_tx_h_dynamic_ps()
248 * practise u-apsd is only used with the voip ac. This is a in ieee80211_tx_h_dynamic_ps()
253 * Note: ifmgd->uapsd_queues access is racy here. If the value is in ieee80211_tx_h_dynamic_ps()
257 if ((ifmgd->flags & IEEE80211_STA_UAPSD_ENABLED) && in ieee80211_tx_h_dynamic_ps()
258 (ifmgd->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VO) && in ieee80211_tx_h_dynamic_ps()
259 skb_get_queue_mapping(tx->skb) == IEEE80211_AC_VO) in ieee80211_tx_h_dynamic_ps()
262 if (local->hw.conf.flags & IEEE80211_CONF_PS) { in ieee80211_tx_h_dynamic_ps()
263 ieee80211_stop_queues_by_reason(&local->hw, in ieee80211_tx_h_dynamic_ps()
267 ifmgd->flags &= ~IEEE80211_STA_NULLFUNC_ACKED; in ieee80211_tx_h_dynamic_ps()
268 ieee80211_queue_work(&local->hw, in ieee80211_tx_h_dynamic_ps()
269 &local->dynamic_ps_disable_work); in ieee80211_tx_h_dynamic_ps()
273 if (!ifmgd->associated) in ieee80211_tx_h_dynamic_ps()
276 mod_timer(&local->dynamic_ps_timer, jiffies + in ieee80211_tx_h_dynamic_ps()
277 msecs_to_jiffies(local->hw.conf.dynamic_ps_timeout)); in ieee80211_tx_h_dynamic_ps()
286 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; in ieee80211_tx_h_check_assoc()
287 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); in ieee80211_tx_h_check_assoc()
290 if (unlikely(info->flags & IEEE80211_TX_CTL_INJECTED)) in ieee80211_tx_h_check_assoc()
293 if (unlikely(test_bit(SCAN_SW_SCANNING, &tx->local->scanning)) && in ieee80211_tx_h_check_assoc()
294 test_bit(SDATA_STATE_OFFCHANNEL, &tx->sdata->state) && in ieee80211_tx_h_check_assoc()
295 !ieee80211_is_probe_req(hdr->frame_control) && in ieee80211_tx_h_check_assoc()
296 !ieee80211_is_any_nullfunc(hdr->frame_control)) in ieee80211_tx_h_check_assoc()
303 * off-channel. See the link below and in ieee80211_tx_h_check_assoc()
310 if (tx->sdata->vif.type == NL80211_IFTYPE_OCB) in ieee80211_tx_h_check_assoc()
313 if (tx->flags & IEEE80211_TX_PS_BUFFERED) in ieee80211_tx_h_check_assoc()
316 if (tx->sta) in ieee80211_tx_h_check_assoc()
317 assoc = test_sta_flag(tx->sta, WLAN_STA_ASSOC); in ieee80211_tx_h_check_assoc()
319 if (likely(tx->flags & IEEE80211_TX_UNICAST)) { in ieee80211_tx_h_check_assoc()
321 ieee80211_is_data(hdr->frame_control))) { in ieee80211_tx_h_check_assoc()
323 sdata_info(tx->sdata, in ieee80211_tx_h_check_assoc()
325 hdr->addr1); in ieee80211_tx_h_check_assoc()
327 I802_DEBUG_INC(tx->local->tx_handlers_drop_not_assoc); in ieee80211_tx_h_check_assoc()
330 } else if (unlikely(ieee80211_is_data(hdr->frame_control) && in ieee80211_tx_h_check_assoc()
331 ieee80211_vif_get_num_mcast_if(tx->sdata) == 0)) { in ieee80211_tx_h_check_assoc()
333 * No associated STAs - no need to send multicast in ieee80211_tx_h_check_assoc()
343 * of buffered frames for power saving STAs. This situation should not really
353 list_for_each_entry_rcu(sdata, &local->interfaces, list) { in purge_old_ps_buffers()
356 if (sdata->vif.type == NL80211_IFTYPE_AP) in purge_old_ps_buffers()
357 ps = &sdata->u.ap.ps; in purge_old_ps_buffers()
358 else if (ieee80211_vif_is_mesh(&sdata->vif)) in purge_old_ps_buffers()
359 ps = &sdata->u.mesh.ps; in purge_old_ps_buffers()
363 skb = skb_dequeue(&ps->bc_buf); in purge_old_ps_buffers()
366 ieee80211_free_txskb(&local->hw, skb); in purge_old_ps_buffers()
368 total += skb_queue_len(&ps->bc_buf); in purge_old_ps_buffers()
372 * Drop one frame from each station from the lowest-priority in purge_old_ps_buffers()
375 list_for_each_entry_rcu(sta, &local->sta_list, list) { in purge_old_ps_buffers()
378 for (ac = IEEE80211_AC_BK; ac >= IEEE80211_AC_VO; ac--) { in purge_old_ps_buffers()
379 skb = skb_dequeue(&sta->ps_tx_buf[ac]); in purge_old_ps_buffers()
380 total += skb_queue_len(&sta->ps_tx_buf[ac]); in purge_old_ps_buffers()
383 ieee80211_free_txskb(&local->hw, skb); in purge_old_ps_buffers()
389 local->total_ps_buffered = total; in purge_old_ps_buffers()
390 ps_dbg_hw(&local->hw, "PS buffers full - purged %d frames\n", purged); in purge_old_ps_buffers()
396 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); in ieee80211_tx_h_multicast_ps_buf()
397 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; in ieee80211_tx_h_multicast_ps_buf()
403 * If any of the associated/peer stations is in power save mode, in ieee80211_tx_h_multicast_ps_buf()
409 if (tx->sdata->vif.type == NL80211_IFTYPE_AP || in ieee80211_tx_h_multicast_ps_buf()
410 tx->sdata->vif.type == NL80211_IFTYPE_AP_VLAN) { in ieee80211_tx_h_multicast_ps_buf()
411 if (!tx->sdata->bss) in ieee80211_tx_h_multicast_ps_buf()
414 ps = &tx->sdata->bss->ps; in ieee80211_tx_h_multicast_ps_buf()
415 } else if (ieee80211_vif_is_mesh(&tx->sdata->vif)) { in ieee80211_tx_h_multicast_ps_buf()
416 ps = &tx->sdata->u.mesh.ps; in ieee80211_tx_h_multicast_ps_buf()
423 if (ieee80211_has_order(hdr->frame_control)) in ieee80211_tx_h_multicast_ps_buf()
426 if (ieee80211_is_probe_req(hdr->frame_control)) in ieee80211_tx_h_multicast_ps_buf()
429 if (ieee80211_hw_check(&tx->local->hw, QUEUE_CONTROL)) in ieee80211_tx_h_multicast_ps_buf()
430 info->hw_queue = tx->sdata->vif.cab_queue; in ieee80211_tx_h_multicast_ps_buf()
433 if (!atomic_read(&ps->num_sta_ps) && skb_queue_empty(&ps->bc_buf)) in ieee80211_tx_h_multicast_ps_buf()
436 info->flags |= IEEE80211_TX_CTL_SEND_AFTER_DTIM; in ieee80211_tx_h_multicast_ps_buf()
439 if (!ieee80211_hw_check(&tx->local->hw, HOST_BROADCAST_PS_BUFFERING)) in ieee80211_tx_h_multicast_ps_buf()
443 if (tx->local->total_ps_buffered >= TOTAL_MAX_TX_BUFFER) in ieee80211_tx_h_multicast_ps_buf()
444 purge_old_ps_buffers(tx->local); in ieee80211_tx_h_multicast_ps_buf()
446 if (skb_queue_len(&ps->bc_buf) >= AP_MAX_BC_BUFFER) { in ieee80211_tx_h_multicast_ps_buf()
447 ps_dbg(tx->sdata, in ieee80211_tx_h_multicast_ps_buf()
448 "BC TX buffer full - dropping the oldest frame\n"); in ieee80211_tx_h_multicast_ps_buf()
449 ieee80211_free_txskb(&tx->local->hw, skb_dequeue(&ps->bc_buf)); in ieee80211_tx_h_multicast_ps_buf()
451 tx->local->total_ps_buffered++; in ieee80211_tx_h_multicast_ps_buf()
453 skb_queue_tail(&ps->bc_buf, tx->skb); in ieee80211_tx_h_multicast_ps_buf()
476 struct sta_info *sta = tx->sta; in ieee80211_tx_h_unicast_ps_buf()
477 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); in ieee80211_tx_h_unicast_ps_buf()
478 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; in ieee80211_tx_h_unicast_ps_buf()
479 struct ieee80211_local *local = tx->local; in ieee80211_tx_h_unicast_ps_buf()
487 !(info->flags & IEEE80211_TX_CTL_NO_PS_BUFFER))) { in ieee80211_tx_h_unicast_ps_buf()
488 int ac = skb_get_queue_mapping(tx->skb); in ieee80211_tx_h_unicast_ps_buf()
490 if (ieee80211_is_mgmt(hdr->frame_control) && in ieee80211_tx_h_unicast_ps_buf()
491 !ieee80211_is_bufferable_mmpdu(hdr->frame_control)) { in ieee80211_tx_h_unicast_ps_buf()
492 info->flags |= IEEE80211_TX_CTL_NO_PS_BUFFER; in ieee80211_tx_h_unicast_ps_buf()
496 ps_dbg(sta->sdata, "STA %pM aid %d: PS buffer for AC %d\n", in ieee80211_tx_h_unicast_ps_buf()
497 sta->sta.addr, sta->sta.aid, ac); in ieee80211_tx_h_unicast_ps_buf()
498 if (tx->local->total_ps_buffered >= TOTAL_MAX_TX_BUFFER) in ieee80211_tx_h_unicast_ps_buf()
499 purge_old_ps_buffers(tx->local); in ieee80211_tx_h_unicast_ps_buf()
502 spin_lock(&sta->ps_lock); in ieee80211_tx_h_unicast_ps_buf()
511 spin_unlock(&sta->ps_lock); in ieee80211_tx_h_unicast_ps_buf()
515 if (skb_queue_len(&sta->ps_tx_buf[ac]) >= STA_MAX_TX_BUFFER) { in ieee80211_tx_h_unicast_ps_buf()
516 struct sk_buff *old = skb_dequeue(&sta->ps_tx_buf[ac]); in ieee80211_tx_h_unicast_ps_buf()
517 ps_dbg(tx->sdata, in ieee80211_tx_h_unicast_ps_buf()
518 "STA %pM TX buffer for AC %d full - dropping oldest frame\n", in ieee80211_tx_h_unicast_ps_buf()
519 sta->sta.addr, ac); in ieee80211_tx_h_unicast_ps_buf()
520 ieee80211_free_txskb(&local->hw, old); in ieee80211_tx_h_unicast_ps_buf()
522 tx->local->total_ps_buffered++; in ieee80211_tx_h_unicast_ps_buf()
524 info->control.jiffies = jiffies; in ieee80211_tx_h_unicast_ps_buf()
525 info->control.vif = &tx->sdata->vif; in ieee80211_tx_h_unicast_ps_buf()
526 info->control.flags |= IEEE80211_TX_INTCFL_NEED_TXPROCESSING; in ieee80211_tx_h_unicast_ps_buf()
527 info->flags &= ~IEEE80211_TX_TEMPORARY_FLAGS; in ieee80211_tx_h_unicast_ps_buf()
528 skb_queue_tail(&sta->ps_tx_buf[ac], tx->skb); in ieee80211_tx_h_unicast_ps_buf()
529 spin_unlock(&sta->ps_lock); in ieee80211_tx_h_unicast_ps_buf()
531 if (!timer_pending(&local->sta_cleanup)) in ieee80211_tx_h_unicast_ps_buf()
532 mod_timer(&local->sta_cleanup, in ieee80211_tx_h_unicast_ps_buf()
544 ps_dbg(tx->sdata, in ieee80211_tx_h_unicast_ps_buf()
545 "STA %pM in PS mode, but polling/in SP -> send frame\n", in ieee80211_tx_h_unicast_ps_buf()
546 sta->sta.addr); in ieee80211_tx_h_unicast_ps_buf()
555 if (unlikely(tx->flags & IEEE80211_TX_PS_BUFFERED)) in ieee80211_tx_h_ps_buf()
558 if (tx->flags & IEEE80211_TX_UNICAST) in ieee80211_tx_h_ps_buf()
567 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); in ieee80211_tx_h_check_control_port_protocol()
569 if (unlikely(tx->sdata->control_port_protocol == tx->skb->protocol)) { in ieee80211_tx_h_check_control_port_protocol()
570 if (tx->sdata->control_port_no_encrypt) in ieee80211_tx_h_check_control_port_protocol()
571 info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; in ieee80211_tx_h_check_control_port_protocol()
572 info->control.flags |= IEEE80211_TX_CTRL_PORT_CTRL_PROTO; in ieee80211_tx_h_check_control_port_protocol()
573 info->flags |= IEEE80211_TX_CTL_USE_MINRATE; in ieee80211_tx_h_check_control_port_protocol()
583 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); in ieee80211_tx_h_select_key()
584 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; in ieee80211_tx_h_select_key()
586 if (unlikely(info->flags & IEEE80211_TX_INTFL_DONT_ENCRYPT)) { in ieee80211_tx_h_select_key()
587 tx->key = NULL; in ieee80211_tx_h_select_key()
591 if (tx->sta && in ieee80211_tx_h_select_key()
592 (key = rcu_dereference(tx->sta->ptk[tx->sta->ptk_idx]))) in ieee80211_tx_h_select_key()
593 tx->key = key; in ieee80211_tx_h_select_key()
594 else if (ieee80211_is_group_privacy_action(tx->skb) && in ieee80211_tx_h_select_key()
595 (key = rcu_dereference(tx->sdata->default_multicast_key))) in ieee80211_tx_h_select_key()
596 tx->key = key; in ieee80211_tx_h_select_key()
597 else if (ieee80211_is_mgmt(hdr->frame_control) && in ieee80211_tx_h_select_key()
598 is_multicast_ether_addr(hdr->addr1) && in ieee80211_tx_h_select_key()
599 ieee80211_is_robust_mgmt_frame(tx->skb) && in ieee80211_tx_h_select_key()
600 (key = rcu_dereference(tx->sdata->default_mgmt_key))) in ieee80211_tx_h_select_key()
601 tx->key = key; in ieee80211_tx_h_select_key()
602 else if (is_multicast_ether_addr(hdr->addr1) && in ieee80211_tx_h_select_key()
603 (key = rcu_dereference(tx->sdata->default_multicast_key))) in ieee80211_tx_h_select_key()
604 tx->key = key; in ieee80211_tx_h_select_key()
605 else if (!is_multicast_ether_addr(hdr->addr1) && in ieee80211_tx_h_select_key()
606 (key = rcu_dereference(tx->sdata->default_unicast_key))) in ieee80211_tx_h_select_key()
607 tx->key = key; in ieee80211_tx_h_select_key()
609 tx->key = NULL; in ieee80211_tx_h_select_key()
611 if (tx->key) { in ieee80211_tx_h_select_key()
616 switch (tx->key->conf.cipher) { in ieee80211_tx_h_select_key()
620 if (!ieee80211_is_data_present(hdr->frame_control)) in ieee80211_tx_h_select_key()
621 tx->key = NULL; in ieee80211_tx_h_select_key()
627 if (!ieee80211_is_data_present(hdr->frame_control) && in ieee80211_tx_h_select_key()
628 !ieee80211_use_mfp(hdr->frame_control, tx->sta, in ieee80211_tx_h_select_key()
629 tx->skb) && in ieee80211_tx_h_select_key()
630 !ieee80211_is_group_privacy_action(tx->skb)) in ieee80211_tx_h_select_key()
631 tx->key = NULL; in ieee80211_tx_h_select_key()
633 skip_hw = (tx->key->conf.flags & in ieee80211_tx_h_select_key()
635 ieee80211_is_mgmt(hdr->frame_control); in ieee80211_tx_h_select_key()
641 if (!ieee80211_is_mgmt(hdr->frame_control)) in ieee80211_tx_h_select_key()
642 tx->key = NULL; in ieee80211_tx_h_select_key()
646 if (unlikely(tx->key && tx->key->flags & KEY_FLAG_TAINTED && in ieee80211_tx_h_select_key()
647 !ieee80211_is_deauth(hdr->frame_control))) in ieee80211_tx_h_select_key()
650 if (!skip_hw && tx->key && in ieee80211_tx_h_select_key()
651 tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) in ieee80211_tx_h_select_key()
652 info->control.hw_key = &tx->key->conf; in ieee80211_tx_h_select_key()
653 } else if (ieee80211_is_data_present(hdr->frame_control) && tx->sta && in ieee80211_tx_h_select_key()
654 test_sta_flag(tx->sta, WLAN_STA_USES_ENCRYPTION)) { in ieee80211_tx_h_select_key()
664 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); in ieee80211_tx_h_rate_ctrl()
665 struct ieee80211_hdr *hdr = (void *)tx->skb->data; in ieee80211_tx_h_rate_ctrl()
670 bool encap = info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP; in ieee80211_tx_h_rate_ctrl()
675 sband = tx->local->hw.wiphy->bands[info->band]; in ieee80211_tx_h_rate_ctrl()
677 len = min_t(u32, tx->skb->len + FCS_LEN, in ieee80211_tx_h_rate_ctrl()
678 tx->local->hw.wiphy->frag_threshold); in ieee80211_tx_h_rate_ctrl()
681 txrc.hw = &tx->local->hw; in ieee80211_tx_h_rate_ctrl()
683 txrc.bss_conf = &tx->sdata->vif.bss_conf; in ieee80211_tx_h_rate_ctrl()
684 txrc.skb = tx->skb; in ieee80211_tx_h_rate_ctrl()
685 txrc.reported_rate.idx = -1; in ieee80211_tx_h_rate_ctrl()
686 txrc.rate_idx_mask = tx->sdata->rc_rateidx_mask[info->band]; in ieee80211_tx_h_rate_ctrl()
688 if (tx->sdata->rc_has_mcs_mask[info->band]) in ieee80211_tx_h_rate_ctrl()
690 tx->sdata->rc_rateidx_mcs_mask[info->band]; in ieee80211_tx_h_rate_ctrl()
692 txrc.bss = (tx->sdata->vif.type == NL80211_IFTYPE_AP || in ieee80211_tx_h_rate_ctrl()
693 tx->sdata->vif.type == NL80211_IFTYPE_MESH_POINT || in ieee80211_tx_h_rate_ctrl()
694 tx->sdata->vif.type == NL80211_IFTYPE_ADHOC || in ieee80211_tx_h_rate_ctrl()
695 tx->sdata->vif.type == NL80211_IFTYPE_OCB); in ieee80211_tx_h_rate_ctrl()
698 if (len > tx->local->hw.wiphy->rts_threshold) { in ieee80211_tx_h_rate_ctrl()
702 info->control.use_rts = txrc.rts; in ieee80211_tx_h_rate_ctrl()
703 info->control.use_cts_prot = tx->sdata->vif.bss_conf.use_cts_prot; in ieee80211_tx_h_rate_ctrl()
708 * that -- the management frame might be to a station that in ieee80211_tx_h_rate_ctrl()
711 if (tx->sdata->vif.bss_conf.use_short_preamble && in ieee80211_tx_h_rate_ctrl()
712 (ieee80211_is_tx_data(tx->skb) || in ieee80211_tx_h_rate_ctrl()
713 (tx->sta && test_sta_flag(tx->sta, WLAN_STA_SHORT_PREAMBLE)))) in ieee80211_tx_h_rate_ctrl()
716 info->control.short_preamble = txrc.short_preamble; in ieee80211_tx_h_rate_ctrl()
719 if (info->control.flags & IEEE80211_TX_CTRL_RATE_INJECT) in ieee80211_tx_h_rate_ctrl()
722 if (tx->sta) in ieee80211_tx_h_rate_ctrl()
723 assoc = test_sta_flag(tx->sta, WLAN_STA_ASSOC); in ieee80211_tx_h_rate_ctrl()
729 if (WARN(test_bit(SCAN_SW_SCANNING, &tx->local->scanning) && assoc && in ieee80211_tx_h_rate_ctrl()
730 !rate_usable_index_exists(sband, &tx->sta->sta), in ieee80211_tx_h_rate_ctrl()
733 "%pM on %d GHz band\n", in ieee80211_tx_h_rate_ctrl()
734 tx->sdata->name, in ieee80211_tx_h_rate_ctrl()
735 encap ? ((struct ethhdr *)hdr)->h_dest : hdr->addr1, in ieee80211_tx_h_rate_ctrl()
736 info->band ? 5 : 2)) in ieee80211_tx_h_rate_ctrl()
743 rate_control_get_rate(tx->sdata, tx->sta, &txrc); in ieee80211_tx_h_rate_ctrl()
745 if (tx->sta && !info->control.skip_table) in ieee80211_tx_h_rate_ctrl()
746 ratetbl = rcu_dereference(tx->sta->sta.rates); in ieee80211_tx_h_rate_ctrl()
748 if (unlikely(info->control.rates[0].idx < 0)) { in ieee80211_tx_h_rate_ctrl()
751 .idx = ratetbl->rate[0].idx, in ieee80211_tx_h_rate_ctrl()
752 .flags = ratetbl->rate[0].flags, in ieee80211_tx_h_rate_ctrl()
753 .count = ratetbl->rate[0].count in ieee80211_tx_h_rate_ctrl()
756 if (ratetbl->rate[0].idx < 0) in ieee80211_tx_h_rate_ctrl()
759 tx->rate = rate; in ieee80211_tx_h_rate_ctrl()
764 tx->rate = info->control.rates[0]; in ieee80211_tx_h_rate_ctrl()
768 txrc.reported_rate = tx->rate; in ieee80211_tx_h_rate_ctrl()
769 if (tx->sta && ieee80211_is_tx_data(tx->skb)) in ieee80211_tx_h_rate_ctrl()
770 tx->sta->tx_stats.last_rate = txrc.reported_rate; in ieee80211_tx_h_rate_ctrl()
771 } else if (tx->sta) in ieee80211_tx_h_rate_ctrl()
772 tx->sta->tx_stats.last_rate = txrc.reported_rate; in ieee80211_tx_h_rate_ctrl()
777 if (unlikely(!info->control.rates[0].count)) in ieee80211_tx_h_rate_ctrl()
778 info->control.rates[0].count = 1; in ieee80211_tx_h_rate_ctrl()
780 if (WARN_ON_ONCE((info->control.rates[0].count > 1) && in ieee80211_tx_h_rate_ctrl()
781 (info->flags & IEEE80211_TX_CTL_NO_ACK))) in ieee80211_tx_h_rate_ctrl()
782 info->control.rates[0].count = 1; in ieee80211_tx_h_rate_ctrl()
789 u16 *seq = &sta->tid_seq[tid]; in ieee80211_tx_next_seq()
801 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); in ieee80211_tx_h_sequence()
802 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; in ieee80211_tx_h_sequence()
810 if (unlikely(info->control.vif->type == NL80211_IFTYPE_MONITOR)) in ieee80211_tx_h_sequence()
813 if (unlikely(ieee80211_is_ctl(hdr->frame_control))) in ieee80211_tx_h_sequence()
816 if (ieee80211_hdrlen(hdr->frame_control) < 24) in ieee80211_tx_h_sequence()
819 if (ieee80211_is_qos_nullfunc(hdr->frame_control)) in ieee80211_tx_h_sequence()
822 if (info->control.flags & IEEE80211_TX_CTRL_NO_SEQNO) in ieee80211_tx_h_sequence()
829 * also use the global counter (802.11-2012 9.3.2.10). in ieee80211_tx_h_sequence()
831 if (!ieee80211_is_data_qos(hdr->frame_control) || in ieee80211_tx_h_sequence()
832 is_multicast_ether_addr(hdr->addr1)) { in ieee80211_tx_h_sequence()
834 info->flags |= IEEE80211_TX_CTL_ASSIGN_SEQ; in ieee80211_tx_h_sequence()
836 hdr->seq_ctrl = cpu_to_le16(tx->sdata->sequence_number); in ieee80211_tx_h_sequence()
837 tx->sdata->sequence_number += 0x10; in ieee80211_tx_h_sequence()
838 if (tx->sta) in ieee80211_tx_h_sequence()
839 tx->sta->tx_stats.msdu[IEEE80211_NUM_TIDS]++; in ieee80211_tx_h_sequence()
846 * above since they are not QoS-data frames. in ieee80211_tx_h_sequence()
848 if (!tx->sta) in ieee80211_tx_h_sequence()
851 /* include per-STA, per-TID sequence counter */ in ieee80211_tx_h_sequence()
853 tx->sta->tx_stats.msdu[tid]++; in ieee80211_tx_h_sequence()
855 hdr->seq_ctrl = ieee80211_tx_next_seq(tx->sta, tid); in ieee80211_tx_h_sequence()
864 struct ieee80211_local *local = tx->local; in ieee80211_fragment()
867 int per_fragm = frag_threshold - hdrlen - FCS_LEN; in ieee80211_fragment()
869 int rem = skb->len - hdrlen - per_fragm; in ieee80211_fragment()
872 return -EINVAL; in ieee80211_fragment()
881 rem -= fraglen; in ieee80211_fragment()
882 tmp = dev_alloc_skb(local->tx_headroom + in ieee80211_fragment()
884 tx->sdata->encrypt_headroom + in ieee80211_fragment()
887 return -ENOMEM; in ieee80211_fragment()
889 __skb_queue_tail(&tx->skbs, tmp); in ieee80211_fragment()
892 local->tx_headroom + tx->sdata->encrypt_headroom); in ieee80211_fragment()
895 memcpy(tmp->cb, skb->cb, sizeof(tmp->cb)); in ieee80211_fragment()
898 info->flags &= ~(IEEE80211_TX_CTL_CLEAR_PS_FILT | in ieee80211_fragment()
902 info->flags |= IEEE80211_TX_CTL_MORE_FRAMES; in ieee80211_fragment()
905 tmp->priority = skb->priority; in ieee80211_fragment()
906 tmp->dev = skb->dev; in ieee80211_fragment()
909 skb_put_data(tmp, skb->data, hdrlen); in ieee80211_fragment()
910 skb_put_data(tmp, skb->data + pos, fraglen); in ieee80211_fragment()
923 struct sk_buff *skb = tx->skb; in ieee80211_tx_h_fragment()
925 struct ieee80211_hdr *hdr = (void *)skb->data; in ieee80211_tx_h_fragment()
926 int frag_threshold = tx->local->hw.wiphy->frag_threshold; in ieee80211_tx_h_fragment()
930 /* no matter what happens, tx->skb moves to tx->skbs */ in ieee80211_tx_h_fragment()
931 __skb_queue_tail(&tx->skbs, skb); in ieee80211_tx_h_fragment()
932 tx->skb = NULL; in ieee80211_tx_h_fragment()
934 if (info->flags & IEEE80211_TX_CTL_DONTFRAG) in ieee80211_tx_h_fragment()
937 if (ieee80211_hw_check(&tx->local->hw, SUPPORTS_TX_FRAG)) in ieee80211_tx_h_fragment()
941 * Warn when submitting a fragmented A-MPDU frame and drop it. in ieee80211_tx_h_fragment()
945 if (WARN_ON(info->flags & IEEE80211_TX_CTL_AMPDU)) in ieee80211_tx_h_fragment()
948 hdrlen = ieee80211_hdrlen(hdr->frame_control); in ieee80211_tx_h_fragment()
951 if (WARN_ON(skb->len + FCS_LEN <= frag_threshold)) in ieee80211_tx_h_fragment()
956 * chain them (using skb as the first fragment) to skb->next. in ieee80211_tx_h_fragment()
958 * fragments from this list. When the low-level driver rejects one in ieee80211_tx_h_fragment()
959 * of the fragments then we will simply pretend to accept the skb in ieee80211_tx_h_fragment()
965 /* update duration/seq/flags of fragments */ in ieee80211_tx_h_fragment()
968 skb_queue_walk(&tx->skbs, skb) { in ieee80211_tx_h_fragment()
971 hdr = (void *)skb->data; in ieee80211_tx_h_fragment()
974 if (!skb_queue_is_last(&tx->skbs, skb)) { in ieee80211_tx_h_fragment()
975 hdr->frame_control |= morefrags; in ieee80211_tx_h_fragment()
977 * No multi-rate retries for fragmented frames, that in ieee80211_tx_h_fragment()
980 info->control.rates[1].idx = -1; in ieee80211_tx_h_fragment()
981 info->control.rates[2].idx = -1; in ieee80211_tx_h_fragment()
982 info->control.rates[3].idx = -1; in ieee80211_tx_h_fragment()
984 info->flags &= ~IEEE80211_TX_CTL_RATE_CTRL_PROBE; in ieee80211_tx_h_fragment()
986 hdr->frame_control &= ~morefrags; in ieee80211_tx_h_fragment()
988 hdr->seq_ctrl |= cpu_to_le16(fragnum & IEEE80211_SCTL_FRAG); in ieee80211_tx_h_fragment()
999 int ac = -1; in ieee80211_tx_h_stats()
1001 if (!tx->sta) in ieee80211_tx_h_stats()
1004 skb_queue_walk(&tx->skbs, skb) { in ieee80211_tx_h_stats()
1006 tx->sta->tx_stats.bytes[ac] += skb->len; in ieee80211_tx_h_stats()
1009 tx->sta->tx_stats.packets[ac]++; in ieee80211_tx_h_stats()
1017 if (!tx->key) in ieee80211_tx_h_encrypt()
1020 switch (tx->key->conf.cipher) { in ieee80211_tx_h_encrypt()
1057 skb_queue_walk(&tx->skbs, skb) { in ieee80211_tx_h_calculate_duration()
1058 hdr = (void *) skb->data; in ieee80211_tx_h_calculate_duration()
1059 if (unlikely(ieee80211_is_pspoll(hdr->frame_control))) in ieee80211_tx_h_calculate_duration()
1061 if (!skb_queue_is_last(&tx->skbs, skb)) { in ieee80211_tx_h_calculate_duration()
1062 struct sk_buff *next = skb_queue_next(&tx->skbs, skb); in ieee80211_tx_h_calculate_duration()
1063 next_len = next->len; in ieee80211_tx_h_calculate_duration()
1066 group_addr = is_multicast_ether_addr(hdr->addr1); in ieee80211_tx_h_calculate_duration()
1068 hdr->duration_id = in ieee80211_tx_h_calculate_duration()
1087 if (test_bit(HT_AGG_STATE_OPERATIONAL, &tid_tx->state)) { in ieee80211_tx_prep_agg()
1088 info->flags |= IEEE80211_TX_CTL_AMPDU; in ieee80211_tx_prep_agg()
1090 } else if (test_bit(HT_AGG_STATE_WANT_START, &tid_tx->state)) { in ieee80211_tx_prep_agg()
1092 * nothing -- this aggregation session is being started in ieee80211_tx_prep_agg()
1095 } else if (!tx->sta->sta.txq[tid]) { in ieee80211_tx_prep_agg()
1096 spin_lock(&tx->sta->lock); in ieee80211_tx_prep_agg()
1098 * Need to re-check now, because we may get here in ieee80211_tx_prep_agg()
1103 * queue yet -- if this happened we acquire the lock in ieee80211_tx_prep_agg()
1105 * need to recheck which of these cases happened. in ieee80211_tx_prep_agg()
1110 * before it was assigned) -- in this case it may in ieee80211_tx_prep_agg()
1115 tid_tx = rcu_dereference_protected_tid_tx(tx->sta, tid); in ieee80211_tx_prep_agg()
1119 } else if (test_bit(HT_AGG_STATE_OPERATIONAL, &tid_tx->state)) { in ieee80211_tx_prep_agg()
1120 info->flags |= IEEE80211_TX_CTL_AMPDU; in ieee80211_tx_prep_agg()
1124 if (info->flags & IEEE80211_TX_CTL_NO_PS_BUFFER) { in ieee80211_tx_prep_agg()
1125 clear_sta_flag(tx->sta, WLAN_STA_SP); in ieee80211_tx_prep_agg()
1126 ps_dbg(tx->sta->sdata, in ieee80211_tx_prep_agg()
1128 tx->sta->sta.addr, tx->sta->sta.aid); in ieee80211_tx_prep_agg()
1130 info->control.vif = &tx->sdata->vif; in ieee80211_tx_prep_agg()
1131 info->control.flags |= IEEE80211_TX_INTCFL_NEED_TXPROCESSING; in ieee80211_tx_prep_agg()
1132 info->flags &= ~IEEE80211_TX_TEMPORARY_FLAGS; in ieee80211_tx_prep_agg()
1133 __skb_queue_tail(&tid_tx->pending, skb); in ieee80211_tx_prep_agg()
1134 if (skb_queue_len(&tid_tx->pending) > STA_MAX_TX_BUFFER) in ieee80211_tx_prep_agg()
1135 purge_skb = __skb_dequeue(&tid_tx->pending); in ieee80211_tx_prep_agg()
1137 spin_unlock(&tx->sta->lock); in ieee80211_tx_prep_agg()
1140 ieee80211_free_txskb(&tx->local->hw, purge_skb); in ieee80211_tx_prep_agg()
1145 tid_tx->last_tx = jiffies; in ieee80211_tx_prep_agg()
1155 struct rate_control_ref *ref = sdata->local->rate_ctrl; in ieee80211_aggr_check()
1158 if (!ref || !(ref->ops->capa & RATE_CTRL_CAPA_AMPDU_TRIGGER)) in ieee80211_aggr_check()
1161 if (!sta || !sta->sta.ht_cap.ht_supported || in ieee80211_aggr_check()
1162 !sta->sta.wme || skb_get_queue_mapping(skb) == IEEE80211_AC_VO || in ieee80211_aggr_check()
1163 skb->protocol == sdata->control_port_protocol) in ieee80211_aggr_check()
1166 tid = skb->priority & IEEE80211_QOS_CTL_TID_MASK; in ieee80211_aggr_check()
1167 if (likely(sta->ampdu_mlme.tid_tx[tid])) in ieee80211_aggr_check()
1170 ieee80211_start_tx_ba_session(&sta->sta, tid, 0); in ieee80211_aggr_check()
1183 struct ieee80211_local *local = sdata->local; in ieee80211_tx_prepare()
1190 tx->skb = skb; in ieee80211_tx_prepare()
1191 tx->local = local; in ieee80211_tx_prepare()
1192 tx->sdata = sdata; in ieee80211_tx_prepare()
1193 __skb_queue_head_init(&tx->skbs); in ieee80211_tx_prepare()
1200 info->control.flags &= ~IEEE80211_TX_INTCFL_NEED_TXPROCESSING; in ieee80211_tx_prepare()
1202 hdr = (struct ieee80211_hdr *) skb->data; in ieee80211_tx_prepare()
1206 tx->sta = sta; in ieee80211_tx_prepare()
1208 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) { in ieee80211_tx_prepare()
1209 tx->sta = rcu_dereference(sdata->u.vlan.sta); in ieee80211_tx_prepare()
1210 if (!tx->sta && sdata->wdev.use_4addr) in ieee80211_tx_prepare()
1212 } else if (tx->sdata->control_port_protocol == tx->skb->protocol) { in ieee80211_tx_prepare()
1213 tx->sta = sta_info_get_bss(sdata, hdr->addr1); in ieee80211_tx_prepare()
1215 if (!tx->sta && !is_multicast_ether_addr(hdr->addr1)) { in ieee80211_tx_prepare()
1216 tx->sta = sta_info_get(sdata, hdr->addr1); in ieee80211_tx_prepare()
1221 if (tx->sta && ieee80211_is_data_qos(hdr->frame_control) && in ieee80211_tx_prepare()
1222 !ieee80211_is_qos_nullfunc(hdr->frame_control) && in ieee80211_tx_prepare()
1223 ieee80211_hw_check(&local->hw, AMPDU_AGGREGATION) && in ieee80211_tx_prepare()
1224 !ieee80211_hw_check(&local->hw, TX_AMPDU_SETUP_IN_HW)) { in ieee80211_tx_prepare()
1228 tid_tx = rcu_dereference(tx->sta->ampdu_mlme.tid_tx[tid]); in ieee80211_tx_prepare()
1230 ieee80211_aggr_check(sdata, tx->sta, skb); in ieee80211_tx_prepare()
1231 tid_tx = rcu_dereference(tx->sta->ampdu_mlme.tid_tx[tid]); in ieee80211_tx_prepare()
1245 if (is_multicast_ether_addr(hdr->addr1)) { in ieee80211_tx_prepare()
1246 tx->flags &= ~IEEE80211_TX_UNICAST; in ieee80211_tx_prepare()
1247 info->flags |= IEEE80211_TX_CTL_NO_ACK; in ieee80211_tx_prepare()
1249 tx->flags |= IEEE80211_TX_UNICAST; in ieee80211_tx_prepare()
1251 if (!(info->flags & IEEE80211_TX_CTL_DONTFRAG)) { in ieee80211_tx_prepare()
1252 if (!(tx->flags & IEEE80211_TX_UNICAST) || in ieee80211_tx_prepare()
1253 skb->len + FCS_LEN <= local->hw.wiphy->frag_threshold || in ieee80211_tx_prepare()
1254 info->flags & IEEE80211_TX_CTL_AMPDU) in ieee80211_tx_prepare()
1255 info->flags |= IEEE80211_TX_CTL_DONTFRAG; in ieee80211_tx_prepare()
1258 if (!tx->sta) in ieee80211_tx_prepare()
1259 info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT; in ieee80211_tx_prepare()
1260 else if (test_and_clear_sta_flag(tx->sta, WLAN_STA_CLEAR_PS_FILT)) { in ieee80211_tx_prepare()
1261 info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT; in ieee80211_tx_prepare()
1262 ieee80211_check_fast_xmit(tx->sta); in ieee80211_tx_prepare()
1265 info->flags |= IEEE80211_TX_CTL_FIRST_FRAGMENT; in ieee80211_tx_prepare()
1275 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; in ieee80211_get_txq()
1279 if ((info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM) || in ieee80211_get_txq()
1280 (info->control.flags & IEEE80211_TX_CTRL_PS_RESPONSE)) in ieee80211_get_txq()
1283 if (!(info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP) && in ieee80211_get_txq()
1284 unlikely(!ieee80211_is_data_present(hdr->frame_control))) { in ieee80211_get_txq()
1285 if ((!ieee80211_is_mgmt(hdr->frame_control) || in ieee80211_get_txq()
1286 ieee80211_is_bufferable_mmpdu(hdr->frame_control) || in ieee80211_get_txq()
1287 vif->type == NL80211_IFTYPE_STATION) && in ieee80211_get_txq()
1288 sta && sta->uploaded) { in ieee80211_get_txq()
1291 * opt-in hardware flag. in ieee80211_get_txq()
1293 txq = sta->sta.txq[IEEE80211_NUM_TIDS]; in ieee80211_get_txq()
1296 u8 tid = skb->priority & IEEE80211_QOS_CTL_TID_MASK; in ieee80211_get_txq()
1298 if (!sta->uploaded) in ieee80211_get_txq()
1301 txq = sta->sta.txq[tid]; in ieee80211_get_txq()
1303 txq = vif->txq; in ieee80211_get_txq()
1314 IEEE80211_SKB_CB(skb)->control.enqueue_time = codel_get_time(); in ieee80211_set_skb_enqueue_time()
1319 return skb->len; in codel_skb_len_func()
1326 info = (const struct ieee80211_tx_info *)skb->cb; in codel_skb_time_func()
1327 return info->control.enqueue_time; in codel_skb_time_func()
1339 local = vif_to_sdata(txqi->txq.vif)->local; in codel_dequeue_func()
1340 fq = &local->fq; in codel_dequeue_func()
1342 if (cvars == &txqi->def_cvars) in codel_dequeue_func()
1343 flow = &txqi->tin.default_flow; in codel_dequeue_func()
1345 flow = &fq->flows[cvars - local->cvars]; in codel_dequeue_func()
1358 local = vif_to_sdata(txqi->txq.vif)->local; in codel_drop_func()
1359 hw = &local->hw; in codel_drop_func()
1376 cstats = &txqi->cstats; in fq_tin_dequeue_func()
1378 if (txqi->txq.sta) { in fq_tin_dequeue_func()
1379 struct sta_info *sta = container_of(txqi->txq.sta, in fq_tin_dequeue_func()
1381 cparams = &sta->cparams; in fq_tin_dequeue_func()
1383 cparams = &local->cparams; in fq_tin_dequeue_func()
1386 if (flow == &tin->default_flow) in fq_tin_dequeue_func()
1387 cvars = &txqi->def_cvars; in fq_tin_dequeue_func()
1389 cvars = &local->cvars[flow - fq->flows]; in fq_tin_dequeue_func()
1392 &flow->backlog, in fq_tin_dequeue_func()
1410 ieee80211_free_txskb(&local->hw, skb); in fq_skb_free_func()
1417 struct fq *fq = &local->fq; in ieee80211_txq_enqueue()
1418 struct fq_tin *tin = &txqi->tin; in ieee80211_txq_enqueue()
1423 spin_lock_bh(&fq->lock); in ieee80211_txq_enqueue()
1430 if (unlikely(txqi->txq.tid == IEEE80211_NUM_TIDS)) { in ieee80211_txq_enqueue()
1431 IEEE80211_SKB_CB(skb)->control.flags |= in ieee80211_txq_enqueue()
1433 __skb_queue_tail(&txqi->frags, skb); in ieee80211_txq_enqueue()
1438 spin_unlock_bh(&fq->lock); in ieee80211_txq_enqueue()
1447 return info->control.vif == data; in fq_vlan_filter_func()
1453 struct fq *fq = &local->fq; in ieee80211_txq_remove_vlan()
1458 if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_AP_VLAN)) in ieee80211_txq_remove_vlan()
1461 ap = container_of(sdata->bss, struct ieee80211_sub_if_data, u.ap); in ieee80211_txq_remove_vlan()
1463 if (!ap->vif.txq) in ieee80211_txq_remove_vlan()
1466 txqi = to_txq_info(ap->vif.txq); in ieee80211_txq_remove_vlan()
1467 tin = &txqi->tin; in ieee80211_txq_remove_vlan()
1469 spin_lock_bh(&fq->lock); in ieee80211_txq_remove_vlan()
1470 fq_tin_filter(fq, tin, fq_vlan_filter_func, &sdata->vif, in ieee80211_txq_remove_vlan()
1472 spin_unlock_bh(&fq->lock); in ieee80211_txq_remove_vlan()
1479 fq_tin_init(&txqi->tin); in ieee80211_txq_init()
1480 codel_vars_init(&txqi->def_cvars); in ieee80211_txq_init()
1481 codel_stats_init(&txqi->cstats); in ieee80211_txq_init()
1482 __skb_queue_head_init(&txqi->frags); in ieee80211_txq_init()
1483 RB_CLEAR_NODE(&txqi->schedule_order); in ieee80211_txq_init()
1485 txqi->txq.vif = &sdata->vif; in ieee80211_txq_init()
1488 sdata->vif.txq = &txqi->txq; in ieee80211_txq_init()
1489 txqi->txq.tid = 0; in ieee80211_txq_init()
1490 txqi->txq.ac = IEEE80211_AC_BE; in ieee80211_txq_init()
1496 if (sdata->vif.type == NL80211_IFTYPE_STATION) { in ieee80211_txq_init()
1498 if (!ieee80211_hw_check(&sdata->local->hw, in ieee80211_txq_init()
1501 } else if (!ieee80211_hw_check(&sdata->local->hw, in ieee80211_txq_init()
1506 txqi->txq.ac = IEEE80211_AC_VO; in ieee80211_txq_init()
1508 txqi->txq.ac = ieee80211_ac_from_tid(tid); in ieee80211_txq_init()
1511 txqi->txq.sta = &sta->sta; in ieee80211_txq_init()
1512 txqi->txq.tid = tid; in ieee80211_txq_init()
1513 sta->sta.txq[tid] = &txqi->txq; in ieee80211_txq_init()
1519 struct fq *fq = &local->fq; in ieee80211_txq_purge()
1520 struct fq_tin *tin = &txqi->tin; in ieee80211_txq_purge()
1522 spin_lock_bh(&fq->lock); in ieee80211_txq_purge()
1524 ieee80211_purge_tx_queue(&local->hw, &txqi->frags); in ieee80211_txq_purge()
1525 spin_unlock_bh(&fq->lock); in ieee80211_txq_purge()
1527 ieee80211_unschedule_txq(&local->hw, &txqi->txq, true); in ieee80211_txq_purge()
1532 if (local->hw.wiphy->txq_limit) in ieee80211_txq_set_params()
1533 local->fq.limit = local->hw.wiphy->txq_limit; in ieee80211_txq_set_params()
1535 local->hw.wiphy->txq_limit = local->fq.limit; in ieee80211_txq_set_params()
1537 if (local->hw.wiphy->txq_memory_limit) in ieee80211_txq_set_params()
1538 local->fq.memory_limit = local->hw.wiphy->txq_memory_limit; in ieee80211_txq_set_params()
1540 local->hw.wiphy->txq_memory_limit = local->fq.memory_limit; in ieee80211_txq_set_params()
1542 if (local->hw.wiphy->txq_quantum) in ieee80211_txq_set_params()
1543 local->fq.quantum = local->hw.wiphy->txq_quantum; in ieee80211_txq_set_params()
1545 local->hw.wiphy->txq_quantum = local->fq.quantum; in ieee80211_txq_set_params()
1550 struct fq *fq = &local->fq; in ieee80211_txq_setup_flows()
1554 enum nl80211_band band; in ieee80211_txq_setup_flows() local
1556 if (!local->ops->wake_tx_queue) in ieee80211_txq_setup_flows()
1565 * queue size. 4 Mbytes is 64 max-size aggregates in 802.11n. in ieee80211_txq_setup_flows()
1567 for (band = 0; band < NUM_NL80211_BANDS; band++) { in ieee80211_txq_setup_flows()
1570 sband = local->hw.wiphy->bands[band]; in ieee80211_txq_setup_flows()
1574 supp_vht = supp_vht || sband->vht_cap.vht_supported; in ieee80211_txq_setup_flows()
1578 fq->memory_limit = 4 << 20; /* 4 Mbytes */ in ieee80211_txq_setup_flows()
1580 codel_params_init(&local->cparams); in ieee80211_txq_setup_flows()
1581 local->cparams.interval = MS2TIME(100); in ieee80211_txq_setup_flows()
1582 local->cparams.target = MS2TIME(20); in ieee80211_txq_setup_flows()
1583 local->cparams.ecn = true; in ieee80211_txq_setup_flows()
1585 local->cvars = kcalloc(fq->flows_cnt, sizeof(local->cvars[0]), in ieee80211_txq_setup_flows()
1587 if (!local->cvars) { in ieee80211_txq_setup_flows()
1588 spin_lock_bh(&fq->lock); in ieee80211_txq_setup_flows()
1590 spin_unlock_bh(&fq->lock); in ieee80211_txq_setup_flows()
1591 return -ENOMEM; in ieee80211_txq_setup_flows()
1594 for (i = 0; i < fq->flows_cnt; i++) in ieee80211_txq_setup_flows()
1595 codel_vars_init(&local->cvars[i]); in ieee80211_txq_setup_flows()
1604 struct fq *fq = &local->fq; in ieee80211_txq_teardown_flows()
1606 if (!local->ops->wake_tx_queue) in ieee80211_txq_teardown_flows()
1609 kfree(local->cvars); in ieee80211_txq_teardown_flows()
1610 local->cvars = NULL; in ieee80211_txq_teardown_flows()
1612 spin_lock_bh(&fq->lock); in ieee80211_txq_teardown_flows()
1614 spin_unlock_bh(&fq->lock); in ieee80211_txq_teardown_flows()
1625 if (!local->ops->wake_tx_queue || in ieee80211_queue_skb()
1626 sdata->vif.type == NL80211_IFTYPE_MONITOR) in ieee80211_queue_skb()
1629 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) in ieee80211_queue_skb()
1630 sdata = container_of(sdata->bss, in ieee80211_queue_skb()
1633 vif = &sdata->vif; in ieee80211_queue_skb()
1658 int q = info->hw_queue; in ieee80211_tx_frags()
1661 if (WARN_ON_ONCE(q >= local->hw.queues)) { in ieee80211_tx_frags()
1663 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_frags()
1668 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in ieee80211_tx_frags()
1669 if (local->queue_stop_reasons[q] || in ieee80211_tx_frags()
1670 (!txpending && !skb_queue_empty(&local->pending[q]))) { in ieee80211_tx_frags()
1671 if (unlikely(info->flags & in ieee80211_tx_frags()
1673 if (local->queue_stop_reasons[q] & in ieee80211_tx_frags()
1676 * Drop off-channel frames if queues in ieee80211_tx_frags()
1678 * than off-channel operation. Never in ieee80211_tx_frags()
1682 &local->queue_stop_reason_lock, in ieee80211_tx_frags()
1684 ieee80211_purge_tx_queue(&local->hw, in ieee80211_tx_frags()
1692 * later transmission from the tx-pending in ieee80211_tx_frags()
1697 &local->pending[q]); in ieee80211_tx_frags()
1700 &local->pending[q]); in ieee80211_tx_frags()
1702 spin_unlock_irqrestore(&local->queue_stop_reason_lock, in ieee80211_tx_frags()
1707 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_tx_frags()
1709 info->control.vif = vif; in ieee80211_tx_frags()
1710 control.sta = sta ? &sta->sta : NULL; in ieee80211_tx_frags()
1737 fc = ((struct ieee80211_hdr *)skb->data)->frame_control; in __ieee80211_tx()
1739 sdata = vif_to_sdata(info->control.vif); in __ieee80211_tx()
1740 if (sta && !sta->uploaded) in __ieee80211_tx()
1743 switch (sdata->vif.type) { in __ieee80211_tx()
1745 if (sdata->u.mntr.flags & MONITOR_FLAG_ACTIVE) { in __ieee80211_tx()
1746 vif = &sdata->vif; in __ieee80211_tx()
1749 sdata = rcu_dereference(local->monitor_sdata); in __ieee80211_tx()
1751 vif = &sdata->vif; in __ieee80211_tx()
1752 info->hw_queue = in __ieee80211_tx()
1753 vif->hw_queue[skb_get_queue_mapping(skb)]; in __ieee80211_tx()
1754 } else if (ieee80211_hw_check(&local->hw, QUEUE_CONTROL)) { in __ieee80211_tx()
1755 ieee80211_purge_tx_queue(&local->hw, skbs); in __ieee80211_tx()
1761 sdata = container_of(sdata->bss, in __ieee80211_tx()
1765 vif = &sdata->vif; in __ieee80211_tx()
1779 * Invoke TX handlers, return 0 on success and non-zero if the
1805 I802_DEBUG_INC(tx->local->tx_handlers_drop); in invoke_tx_handlers_early()
1806 if (tx->skb) in invoke_tx_handlers_early()
1807 ieee80211_free_txskb(&tx->local->hw, tx->skb); in invoke_tx_handlers_early()
1809 ieee80211_purge_tx_queue(&tx->local->hw, &tx->skbs); in invoke_tx_handlers_early()
1810 return -1; in invoke_tx_handlers_early()
1812 I802_DEBUG_INC(tx->local->tx_handlers_queued); in invoke_tx_handlers_early()
1813 return -1; in invoke_tx_handlers_early()
1825 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); in invoke_tx_handlers_late()
1828 if (unlikely(info->flags & IEEE80211_TX_INTFL_RETRANSMISSION)) { in invoke_tx_handlers_late()
1829 __skb_queue_tail(&tx->skbs, tx->skb); in invoke_tx_handlers_late()
1830 tx->skb = NULL; in invoke_tx_handlers_late()
1834 if (!ieee80211_hw_check(&tx->local->hw, HAS_RATE_CONTROL)) in invoke_tx_handlers_late()
1840 /* handlers after fragment must be aware of tx info fragmentation! */ in invoke_tx_handlers_late()
1843 if (!ieee80211_hw_check(&tx->local->hw, HAS_RATE_CONTROL)) in invoke_tx_handlers_late()
1849 I802_DEBUG_INC(tx->local->tx_handlers_drop); in invoke_tx_handlers_late()
1850 if (tx->skb) in invoke_tx_handlers_late()
1851 ieee80211_free_txskb(&tx->local->hw, tx->skb); in invoke_tx_handlers_late()
1853 ieee80211_purge_tx_queue(&tx->local->hw, &tx->skbs); in invoke_tx_handlers_late()
1854 return -1; in invoke_tx_handlers_late()
1856 I802_DEBUG_INC(tx->local->tx_handlers_queued); in invoke_tx_handlers_late()
1857 return -1; in invoke_tx_handlers_late()
1874 int band, struct ieee80211_sta **sta) in ieee80211_tx_prepare_skb() argument
1884 info->band = band; in ieee80211_tx_prepare_skb()
1885 info->control.vif = vif; in ieee80211_tx_prepare_skb()
1886 info->hw_queue = vif->hw_queue[skb_get_queue_mapping(skb)]; in ieee80211_tx_prepare_skb()
1893 *sta = &tx.sta->sta; in ieee80211_tx_prepare_skb()
1917 struct ieee80211_local *local = sdata->local; in ieee80211_tx()
1924 if (unlikely(skb->len < 10)) { in ieee80211_tx()
1930 led_len = skb->len; in ieee80211_tx()
1934 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx()
1941 if (!(info->flags & IEEE80211_TX_CTL_TX_OFFCHAN) || in ieee80211_tx()
1942 !ieee80211_hw_check(&local->hw, QUEUE_CONTROL)) in ieee80211_tx()
1943 info->hw_queue = in ieee80211_tx()
1944 sdata->vif.hw_queue[skb_get_queue_mapping(skb)]; in ieee80211_tx()
1972 struct ieee80211_local *local = sdata->local; in ieee80211_skb_resize()
1978 sdata->crypto_tx_tailroom_needed_cnt); in ieee80211_skb_resize()
1982 tail_need -= skb_tailroom(skb); in ieee80211_skb_resize()
1987 (!ieee80211_hw_check(&local->hw, SUPPORTS_CLONED_SKBS) || in ieee80211_skb_resize()
1989 I802_DEBUG_INC(local->tx_expand_skb_head_cloned); in ieee80211_skb_resize()
1991 I802_DEBUG_INC(local->tx_expand_skb_head); in ieee80211_skb_resize()
1996 wiphy_debug(local->hw.wiphy, in ieee80211_skb_resize()
1998 return -ENOMEM; in ieee80211_skb_resize()
2007 struct ieee80211_local *local = sdata->local; in ieee80211_xmit()
2009 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; in ieee80211_xmit()
2013 if (info->flags & IEEE80211_TX_INTFL_DONT_ENCRYPT) in ieee80211_xmit()
2015 else if (ieee80211_is_mgmt(hdr->frame_control)) in ieee80211_xmit()
2020 headroom = local->tx_headroom; in ieee80211_xmit()
2022 headroom += sdata->encrypt_headroom; in ieee80211_xmit()
2023 headroom -= skb_headroom(skb); in ieee80211_xmit()
2027 ieee80211_free_txskb(&local->hw, skb); in ieee80211_xmit()
2032 hdr = (struct ieee80211_hdr *) skb->data; in ieee80211_xmit()
2033 info->control.vif = &sdata->vif; in ieee80211_xmit()
2035 if (ieee80211_vif_is_mesh(&sdata->vif)) { in ieee80211_xmit()
2036 if (ieee80211_is_data(hdr->frame_control) && in ieee80211_xmit()
2037 is_unicast_ether_addr(hdr->addr1)) { in ieee80211_xmit()
2052 (struct ieee80211_radiotap_header *)skb->data; in ieee80211_validate_radiotap_len()
2055 if (unlikely(skb->len < sizeof(struct ieee80211_radiotap_header))) in ieee80211_validate_radiotap_len()
2059 if (unlikely(rthdr->it_version)) in ieee80211_validate_radiotap_len()
2063 if (unlikely(skb->len < ieee80211_get_radiotap_len(skb->data))) in ieee80211_validate_radiotap_len()
2072 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); in ieee80211_parse_tx_radiotap()
2075 (struct ieee80211_radiotap_header *) skb->data; in ieee80211_parse_tx_radiotap()
2077 int ret = ieee80211_radiotap_iterator_init(&iterator, rthdr, skb->len, in ieee80211_parse_tx_radiotap()
2092 info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT | in ieee80211_parse_tx_radiotap()
2097 * (ieee80211_radiotap_iterator_next returns -ENOENT when no more in ieee80211_parse_tx_radiotap()
2098 * entries present, or -EINVAL on error) in ieee80211_parse_tx_radiotap()
2119 * handed has the 32-bit FCS CRC at the end... in ieee80211_parse_tx_radiotap()
2124 if (skb->len < (iterator._max_length + FCS_LEN)) in ieee80211_parse_tx_radiotap()
2127 skb_trim(skb, skb->len - FCS_LEN); in ieee80211_parse_tx_radiotap()
2130 info->flags &= ~IEEE80211_TX_INTFL_DONT_ENCRYPT; in ieee80211_parse_tx_radiotap()
2132 info->flags &= ~IEEE80211_TX_CTL_DONTFRAG; in ieee80211_parse_tx_radiotap()
2138 info->flags |= IEEE80211_TX_CTL_NO_ACK; in ieee80211_parse_tx_radiotap()
2140 info->control.flags |= IEEE80211_TX_CTRL_NO_SEQNO; in ieee80211_parse_tx_radiotap()
2142 info->control.flags |= in ieee80211_parse_tx_radiotap()
2177 info->flags |= IEEE80211_TX_CTL_LDPC; in ieee80211_parse_tx_radiotap()
2183 info->flags |= in ieee80211_parse_tx_radiotap()
2221 * Documentation/networking/mac80211-injection.rst in ieee80211_parse_tx_radiotap()
2230 if (ret != -ENOENT) /* ie, if we didn't simply run out of fields */ in ieee80211_parse_tx_radiotap()
2235 local->hw.wiphy->bands[info->band]; in ieee80211_parse_tx_radiotap()
2237 info->control.flags |= IEEE80211_TX_CTRL_RATE_INJECT; in ieee80211_parse_tx_radiotap()
2240 info->control.rates[i].idx = -1; in ieee80211_parse_tx_radiotap()
2241 info->control.rates[i].flags = 0; in ieee80211_parse_tx_radiotap()
2242 info->control.rates[i].count = 0; in ieee80211_parse_tx_radiotap()
2246 info->control.rates[0].idx = rate; in ieee80211_parse_tx_radiotap()
2248 ieee80211_rate_set_vht(info->control.rates, vht_mcs, in ieee80211_parse_tx_radiotap()
2251 for (i = 0; i < sband->n_bitrates; i++) { in ieee80211_parse_tx_radiotap()
2252 if (rate * 5 != sband->bitrates[i].bitrate) in ieee80211_parse_tx_radiotap()
2255 info->control.rates[0].idx = i; in ieee80211_parse_tx_radiotap()
2260 if (info->control.rates[0].idx < 0) in ieee80211_parse_tx_radiotap()
2261 info->control.flags &= ~IEEE80211_TX_CTRL_RATE_INJECT; in ieee80211_parse_tx_radiotap()
2263 info->control.rates[0].flags = rate_flags; in ieee80211_parse_tx_radiotap()
2264 info->control.rates[0].count = min_t(u8, rate_retries + 1, in ieee80211_parse_tx_radiotap()
2265 local->hw.max_rate_tries); in ieee80211_parse_tx_radiotap()
2274 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); in ieee80211_monitor_start_xmit()
2284 info->flags = IEEE80211_TX_CTL_REQ_TX_STATUS | in ieee80211_monitor_start_xmit()
2287 /* Sanity-check the length of the radiotap header */ in ieee80211_monitor_start_xmit()
2292 len_rthdr = ieee80211_get_radiotap_len(skb->data); in ieee80211_monitor_start_xmit()
2302 * these are just fixed to the end of the rt area since we in ieee80211_monitor_start_xmit()
2308 if (skb->len < len_rthdr + 2) in ieee80211_monitor_start_xmit()
2311 hdr = (struct ieee80211_hdr *)(skb->data + len_rthdr); in ieee80211_monitor_start_xmit()
2312 hdrlen = ieee80211_hdrlen(hdr->frame_control); in ieee80211_monitor_start_xmit()
2314 if (skb->len < len_rthdr + hdrlen) in ieee80211_monitor_start_xmit()
2318 * Initialize skb->protocol if the injected frame is a data frame in ieee80211_monitor_start_xmit()
2321 if (ieee80211_is_data(hdr->frame_control) && in ieee80211_monitor_start_xmit()
2322 skb->len >= len_rthdr + hdrlen + sizeof(rfc1042_header) + 2) { in ieee80211_monitor_start_xmit()
2326 skb->protocol = cpu_to_be16((payload[6] << 8) | in ieee80211_monitor_start_xmit()
2334 * we handle as though they are non-injected frames. in ieee80211_monitor_start_xmit()
2337 * VLAN support we have an nl80211-based mechanism. in ieee80211_monitor_start_xmit()
2340 * don't use nl80211-based management TX/RX. in ieee80211_monitor_start_xmit()
2344 list_for_each_entry_rcu(tmp_sdata, &local->interfaces, list) { in ieee80211_monitor_start_xmit()
2347 if (tmp_sdata->vif.type == NL80211_IFTYPE_MONITOR || in ieee80211_monitor_start_xmit()
2348 tmp_sdata->vif.type == NL80211_IFTYPE_AP_VLAN) in ieee80211_monitor_start_xmit()
2350 if (ether_addr_equal(tmp_sdata->vif.addr, hdr->addr2)) { in ieee80211_monitor_start_xmit()
2356 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); in ieee80211_monitor_start_xmit()
2358 tmp_sdata = rcu_dereference(local->monitor_sdata); in ieee80211_monitor_start_xmit()
2361 rcu_dereference(tmp_sdata->vif.chanctx_conf); in ieee80211_monitor_start_xmit()
2365 chandef = &chanctx_conf->def; in ieee80211_monitor_start_xmit()
2366 else if (!local->use_chanctx) in ieee80211_monitor_start_xmit()
2367 chandef = &local->_oper_chandef; in ieee80211_monitor_start_xmit()
2387 if (!cfg80211_reg_can_beacon(local->hw.wiphy, chandef, in ieee80211_monitor_start_xmit()
2388 sdata->vif.type)) in ieee80211_monitor_start_xmit()
2391 info->band = chandef->chan->band; in ieee80211_monitor_start_xmit()
2393 /* Initialize skb->priority according to frame type and TID class, in ieee80211_monitor_start_xmit()
2396 * skb-priority is preserved to assure frames injected with this in ieee80211_monitor_start_xmit()
2400 skb_set_queue_mapping(skb, ieee80211_ac_from_tid(skb->priority)); in ieee80211_monitor_start_xmit()
2427 u16 ethertype = (skb->data[12] << 8) | skb->data[13]; in ieee80211_is_tdls_setup()
2430 skb->len > 14 && in ieee80211_is_tdls_setup()
2431 skb->data[14] == WLAN_TDLS_SNAP_RFTYPE; in ieee80211_is_tdls_setup()
2440 switch (sdata->vif.type) { in ieee80211_lookup_ra_sta()
2442 sta = rcu_dereference(sdata->u.vlan.sta); in ieee80211_lookup_ra_sta()
2446 } else if (sdata->wdev.use_4addr) { in ieee80211_lookup_ra_sta()
2447 return -ENOLINK; in ieee80211_lookup_ra_sta()
2453 if (is_multicast_ether_addr(skb->data)) { in ieee80211_lookup_ra_sta()
2454 *sta_out = ERR_PTR(-ENOENT); in ieee80211_lookup_ra_sta()
2457 sta = sta_info_get_bss(sdata, skb->data); in ieee80211_lookup_ra_sta()
2466 if (sdata->wdev.wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS) { in ieee80211_lookup_ra_sta()
2467 sta = sta_info_get(sdata, skb->data); in ieee80211_lookup_ra_sta()
2476 * TDLS link during setup - throw out frames to in ieee80211_lookup_ra_sta()
2477 * peer. Allow TDLS-setup frames to unauthorized in ieee80211_lookup_ra_sta()
2478 * peers for the special case of a link teardown in ieee80211_lookup_ra_sta()
2483 return -EINVAL; in ieee80211_lookup_ra_sta()
2488 sta = sta_info_get(sdata, sdata->u.mgd.bssid); in ieee80211_lookup_ra_sta()
2490 return -ENOLINK; in ieee80211_lookup_ra_sta()
2493 return -EINVAL; in ieee80211_lookup_ra_sta()
2496 *sta_out = sta ?: ERR_PTR(-ENOENT); in ieee80211_lookup_ra_sta()
2508 if (skb->sk) in ieee80211_store_ack_skb()
2517 spin_lock_irqsave(&local->ack_status_lock, flags); in ieee80211_store_ack_skb()
2518 id = idr_alloc(&local->ack_status_frames, ack_skb, in ieee80211_store_ack_skb()
2520 spin_unlock_irqrestore(&local->ack_status_lock, flags); in ieee80211_store_ack_skb()
2527 IEEE80211_SKB_CB(ack_skb)->ack.cookie = *cookie; in ieee80211_store_ack_skb()
2538 * ieee80211_build_hdr - build 802.11 header in the given frame
2550 * Note that this function also takes care of the TX status request and
2551 * potential unsharing of the SKB - this needs to be interleaved with the
2554 * The function requires the read-side RCU lock held
2563 struct ieee80211_local *local = sdata->local; in ieee80211_build_hdr()
2579 enum nl80211_band band; in ieee80211_build_hdr() local
2586 if (local->force_tx_status) in ieee80211_build_hdr()
2592 ethertype = (skb->data[12] << 8) | skb->data[13]; in ieee80211_build_hdr()
2595 switch (sdata->vif.type) { in ieee80211_build_hdr()
2597 if (sdata->wdev.use_4addr) { in ieee80211_build_hdr()
2600 memcpy(hdr.addr1, sta->sta.addr, ETH_ALEN); in ieee80211_build_hdr()
2601 memcpy(hdr.addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_build_hdr()
2602 memcpy(hdr.addr3, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2603 memcpy(hdr.addr4, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2606 wme_sta = sta->sta.wme; in ieee80211_build_hdr()
2608 ap_sdata = container_of(sdata->bss, struct ieee80211_sub_if_data, in ieee80211_build_hdr()
2610 chanctx_conf = rcu_dereference(ap_sdata->vif.chanctx_conf); in ieee80211_build_hdr()
2612 ret = -ENOTCONN; in ieee80211_build_hdr()
2615 band = chanctx_conf->def.chan->band; in ieee80211_build_hdr()
2616 if (sdata->wdev.use_4addr) in ieee80211_build_hdr()
2620 if (sdata->vif.type == NL80211_IFTYPE_AP) in ieee80211_build_hdr()
2621 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); in ieee80211_build_hdr()
2623 ret = -ENOTCONN; in ieee80211_build_hdr()
2628 memcpy(hdr.addr1, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2629 memcpy(hdr.addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_build_hdr()
2630 memcpy(hdr.addr3, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2632 band = chanctx_conf->def.chan->band; in ieee80211_build_hdr()
2636 if (!is_multicast_ether_addr(skb->data)) { in ieee80211_build_hdr()
2640 mpath = mesh_path_lookup(sdata, skb->data); in ieee80211_build_hdr()
2643 next_hop = rcu_dereference(mpath->next_hop); in ieee80211_build_hdr()
2645 !(mpath->flags & (MESH_PATH_ACTIVE | in ieee80211_build_hdr()
2651 mppath = mpp_path_lookup(sdata, skb->data); in ieee80211_build_hdr()
2653 mppath->exp_time = jiffies; in ieee80211_build_hdr()
2657 mesh_path_del(sdata, mpath->dst); in ieee80211_build_hdr()
2666 if (ether_addr_equal(sdata->vif.addr, skb->data + ETH_ALEN) && in ieee80211_build_hdr()
2667 !(mppath && !ether_addr_equal(mppath->mpp, skb->data))) { in ieee80211_build_hdr()
2669 skb->data, skb->data + ETH_ALEN); in ieee80211_build_hdr()
2673 /* DS -> MBSS (802.11-2012 13.11.3.3). in ieee80211_build_hdr()
2679 const u8 *mesh_da = skb->data; in ieee80211_build_hdr()
2682 mesh_da = mppath->mpp; in ieee80211_build_hdr()
2684 mesh_da = mpath->dst; in ieee80211_build_hdr()
2687 mesh_da, sdata->vif.addr); in ieee80211_build_hdr()
2692 skb->data + ETH_ALEN, NULL); in ieee80211_build_hdr()
2696 sdata, &mesh_hdr, skb->data, in ieee80211_build_hdr()
2697 skb->data + ETH_ALEN); in ieee80211_build_hdr()
2700 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); in ieee80211_build_hdr()
2702 ret = -ENOTCONN; in ieee80211_build_hdr()
2705 band = chanctx_conf->def.chan->band; in ieee80211_build_hdr()
2712 memcpy(hdr.addr1, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2721 memcpy(hdr.addr1, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2722 memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2723 memcpy(hdr.addr3, sdata->u.mgd.bssid, ETH_ALEN); in ieee80211_build_hdr()
2725 } else if (sdata->u.mgd.use_4addr && in ieee80211_build_hdr()
2726 cpu_to_be16(ethertype) != sdata->control_port_protocol) { in ieee80211_build_hdr()
2730 memcpy(hdr.addr1, sdata->u.mgd.bssid, ETH_ALEN); in ieee80211_build_hdr()
2731 memcpy(hdr.addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_build_hdr()
2732 memcpy(hdr.addr3, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2733 memcpy(hdr.addr4, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2738 memcpy(hdr.addr1, sdata->u.mgd.bssid, ETH_ALEN); in ieee80211_build_hdr()
2739 memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2740 memcpy(hdr.addr3, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2743 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); in ieee80211_build_hdr()
2745 ret = -ENOTCONN; in ieee80211_build_hdr()
2748 band = chanctx_conf->def.chan->band; in ieee80211_build_hdr()
2752 memcpy(hdr.addr1, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2753 memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2756 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); in ieee80211_build_hdr()
2758 ret = -ENOTCONN; in ieee80211_build_hdr()
2761 band = chanctx_conf->def.chan->band; in ieee80211_build_hdr()
2765 memcpy(hdr.addr1, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2766 memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2767 memcpy(hdr.addr3, sdata->u.ibss.bssid, ETH_ALEN); in ieee80211_build_hdr()
2769 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); in ieee80211_build_hdr()
2771 ret = -ENOTCONN; in ieee80211_build_hdr()
2774 band = chanctx_conf->def.chan->band; in ieee80211_build_hdr()
2777 ret = -EINVAL; in ieee80211_build_hdr()
2786 wme_sta = sta->sta.wme; in ieee80211_build_hdr()
2787 } else if (ieee80211_vif_is_mesh(&sdata->vif)) { in ieee80211_build_hdr()
2788 /* For mesh, the use of the QoS header is mandatory */ in ieee80211_build_hdr()
2802 if (unlikely(!ieee80211_vif_is_mesh(&sdata->vif) && in ieee80211_build_hdr()
2803 (sdata->vif.type != NL80211_IFTYPE_OCB) && in ieee80211_build_hdr()
2805 (cpu_to_be16(ethertype) != sdata->control_port_protocol || in ieee80211_build_hdr()
2806 !ether_addr_equal(sdata->vif.addr, skb->data + ETH_ALEN)))) { in ieee80211_build_hdr()
2809 sdata->name, hdr.addr1); in ieee80211_build_hdr()
2812 I802_DEBUG_INC(local->tx_handlers_drop_unauth_port); in ieee80211_build_hdr()
2814 ret = -EPERM; in ieee80211_build_hdr()
2818 if (unlikely(!multicast && ((skb->sk && in ieee80211_build_hdr()
2819 skb_shinfo(skb)->tx_flags & SKBTX_WIFI_STATUS) || in ieee80211_build_hdr()
2830 /* can't happen -- skb is a clone if info_id != 0 */ in ieee80211_build_hdr()
2837 ret = -ENOMEM; in ieee80211_build_hdr()
2850 skip_header_bytes -= 2; in ieee80211_build_hdr()
2854 skip_header_bytes -= 2; in ieee80211_build_hdr()
2861 head_need = hdrlen + encaps_len + meshhdrlen - skb_headroom(skb); in ieee80211_build_hdr()
2864 * So we need to modify the skb header and hence need a copy of in ieee80211_build_hdr()
2876 head_need += sdata->encrypt_headroom; in ieee80211_build_hdr()
2877 head_need += local->tx_headroom; in ieee80211_build_hdr()
2880 ieee80211_free_txskb(&local->hw, skb); in ieee80211_build_hdr()
2882 return ERR_PTR(-ENOMEM); in ieee80211_build_hdr()
2898 memcpy(skb_push(skb, hdrlen - 2), &hdr, hdrlen - 2); in ieee80211_build_hdr()
2912 info->flags = info_flags; in ieee80211_build_hdr()
2913 info->ack_frame_id = info_id; in ieee80211_build_hdr()
2914 info->band = band; in ieee80211_build_hdr()
2915 info->control.flags = ctrl_flags; in ieee80211_build_hdr()
2924 * fast-xmit overview
2926 * The core idea of this fast-xmit is to remove per-packet checks by checking
2927 * them out of band. ieee80211_check_fast_xmit() implements the out-of-band
2928 * checks that are needed to get the sta->fast_tx pointer assigned, after which
2933 * Once assigned, the fast_tx data structure also caches the per-packet 802.11
2936 * The most difficult part of this is that when any of these assumptions
2939 * since the per-packet code no longer checks the conditions. This is reflected
2940 * by the calls to these functions throughout the rest of the code, and must be
2941 * maintained if any of the TX path checks change.
2947 struct ieee80211_local *local = sta->local; in ieee80211_check_fast_xmit()
2948 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_check_fast_xmit()
2953 if (!ieee80211_hw_check(&local->hw, SUPPORT_FAST_XMIT)) in ieee80211_check_fast_xmit()
2959 * Without it, the invocation of this function right after the key in ieee80211_check_fast_xmit()
2964 * key and the fast-tx assignment are done atomically, so the CPU that in ieee80211_check_fast_xmit()
2968 spin_lock_bh(&sta->lock); in ieee80211_check_fast_xmit()
2969 if (ieee80211_hw_check(&local->hw, SUPPORTS_PS) && in ieee80211_check_fast_xmit()
2970 !ieee80211_hw_check(&local->hw, SUPPORTS_DYNAMIC_PS) && in ieee80211_check_fast_xmit()
2971 sdata->vif.type == NL80211_IFTYPE_STATION) in ieee80211_check_fast_xmit()
2972 goto out; in ieee80211_check_fast_xmit()
2975 goto out; in ieee80211_check_fast_xmit()
2981 goto out; in ieee80211_check_fast_xmit()
2983 if (sdata->noack_map) in ieee80211_check_fast_xmit()
2984 goto out; in ieee80211_check_fast_xmit()
2986 /* fast-xmit doesn't handle fragmentation at all */ in ieee80211_check_fast_xmit()
2987 if (local->hw.wiphy->frag_threshold != (u32)-1 && in ieee80211_check_fast_xmit()
2988 !ieee80211_hw_check(&local->hw, SUPPORTS_TX_FRAG)) in ieee80211_check_fast_xmit()
2989 goto out; in ieee80211_check_fast_xmit()
2992 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); in ieee80211_check_fast_xmit()
2995 goto out; in ieee80211_check_fast_xmit()
2997 build.band = chanctx_conf->def.chan->band; in ieee80211_check_fast_xmit()
3002 switch (sdata->vif.type) { in ieee80211_check_fast_xmit()
3007 memcpy(hdr->addr3, sdata->u.ibss.bssid, ETH_ALEN); in ieee80211_check_fast_xmit()
3015 memcpy(hdr->addr3, sdata->u.mgd.bssid, ETH_ALEN); in ieee80211_check_fast_xmit()
3020 if (sdata->u.mgd.use_4addr) { in ieee80211_check_fast_xmit()
3021 /* non-regular ethertype cannot use the fastpath */ in ieee80211_check_fast_xmit()
3025 memcpy(hdr->addr1, sdata->u.mgd.bssid, ETH_ALEN); in ieee80211_check_fast_xmit()
3026 memcpy(hdr->addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_check_fast_xmit()
3034 memcpy(hdr->addr1, sdata->u.mgd.bssid, ETH_ALEN); in ieee80211_check_fast_xmit()
3040 if (sdata->wdev.use_4addr) { in ieee80211_check_fast_xmit()
3044 memcpy(hdr->addr1, sta->sta.addr, ETH_ALEN); in ieee80211_check_fast_xmit()
3045 memcpy(hdr->addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_check_fast_xmit()
3056 memcpy(hdr->addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_check_fast_xmit()
3061 /* not handled on fast-xmit */ in ieee80211_check_fast_xmit()
3062 goto out; in ieee80211_check_fast_xmit()
3065 if (sta->sta.wme) { in ieee80211_check_fast_xmit()
3075 build.key = rcu_access_pointer(sta->ptk[sta->ptk_idx]); in ieee80211_check_fast_xmit()
3077 build.key = rcu_access_pointer(sdata->default_unicast_key); in ieee80211_check_fast_xmit()
3081 gen_iv = build.key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV; in ieee80211_check_fast_xmit()
3082 iv_spc = build.key->conf.flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE; in ieee80211_check_fast_xmit()
3083 mmic = build.key->conf.flags & in ieee80211_check_fast_xmit()
3088 if (!(build.key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) in ieee80211_check_fast_xmit()
3089 goto out; in ieee80211_check_fast_xmit()
3092 if (build.key->flags & KEY_FLAG_TAINTED) in ieee80211_check_fast_xmit()
3093 goto out; in ieee80211_check_fast_xmit()
3095 switch (build.key->conf.cipher) { in ieee80211_check_fast_xmit()
3111 /* cannot handle MMIC or IV generation in xmit-fast */ in ieee80211_check_fast_xmit()
3113 goto out; in ieee80211_check_fast_xmit()
3119 /* cannot handle IV generation in fast-xmit */ in ieee80211_check_fast_xmit()
3121 goto out; in ieee80211_check_fast_xmit()
3131 build.key->conf.cipher); in ieee80211_check_fast_xmit()
3132 goto out; in ieee80211_check_fast_xmit()
3136 goto out; in ieee80211_check_fast_xmit()
3137 /* pure hardware keys are OK, of course */ in ieee80211_check_fast_xmit()
3138 if (!(build.key->flags & KEY_FLAG_CIPHER_SCHEME)) in ieee80211_check_fast_xmit()
3142 build.key->conf.iv_len > IEEE80211_FAST_XMIT_MAX_IV) in ieee80211_check_fast_xmit()
3143 goto out; in ieee80211_check_fast_xmit()
3145 build.hdr_len += build.key->conf.iv_len; in ieee80211_check_fast_xmit()
3151 hdr->frame_control = fc; in ieee80211_check_fast_xmit()
3160 goto out; in ieee80211_check_fast_xmit()
3162 out: in ieee80211_check_fast_xmit()
3164 old = rcu_dereference_protected(sta->fast_tx, in ieee80211_check_fast_xmit()
3165 lockdep_is_held(&sta->lock)); in ieee80211_check_fast_xmit()
3166 rcu_assign_pointer(sta->fast_tx, fast_tx); in ieee80211_check_fast_xmit()
3169 spin_unlock_bh(&sta->lock); in ieee80211_check_fast_xmit()
3177 list_for_each_entry_rcu(sta, &local->sta_list, list) in ieee80211_check_fast_xmit_all()
3184 struct ieee80211_local *local = sdata->local; in ieee80211_check_fast_xmit_iface()
3189 list_for_each_entry_rcu(sta, &local->sta_list, list) { in ieee80211_check_fast_xmit_iface()
3190 if (sdata != sta->sdata && in ieee80211_check_fast_xmit_iface()
3191 (!sta->sdata->bss || sta->sdata->bss != sdata->bss)) in ieee80211_check_fast_xmit_iface()
3203 spin_lock_bh(&sta->lock); in ieee80211_clear_fast_xmit()
3204 fast_tx = rcu_dereference_protected(sta->fast_tx, in ieee80211_clear_fast_xmit()
3205 lockdep_is_held(&sta->lock)); in ieee80211_clear_fast_xmit()
3206 RCU_INIT_POINTER(sta->fast_tx, NULL); in ieee80211_clear_fast_xmit()
3207 spin_unlock_bh(&sta->lock); in ieee80211_clear_fast_xmit()
3217 I802_DEBUG_INC(local->tx_expand_skb_head); in ieee80211_amsdu_realloc_pad()
3220 wiphy_debug(local->hw.wiphy, in ieee80211_amsdu_realloc_pad()
3233 struct ieee80211_local *local = sdata->local; in ieee80211_amsdu_prepare_head()
3237 int hdr_len = fast_tx->hdr_len - sizeof(rfc1042_header); in ieee80211_amsdu_prepare_head()
3238 int subframe_len = skb->len - hdr_len; in ieee80211_amsdu_prepare_head()
3243 if (info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE) in ieee80211_amsdu_prepare_head()
3246 if (info->control.flags & IEEE80211_TX_CTRL_AMSDU) in ieee80211_amsdu_prepare_head()
3251 local->hw.extra_tx_headroom)) in ieee80211_amsdu_prepare_head()
3259 h_80211_src = data + fast_tx->sa_offs; in ieee80211_amsdu_prepare_head()
3260 h_80211_dst = data + fast_tx->da_offs; in ieee80211_amsdu_prepare_head()
3262 amsdu_hdr->h_proto = cpu_to_be16(subframe_len); in ieee80211_amsdu_prepare_head()
3263 ether_addr_copy(amsdu_hdr->h_source, h_80211_src); in ieee80211_amsdu_prepare_head()
3264 ether_addr_copy(amsdu_hdr->h_dest, h_80211_dst); in ieee80211_amsdu_prepare_head()
3266 /* according to IEEE 802.11-2012 8.3.2 table 8-19, the outer SA/DA in ieee80211_amsdu_prepare_head()
3267 * fields needs to be changed to BSSID for A-MSDU frames depending in ieee80211_amsdu_prepare_head()
3270 switch (sdata->vif.type) { in ieee80211_amsdu_prepare_head()
3272 bssid = sdata->u.mgd.bssid; in ieee80211_amsdu_prepare_head()
3276 bssid = sdata->vif.addr; in ieee80211_amsdu_prepare_head()
3282 if (bssid && ieee80211_has_fromds(hdr->frame_control)) in ieee80211_amsdu_prepare_head()
3285 if (bssid && ieee80211_has_tods(hdr->frame_control)) in ieee80211_amsdu_prepare_head()
3291 info->control.flags |= IEEE80211_TX_CTRL_AMSDU; in ieee80211_amsdu_prepare_head()
3301 struct ieee80211_local *local = sdata->local; in ieee80211_amsdu_aggregate()
3302 struct fq *fq = &local->fq; in ieee80211_amsdu_aggregate()
3305 u8 tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; in ieee80211_amsdu_aggregate()
3306 struct ieee80211_txq *txq = sta->sta.txq[tid]; in ieee80211_amsdu_aggregate()
3309 int subframe_len = skb->len - ETH_ALEN; in ieee80211_amsdu_aggregate()
3310 u8 max_subframes = sta->sta.max_amsdu_subframes; in ieee80211_amsdu_aggregate()
3311 int max_frags = local->hw.max_tx_fragments; in ieee80211_amsdu_aggregate()
3312 int max_amsdu_len = sta->sta.max_amsdu_len; in ieee80211_amsdu_aggregate()
3322 if (!ieee80211_hw_check(&local->hw, TX_AMSDU)) in ieee80211_amsdu_aggregate()
3325 if (sdata->vif.offload_flags & IEEE80211_OFFLOAD_ENCAP_ENABLED) in ieee80211_amsdu_aggregate()
3335 if (test_bit(IEEE80211_TXQ_NO_AMSDU, &txqi->flags)) in ieee80211_amsdu_aggregate()
3338 if (sta->sta.max_rc_amsdu_len) in ieee80211_amsdu_aggregate()
3340 sta->sta.max_rc_amsdu_len); in ieee80211_amsdu_aggregate()
3342 if (sta->sta.max_tid_amsdu_len[tid]) in ieee80211_amsdu_aggregate()
3344 sta->sta.max_tid_amsdu_len[tid]); in ieee80211_amsdu_aggregate()
3348 spin_lock_bh(&fq->lock); in ieee80211_amsdu_aggregate()
3354 tin = &txqi->tin; in ieee80211_amsdu_aggregate()
3356 head = skb_peek_tail(&flow->queue); in ieee80211_amsdu_aggregate()
3358 goto out; in ieee80211_amsdu_aggregate()
3360 orig_truesize = head->truesize; in ieee80211_amsdu_aggregate()
3361 orig_len = head->len; in ieee80211_amsdu_aggregate()
3363 if (skb->len + head->len > max_amsdu_len) in ieee80211_amsdu_aggregate()
3364 goto out; in ieee80211_amsdu_aggregate()
3366 nfrags = 1 + skb_shinfo(skb)->nr_frags; in ieee80211_amsdu_aggregate()
3367 nfrags += 1 + skb_shinfo(head)->nr_frags; in ieee80211_amsdu_aggregate()
3368 frag_tail = &skb_shinfo(head)->frag_list; in ieee80211_amsdu_aggregate()
3370 nfrags += 1 + skb_shinfo(*frag_tail)->nr_frags; in ieee80211_amsdu_aggregate()
3371 frag_tail = &(*frag_tail)->next; in ieee80211_amsdu_aggregate()
3376 goto out; in ieee80211_amsdu_aggregate()
3379 goto out; in ieee80211_amsdu_aggregate()
3382 goto out; in ieee80211_amsdu_aggregate()
3385 goto out; in ieee80211_amsdu_aggregate()
3388 * and frag_tail should be &skb_shinfo(head)->frag_list. in ieee80211_amsdu_aggregate()
3393 frag_tail = &skb_shinfo(head)->frag_list; in ieee80211_amsdu_aggregate()
3396 * Pad out the previous subframe to a multiple of 4 by adding the in ieee80211_amsdu_aggregate()
3397 * padding to the next one, that's being added. Note that head->len in ieee80211_amsdu_aggregate()
3398 * is the length of the full A-MSDU, but that works since each time in ieee80211_amsdu_aggregate()
3399 * we add a new subframe we pad out the previous one to a multiple in ieee80211_amsdu_aggregate()
3400 * of 4 and thus it no longer matters in the next round. in ieee80211_amsdu_aggregate()
3402 hdrlen = fast_tx->hdr_len - sizeof(rfc1042_header); in ieee80211_amsdu_aggregate()
3403 if ((head->len - hdrlen) & 3) in ieee80211_amsdu_aggregate()
3404 pad = 4 - ((head->len - hdrlen) & 3); in ieee80211_amsdu_aggregate()
3421 head->len += skb->len; in ieee80211_amsdu_aggregate()
3422 head->data_len += skb->len; in ieee80211_amsdu_aggregate()
3426 fq->memory_usage += head->truesize - orig_truesize; in ieee80211_amsdu_aggregate()
3427 if (head->len != orig_len) { in ieee80211_amsdu_aggregate()
3428 flow->backlog += head->len - orig_len; in ieee80211_amsdu_aggregate()
3429 tin->backlog_bytes += head->len - orig_len; in ieee80211_amsdu_aggregate()
3431 out: in ieee80211_amsdu_aggregate()
3432 spin_unlock_bh(&fq->lock); in ieee80211_amsdu_aggregate()
3447 struct sk_buff *skb = tx->skb; in ieee80211_xmit_fast_finish()
3449 struct ieee80211_hdr *hdr = (void *)skb->data; in ieee80211_xmit_fast_finish()
3452 if (!ieee80211_hw_check(&tx->local->hw, HAS_RATE_CONTROL) && in ieee80211_xmit_fast_finish()
3457 info->control.hw_key = &key->conf; in ieee80211_xmit_fast_finish()
3459 dev_sw_netstats_tx_add(skb->dev, 1, skb->len); in ieee80211_xmit_fast_finish()
3461 if (hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) { in ieee80211_xmit_fast_finish()
3462 tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; in ieee80211_xmit_fast_finish()
3463 hdr->seq_ctrl = ieee80211_tx_next_seq(sta, tid); in ieee80211_xmit_fast_finish()
3465 info->flags |= IEEE80211_TX_CTL_ASSIGN_SEQ; in ieee80211_xmit_fast_finish()
3466 hdr->seq_ctrl = cpu_to_le16(sdata->sequence_number); in ieee80211_xmit_fast_finish()
3467 sdata->sequence_number += 0x10; in ieee80211_xmit_fast_finish()
3470 if (skb_shinfo(skb)->gso_size) in ieee80211_xmit_fast_finish()
3471 sta->tx_stats.msdu[tid] += in ieee80211_xmit_fast_finish()
3472 DIV_ROUND_UP(skb->len, skb_shinfo(skb)->gso_size); in ieee80211_xmit_fast_finish()
3474 sta->tx_stats.msdu[tid]++; in ieee80211_xmit_fast_finish()
3476 info->hw_queue = sdata->vif.hw_queue[skb_get_queue_mapping(skb)]; in ieee80211_xmit_fast_finish()
3481 sta->tx_stats.bytes[skb_get_queue_mapping(skb)] += skb->len; in ieee80211_xmit_fast_finish()
3482 sta->tx_stats.packets[skb_get_queue_mapping(skb)]++; in ieee80211_xmit_fast_finish()
3486 u8 *crypto_hdr = skb->data + pn_offs; in ieee80211_xmit_fast_finish()
3488 switch (key->conf.cipher) { in ieee80211_xmit_fast_finish()
3493 pn = atomic64_inc_return(&key->conf.tx_pn); in ieee80211_xmit_fast_finish()
3496 crypto_hdr[3] = 0x20 | (key->conf.keyidx << 6); in ieee80211_xmit_fast_finish()
3513 struct ieee80211_local *local = sdata->local; in ieee80211_xmit_fast()
3514 u16 ethertype = (skb->data[12] << 8) | skb->data[13]; in ieee80211_xmit_fast()
3515 int extra_head = fast_tx->hdr_len - (ETH_HLEN - 2); in ieee80211_xmit_fast()
3516 int hw_headroom = sdata->local->hw.extra_tx_headroom; in ieee80211_xmit_fast()
3519 struct ieee80211_hdr *hdr = (void *)fast_tx->hdr; in ieee80211_xmit_fast()
3525 /* control port protocol needs a lot of special handling */ in ieee80211_xmit_fast()
3526 if (cpu_to_be16(ethertype) == sdata->control_port_protocol) in ieee80211_xmit_fast()
3534 if (skb->sk && skb_shinfo(skb)->tx_flags & SKBTX_WIFI_STATUS) in ieee80211_xmit_fast()
3537 if (hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) { in ieee80211_xmit_fast()
3538 tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; in ieee80211_xmit_fast()
3539 tid_tx = rcu_dereference(sta->ampdu_mlme.tid_tx[tid]); in ieee80211_xmit_fast()
3541 if (!test_bit(HT_AGG_STATE_OPERATIONAL, &tid_tx->state)) in ieee80211_xmit_fast()
3543 if (tid_tx->timeout) in ieee80211_xmit_fast()
3544 tid_tx->last_tx = jiffies; in ieee80211_xmit_fast()
3560 if ((hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) && in ieee80211_xmit_fast()
3564 /* will not be crypto-handled beyond what we do here, so use false in ieee80211_xmit_fast()
3565 * as the may-encrypt argument for the resize to not account for in ieee80211_xmit_fast()
3569 max_t(int, extra_head + hw_headroom - in ieee80211_xmit_fast()
3576 memcpy(&eth, skb->data, ETH_HLEN - 2); in ieee80211_xmit_fast()
3578 memcpy(skb->data, fast_tx->hdr, fast_tx->hdr_len); in ieee80211_xmit_fast()
3579 memcpy(skb->data + fast_tx->da_offs, eth.h_dest, ETH_ALEN); in ieee80211_xmit_fast()
3580 memcpy(skb->data + fast_tx->sa_offs, eth.h_source, ETH_ALEN); in ieee80211_xmit_fast()
3584 info->band = fast_tx->band; in ieee80211_xmit_fast()
3585 info->control.vif = &sdata->vif; in ieee80211_xmit_fast()
3586 info->flags = IEEE80211_TX_CTL_FIRST_FRAGMENT | in ieee80211_xmit_fast()
3589 info->control.flags = IEEE80211_TX_CTRL_FAST_XMIT; in ieee80211_xmit_fast()
3592 if (local->force_tx_status) in ieee80211_xmit_fast()
3593 info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS; in ieee80211_xmit_fast()
3596 if (hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) { in ieee80211_xmit_fast()
3597 tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; in ieee80211_xmit_fast()
3607 tx.key = fast_tx->key; in ieee80211_xmit_fast()
3613 r = ieee80211_xmit_fast_finish(sdata, sta, fast_tx->pn_offs, in ieee80211_xmit_fast()
3614 fast_tx->key, &tx); in ieee80211_xmit_fast()
3621 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) in ieee80211_xmit_fast()
3622 sdata = container_of(sdata->bss, in ieee80211_xmit_fast()
3626 ieee80211_tx_frags(local, &sdata->vif, sta, &tx.skbs, false); in ieee80211_xmit_fast()
3637 struct fq *fq = &local->fq; in ieee80211_tx_dequeue()
3638 struct fq_tin *tin = &txqi->tin; in ieee80211_tx_dequeue()
3642 struct ieee80211_vif *vif = txq->vif; in ieee80211_tx_dequeue()
3650 spin_lock_bh(&fq->lock); in ieee80211_tx_dequeue()
3652 if (test_bit(IEEE80211_TXQ_STOP, &txqi->flags) || in ieee80211_tx_dequeue()
3653 test_bit(IEEE80211_TXQ_STOP_NETIF_TX, &txqi->flags)) in ieee80211_tx_dequeue()
3654 goto out; in ieee80211_tx_dequeue()
3656 if (vif->txqs_stopped[txq->ac]) { in ieee80211_tx_dequeue()
3657 set_bit(IEEE80211_TXQ_STOP_NETIF_TX, &txqi->flags); in ieee80211_tx_dequeue()
3658 goto out; in ieee80211_tx_dequeue()
3662 skb = __skb_dequeue(&txqi->frags); in ieee80211_tx_dequeue()
3664 if (!(IEEE80211_SKB_CB(skb)->control.flags & in ieee80211_tx_dequeue()
3666 goto out; in ieee80211_tx_dequeue()
3667 IEEE80211_SKB_CB(skb)->control.flags &= in ieee80211_tx_dequeue()
3674 goto out; in ieee80211_tx_dequeue()
3676 spin_unlock_bh(&fq->lock); in ieee80211_tx_dequeue()
3678 hdr = (struct ieee80211_hdr *)skb->data; in ieee80211_tx_dequeue()
3685 tx.sdata = vif_to_sdata(info->control.vif); in ieee80211_tx_dequeue()
3687 if (txq->sta) { in ieee80211_tx_dequeue()
3688 tx.sta = container_of(txq->sta, struct sta_info, sta); in ieee80211_tx_dequeue()
3693 if (unlikely(!(info->flags & IEEE80211_TX_CTL_INJECTED) && in ieee80211_tx_dequeue()
3694 ieee80211_is_data(hdr->frame_control) && in ieee80211_tx_dequeue()
3695 !ieee80211_vif_is_mesh(&tx.sdata->vif) && in ieee80211_tx_dequeue()
3696 tx.sdata->vif.type != NL80211_IFTYPE_OCB && in ieee80211_tx_dequeue()
3697 !is_multicast_ether_addr(hdr->addr1) && in ieee80211_tx_dequeue()
3699 (!(info->control.flags & in ieee80211_tx_dequeue()
3701 !ether_addr_equal(tx.sdata->vif.addr, in ieee80211_tx_dequeue()
3702 hdr->addr2)))) { in ieee80211_tx_dequeue()
3703 I802_DEBUG_INC(local->tx_handlers_drop_unauth_port); in ieee80211_tx_dequeue()
3704 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_dequeue()
3715 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_dequeue()
3719 if (test_bit(IEEE80211_TXQ_AMPDU, &txqi->flags)) in ieee80211_tx_dequeue()
3720 info->flags |= IEEE80211_TX_CTL_AMPDU; in ieee80211_tx_dequeue()
3722 info->flags &= ~IEEE80211_TX_CTL_AMPDU; in ieee80211_tx_dequeue()
3724 if (info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP) { in ieee80211_tx_dequeue()
3725 if (!ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL)) { in ieee80211_tx_dequeue()
3728 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_dequeue()
3735 if (info->control.flags & IEEE80211_TX_CTRL_FAST_XMIT) { in ieee80211_tx_dequeue()
3736 struct sta_info *sta = container_of(txq->sta, struct sta_info, in ieee80211_tx_dequeue()
3741 (tx.key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)) in ieee80211_tx_dequeue()
3742 pn_offs = ieee80211_hdrlen(hdr->frame_control); in ieee80211_tx_dequeue()
3744 r = ieee80211_xmit_fast_finish(sta->sdata, sta, pn_offs, in ieee80211_tx_dequeue()
3747 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_dequeue()
3757 spin_lock_bh(&fq->lock); in ieee80211_tx_dequeue()
3758 skb_queue_splice_tail(&tx.skbs, &txqi->frags); in ieee80211_tx_dequeue()
3759 spin_unlock_bh(&fq->lock); in ieee80211_tx_dequeue()
3764 !ieee80211_hw_check(&local->hw, TX_FRAG_LIST)) { in ieee80211_tx_dequeue()
3766 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_dequeue()
3771 switch (tx.sdata->vif.type) { in ieee80211_tx_dequeue()
3773 if (tx.sdata->u.mntr.flags & MONITOR_FLAG_ACTIVE) { in ieee80211_tx_dequeue()
3774 vif = &tx.sdata->vif; in ieee80211_tx_dequeue()
3777 tx.sdata = rcu_dereference(local->monitor_sdata); in ieee80211_tx_dequeue()
3779 vif = &tx.sdata->vif; in ieee80211_tx_dequeue()
3780 info->hw_queue = in ieee80211_tx_dequeue()
3781 vif->hw_queue[skb_get_queue_mapping(skb)]; in ieee80211_tx_dequeue()
3782 } else if (ieee80211_hw_check(&local->hw, QUEUE_CONTROL)) { in ieee80211_tx_dequeue()
3783 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_dequeue()
3790 tx.sdata = container_of(tx.sdata->bss, in ieee80211_tx_dequeue()
3794 vif = &tx.sdata->vif; in ieee80211_tx_dequeue()
3799 IEEE80211_SKB_CB(skb)->control.vif = vif; in ieee80211_tx_dequeue()
3802 wiphy_ext_feature_isset(local->hw.wiphy, NL80211_EXT_FEATURE_AQL)) { in ieee80211_tx_dequeue()
3803 bool ampdu = txq->ac != IEEE80211_AC_VO; in ieee80211_tx_dequeue()
3806 airtime = ieee80211_calc_expected_tx_airtime(hw, vif, txq->sta, in ieee80211_tx_dequeue()
3807 skb->len, ampdu); in ieee80211_tx_dequeue()
3811 txq->ac, in ieee80211_tx_dequeue()
3819 out: in ieee80211_tx_dequeue()
3820 spin_unlock_bh(&fq->lock); in ieee80211_tx_dequeue()
3837 air_sched = &local->airtime[ac]; in ieee80211_next_txq()
3838 spin_lock_bh(&air_sched->lock); in ieee80211_next_txq()
3840 node = air_sched->schedule_pos; in ieee80211_next_txq()
3844 node = rb_first_cached(&air_sched->active_txqs); in ieee80211_next_txq()
3851 goto out; in ieee80211_next_txq()
3854 air_info = to_airtime_info(&txqi->txq); in ieee80211_next_txq()
3856 if (air_info->v_t > air_sched->v_t && in ieee80211_next_txq()
3857 (!first || !airtime_catchup_v_t(air_sched, air_info->v_t, now))) in ieee80211_next_txq()
3858 goto out; in ieee80211_next_txq()
3860 if (!ieee80211_txq_airtime_check(hw, &txqi->txq)) { in ieee80211_next_txq()
3865 air_sched->schedule_pos = node; in ieee80211_next_txq()
3866 air_sched->last_schedule_activity = now; in ieee80211_next_txq()
3867 ret = &txqi->txq; in ieee80211_next_txq()
3868 out: in ieee80211_next_txq()
3869 spin_unlock_bh(&air_sched->lock); in ieee80211_next_txq()
3877 struct rb_node **new = &root->rb_root.rb_node; in __ieee80211_insert_txq()
3886 old_air = to_airtime_info(&__txqi->txq); in __ieee80211_insert_txq()
3887 new_air = to_airtime_info(&txqi->txq); in __ieee80211_insert_txq()
3889 if (new_air->v_t <= old_air->v_t) { in __ieee80211_insert_txq()
3890 new = &parent->rb_left; in __ieee80211_insert_txq()
3892 new = &parent->rb_right; in __ieee80211_insert_txq()
3897 rb_link_node(&txqi->schedule_order, parent, new); in __ieee80211_insert_txq()
3898 rb_insert_color_cached(&txqi->schedule_order, root, leftmost); in __ieee80211_insert_txq()
3909 air_sched = &local->airtime[txq->ac]; in ieee80211_resort_txq()
3911 lockdep_assert_held(&air_sched->lock); in ieee80211_resort_txq()
3913 if (!RB_EMPTY_NODE(&txqi->schedule_order)) { in ieee80211_resort_txq()
3920 * and re-insert if the current node is not already in the in ieee80211_resort_txq()
3923 if ((n_prev = rb_prev(&txqi->schedule_order)) != NULL) { in ieee80211_resort_txq()
3926 a_prev = to_airtime_info(&t_prev->txq); in ieee80211_resort_txq()
3929 if ((n_next = rb_next(&txqi->schedule_order)) != NULL) { in ieee80211_resort_txq()
3932 a_next = to_airtime_info(&t_next->txq); in ieee80211_resort_txq()
3935 if ((!a_prev || a_prev->v_t <= air_info->v_t) && in ieee80211_resort_txq()
3936 (!a_next || a_next->v_t > air_info->v_t)) in ieee80211_resort_txq()
3939 if (air_sched->schedule_pos == &txqi->schedule_order) in ieee80211_resort_txq()
3940 air_sched->schedule_pos = n_prev; in ieee80211_resort_txq()
3942 rb_erase_cached(&txqi->schedule_order, in ieee80211_resort_txq()
3943 &air_sched->active_txqs); in ieee80211_resort_txq()
3944 RB_CLEAR_NODE(&txqi->schedule_order); in ieee80211_resort_txq()
3945 __ieee80211_insert_txq(&air_sched->active_txqs, txqi); in ieee80211_resort_txq()
3959 lockdep_assert_held(&air_sched->lock); in ieee80211_update_airtime_weight()
3961 if (!force && (air_sched->last_weight_update < in ieee80211_update_airtime_weight()
3962 now - AIRTIME_ACTIVE_DURATION)) in ieee80211_update_airtime_weight()
3966 &air_sched->active_list, list) { in ieee80211_update_airtime_weight()
3968 weight_sum += air_info->weight; in ieee80211_update_airtime_weight()
3970 list_del_init(&air_info->list); in ieee80211_update_airtime_weight()
3973 air_sched->last_weight_update = now; in ieee80211_update_airtime_weight()
3985 u8 ac = txq->ac; in ieee80211_schedule_txq()
3988 air_sched = &local->airtime[ac]; in ieee80211_schedule_txq()
3991 spin_lock_bh(&air_sched->lock); in ieee80211_schedule_txq()
3995 if (!RB_EMPTY_NODE(&txqi->schedule_order)) in ieee80211_schedule_txq()
3996 goto out; in ieee80211_schedule_txq()
3999 * doesn't get indefinite priority; see comment above the definition of in ieee80211_schedule_txq()
4002 if ((!was_active && air_info->v_t < air_sched->v_t) || in ieee80211_schedule_txq()
4003 air_info->v_t < air_sched->v_t - AIRTIME_MAX_BEHIND) in ieee80211_schedule_txq()
4004 air_info->v_t = air_sched->v_t; in ieee80211_schedule_txq()
4007 __ieee80211_insert_txq(&air_sched->active_txqs, txqi); in ieee80211_schedule_txq()
4009 out: in ieee80211_schedule_txq()
4010 spin_unlock_bh(&air_sched->lock); in ieee80211_schedule_txq()
4023 air_sched = &local->airtime[txq->ac]; in __ieee80211_unschedule_txq()
4024 air_info = to_airtime_info(&txqi->txq); in __ieee80211_unschedule_txq()
4026 lockdep_assert_held(&air_sched->lock); in __ieee80211_unschedule_txq()
4029 list_del_init(&air_info->list); in __ieee80211_unschedule_txq()
4033 if (RB_EMPTY_NODE(&txqi->schedule_order)) in __ieee80211_unschedule_txq()
4036 if (air_sched->schedule_pos == &txqi->schedule_order) in __ieee80211_unschedule_txq()
4037 air_sched->schedule_pos = rb_prev(&txqi->schedule_order); in __ieee80211_unschedule_txq()
4043 rb_erase_cached(&txqi->schedule_order, in __ieee80211_unschedule_txq()
4044 &air_sched->active_txqs); in __ieee80211_unschedule_txq()
4045 RB_CLEAR_NODE(&txqi->schedule_order); in __ieee80211_unschedule_txq()
4055 spin_lock_bh(&local->airtime[txq->ac].lock); in ieee80211_unschedule_txq()
4057 spin_unlock_bh(&local->airtime[txq->ac].lock); in ieee80211_unschedule_txq()
4066 spin_lock_bh(&local->airtime[txq->ac].lock); in ieee80211_return_txq()
4068 if (!RB_EMPTY_NODE(&txqi->schedule_order) && !force && in ieee80211_return_txq()
4072 spin_unlock_bh(&local->airtime[txq->ac].lock); in ieee80211_return_txq()
4084 if (!wiphy_ext_feature_isset(local->hw.wiphy, NL80211_EXT_FEATURE_AQL)) in ieee80211_txq_airtime_check()
4090 if (!txq->sta) in ieee80211_txq_airtime_check()
4093 if (unlikely(txq->tid == IEEE80211_NUM_TIDS)) in ieee80211_txq_airtime_check()
4096 if (atomic_read(&air_info->aql_tx_pending) < air_info->aql_limit_low) in ieee80211_txq_airtime_check()
4099 if (atomic_read(&local->aql_total_pending_airtime) < in ieee80211_txq_airtime_check()
4100 local->aql_threshold && in ieee80211_txq_airtime_check()
4101 atomic_read(&air_info->aql_tx_pending) < air_info->aql_limit_high) in ieee80211_txq_airtime_check()
4123 air_sched = &local->airtime[txq->ac]; in ieee80211_txq_may_transmit()
4124 spin_lock_bh(&air_sched->lock); in ieee80211_txq_may_transmit()
4126 if (RB_EMPTY_NODE(&txqi->schedule_order)) in ieee80211_txq_may_transmit()
4127 goto out; in ieee80211_txq_may_transmit()
4134 node = rb_first_cached(&air_sched->active_txqs); in ieee80211_txq_may_transmit()
4138 air_info = to_airtime_info(&first_txqi->txq); in ieee80211_txq_may_transmit()
4140 if (air_sched->v_t < air_info->v_t) in ieee80211_txq_may_transmit()
4141 airtime_catchup_v_t(air_sched, air_info->v_t, now); in ieee80211_txq_may_transmit()
4144 air_info = to_airtime_info(&txqi->txq); in ieee80211_txq_may_transmit()
4145 if (air_info->v_t <= air_sched->v_t) { in ieee80211_txq_may_transmit()
4146 air_sched->last_schedule_activity = now; in ieee80211_txq_may_transmit()
4150 out: in ieee80211_txq_may_transmit()
4151 spin_unlock_bh(&air_sched->lock); in ieee80211_txq_may_transmit()
4159 struct airtime_sched_info *air_sched = &local->airtime[ac]; in ieee80211_txq_schedule_start()
4161 spin_lock_bh(&air_sched->lock); in ieee80211_txq_schedule_start()
4162 air_sched->schedule_pos = NULL; in ieee80211_txq_schedule_start()
4163 spin_unlock_bh(&air_sched->lock); in ieee80211_txq_schedule_start()
4174 struct ieee80211_local *local = sdata->local; in __ieee80211_subif_start_xmit()
4178 if (unlikely(skb->len < ETH_HLEN)) { in __ieee80211_subif_start_xmit()
4191 if (local->ops->wake_tx_queue) { in __ieee80211_subif_start_xmit()
4202 sk_pacing_shift_update(skb->sk, sdata->local->hw.tx_sk_pacing_shift); in __ieee80211_subif_start_xmit()
4204 fast_tx = rcu_dereference(sta->fast_tx); in __ieee80211_subif_start_xmit()
4208 goto out; in __ieee80211_subif_start_xmit()
4222 /* we cannot process non-linear frames on this path */ in __ieee80211_subif_start_xmit()
4225 goto out; in __ieee80211_subif_start_xmit()
4228 /* the frame could be fragmented, software-encrypted, and other in __ieee80211_subif_start_xmit()
4229 * things so we cannot really handle checksum offload with it - in __ieee80211_subif_start_xmit()
4232 if (skb->ip_summed == CHECKSUM_PARTIAL) { in __ieee80211_subif_start_xmit()
4243 if (skb->protocol == sdata->control_port_protocol) in __ieee80211_subif_start_xmit()
4250 goto out; in __ieee80211_subif_start_xmit()
4253 dev_sw_netstats_tx_add(dev, 1, skb->len); in __ieee80211_subif_start_xmit()
4257 goto out; in __ieee80211_subif_start_xmit()
4260 out: in __ieee80211_subif_start_xmit()
4273 eth = (void *)skb->data; in ieee80211_change_da()
4274 ether_addr_copy(eth->h_dest, sta->sta.addr); in ieee80211_change_da()
4283 const struct ethhdr *eth = (void *)skb->data; in ieee80211_multicast_to_unicast()
4284 const struct vlan_ethhdr *ethvlan = (void *)skb->data; in ieee80211_multicast_to_unicast()
4287 if (likely(!is_multicast_ether_addr(eth->h_dest))) in ieee80211_multicast_to_unicast()
4290 switch (sdata->vif.type) { in ieee80211_multicast_to_unicast()
4292 if (sdata->u.vlan.sta) in ieee80211_multicast_to_unicast()
4294 if (sdata->wdev.use_4addr) in ieee80211_multicast_to_unicast()
4299 if (!sdata->bss->multicast_to_unicast) in ieee80211_multicast_to_unicast()
4307 ethertype = eth->h_proto; in ieee80211_multicast_to_unicast()
4308 if (ethertype == htons(ETH_P_8021Q) && skb->len >= VLAN_ETH_HLEN) in ieee80211_multicast_to_unicast()
4309 ethertype = ethvlan->h_vlan_encapsulated_proto; in ieee80211_multicast_to_unicast()
4327 struct ieee80211_local *local = sdata->local; in ieee80211_convert_to_unicast()
4328 const struct ethhdr *eth = (struct ethhdr *)skb->data; in ieee80211_convert_to_unicast()
4334 list_for_each_entry_rcu(sta, &local->sta_list, list) { in ieee80211_convert_to_unicast()
4335 if (sdata != sta->sdata) in ieee80211_convert_to_unicast()
4336 /* AP-VLAN mismatch */ in ieee80211_convert_to_unicast()
4338 if (unlikely(ether_addr_equal(eth->h_source, sta->sta.addr))) in ieee80211_convert_to_unicast()
4365 goto out; in ieee80211_convert_to_unicast()
4369 out: in ieee80211_convert_to_unicast()
4374 * ieee80211_subif_start_xmit - netif start_xmit function for 802.3 vifs
4402 struct ieee80211_local *local = sdata->local; in ieee80211_tx_8023()
4407 int q = info->hw_queue; in ieee80211_tx_8023()
4410 sk_pacing_shift_update(skb->sk, local->hw.tx_sk_pacing_shift); in ieee80211_tx_8023()
4415 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in ieee80211_tx_8023()
4417 if (local->queue_stop_reasons[q] || in ieee80211_tx_8023()
4418 (!txpending && !skb_queue_empty(&local->pending[q]))) { in ieee80211_tx_8023()
4420 skb_queue_head(&local->pending[q], skb); in ieee80211_tx_8023()
4422 skb_queue_tail(&local->pending[q], skb); in ieee80211_tx_8023()
4424 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_tx_8023()
4429 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_tx_8023()
4431 if (sta && sta->uploaded) in ieee80211_tx_8023()
4432 pubsta = &sta->sta; in ieee80211_tx_8023()
4446 struct ieee80211_local *local = sdata->local; in ieee80211_8023_xmit()
4450 if (local->ops->wake_tx_queue) { in ieee80211_8023_xmit()
4456 if (unlikely(test_bit(SCAN_SW_SCANNING, &local->scanning)) && in ieee80211_8023_xmit()
4457 test_bit(SDATA_STATE_OFFCHANNEL, &sdata->state)) in ieee80211_8023_xmit()
4464 tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; in ieee80211_8023_xmit()
4465 tid_tx = rcu_dereference(sta->ampdu_mlme.tid_tx[tid]); in ieee80211_8023_xmit()
4467 if (!test_bit(HT_AGG_STATE_OPERATIONAL, &tid_tx->state)) { in ieee80211_8023_xmit()
4468 /* fall back to non-offload slow path */ in ieee80211_8023_xmit()
4473 info->flags |= IEEE80211_TX_CTL_AMPDU; in ieee80211_8023_xmit()
4474 if (tid_tx->timeout) in ieee80211_8023_xmit()
4475 tid_tx->last_tx = jiffies; in ieee80211_8023_xmit()
4478 if (unlikely(skb->sk && in ieee80211_8023_xmit()
4479 skb_shinfo(skb)->tx_flags & SKBTX_WIFI_STATUS)) in ieee80211_8023_xmit()
4480 info->ack_frame_id = ieee80211_store_ack_skb(local, skb, in ieee80211_8023_xmit()
4481 &info->flags, NULL); in ieee80211_8023_xmit()
4483 info->hw_queue = sdata->vif.hw_queue[skb_get_queue_mapping(skb)]; in ieee80211_8023_xmit()
4485 dev_sw_netstats_tx_add(dev, 1, skb->len); in ieee80211_8023_xmit()
4487 sta->tx_stats.bytes[skb_get_queue_mapping(skb)] += skb->len; in ieee80211_8023_xmit()
4488 sta->tx_stats.packets[skb_get_queue_mapping(skb)]++; in ieee80211_8023_xmit()
4490 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) in ieee80211_8023_xmit()
4491 sdata = container_of(sdata->bss, in ieee80211_8023_xmit()
4494 info->flags |= IEEE80211_TX_CTL_HW_80211_ENCAP; in ieee80211_8023_xmit()
4495 info->control.vif = &sdata->vif; in ieee80211_8023_xmit()
4498 info->control.hw_key = &key->conf; in ieee80211_8023_xmit()
4500 ieee80211_tx_8023(sdata, skb, skb->len, sta, false); in ieee80211_8023_xmit()
4512 struct ethhdr *ehdr = (struct ethhdr *)skb->data; in ieee80211_subif_start_xmit_8023()
4516 if (unlikely(skb->len < ETH_HLEN)) { in ieee80211_subif_start_xmit_8023()
4525 goto out; in ieee80211_subif_start_xmit_8023()
4528 if (unlikely(IS_ERR_OR_NULL(sta) || !sta->uploaded || in ieee80211_subif_start_xmit_8023()
4530 sdata->control_port_protocol == ehdr->h_proto)) in ieee80211_subif_start_xmit_8023()
4533 key = rcu_dereference(sta->ptk[sta->ptk_idx]); in ieee80211_subif_start_xmit_8023()
4535 key = rcu_dereference(sdata->default_unicast_key); in ieee80211_subif_start_xmit_8023()
4537 if (key && (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) || in ieee80211_subif_start_xmit_8023()
4538 key->conf.cipher == WLAN_CIPHER_SUITE_TKIP)) in ieee80211_subif_start_xmit_8023()
4542 goto out; in ieee80211_subif_start_xmit_8023()
4546 out: in ieee80211_subif_start_xmit_8023()
4558 .local = sdata->local, in ieee80211_build_data_template()
4567 skb = ERR_PTR(-EINVAL); in ieee80211_build_data_template()
4568 goto out; in ieee80211_build_data_template()
4573 goto out; in ieee80211_build_data_template()
4575 hdr = (void *)skb->data; in ieee80211_build_data_template()
4576 tx.sta = sta_info_get(sdata, hdr->addr1); in ieee80211_build_data_template()
4582 return ERR_PTR(-EINVAL); in ieee80211_build_data_template()
4585 out: in ieee80211_build_data_template()
4599 for (i = 0; i < local->hw.queues; i++) { in ieee80211_clear_tx_pending()
4600 while ((skb = skb_dequeue(&local->pending[i])) != NULL) in ieee80211_clear_tx_pending()
4601 ieee80211_free_txskb(&local->hw, skb); in ieee80211_clear_tx_pending()
4607 * which in this case means re-queued -- take as an indication to stop sending
4620 sdata = vif_to_sdata(info->control.vif); in ieee80211_tx_pending_skb()
4622 if (info->control.flags & IEEE80211_TX_INTCFL_NEED_TXPROCESSING) { in ieee80211_tx_pending_skb()
4623 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); in ieee80211_tx_pending_skb()
4628 info->band = chanctx_conf->def.chan->band; in ieee80211_tx_pending_skb()
4630 } else if (info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP) { in ieee80211_tx_pending_skb()
4636 if (IS_ERR(sta) || (sta && !sta->uploaded)) in ieee80211_tx_pending_skb()
4639 result = ieee80211_tx_8023(sdata, skb, skb->len, sta, true); in ieee80211_tx_pending_skb()
4646 hdr = (struct ieee80211_hdr *)skb->data; in ieee80211_tx_pending_skb()
4647 sta = sta_info_get(sdata, hdr->addr1); in ieee80211_tx_pending_skb()
4649 result = __ieee80211_tx(local, &skbs, skb->len, sta, true); in ieee80211_tx_pending_skb()
4668 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in ieee80211_tx_pending()
4669 for (i = 0; i < local->hw.queues; i++) { in ieee80211_tx_pending()
4674 if (local->queue_stop_reasons[i] || in ieee80211_tx_pending()
4675 skb_queue_empty(&local->pending[i])) in ieee80211_tx_pending()
4678 while (!skb_queue_empty(&local->pending[i])) { in ieee80211_tx_pending()
4679 struct sk_buff *skb = __skb_dequeue(&local->pending[i]); in ieee80211_tx_pending()
4682 if (WARN_ON(!info->control.vif)) { in ieee80211_tx_pending()
4683 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_pending()
4687 spin_unlock_irqrestore(&local->queue_stop_reason_lock, in ieee80211_tx_pending()
4691 spin_lock_irqsave(&local->queue_stop_reason_lock, in ieee80211_tx_pending()
4697 if (skb_queue_empty(&local->pending[i])) in ieee80211_tx_pending()
4700 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_tx_pending()
4717 if (atomic_read(&ps->num_sta_ps) > 0) in __ieee80211_beacon_add_tim()
4719 * checking byte-for-byte */ in __ieee80211_beacon_add_tim()
4720 have_bits = !bitmap_empty((unsigned long *)ps->tim, in __ieee80211_beacon_add_tim()
4723 if (ps->dtim_count == 0) in __ieee80211_beacon_add_tim()
4724 ps->dtim_count = sdata->vif.bss_conf.dtim_period - 1; in __ieee80211_beacon_add_tim()
4726 ps->dtim_count--; in __ieee80211_beacon_add_tim()
4732 *pos++ = ps->dtim_count; in __ieee80211_beacon_add_tim()
4733 *pos++ = sdata->vif.bss_conf.dtim_period; in __ieee80211_beacon_add_tim()
4735 if (ps->dtim_count == 0 && !skb_queue_empty(&ps->bc_buf)) in __ieee80211_beacon_add_tim()
4738 ps->dtim_bc_mc = aid0 == 1; in __ieee80211_beacon_add_tim()
4742 * (N1 x 8) - 1 in the bitmap are 0 and number N2 so that bits in __ieee80211_beacon_add_tim()
4746 if (ps->tim[i]) { in __ieee80211_beacon_add_tim()
4752 for (i = IEEE80211_MAX_TIM_LEN - 1; i >= n1; i--) { in __ieee80211_beacon_add_tim()
4753 if (ps->tim[i]) { in __ieee80211_beacon_add_tim()
4762 skb_put(skb, n2 - n1); in __ieee80211_beacon_add_tim()
4763 memcpy(pos, ps->tim + n1, n2 - n1 + 1); in __ieee80211_beacon_add_tim()
4765 tim[1] = n2 - n1 + 4; in __ieee80211_beacon_add_tim()
4776 struct ieee80211_local *local = sdata->local; in ieee80211_beacon_add_tim()
4782 * sta_lock to guarantee consistent and race-free update in ieee80211_beacon_add_tim()
4783 * of the tim bitmap in mac80211 and the driver. in ieee80211_beacon_add_tim()
4785 if (local->tim_in_locked_section) { in ieee80211_beacon_add_tim()
4788 spin_lock_bh(&local->tim_lock); in ieee80211_beacon_add_tim()
4790 spin_unlock_bh(&local->tim_lock); in ieee80211_beacon_add_tim()
4805 switch (sdata->vif.type) { in ieee80211_set_beacon_cntdwn()
4807 beacon_data = beacon->tail; in ieee80211_set_beacon_cntdwn()
4808 beacon_data_len = beacon->tail_len; in ieee80211_set_beacon_cntdwn()
4811 beacon_data = beacon->head; in ieee80211_set_beacon_cntdwn()
4812 beacon_data_len = beacon->head_len; in ieee80211_set_beacon_cntdwn()
4815 beacon_data = beacon->head; in ieee80211_set_beacon_cntdwn()
4816 beacon_data_len = beacon->head_len; in ieee80211_set_beacon_cntdwn()
4823 resp = rcu_dereference(sdata->u.ap.probe_resp); in ieee80211_set_beacon_cntdwn()
4825 bcn_offsets = beacon->cntdwn_counter_offsets; in ieee80211_set_beacon_cntdwn()
4826 count = beacon->cntdwn_current_counter; in ieee80211_set_beacon_cntdwn()
4827 if (sdata->vif.csa_active) in ieee80211_set_beacon_cntdwn()
4839 if (sdata->vif.type == NL80211_IFTYPE_AP && resp) { in ieee80211_set_beacon_cntdwn()
4840 u16 *resp_offsets = resp->cntdwn_counter_offsets; in ieee80211_set_beacon_cntdwn()
4842 resp->data[resp_offsets[i]] = count; in ieee80211_set_beacon_cntdwn()
4850 beacon->cntdwn_current_counter--; in __ieee80211_beacon_update_cntdwn()
4853 WARN_ON_ONCE(!beacon->cntdwn_current_counter); in __ieee80211_beacon_update_cntdwn()
4855 return beacon->cntdwn_current_counter; in __ieee80211_beacon_update_cntdwn()
4866 if (sdata->vif.type == NL80211_IFTYPE_AP) in ieee80211_beacon_update_cntdwn()
4867 beacon = rcu_dereference(sdata->u.ap.beacon); in ieee80211_beacon_update_cntdwn()
4868 else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) in ieee80211_beacon_update_cntdwn()
4869 beacon = rcu_dereference(sdata->u.ibss.presp); in ieee80211_beacon_update_cntdwn()
4870 else if (ieee80211_vif_is_mesh(&sdata->vif)) in ieee80211_beacon_update_cntdwn()
4871 beacon = rcu_dereference(sdata->u.mesh.beacon); in ieee80211_beacon_update_cntdwn()
4891 if (sdata->vif.type == NL80211_IFTYPE_AP) in ieee80211_beacon_set_cntdwn()
4892 beacon = rcu_dereference(sdata->u.ap.beacon); in ieee80211_beacon_set_cntdwn()
4893 else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) in ieee80211_beacon_set_cntdwn()
4894 beacon = rcu_dereference(sdata->u.ibss.presp); in ieee80211_beacon_set_cntdwn()
4895 else if (ieee80211_vif_is_mesh(&sdata->vif)) in ieee80211_beacon_set_cntdwn()
4896 beacon = rcu_dereference(sdata->u.mesh.beacon); in ieee80211_beacon_set_cntdwn()
4901 if (counter < beacon->cntdwn_current_counter) in ieee80211_beacon_set_cntdwn()
4902 beacon->cntdwn_current_counter = counter; in ieee80211_beacon_set_cntdwn()
4921 if (vif->type == NL80211_IFTYPE_AP) { in ieee80211_beacon_cntdwn_is_complete()
4922 struct ieee80211_if_ap *ap = &sdata->u.ap; in ieee80211_beacon_cntdwn_is_complete()
4924 beacon = rcu_dereference(ap->beacon); in ieee80211_beacon_cntdwn_is_complete()
4925 if (WARN_ON(!beacon || !beacon->tail)) in ieee80211_beacon_cntdwn_is_complete()
4926 goto out; in ieee80211_beacon_cntdwn_is_complete()
4927 beacon_data = beacon->tail; in ieee80211_beacon_cntdwn_is_complete()
4928 beacon_data_len = beacon->tail_len; in ieee80211_beacon_cntdwn_is_complete()
4929 } else if (vif->type == NL80211_IFTYPE_ADHOC) { in ieee80211_beacon_cntdwn_is_complete()
4930 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; in ieee80211_beacon_cntdwn_is_complete()
4932 beacon = rcu_dereference(ifibss->presp); in ieee80211_beacon_cntdwn_is_complete()
4934 goto out; in ieee80211_beacon_cntdwn_is_complete()
4936 beacon_data = beacon->head; in ieee80211_beacon_cntdwn_is_complete()
4937 beacon_data_len = beacon->head_len; in ieee80211_beacon_cntdwn_is_complete()
4938 } else if (vif->type == NL80211_IFTYPE_MESH_POINT) { in ieee80211_beacon_cntdwn_is_complete()
4939 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; in ieee80211_beacon_cntdwn_is_complete()
4941 beacon = rcu_dereference(ifmsh->beacon); in ieee80211_beacon_cntdwn_is_complete()
4943 goto out; in ieee80211_beacon_cntdwn_is_complete()
4945 beacon_data = beacon->head; in ieee80211_beacon_cntdwn_is_complete()
4946 beacon_data_len = beacon->head_len; in ieee80211_beacon_cntdwn_is_complete()
4949 goto out; in ieee80211_beacon_cntdwn_is_complete()
4952 if (!beacon->cntdwn_counter_offsets[0]) in ieee80211_beacon_cntdwn_is_complete()
4953 goto out; in ieee80211_beacon_cntdwn_is_complete()
4955 if (WARN_ON_ONCE(beacon->cntdwn_counter_offsets[0] > beacon_data_len)) in ieee80211_beacon_cntdwn_is_complete()
4956 goto out; in ieee80211_beacon_cntdwn_is_complete()
4958 if (beacon_data[beacon->cntdwn_counter_offsets[0]] == 1) in ieee80211_beacon_cntdwn_is_complete()
4961 out: in ieee80211_beacon_cntdwn_is_complete()
4977 tx.key = rcu_dereference(sdata->default_beacon_key); in ieee80211_beacon_protect()
4989 return -EINVAL; in ieee80211_beacon_protect()
5005 enum nl80211_band band; in __ieee80211_beacon_get() local
5013 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); in __ieee80211_beacon_get()
5016 goto out; in __ieee80211_beacon_get()
5021 if (sdata->vif.type == NL80211_IFTYPE_AP) { in __ieee80211_beacon_get()
5022 struct ieee80211_if_ap *ap = &sdata->u.ap; in __ieee80211_beacon_get()
5024 beacon = rcu_dereference(ap->beacon); in __ieee80211_beacon_get()
5026 if (beacon->cntdwn_counter_offsets[0]) { in __ieee80211_beacon_get()
5037 skb = dev_alloc_skb(local->tx_headroom + in __ieee80211_beacon_get()
5038 beacon->head_len + in __ieee80211_beacon_get()
5039 beacon->tail_len + 256 + in __ieee80211_beacon_get()
5040 local->hw.extra_beacon_tailroom); in __ieee80211_beacon_get()
5042 goto out; in __ieee80211_beacon_get()
5044 skb_reserve(skb, local->tx_headroom); in __ieee80211_beacon_get()
5045 skb_put_data(skb, beacon->head, beacon->head_len); in __ieee80211_beacon_get()
5047 ieee80211_beacon_add_tim(sdata, &ap->ps, skb, in __ieee80211_beacon_get()
5051 offs->tim_offset = beacon->head_len; in __ieee80211_beacon_get()
5052 offs->tim_length = skb->len - beacon->head_len; in __ieee80211_beacon_get()
5053 offs->cntdwn_counter_offs[0] = beacon->cntdwn_counter_offsets[0]; in __ieee80211_beacon_get()
5056 csa_off_base = skb->len; in __ieee80211_beacon_get()
5059 if (beacon->tail) in __ieee80211_beacon_get()
5060 skb_put_data(skb, beacon->tail, in __ieee80211_beacon_get()
5061 beacon->tail_len); in __ieee80211_beacon_get()
5064 goto out; in __ieee80211_beacon_get()
5066 goto out; in __ieee80211_beacon_get()
5067 } else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) { in __ieee80211_beacon_get()
5068 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; in __ieee80211_beacon_get()
5071 beacon = rcu_dereference(ifibss->presp); in __ieee80211_beacon_get()
5073 goto out; in __ieee80211_beacon_get()
5075 if (beacon->cntdwn_counter_offsets[0]) { in __ieee80211_beacon_get()
5082 skb = dev_alloc_skb(local->tx_headroom + beacon->head_len + in __ieee80211_beacon_get()
5083 local->hw.extra_beacon_tailroom); in __ieee80211_beacon_get()
5085 goto out; in __ieee80211_beacon_get()
5086 skb_reserve(skb, local->tx_headroom); in __ieee80211_beacon_get()
5087 skb_put_data(skb, beacon->head, beacon->head_len); in __ieee80211_beacon_get()
5089 hdr = (struct ieee80211_hdr *) skb->data; in __ieee80211_beacon_get()
5090 hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | in __ieee80211_beacon_get()
5092 } else if (ieee80211_vif_is_mesh(&sdata->vif)) { in __ieee80211_beacon_get()
5093 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; in __ieee80211_beacon_get()
5095 beacon = rcu_dereference(ifmsh->beacon); in __ieee80211_beacon_get()
5097 goto out; in __ieee80211_beacon_get()
5099 if (beacon->cntdwn_counter_offsets[0]) { in __ieee80211_beacon_get()
5111 if (ifmsh->sync_ops) in __ieee80211_beacon_get()
5112 ifmsh->sync_ops->adjust_tsf(sdata, beacon); in __ieee80211_beacon_get()
5114 skb = dev_alloc_skb(local->tx_headroom + in __ieee80211_beacon_get()
5115 beacon->head_len + in __ieee80211_beacon_get()
5117 beacon->tail_len + in __ieee80211_beacon_get()
5118 local->hw.extra_beacon_tailroom); in __ieee80211_beacon_get()
5120 goto out; in __ieee80211_beacon_get()
5121 skb_reserve(skb, local->tx_headroom); in __ieee80211_beacon_get()
5122 skb_put_data(skb, beacon->head, beacon->head_len); in __ieee80211_beacon_get()
5123 ieee80211_beacon_add_tim(sdata, &ifmsh->ps, skb, is_template); in __ieee80211_beacon_get()
5126 offs->tim_offset = beacon->head_len; in __ieee80211_beacon_get()
5127 offs->tim_length = skb->len - beacon->head_len; in __ieee80211_beacon_get()
5130 skb_put_data(skb, beacon->tail, beacon->tail_len); in __ieee80211_beacon_get()
5133 goto out; in __ieee80211_beacon_get()
5141 u16 csa_off = beacon->cntdwn_counter_offsets[i]; in __ieee80211_beacon_get()
5146 offs->cntdwn_counter_offs[i] = csa_off_base + csa_off; in __ieee80211_beacon_get()
5150 band = chanctx_conf->def.chan->band; in __ieee80211_beacon_get()
5154 info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; in __ieee80211_beacon_get()
5155 info->flags |= IEEE80211_TX_CTL_NO_ACK; in __ieee80211_beacon_get()
5156 info->band = band; in __ieee80211_beacon_get()
5160 txrc.sband = local->hw.wiphy->bands[band]; in __ieee80211_beacon_get()
5161 txrc.bss_conf = &sdata->vif.bss_conf; in __ieee80211_beacon_get()
5163 txrc.reported_rate.idx = -1; in __ieee80211_beacon_get()
5164 if (sdata->beacon_rate_set && sdata->beacon_rateidx_mask[band]) in __ieee80211_beacon_get()
5165 txrc.rate_idx_mask = sdata->beacon_rateidx_mask[band]; in __ieee80211_beacon_get()
5167 txrc.rate_idx_mask = sdata->rc_rateidx_mask[band]; in __ieee80211_beacon_get()
5171 info->control.vif = vif; in __ieee80211_beacon_get()
5173 info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT | in __ieee80211_beacon_get()
5176 out: in __ieee80211_beacon_get()
5211 !hw_to_local(hw)->monitors) in ieee80211_beacon_get_tim()
5240 if (sdata->vif.type != NL80211_IFTYPE_AP) in ieee80211_proberesp_get()
5245 ap = &sdata->u.ap; in ieee80211_proberesp_get()
5246 presp = rcu_dereference(ap->probe_resp); in ieee80211_proberesp_get()
5248 goto out; in ieee80211_proberesp_get()
5250 skb = dev_alloc_skb(presp->len); in ieee80211_proberesp_get()
5252 goto out; in ieee80211_proberesp_get()
5254 skb_put_data(skb, presp->data, presp->len); in ieee80211_proberesp_get()
5256 hdr = (struct ieee80211_hdr *) skb->data; in ieee80211_proberesp_get()
5257 memset(hdr->addr1, 0, sizeof(hdr->addr1)); in ieee80211_proberesp_get()
5259 out: in ieee80211_proberesp_get()
5272 if (sdata->vif.type != NL80211_IFTYPE_AP) in ieee80211_get_fils_discovery_tmpl()
5276 tmpl = rcu_dereference(sdata->u.ap.fils_discovery); in ieee80211_get_fils_discovery_tmpl()
5282 skb = dev_alloc_skb(sdata->local->hw.extra_tx_headroom + tmpl->len); in ieee80211_get_fils_discovery_tmpl()
5284 skb_reserve(skb, sdata->local->hw.extra_tx_headroom); in ieee80211_get_fils_discovery_tmpl()
5285 skb_put_data(skb, tmpl->data, tmpl->len); in ieee80211_get_fils_discovery_tmpl()
5301 if (sdata->vif.type != NL80211_IFTYPE_AP) in ieee80211_get_unsol_bcast_probe_resp_tmpl()
5305 tmpl = rcu_dereference(sdata->u.ap.unsol_bcast_probe_resp); in ieee80211_get_unsol_bcast_probe_resp_tmpl()
5311 skb = dev_alloc_skb(sdata->local->hw.extra_tx_headroom + tmpl->len); in ieee80211_get_unsol_bcast_probe_resp_tmpl()
5313 skb_reserve(skb, sdata->local->hw.extra_tx_headroom); in ieee80211_get_unsol_bcast_probe_resp_tmpl()
5314 skb_put_data(skb, tmpl->data, tmpl->len); in ieee80211_get_unsol_bcast_probe_resp_tmpl()
5331 if (WARN_ON(vif->type != NL80211_IFTYPE_STATION)) in ieee80211_pspoll_get()
5335 ifmgd = &sdata->u.mgd; in ieee80211_pspoll_get()
5336 local = sdata->local; in ieee80211_pspoll_get()
5338 skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*pspoll)); in ieee80211_pspoll_get()
5342 skb_reserve(skb, local->hw.extra_tx_headroom); in ieee80211_pspoll_get()
5345 pspoll->frame_control = cpu_to_le16(IEEE80211_FTYPE_CTL | in ieee80211_pspoll_get()
5347 pspoll->aid = cpu_to_le16(sdata->vif.bss_conf.aid); in ieee80211_pspoll_get()
5349 /* aid in PS-Poll has its two MSBs each set to 1 */ in ieee80211_pspoll_get()
5350 pspoll->aid |= cpu_to_le16(1 << 15 | 1 << 14); in ieee80211_pspoll_get()
5352 memcpy(pspoll->bssid, ifmgd->bssid, ETH_ALEN); in ieee80211_pspoll_get()
5353 memcpy(pspoll->ta, vif->addr, ETH_ALEN); in ieee80211_pspoll_get()
5370 if (WARN_ON(vif->type != NL80211_IFTYPE_STATION)) in ieee80211_nullfunc_get()
5374 ifmgd = &sdata->u.mgd; in ieee80211_nullfunc_get()
5375 local = sdata->local; in ieee80211_nullfunc_get()
5381 sta = sta_info_get(sdata, ifmgd->bssid); in ieee80211_nullfunc_get()
5382 qos = sta && sta->sta.wme; in ieee80211_nullfunc_get()
5386 skb = dev_alloc_skb(local->hw.extra_tx_headroom + in ieee80211_nullfunc_get()
5391 skb_reserve(skb, local->hw.extra_tx_headroom); in ieee80211_nullfunc_get()
5394 nullfunc->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA | in ieee80211_nullfunc_get()
5403 nullfunc->frame_control |= in ieee80211_nullfunc_get()
5405 skb->priority = 7; in ieee80211_nullfunc_get()
5410 memcpy(nullfunc->addr1, ifmgd->bssid, ETH_ALEN); in ieee80211_nullfunc_get()
5411 memcpy(nullfunc->addr2, vif->addr, ETH_ALEN); in ieee80211_nullfunc_get()
5412 memcpy(nullfunc->addr3, ifmgd->bssid, ETH_ALEN); in ieee80211_nullfunc_get()
5431 skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*hdr) + in ieee80211_probereq_get()
5436 skb_reserve(skb, local->hw.extra_tx_headroom); in ieee80211_probereq_get()
5439 hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | in ieee80211_probereq_get()
5441 eth_broadcast_addr(hdr->addr1); in ieee80211_probereq_get()
5442 memcpy(hdr->addr2, src_addr, ETH_ALEN); in ieee80211_probereq_get()
5443 eth_broadcast_addr(hdr->addr3); in ieee80211_probereq_get()
5463 rts->frame_control = in ieee80211_rts_get()
5465 rts->duration = ieee80211_rts_duration(hw, vif, frame_len, in ieee80211_rts_get()
5467 memcpy(rts->ra, hdr->addr1, sizeof(rts->ra)); in ieee80211_rts_get()
5468 memcpy(rts->ta, hdr->addr2, sizeof(rts->ta)); in ieee80211_rts_get()
5479 cts->frame_control = in ieee80211_ctstoself_get()
5481 cts->duration = ieee80211_ctstoself_duration(hw, vif, in ieee80211_ctstoself_get()
5483 memcpy(cts->ra, hdr->addr1, sizeof(cts->ra)); in ieee80211_ctstoself_get()
5502 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); in ieee80211_get_buffered_bc()
5505 goto out; in ieee80211_get_buffered_bc()
5507 if (sdata->vif.type == NL80211_IFTYPE_AP) { in ieee80211_get_buffered_bc()
5509 rcu_dereference(sdata->u.ap.beacon); in ieee80211_get_buffered_bc()
5511 if (!beacon || !beacon->head) in ieee80211_get_buffered_bc()
5512 goto out; in ieee80211_get_buffered_bc()
5514 ps = &sdata->u.ap.ps; in ieee80211_get_buffered_bc()
5515 } else if (ieee80211_vif_is_mesh(&sdata->vif)) { in ieee80211_get_buffered_bc()
5516 ps = &sdata->u.mesh.ps; in ieee80211_get_buffered_bc()
5518 goto out; in ieee80211_get_buffered_bc()
5521 if (ps->dtim_count != 0 || !ps->dtim_bc_mc) in ieee80211_get_buffered_bc()
5522 goto out; /* send buffered bc/mc only after DTIM beacon */ in ieee80211_get_buffered_bc()
5525 skb = skb_dequeue(&ps->bc_buf); in ieee80211_get_buffered_bc()
5527 goto out; in ieee80211_get_buffered_bc()
5528 local->total_ps_buffered--; in ieee80211_get_buffered_bc()
5530 if (!skb_queue_empty(&ps->bc_buf) && skb->len >= 2) { in ieee80211_get_buffered_bc()
5532 (struct ieee80211_hdr *) skb->data; in ieee80211_get_buffered_bc()
5536 hdr->frame_control |= in ieee80211_get_buffered_bc()
5540 if (sdata->vif.type == NL80211_IFTYPE_AP) in ieee80211_get_buffered_bc()
5541 sdata = IEEE80211_DEV_TO_SUB_IF(skb->dev); in ieee80211_get_buffered_bc()
5550 info->band = chanctx_conf->def.chan->band; in ieee80211_get_buffered_bc()
5554 out: in ieee80211_get_buffered_bc()
5564 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_reserve_tid()
5565 struct ieee80211_local *local = sdata->local; in ieee80211_reserve_tid()
5569 lockdep_assert_held(&local->sta_mtx); in ieee80211_reserve_tid()
5572 switch (sdata->vif.type) { in ieee80211_reserve_tid()
5579 return -EINVAL; in ieee80211_reserve_tid()
5583 return -EINVAL; in ieee80211_reserve_tid()
5585 if (sta->reserved_tid == tid) { in ieee80211_reserve_tid()
5587 goto out; in ieee80211_reserve_tid()
5590 if (sta->reserved_tid != IEEE80211_TID_UNRESERVED) { in ieee80211_reserve_tid()
5592 ret = -EALREADY; in ieee80211_reserve_tid()
5593 goto out; in ieee80211_reserve_tid()
5596 ieee80211_stop_vif_queues(sdata->local, sdata, in ieee80211_reserve_tid()
5602 if (ieee80211_hw_check(&local->hw, AMPDU_AGGREGATION)) { in ieee80211_reserve_tid()
5608 queues = BIT(sdata->vif.hw_queue[ieee802_1d_to_ac[tid]]); in ieee80211_reserve_tid()
5611 sta->reserved_tid = tid; in ieee80211_reserve_tid()
5616 if (ieee80211_hw_check(&local->hw, AMPDU_AGGREGATION)) in ieee80211_reserve_tid()
5620 out: in ieee80211_reserve_tid()
5628 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_unreserve_tid()
5630 lockdep_assert_held(&sdata->local->sta_mtx); in ieee80211_unreserve_tid()
5633 switch (sdata->vif.type) { in ieee80211_unreserve_tid()
5643 if (tid != sta->reserved_tid) { in ieee80211_unreserve_tid()
5648 sta->reserved_tid = IEEE80211_TID_UNRESERVED; in ieee80211_unreserve_tid()
5654 enum nl80211_band band) in __ieee80211_tx_skb_tid_band() argument
5660 skb->priority = tid; in __ieee80211_tx_skb_tid_band()
5662 skb->dev = sdata->dev; in __ieee80211_tx_skb_tid_band()
5670 IEEE80211_SKB_CB(skb)->band = band; in __ieee80211_tx_skb_tid_band()
5681 struct ieee80211_local *local = sdata->local; in ieee80211_tx_control_port()
5689 * or Pre-Authentication in ieee80211_tx_control_port()
5691 if (proto != sdata->control_port_protocol && in ieee80211_tx_control_port()
5693 return -EINVAL; in ieee80211_tx_control_port()
5695 if (proto == sdata->control_port_protocol) in ieee80211_tx_control_port()
5707 skb = dev_alloc_skb(local->hw.extra_tx_headroom + in ieee80211_tx_control_port()
5710 return -ENOMEM; in ieee80211_tx_control_port()
5712 skb_reserve(skb, local->hw.extra_tx_headroom + sizeof(struct ethhdr)); in ieee80211_tx_control_port()
5717 memcpy(ehdr->h_dest, dest, ETH_ALEN); in ieee80211_tx_control_port()
5718 memcpy(ehdr->h_source, sdata->vif.addr, ETH_ALEN); in ieee80211_tx_control_port()
5719 ehdr->h_proto = proto; in ieee80211_tx_control_port()
5721 skb->dev = dev; in ieee80211_tx_control_port()
5722 skb->protocol = proto; in ieee80211_tx_control_port()
5742 mutex_lock(&local->mtx); in ieee80211_tx_control_port()
5745 __ieee80211_subif_start_xmit(skb, skb->dev, flags, ctrl_flags, cookie); in ieee80211_tx_control_port()
5748 mutex_unlock(&local->mtx); in ieee80211_tx_control_port()
5757 struct ieee80211_local *local = sdata->local; in ieee80211_probe_mesh_link()
5760 skb = dev_alloc_skb(local->hw.extra_tx_headroom + len + in ieee80211_probe_mesh_link()
5764 return -ENOMEM; in ieee80211_probe_mesh_link()
5766 skb_reserve(skb, local->hw.extra_tx_headroom); in ieee80211_probe_mesh_link()
5769 skb->dev = dev; in ieee80211_probe_mesh_link()
5770 skb->protocol = htons(ETH_P_802_3); in ieee80211_probe_mesh_link()
5775 __ieee80211_subif_start_xmit(skb, skb->dev, 0, in ieee80211_probe_mesh_link()