• Home
  • Raw
  • Download

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-2020 Intel Corporation
31 #include "driver-ops.h"
43 struct pcpu_sw_netstats *tstats = this_cpu_ptr(dev->tstats); in ieee80211_tx_stats()
45 u64_stats_update_begin(&tstats->syncp); in ieee80211_tx_stats()
46 tstats->tx_packets++; in ieee80211_tx_stats()
47 tstats->tx_bytes += len; in ieee80211_tx_stats()
48 u64_stats_update_end(&tstats->syncp); in ieee80211_tx_stats()
57 struct ieee80211_local *local = tx->local; in ieee80211_duration()
65 if (tx->rate.flags & (IEEE80211_TX_RC_MCS | IEEE80211_TX_RC_VHT_MCS)) in ieee80211_duration()
69 chanctx_conf = rcu_dereference(tx->sdata->vif.chanctx_conf); in ieee80211_duration()
71 shift = ieee80211_chandef_get_shift(&chanctx_conf->def); in ieee80211_duration()
72 rate_flags = ieee80211_chandef_rate_flags(&chanctx_conf->def); in ieee80211_duration()
77 if (WARN_ON_ONCE(tx->rate.idx < 0)) in ieee80211_duration()
80 sband = local->hw.wiphy->bands[info->band]; in ieee80211_duration()
81 txrate = &sband->bitrates[tx->rate.idx]; in ieee80211_duration()
83 erp = txrate->flags & IEEE80211_RATE_ERP_G; in ieee80211_duration()
86 if (sband->band == NL80211_BAND_S1GHZ) in ieee80211_duration()
91 * - during CFP: 32768 in ieee80211_duration()
92 * - during contention period: in ieee80211_duration()
100 * - control response frame (CTS or ACK) shall be transmitted using the in ieee80211_duration()
106 hdr = (struct ieee80211_hdr *)skb->data; in ieee80211_duration()
107 if (ieee80211_is_ctl(hdr->frame_control)) { in ieee80211_duration()
114 * CTS: duration of immediately previous RTS minus time in ieee80211_duration()
129 if (group_addr) /* Group address as the destination - no ACK */ in ieee80211_duration()
135 * basic rate set that is less than or equal to the rate of the in ieee80211_duration()
138 * the highest mandatory rate of the PHY that is less than or equal to in ieee80211_duration()
139 * the rate of the previous frame is used. in ieee80211_duration()
142 rate = -1; in ieee80211_duration()
144 mrate = sband->bitrates[0].bitrate; in ieee80211_duration()
145 for (i = 0; i < sband->n_bitrates; i++) { in ieee80211_duration()
146 struct ieee80211_rate *r = &sband->bitrates[i]; in ieee80211_duration()
148 if (r->bitrate > txrate->bitrate) in ieee80211_duration()
151 if ((rate_flags & r->flags) != rate_flags) in ieee80211_duration()
154 if (tx->sdata->vif.bss_conf.basic_rates & BIT(i)) in ieee80211_duration()
155 rate = DIV_ROUND_UP(r->bitrate, 1 << shift); in ieee80211_duration()
157 switch (sband->band) { in ieee80211_duration()
160 if (tx->sdata->flags & IEEE80211_SDATA_OPERATING_GMODE) in ieee80211_duration()
164 if (r->flags & flag) in ieee80211_duration()
165 mrate = r->bitrate; in ieee80211_duration()
170 if (r->flags & IEEE80211_RATE_MANDATORY_A) in ieee80211_duration()
171 mrate = r->bitrate; in ieee80211_duration()
181 if (rate == -1) { in ieee80211_duration()
188 if (ieee80211_is_data_qos(hdr->frame_control) && in ieee80211_duration()
193 * (10 bytes + 4-byte FCS = 112 bits) plus SIFS; rounded up in ieee80211_duration()
195 dur = ieee80211_frame_duration(sband->band, 10, rate, erp, in ieee80211_duration()
196 tx->sdata->vif.bss_conf.use_short_preamble, in ieee80211_duration()
204 dur += ieee80211_frame_duration(sband->band, next_frag_len, in ieee80211_duration()
205 txrate->bitrate, erp, in ieee80211_duration()
206 tx->sdata->vif.bss_conf.use_short_preamble, in ieee80211_duration()
217 struct ieee80211_local *local = tx->local; in ieee80211_tx_h_dynamic_ps()
219 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); in ieee80211_tx_h_dynamic_ps()
222 if (!ieee80211_hw_check(&local->hw, SUPPORTS_PS)) in ieee80211_tx_h_dynamic_ps()
226 if (ieee80211_hw_check(&local->hw, SUPPORTS_DYNAMIC_PS)) in ieee80211_tx_h_dynamic_ps()
230 if (local->hw.conf.dynamic_ps_timeout <= 0) in ieee80211_tx_h_dynamic_ps()
234 if (local->scanning) in ieee80211_tx_h_dynamic_ps()
237 if (!local->ps_sdata) in ieee80211_tx_h_dynamic_ps()
241 if (local->quiescing) in ieee80211_tx_h_dynamic_ps()
245 if (tx->sdata->vif.type != NL80211_IFTYPE_STATION) in ieee80211_tx_h_dynamic_ps()
248 if (unlikely(info->flags & IEEE80211_TX_INTFL_OFFCHAN_TX_OK)) in ieee80211_tx_h_dynamic_ps()
251 ifmgd = &tx->sdata->u.mgd; in ieee80211_tx_h_dynamic_ps()
254 * Don't wakeup from power save if u-apsd is enabled, voip ac has in ieee80211_tx_h_dynamic_ps()
255 * u-apsd enabled and the frame is in voip class. This effectively in ieee80211_tx_h_dynamic_ps()
256 * means that even if all access categories have u-apsd enabled, in in ieee80211_tx_h_dynamic_ps()
257 * practise u-apsd is only used with the voip ac. This is a in ieee80211_tx_h_dynamic_ps()
262 * Note: ifmgd->uapsd_queues access is racy here. If the value is in ieee80211_tx_h_dynamic_ps()
266 if ((ifmgd->flags & IEEE80211_STA_UAPSD_ENABLED) && in ieee80211_tx_h_dynamic_ps()
267 (ifmgd->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VO) && in ieee80211_tx_h_dynamic_ps()
268 skb_get_queue_mapping(tx->skb) == IEEE80211_AC_VO) in ieee80211_tx_h_dynamic_ps()
271 if (local->hw.conf.flags & IEEE80211_CONF_PS) { in ieee80211_tx_h_dynamic_ps()
272 ieee80211_stop_queues_by_reason(&local->hw, in ieee80211_tx_h_dynamic_ps()
276 ifmgd->flags &= ~IEEE80211_STA_NULLFUNC_ACKED; in ieee80211_tx_h_dynamic_ps()
277 ieee80211_queue_work(&local->hw, in ieee80211_tx_h_dynamic_ps()
278 &local->dynamic_ps_disable_work); in ieee80211_tx_h_dynamic_ps()
282 if (!ifmgd->associated) in ieee80211_tx_h_dynamic_ps()
285 mod_timer(&local->dynamic_ps_timer, jiffies + in ieee80211_tx_h_dynamic_ps()
286 msecs_to_jiffies(local->hw.conf.dynamic_ps_timeout)); in ieee80211_tx_h_dynamic_ps()
295 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; in ieee80211_tx_h_check_assoc()
296 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); in ieee80211_tx_h_check_assoc()
299 if (unlikely(info->flags & IEEE80211_TX_CTL_INJECTED)) in ieee80211_tx_h_check_assoc()
302 if (unlikely(test_bit(SCAN_SW_SCANNING, &tx->local->scanning)) && in ieee80211_tx_h_check_assoc()
303 test_bit(SDATA_STATE_OFFCHANNEL, &tx->sdata->state) && in ieee80211_tx_h_check_assoc()
304 !ieee80211_is_probe_req(hdr->frame_control) && in ieee80211_tx_h_check_assoc()
305 !ieee80211_is_any_nullfunc(hdr->frame_control)) in ieee80211_tx_h_check_assoc()
312 * off-channel. See the link below and in ieee80211_tx_h_check_assoc()
319 if (tx->sdata->vif.type == NL80211_IFTYPE_OCB) in ieee80211_tx_h_check_assoc()
322 if (tx->sdata->vif.type == NL80211_IFTYPE_WDS) in ieee80211_tx_h_check_assoc()
325 if (tx->flags & IEEE80211_TX_PS_BUFFERED) in ieee80211_tx_h_check_assoc()
328 if (tx->sta) in ieee80211_tx_h_check_assoc()
329 assoc = test_sta_flag(tx->sta, WLAN_STA_ASSOC); in ieee80211_tx_h_check_assoc()
331 if (likely(tx->flags & IEEE80211_TX_UNICAST)) { in ieee80211_tx_h_check_assoc()
333 ieee80211_is_data(hdr->frame_control))) { in ieee80211_tx_h_check_assoc()
335 sdata_info(tx->sdata, in ieee80211_tx_h_check_assoc()
337 hdr->addr1); in ieee80211_tx_h_check_assoc()
339 I802_DEBUG_INC(tx->local->tx_handlers_drop_not_assoc); in ieee80211_tx_h_check_assoc()
342 } else if (unlikely(ieee80211_is_data(hdr->frame_control) && in ieee80211_tx_h_check_assoc()
343 ieee80211_vif_get_num_mcast_if(tx->sdata) == 0)) { in ieee80211_tx_h_check_assoc()
345 * No associated STAs - no need to send multicast in ieee80211_tx_h_check_assoc()
355 * of buffered frames for power saving STAs. This situation should not really
365 list_for_each_entry_rcu(sdata, &local->interfaces, list) { in purge_old_ps_buffers()
368 if (sdata->vif.type == NL80211_IFTYPE_AP) in purge_old_ps_buffers()
369 ps = &sdata->u.ap.ps; in purge_old_ps_buffers()
370 else if (ieee80211_vif_is_mesh(&sdata->vif)) in purge_old_ps_buffers()
371 ps = &sdata->u.mesh.ps; in purge_old_ps_buffers()
375 skb = skb_dequeue(&ps->bc_buf); in purge_old_ps_buffers()
378 ieee80211_free_txskb(&local->hw, skb); in purge_old_ps_buffers()
380 total += skb_queue_len(&ps->bc_buf); in purge_old_ps_buffers()
384 * Drop one frame from each station from the lowest-priority in purge_old_ps_buffers()
387 list_for_each_entry_rcu(sta, &local->sta_list, list) { in purge_old_ps_buffers()
390 for (ac = IEEE80211_AC_BK; ac >= IEEE80211_AC_VO; ac--) { in purge_old_ps_buffers()
391 skb = skb_dequeue(&sta->ps_tx_buf[ac]); in purge_old_ps_buffers()
392 total += skb_queue_len(&sta->ps_tx_buf[ac]); in purge_old_ps_buffers()
395 ieee80211_free_txskb(&local->hw, skb); in purge_old_ps_buffers()
401 local->total_ps_buffered = total; in purge_old_ps_buffers()
402 ps_dbg_hw(&local->hw, "PS buffers full - purged %d frames\n", purged); in purge_old_ps_buffers()
408 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); in ieee80211_tx_h_multicast_ps_buf()
409 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; in ieee80211_tx_h_multicast_ps_buf()
415 * If any of the associated/peer stations is in power save mode, in ieee80211_tx_h_multicast_ps_buf()
421 if (tx->sdata->vif.type == NL80211_IFTYPE_AP || in ieee80211_tx_h_multicast_ps_buf()
422 tx->sdata->vif.type == NL80211_IFTYPE_AP_VLAN) { in ieee80211_tx_h_multicast_ps_buf()
423 if (!tx->sdata->bss) in ieee80211_tx_h_multicast_ps_buf()
426 ps = &tx->sdata->bss->ps; in ieee80211_tx_h_multicast_ps_buf()
427 } else if (ieee80211_vif_is_mesh(&tx->sdata->vif)) { in ieee80211_tx_h_multicast_ps_buf()
428 ps = &tx->sdata->u.mesh.ps; in ieee80211_tx_h_multicast_ps_buf()
435 if (ieee80211_has_order(hdr->frame_control)) in ieee80211_tx_h_multicast_ps_buf()
438 if (ieee80211_is_probe_req(hdr->frame_control)) in ieee80211_tx_h_multicast_ps_buf()
441 if (ieee80211_hw_check(&tx->local->hw, QUEUE_CONTROL)) in ieee80211_tx_h_multicast_ps_buf()
442 info->hw_queue = tx->sdata->vif.cab_queue; in ieee80211_tx_h_multicast_ps_buf()
445 if (!atomic_read(&ps->num_sta_ps) && skb_queue_empty(&ps->bc_buf)) in ieee80211_tx_h_multicast_ps_buf()
448 info->flags |= IEEE80211_TX_CTL_SEND_AFTER_DTIM; in ieee80211_tx_h_multicast_ps_buf()
451 if (!ieee80211_hw_check(&tx->local->hw, HOST_BROADCAST_PS_BUFFERING)) in ieee80211_tx_h_multicast_ps_buf()
455 if (tx->local->total_ps_buffered >= TOTAL_MAX_TX_BUFFER) in ieee80211_tx_h_multicast_ps_buf()
456 purge_old_ps_buffers(tx->local); in ieee80211_tx_h_multicast_ps_buf()
458 if (skb_queue_len(&ps->bc_buf) >= AP_MAX_BC_BUFFER) { in ieee80211_tx_h_multicast_ps_buf()
459 ps_dbg(tx->sdata, in ieee80211_tx_h_multicast_ps_buf()
460 "BC TX buffer full - dropping the oldest frame\n"); in ieee80211_tx_h_multicast_ps_buf()
461 ieee80211_free_txskb(&tx->local->hw, skb_dequeue(&ps->bc_buf)); in ieee80211_tx_h_multicast_ps_buf()
463 tx->local->total_ps_buffered++; in ieee80211_tx_h_multicast_ps_buf()
465 skb_queue_tail(&ps->bc_buf, tx->skb); in ieee80211_tx_h_multicast_ps_buf()
488 struct sta_info *sta = tx->sta; in ieee80211_tx_h_unicast_ps_buf()
489 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); in ieee80211_tx_h_unicast_ps_buf()
490 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; in ieee80211_tx_h_unicast_ps_buf()
491 struct ieee80211_local *local = tx->local; in ieee80211_tx_h_unicast_ps_buf()
499 !(info->flags & IEEE80211_TX_CTL_NO_PS_BUFFER))) { in ieee80211_tx_h_unicast_ps_buf()
500 int ac = skb_get_queue_mapping(tx->skb); in ieee80211_tx_h_unicast_ps_buf()
502 if (ieee80211_is_mgmt(hdr->frame_control) && in ieee80211_tx_h_unicast_ps_buf()
503 !ieee80211_is_bufferable_mmpdu(hdr->frame_control)) { in ieee80211_tx_h_unicast_ps_buf()
504 info->flags |= IEEE80211_TX_CTL_NO_PS_BUFFER; in ieee80211_tx_h_unicast_ps_buf()
508 ps_dbg(sta->sdata, "STA %pM aid %d: PS buffer for AC %d\n", in ieee80211_tx_h_unicast_ps_buf()
509 sta->sta.addr, sta->sta.aid, ac); in ieee80211_tx_h_unicast_ps_buf()
510 if (tx->local->total_ps_buffered >= TOTAL_MAX_TX_BUFFER) in ieee80211_tx_h_unicast_ps_buf()
511 purge_old_ps_buffers(tx->local); in ieee80211_tx_h_unicast_ps_buf()
514 spin_lock(&sta->ps_lock); in ieee80211_tx_h_unicast_ps_buf()
523 spin_unlock(&sta->ps_lock); in ieee80211_tx_h_unicast_ps_buf()
527 if (skb_queue_len(&sta->ps_tx_buf[ac]) >= STA_MAX_TX_BUFFER) { in ieee80211_tx_h_unicast_ps_buf()
528 struct sk_buff *old = skb_dequeue(&sta->ps_tx_buf[ac]); in ieee80211_tx_h_unicast_ps_buf()
529 ps_dbg(tx->sdata, in ieee80211_tx_h_unicast_ps_buf()
530 "STA %pM TX buffer for AC %d full - dropping oldest frame\n", in ieee80211_tx_h_unicast_ps_buf()
531 sta->sta.addr, ac); in ieee80211_tx_h_unicast_ps_buf()
532 ieee80211_free_txskb(&local->hw, old); in ieee80211_tx_h_unicast_ps_buf()
534 tx->local->total_ps_buffered++; in ieee80211_tx_h_unicast_ps_buf()
536 info->control.jiffies = jiffies; in ieee80211_tx_h_unicast_ps_buf()
537 info->control.vif = &tx->sdata->vif; in ieee80211_tx_h_unicast_ps_buf()
538 info->control.flags |= IEEE80211_TX_INTCFL_NEED_TXPROCESSING; in ieee80211_tx_h_unicast_ps_buf()
539 info->flags &= ~IEEE80211_TX_TEMPORARY_FLAGS; in ieee80211_tx_h_unicast_ps_buf()
540 skb_queue_tail(&sta->ps_tx_buf[ac], tx->skb); in ieee80211_tx_h_unicast_ps_buf()
541 spin_unlock(&sta->ps_lock); in ieee80211_tx_h_unicast_ps_buf()
543 if (!timer_pending(&local->sta_cleanup)) in ieee80211_tx_h_unicast_ps_buf()
544 mod_timer(&local->sta_cleanup, in ieee80211_tx_h_unicast_ps_buf()
556 ps_dbg(tx->sdata, in ieee80211_tx_h_unicast_ps_buf()
557 "STA %pM in PS mode, but polling/in SP -> send frame\n", in ieee80211_tx_h_unicast_ps_buf()
558 sta->sta.addr); in ieee80211_tx_h_unicast_ps_buf()
567 if (unlikely(tx->flags & IEEE80211_TX_PS_BUFFERED)) in ieee80211_tx_h_ps_buf()
570 if (tx->flags & IEEE80211_TX_UNICAST) in ieee80211_tx_h_ps_buf()
579 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); in ieee80211_tx_h_check_control_port_protocol()
581 if (unlikely(tx->sdata->control_port_protocol == tx->skb->protocol)) { in ieee80211_tx_h_check_control_port_protocol()
582 if (tx->sdata->control_port_no_encrypt) in ieee80211_tx_h_check_control_port_protocol()
583 info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; in ieee80211_tx_h_check_control_port_protocol()
584 info->control.flags |= IEEE80211_TX_CTRL_PORT_CTRL_PROTO; in ieee80211_tx_h_check_control_port_protocol()
585 info->flags |= IEEE80211_TX_CTL_USE_MINRATE; in ieee80211_tx_h_check_control_port_protocol()
595 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); in ieee80211_tx_h_select_key()
596 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; in ieee80211_tx_h_select_key()
598 if (unlikely(info->flags & IEEE80211_TX_INTFL_DONT_ENCRYPT)) { in ieee80211_tx_h_select_key()
599 tx->key = NULL; in ieee80211_tx_h_select_key()
603 if (tx->sta && in ieee80211_tx_h_select_key()
604 (key = rcu_dereference(tx->sta->ptk[tx->sta->ptk_idx]))) in ieee80211_tx_h_select_key()
605 tx->key = key; in ieee80211_tx_h_select_key()
606 else if (ieee80211_is_group_privacy_action(tx->skb) && in ieee80211_tx_h_select_key()
607 (key = rcu_dereference(tx->sdata->default_multicast_key))) in ieee80211_tx_h_select_key()
608 tx->key = key; in ieee80211_tx_h_select_key()
609 else if (ieee80211_is_mgmt(hdr->frame_control) && in ieee80211_tx_h_select_key()
610 is_multicast_ether_addr(hdr->addr1) && in ieee80211_tx_h_select_key()
611 ieee80211_is_robust_mgmt_frame(tx->skb) && in ieee80211_tx_h_select_key()
612 (key = rcu_dereference(tx->sdata->default_mgmt_key))) in ieee80211_tx_h_select_key()
613 tx->key = key; in ieee80211_tx_h_select_key()
614 else if (is_multicast_ether_addr(hdr->addr1) && in ieee80211_tx_h_select_key()
615 (key = rcu_dereference(tx->sdata->default_multicast_key))) in ieee80211_tx_h_select_key()
616 tx->key = key; in ieee80211_tx_h_select_key()
617 else if (!is_multicast_ether_addr(hdr->addr1) && in ieee80211_tx_h_select_key()
618 (key = rcu_dereference(tx->sdata->default_unicast_key))) in ieee80211_tx_h_select_key()
619 tx->key = key; in ieee80211_tx_h_select_key()
621 tx->key = NULL; in ieee80211_tx_h_select_key()
623 if (tx->key) { in ieee80211_tx_h_select_key()
628 switch (tx->key->conf.cipher) { in ieee80211_tx_h_select_key()
632 if (!ieee80211_is_data_present(hdr->frame_control)) in ieee80211_tx_h_select_key()
633 tx->key = NULL; in ieee80211_tx_h_select_key()
639 if (!ieee80211_is_data_present(hdr->frame_control) && in ieee80211_tx_h_select_key()
640 !ieee80211_use_mfp(hdr->frame_control, tx->sta, in ieee80211_tx_h_select_key()
641 tx->skb) && in ieee80211_tx_h_select_key()
642 !ieee80211_is_group_privacy_action(tx->skb)) in ieee80211_tx_h_select_key()
643 tx->key = NULL; in ieee80211_tx_h_select_key()
645 skip_hw = (tx->key->conf.flags & in ieee80211_tx_h_select_key()
647 ieee80211_is_mgmt(hdr->frame_control); in ieee80211_tx_h_select_key()
653 if (!ieee80211_is_mgmt(hdr->frame_control)) in ieee80211_tx_h_select_key()
654 tx->key = NULL; in ieee80211_tx_h_select_key()
658 if (unlikely(tx->key && tx->key->flags & KEY_FLAG_TAINTED && in ieee80211_tx_h_select_key()
659 !ieee80211_is_deauth(hdr->frame_control))) in ieee80211_tx_h_select_key()
662 if (!skip_hw && tx->key && in ieee80211_tx_h_select_key()
663 tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) in ieee80211_tx_h_select_key()
664 info->control.hw_key = &tx->key->conf; in ieee80211_tx_h_select_key()
665 } else if (ieee80211_is_data_present(hdr->frame_control) && tx->sta && in ieee80211_tx_h_select_key()
666 test_sta_flag(tx->sta, WLAN_STA_USES_ENCRYPTION)) { in ieee80211_tx_h_select_key()
676 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); in ieee80211_tx_h_rate_ctrl()
677 struct ieee80211_hdr *hdr = (void *)tx->skb->data; in ieee80211_tx_h_rate_ctrl()
686 sband = tx->local->hw.wiphy->bands[info->band]; in ieee80211_tx_h_rate_ctrl()
688 len = min_t(u32, tx->skb->len + FCS_LEN, in ieee80211_tx_h_rate_ctrl()
689 tx->local->hw.wiphy->frag_threshold); in ieee80211_tx_h_rate_ctrl()
692 txrc.hw = &tx->local->hw; in ieee80211_tx_h_rate_ctrl()
694 txrc.bss_conf = &tx->sdata->vif.bss_conf; in ieee80211_tx_h_rate_ctrl()
695 txrc.skb = tx->skb; in ieee80211_tx_h_rate_ctrl()
696 txrc.reported_rate.idx = -1; in ieee80211_tx_h_rate_ctrl()
697 txrc.rate_idx_mask = tx->sdata->rc_rateidx_mask[info->band]; in ieee80211_tx_h_rate_ctrl()
699 if (tx->sdata->rc_has_mcs_mask[info->band]) in ieee80211_tx_h_rate_ctrl()
701 tx->sdata->rc_rateidx_mcs_mask[info->band]; in ieee80211_tx_h_rate_ctrl()
703 txrc.bss = (tx->sdata->vif.type == NL80211_IFTYPE_AP || in ieee80211_tx_h_rate_ctrl()
704 tx->sdata->vif.type == NL80211_IFTYPE_MESH_POINT || in ieee80211_tx_h_rate_ctrl()
705 tx->sdata->vif.type == NL80211_IFTYPE_ADHOC || in ieee80211_tx_h_rate_ctrl()
706 tx->sdata->vif.type == NL80211_IFTYPE_OCB); in ieee80211_tx_h_rate_ctrl()
709 if (len > tx->local->hw.wiphy->rts_threshold) { in ieee80211_tx_h_rate_ctrl()
713 info->control.use_rts = txrc.rts; in ieee80211_tx_h_rate_ctrl()
714 info->control.use_cts_prot = tx->sdata->vif.bss_conf.use_cts_prot; in ieee80211_tx_h_rate_ctrl()
719 * that -- the management frame might be to a station that in ieee80211_tx_h_rate_ctrl()
722 if (tx->sdata->vif.bss_conf.use_short_preamble && in ieee80211_tx_h_rate_ctrl()
723 (ieee80211_is_data(hdr->frame_control) || in ieee80211_tx_h_rate_ctrl()
724 (tx->sta && test_sta_flag(tx->sta, WLAN_STA_SHORT_PREAMBLE)))) in ieee80211_tx_h_rate_ctrl()
727 info->control.short_preamble = txrc.short_preamble; in ieee80211_tx_h_rate_ctrl()
730 if (info->control.flags & IEEE80211_TX_CTRL_RATE_INJECT) in ieee80211_tx_h_rate_ctrl()
733 if (tx->sta) in ieee80211_tx_h_rate_ctrl()
734 assoc = test_sta_flag(tx->sta, WLAN_STA_ASSOC); in ieee80211_tx_h_rate_ctrl()
740 if (WARN(test_bit(SCAN_SW_SCANNING, &tx->local->scanning) && assoc && in ieee80211_tx_h_rate_ctrl()
741 !rate_usable_index_exists(sband, &tx->sta->sta), in ieee80211_tx_h_rate_ctrl()
744 "%pM on %d GHz band\n", in ieee80211_tx_h_rate_ctrl()
745 tx->sdata->name, hdr->addr1, in ieee80211_tx_h_rate_ctrl()
746 info->band ? 5 : 2)) in ieee80211_tx_h_rate_ctrl()
753 rate_control_get_rate(tx->sdata, tx->sta, &txrc); in ieee80211_tx_h_rate_ctrl()
755 if (tx->sta && !info->control.skip_table) in ieee80211_tx_h_rate_ctrl()
756 ratetbl = rcu_dereference(tx->sta->sta.rates); in ieee80211_tx_h_rate_ctrl()
758 if (unlikely(info->control.rates[0].idx < 0)) { in ieee80211_tx_h_rate_ctrl()
761 .idx = ratetbl->rate[0].idx, in ieee80211_tx_h_rate_ctrl()
762 .flags = ratetbl->rate[0].flags, in ieee80211_tx_h_rate_ctrl()
763 .count = ratetbl->rate[0].count in ieee80211_tx_h_rate_ctrl()
766 if (ratetbl->rate[0].idx < 0) in ieee80211_tx_h_rate_ctrl()
769 tx->rate = rate; in ieee80211_tx_h_rate_ctrl()
774 tx->rate = info->control.rates[0]; in ieee80211_tx_h_rate_ctrl()
778 txrc.reported_rate = tx->rate; in ieee80211_tx_h_rate_ctrl()
779 if (tx->sta && ieee80211_is_data(hdr->frame_control)) in ieee80211_tx_h_rate_ctrl()
780 tx->sta->tx_stats.last_rate = txrc.reported_rate; in ieee80211_tx_h_rate_ctrl()
781 } else if (tx->sta) in ieee80211_tx_h_rate_ctrl()
782 tx->sta->tx_stats.last_rate = txrc.reported_rate; in ieee80211_tx_h_rate_ctrl()
787 if (unlikely(!info->control.rates[0].count)) in ieee80211_tx_h_rate_ctrl()
788 info->control.rates[0].count = 1; in ieee80211_tx_h_rate_ctrl()
790 if (WARN_ON_ONCE((info->control.rates[0].count > 1) && in ieee80211_tx_h_rate_ctrl()
791 (info->flags & IEEE80211_TX_CTL_NO_ACK))) in ieee80211_tx_h_rate_ctrl()
792 info->control.rates[0].count = 1; in ieee80211_tx_h_rate_ctrl()
799 u16 *seq = &sta->tid_seq[tid]; in ieee80211_tx_next_seq()
811 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); in ieee80211_tx_h_sequence()
812 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; in ieee80211_tx_h_sequence()
820 if (unlikely(info->control.vif->type == NL80211_IFTYPE_MONITOR)) in ieee80211_tx_h_sequence()
823 if (unlikely(ieee80211_is_ctl(hdr->frame_control))) in ieee80211_tx_h_sequence()
826 if (ieee80211_hdrlen(hdr->frame_control) < 24) in ieee80211_tx_h_sequence()
829 if (ieee80211_is_qos_nullfunc(hdr->frame_control)) in ieee80211_tx_h_sequence()
832 if (info->control.flags & IEEE80211_TX_CTRL_NO_SEQNO) in ieee80211_tx_h_sequence()
839 * also use the global counter (802.11-2012 9.3.2.10). in ieee80211_tx_h_sequence()
841 if (!ieee80211_is_data_qos(hdr->frame_control) || in ieee80211_tx_h_sequence()
842 is_multicast_ether_addr(hdr->addr1)) { in ieee80211_tx_h_sequence()
844 info->flags |= IEEE80211_TX_CTL_ASSIGN_SEQ; in ieee80211_tx_h_sequence()
846 hdr->seq_ctrl = cpu_to_le16(tx->sdata->sequence_number); in ieee80211_tx_h_sequence()
847 tx->sdata->sequence_number += 0x10; in ieee80211_tx_h_sequence()
848 if (tx->sta) in ieee80211_tx_h_sequence()
849 tx->sta->tx_stats.msdu[IEEE80211_NUM_TIDS]++; in ieee80211_tx_h_sequence()
856 * above since they are not QoS-data frames. in ieee80211_tx_h_sequence()
858 if (!tx->sta) in ieee80211_tx_h_sequence()
861 /* include per-STA, per-TID sequence counter */ in ieee80211_tx_h_sequence()
863 tx->sta->tx_stats.msdu[tid]++; in ieee80211_tx_h_sequence()
865 hdr->seq_ctrl = ieee80211_tx_next_seq(tx->sta, tid); in ieee80211_tx_h_sequence()
874 struct ieee80211_local *local = tx->local; in ieee80211_fragment()
877 int per_fragm = frag_threshold - hdrlen - FCS_LEN; in ieee80211_fragment()
879 int rem = skb->len - hdrlen - per_fragm; in ieee80211_fragment()
882 return -EINVAL; in ieee80211_fragment()
891 rem -= fraglen; in ieee80211_fragment()
892 tmp = dev_alloc_skb(local->tx_headroom + in ieee80211_fragment()
894 tx->sdata->encrypt_headroom + in ieee80211_fragment()
897 return -ENOMEM; in ieee80211_fragment()
899 __skb_queue_tail(&tx->skbs, tmp); in ieee80211_fragment()
902 local->tx_headroom + tx->sdata->encrypt_headroom); in ieee80211_fragment()
905 memcpy(tmp->cb, skb->cb, sizeof(tmp->cb)); in ieee80211_fragment()
908 info->flags &= ~(IEEE80211_TX_CTL_CLEAR_PS_FILT | in ieee80211_fragment()
912 info->flags |= IEEE80211_TX_CTL_MORE_FRAMES; in ieee80211_fragment()
915 tmp->priority = skb->priority; in ieee80211_fragment()
916 tmp->dev = skb->dev; in ieee80211_fragment()
919 skb_put_data(tmp, skb->data, hdrlen); in ieee80211_fragment()
920 skb_put_data(tmp, skb->data + pos, fraglen); in ieee80211_fragment()
933 struct sk_buff *skb = tx->skb; in ieee80211_tx_h_fragment()
935 struct ieee80211_hdr *hdr = (void *)skb->data; in ieee80211_tx_h_fragment()
936 int frag_threshold = tx->local->hw.wiphy->frag_threshold; in ieee80211_tx_h_fragment()
940 /* no matter what happens, tx->skb moves to tx->skbs */ in ieee80211_tx_h_fragment()
941 __skb_queue_tail(&tx->skbs, skb); in ieee80211_tx_h_fragment()
942 tx->skb = NULL; in ieee80211_tx_h_fragment()
944 if (info->flags & IEEE80211_TX_CTL_DONTFRAG) in ieee80211_tx_h_fragment()
947 if (ieee80211_hw_check(&tx->local->hw, SUPPORTS_TX_FRAG)) in ieee80211_tx_h_fragment()
951 * Warn when submitting a fragmented A-MPDU frame and drop it. in ieee80211_tx_h_fragment()
955 if (WARN_ON(info->flags & IEEE80211_TX_CTL_AMPDU)) in ieee80211_tx_h_fragment()
958 hdrlen = ieee80211_hdrlen(hdr->frame_control); in ieee80211_tx_h_fragment()
961 if (WARN_ON(skb->len + FCS_LEN <= frag_threshold)) in ieee80211_tx_h_fragment()
966 * chain them (using skb as the first fragment) to skb->next. in ieee80211_tx_h_fragment()
968 * fragments from this list. When the low-level driver rejects one in ieee80211_tx_h_fragment()
969 * of the fragments then we will simply pretend to accept the skb in ieee80211_tx_h_fragment()
975 /* update duration/seq/flags of fragments */ in ieee80211_tx_h_fragment()
978 skb_queue_walk(&tx->skbs, skb) { in ieee80211_tx_h_fragment()
981 hdr = (void *)skb->data; in ieee80211_tx_h_fragment()
984 if (!skb_queue_is_last(&tx->skbs, skb)) { in ieee80211_tx_h_fragment()
985 hdr->frame_control |= morefrags; in ieee80211_tx_h_fragment()
987 * No multi-rate retries for fragmented frames, that in ieee80211_tx_h_fragment()
990 info->control.rates[1].idx = -1; in ieee80211_tx_h_fragment()
991 info->control.rates[2].idx = -1; in ieee80211_tx_h_fragment()
992 info->control.rates[3].idx = -1; in ieee80211_tx_h_fragment()
994 info->flags &= ~IEEE80211_TX_CTL_RATE_CTRL_PROBE; in ieee80211_tx_h_fragment()
996 hdr->frame_control &= ~morefrags; in ieee80211_tx_h_fragment()
998 hdr->seq_ctrl |= cpu_to_le16(fragnum & IEEE80211_SCTL_FRAG); in ieee80211_tx_h_fragment()
1009 int ac = -1; in ieee80211_tx_h_stats()
1011 if (!tx->sta) in ieee80211_tx_h_stats()
1014 skb_queue_walk(&tx->skbs, skb) { in ieee80211_tx_h_stats()
1016 tx->sta->tx_stats.bytes[ac] += skb->len; in ieee80211_tx_h_stats()
1019 tx->sta->tx_stats.packets[ac]++; in ieee80211_tx_h_stats()
1027 if (!tx->key) in ieee80211_tx_h_encrypt()
1030 switch (tx->key->conf.cipher) { in ieee80211_tx_h_encrypt()
1067 skb_queue_walk(&tx->skbs, skb) { in ieee80211_tx_h_calculate_duration()
1068 hdr = (void *) skb->data; in ieee80211_tx_h_calculate_duration()
1069 if (unlikely(ieee80211_is_pspoll(hdr->frame_control))) in ieee80211_tx_h_calculate_duration()
1071 if (!skb_queue_is_last(&tx->skbs, skb)) { in ieee80211_tx_h_calculate_duration()
1072 struct sk_buff *next = skb_queue_next(&tx->skbs, skb); in ieee80211_tx_h_calculate_duration()
1073 next_len = next->len; in ieee80211_tx_h_calculate_duration()
1076 group_addr = is_multicast_ether_addr(hdr->addr1); in ieee80211_tx_h_calculate_duration()
1078 hdr->duration_id = in ieee80211_tx_h_calculate_duration()
1097 if (test_bit(HT_AGG_STATE_OPERATIONAL, &tid_tx->state)) { in ieee80211_tx_prep_agg()
1098 info->flags |= IEEE80211_TX_CTL_AMPDU; in ieee80211_tx_prep_agg()
1100 } else if (test_bit(HT_AGG_STATE_WANT_START, &tid_tx->state)) { in ieee80211_tx_prep_agg()
1102 * nothing -- this aggregation session is being started in ieee80211_tx_prep_agg()
1105 } else if (!tx->sta->sta.txq[tid]) { in ieee80211_tx_prep_agg()
1106 spin_lock(&tx->sta->lock); in ieee80211_tx_prep_agg()
1108 * Need to re-check now, because we may get here in ieee80211_tx_prep_agg()
1113 * queue yet -- if this happened we acquire the lock in ieee80211_tx_prep_agg()
1115 * need to recheck which of these cases happened. in ieee80211_tx_prep_agg()
1120 * before it was assigned) -- in this case it may in ieee80211_tx_prep_agg()
1125 tid_tx = rcu_dereference_protected_tid_tx(tx->sta, tid); in ieee80211_tx_prep_agg()
1129 } else if (test_bit(HT_AGG_STATE_OPERATIONAL, &tid_tx->state)) { in ieee80211_tx_prep_agg()
1130 info->flags |= IEEE80211_TX_CTL_AMPDU; in ieee80211_tx_prep_agg()
1134 if (info->flags & IEEE80211_TX_CTL_NO_PS_BUFFER) { in ieee80211_tx_prep_agg()
1135 clear_sta_flag(tx->sta, WLAN_STA_SP); in ieee80211_tx_prep_agg()
1136 ps_dbg(tx->sta->sdata, in ieee80211_tx_prep_agg()
1138 tx->sta->sta.addr, tx->sta->sta.aid); in ieee80211_tx_prep_agg()
1140 info->control.vif = &tx->sdata->vif; in ieee80211_tx_prep_agg()
1141 info->control.flags |= IEEE80211_TX_INTCFL_NEED_TXPROCESSING; in ieee80211_tx_prep_agg()
1142 info->flags &= ~IEEE80211_TX_TEMPORARY_FLAGS; in ieee80211_tx_prep_agg()
1143 __skb_queue_tail(&tid_tx->pending, skb); in ieee80211_tx_prep_agg()
1144 if (skb_queue_len(&tid_tx->pending) > STA_MAX_TX_BUFFER) in ieee80211_tx_prep_agg()
1145 purge_skb = __skb_dequeue(&tid_tx->pending); in ieee80211_tx_prep_agg()
1147 spin_unlock(&tx->sta->lock); in ieee80211_tx_prep_agg()
1150 ieee80211_free_txskb(&tx->local->hw, purge_skb); in ieee80211_tx_prep_agg()
1155 tid_tx->last_tx = jiffies; in ieee80211_tx_prep_agg()
1170 struct ieee80211_local *local = sdata->local; in ieee80211_tx_prepare()
1176 tx->skb = skb; in ieee80211_tx_prepare()
1177 tx->local = local; in ieee80211_tx_prepare()
1178 tx->sdata = sdata; in ieee80211_tx_prepare()
1179 __skb_queue_head_init(&tx->skbs); in ieee80211_tx_prepare()
1186 info->control.flags &= ~IEEE80211_TX_INTCFL_NEED_TXPROCESSING; in ieee80211_tx_prepare()
1188 hdr = (struct ieee80211_hdr *) skb->data; in ieee80211_tx_prepare()
1192 tx->sta = sta; in ieee80211_tx_prepare()
1194 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) { in ieee80211_tx_prepare()
1195 tx->sta = rcu_dereference(sdata->u.vlan.sta); in ieee80211_tx_prepare()
1196 if (!tx->sta && sdata->wdev.use_4addr) in ieee80211_tx_prepare()
1198 } else if (info->flags & (IEEE80211_TX_INTFL_NL80211_FRAME_TX | in ieee80211_tx_prepare()
1200 tx->sdata->control_port_protocol == tx->skb->protocol) { in ieee80211_tx_prepare()
1201 tx->sta = sta_info_get_bss(sdata, hdr->addr1); in ieee80211_tx_prepare()
1203 if (!tx->sta && !is_multicast_ether_addr(hdr->addr1)) in ieee80211_tx_prepare()
1204 tx->sta = sta_info_get(sdata, hdr->addr1); in ieee80211_tx_prepare()
1207 if (tx->sta && ieee80211_is_data_qos(hdr->frame_control) && in ieee80211_tx_prepare()
1208 !ieee80211_is_qos_nullfunc(hdr->frame_control) && in ieee80211_tx_prepare()
1209 ieee80211_hw_check(&local->hw, AMPDU_AGGREGATION) && in ieee80211_tx_prepare()
1210 !ieee80211_hw_check(&local->hw, TX_AMPDU_SETUP_IN_HW)) { in ieee80211_tx_prepare()
1215 tid_tx = rcu_dereference(tx->sta->ampdu_mlme.tid_tx[tid]); in ieee80211_tx_prepare()
1227 if (is_multicast_ether_addr(hdr->addr1)) { in ieee80211_tx_prepare()
1228 tx->flags &= ~IEEE80211_TX_UNICAST; in ieee80211_tx_prepare()
1229 info->flags |= IEEE80211_TX_CTL_NO_ACK; in ieee80211_tx_prepare()
1231 tx->flags |= IEEE80211_TX_UNICAST; in ieee80211_tx_prepare()
1233 if (!(info->flags & IEEE80211_TX_CTL_DONTFRAG)) { in ieee80211_tx_prepare()
1234 if (!(tx->flags & IEEE80211_TX_UNICAST) || in ieee80211_tx_prepare()
1235 skb->len + FCS_LEN <= local->hw.wiphy->frag_threshold || in ieee80211_tx_prepare()
1236 info->flags & IEEE80211_TX_CTL_AMPDU) in ieee80211_tx_prepare()
1237 info->flags |= IEEE80211_TX_CTL_DONTFRAG; in ieee80211_tx_prepare()
1240 if (!tx->sta) in ieee80211_tx_prepare()
1241 info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT; in ieee80211_tx_prepare()
1242 else if (test_and_clear_sta_flag(tx->sta, WLAN_STA_CLEAR_PS_FILT)) { in ieee80211_tx_prepare()
1243 info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT; in ieee80211_tx_prepare()
1244 ieee80211_check_fast_xmit(tx->sta); in ieee80211_tx_prepare()
1247 info->flags |= IEEE80211_TX_CTL_FIRST_FRAGMENT; in ieee80211_tx_prepare()
1257 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; in ieee80211_get_txq()
1261 if ((info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM) || in ieee80211_get_txq()
1262 (info->control.flags & IEEE80211_TX_CTRL_PS_RESPONSE)) in ieee80211_get_txq()
1265 if (!(info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP) && in ieee80211_get_txq()
1266 unlikely(!ieee80211_is_data_present(hdr->frame_control))) { in ieee80211_get_txq()
1267 if ((!ieee80211_is_mgmt(hdr->frame_control) || in ieee80211_get_txq()
1268 ieee80211_is_bufferable_mmpdu(hdr->frame_control) || in ieee80211_get_txq()
1269 vif->type == NL80211_IFTYPE_STATION) && in ieee80211_get_txq()
1270 sta && sta->uploaded) { in ieee80211_get_txq()
1273 * opt-in hardware flag. in ieee80211_get_txq()
1275 txq = sta->sta.txq[IEEE80211_NUM_TIDS]; in ieee80211_get_txq()
1278 u8 tid = skb->priority & IEEE80211_QOS_CTL_TID_MASK; in ieee80211_get_txq()
1280 if (!sta->uploaded) in ieee80211_get_txq()
1283 txq = sta->sta.txq[tid]; in ieee80211_get_txq()
1285 txq = vif->txq; in ieee80211_get_txq()
1296 IEEE80211_SKB_CB(skb)->control.enqueue_time = codel_get_time(); in ieee80211_set_skb_enqueue_time()
1301 return skb->len; in codel_skb_len_func()
1308 info = (const struct ieee80211_tx_info *)skb->cb; in codel_skb_time_func()
1309 return info->control.enqueue_time; in codel_skb_time_func()
1321 local = vif_to_sdata(txqi->txq.vif)->local; in codel_dequeue_func()
1322 fq = &local->fq; in codel_dequeue_func()
1324 if (cvars == &txqi->def_cvars) in codel_dequeue_func()
1325 flow = &txqi->def_flow; in codel_dequeue_func()
1327 flow = &fq->flows[cvars - local->cvars]; in codel_dequeue_func()
1340 local = vif_to_sdata(txqi->txq.vif)->local; in codel_drop_func()
1341 hw = &local->hw; in codel_drop_func()
1358 cstats = &txqi->cstats; in fq_tin_dequeue_func()
1360 if (txqi->txq.sta) { in fq_tin_dequeue_func()
1361 struct sta_info *sta = container_of(txqi->txq.sta, in fq_tin_dequeue_func()
1363 cparams = &sta->cparams; in fq_tin_dequeue_func()
1365 cparams = &local->cparams; in fq_tin_dequeue_func()
1368 if (flow == &txqi->def_flow) in fq_tin_dequeue_func()
1369 cvars = &txqi->def_cvars; in fq_tin_dequeue_func()
1371 cvars = &local->cvars[flow - fq->flows]; in fq_tin_dequeue_func()
1374 &flow->backlog, in fq_tin_dequeue_func()
1392 ieee80211_free_txskb(&local->hw, skb); in fq_skb_free_func()
1403 return &txqi->def_flow; in fq_flow_get_default_func()
1410 struct fq *fq = &local->fq; in ieee80211_txq_enqueue()
1411 struct fq_tin *tin = &txqi->tin; in ieee80211_txq_enqueue()
1416 spin_lock_bh(&fq->lock); in ieee80211_txq_enqueue()
1420 spin_unlock_bh(&fq->lock); in ieee80211_txq_enqueue()
1429 return info->control.vif == data; in fq_vlan_filter_func()
1435 struct fq *fq = &local->fq; in ieee80211_txq_remove_vlan()
1440 if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_AP_VLAN)) in ieee80211_txq_remove_vlan()
1443 ap = container_of(sdata->bss, struct ieee80211_sub_if_data, u.ap); in ieee80211_txq_remove_vlan()
1445 if (!ap->vif.txq) in ieee80211_txq_remove_vlan()
1448 txqi = to_txq_info(ap->vif.txq); in ieee80211_txq_remove_vlan()
1449 tin = &txqi->tin; in ieee80211_txq_remove_vlan()
1451 spin_lock_bh(&fq->lock); in ieee80211_txq_remove_vlan()
1452 fq_tin_filter(fq, tin, fq_vlan_filter_func, &sdata->vif, in ieee80211_txq_remove_vlan()
1454 spin_unlock_bh(&fq->lock); in ieee80211_txq_remove_vlan()
1461 fq_tin_init(&txqi->tin); in ieee80211_txq_init()
1462 fq_flow_init(&txqi->def_flow); in ieee80211_txq_init()
1463 codel_vars_init(&txqi->def_cvars); in ieee80211_txq_init()
1464 codel_stats_init(&txqi->cstats); in ieee80211_txq_init()
1465 __skb_queue_head_init(&txqi->frags); in ieee80211_txq_init()
1466 INIT_LIST_HEAD(&txqi->schedule_order); in ieee80211_txq_init()
1468 txqi->txq.vif = &sdata->vif; in ieee80211_txq_init()
1471 sdata->vif.txq = &txqi->txq; in ieee80211_txq_init()
1472 txqi->txq.tid = 0; in ieee80211_txq_init()
1473 txqi->txq.ac = IEEE80211_AC_BE; in ieee80211_txq_init()
1479 if (sdata->vif.type == NL80211_IFTYPE_STATION) { in ieee80211_txq_init()
1481 if (!ieee80211_hw_check(&sdata->local->hw, in ieee80211_txq_init()
1484 } else if (!ieee80211_hw_check(&sdata->local->hw, in ieee80211_txq_init()
1489 txqi->txq.ac = IEEE80211_AC_VO; in ieee80211_txq_init()
1491 txqi->txq.ac = ieee80211_ac_from_tid(tid); in ieee80211_txq_init()
1494 txqi->txq.sta = &sta->sta; in ieee80211_txq_init()
1495 txqi->txq.tid = tid; in ieee80211_txq_init()
1496 sta->sta.txq[tid] = &txqi->txq; in ieee80211_txq_init()
1502 struct fq *fq = &local->fq; in ieee80211_txq_purge()
1503 struct fq_tin *tin = &txqi->tin; in ieee80211_txq_purge()
1505 spin_lock_bh(&fq->lock); in ieee80211_txq_purge()
1507 ieee80211_purge_tx_queue(&local->hw, &txqi->frags); in ieee80211_txq_purge()
1508 spin_unlock_bh(&fq->lock); in ieee80211_txq_purge()
1510 spin_lock_bh(&local->active_txq_lock[txqi->txq.ac]); in ieee80211_txq_purge()
1511 list_del_init(&txqi->schedule_order); in ieee80211_txq_purge()
1512 spin_unlock_bh(&local->active_txq_lock[txqi->txq.ac]); in ieee80211_txq_purge()
1517 if (local->hw.wiphy->txq_limit) in ieee80211_txq_set_params()
1518 local->fq.limit = local->hw.wiphy->txq_limit; in ieee80211_txq_set_params()
1520 local->hw.wiphy->txq_limit = local->fq.limit; in ieee80211_txq_set_params()
1522 if (local->hw.wiphy->txq_memory_limit) in ieee80211_txq_set_params()
1523 local->fq.memory_limit = local->hw.wiphy->txq_memory_limit; in ieee80211_txq_set_params()
1525 local->hw.wiphy->txq_memory_limit = local->fq.memory_limit; in ieee80211_txq_set_params()
1527 if (local->hw.wiphy->txq_quantum) in ieee80211_txq_set_params()
1528 local->fq.quantum = local->hw.wiphy->txq_quantum; in ieee80211_txq_set_params()
1530 local->hw.wiphy->txq_quantum = local->fq.quantum; in ieee80211_txq_set_params()
1535 struct fq *fq = &local->fq; in ieee80211_txq_setup_flows()
1539 enum nl80211_band band; in ieee80211_txq_setup_flows() local
1541 if (!local->ops->wake_tx_queue) in ieee80211_txq_setup_flows()
1550 * queue size. 4 Mbytes is 64 max-size aggregates in 802.11n. in ieee80211_txq_setup_flows()
1552 for (band = 0; band < NUM_NL80211_BANDS; band++) { in ieee80211_txq_setup_flows()
1555 sband = local->hw.wiphy->bands[band]; in ieee80211_txq_setup_flows()
1559 supp_vht = supp_vht || sband->vht_cap.vht_supported; in ieee80211_txq_setup_flows()
1563 fq->memory_limit = 4 << 20; /* 4 Mbytes */ in ieee80211_txq_setup_flows()
1565 codel_params_init(&local->cparams); in ieee80211_txq_setup_flows()
1566 local->cparams.interval = MS2TIME(100); in ieee80211_txq_setup_flows()
1567 local->cparams.target = MS2TIME(20); in ieee80211_txq_setup_flows()
1568 local->cparams.ecn = true; in ieee80211_txq_setup_flows()
1570 local->cvars = kcalloc(fq->flows_cnt, sizeof(local->cvars[0]), in ieee80211_txq_setup_flows()
1572 if (!local->cvars) { in ieee80211_txq_setup_flows()
1573 spin_lock_bh(&fq->lock); in ieee80211_txq_setup_flows()
1575 spin_unlock_bh(&fq->lock); in ieee80211_txq_setup_flows()
1576 return -ENOMEM; in ieee80211_txq_setup_flows()
1579 for (i = 0; i < fq->flows_cnt; i++) in ieee80211_txq_setup_flows()
1580 codel_vars_init(&local->cvars[i]); in ieee80211_txq_setup_flows()
1589 struct fq *fq = &local->fq; in ieee80211_txq_teardown_flows()
1591 if (!local->ops->wake_tx_queue) in ieee80211_txq_teardown_flows()
1594 kfree(local->cvars); in ieee80211_txq_teardown_flows()
1595 local->cvars = NULL; in ieee80211_txq_teardown_flows()
1597 spin_lock_bh(&fq->lock); in ieee80211_txq_teardown_flows()
1599 spin_unlock_bh(&fq->lock); in ieee80211_txq_teardown_flows()
1610 if (!local->ops->wake_tx_queue || in ieee80211_queue_skb()
1611 sdata->vif.type == NL80211_IFTYPE_MONITOR) in ieee80211_queue_skb()
1614 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) in ieee80211_queue_skb()
1615 sdata = container_of(sdata->bss, in ieee80211_queue_skb()
1618 vif = &sdata->vif; in ieee80211_queue_skb()
1643 int q = info->hw_queue; in ieee80211_tx_frags()
1646 if (WARN_ON_ONCE(q >= local->hw.queues)) { in ieee80211_tx_frags()
1648 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_frags()
1653 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in ieee80211_tx_frags()
1654 if (local->queue_stop_reasons[q] || in ieee80211_tx_frags()
1655 (!txpending && !skb_queue_empty(&local->pending[q]))) { in ieee80211_tx_frags()
1656 if (unlikely(info->flags & in ieee80211_tx_frags()
1658 if (local->queue_stop_reasons[q] & in ieee80211_tx_frags()
1661 * Drop off-channel frames if queues in ieee80211_tx_frags()
1663 * than off-channel operation. Never in ieee80211_tx_frags()
1667 &local->queue_stop_reason_lock, in ieee80211_tx_frags()
1669 ieee80211_purge_tx_queue(&local->hw, in ieee80211_tx_frags()
1677 * later transmission from the tx-pending in ieee80211_tx_frags()
1682 &local->pending[q]); in ieee80211_tx_frags()
1685 &local->pending[q]); in ieee80211_tx_frags()
1687 spin_unlock_irqrestore(&local->queue_stop_reason_lock, in ieee80211_tx_frags()
1692 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_tx_frags()
1694 info->control.vif = vif; in ieee80211_tx_frags()
1695 control.sta = sta ? &sta->sta : NULL; in ieee80211_tx_frags()
1722 fc = ((struct ieee80211_hdr *)skb->data)->frame_control; in __ieee80211_tx()
1724 sdata = vif_to_sdata(info->control.vif); in __ieee80211_tx()
1725 if (sta && !sta->uploaded) in __ieee80211_tx()
1728 switch (sdata->vif.type) { in __ieee80211_tx()
1730 if (sdata->u.mntr.flags & MONITOR_FLAG_ACTIVE) { in __ieee80211_tx()
1731 vif = &sdata->vif; in __ieee80211_tx()
1734 sdata = rcu_dereference(local->monitor_sdata); in __ieee80211_tx()
1736 vif = &sdata->vif; in __ieee80211_tx()
1737 info->hw_queue = in __ieee80211_tx()
1738 vif->hw_queue[skb_get_queue_mapping(skb)]; in __ieee80211_tx()
1739 } else if (ieee80211_hw_check(&local->hw, QUEUE_CONTROL)) { in __ieee80211_tx()
1740 ieee80211_purge_tx_queue(&local->hw, skbs); in __ieee80211_tx()
1746 sdata = container_of(sdata->bss, in __ieee80211_tx()
1750 vif = &sdata->vif; in __ieee80211_tx()
1764 * Invoke TX handlers, return 0 on success and non-zero if the
1787 if (!ieee80211_hw_check(&tx->local->hw, HAS_RATE_CONTROL)) in invoke_tx_handlers_early()
1792 I802_DEBUG_INC(tx->local->tx_handlers_drop); in invoke_tx_handlers_early()
1793 if (tx->skb) in invoke_tx_handlers_early()
1794 ieee80211_free_txskb(&tx->local->hw, tx->skb); in invoke_tx_handlers_early()
1796 ieee80211_purge_tx_queue(&tx->local->hw, &tx->skbs); in invoke_tx_handlers_early()
1797 return -1; in invoke_tx_handlers_early()
1799 I802_DEBUG_INC(tx->local->tx_handlers_queued); in invoke_tx_handlers_early()
1800 return -1; in invoke_tx_handlers_early()
1812 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); in invoke_tx_handlers_late()
1815 if (unlikely(info->flags & IEEE80211_TX_INTFL_RETRANSMISSION)) { in invoke_tx_handlers_late()
1816 __skb_queue_tail(&tx->skbs, tx->skb); in invoke_tx_handlers_late()
1817 tx->skb = NULL; in invoke_tx_handlers_late()
1824 /* handlers after fragment must be aware of tx info fragmentation! */ in invoke_tx_handlers_late()
1827 if (!ieee80211_hw_check(&tx->local->hw, HAS_RATE_CONTROL)) in invoke_tx_handlers_late()
1833 I802_DEBUG_INC(tx->local->tx_handlers_drop); in invoke_tx_handlers_late()
1834 if (tx->skb) in invoke_tx_handlers_late()
1835 ieee80211_free_txskb(&tx->local->hw, tx->skb); in invoke_tx_handlers_late()
1837 ieee80211_purge_tx_queue(&tx->local->hw, &tx->skbs); in invoke_tx_handlers_late()
1838 return -1; in invoke_tx_handlers_late()
1840 I802_DEBUG_INC(tx->local->tx_handlers_queued); in invoke_tx_handlers_late()
1841 return -1; in invoke_tx_handlers_late()
1858 int band, struct ieee80211_sta **sta) in ieee80211_tx_prepare_skb() argument
1868 info->band = band; in ieee80211_tx_prepare_skb()
1869 info->control.vif = vif; in ieee80211_tx_prepare_skb()
1870 info->hw_queue = vif->hw_queue[skb_get_queue_mapping(skb)]; in ieee80211_tx_prepare_skb()
1877 *sta = &tx.sta->sta; in ieee80211_tx_prepare_skb()
1901 struct ieee80211_local *local = sdata->local; in ieee80211_tx()
1908 if (unlikely(skb->len < 10)) { in ieee80211_tx()
1914 led_len = skb->len; in ieee80211_tx()
1918 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx()
1925 if (!(info->flags & IEEE80211_TX_CTL_TX_OFFCHAN) || in ieee80211_tx()
1926 !ieee80211_hw_check(&local->hw, QUEUE_CONTROL)) in ieee80211_tx()
1927 info->hw_queue = in ieee80211_tx()
1928 sdata->vif.hw_queue[skb_get_queue_mapping(skb)]; in ieee80211_tx()
1956 struct ieee80211_local *local = sdata->local; in ieee80211_skb_resize()
1962 sdata->crypto_tx_tailroom_needed_cnt); in ieee80211_skb_resize()
1966 tail_need -= skb_tailroom(skb); in ieee80211_skb_resize()
1971 (!ieee80211_hw_check(&local->hw, SUPPORTS_CLONED_SKBS) || in ieee80211_skb_resize()
1973 I802_DEBUG_INC(local->tx_expand_skb_head_cloned); in ieee80211_skb_resize()
1975 I802_DEBUG_INC(local->tx_expand_skb_head); in ieee80211_skb_resize()
1980 wiphy_debug(local->hw.wiphy, in ieee80211_skb_resize()
1982 return -ENOMEM; in ieee80211_skb_resize()
1991 struct ieee80211_local *local = sdata->local; in ieee80211_xmit()
1993 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; in ieee80211_xmit()
1997 if (info->flags & IEEE80211_TX_INTFL_DONT_ENCRYPT) in ieee80211_xmit()
1999 else if (ieee80211_is_mgmt(hdr->frame_control)) in ieee80211_xmit()
2004 headroom = local->tx_headroom; in ieee80211_xmit()
2006 headroom += sdata->encrypt_headroom; in ieee80211_xmit()
2007 headroom -= skb_headroom(skb); in ieee80211_xmit()
2011 ieee80211_free_txskb(&local->hw, skb); in ieee80211_xmit()
2016 hdr = (struct ieee80211_hdr *) skb->data; in ieee80211_xmit()
2017 info->control.vif = &sdata->vif; in ieee80211_xmit()
2019 if (ieee80211_vif_is_mesh(&sdata->vif)) { in ieee80211_xmit()
2020 if (ieee80211_is_data(hdr->frame_control) && in ieee80211_xmit()
2021 is_unicast_ether_addr(hdr->addr1)) { in ieee80211_xmit()
2036 (struct ieee80211_radiotap_header *)skb->data; in ieee80211_validate_radiotap_len()
2039 if (unlikely(skb->len < sizeof(struct ieee80211_radiotap_header))) in ieee80211_validate_radiotap_len()
2043 if (unlikely(rthdr->it_version)) in ieee80211_validate_radiotap_len()
2047 if (unlikely(skb->len < ieee80211_get_radiotap_len(skb->data))) in ieee80211_validate_radiotap_len()
2056 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); in ieee80211_parse_tx_radiotap()
2059 (struct ieee80211_radiotap_header *) skb->data; in ieee80211_parse_tx_radiotap()
2061 int ret = ieee80211_radiotap_iterator_init(&iterator, rthdr, skb->len, in ieee80211_parse_tx_radiotap()
2076 info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT | in ieee80211_parse_tx_radiotap()
2081 * (ieee80211_radiotap_iterator_next returns -ENOENT when no more in ieee80211_parse_tx_radiotap()
2082 * entries present, or -EINVAL on error) in ieee80211_parse_tx_radiotap()
2103 * handed has the 32-bit FCS CRC at the end... in ieee80211_parse_tx_radiotap()
2108 if (skb->len < (iterator._max_length + FCS_LEN)) in ieee80211_parse_tx_radiotap()
2111 skb_trim(skb, skb->len - FCS_LEN); in ieee80211_parse_tx_radiotap()
2114 info->flags &= ~IEEE80211_TX_INTFL_DONT_ENCRYPT; in ieee80211_parse_tx_radiotap()
2116 info->flags &= ~IEEE80211_TX_CTL_DONTFRAG; in ieee80211_parse_tx_radiotap()
2122 info->flags |= IEEE80211_TX_CTL_NO_ACK; in ieee80211_parse_tx_radiotap()
2124 info->control.flags |= IEEE80211_TX_CTRL_NO_SEQNO; in ieee80211_parse_tx_radiotap()
2189 * Documentation/networking/mac80211-injection.rst in ieee80211_parse_tx_radiotap()
2198 if (ret != -ENOENT) /* ie, if we didn't simply run out of fields */ in ieee80211_parse_tx_radiotap()
2203 local->hw.wiphy->bands[info->band]; in ieee80211_parse_tx_radiotap()
2205 info->control.flags |= IEEE80211_TX_CTRL_RATE_INJECT; in ieee80211_parse_tx_radiotap()
2208 info->control.rates[i].idx = -1; in ieee80211_parse_tx_radiotap()
2209 info->control.rates[i].flags = 0; in ieee80211_parse_tx_radiotap()
2210 info->control.rates[i].count = 0; in ieee80211_parse_tx_radiotap()
2214 info->control.rates[0].idx = rate; in ieee80211_parse_tx_radiotap()
2216 ieee80211_rate_set_vht(info->control.rates, vht_mcs, in ieee80211_parse_tx_radiotap()
2219 for (i = 0; i < sband->n_bitrates; i++) { in ieee80211_parse_tx_radiotap()
2220 if (rate * 5 != sband->bitrates[i].bitrate) in ieee80211_parse_tx_radiotap()
2223 info->control.rates[0].idx = i; in ieee80211_parse_tx_radiotap()
2228 if (info->control.rates[0].idx < 0) in ieee80211_parse_tx_radiotap()
2229 info->control.flags &= ~IEEE80211_TX_CTRL_RATE_INJECT; in ieee80211_parse_tx_radiotap()
2231 info->control.rates[0].flags = rate_flags; in ieee80211_parse_tx_radiotap()
2232 info->control.rates[0].count = min_t(u8, rate_retries + 1, in ieee80211_parse_tx_radiotap()
2233 local->hw.max_rate_tries); in ieee80211_parse_tx_radiotap()
2242 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); in ieee80211_monitor_start_xmit()
2252 info->flags = IEEE80211_TX_CTL_REQ_TX_STATUS | in ieee80211_monitor_start_xmit()
2255 /* Sanity-check the length of the radiotap header */ in ieee80211_monitor_start_xmit()
2260 len_rthdr = ieee80211_get_radiotap_len(skb->data); in ieee80211_monitor_start_xmit()
2270 * these are just fixed to the end of the rt area since we in ieee80211_monitor_start_xmit()
2276 if (skb->len < len_rthdr + 2) in ieee80211_monitor_start_xmit()
2279 hdr = (struct ieee80211_hdr *)(skb->data + len_rthdr); in ieee80211_monitor_start_xmit()
2280 hdrlen = ieee80211_hdrlen(hdr->frame_control); in ieee80211_monitor_start_xmit()
2282 if (skb->len < len_rthdr + hdrlen) in ieee80211_monitor_start_xmit()
2286 * Initialize skb->protocol if the injected frame is a data frame in ieee80211_monitor_start_xmit()
2289 if (ieee80211_is_data(hdr->frame_control) && in ieee80211_monitor_start_xmit()
2290 skb->len >= len_rthdr + hdrlen + sizeof(rfc1042_header) + 2) { in ieee80211_monitor_start_xmit()
2294 skb->protocol = cpu_to_be16((payload[6] << 8) | in ieee80211_monitor_start_xmit()
2299 * Initialize skb->priority for QoS frames. This is put in the TID field in ieee80211_monitor_start_xmit()
2300 * of the frame before passing it to the driver. in ieee80211_monitor_start_xmit()
2302 if (ieee80211_is_data_qos(hdr->frame_control)) { in ieee80211_monitor_start_xmit()
2304 skb->priority = *p & IEEE80211_QOS_CTL_TAG1D_MASK; in ieee80211_monitor_start_xmit()
2311 * we handle as though they are non-injected frames. in ieee80211_monitor_start_xmit()
2318 * don't use nl80211-based management TX/RX. in ieee80211_monitor_start_xmit()
2322 list_for_each_entry_rcu(tmp_sdata, &local->interfaces, list) { in ieee80211_monitor_start_xmit()
2325 if (tmp_sdata->vif.type == NL80211_IFTYPE_MONITOR || in ieee80211_monitor_start_xmit()
2326 tmp_sdata->vif.type == NL80211_IFTYPE_AP_VLAN || in ieee80211_monitor_start_xmit()
2327 tmp_sdata->vif.type == NL80211_IFTYPE_WDS) in ieee80211_monitor_start_xmit()
2329 if (ether_addr_equal(tmp_sdata->vif.addr, hdr->addr2)) { in ieee80211_monitor_start_xmit()
2335 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); in ieee80211_monitor_start_xmit()
2337 tmp_sdata = rcu_dereference(local->monitor_sdata); in ieee80211_monitor_start_xmit()
2340 rcu_dereference(tmp_sdata->vif.chanctx_conf); in ieee80211_monitor_start_xmit()
2344 chandef = &chanctx_conf->def; in ieee80211_monitor_start_xmit()
2345 else if (!local->use_chanctx) in ieee80211_monitor_start_xmit()
2346 chandef = &local->_oper_chandef; in ieee80211_monitor_start_xmit()
2366 if (!cfg80211_reg_can_beacon(local->hw.wiphy, chandef, in ieee80211_monitor_start_xmit()
2367 sdata->vif.type)) in ieee80211_monitor_start_xmit()
2370 info->band = chandef->chan->band; in ieee80211_monitor_start_xmit()
2397 u16 ethertype = (skb->data[12] << 8) | skb->data[13]; in ieee80211_is_tdls_setup()
2400 skb->len > 14 && in ieee80211_is_tdls_setup()
2401 skb->data[14] == WLAN_TDLS_SNAP_RFTYPE; in ieee80211_is_tdls_setup()
2410 switch (sdata->vif.type) { in ieee80211_lookup_ra_sta()
2412 sta = rcu_dereference(sdata->u.vlan.sta); in ieee80211_lookup_ra_sta()
2416 } else if (sdata->wdev.use_4addr) { in ieee80211_lookup_ra_sta()
2417 return -ENOLINK; in ieee80211_lookup_ra_sta()
2423 if (is_multicast_ether_addr(skb->data)) { in ieee80211_lookup_ra_sta()
2424 *sta_out = ERR_PTR(-ENOENT); in ieee80211_lookup_ra_sta()
2427 sta = sta_info_get_bss(sdata, skb->data); in ieee80211_lookup_ra_sta()
2430 sta = sta_info_get(sdata, sdata->u.wds.remote_addr); in ieee80211_lookup_ra_sta()
2439 if (sdata->wdev.wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS) { in ieee80211_lookup_ra_sta()
2440 sta = sta_info_get(sdata, skb->data); in ieee80211_lookup_ra_sta()
2449 * TDLS link during setup - throw out frames to in ieee80211_lookup_ra_sta()
2450 * peer. Allow TDLS-setup frames to unauthorized in ieee80211_lookup_ra_sta()
2451 * peers for the special case of a link teardown in ieee80211_lookup_ra_sta()
2456 return -EINVAL; in ieee80211_lookup_ra_sta()
2461 sta = sta_info_get(sdata, sdata->u.mgd.bssid); in ieee80211_lookup_ra_sta()
2463 return -ENOLINK; in ieee80211_lookup_ra_sta()
2466 return -EINVAL; in ieee80211_lookup_ra_sta()
2469 *sta_out = sta ?: ERR_PTR(-ENOENT); in ieee80211_lookup_ra_sta()
2481 if (skb->sk) in ieee80211_store_ack_skb()
2490 spin_lock_irqsave(&local->ack_status_lock, flags); in ieee80211_store_ack_skb()
2491 id = idr_alloc(&local->ack_status_frames, ack_skb, in ieee80211_store_ack_skb()
2493 spin_unlock_irqrestore(&local->ack_status_lock, flags); in ieee80211_store_ack_skb()
2500 IEEE80211_SKB_CB(ack_skb)->ack.cookie = *cookie; in ieee80211_store_ack_skb()
2511 * ieee80211_build_hdr - build 802.11 header in the given frame
2523 * Note that this function also takes care of the TX status request and
2524 * potential unsharing of the SKB - this needs to be interleaved with the
2527 * The function requires the read-side RCU lock held
2536 struct ieee80211_local *local = sdata->local; in ieee80211_build_hdr()
2552 enum nl80211_band band; in ieee80211_build_hdr() local
2559 if (local->force_tx_status) in ieee80211_build_hdr()
2565 ethertype = (skb->data[12] << 8) | skb->data[13]; in ieee80211_build_hdr()
2568 switch (sdata->vif.type) { in ieee80211_build_hdr()
2570 if (sdata->wdev.use_4addr) { in ieee80211_build_hdr()
2573 memcpy(hdr.addr1, sta->sta.addr, ETH_ALEN); in ieee80211_build_hdr()
2574 memcpy(hdr.addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_build_hdr()
2575 memcpy(hdr.addr3, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2576 memcpy(hdr.addr4, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2579 wme_sta = sta->sta.wme; in ieee80211_build_hdr()
2581 ap_sdata = container_of(sdata->bss, struct ieee80211_sub_if_data, in ieee80211_build_hdr()
2583 chanctx_conf = rcu_dereference(ap_sdata->vif.chanctx_conf); in ieee80211_build_hdr()
2585 ret = -ENOTCONN; in ieee80211_build_hdr()
2588 band = chanctx_conf->def.chan->band; in ieee80211_build_hdr()
2589 if (sdata->wdev.use_4addr) in ieee80211_build_hdr()
2593 if (sdata->vif.type == NL80211_IFTYPE_AP) in ieee80211_build_hdr()
2594 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); in ieee80211_build_hdr()
2596 ret = -ENOTCONN; in ieee80211_build_hdr()
2601 memcpy(hdr.addr1, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2602 memcpy(hdr.addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_build_hdr()
2603 memcpy(hdr.addr3, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2605 band = chanctx_conf->def.chan->band; in ieee80211_build_hdr()
2610 memcpy(hdr.addr1, sdata->u.wds.remote_addr, ETH_ALEN); in ieee80211_build_hdr()
2611 memcpy(hdr.addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_build_hdr()
2612 memcpy(hdr.addr3, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2613 memcpy(hdr.addr4, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2619 band = local->hw.conf.chandef.chan->band; in ieee80211_build_hdr()
2623 if (!is_multicast_ether_addr(skb->data)) { in ieee80211_build_hdr()
2627 mpath = mesh_path_lookup(sdata, skb->data); in ieee80211_build_hdr()
2630 next_hop = rcu_dereference(mpath->next_hop); in ieee80211_build_hdr()
2632 !(mpath->flags & (MESH_PATH_ACTIVE | in ieee80211_build_hdr()
2638 mppath = mpp_path_lookup(sdata, skb->data); in ieee80211_build_hdr()
2640 mppath->exp_time = jiffies; in ieee80211_build_hdr()
2644 mesh_path_del(sdata, mpath->dst); in ieee80211_build_hdr()
2653 if (ether_addr_equal(sdata->vif.addr, skb->data + ETH_ALEN) && in ieee80211_build_hdr()
2654 !(mppath && !ether_addr_equal(mppath->mpp, skb->data))) { in ieee80211_build_hdr()
2656 skb->data, skb->data + ETH_ALEN); in ieee80211_build_hdr()
2660 /* DS -> MBSS (802.11-2012 13.11.3.3). in ieee80211_build_hdr()
2666 const u8 *mesh_da = skb->data; in ieee80211_build_hdr()
2669 mesh_da = mppath->mpp; in ieee80211_build_hdr()
2671 mesh_da = mpath->dst; in ieee80211_build_hdr()
2674 mesh_da, sdata->vif.addr); in ieee80211_build_hdr()
2679 skb->data + ETH_ALEN, NULL); in ieee80211_build_hdr()
2683 sdata, &mesh_hdr, skb->data, in ieee80211_build_hdr()
2684 skb->data + ETH_ALEN); in ieee80211_build_hdr()
2687 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); in ieee80211_build_hdr()
2689 ret = -ENOTCONN; in ieee80211_build_hdr()
2692 band = chanctx_conf->def.chan->band; in ieee80211_build_hdr()
2699 memcpy(hdr.addr1, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2708 memcpy(hdr.addr1, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2709 memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2710 memcpy(hdr.addr3, sdata->u.mgd.bssid, ETH_ALEN); in ieee80211_build_hdr()
2712 } else if (sdata->u.mgd.use_4addr && in ieee80211_build_hdr()
2713 cpu_to_be16(ethertype) != sdata->control_port_protocol) { in ieee80211_build_hdr()
2717 memcpy(hdr.addr1, sdata->u.mgd.bssid, ETH_ALEN); in ieee80211_build_hdr()
2718 memcpy(hdr.addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_build_hdr()
2719 memcpy(hdr.addr3, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2720 memcpy(hdr.addr4, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2725 memcpy(hdr.addr1, sdata->u.mgd.bssid, ETH_ALEN); in ieee80211_build_hdr()
2726 memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2727 memcpy(hdr.addr3, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2730 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); in ieee80211_build_hdr()
2732 ret = -ENOTCONN; in ieee80211_build_hdr()
2735 band = chanctx_conf->def.chan->band; in ieee80211_build_hdr()
2739 memcpy(hdr.addr1, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2740 memcpy(hdr.addr2, skb->data + ETH_ALEN, 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()
2754 memcpy(hdr.addr3, sdata->u.ibss.bssid, 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()
2764 ret = -EINVAL; in ieee80211_build_hdr()
2773 wme_sta = sta->sta.wme; in ieee80211_build_hdr()
2774 } else if (ieee80211_vif_is_mesh(&sdata->vif)) { in ieee80211_build_hdr()
2775 /* For mesh, the use of the QoS header is mandatory */ in ieee80211_build_hdr()
2789 if (unlikely(!ieee80211_vif_is_mesh(&sdata->vif) && in ieee80211_build_hdr()
2790 (sdata->vif.type != NL80211_IFTYPE_OCB) && in ieee80211_build_hdr()
2792 (cpu_to_be16(ethertype) != sdata->control_port_protocol || in ieee80211_build_hdr()
2793 !ether_addr_equal(sdata->vif.addr, skb->data + ETH_ALEN)))) { in ieee80211_build_hdr()
2796 sdata->name, hdr.addr1); in ieee80211_build_hdr()
2799 I802_DEBUG_INC(local->tx_handlers_drop_unauth_port); in ieee80211_build_hdr()
2801 ret = -EPERM; in ieee80211_build_hdr()
2805 if (unlikely(!multicast && ((skb->sk && in ieee80211_build_hdr()
2806 skb_shinfo(skb)->tx_flags & SKBTX_WIFI_STATUS) || in ieee80211_build_hdr()
2817 /* can't happen -- skb is a clone if info_id != 0 */ in ieee80211_build_hdr()
2824 ret = -ENOMEM; in ieee80211_build_hdr()
2837 skip_header_bytes -= 2; in ieee80211_build_hdr()
2841 skip_header_bytes -= 2; in ieee80211_build_hdr()
2848 head_need = hdrlen + encaps_len + meshhdrlen - skb_headroom(skb); in ieee80211_build_hdr()
2851 * So we need to modify the skb header and hence need a copy of in ieee80211_build_hdr()
2863 head_need += sdata->encrypt_headroom; in ieee80211_build_hdr()
2864 head_need += local->tx_headroom; in ieee80211_build_hdr()
2867 ieee80211_free_txskb(&local->hw, skb); in ieee80211_build_hdr()
2869 return ERR_PTR(-ENOMEM); in ieee80211_build_hdr()
2885 memcpy(skb_push(skb, hdrlen - 2), &hdr, hdrlen - 2); in ieee80211_build_hdr()
2899 info->flags = info_flags; in ieee80211_build_hdr()
2900 info->ack_frame_id = info_id; in ieee80211_build_hdr()
2901 info->band = band; in ieee80211_build_hdr()
2902 info->control.flags = ctrl_flags; in ieee80211_build_hdr()
2911 * fast-xmit overview
2913 * The core idea of this fast-xmit is to remove per-packet checks by checking
2914 * them out of band. ieee80211_check_fast_xmit() implements the out-of-band
2915 * checks that are needed to get the sta->fast_tx pointer assigned, after which
2920 * Once assigned, the fast_tx data structure also caches the per-packet 802.11
2923 * The most difficult part of this is that when any of these assumptions
2926 * since the per-packet code no longer checks the conditions. This is reflected
2927 * by the calls to these functions throughout the rest of the code, and must be
2928 * maintained if any of the TX path checks change.
2934 struct ieee80211_local *local = sta->local; in ieee80211_check_fast_xmit()
2935 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_check_fast_xmit()
2940 if (!ieee80211_hw_check(&local->hw, SUPPORT_FAST_XMIT)) in ieee80211_check_fast_xmit()
2946 * Without it, the invocation of this function right after the key in ieee80211_check_fast_xmit()
2951 * key and the fast-tx assignment are done atomically, so the CPU that in ieee80211_check_fast_xmit()
2955 spin_lock_bh(&sta->lock); in ieee80211_check_fast_xmit()
2956 if (ieee80211_hw_check(&local->hw, SUPPORTS_PS) && in ieee80211_check_fast_xmit()
2957 !ieee80211_hw_check(&local->hw, SUPPORTS_DYNAMIC_PS) && in ieee80211_check_fast_xmit()
2958 sdata->vif.type == NL80211_IFTYPE_STATION) in ieee80211_check_fast_xmit()
2959 goto out; in ieee80211_check_fast_xmit()
2962 goto out; in ieee80211_check_fast_xmit()
2968 goto out; in ieee80211_check_fast_xmit()
2970 if (sdata->noack_map) in ieee80211_check_fast_xmit()
2971 goto out; in ieee80211_check_fast_xmit()
2973 /* fast-xmit doesn't handle fragmentation at all */ in ieee80211_check_fast_xmit()
2974 if (local->hw.wiphy->frag_threshold != (u32)-1 && in ieee80211_check_fast_xmit()
2975 !ieee80211_hw_check(&local->hw, SUPPORTS_TX_FRAG)) in ieee80211_check_fast_xmit()
2976 goto out; in ieee80211_check_fast_xmit()
2979 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); in ieee80211_check_fast_xmit()
2982 goto out; in ieee80211_check_fast_xmit()
2984 build.band = chanctx_conf->def.chan->band; in ieee80211_check_fast_xmit()
2989 switch (sdata->vif.type) { in ieee80211_check_fast_xmit()
2994 memcpy(hdr->addr3, sdata->u.ibss.bssid, ETH_ALEN); in ieee80211_check_fast_xmit()
3002 memcpy(hdr->addr3, sdata->u.mgd.bssid, ETH_ALEN); in ieee80211_check_fast_xmit()
3007 if (sdata->u.mgd.use_4addr) { in ieee80211_check_fast_xmit()
3008 /* non-regular ethertype cannot use the fastpath */ in ieee80211_check_fast_xmit()
3012 memcpy(hdr->addr1, sdata->u.mgd.bssid, ETH_ALEN); in ieee80211_check_fast_xmit()
3013 memcpy(hdr->addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_check_fast_xmit()
3021 memcpy(hdr->addr1, sdata->u.mgd.bssid, ETH_ALEN); in ieee80211_check_fast_xmit()
3027 if (sdata->wdev.use_4addr) { in ieee80211_check_fast_xmit()
3031 memcpy(hdr->addr1, sta->sta.addr, ETH_ALEN); in ieee80211_check_fast_xmit()
3032 memcpy(hdr->addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_check_fast_xmit()
3043 memcpy(hdr->addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_check_fast_xmit()
3048 /* not handled on fast-xmit */ in ieee80211_check_fast_xmit()
3049 goto out; in ieee80211_check_fast_xmit()
3052 if (sta->sta.wme) { in ieee80211_check_fast_xmit()
3062 build.key = rcu_access_pointer(sta->ptk[sta->ptk_idx]); in ieee80211_check_fast_xmit()
3064 build.key = rcu_access_pointer(sdata->default_unicast_key); in ieee80211_check_fast_xmit()
3068 gen_iv = build.key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV; in ieee80211_check_fast_xmit()
3069 iv_spc = build.key->conf.flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE; in ieee80211_check_fast_xmit()
3070 mmic = build.key->conf.flags & in ieee80211_check_fast_xmit()
3075 if (!(build.key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) in ieee80211_check_fast_xmit()
3076 goto out; in ieee80211_check_fast_xmit()
3079 if (build.key->flags & KEY_FLAG_TAINTED) in ieee80211_check_fast_xmit()
3080 goto out; in ieee80211_check_fast_xmit()
3082 switch (build.key->conf.cipher) { in ieee80211_check_fast_xmit()
3098 /* cannot handle MMIC or IV generation in xmit-fast */ in ieee80211_check_fast_xmit()
3100 goto out; in ieee80211_check_fast_xmit()
3106 /* cannot handle IV generation in fast-xmit */ in ieee80211_check_fast_xmit()
3108 goto out; in ieee80211_check_fast_xmit()
3118 build.key->conf.cipher); in ieee80211_check_fast_xmit()
3119 goto out; in ieee80211_check_fast_xmit()
3123 goto out; in ieee80211_check_fast_xmit()
3124 /* pure hardware keys are OK, of course */ in ieee80211_check_fast_xmit()
3125 if (!(build.key->flags & KEY_FLAG_CIPHER_SCHEME)) in ieee80211_check_fast_xmit()
3129 build.key->conf.iv_len > IEEE80211_FAST_XMIT_MAX_IV) in ieee80211_check_fast_xmit()
3130 goto out; in ieee80211_check_fast_xmit()
3132 build.hdr_len += build.key->conf.iv_len; in ieee80211_check_fast_xmit()
3138 hdr->frame_control = fc; in ieee80211_check_fast_xmit()
3147 goto out; in ieee80211_check_fast_xmit()
3149 out: in ieee80211_check_fast_xmit()
3151 old = rcu_dereference_protected(sta->fast_tx, in ieee80211_check_fast_xmit()
3152 lockdep_is_held(&sta->lock)); in ieee80211_check_fast_xmit()
3153 rcu_assign_pointer(sta->fast_tx, fast_tx); in ieee80211_check_fast_xmit()
3156 spin_unlock_bh(&sta->lock); in ieee80211_check_fast_xmit()
3164 list_for_each_entry_rcu(sta, &local->sta_list, list) in ieee80211_check_fast_xmit_all()
3171 struct ieee80211_local *local = sdata->local; in ieee80211_check_fast_xmit_iface()
3176 list_for_each_entry_rcu(sta, &local->sta_list, list) { in ieee80211_check_fast_xmit_iface()
3177 if (sdata != sta->sdata && in ieee80211_check_fast_xmit_iface()
3178 (!sta->sdata->bss || sta->sdata->bss != sdata->bss)) in ieee80211_check_fast_xmit_iface()
3190 spin_lock_bh(&sta->lock); in ieee80211_clear_fast_xmit()
3191 fast_tx = rcu_dereference_protected(sta->fast_tx, in ieee80211_clear_fast_xmit()
3192 lockdep_is_held(&sta->lock)); in ieee80211_clear_fast_xmit()
3193 RCU_INIT_POINTER(sta->fast_tx, NULL); in ieee80211_clear_fast_xmit()
3194 spin_unlock_bh(&sta->lock); in ieee80211_clear_fast_xmit()
3204 I802_DEBUG_INC(local->tx_expand_skb_head); in ieee80211_amsdu_realloc_pad()
3207 wiphy_debug(local->hw.wiphy, in ieee80211_amsdu_realloc_pad()
3220 struct ieee80211_local *local = sdata->local; in ieee80211_amsdu_prepare_head()
3224 int hdr_len = fast_tx->hdr_len - sizeof(rfc1042_header); in ieee80211_amsdu_prepare_head()
3225 int subframe_len = skb->len - hdr_len; in ieee80211_amsdu_prepare_head()
3230 if (info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE) in ieee80211_amsdu_prepare_head()
3233 if (info->control.flags & IEEE80211_TX_CTRL_AMSDU) in ieee80211_amsdu_prepare_head()
3238 local->hw.extra_tx_headroom)) in ieee80211_amsdu_prepare_head()
3246 h_80211_src = data + fast_tx->sa_offs; in ieee80211_amsdu_prepare_head()
3247 h_80211_dst = data + fast_tx->da_offs; in ieee80211_amsdu_prepare_head()
3249 amsdu_hdr->h_proto = cpu_to_be16(subframe_len); in ieee80211_amsdu_prepare_head()
3250 ether_addr_copy(amsdu_hdr->h_source, h_80211_src); in ieee80211_amsdu_prepare_head()
3251 ether_addr_copy(amsdu_hdr->h_dest, h_80211_dst); in ieee80211_amsdu_prepare_head()
3253 /* according to IEEE 802.11-2012 8.3.2 table 8-19, the outer SA/DA in ieee80211_amsdu_prepare_head()
3254 * fields needs to be changed to BSSID for A-MSDU frames depending in ieee80211_amsdu_prepare_head()
3257 switch (sdata->vif.type) { in ieee80211_amsdu_prepare_head()
3259 bssid = sdata->u.mgd.bssid; in ieee80211_amsdu_prepare_head()
3263 bssid = sdata->vif.addr; in ieee80211_amsdu_prepare_head()
3269 if (bssid && ieee80211_has_fromds(hdr->frame_control)) in ieee80211_amsdu_prepare_head()
3272 if (bssid && ieee80211_has_tods(hdr->frame_control)) in ieee80211_amsdu_prepare_head()
3278 info->control.flags |= IEEE80211_TX_CTRL_AMSDU; in ieee80211_amsdu_prepare_head()
3288 struct ieee80211_local *local = sdata->local; in ieee80211_amsdu_aggregate()
3289 struct fq *fq = &local->fq; in ieee80211_amsdu_aggregate()
3292 u8 tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; in ieee80211_amsdu_aggregate()
3293 struct ieee80211_txq *txq = sta->sta.txq[tid]; in ieee80211_amsdu_aggregate()
3296 int subframe_len = skb->len - ETH_ALEN; in ieee80211_amsdu_aggregate()
3297 u8 max_subframes = sta->sta.max_amsdu_subframes; in ieee80211_amsdu_aggregate()
3298 int max_frags = local->hw.max_tx_fragments; in ieee80211_amsdu_aggregate()
3299 int max_amsdu_len = sta->sta.max_amsdu_len; in ieee80211_amsdu_aggregate()
3309 if (!ieee80211_hw_check(&local->hw, TX_AMSDU)) in ieee80211_amsdu_aggregate()
3319 if (test_bit(IEEE80211_TXQ_NO_AMSDU, &txqi->flags)) in ieee80211_amsdu_aggregate()
3322 if (sta->sta.max_rc_amsdu_len) in ieee80211_amsdu_aggregate()
3324 sta->sta.max_rc_amsdu_len); in ieee80211_amsdu_aggregate()
3326 if (sta->sta.max_tid_amsdu_len[tid]) in ieee80211_amsdu_aggregate()
3328 sta->sta.max_tid_amsdu_len[tid]); in ieee80211_amsdu_aggregate()
3332 spin_lock_bh(&fq->lock); in ieee80211_amsdu_aggregate()
3338 tin = &txqi->tin; in ieee80211_amsdu_aggregate()
3341 head = skb_peek_tail(&flow->queue); in ieee80211_amsdu_aggregate()
3343 goto out; in ieee80211_amsdu_aggregate()
3345 orig_truesize = head->truesize; in ieee80211_amsdu_aggregate()
3346 orig_len = head->len; in ieee80211_amsdu_aggregate()
3348 if (skb->len + head->len > max_amsdu_len) in ieee80211_amsdu_aggregate()
3349 goto out; in ieee80211_amsdu_aggregate()
3351 nfrags = 1 + skb_shinfo(skb)->nr_frags; in ieee80211_amsdu_aggregate()
3352 nfrags += 1 + skb_shinfo(head)->nr_frags; in ieee80211_amsdu_aggregate()
3353 frag_tail = &skb_shinfo(head)->frag_list; in ieee80211_amsdu_aggregate()
3355 nfrags += 1 + skb_shinfo(*frag_tail)->nr_frags; in ieee80211_amsdu_aggregate()
3356 frag_tail = &(*frag_tail)->next; in ieee80211_amsdu_aggregate()
3361 goto out; in ieee80211_amsdu_aggregate()
3364 goto out; in ieee80211_amsdu_aggregate()
3367 goto out; in ieee80211_amsdu_aggregate()
3370 goto out; in ieee80211_amsdu_aggregate()
3373 * and frag_tail should be &skb_shinfo(head)->frag_list. in ieee80211_amsdu_aggregate()
3378 frag_tail = &skb_shinfo(head)->frag_list; in ieee80211_amsdu_aggregate()
3381 * Pad out the previous subframe to a multiple of 4 by adding the in ieee80211_amsdu_aggregate()
3382 * padding to the next one, that's being added. Note that head->len in ieee80211_amsdu_aggregate()
3383 * is the length of the full A-MSDU, but that works since each time in ieee80211_amsdu_aggregate()
3384 * we add a new subframe we pad out the previous one to a multiple in ieee80211_amsdu_aggregate()
3385 * of 4 and thus it no longer matters in the next round. in ieee80211_amsdu_aggregate()
3387 hdrlen = fast_tx->hdr_len - sizeof(rfc1042_header); in ieee80211_amsdu_aggregate()
3388 if ((head->len - hdrlen) & 3) in ieee80211_amsdu_aggregate()
3389 pad = 4 - ((head->len - hdrlen) & 3); in ieee80211_amsdu_aggregate()
3406 head->len += skb->len; in ieee80211_amsdu_aggregate()
3407 head->data_len += skb->len; in ieee80211_amsdu_aggregate()
3411 fq->memory_usage += head->truesize - orig_truesize; in ieee80211_amsdu_aggregate()
3412 if (head->len != orig_len) { in ieee80211_amsdu_aggregate()
3413 flow->backlog += head->len - orig_len; in ieee80211_amsdu_aggregate()
3414 tin->backlog_bytes += head->len - orig_len; in ieee80211_amsdu_aggregate()
3418 out: in ieee80211_amsdu_aggregate()
3419 spin_unlock_bh(&fq->lock); in ieee80211_amsdu_aggregate()
3434 struct ieee80211_hdr *hdr = (void *)skb->data; in ieee80211_xmit_fast_finish()
3438 info->control.hw_key = &key->conf; in ieee80211_xmit_fast_finish()
3440 ieee80211_tx_stats(skb->dev, skb->len); in ieee80211_xmit_fast_finish()
3442 if (hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) { in ieee80211_xmit_fast_finish()
3443 tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; in ieee80211_xmit_fast_finish()
3444 hdr->seq_ctrl = ieee80211_tx_next_seq(sta, tid); in ieee80211_xmit_fast_finish()
3446 info->flags |= IEEE80211_TX_CTL_ASSIGN_SEQ; in ieee80211_xmit_fast_finish()
3447 hdr->seq_ctrl = cpu_to_le16(sdata->sequence_number); in ieee80211_xmit_fast_finish()
3448 sdata->sequence_number += 0x10; in ieee80211_xmit_fast_finish()
3451 if (skb_shinfo(skb)->gso_size) in ieee80211_xmit_fast_finish()
3452 sta->tx_stats.msdu[tid] += in ieee80211_xmit_fast_finish()
3453 DIV_ROUND_UP(skb->len, skb_shinfo(skb)->gso_size); in ieee80211_xmit_fast_finish()
3455 sta->tx_stats.msdu[tid]++; in ieee80211_xmit_fast_finish()
3457 info->hw_queue = sdata->vif.hw_queue[skb_get_queue_mapping(skb)]; in ieee80211_xmit_fast_finish()
3462 sta->tx_stats.bytes[skb_get_queue_mapping(skb)] += skb->len; in ieee80211_xmit_fast_finish()
3463 sta->tx_stats.packets[skb_get_queue_mapping(skb)]++; in ieee80211_xmit_fast_finish()
3467 u8 *crypto_hdr = skb->data + pn_offs; in ieee80211_xmit_fast_finish()
3469 switch (key->conf.cipher) { in ieee80211_xmit_fast_finish()
3474 pn = atomic64_inc_return(&key->conf.tx_pn); in ieee80211_xmit_fast_finish()
3477 crypto_hdr[3] = 0x20 | (key->conf.keyidx << 6); in ieee80211_xmit_fast_finish()
3492 struct ieee80211_local *local = sdata->local; in ieee80211_xmit_fast()
3493 u16 ethertype = (skb->data[12] << 8) | skb->data[13]; in ieee80211_xmit_fast()
3494 int extra_head = fast_tx->hdr_len - (ETH_HLEN - 2); in ieee80211_xmit_fast()
3495 int hw_headroom = sdata->local->hw.extra_tx_headroom; in ieee80211_xmit_fast()
3498 struct ieee80211_hdr *hdr = (void *)fast_tx->hdr; in ieee80211_xmit_fast()
3504 /* control port protocol needs a lot of special handling */ in ieee80211_xmit_fast()
3505 if (cpu_to_be16(ethertype) == sdata->control_port_protocol) in ieee80211_xmit_fast()
3513 if (skb->sk && skb_shinfo(skb)->tx_flags & SKBTX_WIFI_STATUS) in ieee80211_xmit_fast()
3516 if (hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) { in ieee80211_xmit_fast()
3517 tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; in ieee80211_xmit_fast()
3518 tid_tx = rcu_dereference(sta->ampdu_mlme.tid_tx[tid]); in ieee80211_xmit_fast()
3520 if (!test_bit(HT_AGG_STATE_OPERATIONAL, &tid_tx->state)) in ieee80211_xmit_fast()
3522 if (tid_tx->timeout) in ieee80211_xmit_fast()
3523 tid_tx->last_tx = jiffies; in ieee80211_xmit_fast()
3539 if ((hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) && in ieee80211_xmit_fast()
3543 /* will not be crypto-handled beyond what we do here, so use false in ieee80211_xmit_fast()
3544 * as the may-encrypt argument for the resize to not account for in ieee80211_xmit_fast()
3548 max_t(int, extra_head + hw_headroom - in ieee80211_xmit_fast()
3555 memcpy(&eth, skb->data, ETH_HLEN - 2); in ieee80211_xmit_fast()
3557 memcpy(skb->data, fast_tx->hdr, fast_tx->hdr_len); in ieee80211_xmit_fast()
3558 memcpy(skb->data + fast_tx->da_offs, eth.h_dest, ETH_ALEN); in ieee80211_xmit_fast()
3559 memcpy(skb->data + fast_tx->sa_offs, eth.h_source, ETH_ALEN); in ieee80211_xmit_fast()
3563 info->band = fast_tx->band; in ieee80211_xmit_fast()
3564 info->control.vif = &sdata->vif; in ieee80211_xmit_fast()
3565 info->flags = IEEE80211_TX_CTL_FIRST_FRAGMENT | in ieee80211_xmit_fast()
3568 info->control.flags = IEEE80211_TX_CTRL_FAST_XMIT; in ieee80211_xmit_fast()
3571 if (local->force_tx_status) in ieee80211_xmit_fast()
3572 info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS; in ieee80211_xmit_fast()
3575 if (hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) { in ieee80211_xmit_fast()
3576 tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; in ieee80211_xmit_fast()
3586 tx.key = fast_tx->key; in ieee80211_xmit_fast()
3588 if (!ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL)) { in ieee80211_xmit_fast()
3604 ieee80211_xmit_fast_finish(sdata, sta, fast_tx->pn_offs, in ieee80211_xmit_fast()
3605 fast_tx->key, skb); in ieee80211_xmit_fast()
3607 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) in ieee80211_xmit_fast()
3608 sdata = container_of(sdata->bss, in ieee80211_xmit_fast()
3612 ieee80211_tx_frags(local, &sdata->vif, sta, &tx.skbs, false); in ieee80211_xmit_fast()
3623 struct fq *fq = &local->fq; in ieee80211_tx_dequeue()
3624 struct fq_tin *tin = &txqi->tin; in ieee80211_tx_dequeue()
3628 struct ieee80211_vif *vif = txq->vif; in ieee80211_tx_dequeue()
3636 spin_lock_bh(&fq->lock); in ieee80211_tx_dequeue()
3638 if (test_bit(IEEE80211_TXQ_STOP, &txqi->flags) || in ieee80211_tx_dequeue()
3639 test_bit(IEEE80211_TXQ_STOP_NETIF_TX, &txqi->flags)) in ieee80211_tx_dequeue()
3640 goto out; in ieee80211_tx_dequeue()
3642 if (vif->txqs_stopped[txq->ac]) { in ieee80211_tx_dequeue()
3643 set_bit(IEEE80211_TXQ_STOP_NETIF_TX, &txqi->flags); in ieee80211_tx_dequeue()
3644 goto out; in ieee80211_tx_dequeue()
3648 skb = __skb_dequeue(&txqi->frags); in ieee80211_tx_dequeue()
3650 goto out; in ieee80211_tx_dequeue()
3654 goto out; in ieee80211_tx_dequeue()
3656 spin_unlock_bh(&fq->lock); in ieee80211_tx_dequeue()
3658 hdr = (struct ieee80211_hdr *)skb->data; in ieee80211_tx_dequeue()
3665 tx.sdata = vif_to_sdata(info->control.vif); in ieee80211_tx_dequeue()
3667 if (txq->sta) { in ieee80211_tx_dequeue()
3668 tx.sta = container_of(txq->sta, struct sta_info, sta); in ieee80211_tx_dequeue()
3673 if (unlikely(!(info->flags & IEEE80211_TX_CTL_INJECTED) && in ieee80211_tx_dequeue()
3674 ieee80211_is_data(hdr->frame_control) && in ieee80211_tx_dequeue()
3675 !ieee80211_vif_is_mesh(&tx.sdata->vif) && in ieee80211_tx_dequeue()
3676 tx.sdata->vif.type != NL80211_IFTYPE_OCB && in ieee80211_tx_dequeue()
3677 !is_multicast_ether_addr(hdr->addr1) && in ieee80211_tx_dequeue()
3679 (!(info->control.flags & in ieee80211_tx_dequeue()
3681 !ether_addr_equal(tx.sdata->vif.addr, in ieee80211_tx_dequeue()
3682 hdr->addr2)))) { in ieee80211_tx_dequeue()
3683 I802_DEBUG_INC(local->tx_handlers_drop_unauth_port); in ieee80211_tx_dequeue()
3684 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_dequeue()
3695 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_dequeue()
3699 if (test_bit(IEEE80211_TXQ_AMPDU, &txqi->flags)) in ieee80211_tx_dequeue()
3700 info->flags |= IEEE80211_TX_CTL_AMPDU; in ieee80211_tx_dequeue()
3702 info->flags &= ~IEEE80211_TX_CTL_AMPDU; in ieee80211_tx_dequeue()
3704 if (info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP) in ieee80211_tx_dequeue()
3707 if (info->control.flags & IEEE80211_TX_CTRL_FAST_XMIT) { in ieee80211_tx_dequeue()
3708 struct sta_info *sta = container_of(txq->sta, struct sta_info, in ieee80211_tx_dequeue()
3713 (tx.key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)) in ieee80211_tx_dequeue()
3714 pn_offs = ieee80211_hdrlen(hdr->frame_control); in ieee80211_tx_dequeue()
3716 ieee80211_xmit_fast_finish(sta->sdata, sta, pn_offs, in ieee80211_tx_dequeue()
3725 spin_lock_bh(&fq->lock); in ieee80211_tx_dequeue()
3726 skb_queue_splice_tail(&tx.skbs, &txqi->frags); in ieee80211_tx_dequeue()
3727 spin_unlock_bh(&fq->lock); in ieee80211_tx_dequeue()
3732 !ieee80211_hw_check(&local->hw, TX_FRAG_LIST)) { in ieee80211_tx_dequeue()
3734 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_dequeue()
3739 switch (tx.sdata->vif.type) { in ieee80211_tx_dequeue()
3741 if (tx.sdata->u.mntr.flags & MONITOR_FLAG_ACTIVE) { in ieee80211_tx_dequeue()
3742 vif = &tx.sdata->vif; in ieee80211_tx_dequeue()
3745 tx.sdata = rcu_dereference(local->monitor_sdata); in ieee80211_tx_dequeue()
3747 vif = &tx.sdata->vif; in ieee80211_tx_dequeue()
3748 info->hw_queue = in ieee80211_tx_dequeue()
3749 vif->hw_queue[skb_get_queue_mapping(skb)]; in ieee80211_tx_dequeue()
3750 } else if (ieee80211_hw_check(&local->hw, QUEUE_CONTROL)) { in ieee80211_tx_dequeue()
3751 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_dequeue()
3758 tx.sdata = container_of(tx.sdata->bss, in ieee80211_tx_dequeue()
3762 vif = &tx.sdata->vif; in ieee80211_tx_dequeue()
3767 IEEE80211_SKB_CB(skb)->control.vif = vif; in ieee80211_tx_dequeue()
3770 wiphy_ext_feature_isset(local->hw.wiphy, NL80211_EXT_FEATURE_AQL)) { in ieee80211_tx_dequeue()
3771 bool ampdu = txq->ac != IEEE80211_AC_VO; in ieee80211_tx_dequeue()
3774 airtime = ieee80211_calc_expected_tx_airtime(hw, vif, txq->sta, in ieee80211_tx_dequeue()
3775 skb->len, ampdu); in ieee80211_tx_dequeue()
3779 txq->ac, in ieee80211_tx_dequeue()
3787 out: in ieee80211_tx_dequeue()
3788 spin_unlock_bh(&fq->lock); in ieee80211_tx_dequeue()
3801 spin_lock_bh(&local->active_txq_lock[ac]); in ieee80211_next_txq()
3804 txqi = list_first_entry_or_null(&local->active_txqs[ac], in ieee80211_next_txq()
3808 goto out; in ieee80211_next_txq()
3812 goto out; in ieee80211_next_txq()
3820 if (txqi->txq.sta) { in ieee80211_next_txq()
3821 struct sta_info *sta = container_of(txqi->txq.sta, in ieee80211_next_txq()
3823 bool aql_check = ieee80211_txq_airtime_check(hw, &txqi->txq); in ieee80211_next_txq()
3824 s64 deficit = sta->airtime[txqi->txq.ac].deficit; in ieee80211_next_txq()
3830 sta->airtime[txqi->txq.ac].deficit += in ieee80211_next_txq()
3831 sta->airtime_weight; in ieee80211_next_txq()
3834 list_move_tail(&txqi->schedule_order, in ieee80211_next_txq()
3835 &local->active_txqs[txqi->txq.ac]); in ieee80211_next_txq()
3841 if (txqi->schedule_round == local->schedule_round[ac]) in ieee80211_next_txq()
3842 goto out; in ieee80211_next_txq()
3844 list_del_init(&txqi->schedule_order); in ieee80211_next_txq()
3845 txqi->schedule_round = local->schedule_round[ac]; in ieee80211_next_txq()
3846 ret = &txqi->txq; in ieee80211_next_txq()
3848 out: in ieee80211_next_txq()
3849 spin_unlock_bh(&local->active_txq_lock[ac]); in ieee80211_next_txq()
3861 spin_lock_bh(&local->active_txq_lock[txq->ac]); in __ieee80211_schedule_txq()
3863 if (list_empty(&txqi->schedule_order) && in __ieee80211_schedule_txq()
3864 (force || !skb_queue_empty(&txqi->frags) || in __ieee80211_schedule_txq()
3865 txqi->tin.backlog_packets)) { in __ieee80211_schedule_txq()
3867 * head of the list to ensure that they only get moved to the in __ieee80211_schedule_txq()
3870 * get immediately moved to the back of the list on the next in __ieee80211_schedule_txq()
3873 if (txqi->txq.sta && local->airtime_flags && in __ieee80211_schedule_txq()
3874 wiphy_ext_feature_isset(local->hw.wiphy, in __ieee80211_schedule_txq()
3876 list_add(&txqi->schedule_order, in __ieee80211_schedule_txq()
3877 &local->active_txqs[txq->ac]); in __ieee80211_schedule_txq()
3879 list_add_tail(&txqi->schedule_order, in __ieee80211_schedule_txq()
3880 &local->active_txqs[txq->ac]); in __ieee80211_schedule_txq()
3883 spin_unlock_bh(&local->active_txq_lock[txq->ac]); in __ieee80211_schedule_txq()
3893 if (!wiphy_ext_feature_isset(local->hw.wiphy, NL80211_EXT_FEATURE_AQL)) in ieee80211_txq_airtime_check()
3896 if (!txq->sta) in ieee80211_txq_airtime_check()
3899 sta = container_of(txq->sta, struct sta_info, sta); in ieee80211_txq_airtime_check()
3900 if (atomic_read(&sta->airtime[txq->ac].aql_tx_pending) < in ieee80211_txq_airtime_check()
3901 sta->airtime[txq->ac].aql_limit_low) in ieee80211_txq_airtime_check()
3904 if (atomic_read(&local->aql_total_pending_airtime) < in ieee80211_txq_airtime_check()
3905 local->aql_threshold && in ieee80211_txq_airtime_check()
3906 atomic_read(&sta->airtime[txq->ac].aql_tx_pending) < in ieee80211_txq_airtime_check()
3907 sta->airtime[txq->ac].aql_limit_high) in ieee80211_txq_airtime_check()
3920 u8 ac = txq->ac; in ieee80211_txq_may_transmit()
3922 spin_lock_bh(&local->active_txq_lock[ac]); in ieee80211_txq_may_transmit()
3924 if (!txqi->txq.sta) in ieee80211_txq_may_transmit()
3925 goto out; in ieee80211_txq_may_transmit()
3927 if (list_empty(&txqi->schedule_order)) in ieee80211_txq_may_transmit()
3928 goto out; in ieee80211_txq_may_transmit()
3930 list_for_each_entry_safe(iter, tmp, &local->active_txqs[ac], in ieee80211_txq_may_transmit()
3935 if (!iter->txq.sta) { in ieee80211_txq_may_transmit()
3936 list_move_tail(&iter->schedule_order, in ieee80211_txq_may_transmit()
3937 &local->active_txqs[ac]); in ieee80211_txq_may_transmit()
3940 sta = container_of(iter->txq.sta, struct sta_info, sta); in ieee80211_txq_may_transmit()
3941 if (sta->airtime[ac].deficit < 0) in ieee80211_txq_may_transmit()
3942 sta->airtime[ac].deficit += sta->airtime_weight; in ieee80211_txq_may_transmit()
3943 list_move_tail(&iter->schedule_order, &local->active_txqs[ac]); in ieee80211_txq_may_transmit()
3946 sta = container_of(txqi->txq.sta, struct sta_info, sta); in ieee80211_txq_may_transmit()
3947 if (sta->airtime[ac].deficit >= 0) in ieee80211_txq_may_transmit()
3948 goto out; in ieee80211_txq_may_transmit()
3950 sta->airtime[ac].deficit += sta->airtime_weight; in ieee80211_txq_may_transmit()
3951 list_move_tail(&txqi->schedule_order, &local->active_txqs[ac]); in ieee80211_txq_may_transmit()
3952 spin_unlock_bh(&local->active_txq_lock[ac]); in ieee80211_txq_may_transmit()
3955 out: in ieee80211_txq_may_transmit()
3956 if (!list_empty(&txqi->schedule_order)) in ieee80211_txq_may_transmit()
3957 list_del_init(&txqi->schedule_order); in ieee80211_txq_may_transmit()
3958 spin_unlock_bh(&local->active_txq_lock[ac]); in ieee80211_txq_may_transmit()
3968 spin_lock_bh(&local->active_txq_lock[ac]); in ieee80211_txq_schedule_start()
3969 local->schedule_round[ac]++; in ieee80211_txq_schedule_start()
3970 spin_unlock_bh(&local->active_txq_lock[ac]); in ieee80211_txq_schedule_start()
3981 struct ieee80211_local *local = sdata->local; in __ieee80211_subif_start_xmit()
3985 if (unlikely(skb->len < ETH_HLEN)) { in __ieee80211_subif_start_xmit()
3998 if (local->ops->wake_tx_queue) { in __ieee80211_subif_start_xmit()
4007 sk_pacing_shift_update(skb->sk, sdata->local->hw.tx_sk_pacing_shift); in __ieee80211_subif_start_xmit()
4009 fast_tx = rcu_dereference(sta->fast_tx); in __ieee80211_subif_start_xmit()
4013 goto out; in __ieee80211_subif_start_xmit()
4027 /* we cannot process non-linear frames on this path */ in __ieee80211_subif_start_xmit()
4030 goto out; in __ieee80211_subif_start_xmit()
4033 /* the frame could be fragmented, software-encrypted, and other in __ieee80211_subif_start_xmit()
4034 * things so we cannot really handle checksum offload with it - in __ieee80211_subif_start_xmit()
4037 if (skb->ip_summed == CHECKSUM_PARTIAL) { in __ieee80211_subif_start_xmit()
4048 if (skb->protocol == sdata->control_port_protocol) in __ieee80211_subif_start_xmit()
4055 goto out; in __ieee80211_subif_start_xmit()
4058 ieee80211_tx_stats(dev, skb->len); in __ieee80211_subif_start_xmit()
4062 goto out; in __ieee80211_subif_start_xmit()
4065 out: in __ieee80211_subif_start_xmit()
4078 eth = (void *)skb->data; in ieee80211_change_da()
4079 ether_addr_copy(eth->h_dest, sta->sta.addr); in ieee80211_change_da()
4088 const struct ethhdr *eth = (void *)skb->data; in ieee80211_multicast_to_unicast()
4089 const struct vlan_ethhdr *ethvlan = (void *)skb->data; in ieee80211_multicast_to_unicast()
4092 if (likely(!is_multicast_ether_addr(eth->h_dest))) in ieee80211_multicast_to_unicast()
4095 switch (sdata->vif.type) { in ieee80211_multicast_to_unicast()
4097 if (sdata->u.vlan.sta) in ieee80211_multicast_to_unicast()
4099 if (sdata->wdev.use_4addr) in ieee80211_multicast_to_unicast()
4104 if (!sdata->bss->multicast_to_unicast) in ieee80211_multicast_to_unicast()
4112 ethertype = eth->h_proto; in ieee80211_multicast_to_unicast()
4113 if (ethertype == htons(ETH_P_8021Q) && skb->len >= VLAN_ETH_HLEN) in ieee80211_multicast_to_unicast()
4114 ethertype = ethvlan->h_vlan_encapsulated_proto; in ieee80211_multicast_to_unicast()
4132 struct ieee80211_local *local = sdata->local; in ieee80211_convert_to_unicast()
4133 const struct ethhdr *eth = (struct ethhdr *)skb->data; in ieee80211_convert_to_unicast()
4139 list_for_each_entry_rcu(sta, &local->sta_list, list) { in ieee80211_convert_to_unicast()
4140 if (sdata != sta->sdata) in ieee80211_convert_to_unicast()
4141 /* AP-VLAN mismatch */ in ieee80211_convert_to_unicast()
4143 if (unlikely(ether_addr_equal(eth->h_source, sta->sta.addr))) in ieee80211_convert_to_unicast()
4170 goto out; in ieee80211_convert_to_unicast()
4174 out: in ieee80211_convert_to_unicast()
4179 * ieee80211_subif_start_xmit - netif start_xmit function for 802.3 vifs
4207 struct ieee80211_local *local = sdata->local; in ieee80211_tx_8023()
4212 int q = info->hw_queue; in ieee80211_tx_8023()
4217 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in ieee80211_tx_8023()
4219 if (local->queue_stop_reasons[q] || in ieee80211_tx_8023()
4220 (!txpending && !skb_queue_empty(&local->pending[q]))) { in ieee80211_tx_8023()
4222 skb_queue_head(&local->pending[q], skb); in ieee80211_tx_8023()
4224 skb_queue_tail(&local->pending[q], skb); in ieee80211_tx_8023()
4226 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_tx_8023()
4231 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_tx_8023()
4233 if (sta && sta->uploaded) in ieee80211_tx_8023()
4234 pubsta = &sta->sta; in ieee80211_tx_8023()
4248 struct ieee80211_local *local = sdata->local; in ieee80211_8023_xmit()
4252 if (local->ops->wake_tx_queue) { in ieee80211_8023_xmit()
4258 if (unlikely(test_bit(SCAN_SW_SCANNING, &local->scanning)) && in ieee80211_8023_xmit()
4259 test_bit(SDATA_STATE_OFFCHANNEL, &sdata->state)) in ieee80211_8023_xmit()
4264 tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; in ieee80211_8023_xmit()
4265 tid_tx = rcu_dereference(sta->ampdu_mlme.tid_tx[tid]); in ieee80211_8023_xmit()
4267 if (!test_bit(HT_AGG_STATE_OPERATIONAL, &tid_tx->state)) { in ieee80211_8023_xmit()
4268 /* fall back to non-offload slow path */ in ieee80211_8023_xmit()
4273 info->flags |= IEEE80211_TX_CTL_AMPDU; in ieee80211_8023_xmit()
4274 if (tid_tx->timeout) in ieee80211_8023_xmit()
4275 tid_tx->last_tx = jiffies; in ieee80211_8023_xmit()
4278 if (unlikely(skb->sk && in ieee80211_8023_xmit()
4279 skb_shinfo(skb)->tx_flags & SKBTX_WIFI_STATUS)) in ieee80211_8023_xmit()
4280 info->ack_frame_id = ieee80211_store_ack_skb(local, skb, in ieee80211_8023_xmit()
4281 &info->flags, NULL); in ieee80211_8023_xmit()
4283 info->hw_queue = sdata->vif.hw_queue[skb_get_queue_mapping(skb)]; in ieee80211_8023_xmit()
4285 ieee80211_tx_stats(dev, skb->len); in ieee80211_8023_xmit()
4287 sta->tx_stats.bytes[skb_get_queue_mapping(skb)] += skb->len; in ieee80211_8023_xmit()
4288 sta->tx_stats.packets[skb_get_queue_mapping(skb)]++; in ieee80211_8023_xmit()
4290 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) in ieee80211_8023_xmit()
4291 sdata = container_of(sdata->bss, in ieee80211_8023_xmit()
4294 info->flags |= IEEE80211_TX_CTL_HW_80211_ENCAP; in ieee80211_8023_xmit()
4295 info->control.vif = &sdata->vif; in ieee80211_8023_xmit()
4298 info->control.hw_key = &key->conf; in ieee80211_8023_xmit()
4300 ieee80211_tx_8023(sdata, skb, skb->len, sta, false); in ieee80211_8023_xmit()
4312 struct ethhdr *ehdr = (struct ethhdr *)skb->data; in ieee80211_subif_start_xmit_8023()
4316 if (unlikely(skb->len < ETH_HLEN)) { in ieee80211_subif_start_xmit_8023()
4325 goto out; in ieee80211_subif_start_xmit_8023()
4328 if (unlikely(IS_ERR_OR_NULL(sta) || !sta->uploaded || in ieee80211_subif_start_xmit_8023()
4330 sdata->control_port_protocol == ehdr->h_proto)) in ieee80211_subif_start_xmit_8023()
4333 key = rcu_dereference(sta->ptk[sta->ptk_idx]); in ieee80211_subif_start_xmit_8023()
4335 key = rcu_dereference(sdata->default_unicast_key); in ieee80211_subif_start_xmit_8023()
4337 if (key && (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) || in ieee80211_subif_start_xmit_8023()
4338 key->conf.cipher == WLAN_CIPHER_SUITE_TKIP)) in ieee80211_subif_start_xmit_8023()
4342 goto out; in ieee80211_subif_start_xmit_8023()
4346 out: in ieee80211_subif_start_xmit_8023()
4358 .local = sdata->local, in ieee80211_build_data_template()
4367 skb = ERR_PTR(-EINVAL); in ieee80211_build_data_template()
4368 goto out; in ieee80211_build_data_template()
4373 goto out; in ieee80211_build_data_template()
4375 hdr = (void *)skb->data; in ieee80211_build_data_template()
4376 tx.sta = sta_info_get(sdata, hdr->addr1); in ieee80211_build_data_template()
4382 return ERR_PTR(-EINVAL); in ieee80211_build_data_template()
4385 out: in ieee80211_build_data_template()
4399 for (i = 0; i < local->hw.queues; i++) { in ieee80211_clear_tx_pending()
4400 while ((skb = skb_dequeue(&local->pending[i])) != NULL) in ieee80211_clear_tx_pending()
4401 ieee80211_free_txskb(&local->hw, skb); in ieee80211_clear_tx_pending()
4407 * which in this case means re-queued -- take as an indication to stop sending
4420 sdata = vif_to_sdata(info->control.vif); in ieee80211_tx_pending_skb()
4422 if (info->control.flags & IEEE80211_TX_INTCFL_NEED_TXPROCESSING) { in ieee80211_tx_pending_skb()
4423 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); in ieee80211_tx_pending_skb()
4428 info->band = chanctx_conf->def.chan->band; in ieee80211_tx_pending_skb()
4430 } else if (info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP) { in ieee80211_tx_pending_skb()
4436 if (IS_ERR(sta) || (sta && !sta->uploaded)) in ieee80211_tx_pending_skb()
4439 result = ieee80211_tx_8023(sdata, skb, skb->len, sta, true); in ieee80211_tx_pending_skb()
4446 hdr = (struct ieee80211_hdr *)skb->data; in ieee80211_tx_pending_skb()
4447 sta = sta_info_get(sdata, hdr->addr1); in ieee80211_tx_pending_skb()
4449 result = __ieee80211_tx(local, &skbs, skb->len, sta, true); in ieee80211_tx_pending_skb()
4467 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in ieee80211_tx_pending()
4468 for (i = 0; i < local->hw.queues; i++) { in ieee80211_tx_pending()
4473 if (local->queue_stop_reasons[i] || in ieee80211_tx_pending()
4474 skb_queue_empty(&local->pending[i])) in ieee80211_tx_pending()
4477 while (!skb_queue_empty(&local->pending[i])) { in ieee80211_tx_pending()
4478 struct sk_buff *skb = __skb_dequeue(&local->pending[i]); in ieee80211_tx_pending()
4481 if (WARN_ON(!info->control.vif)) { in ieee80211_tx_pending()
4482 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_pending()
4486 spin_unlock_irqrestore(&local->queue_stop_reason_lock, in ieee80211_tx_pending()
4490 spin_lock_irqsave(&local->queue_stop_reason_lock, in ieee80211_tx_pending()
4496 if (skb_queue_empty(&local->pending[i])) in ieee80211_tx_pending()
4499 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_tx_pending()
4516 if (atomic_read(&ps->num_sta_ps) > 0) in __ieee80211_beacon_add_tim()
4518 * checking byte-for-byte */ in __ieee80211_beacon_add_tim()
4519 have_bits = !bitmap_empty((unsigned long *)ps->tim, in __ieee80211_beacon_add_tim()
4522 if (ps->dtim_count == 0) in __ieee80211_beacon_add_tim()
4523 ps->dtim_count = sdata->vif.bss_conf.dtim_period - 1; in __ieee80211_beacon_add_tim()
4525 ps->dtim_count--; in __ieee80211_beacon_add_tim()
4531 *pos++ = ps->dtim_count; in __ieee80211_beacon_add_tim()
4532 *pos++ = sdata->vif.bss_conf.dtim_period; in __ieee80211_beacon_add_tim()
4534 if (ps->dtim_count == 0 && !skb_queue_empty(&ps->bc_buf)) in __ieee80211_beacon_add_tim()
4537 ps->dtim_bc_mc = aid0 == 1; in __ieee80211_beacon_add_tim()
4541 * (N1 x 8) - 1 in the bitmap are 0 and number N2 so that bits in __ieee80211_beacon_add_tim()
4545 if (ps->tim[i]) { in __ieee80211_beacon_add_tim()
4551 for (i = IEEE80211_MAX_TIM_LEN - 1; i >= n1; i--) { in __ieee80211_beacon_add_tim()
4552 if (ps->tim[i]) { in __ieee80211_beacon_add_tim()
4561 skb_put(skb, n2 - n1); in __ieee80211_beacon_add_tim()
4562 memcpy(pos, ps->tim + n1, n2 - n1 + 1); in __ieee80211_beacon_add_tim()
4564 tim[1] = n2 - n1 + 4; in __ieee80211_beacon_add_tim()
4575 struct ieee80211_local *local = sdata->local; in ieee80211_beacon_add_tim()
4581 * sta_lock to guarantee consistent and race-free update in ieee80211_beacon_add_tim()
4582 * of the tim bitmap in mac80211 and the driver. in ieee80211_beacon_add_tim()
4584 if (local->tim_in_locked_section) { in ieee80211_beacon_add_tim()
4587 spin_lock_bh(&local->tim_lock); in ieee80211_beacon_add_tim()
4589 spin_unlock_bh(&local->tim_lock); in ieee80211_beacon_add_tim()
4602 u8 count = beacon->cntdwn_current_counter; in ieee80211_set_beacon_cntdwn()
4604 switch (sdata->vif.type) { in ieee80211_set_beacon_cntdwn()
4606 beacon_data = beacon->tail; in ieee80211_set_beacon_cntdwn()
4607 beacon_data_len = beacon->tail_len; in ieee80211_set_beacon_cntdwn()
4610 beacon_data = beacon->head; in ieee80211_set_beacon_cntdwn()
4611 beacon_data_len = beacon->head_len; in ieee80211_set_beacon_cntdwn()
4614 beacon_data = beacon->head; in ieee80211_set_beacon_cntdwn()
4615 beacon_data_len = beacon->head_len; in ieee80211_set_beacon_cntdwn()
4623 resp = rcu_dereference(sdata->u.ap.probe_resp); in ieee80211_set_beacon_cntdwn()
4625 if (beacon->cntdwn_counter_offsets[i]) { in ieee80211_set_beacon_cntdwn()
4626 if (WARN_ON_ONCE(beacon->cntdwn_counter_offsets[i] >= in ieee80211_set_beacon_cntdwn()
4632 beacon_data[beacon->cntdwn_counter_offsets[i]] = count; in ieee80211_set_beacon_cntdwn()
4635 if (sdata->vif.type == NL80211_IFTYPE_AP && resp) in ieee80211_set_beacon_cntdwn()
4636 resp->data[resp->cntdwn_counter_offsets[i]] = count; in ieee80211_set_beacon_cntdwn()
4643 beacon->cntdwn_current_counter--; in __ieee80211_beacon_update_cntdwn()
4646 WARN_ON_ONCE(!beacon->cntdwn_current_counter); in __ieee80211_beacon_update_cntdwn()
4648 return beacon->cntdwn_current_counter; in __ieee80211_beacon_update_cntdwn()
4659 if (sdata->vif.type == NL80211_IFTYPE_AP) in ieee80211_beacon_update_cntdwn()
4660 beacon = rcu_dereference(sdata->u.ap.beacon); in ieee80211_beacon_update_cntdwn()
4661 else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) in ieee80211_beacon_update_cntdwn()
4662 beacon = rcu_dereference(sdata->u.ibss.presp); in ieee80211_beacon_update_cntdwn()
4663 else if (ieee80211_vif_is_mesh(&sdata->vif)) in ieee80211_beacon_update_cntdwn()
4664 beacon = rcu_dereference(sdata->u.mesh.beacon); in ieee80211_beacon_update_cntdwn()
4684 if (sdata->vif.type == NL80211_IFTYPE_AP) in ieee80211_beacon_set_cntdwn()
4685 beacon = rcu_dereference(sdata->u.ap.beacon); in ieee80211_beacon_set_cntdwn()
4686 else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) in ieee80211_beacon_set_cntdwn()
4687 beacon = rcu_dereference(sdata->u.ibss.presp); in ieee80211_beacon_set_cntdwn()
4688 else if (ieee80211_vif_is_mesh(&sdata->vif)) in ieee80211_beacon_set_cntdwn()
4689 beacon = rcu_dereference(sdata->u.mesh.beacon); in ieee80211_beacon_set_cntdwn()
4694 if (counter < beacon->cntdwn_current_counter) in ieee80211_beacon_set_cntdwn()
4695 beacon->cntdwn_current_counter = counter; in ieee80211_beacon_set_cntdwn()
4714 if (vif->type == NL80211_IFTYPE_AP) { in ieee80211_beacon_cntdwn_is_complete()
4715 struct ieee80211_if_ap *ap = &sdata->u.ap; in ieee80211_beacon_cntdwn_is_complete()
4717 beacon = rcu_dereference(ap->beacon); in ieee80211_beacon_cntdwn_is_complete()
4718 if (WARN_ON(!beacon || !beacon->tail)) in ieee80211_beacon_cntdwn_is_complete()
4719 goto out; in ieee80211_beacon_cntdwn_is_complete()
4720 beacon_data = beacon->tail; in ieee80211_beacon_cntdwn_is_complete()
4721 beacon_data_len = beacon->tail_len; in ieee80211_beacon_cntdwn_is_complete()
4722 } else if (vif->type == NL80211_IFTYPE_ADHOC) { in ieee80211_beacon_cntdwn_is_complete()
4723 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; in ieee80211_beacon_cntdwn_is_complete()
4725 beacon = rcu_dereference(ifibss->presp); in ieee80211_beacon_cntdwn_is_complete()
4727 goto out; in ieee80211_beacon_cntdwn_is_complete()
4729 beacon_data = beacon->head; in ieee80211_beacon_cntdwn_is_complete()
4730 beacon_data_len = beacon->head_len; in ieee80211_beacon_cntdwn_is_complete()
4731 } else if (vif->type == NL80211_IFTYPE_MESH_POINT) { in ieee80211_beacon_cntdwn_is_complete()
4732 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; in ieee80211_beacon_cntdwn_is_complete()
4734 beacon = rcu_dereference(ifmsh->beacon); in ieee80211_beacon_cntdwn_is_complete()
4736 goto out; in ieee80211_beacon_cntdwn_is_complete()
4738 beacon_data = beacon->head; in ieee80211_beacon_cntdwn_is_complete()
4739 beacon_data_len = beacon->head_len; in ieee80211_beacon_cntdwn_is_complete()
4742 goto out; in ieee80211_beacon_cntdwn_is_complete()
4745 if (!beacon->cntdwn_counter_offsets[0]) in ieee80211_beacon_cntdwn_is_complete()
4746 goto out; in ieee80211_beacon_cntdwn_is_complete()
4748 if (WARN_ON_ONCE(beacon->cntdwn_counter_offsets[0] > beacon_data_len)) in ieee80211_beacon_cntdwn_is_complete()
4749 goto out; in ieee80211_beacon_cntdwn_is_complete()
4751 if (beacon_data[beacon->cntdwn_counter_offsets[0]] == 1) in ieee80211_beacon_cntdwn_is_complete()
4754 out: in ieee80211_beacon_cntdwn_is_complete()
4770 tx.key = rcu_dereference(sdata->default_beacon_key); in ieee80211_beacon_protect()
4782 return -EINVAL; in ieee80211_beacon_protect()
4798 enum nl80211_band band; in __ieee80211_beacon_get() local
4806 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); in __ieee80211_beacon_get()
4809 goto out; in __ieee80211_beacon_get()
4814 if (sdata->vif.type == NL80211_IFTYPE_AP) { in __ieee80211_beacon_get()
4815 struct ieee80211_if_ap *ap = &sdata->u.ap; in __ieee80211_beacon_get()
4817 beacon = rcu_dereference(ap->beacon); in __ieee80211_beacon_get()
4819 if (beacon->cntdwn_counter_offsets[0]) { in __ieee80211_beacon_get()
4830 skb = dev_alloc_skb(local->tx_headroom + in __ieee80211_beacon_get()
4831 beacon->head_len + in __ieee80211_beacon_get()
4832 beacon->tail_len + 256 + in __ieee80211_beacon_get()
4833 local->hw.extra_beacon_tailroom); in __ieee80211_beacon_get()
4835 goto out; in __ieee80211_beacon_get()
4837 skb_reserve(skb, local->tx_headroom); in __ieee80211_beacon_get()
4838 skb_put_data(skb, beacon->head, beacon->head_len); in __ieee80211_beacon_get()
4840 ieee80211_beacon_add_tim(sdata, &ap->ps, skb, in __ieee80211_beacon_get()
4844 offs->tim_offset = beacon->head_len; in __ieee80211_beacon_get()
4845 offs->tim_length = skb->len - beacon->head_len; in __ieee80211_beacon_get()
4848 csa_off_base = skb->len; in __ieee80211_beacon_get()
4851 if (beacon->tail) in __ieee80211_beacon_get()
4852 skb_put_data(skb, beacon->tail, in __ieee80211_beacon_get()
4853 beacon->tail_len); in __ieee80211_beacon_get()
4856 goto out; in __ieee80211_beacon_get()
4858 goto out; in __ieee80211_beacon_get()
4859 } else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) { in __ieee80211_beacon_get()
4860 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; in __ieee80211_beacon_get()
4863 beacon = rcu_dereference(ifibss->presp); in __ieee80211_beacon_get()
4865 goto out; in __ieee80211_beacon_get()
4867 if (beacon->cntdwn_counter_offsets[0]) { in __ieee80211_beacon_get()
4874 skb = dev_alloc_skb(local->tx_headroom + beacon->head_len + in __ieee80211_beacon_get()
4875 local->hw.extra_beacon_tailroom); in __ieee80211_beacon_get()
4877 goto out; in __ieee80211_beacon_get()
4878 skb_reserve(skb, local->tx_headroom); in __ieee80211_beacon_get()
4879 skb_put_data(skb, beacon->head, beacon->head_len); in __ieee80211_beacon_get()
4881 hdr = (struct ieee80211_hdr *) skb->data; in __ieee80211_beacon_get()
4882 hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | in __ieee80211_beacon_get()
4884 } else if (ieee80211_vif_is_mesh(&sdata->vif)) { in __ieee80211_beacon_get()
4885 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; in __ieee80211_beacon_get()
4887 beacon = rcu_dereference(ifmsh->beacon); in __ieee80211_beacon_get()
4889 goto out; in __ieee80211_beacon_get()
4891 if (beacon->cntdwn_counter_offsets[0]) { in __ieee80211_beacon_get()
4903 if (ifmsh->sync_ops) in __ieee80211_beacon_get()
4904 ifmsh->sync_ops->adjust_tsf(sdata, beacon); in __ieee80211_beacon_get()
4906 skb = dev_alloc_skb(local->tx_headroom + in __ieee80211_beacon_get()
4907 beacon->head_len + in __ieee80211_beacon_get()
4909 beacon->tail_len + in __ieee80211_beacon_get()
4910 local->hw.extra_beacon_tailroom); in __ieee80211_beacon_get()
4912 goto out; in __ieee80211_beacon_get()
4913 skb_reserve(skb, local->tx_headroom); in __ieee80211_beacon_get()
4914 skb_put_data(skb, beacon->head, beacon->head_len); in __ieee80211_beacon_get()
4915 ieee80211_beacon_add_tim(sdata, &ifmsh->ps, skb, is_template); in __ieee80211_beacon_get()
4918 offs->tim_offset = beacon->head_len; in __ieee80211_beacon_get()
4919 offs->tim_length = skb->len - beacon->head_len; in __ieee80211_beacon_get()
4922 skb_put_data(skb, beacon->tail, beacon->tail_len); in __ieee80211_beacon_get()
4925 goto out; in __ieee80211_beacon_get()
4933 u16 csa_off = beacon->cntdwn_counter_offsets[i]; in __ieee80211_beacon_get()
4938 offs->cntdwn_counter_offs[i] = csa_off_base + csa_off; in __ieee80211_beacon_get()
4942 band = chanctx_conf->def.chan->band; in __ieee80211_beacon_get()
4946 info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; in __ieee80211_beacon_get()
4947 info->flags |= IEEE80211_TX_CTL_NO_ACK; in __ieee80211_beacon_get()
4948 info->band = band; in __ieee80211_beacon_get()
4952 txrc.sband = local->hw.wiphy->bands[band]; in __ieee80211_beacon_get()
4953 txrc.bss_conf = &sdata->vif.bss_conf; in __ieee80211_beacon_get()
4955 txrc.reported_rate.idx = -1; in __ieee80211_beacon_get()
4956 if (sdata->beacon_rate_set && sdata->beacon_rateidx_mask[band]) in __ieee80211_beacon_get()
4957 txrc.rate_idx_mask = sdata->beacon_rateidx_mask[band]; in __ieee80211_beacon_get()
4959 txrc.rate_idx_mask = sdata->rc_rateidx_mask[band]; in __ieee80211_beacon_get()
4963 info->control.vif = vif; in __ieee80211_beacon_get()
4965 info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT | in __ieee80211_beacon_get()
4968 out: in __ieee80211_beacon_get()
5003 !hw_to_local(hw)->monitors) in ieee80211_beacon_get_tim()
5032 if (sdata->vif.type != NL80211_IFTYPE_AP) in ieee80211_proberesp_get()
5037 ap = &sdata->u.ap; in ieee80211_proberesp_get()
5038 presp = rcu_dereference(ap->probe_resp); in ieee80211_proberesp_get()
5040 goto out; in ieee80211_proberesp_get()
5042 skb = dev_alloc_skb(presp->len); in ieee80211_proberesp_get()
5044 goto out; in ieee80211_proberesp_get()
5046 skb_put_data(skb, presp->data, presp->len); in ieee80211_proberesp_get()
5048 hdr = (struct ieee80211_hdr *) skb->data; in ieee80211_proberesp_get()
5049 memset(hdr->addr1, 0, sizeof(hdr->addr1)); in ieee80211_proberesp_get()
5051 out: in ieee80211_proberesp_get()
5064 if (sdata->vif.type != NL80211_IFTYPE_AP) in ieee80211_get_fils_discovery_tmpl()
5068 tmpl = rcu_dereference(sdata->u.ap.fils_discovery); in ieee80211_get_fils_discovery_tmpl()
5074 skb = dev_alloc_skb(sdata->local->hw.extra_tx_headroom + tmpl->len); in ieee80211_get_fils_discovery_tmpl()
5076 skb_reserve(skb, sdata->local->hw.extra_tx_headroom); in ieee80211_get_fils_discovery_tmpl()
5077 skb_put_data(skb, tmpl->data, tmpl->len); in ieee80211_get_fils_discovery_tmpl()
5093 if (sdata->vif.type != NL80211_IFTYPE_AP) in ieee80211_get_unsol_bcast_probe_resp_tmpl()
5097 tmpl = rcu_dereference(sdata->u.ap.unsol_bcast_probe_resp); in ieee80211_get_unsol_bcast_probe_resp_tmpl()
5103 skb = dev_alloc_skb(sdata->local->hw.extra_tx_headroom + tmpl->len); in ieee80211_get_unsol_bcast_probe_resp_tmpl()
5105 skb_reserve(skb, sdata->local->hw.extra_tx_headroom); in ieee80211_get_unsol_bcast_probe_resp_tmpl()
5106 skb_put_data(skb, tmpl->data, tmpl->len); in ieee80211_get_unsol_bcast_probe_resp_tmpl()
5123 if (WARN_ON(vif->type != NL80211_IFTYPE_STATION)) in ieee80211_pspoll_get()
5127 ifmgd = &sdata->u.mgd; in ieee80211_pspoll_get()
5128 local = sdata->local; in ieee80211_pspoll_get()
5130 skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*pspoll)); in ieee80211_pspoll_get()
5134 skb_reserve(skb, local->hw.extra_tx_headroom); in ieee80211_pspoll_get()
5137 pspoll->frame_control = cpu_to_le16(IEEE80211_FTYPE_CTL | in ieee80211_pspoll_get()
5139 pspoll->aid = cpu_to_le16(sdata->vif.bss_conf.aid); in ieee80211_pspoll_get()
5141 /* aid in PS-Poll has its two MSBs each set to 1 */ in ieee80211_pspoll_get()
5142 pspoll->aid |= cpu_to_le16(1 << 15 | 1 << 14); in ieee80211_pspoll_get()
5144 memcpy(pspoll->bssid, ifmgd->bssid, ETH_ALEN); in ieee80211_pspoll_get()
5145 memcpy(pspoll->ta, vif->addr, ETH_ALEN); in ieee80211_pspoll_get()
5162 if (WARN_ON(vif->type != NL80211_IFTYPE_STATION)) in ieee80211_nullfunc_get()
5166 ifmgd = &sdata->u.mgd; in ieee80211_nullfunc_get()
5167 local = sdata->local; in ieee80211_nullfunc_get()
5173 sta = sta_info_get(sdata, ifmgd->bssid); in ieee80211_nullfunc_get()
5174 qos = sta && sta->sta.wme; in ieee80211_nullfunc_get()
5178 skb = dev_alloc_skb(local->hw.extra_tx_headroom + in ieee80211_nullfunc_get()
5183 skb_reserve(skb, local->hw.extra_tx_headroom); in ieee80211_nullfunc_get()
5186 nullfunc->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA | in ieee80211_nullfunc_get()
5195 nullfunc->frame_control |= in ieee80211_nullfunc_get()
5197 skb->priority = 7; in ieee80211_nullfunc_get()
5202 memcpy(nullfunc->addr1, ifmgd->bssid, ETH_ALEN); in ieee80211_nullfunc_get()
5203 memcpy(nullfunc->addr2, vif->addr, ETH_ALEN); in ieee80211_nullfunc_get()
5204 memcpy(nullfunc->addr3, ifmgd->bssid, ETH_ALEN); in ieee80211_nullfunc_get()
5223 skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*hdr) + in ieee80211_probereq_get()
5228 skb_reserve(skb, local->hw.extra_tx_headroom); in ieee80211_probereq_get()
5231 hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | in ieee80211_probereq_get()
5233 eth_broadcast_addr(hdr->addr1); in ieee80211_probereq_get()
5234 memcpy(hdr->addr2, src_addr, ETH_ALEN); in ieee80211_probereq_get()
5235 eth_broadcast_addr(hdr->addr3); in ieee80211_probereq_get()
5255 rts->frame_control = in ieee80211_rts_get()
5257 rts->duration = ieee80211_rts_duration(hw, vif, frame_len, in ieee80211_rts_get()
5259 memcpy(rts->ra, hdr->addr1, sizeof(rts->ra)); in ieee80211_rts_get()
5260 memcpy(rts->ta, hdr->addr2, sizeof(rts->ta)); in ieee80211_rts_get()
5271 cts->frame_control = in ieee80211_ctstoself_get()
5273 cts->duration = ieee80211_ctstoself_duration(hw, vif, in ieee80211_ctstoself_get()
5275 memcpy(cts->ra, hdr->addr1, sizeof(cts->ra)); in ieee80211_ctstoself_get()
5294 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); in ieee80211_get_buffered_bc()
5297 goto out; in ieee80211_get_buffered_bc()
5299 if (sdata->vif.type == NL80211_IFTYPE_AP) { in ieee80211_get_buffered_bc()
5301 rcu_dereference(sdata->u.ap.beacon); in ieee80211_get_buffered_bc()
5303 if (!beacon || !beacon->head) in ieee80211_get_buffered_bc()
5304 goto out; in ieee80211_get_buffered_bc()
5306 ps = &sdata->u.ap.ps; in ieee80211_get_buffered_bc()
5307 } else if (ieee80211_vif_is_mesh(&sdata->vif)) { in ieee80211_get_buffered_bc()
5308 ps = &sdata->u.mesh.ps; in ieee80211_get_buffered_bc()
5310 goto out; in ieee80211_get_buffered_bc()
5313 if (ps->dtim_count != 0 || !ps->dtim_bc_mc) in ieee80211_get_buffered_bc()
5314 goto out; /* send buffered bc/mc only after DTIM beacon */ in ieee80211_get_buffered_bc()
5317 skb = skb_dequeue(&ps->bc_buf); in ieee80211_get_buffered_bc()
5319 goto out; in ieee80211_get_buffered_bc()
5320 local->total_ps_buffered--; in ieee80211_get_buffered_bc()
5322 if (!skb_queue_empty(&ps->bc_buf) && skb->len >= 2) { in ieee80211_get_buffered_bc()
5324 (struct ieee80211_hdr *) skb->data; in ieee80211_get_buffered_bc()
5328 hdr->frame_control |= in ieee80211_get_buffered_bc()
5332 if (sdata->vif.type == NL80211_IFTYPE_AP) in ieee80211_get_buffered_bc()
5333 sdata = IEEE80211_DEV_TO_SUB_IF(skb->dev); in ieee80211_get_buffered_bc()
5342 info->band = chanctx_conf->def.chan->band; in ieee80211_get_buffered_bc()
5346 out: in ieee80211_get_buffered_bc()
5356 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_reserve_tid()
5357 struct ieee80211_local *local = sdata->local; in ieee80211_reserve_tid()
5361 lockdep_assert_held(&local->sta_mtx); in ieee80211_reserve_tid()
5364 switch (sdata->vif.type) { in ieee80211_reserve_tid()
5371 return -EINVAL; in ieee80211_reserve_tid()
5375 return -EINVAL; in ieee80211_reserve_tid()
5377 if (sta->reserved_tid == tid) { in ieee80211_reserve_tid()
5379 goto out; in ieee80211_reserve_tid()
5382 if (sta->reserved_tid != IEEE80211_TID_UNRESERVED) { in ieee80211_reserve_tid()
5384 ret = -EALREADY; in ieee80211_reserve_tid()
5385 goto out; in ieee80211_reserve_tid()
5388 ieee80211_stop_vif_queues(sdata->local, sdata, in ieee80211_reserve_tid()
5394 if (ieee80211_hw_check(&local->hw, AMPDU_AGGREGATION)) { in ieee80211_reserve_tid()
5400 queues = BIT(sdata->vif.hw_queue[ieee802_1d_to_ac[tid]]); in ieee80211_reserve_tid()
5403 sta->reserved_tid = tid; in ieee80211_reserve_tid()
5408 if (ieee80211_hw_check(&local->hw, AMPDU_AGGREGATION)) in ieee80211_reserve_tid()
5412 out: in ieee80211_reserve_tid()
5420 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_unreserve_tid()
5422 lockdep_assert_held(&sdata->local->sta_mtx); in ieee80211_unreserve_tid()
5425 switch (sdata->vif.type) { in ieee80211_unreserve_tid()
5435 if (tid != sta->reserved_tid) { in ieee80211_unreserve_tid()
5440 sta->reserved_tid = IEEE80211_TID_UNRESERVED; in ieee80211_unreserve_tid()
5446 enum nl80211_band band) in __ieee80211_tx_skb_tid_band() argument
5452 skb->priority = tid; in __ieee80211_tx_skb_tid_band()
5454 skb->dev = sdata->dev; in __ieee80211_tx_skb_tid_band()
5462 IEEE80211_SKB_CB(skb)->band = band; in __ieee80211_tx_skb_tid_band()
5473 struct ieee80211_local *local = sdata->local; in ieee80211_tx_control_port()
5480 * or Pre-Authentication in ieee80211_tx_control_port()
5482 if (proto != sdata->control_port_protocol && in ieee80211_tx_control_port()
5484 return -EINVAL; in ieee80211_tx_control_port()
5486 if (proto == sdata->control_port_protocol) in ieee80211_tx_control_port()
5499 skb = dev_alloc_skb(local->hw.extra_tx_headroom + in ieee80211_tx_control_port()
5502 return -ENOMEM; in ieee80211_tx_control_port()
5504 skb_reserve(skb, local->hw.extra_tx_headroom + sizeof(struct ethhdr)); in ieee80211_tx_control_port()
5509 memcpy(ehdr->h_dest, dest, ETH_ALEN); in ieee80211_tx_control_port()
5510 memcpy(ehdr->h_source, sdata->vif.addr, ETH_ALEN); in ieee80211_tx_control_port()
5511 ehdr->h_proto = proto; in ieee80211_tx_control_port()
5513 skb->dev = dev; in ieee80211_tx_control_port()
5514 skb->protocol = htons(ETH_P_802_3); in ieee80211_tx_control_port()
5519 mutex_lock(&local->mtx); in ieee80211_tx_control_port()
5522 __ieee80211_subif_start_xmit(skb, skb->dev, flags, ctrl_flags, cookie); in ieee80211_tx_control_port()
5525 mutex_unlock(&local->mtx); in ieee80211_tx_control_port()
5534 struct ieee80211_local *local = sdata->local; in ieee80211_probe_mesh_link()
5537 skb = dev_alloc_skb(local->hw.extra_tx_headroom + len + in ieee80211_probe_mesh_link()
5541 return -ENOMEM; in ieee80211_probe_mesh_link()
5543 skb_reserve(skb, local->hw.extra_tx_headroom); in ieee80211_probe_mesh_link()
5546 skb->dev = dev; in ieee80211_probe_mesh_link()
5547 skb->protocol = htons(ETH_P_802_3); in ieee80211_probe_mesh_link()
5552 __ieee80211_subif_start_xmit(skb, skb->dev, 0, in ieee80211_probe_mesh_link()