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
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()
87 * - during CFP: 32768 in ieee80211_duration()
88 * - during contention period: in ieee80211_duration()
96 * - control response frame (CTS or ACK) shall be transmitted using the in ieee80211_duration()
102 hdr = (struct ieee80211_hdr *)skb->data; in ieee80211_duration()
103 if (ieee80211_is_ctl(hdr->frame_control)) { in ieee80211_duration()
110 * CTS: duration of immediately previous RTS minus time in ieee80211_duration()
125 if (group_addr) /* Group address as the destination - no ACK */ in ieee80211_duration()
131 * basic rate set that is less than or equal to the rate of the in ieee80211_duration()
134 * the highest mandatory rate of the PHY that is less than or equal to in ieee80211_duration()
135 * the rate of the previous frame is used. in ieee80211_duration()
138 rate = -1; in ieee80211_duration()
140 mrate = sband->bitrates[0].bitrate; in ieee80211_duration()
141 for (i = 0; i < sband->n_bitrates; i++) { in ieee80211_duration()
142 struct ieee80211_rate *r = &sband->bitrates[i]; in ieee80211_duration()
144 if (r->bitrate > txrate->bitrate) in ieee80211_duration()
147 if ((rate_flags & r->flags) != rate_flags) in ieee80211_duration()
150 if (tx->sdata->vif.bss_conf.basic_rates & BIT(i)) in ieee80211_duration()
151 rate = DIV_ROUND_UP(r->bitrate, 1 << shift); in ieee80211_duration()
153 switch (sband->band) { in ieee80211_duration()
156 if (tx->sdata->flags & IEEE80211_SDATA_OPERATING_GMODE) in ieee80211_duration()
160 if (r->flags & flag) in ieee80211_duration()
161 mrate = r->bitrate; in ieee80211_duration()
166 if (r->flags & IEEE80211_RATE_MANDATORY_A) in ieee80211_duration()
167 mrate = r->bitrate; in ieee80211_duration()
176 if (rate == -1) { in ieee80211_duration()
183 if (ieee80211_is_data_qos(hdr->frame_control) && in ieee80211_duration()
188 * (10 bytes + 4-byte FCS = 112 bits) plus SIFS; rounded up in ieee80211_duration()
190 dur = ieee80211_frame_duration(sband->band, 10, rate, erp, in ieee80211_duration()
191 tx->sdata->vif.bss_conf.use_short_preamble, in ieee80211_duration()
199 dur += ieee80211_frame_duration(sband->band, next_frag_len, in ieee80211_duration()
200 txrate->bitrate, erp, in ieee80211_duration()
201 tx->sdata->vif.bss_conf.use_short_preamble, in ieee80211_duration()
212 struct ieee80211_local *local = tx->local; in ieee80211_tx_h_dynamic_ps()
214 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); in ieee80211_tx_h_dynamic_ps()
217 if (!ieee80211_hw_check(&local->hw, SUPPORTS_PS)) in ieee80211_tx_h_dynamic_ps()
221 if (ieee80211_hw_check(&local->hw, SUPPORTS_DYNAMIC_PS)) in ieee80211_tx_h_dynamic_ps()
225 if (local->hw.conf.dynamic_ps_timeout <= 0) in ieee80211_tx_h_dynamic_ps()
229 if (local->scanning) in ieee80211_tx_h_dynamic_ps()
232 if (!local->ps_sdata) in ieee80211_tx_h_dynamic_ps()
236 if (local->quiescing) in ieee80211_tx_h_dynamic_ps()
240 if (tx->sdata->vif.type != NL80211_IFTYPE_STATION) in ieee80211_tx_h_dynamic_ps()
243 if (unlikely(info->flags & IEEE80211_TX_INTFL_OFFCHAN_TX_OK)) in ieee80211_tx_h_dynamic_ps()
246 ifmgd = &tx->sdata->u.mgd; in ieee80211_tx_h_dynamic_ps()
249 * Don't wakeup from power save if u-apsd is enabled, voip ac has in ieee80211_tx_h_dynamic_ps()
250 * u-apsd enabled and the frame is in voip class. This effectively in ieee80211_tx_h_dynamic_ps()
251 * means that even if all access categories have u-apsd enabled, in in ieee80211_tx_h_dynamic_ps()
252 * practise u-apsd is only used with the voip ac. This is a in ieee80211_tx_h_dynamic_ps()
257 * Note: ifmgd->uapsd_queues access is racy here. If the value is in ieee80211_tx_h_dynamic_ps()
261 if ((ifmgd->flags & IEEE80211_STA_UAPSD_ENABLED) && in ieee80211_tx_h_dynamic_ps()
262 (ifmgd->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VO) && in ieee80211_tx_h_dynamic_ps()
263 skb_get_queue_mapping(tx->skb) == IEEE80211_AC_VO) in ieee80211_tx_h_dynamic_ps()
266 if (local->hw.conf.flags & IEEE80211_CONF_PS) { in ieee80211_tx_h_dynamic_ps()
267 ieee80211_stop_queues_by_reason(&local->hw, in ieee80211_tx_h_dynamic_ps()
271 ifmgd->flags &= ~IEEE80211_STA_NULLFUNC_ACKED; in ieee80211_tx_h_dynamic_ps()
272 ieee80211_queue_work(&local->hw, in ieee80211_tx_h_dynamic_ps()
273 &local->dynamic_ps_disable_work); in ieee80211_tx_h_dynamic_ps()
277 if (!ifmgd->associated) in ieee80211_tx_h_dynamic_ps()
280 mod_timer(&local->dynamic_ps_timer, jiffies + in ieee80211_tx_h_dynamic_ps()
281 msecs_to_jiffies(local->hw.conf.dynamic_ps_timeout)); in ieee80211_tx_h_dynamic_ps()
290 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; in ieee80211_tx_h_check_assoc()
291 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); in ieee80211_tx_h_check_assoc()
294 if (unlikely(info->flags & IEEE80211_TX_CTL_INJECTED)) in ieee80211_tx_h_check_assoc()
297 if (unlikely(test_bit(SCAN_SW_SCANNING, &tx->local->scanning)) && in ieee80211_tx_h_check_assoc()
298 test_bit(SDATA_STATE_OFFCHANNEL, &tx->sdata->state) && in ieee80211_tx_h_check_assoc()
299 !ieee80211_is_probe_req(hdr->frame_control) && in ieee80211_tx_h_check_assoc()
300 !ieee80211_is_nullfunc(hdr->frame_control)) in ieee80211_tx_h_check_assoc()
307 * off-channel. See the link below and in ieee80211_tx_h_check_assoc()
314 if (tx->sdata->vif.type == NL80211_IFTYPE_OCB) in ieee80211_tx_h_check_assoc()
317 if (tx->sdata->vif.type == NL80211_IFTYPE_WDS) in ieee80211_tx_h_check_assoc()
320 if (tx->flags & IEEE80211_TX_PS_BUFFERED) in ieee80211_tx_h_check_assoc()
323 if (tx->sta) in ieee80211_tx_h_check_assoc()
324 assoc = test_sta_flag(tx->sta, WLAN_STA_ASSOC); in ieee80211_tx_h_check_assoc()
326 if (likely(tx->flags & IEEE80211_TX_UNICAST)) { in ieee80211_tx_h_check_assoc()
328 ieee80211_is_data(hdr->frame_control))) { in ieee80211_tx_h_check_assoc()
330 sdata_info(tx->sdata, in ieee80211_tx_h_check_assoc()
332 hdr->addr1); in ieee80211_tx_h_check_assoc()
334 I802_DEBUG_INC(tx->local->tx_handlers_drop_not_assoc); in ieee80211_tx_h_check_assoc()
337 } else if (unlikely(ieee80211_is_data(hdr->frame_control) && in ieee80211_tx_h_check_assoc()
338 ieee80211_vif_get_num_mcast_if(tx->sdata) == 0)) { in ieee80211_tx_h_check_assoc()
340 * No associated STAs - no need to send multicast in ieee80211_tx_h_check_assoc()
350 * of buffered frames for power saving STAs. This situation should not really
360 list_for_each_entry_rcu(sdata, &local->interfaces, list) { in purge_old_ps_buffers()
363 if (sdata->vif.type == NL80211_IFTYPE_AP) in purge_old_ps_buffers()
364 ps = &sdata->u.ap.ps; in purge_old_ps_buffers()
365 else if (ieee80211_vif_is_mesh(&sdata->vif)) in purge_old_ps_buffers()
366 ps = &sdata->u.mesh.ps; in purge_old_ps_buffers()
370 skb = skb_dequeue(&ps->bc_buf); in purge_old_ps_buffers()
373 ieee80211_free_txskb(&local->hw, skb); in purge_old_ps_buffers()
375 total += skb_queue_len(&ps->bc_buf); in purge_old_ps_buffers()
379 * Drop one frame from each station from the lowest-priority in purge_old_ps_buffers()
382 list_for_each_entry_rcu(sta, &local->sta_list, list) { in purge_old_ps_buffers()
385 for (ac = IEEE80211_AC_BK; ac >= IEEE80211_AC_VO; ac--) { in purge_old_ps_buffers()
386 skb = skb_dequeue(&sta->ps_tx_buf[ac]); in purge_old_ps_buffers()
387 total += skb_queue_len(&sta->ps_tx_buf[ac]); in purge_old_ps_buffers()
390 ieee80211_free_txskb(&local->hw, skb); in purge_old_ps_buffers()
396 local->total_ps_buffered = total; in purge_old_ps_buffers()
397 ps_dbg_hw(&local->hw, "PS buffers full - purged %d frames\n", purged); in purge_old_ps_buffers()
403 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); in ieee80211_tx_h_multicast_ps_buf()
404 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; in ieee80211_tx_h_multicast_ps_buf()
410 * If any of the associated/peer stations is in power save mode, in ieee80211_tx_h_multicast_ps_buf()
416 if (tx->sdata->vif.type == NL80211_IFTYPE_AP || in ieee80211_tx_h_multicast_ps_buf()
417 tx->sdata->vif.type == NL80211_IFTYPE_AP_VLAN) { in ieee80211_tx_h_multicast_ps_buf()
418 if (!tx->sdata->bss) in ieee80211_tx_h_multicast_ps_buf()
421 ps = &tx->sdata->bss->ps; in ieee80211_tx_h_multicast_ps_buf()
422 } else if (ieee80211_vif_is_mesh(&tx->sdata->vif)) { in ieee80211_tx_h_multicast_ps_buf()
423 ps = &tx->sdata->u.mesh.ps; in ieee80211_tx_h_multicast_ps_buf()
430 if (ieee80211_has_order(hdr->frame_control)) in ieee80211_tx_h_multicast_ps_buf()
433 if (ieee80211_is_probe_req(hdr->frame_control)) in ieee80211_tx_h_multicast_ps_buf()
436 if (ieee80211_hw_check(&tx->local->hw, QUEUE_CONTROL)) in ieee80211_tx_h_multicast_ps_buf()
437 info->hw_queue = tx->sdata->vif.cab_queue; in ieee80211_tx_h_multicast_ps_buf()
440 if (!atomic_read(&ps->num_sta_ps) && skb_queue_empty(&ps->bc_buf)) in ieee80211_tx_h_multicast_ps_buf()
443 info->flags |= IEEE80211_TX_CTL_SEND_AFTER_DTIM; in ieee80211_tx_h_multicast_ps_buf()
446 if (!ieee80211_hw_check(&tx->local->hw, HOST_BROADCAST_PS_BUFFERING)) in ieee80211_tx_h_multicast_ps_buf()
450 if (tx->local->total_ps_buffered >= TOTAL_MAX_TX_BUFFER) in ieee80211_tx_h_multicast_ps_buf()
451 purge_old_ps_buffers(tx->local); in ieee80211_tx_h_multicast_ps_buf()
453 if (skb_queue_len(&ps->bc_buf) >= AP_MAX_BC_BUFFER) { in ieee80211_tx_h_multicast_ps_buf()
454 ps_dbg(tx->sdata, in ieee80211_tx_h_multicast_ps_buf()
455 "BC TX buffer full - dropping the oldest frame\n"); in ieee80211_tx_h_multicast_ps_buf()
456 ieee80211_free_txskb(&tx->local->hw, skb_dequeue(&ps->bc_buf)); in ieee80211_tx_h_multicast_ps_buf()
458 tx->local->total_ps_buffered++; in ieee80211_tx_h_multicast_ps_buf()
460 skb_queue_tail(&ps->bc_buf, tx->skb); in ieee80211_tx_h_multicast_ps_buf()
483 struct sta_info *sta = tx->sta; in ieee80211_tx_h_unicast_ps_buf()
484 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); in ieee80211_tx_h_unicast_ps_buf()
485 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; in ieee80211_tx_h_unicast_ps_buf()
486 struct ieee80211_local *local = tx->local; in ieee80211_tx_h_unicast_ps_buf()
494 !(info->flags & IEEE80211_TX_CTL_NO_PS_BUFFER))) { in ieee80211_tx_h_unicast_ps_buf()
495 int ac = skb_get_queue_mapping(tx->skb); in ieee80211_tx_h_unicast_ps_buf()
497 if (ieee80211_is_mgmt(hdr->frame_control) && in ieee80211_tx_h_unicast_ps_buf()
498 !ieee80211_is_bufferable_mmpdu(hdr->frame_control)) { in ieee80211_tx_h_unicast_ps_buf()
499 info->flags |= IEEE80211_TX_CTL_NO_PS_BUFFER; in ieee80211_tx_h_unicast_ps_buf()
503 ps_dbg(sta->sdata, "STA %pM aid %d: PS buffer for AC %d\n", in ieee80211_tx_h_unicast_ps_buf()
504 sta->sta.addr, sta->sta.aid, ac); in ieee80211_tx_h_unicast_ps_buf()
505 if (tx->local->total_ps_buffered >= TOTAL_MAX_TX_BUFFER) in ieee80211_tx_h_unicast_ps_buf()
506 purge_old_ps_buffers(tx->local); in ieee80211_tx_h_unicast_ps_buf()
509 spin_lock(&sta->ps_lock); in ieee80211_tx_h_unicast_ps_buf()
518 spin_unlock(&sta->ps_lock); in ieee80211_tx_h_unicast_ps_buf()
522 if (skb_queue_len(&sta->ps_tx_buf[ac]) >= STA_MAX_TX_BUFFER) { in ieee80211_tx_h_unicast_ps_buf()
523 struct sk_buff *old = skb_dequeue(&sta->ps_tx_buf[ac]); in ieee80211_tx_h_unicast_ps_buf()
524 ps_dbg(tx->sdata, in ieee80211_tx_h_unicast_ps_buf()
525 "STA %pM TX buffer for AC %d full - dropping oldest frame\n", in ieee80211_tx_h_unicast_ps_buf()
526 sta->sta.addr, ac); in ieee80211_tx_h_unicast_ps_buf()
527 ieee80211_free_txskb(&local->hw, old); in ieee80211_tx_h_unicast_ps_buf()
529 tx->local->total_ps_buffered++; in ieee80211_tx_h_unicast_ps_buf()
531 info->control.jiffies = jiffies; in ieee80211_tx_h_unicast_ps_buf()
532 info->control.vif = &tx->sdata->vif; in ieee80211_tx_h_unicast_ps_buf()
533 info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING; in ieee80211_tx_h_unicast_ps_buf()
534 info->flags &= ~IEEE80211_TX_TEMPORARY_FLAGS; in ieee80211_tx_h_unicast_ps_buf()
535 skb_queue_tail(&sta->ps_tx_buf[ac], tx->skb); in ieee80211_tx_h_unicast_ps_buf()
536 spin_unlock(&sta->ps_lock); in ieee80211_tx_h_unicast_ps_buf()
538 if (!timer_pending(&local->sta_cleanup)) in ieee80211_tx_h_unicast_ps_buf()
539 mod_timer(&local->sta_cleanup, in ieee80211_tx_h_unicast_ps_buf()
551 ps_dbg(tx->sdata, in ieee80211_tx_h_unicast_ps_buf()
552 "STA %pM in PS mode, but polling/in SP -> send frame\n", in ieee80211_tx_h_unicast_ps_buf()
553 sta->sta.addr); in ieee80211_tx_h_unicast_ps_buf()
562 if (unlikely(tx->flags & IEEE80211_TX_PS_BUFFERED)) in ieee80211_tx_h_ps_buf()
565 if (tx->flags & IEEE80211_TX_UNICAST) in ieee80211_tx_h_ps_buf()
574 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); in ieee80211_tx_h_check_control_port_protocol()
576 if (unlikely(tx->sdata->control_port_protocol == tx->skb->protocol)) { in ieee80211_tx_h_check_control_port_protocol()
577 if (tx->sdata->control_port_no_encrypt) in ieee80211_tx_h_check_control_port_protocol()
578 info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; in ieee80211_tx_h_check_control_port_protocol()
579 info->control.flags |= IEEE80211_TX_CTRL_PORT_CTRL_PROTO; in ieee80211_tx_h_check_control_port_protocol()
580 info->flags |= IEEE80211_TX_CTL_USE_MINRATE; in ieee80211_tx_h_check_control_port_protocol()
590 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); in ieee80211_tx_h_select_key()
591 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; in ieee80211_tx_h_select_key()
593 if (unlikely(info->flags & IEEE80211_TX_INTFL_DONT_ENCRYPT)) in ieee80211_tx_h_select_key()
594 tx->key = NULL; in ieee80211_tx_h_select_key()
595 else if (tx->sta && in ieee80211_tx_h_select_key()
596 (key = rcu_dereference(tx->sta->ptk[tx->sta->ptk_idx]))) in ieee80211_tx_h_select_key()
597 tx->key = key; in ieee80211_tx_h_select_key()
598 else if (ieee80211_is_group_privacy_action(tx->skb) && in ieee80211_tx_h_select_key()
599 (key = rcu_dereference(tx->sdata->default_multicast_key))) in ieee80211_tx_h_select_key()
600 tx->key = key; in ieee80211_tx_h_select_key()
601 else if (ieee80211_is_mgmt(hdr->frame_control) && in ieee80211_tx_h_select_key()
602 is_multicast_ether_addr(hdr->addr1) && in ieee80211_tx_h_select_key()
603 ieee80211_is_robust_mgmt_frame(tx->skb) && in ieee80211_tx_h_select_key()
604 (key = rcu_dereference(tx->sdata->default_mgmt_key))) in ieee80211_tx_h_select_key()
605 tx->key = key; in ieee80211_tx_h_select_key()
606 else if (is_multicast_ether_addr(hdr->addr1) && 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 (!is_multicast_ether_addr(hdr->addr1) && in ieee80211_tx_h_select_key()
610 (key = rcu_dereference(tx->sdata->default_unicast_key))) in ieee80211_tx_h_select_key()
611 tx->key = key; in ieee80211_tx_h_select_key()
613 tx->key = NULL; in ieee80211_tx_h_select_key()
615 if (tx->key) { in ieee80211_tx_h_select_key()
620 switch (tx->key->conf.cipher) { in ieee80211_tx_h_select_key()
624 if (!ieee80211_is_data_present(hdr->frame_control)) in ieee80211_tx_h_select_key()
625 tx->key = NULL; in ieee80211_tx_h_select_key()
631 if (!ieee80211_is_data_present(hdr->frame_control) && in ieee80211_tx_h_select_key()
632 !ieee80211_use_mfp(hdr->frame_control, tx->sta, in ieee80211_tx_h_select_key()
633 tx->skb) && in ieee80211_tx_h_select_key()
634 !ieee80211_is_group_privacy_action(tx->skb)) in ieee80211_tx_h_select_key()
635 tx->key = NULL; in ieee80211_tx_h_select_key()
637 skip_hw = (tx->key->conf.flags & in ieee80211_tx_h_select_key()
639 ieee80211_is_mgmt(hdr->frame_control); in ieee80211_tx_h_select_key()
645 if (!ieee80211_is_mgmt(hdr->frame_control)) in ieee80211_tx_h_select_key()
646 tx->key = NULL; in ieee80211_tx_h_select_key()
650 if (unlikely(tx->key && tx->key->flags & KEY_FLAG_TAINTED && in ieee80211_tx_h_select_key()
651 !ieee80211_is_deauth(hdr->frame_control))) in ieee80211_tx_h_select_key()
654 if (!skip_hw && tx->key && in ieee80211_tx_h_select_key()
655 tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) in ieee80211_tx_h_select_key()
656 info->control.hw_key = &tx->key->conf; in ieee80211_tx_h_select_key()
665 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); in ieee80211_tx_h_rate_ctrl()
666 struct ieee80211_hdr *hdr = (void *)tx->skb->data; in ieee80211_tx_h_rate_ctrl()
675 sband = tx->local->hw.wiphy->bands[info->band]; in ieee80211_tx_h_rate_ctrl()
677 len = min_t(u32, tx->skb->len + FCS_LEN, in ieee80211_tx_h_rate_ctrl()
678 tx->local->hw.wiphy->frag_threshold); in ieee80211_tx_h_rate_ctrl()
681 txrc.hw = &tx->local->hw; in ieee80211_tx_h_rate_ctrl()
683 txrc.bss_conf = &tx->sdata->vif.bss_conf; in ieee80211_tx_h_rate_ctrl()
684 txrc.skb = tx->skb; in ieee80211_tx_h_rate_ctrl()
685 txrc.reported_rate.idx = -1; in ieee80211_tx_h_rate_ctrl()
686 txrc.rate_idx_mask = tx->sdata->rc_rateidx_mask[info->band]; in ieee80211_tx_h_rate_ctrl()
688 if (tx->sdata->rc_has_mcs_mask[info->band]) in ieee80211_tx_h_rate_ctrl()
690 tx->sdata->rc_rateidx_mcs_mask[info->band]; in ieee80211_tx_h_rate_ctrl()
692 txrc.bss = (tx->sdata->vif.type == NL80211_IFTYPE_AP || in ieee80211_tx_h_rate_ctrl()
693 tx->sdata->vif.type == NL80211_IFTYPE_MESH_POINT || in ieee80211_tx_h_rate_ctrl()
694 tx->sdata->vif.type == NL80211_IFTYPE_ADHOC || in ieee80211_tx_h_rate_ctrl()
695 tx->sdata->vif.type == NL80211_IFTYPE_OCB); in ieee80211_tx_h_rate_ctrl()
698 if (len > tx->local->hw.wiphy->rts_threshold) { in ieee80211_tx_h_rate_ctrl()
702 info->control.use_rts = txrc.rts; in ieee80211_tx_h_rate_ctrl()
703 info->control.use_cts_prot = tx->sdata->vif.bss_conf.use_cts_prot; in ieee80211_tx_h_rate_ctrl()
708 * that -- the management frame might be to a station that in ieee80211_tx_h_rate_ctrl()
711 if (tx->sdata->vif.bss_conf.use_short_preamble && in ieee80211_tx_h_rate_ctrl()
712 (ieee80211_is_data(hdr->frame_control) || in ieee80211_tx_h_rate_ctrl()
713 (tx->sta && test_sta_flag(tx->sta, WLAN_STA_SHORT_PREAMBLE)))) in ieee80211_tx_h_rate_ctrl()
716 info->control.short_preamble = txrc.short_preamble; in ieee80211_tx_h_rate_ctrl()
719 if (info->control.flags & IEEE80211_TX_CTRL_RATE_INJECT) in ieee80211_tx_h_rate_ctrl()
722 if (tx->sta) in ieee80211_tx_h_rate_ctrl()
723 assoc = test_sta_flag(tx->sta, WLAN_STA_ASSOC); in ieee80211_tx_h_rate_ctrl()
729 if (WARN(test_bit(SCAN_SW_SCANNING, &tx->local->scanning) && assoc && in ieee80211_tx_h_rate_ctrl()
730 !rate_usable_index_exists(sband, &tx->sta->sta), in ieee80211_tx_h_rate_ctrl()
733 "%pM on %d GHz band\n", in ieee80211_tx_h_rate_ctrl()
734 tx->sdata->name, hdr->addr1, in ieee80211_tx_h_rate_ctrl()
735 info->band ? 5 : 2)) in ieee80211_tx_h_rate_ctrl()
742 rate_control_get_rate(tx->sdata, tx->sta, &txrc); in ieee80211_tx_h_rate_ctrl()
744 if (tx->sta && !info->control.skip_table) in ieee80211_tx_h_rate_ctrl()
745 ratetbl = rcu_dereference(tx->sta->sta.rates); in ieee80211_tx_h_rate_ctrl()
747 if (unlikely(info->control.rates[0].idx < 0)) { in ieee80211_tx_h_rate_ctrl()
750 .idx = ratetbl->rate[0].idx, in ieee80211_tx_h_rate_ctrl()
751 .flags = ratetbl->rate[0].flags, in ieee80211_tx_h_rate_ctrl()
752 .count = ratetbl->rate[0].count in ieee80211_tx_h_rate_ctrl()
755 if (ratetbl->rate[0].idx < 0) in ieee80211_tx_h_rate_ctrl()
758 tx->rate = rate; in ieee80211_tx_h_rate_ctrl()
763 tx->rate = info->control.rates[0]; in ieee80211_tx_h_rate_ctrl()
767 txrc.reported_rate = tx->rate; in ieee80211_tx_h_rate_ctrl()
768 if (tx->sta && ieee80211_is_data(hdr->frame_control)) in ieee80211_tx_h_rate_ctrl()
769 tx->sta->tx_stats.last_rate = txrc.reported_rate; in ieee80211_tx_h_rate_ctrl()
770 } else if (tx->sta) in ieee80211_tx_h_rate_ctrl()
771 tx->sta->tx_stats.last_rate = txrc.reported_rate; in ieee80211_tx_h_rate_ctrl()
776 if (unlikely(!info->control.rates[0].count)) in ieee80211_tx_h_rate_ctrl()
777 info->control.rates[0].count = 1; in ieee80211_tx_h_rate_ctrl()
779 if (WARN_ON_ONCE((info->control.rates[0].count > 1) && in ieee80211_tx_h_rate_ctrl()
780 (info->flags & IEEE80211_TX_CTL_NO_ACK))) in ieee80211_tx_h_rate_ctrl()
781 info->control.rates[0].count = 1; in ieee80211_tx_h_rate_ctrl()
788 u16 *seq = &sta->tid_seq[tid]; in ieee80211_tx_next_seq()
800 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); in ieee80211_tx_h_sequence()
801 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; in ieee80211_tx_h_sequence()
809 if (unlikely(info->control.vif->type == NL80211_IFTYPE_MONITOR)) in ieee80211_tx_h_sequence()
812 if (unlikely(ieee80211_is_ctl(hdr->frame_control))) in ieee80211_tx_h_sequence()
815 if (ieee80211_hdrlen(hdr->frame_control) < 24) in ieee80211_tx_h_sequence()
818 if (ieee80211_is_qos_nullfunc(hdr->frame_control)) in ieee80211_tx_h_sequence()
825 * also use the global counter (802.11-2012 9.3.2.10). in ieee80211_tx_h_sequence()
827 if (!ieee80211_is_data_qos(hdr->frame_control) || in ieee80211_tx_h_sequence()
828 is_multicast_ether_addr(hdr->addr1)) { in ieee80211_tx_h_sequence()
829 if (tx->flags & IEEE80211_TX_NO_SEQNO) in ieee80211_tx_h_sequence()
832 info->flags |= IEEE80211_TX_CTL_ASSIGN_SEQ; in ieee80211_tx_h_sequence()
834 hdr->seq_ctrl = cpu_to_le16(tx->sdata->sequence_number); in ieee80211_tx_h_sequence()
835 tx->sdata->sequence_number += 0x10; in ieee80211_tx_h_sequence()
836 if (tx->sta) in ieee80211_tx_h_sequence()
837 tx->sta->tx_stats.msdu[IEEE80211_NUM_TIDS]++; in ieee80211_tx_h_sequence()
844 * above since they are not QoS-data frames. in ieee80211_tx_h_sequence()
846 if (!tx->sta) in ieee80211_tx_h_sequence()
849 /* include per-STA, per-TID sequence counter */ in ieee80211_tx_h_sequence()
851 tx->sta->tx_stats.msdu[tid]++; in ieee80211_tx_h_sequence()
853 hdr->seq_ctrl = ieee80211_tx_next_seq(tx->sta, tid); in ieee80211_tx_h_sequence()
862 struct ieee80211_local *local = tx->local; in ieee80211_fragment()
865 int per_fragm = frag_threshold - hdrlen - FCS_LEN; in ieee80211_fragment()
867 int rem = skb->len - hdrlen - per_fragm; in ieee80211_fragment()
870 return -EINVAL; in ieee80211_fragment()
879 rem -= fraglen; in ieee80211_fragment()
880 tmp = dev_alloc_skb(local->tx_headroom + in ieee80211_fragment()
882 tx->sdata->encrypt_headroom + in ieee80211_fragment()
885 return -ENOMEM; in ieee80211_fragment()
887 __skb_queue_tail(&tx->skbs, tmp); in ieee80211_fragment()
890 local->tx_headroom + tx->sdata->encrypt_headroom); in ieee80211_fragment()
893 memcpy(tmp->cb, skb->cb, sizeof(tmp->cb)); in ieee80211_fragment()
896 info->flags &= ~(IEEE80211_TX_CTL_CLEAR_PS_FILT | in ieee80211_fragment()
900 info->flags |= IEEE80211_TX_CTL_MORE_FRAMES; in ieee80211_fragment()
903 tmp->priority = skb->priority; in ieee80211_fragment()
904 tmp->dev = skb->dev; in ieee80211_fragment()
907 skb_put_data(tmp, skb->data, hdrlen); in ieee80211_fragment()
908 skb_put_data(tmp, skb->data + pos, fraglen); in ieee80211_fragment()
921 struct sk_buff *skb = tx->skb; in ieee80211_tx_h_fragment()
923 struct ieee80211_hdr *hdr = (void *)skb->data; in ieee80211_tx_h_fragment()
924 int frag_threshold = tx->local->hw.wiphy->frag_threshold; in ieee80211_tx_h_fragment()
928 /* no matter what happens, tx->skb moves to tx->skbs */ in ieee80211_tx_h_fragment()
929 __skb_queue_tail(&tx->skbs, skb); in ieee80211_tx_h_fragment()
930 tx->skb = NULL; in ieee80211_tx_h_fragment()
932 if (info->flags & IEEE80211_TX_CTL_DONTFRAG) in ieee80211_tx_h_fragment()
935 if (ieee80211_hw_check(&tx->local->hw, SUPPORTS_TX_FRAG)) in ieee80211_tx_h_fragment()
939 * Warn when submitting a fragmented A-MPDU frame and drop it. in ieee80211_tx_h_fragment()
943 if (WARN_ON(info->flags & IEEE80211_TX_CTL_AMPDU)) in ieee80211_tx_h_fragment()
946 hdrlen = ieee80211_hdrlen(hdr->frame_control); in ieee80211_tx_h_fragment()
949 if (WARN_ON(skb->len + FCS_LEN <= frag_threshold)) in ieee80211_tx_h_fragment()
954 * chain them (using skb as the first fragment) to skb->next. in ieee80211_tx_h_fragment()
956 * fragments from this list. When the low-level driver rejects one in ieee80211_tx_h_fragment()
957 * of the fragments then we will simply pretend to accept the skb in ieee80211_tx_h_fragment()
963 /* update duration/seq/flags of fragments */ in ieee80211_tx_h_fragment()
966 skb_queue_walk(&tx->skbs, skb) { in ieee80211_tx_h_fragment()
969 hdr = (void *)skb->data; in ieee80211_tx_h_fragment()
972 if (!skb_queue_is_last(&tx->skbs, skb)) { in ieee80211_tx_h_fragment()
973 hdr->frame_control |= morefrags; in ieee80211_tx_h_fragment()
975 * No multi-rate retries for fragmented frames, that in ieee80211_tx_h_fragment()
978 info->control.rates[1].idx = -1; in ieee80211_tx_h_fragment()
979 info->control.rates[2].idx = -1; in ieee80211_tx_h_fragment()
980 info->control.rates[3].idx = -1; in ieee80211_tx_h_fragment()
982 info->flags &= ~IEEE80211_TX_CTL_RATE_CTRL_PROBE; in ieee80211_tx_h_fragment()
984 hdr->frame_control &= ~morefrags; in ieee80211_tx_h_fragment()
986 hdr->seq_ctrl |= cpu_to_le16(fragnum & IEEE80211_SCTL_FRAG); in ieee80211_tx_h_fragment()
997 int ac = -1; in ieee80211_tx_h_stats()
999 if (!tx->sta) in ieee80211_tx_h_stats()
1002 skb_queue_walk(&tx->skbs, skb) { in ieee80211_tx_h_stats()
1004 tx->sta->tx_stats.bytes[ac] += skb->len; in ieee80211_tx_h_stats()
1007 tx->sta->tx_stats.packets[ac]++; in ieee80211_tx_h_stats()
1015 if (!tx->key) in ieee80211_tx_h_encrypt()
1018 switch (tx->key->conf.cipher) { in ieee80211_tx_h_encrypt()
1055 skb_queue_walk(&tx->skbs, skb) { in ieee80211_tx_h_calculate_duration()
1056 hdr = (void *) skb->data; in ieee80211_tx_h_calculate_duration()
1057 if (unlikely(ieee80211_is_pspoll(hdr->frame_control))) in ieee80211_tx_h_calculate_duration()
1059 if (!skb_queue_is_last(&tx->skbs, skb)) { in ieee80211_tx_h_calculate_duration()
1060 struct sk_buff *next = skb_queue_next(&tx->skbs, skb); in ieee80211_tx_h_calculate_duration()
1061 next_len = next->len; in ieee80211_tx_h_calculate_duration()
1064 group_addr = is_multicast_ether_addr(hdr->addr1); in ieee80211_tx_h_calculate_duration()
1066 hdr->duration_id = in ieee80211_tx_h_calculate_duration()
1085 if (test_bit(HT_AGG_STATE_OPERATIONAL, &tid_tx->state)) { in ieee80211_tx_prep_agg()
1086 info->flags |= IEEE80211_TX_CTL_AMPDU; in ieee80211_tx_prep_agg()
1088 } else if (test_bit(HT_AGG_STATE_WANT_START, &tid_tx->state)) { in ieee80211_tx_prep_agg()
1090 * nothing -- this aggregation session is being started in ieee80211_tx_prep_agg()
1093 } else if (!tx->sta->sta.txq[tid]) { in ieee80211_tx_prep_agg()
1094 spin_lock(&tx->sta->lock); in ieee80211_tx_prep_agg()
1096 * Need to re-check now, because we may get here in ieee80211_tx_prep_agg()
1101 * queue yet -- if this happened we acquire the lock in ieee80211_tx_prep_agg()
1103 * need to recheck which of these cases happened. in ieee80211_tx_prep_agg()
1108 * before it was assigned) -- in this case it may in ieee80211_tx_prep_agg()
1113 tid_tx = rcu_dereference_protected_tid_tx(tx->sta, tid); in ieee80211_tx_prep_agg()
1117 } else if (test_bit(HT_AGG_STATE_OPERATIONAL, &tid_tx->state)) { in ieee80211_tx_prep_agg()
1118 info->flags |= IEEE80211_TX_CTL_AMPDU; in ieee80211_tx_prep_agg()
1122 if (info->flags & IEEE80211_TX_CTL_NO_PS_BUFFER) { in ieee80211_tx_prep_agg()
1123 clear_sta_flag(tx->sta, WLAN_STA_SP); in ieee80211_tx_prep_agg()
1124 ps_dbg(tx->sta->sdata, in ieee80211_tx_prep_agg()
1126 tx->sta->sta.addr, tx->sta->sta.aid); in ieee80211_tx_prep_agg()
1128 info->control.vif = &tx->sdata->vif; in ieee80211_tx_prep_agg()
1129 info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING; in ieee80211_tx_prep_agg()
1130 info->flags &= ~IEEE80211_TX_TEMPORARY_FLAGS; in ieee80211_tx_prep_agg()
1131 __skb_queue_tail(&tid_tx->pending, skb); in ieee80211_tx_prep_agg()
1132 if (skb_queue_len(&tid_tx->pending) > STA_MAX_TX_BUFFER) in ieee80211_tx_prep_agg()
1133 purge_skb = __skb_dequeue(&tid_tx->pending); in ieee80211_tx_prep_agg()
1135 spin_unlock(&tx->sta->lock); in ieee80211_tx_prep_agg()
1138 ieee80211_free_txskb(&tx->local->hw, purge_skb); in ieee80211_tx_prep_agg()
1143 tid_tx->last_tx = jiffies; in ieee80211_tx_prep_agg()
1158 struct ieee80211_local *local = sdata->local; in ieee80211_tx_prepare()
1164 tx->skb = skb; in ieee80211_tx_prepare()
1165 tx->local = local; in ieee80211_tx_prepare()
1166 tx->sdata = sdata; in ieee80211_tx_prepare()
1167 __skb_queue_head_init(&tx->skbs); in ieee80211_tx_prepare()
1174 info->flags &= ~IEEE80211_TX_INTFL_NEED_TXPROCESSING; in ieee80211_tx_prepare()
1176 hdr = (struct ieee80211_hdr *) skb->data; in ieee80211_tx_prepare()
1180 tx->sta = sta; in ieee80211_tx_prepare()
1182 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) { in ieee80211_tx_prepare()
1183 tx->sta = rcu_dereference(sdata->u.vlan.sta); in ieee80211_tx_prepare()
1184 if (!tx->sta && sdata->wdev.use_4addr) in ieee80211_tx_prepare()
1186 } else if (info->flags & (IEEE80211_TX_INTFL_NL80211_FRAME_TX | in ieee80211_tx_prepare()
1188 tx->sdata->control_port_protocol == tx->skb->protocol) { in ieee80211_tx_prepare()
1189 tx->sta = sta_info_get_bss(sdata, hdr->addr1); in ieee80211_tx_prepare()
1191 if (!tx->sta && !is_multicast_ether_addr(hdr->addr1)) in ieee80211_tx_prepare()
1192 tx->sta = sta_info_get(sdata, hdr->addr1); in ieee80211_tx_prepare()
1195 if (tx->sta && ieee80211_is_data_qos(hdr->frame_control) && in ieee80211_tx_prepare()
1196 !ieee80211_is_qos_nullfunc(hdr->frame_control) && in ieee80211_tx_prepare()
1197 ieee80211_hw_check(&local->hw, AMPDU_AGGREGATION) && in ieee80211_tx_prepare()
1198 !ieee80211_hw_check(&local->hw, TX_AMPDU_SETUP_IN_HW)) { in ieee80211_tx_prepare()
1203 tid_tx = rcu_dereference(tx->sta->ampdu_mlme.tid_tx[tid]); in ieee80211_tx_prepare()
1215 if (is_multicast_ether_addr(hdr->addr1)) { in ieee80211_tx_prepare()
1216 tx->flags &= ~IEEE80211_TX_UNICAST; in ieee80211_tx_prepare()
1217 info->flags |= IEEE80211_TX_CTL_NO_ACK; in ieee80211_tx_prepare()
1219 tx->flags |= IEEE80211_TX_UNICAST; in ieee80211_tx_prepare()
1221 if (!(info->flags & IEEE80211_TX_CTL_DONTFRAG)) { in ieee80211_tx_prepare()
1222 if (!(tx->flags & IEEE80211_TX_UNICAST) || in ieee80211_tx_prepare()
1223 skb->len + FCS_LEN <= local->hw.wiphy->frag_threshold || in ieee80211_tx_prepare()
1224 info->flags & IEEE80211_TX_CTL_AMPDU) in ieee80211_tx_prepare()
1225 info->flags |= IEEE80211_TX_CTL_DONTFRAG; in ieee80211_tx_prepare()
1228 if (!tx->sta) in ieee80211_tx_prepare()
1229 info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT; in ieee80211_tx_prepare()
1230 else if (test_and_clear_sta_flag(tx->sta, WLAN_STA_CLEAR_PS_FILT)) { in ieee80211_tx_prepare()
1231 info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT; in ieee80211_tx_prepare()
1232 ieee80211_check_fast_xmit(tx->sta); in ieee80211_tx_prepare()
1235 info->flags |= IEEE80211_TX_CTL_FIRST_FRAGMENT; in ieee80211_tx_prepare()
1245 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; in ieee80211_get_txq()
1249 if ((info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM) || in ieee80211_get_txq()
1250 (info->control.flags & IEEE80211_TX_CTRL_PS_RESPONSE)) in ieee80211_get_txq()
1253 if (unlikely(!ieee80211_is_data_present(hdr->frame_control))) { in ieee80211_get_txq()
1254 if ((!ieee80211_is_mgmt(hdr->frame_control) || in ieee80211_get_txq()
1255 ieee80211_is_bufferable_mmpdu(hdr->frame_control) || in ieee80211_get_txq()
1256 vif->type == NL80211_IFTYPE_STATION) && in ieee80211_get_txq()
1257 sta && sta->uploaded) { in ieee80211_get_txq()
1260 * opt-in hardware flag. in ieee80211_get_txq()
1262 txq = sta->sta.txq[IEEE80211_NUM_TIDS]; in ieee80211_get_txq()
1265 u8 tid = skb->priority & IEEE80211_QOS_CTL_TID_MASK; in ieee80211_get_txq()
1267 if (!sta->uploaded) in ieee80211_get_txq()
1270 txq = sta->sta.txq[tid]; in ieee80211_get_txq()
1272 txq = vif->txq; in ieee80211_get_txq()
1283 IEEE80211_SKB_CB(skb)->control.enqueue_time = codel_get_time(); in ieee80211_set_skb_enqueue_time()
1288 return skb->len; in codel_skb_len_func()
1295 info = (const struct ieee80211_tx_info *)skb->cb; in codel_skb_time_func()
1296 return info->control.enqueue_time; in codel_skb_time_func()
1308 local = vif_to_sdata(txqi->txq.vif)->local; in codel_dequeue_func()
1309 fq = &local->fq; in codel_dequeue_func()
1311 if (cvars == &txqi->def_cvars) in codel_dequeue_func()
1312 flow = &txqi->def_flow; in codel_dequeue_func()
1314 flow = &fq->flows[cvars - local->cvars]; in codel_dequeue_func()
1327 local = vif_to_sdata(txqi->txq.vif)->local; in codel_drop_func()
1328 hw = &local->hw; in codel_drop_func()
1345 cstats = &txqi->cstats; in fq_tin_dequeue_func()
1347 if (txqi->txq.sta) { in fq_tin_dequeue_func()
1348 struct sta_info *sta = container_of(txqi->txq.sta, in fq_tin_dequeue_func()
1350 cparams = &sta->cparams; in fq_tin_dequeue_func()
1352 cparams = &local->cparams; in fq_tin_dequeue_func()
1355 if (flow == &txqi->def_flow) in fq_tin_dequeue_func()
1356 cvars = &txqi->def_cvars; in fq_tin_dequeue_func()
1358 cvars = &local->cvars[flow - fq->flows]; in fq_tin_dequeue_func()
1361 &flow->backlog, in fq_tin_dequeue_func()
1379 ieee80211_free_txskb(&local->hw, skb); in fq_skb_free_func()
1390 return &txqi->def_flow; in fq_flow_get_default_func()
1397 struct fq *fq = &local->fq; in ieee80211_txq_enqueue()
1398 struct fq_tin *tin = &txqi->tin; in ieee80211_txq_enqueue()
1403 spin_lock_bh(&fq->lock); in ieee80211_txq_enqueue()
1407 spin_unlock_bh(&fq->lock); in ieee80211_txq_enqueue()
1416 return info->control.vif == data; in fq_vlan_filter_func()
1422 struct fq *fq = &local->fq; in ieee80211_txq_remove_vlan()
1427 if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_AP_VLAN)) in ieee80211_txq_remove_vlan()
1430 ap = container_of(sdata->bss, struct ieee80211_sub_if_data, u.ap); in ieee80211_txq_remove_vlan()
1432 if (!ap->vif.txq) in ieee80211_txq_remove_vlan()
1435 txqi = to_txq_info(ap->vif.txq); in ieee80211_txq_remove_vlan()
1436 tin = &txqi->tin; in ieee80211_txq_remove_vlan()
1438 spin_lock_bh(&fq->lock); in ieee80211_txq_remove_vlan()
1439 fq_tin_filter(fq, tin, fq_vlan_filter_func, &sdata->vif, in ieee80211_txq_remove_vlan()
1441 spin_unlock_bh(&fq->lock); in ieee80211_txq_remove_vlan()
1448 fq_tin_init(&txqi->tin); in ieee80211_txq_init()
1449 fq_flow_init(&txqi->def_flow); in ieee80211_txq_init()
1450 codel_vars_init(&txqi->def_cvars); in ieee80211_txq_init()
1451 codel_stats_init(&txqi->cstats); in ieee80211_txq_init()
1452 __skb_queue_head_init(&txqi->frags); in ieee80211_txq_init()
1453 INIT_LIST_HEAD(&txqi->schedule_order); in ieee80211_txq_init()
1455 txqi->txq.vif = &sdata->vif; in ieee80211_txq_init()
1458 sdata->vif.txq = &txqi->txq; in ieee80211_txq_init()
1459 txqi->txq.tid = 0; in ieee80211_txq_init()
1460 txqi->txq.ac = IEEE80211_AC_BE; in ieee80211_txq_init()
1466 if (sdata->vif.type == NL80211_IFTYPE_STATION) { in ieee80211_txq_init()
1468 if (!ieee80211_hw_check(&sdata->local->hw, in ieee80211_txq_init()
1471 } else if (!ieee80211_hw_check(&sdata->local->hw, in ieee80211_txq_init()
1476 txqi->txq.ac = IEEE80211_AC_VO; in ieee80211_txq_init()
1478 txqi->txq.ac = ieee80211_ac_from_tid(tid); in ieee80211_txq_init()
1481 txqi->txq.sta = &sta->sta; in ieee80211_txq_init()
1482 txqi->txq.tid = tid; in ieee80211_txq_init()
1483 sta->sta.txq[tid] = &txqi->txq; in ieee80211_txq_init()
1489 struct fq *fq = &local->fq; in ieee80211_txq_purge()
1490 struct fq_tin *tin = &txqi->tin; in ieee80211_txq_purge()
1492 spin_lock_bh(&fq->lock); in ieee80211_txq_purge()
1494 ieee80211_purge_tx_queue(&local->hw, &txqi->frags); in ieee80211_txq_purge()
1495 spin_unlock_bh(&fq->lock); in ieee80211_txq_purge()
1497 spin_lock_bh(&local->active_txq_lock[txqi->txq.ac]); in ieee80211_txq_purge()
1498 list_del_init(&txqi->schedule_order); in ieee80211_txq_purge()
1499 spin_unlock_bh(&local->active_txq_lock[txqi->txq.ac]); in ieee80211_txq_purge()
1504 if (local->hw.wiphy->txq_limit) in ieee80211_txq_set_params()
1505 local->fq.limit = local->hw.wiphy->txq_limit; in ieee80211_txq_set_params()
1507 local->hw.wiphy->txq_limit = local->fq.limit; in ieee80211_txq_set_params()
1509 if (local->hw.wiphy->txq_memory_limit) in ieee80211_txq_set_params()
1510 local->fq.memory_limit = local->hw.wiphy->txq_memory_limit; in ieee80211_txq_set_params()
1512 local->hw.wiphy->txq_memory_limit = local->fq.memory_limit; in ieee80211_txq_set_params()
1514 if (local->hw.wiphy->txq_quantum) in ieee80211_txq_set_params()
1515 local->fq.quantum = local->hw.wiphy->txq_quantum; in ieee80211_txq_set_params()
1517 local->hw.wiphy->txq_quantum = local->fq.quantum; in ieee80211_txq_set_params()
1522 struct fq *fq = &local->fq; in ieee80211_txq_setup_flows()
1526 enum nl80211_band band; in ieee80211_txq_setup_flows() local
1528 if (!local->ops->wake_tx_queue) in ieee80211_txq_setup_flows()
1537 * queue size. 4 Mbytes is 64 max-size aggregates in 802.11n. in ieee80211_txq_setup_flows()
1539 for (band = 0; band < NUM_NL80211_BANDS; band++) { in ieee80211_txq_setup_flows()
1542 sband = local->hw.wiphy->bands[band]; in ieee80211_txq_setup_flows()
1546 supp_vht = supp_vht || sband->vht_cap.vht_supported; in ieee80211_txq_setup_flows()
1550 fq->memory_limit = 4 << 20; /* 4 Mbytes */ in ieee80211_txq_setup_flows()
1552 codel_params_init(&local->cparams); in ieee80211_txq_setup_flows()
1553 local->cparams.interval = MS2TIME(100); in ieee80211_txq_setup_flows()
1554 local->cparams.target = MS2TIME(20); in ieee80211_txq_setup_flows()
1555 local->cparams.ecn = true; in ieee80211_txq_setup_flows()
1557 local->cvars = kcalloc(fq->flows_cnt, sizeof(local->cvars[0]), in ieee80211_txq_setup_flows()
1559 if (!local->cvars) { in ieee80211_txq_setup_flows()
1560 spin_lock_bh(&fq->lock); in ieee80211_txq_setup_flows()
1562 spin_unlock_bh(&fq->lock); in ieee80211_txq_setup_flows()
1563 return -ENOMEM; in ieee80211_txq_setup_flows()
1566 for (i = 0; i < fq->flows_cnt; i++) in ieee80211_txq_setup_flows()
1567 codel_vars_init(&local->cvars[i]); in ieee80211_txq_setup_flows()
1576 struct fq *fq = &local->fq; in ieee80211_txq_teardown_flows()
1578 if (!local->ops->wake_tx_queue) in ieee80211_txq_teardown_flows()
1581 kfree(local->cvars); in ieee80211_txq_teardown_flows()
1582 local->cvars = NULL; in ieee80211_txq_teardown_flows()
1584 spin_lock_bh(&fq->lock); in ieee80211_txq_teardown_flows()
1586 spin_unlock_bh(&fq->lock); in ieee80211_txq_teardown_flows()
1597 if (!local->ops->wake_tx_queue || in ieee80211_queue_skb()
1598 sdata->vif.type == NL80211_IFTYPE_MONITOR) in ieee80211_queue_skb()
1601 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) in ieee80211_queue_skb()
1602 sdata = container_of(sdata->bss, in ieee80211_queue_skb()
1605 vif = &sdata->vif; in ieee80211_queue_skb()
1630 int q = info->hw_queue; in ieee80211_tx_frags()
1633 if (WARN_ON_ONCE(q >= local->hw.queues)) { in ieee80211_tx_frags()
1635 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_frags()
1640 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in ieee80211_tx_frags()
1641 if (local->queue_stop_reasons[q] || in ieee80211_tx_frags()
1642 (!txpending && !skb_queue_empty(&local->pending[q]))) { in ieee80211_tx_frags()
1643 if (unlikely(info->flags & in ieee80211_tx_frags()
1645 if (local->queue_stop_reasons[q] & in ieee80211_tx_frags()
1648 * Drop off-channel frames if queues in ieee80211_tx_frags()
1650 * than off-channel operation. Never in ieee80211_tx_frags()
1654 &local->queue_stop_reason_lock, in ieee80211_tx_frags()
1656 ieee80211_purge_tx_queue(&local->hw, in ieee80211_tx_frags()
1664 * later transmission from the tx-pending in ieee80211_tx_frags()
1669 &local->pending[q]); in ieee80211_tx_frags()
1672 &local->pending[q]); in ieee80211_tx_frags()
1674 spin_unlock_irqrestore(&local->queue_stop_reason_lock, in ieee80211_tx_frags()
1679 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_tx_frags()
1681 info->control.vif = vif; in ieee80211_tx_frags()
1710 fc = ((struct ieee80211_hdr *)skb->data)->frame_control; in __ieee80211_tx()
1712 sdata = vif_to_sdata(info->control.vif); in __ieee80211_tx()
1713 if (sta && !sta->uploaded) in __ieee80211_tx()
1717 pubsta = &sta->sta; in __ieee80211_tx()
1721 switch (sdata->vif.type) { in __ieee80211_tx()
1723 if (sdata->u.mntr.flags & MONITOR_FLAG_ACTIVE) { in __ieee80211_tx()
1724 vif = &sdata->vif; in __ieee80211_tx()
1727 sdata = rcu_dereference(local->monitor_sdata); in __ieee80211_tx()
1729 vif = &sdata->vif; in __ieee80211_tx()
1730 info->hw_queue = in __ieee80211_tx()
1731 vif->hw_queue[skb_get_queue_mapping(skb)]; in __ieee80211_tx()
1732 } else if (ieee80211_hw_check(&local->hw, QUEUE_CONTROL)) { in __ieee80211_tx()
1733 ieee80211_purge_tx_queue(&local->hw, skbs); in __ieee80211_tx()
1739 sdata = container_of(sdata->bss, in __ieee80211_tx()
1743 vif = &sdata->vif; in __ieee80211_tx()
1758 * Invoke TX handlers, return 0 on success and non-zero if the
1781 if (!ieee80211_hw_check(&tx->local->hw, HAS_RATE_CONTROL)) in invoke_tx_handlers_early()
1786 I802_DEBUG_INC(tx->local->tx_handlers_drop); in invoke_tx_handlers_early()
1787 if (tx->skb) in invoke_tx_handlers_early()
1788 ieee80211_free_txskb(&tx->local->hw, tx->skb); in invoke_tx_handlers_early()
1790 ieee80211_purge_tx_queue(&tx->local->hw, &tx->skbs); in invoke_tx_handlers_early()
1791 return -1; in invoke_tx_handlers_early()
1793 I802_DEBUG_INC(tx->local->tx_handlers_queued); in invoke_tx_handlers_early()
1794 return -1; in invoke_tx_handlers_early()
1806 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); in invoke_tx_handlers_late()
1809 if (unlikely(info->flags & IEEE80211_TX_INTFL_RETRANSMISSION)) { in invoke_tx_handlers_late()
1810 __skb_queue_tail(&tx->skbs, tx->skb); in invoke_tx_handlers_late()
1811 tx->skb = NULL; in invoke_tx_handlers_late()
1818 /* handlers after fragment must be aware of tx info fragmentation! */ in invoke_tx_handlers_late()
1821 if (!ieee80211_hw_check(&tx->local->hw, HAS_RATE_CONTROL)) in invoke_tx_handlers_late()
1827 I802_DEBUG_INC(tx->local->tx_handlers_drop); in invoke_tx_handlers_late()
1828 if (tx->skb) in invoke_tx_handlers_late()
1829 ieee80211_free_txskb(&tx->local->hw, tx->skb); in invoke_tx_handlers_late()
1831 ieee80211_purge_tx_queue(&tx->local->hw, &tx->skbs); in invoke_tx_handlers_late()
1832 return -1; in invoke_tx_handlers_late()
1834 I802_DEBUG_INC(tx->local->tx_handlers_queued); in invoke_tx_handlers_late()
1835 return -1; in invoke_tx_handlers_late()
1852 int band, struct ieee80211_sta **sta) in ieee80211_tx_prepare_skb() argument
1862 info->band = band; in ieee80211_tx_prepare_skb()
1863 info->control.vif = vif; in ieee80211_tx_prepare_skb()
1864 info->hw_queue = vif->hw_queue[skb_get_queue_mapping(skb)]; in ieee80211_tx_prepare_skb()
1871 *sta = &tx.sta->sta; in ieee80211_tx_prepare_skb()
1895 struct ieee80211_local *local = sdata->local; in ieee80211_tx()
1902 if (unlikely(skb->len < 10)) { in ieee80211_tx()
1908 led_len = skb->len; in ieee80211_tx()
1914 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx()
1921 if (!(info->flags & IEEE80211_TX_CTL_TX_OFFCHAN) || in ieee80211_tx()
1922 !ieee80211_hw_check(&local->hw, QUEUE_CONTROL)) in ieee80211_tx()
1923 info->hw_queue = in ieee80211_tx()
1924 sdata->vif.hw_queue[skb_get_queue_mapping(skb)]; in ieee80211_tx()
1945 struct ieee80211_local *local = sdata->local; in ieee80211_skb_resize()
1950 hdr = (struct ieee80211_hdr *) skb->data; in ieee80211_skb_resize()
1952 (sdata->crypto_tx_tailroom_needed_cnt || in ieee80211_skb_resize()
1953 ieee80211_is_mgmt(hdr->frame_control)); in ieee80211_skb_resize()
1957 tail_need -= skb_tailroom(skb); in ieee80211_skb_resize()
1962 (!ieee80211_hw_check(&local->hw, SUPPORTS_CLONED_SKBS) || in ieee80211_skb_resize()
1964 I802_DEBUG_INC(local->tx_expand_skb_head_cloned); in ieee80211_skb_resize()
1966 I802_DEBUG_INC(local->tx_expand_skb_head); in ieee80211_skb_resize()
1971 wiphy_debug(local->hw.wiphy, in ieee80211_skb_resize()
1973 return -ENOMEM; in ieee80211_skb_resize()
1983 struct ieee80211_local *local = sdata->local; in ieee80211_xmit()
1989 may_encrypt = !(info->flags & IEEE80211_TX_INTFL_DONT_ENCRYPT); in ieee80211_xmit()
1991 headroom = local->tx_headroom; in ieee80211_xmit()
1993 headroom += sdata->encrypt_headroom; in ieee80211_xmit()
1994 headroom -= skb_headroom(skb); in ieee80211_xmit()
1998 ieee80211_free_txskb(&local->hw, skb); in ieee80211_xmit()
2002 hdr = (struct ieee80211_hdr *) skb->data; in ieee80211_xmit()
2003 info->control.vif = &sdata->vif; in ieee80211_xmit()
2005 if (ieee80211_vif_is_mesh(&sdata->vif)) { in ieee80211_xmit()
2006 if (ieee80211_is_data(hdr->frame_control) && in ieee80211_xmit()
2007 is_unicast_ether_addr(hdr->addr1)) { in ieee80211_xmit()
2024 (struct ieee80211_radiotap_header *) skb->data; in ieee80211_parse_tx_radiotap()
2027 local->hw.wiphy->bands[info->band]; in ieee80211_parse_tx_radiotap()
2028 int ret = ieee80211_radiotap_iterator_init(&iterator, rthdr, skb->len, in ieee80211_parse_tx_radiotap()
2040 info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT | in ieee80211_parse_tx_radiotap()
2045 * (ieee80211_radiotap_iterator_next returns -ENOENT when no more in ieee80211_parse_tx_radiotap()
2046 * entries present, or -EINVAL on error) in ieee80211_parse_tx_radiotap()
2067 * handed has the 32-bit FCS CRC at the end... in ieee80211_parse_tx_radiotap()
2072 if (skb->len < (iterator._max_length + FCS_LEN)) in ieee80211_parse_tx_radiotap()
2075 skb_trim(skb, skb->len - FCS_LEN); in ieee80211_parse_tx_radiotap()
2078 info->flags &= ~IEEE80211_TX_INTFL_DONT_ENCRYPT; in ieee80211_parse_tx_radiotap()
2080 info->flags &= ~IEEE80211_TX_CTL_DONTFRAG; in ieee80211_parse_tx_radiotap()
2086 info->flags |= IEEE80211_TX_CTL_NO_ACK; in ieee80211_parse_tx_radiotap()
2147 * Documentation/networking/mac80211-injection.txt in ieee80211_parse_tx_radiotap()
2156 if (ret != -ENOENT) /* ie, if we didn't simply run out of fields */ in ieee80211_parse_tx_radiotap()
2160 info->control.flags |= IEEE80211_TX_CTRL_RATE_INJECT; in ieee80211_parse_tx_radiotap()
2163 info->control.rates[i].idx = -1; in ieee80211_parse_tx_radiotap()
2164 info->control.rates[i].flags = 0; in ieee80211_parse_tx_radiotap()
2165 info->control.rates[i].count = 0; in ieee80211_parse_tx_radiotap()
2169 info->control.rates[0].idx = rate; in ieee80211_parse_tx_radiotap()
2171 ieee80211_rate_set_vht(info->control.rates, vht_mcs, in ieee80211_parse_tx_radiotap()
2174 for (i = 0; i < sband->n_bitrates; i++) { in ieee80211_parse_tx_radiotap()
2175 if (rate * 5 != sband->bitrates[i].bitrate) in ieee80211_parse_tx_radiotap()
2178 info->control.rates[0].idx = i; in ieee80211_parse_tx_radiotap()
2183 if (info->control.rates[0].idx < 0) in ieee80211_parse_tx_radiotap()
2184 info->control.flags &= ~IEEE80211_TX_CTRL_RATE_INJECT; in ieee80211_parse_tx_radiotap()
2186 info->control.rates[0].flags = rate_flags; in ieee80211_parse_tx_radiotap()
2187 info->control.rates[0].count = min_t(u8, rate_retries + 1, in ieee80211_parse_tx_radiotap()
2188 local->hw.max_rate_tries); in ieee80211_parse_tx_radiotap()
2193 * iterator->_max_length was sanity-checked against in ieee80211_parse_tx_radiotap()
2194 * skb->len by iterator init in ieee80211_parse_tx_radiotap()
2204 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); in ieee80211_monitor_start_xmit()
2207 (struct ieee80211_radiotap_header *)skb->data; in ieee80211_monitor_start_xmit()
2216 if (unlikely(skb->len < sizeof(struct ieee80211_radiotap_header))) in ieee80211_monitor_start_xmit()
2220 if (unlikely(prthdr->it_version)) in ieee80211_monitor_start_xmit()
2224 len_rthdr = ieee80211_get_radiotap_len(skb->data); in ieee80211_monitor_start_xmit()
2227 if (unlikely(skb->len < len_rthdr)) in ieee80211_monitor_start_xmit()
2238 * these are just fixed to the end of the rt area since we in ieee80211_monitor_start_xmit()
2244 if (skb->len < len_rthdr + 2) in ieee80211_monitor_start_xmit()
2247 hdr = (struct ieee80211_hdr *)(skb->data + len_rthdr); in ieee80211_monitor_start_xmit()
2248 hdrlen = ieee80211_hdrlen(hdr->frame_control); in ieee80211_monitor_start_xmit()
2250 if (skb->len < len_rthdr + hdrlen) in ieee80211_monitor_start_xmit()
2254 * Initialize skb->protocol if the injected frame is a data frame in ieee80211_monitor_start_xmit()
2257 if (ieee80211_is_data(hdr->frame_control) && in ieee80211_monitor_start_xmit()
2258 skb->len >= len_rthdr + hdrlen + sizeof(rfc1042_header) + 2) { in ieee80211_monitor_start_xmit()
2262 skb->protocol = cpu_to_be16((payload[6] << 8) | in ieee80211_monitor_start_xmit()
2268 info->flags = IEEE80211_TX_CTL_REQ_TX_STATUS | in ieee80211_monitor_start_xmit()
2275 * we handle as though they are non-injected frames. in ieee80211_monitor_start_xmit()
2283 list_for_each_entry_rcu(tmp_sdata, &local->interfaces, list) { in ieee80211_monitor_start_xmit()
2286 if (tmp_sdata->vif.type == NL80211_IFTYPE_MONITOR || in ieee80211_monitor_start_xmit()
2287 tmp_sdata->vif.type == NL80211_IFTYPE_AP_VLAN || in ieee80211_monitor_start_xmit()
2288 tmp_sdata->vif.type == NL80211_IFTYPE_WDS) in ieee80211_monitor_start_xmit()
2290 if (ether_addr_equal(tmp_sdata->vif.addr, hdr->addr2)) { in ieee80211_monitor_start_xmit()
2296 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); in ieee80211_monitor_start_xmit()
2298 tmp_sdata = rcu_dereference(local->monitor_sdata); in ieee80211_monitor_start_xmit()
2301 rcu_dereference(tmp_sdata->vif.chanctx_conf); in ieee80211_monitor_start_xmit()
2305 chandef = &chanctx_conf->def; in ieee80211_monitor_start_xmit()
2306 else if (!local->use_chanctx) in ieee80211_monitor_start_xmit()
2307 chandef = &local->_oper_chandef; in ieee80211_monitor_start_xmit()
2327 if (!cfg80211_reg_can_beacon(local->hw.wiphy, chandef, in ieee80211_monitor_start_xmit()
2328 sdata->vif.type)) in ieee80211_monitor_start_xmit()
2331 info->band = chandef->chan->band; in ieee80211_monitor_start_xmit()
2351 u16 ethertype = (skb->data[12] << 8) | skb->data[13]; in ieee80211_is_tdls_setup()
2354 skb->len > 14 && in ieee80211_is_tdls_setup()
2355 skb->data[14] == WLAN_TDLS_SNAP_RFTYPE; in ieee80211_is_tdls_setup()
2364 switch (sdata->vif.type) { in ieee80211_lookup_ra_sta()
2366 sta = rcu_dereference(sdata->u.vlan.sta); in ieee80211_lookup_ra_sta()
2370 } else if (sdata->wdev.use_4addr) { in ieee80211_lookup_ra_sta()
2371 return -ENOLINK; in ieee80211_lookup_ra_sta()
2377 if (is_multicast_ether_addr(skb->data)) { in ieee80211_lookup_ra_sta()
2378 *sta_out = ERR_PTR(-ENOENT); in ieee80211_lookup_ra_sta()
2381 sta = sta_info_get_bss(sdata, skb->data); in ieee80211_lookup_ra_sta()
2384 sta = sta_info_get(sdata, sdata->u.wds.remote_addr); in ieee80211_lookup_ra_sta()
2393 if (sdata->wdev.wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS) { in ieee80211_lookup_ra_sta()
2394 sta = sta_info_get(sdata, skb->data); in ieee80211_lookup_ra_sta()
2403 * TDLS link during setup - throw out frames to in ieee80211_lookup_ra_sta()
2404 * peer. Allow TDLS-setup frames to unauthorized in ieee80211_lookup_ra_sta()
2405 * peers for the special case of a link teardown in ieee80211_lookup_ra_sta()
2410 return -EINVAL; in ieee80211_lookup_ra_sta()
2415 sta = sta_info_get(sdata, sdata->u.mgd.bssid); in ieee80211_lookup_ra_sta()
2417 return -ENOLINK; in ieee80211_lookup_ra_sta()
2420 return -EINVAL; in ieee80211_lookup_ra_sta()
2423 *sta_out = sta ?: ERR_PTR(-ENOENT); in ieee80211_lookup_ra_sta()
2428 * ieee80211_build_hdr - build 802.11 header in the given frame
2438 * Note that this function also takes care of the TX status request and
2439 * potential unsharing of the SKB - this needs to be interleaved with the
2442 * The function requires the read-side RCU lock held
2450 struct ieee80211_local *local = sdata->local; in ieee80211_build_hdr()
2466 enum nl80211_band band; in ieee80211_build_hdr() local
2473 if (local->force_tx_status) in ieee80211_build_hdr()
2479 ethertype = (skb->data[12] << 8) | skb->data[13]; in ieee80211_build_hdr()
2482 switch (sdata->vif.type) { in ieee80211_build_hdr()
2484 if (sdata->wdev.use_4addr) { in ieee80211_build_hdr()
2487 memcpy(hdr.addr1, sta->sta.addr, ETH_ALEN); in ieee80211_build_hdr()
2488 memcpy(hdr.addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_build_hdr()
2489 memcpy(hdr.addr3, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2490 memcpy(hdr.addr4, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2493 wme_sta = sta->sta.wme; in ieee80211_build_hdr()
2495 ap_sdata = container_of(sdata->bss, struct ieee80211_sub_if_data, in ieee80211_build_hdr()
2497 chanctx_conf = rcu_dereference(ap_sdata->vif.chanctx_conf); in ieee80211_build_hdr()
2499 ret = -ENOTCONN; in ieee80211_build_hdr()
2502 band = chanctx_conf->def.chan->band; in ieee80211_build_hdr()
2503 if (sdata->wdev.use_4addr) in ieee80211_build_hdr()
2507 if (sdata->vif.type == NL80211_IFTYPE_AP) in ieee80211_build_hdr()
2508 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); in ieee80211_build_hdr()
2510 ret = -ENOTCONN; in ieee80211_build_hdr()
2515 memcpy(hdr.addr1, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2516 memcpy(hdr.addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_build_hdr()
2517 memcpy(hdr.addr3, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2519 band = chanctx_conf->def.chan->band; in ieee80211_build_hdr()
2524 memcpy(hdr.addr1, sdata->u.wds.remote_addr, ETH_ALEN); in ieee80211_build_hdr()
2525 memcpy(hdr.addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_build_hdr()
2526 memcpy(hdr.addr3, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2527 memcpy(hdr.addr4, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2533 band = local->hw.conf.chandef.chan->band; in ieee80211_build_hdr()
2537 if (!is_multicast_ether_addr(skb->data)) { in ieee80211_build_hdr()
2541 mpath = mesh_path_lookup(sdata, skb->data); in ieee80211_build_hdr()
2544 next_hop = rcu_dereference(mpath->next_hop); in ieee80211_build_hdr()
2546 !(mpath->flags & (MESH_PATH_ACTIVE | in ieee80211_build_hdr()
2552 mppath = mpp_path_lookup(sdata, skb->data); in ieee80211_build_hdr()
2554 mppath->exp_time = jiffies; in ieee80211_build_hdr()
2558 mesh_path_del(sdata, mpath->dst); in ieee80211_build_hdr()
2567 if (ether_addr_equal(sdata->vif.addr, skb->data + ETH_ALEN) && in ieee80211_build_hdr()
2568 !(mppath && !ether_addr_equal(mppath->mpp, skb->data))) { in ieee80211_build_hdr()
2570 skb->data, skb->data + ETH_ALEN); in ieee80211_build_hdr()
2574 /* DS -> MBSS (802.11-2012 13.11.3.3). in ieee80211_build_hdr()
2580 const u8 *mesh_da = skb->data; in ieee80211_build_hdr()
2583 mesh_da = mppath->mpp; in ieee80211_build_hdr()
2585 mesh_da = mpath->dst; in ieee80211_build_hdr()
2588 mesh_da, sdata->vif.addr); in ieee80211_build_hdr()
2593 skb->data + ETH_ALEN, NULL); in ieee80211_build_hdr()
2597 sdata, &mesh_hdr, skb->data, in ieee80211_build_hdr()
2598 skb->data + ETH_ALEN); in ieee80211_build_hdr()
2601 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); in ieee80211_build_hdr()
2603 ret = -ENOTCONN; in ieee80211_build_hdr()
2606 band = chanctx_conf->def.chan->band; in ieee80211_build_hdr()
2613 memcpy(hdr.addr1, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2622 memcpy(hdr.addr1, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2623 memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2624 memcpy(hdr.addr3, sdata->u.mgd.bssid, ETH_ALEN); in ieee80211_build_hdr()
2626 } else if (sdata->u.mgd.use_4addr && in ieee80211_build_hdr()
2627 cpu_to_be16(ethertype) != sdata->control_port_protocol) { in ieee80211_build_hdr()
2631 memcpy(hdr.addr1, sdata->u.mgd.bssid, ETH_ALEN); in ieee80211_build_hdr()
2632 memcpy(hdr.addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_build_hdr()
2633 memcpy(hdr.addr3, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2634 memcpy(hdr.addr4, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2639 memcpy(hdr.addr1, sdata->u.mgd.bssid, ETH_ALEN); in ieee80211_build_hdr()
2640 memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2641 memcpy(hdr.addr3, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2644 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); in ieee80211_build_hdr()
2646 ret = -ENOTCONN; in ieee80211_build_hdr()
2649 band = chanctx_conf->def.chan->band; in ieee80211_build_hdr()
2653 memcpy(hdr.addr1, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2654 memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2657 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); in ieee80211_build_hdr()
2659 ret = -ENOTCONN; in ieee80211_build_hdr()
2662 band = chanctx_conf->def.chan->band; in ieee80211_build_hdr()
2666 memcpy(hdr.addr1, skb->data, ETH_ALEN); in ieee80211_build_hdr()
2667 memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN); in ieee80211_build_hdr()
2668 memcpy(hdr.addr3, sdata->u.ibss.bssid, ETH_ALEN); in ieee80211_build_hdr()
2670 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); in ieee80211_build_hdr()
2672 ret = -ENOTCONN; in ieee80211_build_hdr()
2675 band = chanctx_conf->def.chan->band; in ieee80211_build_hdr()
2678 ret = -EINVAL; in ieee80211_build_hdr()
2687 wme_sta = sta->sta.wme; in ieee80211_build_hdr()
2688 } else if (ieee80211_vif_is_mesh(&sdata->vif)) { in ieee80211_build_hdr()
2689 /* For mesh, the use of the QoS header is mandatory */ in ieee80211_build_hdr()
2703 if (unlikely(!ieee80211_vif_is_mesh(&sdata->vif) && in ieee80211_build_hdr()
2704 (sdata->vif.type != NL80211_IFTYPE_OCB) && in ieee80211_build_hdr()
2706 (cpu_to_be16(ethertype) != sdata->control_port_protocol || in ieee80211_build_hdr()
2707 !ether_addr_equal(sdata->vif.addr, skb->data + ETH_ALEN)))) { in ieee80211_build_hdr()
2710 sdata->name, hdr.addr1); in ieee80211_build_hdr()
2713 I802_DEBUG_INC(local->tx_handlers_drop_unauth_port); in ieee80211_build_hdr()
2715 ret = -EPERM; in ieee80211_build_hdr()
2719 if (unlikely(!multicast && skb->sk && in ieee80211_build_hdr()
2720 skb_shinfo(skb)->tx_flags & SKBTX_WIFI_STATUS)) { in ieee80211_build_hdr()
2727 spin_lock_irqsave(&local->ack_status_lock, flags); in ieee80211_build_hdr()
2728 id = idr_alloc(&local->ack_status_frames, ack_skb, in ieee80211_build_hdr()
2730 spin_unlock_irqrestore(&local->ack_status_lock, flags); in ieee80211_build_hdr()
2747 /* can't happen -- skb is a clone if info_id != 0 */ in ieee80211_build_hdr()
2754 ret = -ENOMEM; in ieee80211_build_hdr()
2767 skip_header_bytes -= 2; in ieee80211_build_hdr()
2771 skip_header_bytes -= 2; in ieee80211_build_hdr()
2778 head_need = hdrlen + encaps_len + meshhdrlen - skb_headroom(skb); in ieee80211_build_hdr()
2781 * So we need to modify the skb header and hence need a copy of in ieee80211_build_hdr()
2793 head_need += sdata->encrypt_headroom; in ieee80211_build_hdr()
2794 head_need += local->tx_headroom; in ieee80211_build_hdr()
2797 ieee80211_free_txskb(&local->hw, skb); in ieee80211_build_hdr()
2799 return ERR_PTR(-ENOMEM); in ieee80211_build_hdr()
2815 memcpy(skb_push(skb, hdrlen - 2), &hdr, hdrlen - 2); in ieee80211_build_hdr()
2829 info->flags = info_flags; in ieee80211_build_hdr()
2830 info->ack_frame_id = info_id; in ieee80211_build_hdr()
2831 info->band = band; in ieee80211_build_hdr()
2832 info->control.flags = ctrl_flags; in ieee80211_build_hdr()
2841 * fast-xmit overview
2843 * The core idea of this fast-xmit is to remove per-packet checks by checking
2844 * them out of band. ieee80211_check_fast_xmit() implements the out-of-band
2845 * checks that are needed to get the sta->fast_tx pointer assigned, after which
2850 * Once assigned, the fast_tx data structure also caches the per-packet 802.11
2853 * The most difficult part of this is that when any of these assumptions
2856 * since the per-packet code no longer checks the conditions. This is reflected
2857 * by the calls to these functions throughout the rest of the code, and must be
2858 * maintained if any of the TX path checks change.
2864 struct ieee80211_local *local = sta->local; in ieee80211_check_fast_xmit()
2865 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_check_fast_xmit()
2870 if (!ieee80211_hw_check(&local->hw, SUPPORT_FAST_XMIT)) in ieee80211_check_fast_xmit()
2876 * Without it, the invocation of this function right after the key in ieee80211_check_fast_xmit()
2881 * key and the fast-tx assignment are done atomically, so the CPU that in ieee80211_check_fast_xmit()
2885 spin_lock_bh(&sta->lock); in ieee80211_check_fast_xmit()
2886 if (ieee80211_hw_check(&local->hw, SUPPORTS_PS) && in ieee80211_check_fast_xmit()
2887 !ieee80211_hw_check(&local->hw, SUPPORTS_DYNAMIC_PS) && in ieee80211_check_fast_xmit()
2888 sdata->vif.type == NL80211_IFTYPE_STATION) in ieee80211_check_fast_xmit()
2889 goto out; in ieee80211_check_fast_xmit()
2892 goto out; in ieee80211_check_fast_xmit()
2898 goto out; in ieee80211_check_fast_xmit()
2900 if (sdata->noack_map) in ieee80211_check_fast_xmit()
2901 goto out; in ieee80211_check_fast_xmit()
2903 /* fast-xmit doesn't handle fragmentation at all */ in ieee80211_check_fast_xmit()
2904 if (local->hw.wiphy->frag_threshold != (u32)-1 && in ieee80211_check_fast_xmit()
2905 !ieee80211_hw_check(&local->hw, SUPPORTS_TX_FRAG)) in ieee80211_check_fast_xmit()
2906 goto out; in ieee80211_check_fast_xmit()
2909 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); in ieee80211_check_fast_xmit()
2912 goto out; in ieee80211_check_fast_xmit()
2914 build.band = chanctx_conf->def.chan->band; in ieee80211_check_fast_xmit()
2919 switch (sdata->vif.type) { in ieee80211_check_fast_xmit()
2924 memcpy(hdr->addr3, sdata->u.ibss.bssid, ETH_ALEN); in ieee80211_check_fast_xmit()
2932 memcpy(hdr->addr3, sdata->u.mgd.bssid, ETH_ALEN); in ieee80211_check_fast_xmit()
2937 if (sdata->u.mgd.use_4addr) { in ieee80211_check_fast_xmit()
2938 /* non-regular ethertype cannot use the fastpath */ in ieee80211_check_fast_xmit()
2942 memcpy(hdr->addr1, sdata->u.mgd.bssid, ETH_ALEN); in ieee80211_check_fast_xmit()
2943 memcpy(hdr->addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_check_fast_xmit()
2951 memcpy(hdr->addr1, sdata->u.mgd.bssid, ETH_ALEN); in ieee80211_check_fast_xmit()
2957 if (sdata->wdev.use_4addr) { in ieee80211_check_fast_xmit()
2961 memcpy(hdr->addr1, sta->sta.addr, ETH_ALEN); in ieee80211_check_fast_xmit()
2962 memcpy(hdr->addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_check_fast_xmit()
2973 memcpy(hdr->addr2, sdata->vif.addr, ETH_ALEN); in ieee80211_check_fast_xmit()
2978 /* not handled on fast-xmit */ in ieee80211_check_fast_xmit()
2979 goto out; in ieee80211_check_fast_xmit()
2982 if (sta->sta.wme) { in ieee80211_check_fast_xmit()
2992 build.key = rcu_access_pointer(sta->ptk[sta->ptk_idx]); in ieee80211_check_fast_xmit()
2994 build.key = rcu_access_pointer(sdata->default_unicast_key); in ieee80211_check_fast_xmit()
2998 gen_iv = build.key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV; in ieee80211_check_fast_xmit()
2999 iv_spc = build.key->conf.flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE; in ieee80211_check_fast_xmit()
3000 mmic = build.key->conf.flags & in ieee80211_check_fast_xmit()
3005 if (!(build.key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) in ieee80211_check_fast_xmit()
3006 goto out; in ieee80211_check_fast_xmit()
3009 if (build.key->flags & KEY_FLAG_TAINTED) in ieee80211_check_fast_xmit()
3010 goto out; in ieee80211_check_fast_xmit()
3012 switch (build.key->conf.cipher) { in ieee80211_check_fast_xmit()
3028 /* cannot handle MMIC or IV generation in xmit-fast */ in ieee80211_check_fast_xmit()
3030 goto out; in ieee80211_check_fast_xmit()
3036 /* cannot handle IV generation in fast-xmit */ in ieee80211_check_fast_xmit()
3038 goto out; in ieee80211_check_fast_xmit()
3048 build.key->conf.cipher); in ieee80211_check_fast_xmit()
3049 goto out; in ieee80211_check_fast_xmit()
3053 goto out; in ieee80211_check_fast_xmit()
3054 /* pure hardware keys are OK, of course */ in ieee80211_check_fast_xmit()
3055 if (!(build.key->flags & KEY_FLAG_CIPHER_SCHEME)) in ieee80211_check_fast_xmit()
3059 build.key->conf.iv_len > IEEE80211_FAST_XMIT_MAX_IV) in ieee80211_check_fast_xmit()
3060 goto out; in ieee80211_check_fast_xmit()
3062 build.hdr_len += build.key->conf.iv_len; in ieee80211_check_fast_xmit()
3068 hdr->frame_control = fc; in ieee80211_check_fast_xmit()
3077 goto out; in ieee80211_check_fast_xmit()
3079 out: in ieee80211_check_fast_xmit()
3081 old = rcu_dereference_protected(sta->fast_tx, in ieee80211_check_fast_xmit()
3082 lockdep_is_held(&sta->lock)); in ieee80211_check_fast_xmit()
3083 rcu_assign_pointer(sta->fast_tx, fast_tx); in ieee80211_check_fast_xmit()
3086 spin_unlock_bh(&sta->lock); in ieee80211_check_fast_xmit()
3094 list_for_each_entry_rcu(sta, &local->sta_list, list) in ieee80211_check_fast_xmit_all()
3101 struct ieee80211_local *local = sdata->local; in ieee80211_check_fast_xmit_iface()
3106 list_for_each_entry_rcu(sta, &local->sta_list, list) { in ieee80211_check_fast_xmit_iface()
3107 if (sdata != sta->sdata && in ieee80211_check_fast_xmit_iface()
3108 (!sta->sdata->bss || sta->sdata->bss != sdata->bss)) in ieee80211_check_fast_xmit_iface()
3120 spin_lock_bh(&sta->lock); in ieee80211_clear_fast_xmit()
3121 fast_tx = rcu_dereference_protected(sta->fast_tx, in ieee80211_clear_fast_xmit()
3122 lockdep_is_held(&sta->lock)); in ieee80211_clear_fast_xmit()
3123 RCU_INIT_POINTER(sta->fast_tx, NULL); in ieee80211_clear_fast_xmit()
3124 spin_unlock_bh(&sta->lock); in ieee80211_clear_fast_xmit()
3134 I802_DEBUG_INC(local->tx_expand_skb_head); in ieee80211_amsdu_realloc_pad()
3137 wiphy_debug(local->hw.wiphy, in ieee80211_amsdu_realloc_pad()
3150 struct ieee80211_local *local = sdata->local; in ieee80211_amsdu_prepare_head()
3154 int hdr_len = fast_tx->hdr_len - sizeof(rfc1042_header); in ieee80211_amsdu_prepare_head()
3155 int subframe_len = skb->len - hdr_len; in ieee80211_amsdu_prepare_head()
3160 if (info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE) in ieee80211_amsdu_prepare_head()
3163 if (info->control.flags & IEEE80211_TX_CTRL_AMSDU) in ieee80211_amsdu_prepare_head()
3174 h_80211_src = data + fast_tx->sa_offs; in ieee80211_amsdu_prepare_head()
3175 h_80211_dst = data + fast_tx->da_offs; in ieee80211_amsdu_prepare_head()
3177 amsdu_hdr->h_proto = cpu_to_be16(subframe_len); in ieee80211_amsdu_prepare_head()
3178 ether_addr_copy(amsdu_hdr->h_source, h_80211_src); in ieee80211_amsdu_prepare_head()
3179 ether_addr_copy(amsdu_hdr->h_dest, h_80211_dst); in ieee80211_amsdu_prepare_head()
3181 /* according to IEEE 802.11-2012 8.3.2 table 8-19, the outer SA/DA in ieee80211_amsdu_prepare_head()
3182 * fields needs to be changed to BSSID for A-MSDU frames depending in ieee80211_amsdu_prepare_head()
3185 switch (sdata->vif.type) { in ieee80211_amsdu_prepare_head()
3187 bssid = sdata->u.mgd.bssid; in ieee80211_amsdu_prepare_head()
3191 bssid = sdata->vif.addr; in ieee80211_amsdu_prepare_head()
3197 if (bssid && ieee80211_has_fromds(hdr->frame_control)) in ieee80211_amsdu_prepare_head()
3200 if (bssid && ieee80211_has_tods(hdr->frame_control)) in ieee80211_amsdu_prepare_head()
3206 info->control.flags |= IEEE80211_TX_CTRL_AMSDU; in ieee80211_amsdu_prepare_head()
3216 struct ieee80211_local *local = sdata->local; in ieee80211_amsdu_aggregate()
3217 struct fq *fq = &local->fq; in ieee80211_amsdu_aggregate()
3220 u8 tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; in ieee80211_amsdu_aggregate()
3221 struct ieee80211_txq *txq = sta->sta.txq[tid]; in ieee80211_amsdu_aggregate()
3224 int subframe_len = skb->len - ETH_ALEN; in ieee80211_amsdu_aggregate()
3225 u8 max_subframes = sta->sta.max_amsdu_subframes; in ieee80211_amsdu_aggregate()
3226 int max_frags = local->hw.max_tx_fragments; in ieee80211_amsdu_aggregate()
3227 int max_amsdu_len = sta->sta.max_amsdu_len; in ieee80211_amsdu_aggregate()
3237 if (!ieee80211_hw_check(&local->hw, TX_AMSDU)) in ieee80211_amsdu_aggregate()
3247 if (test_bit(IEEE80211_TXQ_NO_AMSDU, &txqi->flags)) in ieee80211_amsdu_aggregate()
3250 if (sta->sta.max_rc_amsdu_len) in ieee80211_amsdu_aggregate()
3252 sta->sta.max_rc_amsdu_len); in ieee80211_amsdu_aggregate()
3254 if (sta->sta.max_tid_amsdu_len[tid]) in ieee80211_amsdu_aggregate()
3256 sta->sta.max_tid_amsdu_len[tid]); in ieee80211_amsdu_aggregate()
3260 spin_lock_bh(&fq->lock); in ieee80211_amsdu_aggregate()
3266 tin = &txqi->tin; in ieee80211_amsdu_aggregate()
3269 head = skb_peek_tail(&flow->queue); in ieee80211_amsdu_aggregate()
3271 goto out; in ieee80211_amsdu_aggregate()
3273 orig_truesize = head->truesize; in ieee80211_amsdu_aggregate()
3274 orig_len = head->len; in ieee80211_amsdu_aggregate()
3276 if (skb->len + head->len > max_amsdu_len) in ieee80211_amsdu_aggregate()
3277 goto out; in ieee80211_amsdu_aggregate()
3279 nfrags = 1 + skb_shinfo(skb)->nr_frags; in ieee80211_amsdu_aggregate()
3280 nfrags += 1 + skb_shinfo(head)->nr_frags; in ieee80211_amsdu_aggregate()
3281 frag_tail = &skb_shinfo(head)->frag_list; in ieee80211_amsdu_aggregate()
3283 nfrags += 1 + skb_shinfo(*frag_tail)->nr_frags; in ieee80211_amsdu_aggregate()
3284 frag_tail = &(*frag_tail)->next; in ieee80211_amsdu_aggregate()
3289 goto out; in ieee80211_amsdu_aggregate()
3292 goto out; in ieee80211_amsdu_aggregate()
3295 goto out; in ieee80211_amsdu_aggregate()
3298 goto out; in ieee80211_amsdu_aggregate()
3301 * Pad out the previous subframe to a multiple of 4 by adding the in ieee80211_amsdu_aggregate()
3302 * padding to the next one, that's being added. Note that head->len in ieee80211_amsdu_aggregate()
3303 * is the length of the full A-MSDU, but that works since each time in ieee80211_amsdu_aggregate()
3304 * we add a new subframe we pad out the previous one to a multiple in ieee80211_amsdu_aggregate()
3305 * of 4 and thus it no longer matters in the next round. in ieee80211_amsdu_aggregate()
3307 hdrlen = fast_tx->hdr_len - sizeof(rfc1042_header); in ieee80211_amsdu_aggregate()
3308 if ((head->len - hdrlen) & 3) in ieee80211_amsdu_aggregate()
3309 pad = 4 - ((head->len - hdrlen) & 3); in ieee80211_amsdu_aggregate()
3326 head->len += skb->len; in ieee80211_amsdu_aggregate()
3327 head->data_len += skb->len; in ieee80211_amsdu_aggregate()
3331 fq->memory_usage += head->truesize - orig_truesize; in ieee80211_amsdu_aggregate()
3332 if (head->len != orig_len) { in ieee80211_amsdu_aggregate()
3333 flow->backlog += head->len - orig_len; in ieee80211_amsdu_aggregate()
3334 tin->backlog_bytes += head->len - orig_len; in ieee80211_amsdu_aggregate()
3338 out: in ieee80211_amsdu_aggregate()
3339 spin_unlock_bh(&fq->lock); in ieee80211_amsdu_aggregate()
3354 struct ieee80211_hdr *hdr = (void *)skb->data; in ieee80211_xmit_fast_finish()
3358 info->control.hw_key = &key->conf; in ieee80211_xmit_fast_finish()
3360 ieee80211_tx_stats(skb->dev, skb->len); in ieee80211_xmit_fast_finish()
3362 if (hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) { in ieee80211_xmit_fast_finish()
3363 tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; in ieee80211_xmit_fast_finish()
3364 hdr->seq_ctrl = ieee80211_tx_next_seq(sta, tid); in ieee80211_xmit_fast_finish()
3366 info->flags |= IEEE80211_TX_CTL_ASSIGN_SEQ; in ieee80211_xmit_fast_finish()
3367 hdr->seq_ctrl = cpu_to_le16(sdata->sequence_number); in ieee80211_xmit_fast_finish()
3368 sdata->sequence_number += 0x10; in ieee80211_xmit_fast_finish()
3371 if (skb_shinfo(skb)->gso_size) in ieee80211_xmit_fast_finish()
3372 sta->tx_stats.msdu[tid] += in ieee80211_xmit_fast_finish()
3373 DIV_ROUND_UP(skb->len, skb_shinfo(skb)->gso_size); in ieee80211_xmit_fast_finish()
3375 sta->tx_stats.msdu[tid]++; in ieee80211_xmit_fast_finish()
3377 info->hw_queue = sdata->vif.hw_queue[skb_get_queue_mapping(skb)]; in ieee80211_xmit_fast_finish()
3382 sta->tx_stats.bytes[skb_get_queue_mapping(skb)] += skb->len; in ieee80211_xmit_fast_finish()
3383 sta->tx_stats.packets[skb_get_queue_mapping(skb)]++; in ieee80211_xmit_fast_finish()
3387 u8 *crypto_hdr = skb->data + pn_offs; in ieee80211_xmit_fast_finish()
3389 switch (key->conf.cipher) { in ieee80211_xmit_fast_finish()
3394 pn = atomic64_inc_return(&key->conf.tx_pn); in ieee80211_xmit_fast_finish()
3397 crypto_hdr[3] = 0x20 | (key->conf.keyidx << 6); in ieee80211_xmit_fast_finish()
3412 struct ieee80211_local *local = sdata->local; in ieee80211_xmit_fast()
3413 u16 ethertype = (skb->data[12] << 8) | skb->data[13]; in ieee80211_xmit_fast()
3414 int extra_head = fast_tx->hdr_len - (ETH_HLEN - 2); in ieee80211_xmit_fast()
3415 int hw_headroom = sdata->local->hw.extra_tx_headroom; in ieee80211_xmit_fast()
3418 struct ieee80211_hdr *hdr = (void *)fast_tx->hdr; in ieee80211_xmit_fast()
3424 /* control port protocol needs a lot of special handling */ in ieee80211_xmit_fast()
3425 if (cpu_to_be16(ethertype) == sdata->control_port_protocol) in ieee80211_xmit_fast()
3433 if (skb->sk && skb_shinfo(skb)->tx_flags & SKBTX_WIFI_STATUS) in ieee80211_xmit_fast()
3436 if (hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) { in ieee80211_xmit_fast()
3437 tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; in ieee80211_xmit_fast()
3438 tid_tx = rcu_dereference(sta->ampdu_mlme.tid_tx[tid]); in ieee80211_xmit_fast()
3440 if (!test_bit(HT_AGG_STATE_OPERATIONAL, &tid_tx->state)) in ieee80211_xmit_fast()
3442 if (tid_tx->timeout) in ieee80211_xmit_fast()
3443 tid_tx->last_tx = jiffies; in ieee80211_xmit_fast()
3459 if ((hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) && in ieee80211_xmit_fast()
3463 /* will not be crypto-handled beyond what we do here, so use false in ieee80211_xmit_fast()
3464 * as the may-encrypt argument for the resize to not account for in ieee80211_xmit_fast()
3468 max_t(int, extra_head + hw_headroom - in ieee80211_xmit_fast()
3475 memcpy(&eth, skb->data, ETH_HLEN - 2); in ieee80211_xmit_fast()
3477 memcpy(skb->data, fast_tx->hdr, fast_tx->hdr_len); in ieee80211_xmit_fast()
3478 memcpy(skb->data + fast_tx->da_offs, eth.h_dest, ETH_ALEN); in ieee80211_xmit_fast()
3479 memcpy(skb->data + fast_tx->sa_offs, eth.h_source, ETH_ALEN); in ieee80211_xmit_fast()
3483 info->band = fast_tx->band; in ieee80211_xmit_fast()
3484 info->control.vif = &sdata->vif; in ieee80211_xmit_fast()
3485 info->flags = IEEE80211_TX_CTL_FIRST_FRAGMENT | in ieee80211_xmit_fast()
3488 info->control.flags = IEEE80211_TX_CTRL_FAST_XMIT; in ieee80211_xmit_fast()
3491 if (local->force_tx_status) in ieee80211_xmit_fast()
3492 info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS; in ieee80211_xmit_fast()
3495 if (hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) { in ieee80211_xmit_fast()
3496 tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; in ieee80211_xmit_fast()
3506 tx.key = fast_tx->key; in ieee80211_xmit_fast()
3508 if (!ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL)) { in ieee80211_xmit_fast()
3524 ieee80211_xmit_fast_finish(sdata, sta, fast_tx->pn_offs, in ieee80211_xmit_fast()
3525 fast_tx->key, skb); in ieee80211_xmit_fast()
3527 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) in ieee80211_xmit_fast()
3528 sdata = container_of(sdata->bss, in ieee80211_xmit_fast()
3532 ieee80211_tx_frags(local, &sdata->vif, &sta->sta, &tx.skbs, false); in ieee80211_xmit_fast()
3543 struct fq *fq = &local->fq; in ieee80211_tx_dequeue()
3544 struct fq_tin *tin = &txqi->tin; in ieee80211_tx_dequeue()
3548 struct ieee80211_vif *vif = txq->vif; in ieee80211_tx_dequeue()
3553 spin_lock_bh(&fq->lock); in ieee80211_tx_dequeue()
3555 if (test_bit(IEEE80211_TXQ_STOP, &txqi->flags) || in ieee80211_tx_dequeue()
3556 test_bit(IEEE80211_TXQ_STOP_NETIF_TX, &txqi->flags)) in ieee80211_tx_dequeue()
3557 goto out; in ieee80211_tx_dequeue()
3559 if (vif->txqs_stopped[ieee80211_ac_from_tid(txq->tid)]) { in ieee80211_tx_dequeue()
3560 set_bit(IEEE80211_TXQ_STOP_NETIF_TX, &txqi->flags); in ieee80211_tx_dequeue()
3561 goto out; in ieee80211_tx_dequeue()
3565 skb = __skb_dequeue(&txqi->frags); in ieee80211_tx_dequeue()
3567 goto out; in ieee80211_tx_dequeue()
3571 goto out; in ieee80211_tx_dequeue()
3573 spin_unlock_bh(&fq->lock); in ieee80211_tx_dequeue()
3575 hdr = (struct ieee80211_hdr *)skb->data; in ieee80211_tx_dequeue()
3582 tx.sdata = vif_to_sdata(info->control.vif); in ieee80211_tx_dequeue()
3584 if (txq->sta) in ieee80211_tx_dequeue()
3585 tx.sta = container_of(txq->sta, struct sta_info, sta); in ieee80211_tx_dequeue()
3593 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_dequeue()
3597 if (test_bit(IEEE80211_TXQ_AMPDU, &txqi->flags)) in ieee80211_tx_dequeue()
3598 info->flags |= IEEE80211_TX_CTL_AMPDU; in ieee80211_tx_dequeue()
3600 info->flags &= ~IEEE80211_TX_CTL_AMPDU; in ieee80211_tx_dequeue()
3602 if (info->control.flags & IEEE80211_TX_CTRL_FAST_XMIT) { in ieee80211_tx_dequeue()
3603 struct sta_info *sta = container_of(txq->sta, struct sta_info, in ieee80211_tx_dequeue()
3608 (tx.key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)) in ieee80211_tx_dequeue()
3609 pn_offs = ieee80211_hdrlen(hdr->frame_control); in ieee80211_tx_dequeue()
3611 ieee80211_xmit_fast_finish(sta->sdata, sta, pn_offs, in ieee80211_tx_dequeue()
3620 spin_lock_bh(&fq->lock); in ieee80211_tx_dequeue()
3621 skb_queue_splice_tail(&tx.skbs, &txqi->frags); in ieee80211_tx_dequeue()
3622 spin_unlock_bh(&fq->lock); in ieee80211_tx_dequeue()
3627 !ieee80211_hw_check(&local->hw, TX_FRAG_LIST)) { in ieee80211_tx_dequeue()
3629 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_dequeue()
3634 switch (tx.sdata->vif.type) { in ieee80211_tx_dequeue()
3636 if (tx.sdata->u.mntr.flags & MONITOR_FLAG_ACTIVE) { in ieee80211_tx_dequeue()
3637 vif = &tx.sdata->vif; in ieee80211_tx_dequeue()
3640 tx.sdata = rcu_dereference(local->monitor_sdata); in ieee80211_tx_dequeue()
3642 vif = &tx.sdata->vif; in ieee80211_tx_dequeue()
3643 info->hw_queue = in ieee80211_tx_dequeue()
3644 vif->hw_queue[skb_get_queue_mapping(skb)]; in ieee80211_tx_dequeue()
3645 } else if (ieee80211_hw_check(&local->hw, QUEUE_CONTROL)) { in ieee80211_tx_dequeue()
3646 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_dequeue()
3653 tx.sdata = container_of(tx.sdata->bss, in ieee80211_tx_dequeue()
3657 vif = &tx.sdata->vif; in ieee80211_tx_dequeue()
3661 IEEE80211_SKB_CB(skb)->control.vif = vif; in ieee80211_tx_dequeue()
3664 out: in ieee80211_tx_dequeue()
3665 spin_unlock_bh(&fq->lock); in ieee80211_tx_dequeue()
3677 spin_lock_bh(&local->active_txq_lock[ac]); in ieee80211_next_txq()
3680 txqi = list_first_entry_or_null(&local->active_txqs[ac], in ieee80211_next_txq()
3684 goto out; in ieee80211_next_txq()
3686 if (txqi->txq.sta) { in ieee80211_next_txq()
3687 struct sta_info *sta = container_of(txqi->txq.sta, in ieee80211_next_txq()
3690 if (sta->airtime[txqi->txq.ac].deficit < 0) { in ieee80211_next_txq()
3691 sta->airtime[txqi->txq.ac].deficit += in ieee80211_next_txq()
3692 sta->airtime_weight; in ieee80211_next_txq()
3693 list_move_tail(&txqi->schedule_order, in ieee80211_next_txq()
3694 &local->active_txqs[txqi->txq.ac]); in ieee80211_next_txq()
3700 if (txqi->schedule_round == local->schedule_round[ac]) in ieee80211_next_txq()
3701 goto out; in ieee80211_next_txq()
3703 list_del_init(&txqi->schedule_order); in ieee80211_next_txq()
3704 txqi->schedule_round = local->schedule_round[ac]; in ieee80211_next_txq()
3705 ret = &txqi->txq; in ieee80211_next_txq()
3707 out: in ieee80211_next_txq()
3708 spin_unlock_bh(&local->active_txq_lock[ac]); in ieee80211_next_txq()
3720 spin_lock_bh(&local->active_txq_lock[txq->ac]); in __ieee80211_schedule_txq()
3722 if (list_empty(&txqi->schedule_order) && in __ieee80211_schedule_txq()
3723 (force || !skb_queue_empty(&txqi->frags) || in __ieee80211_schedule_txq()
3724 txqi->tin.backlog_packets)) { in __ieee80211_schedule_txq()
3726 * head of the list to ensure that they only get moved to the in __ieee80211_schedule_txq()
3729 * get immediately moved to the back of the list on the next in __ieee80211_schedule_txq()
3732 if (txqi->txq.sta && in __ieee80211_schedule_txq()
3733 wiphy_ext_feature_isset(local->hw.wiphy, in __ieee80211_schedule_txq()
3735 list_add(&txqi->schedule_order, in __ieee80211_schedule_txq()
3736 &local->active_txqs[txq->ac]); in __ieee80211_schedule_txq()
3738 list_add_tail(&txqi->schedule_order, in __ieee80211_schedule_txq()
3739 &local->active_txqs[txq->ac]); in __ieee80211_schedule_txq()
3742 spin_unlock_bh(&local->active_txq_lock[txq->ac]); in __ieee80211_schedule_txq()
3752 u8 ac = txq->ac; in ieee80211_txq_may_transmit()
3754 spin_lock_bh(&local->active_txq_lock[ac]); in ieee80211_txq_may_transmit()
3756 if (!txqi->txq.sta) in ieee80211_txq_may_transmit()
3757 goto out; in ieee80211_txq_may_transmit()
3759 if (list_empty(&txqi->schedule_order)) in ieee80211_txq_may_transmit()
3760 goto out; in ieee80211_txq_may_transmit()
3762 list_for_each_entry_safe(iter, tmp, &local->active_txqs[ac], in ieee80211_txq_may_transmit()
3767 if (!iter->txq.sta) { in ieee80211_txq_may_transmit()
3768 list_move_tail(&iter->schedule_order, in ieee80211_txq_may_transmit()
3769 &local->active_txqs[ac]); in ieee80211_txq_may_transmit()
3772 sta = container_of(iter->txq.sta, struct sta_info, sta); in ieee80211_txq_may_transmit()
3773 if (sta->airtime[ac].deficit < 0) in ieee80211_txq_may_transmit()
3774 sta->airtime[ac].deficit += sta->airtime_weight; in ieee80211_txq_may_transmit()
3775 list_move_tail(&iter->schedule_order, &local->active_txqs[ac]); in ieee80211_txq_may_transmit()
3778 sta = container_of(txqi->txq.sta, struct sta_info, sta); in ieee80211_txq_may_transmit()
3779 if (sta->airtime[ac].deficit >= 0) in ieee80211_txq_may_transmit()
3780 goto out; in ieee80211_txq_may_transmit()
3782 sta->airtime[ac].deficit += sta->airtime_weight; in ieee80211_txq_may_transmit()
3783 list_move_tail(&txqi->schedule_order, &local->active_txqs[ac]); in ieee80211_txq_may_transmit()
3784 spin_unlock_bh(&local->active_txq_lock[ac]); in ieee80211_txq_may_transmit()
3787 out: in ieee80211_txq_may_transmit()
3788 if (!list_empty(&txqi->schedule_order)) in ieee80211_txq_may_transmit()
3789 list_del_init(&txqi->schedule_order); in ieee80211_txq_may_transmit()
3790 spin_unlock_bh(&local->active_txq_lock[ac]); in ieee80211_txq_may_transmit()
3800 spin_lock_bh(&local->active_txq_lock[ac]); in ieee80211_txq_schedule_start()
3801 local->schedule_round[ac]++; in ieee80211_txq_schedule_start()
3802 spin_unlock_bh(&local->active_txq_lock[ac]); in ieee80211_txq_schedule_start()
3812 struct ieee80211_local *local = sdata->local; in __ieee80211_subif_start_xmit()
3816 if (unlikely(skb->len < ETH_HLEN)) { in __ieee80211_subif_start_xmit()
3829 if (local->ops->wake_tx_queue) { in __ieee80211_subif_start_xmit()
3837 sk_pacing_shift_update(skb->sk, sdata->local->hw.tx_sk_pacing_shift); in __ieee80211_subif_start_xmit()
3839 fast_tx = rcu_dereference(sta->fast_tx); in __ieee80211_subif_start_xmit()
3843 goto out; in __ieee80211_subif_start_xmit()
3857 /* we cannot process non-linear frames on this path */ in __ieee80211_subif_start_xmit()
3860 goto out; in __ieee80211_subif_start_xmit()
3863 /* the frame could be fragmented, software-encrypted, and other in __ieee80211_subif_start_xmit()
3864 * things so we cannot really handle checksum offload with it - in __ieee80211_subif_start_xmit()
3867 if (skb->ip_summed == CHECKSUM_PARTIAL) { in __ieee80211_subif_start_xmit()
3878 next = skb->next; in __ieee80211_subif_start_xmit()
3880 skb->prev = NULL; in __ieee80211_subif_start_xmit()
3881 skb->next = NULL; in __ieee80211_subif_start_xmit()
3886 goto out; in __ieee80211_subif_start_xmit()
3888 ieee80211_tx_stats(dev, skb->len); in __ieee80211_subif_start_xmit()
3892 goto out; in __ieee80211_subif_start_xmit()
3895 out: in __ieee80211_subif_start_xmit()
3908 eth = (void *)skb->data; in ieee80211_change_da()
3909 ether_addr_copy(eth->h_dest, sta->sta.addr); in ieee80211_change_da()
3918 const struct ethhdr *eth = (void *)skb->data; in ieee80211_multicast_to_unicast()
3919 const struct vlan_ethhdr *ethvlan = (void *)skb->data; in ieee80211_multicast_to_unicast()
3922 if (likely(!is_multicast_ether_addr(eth->h_dest))) in ieee80211_multicast_to_unicast()
3925 switch (sdata->vif.type) { in ieee80211_multicast_to_unicast()
3927 if (sdata->u.vlan.sta) in ieee80211_multicast_to_unicast()
3929 if (sdata->wdev.use_4addr) in ieee80211_multicast_to_unicast()
3934 if (!sdata->bss->multicast_to_unicast) in ieee80211_multicast_to_unicast()
3942 ethertype = eth->h_proto; in ieee80211_multicast_to_unicast()
3943 if (ethertype == htons(ETH_P_8021Q) && skb->len >= VLAN_ETH_HLEN) in ieee80211_multicast_to_unicast()
3944 ethertype = ethvlan->h_vlan_encapsulated_proto; in ieee80211_multicast_to_unicast()
3962 struct ieee80211_local *local = sdata->local; in ieee80211_convert_to_unicast()
3963 const struct ethhdr *eth = (struct ethhdr *)skb->data; in ieee80211_convert_to_unicast()
3969 list_for_each_entry_rcu(sta, &local->sta_list, list) { in ieee80211_convert_to_unicast()
3970 if (sdata != sta->sdata) in ieee80211_convert_to_unicast()
3971 /* AP-VLAN mismatch */ in ieee80211_convert_to_unicast()
3973 if (unlikely(ether_addr_equal(eth->h_source, sta->sta.addr))) in ieee80211_convert_to_unicast()
4000 goto out; in ieee80211_convert_to_unicast()
4004 out: in ieee80211_convert_to_unicast()
4009 * ieee80211_subif_start_xmit - netif start_xmit function for 802.3 vifs
4038 .local = sdata->local, in ieee80211_build_data_template()
4047 skb = ERR_PTR(-EINVAL); in ieee80211_build_data_template()
4048 goto out; in ieee80211_build_data_template()
4053 goto out; in ieee80211_build_data_template()
4055 hdr = (void *)skb->data; in ieee80211_build_data_template()
4056 tx.sta = sta_info_get(sdata, hdr->addr1); in ieee80211_build_data_template()
4062 return ERR_PTR(-EINVAL); in ieee80211_build_data_template()
4065 out: in ieee80211_build_data_template()
4079 for (i = 0; i < local->hw.queues; i++) { in ieee80211_clear_tx_pending()
4080 while ((skb = skb_dequeue(&local->pending[i])) != NULL) in ieee80211_clear_tx_pending()
4081 ieee80211_free_txskb(&local->hw, skb); in ieee80211_clear_tx_pending()
4087 * which in this case means re-queued -- take as an indication to stop sending
4100 sdata = vif_to_sdata(info->control.vif); in ieee80211_tx_pending_skb()
4102 if (info->flags & IEEE80211_TX_INTFL_NEED_TXPROCESSING) { in ieee80211_tx_pending_skb()
4103 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); in ieee80211_tx_pending_skb()
4108 info->band = chanctx_conf->def.chan->band; in ieee80211_tx_pending_skb()
4116 hdr = (struct ieee80211_hdr *)skb->data; in ieee80211_tx_pending_skb()
4117 sta = sta_info_get(sdata, hdr->addr1); in ieee80211_tx_pending_skb()
4119 result = __ieee80211_tx(local, &skbs, skb->len, sta, true); in ieee80211_tx_pending_skb()
4137 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); in ieee80211_tx_pending()
4138 for (i = 0; i < local->hw.queues; i++) { in ieee80211_tx_pending()
4143 if (local->queue_stop_reasons[i] || in ieee80211_tx_pending()
4144 skb_queue_empty(&local->pending[i])) in ieee80211_tx_pending()
4147 while (!skb_queue_empty(&local->pending[i])) { in ieee80211_tx_pending()
4148 struct sk_buff *skb = __skb_dequeue(&local->pending[i]); in ieee80211_tx_pending()
4151 if (WARN_ON(!info->control.vif)) { in ieee80211_tx_pending()
4152 ieee80211_free_txskb(&local->hw, skb); in ieee80211_tx_pending()
4156 spin_unlock_irqrestore(&local->queue_stop_reason_lock, in ieee80211_tx_pending()
4160 spin_lock_irqsave(&local->queue_stop_reason_lock, in ieee80211_tx_pending()
4166 if (skb_queue_empty(&local->pending[i])) in ieee80211_tx_pending()
4169 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); in ieee80211_tx_pending()
4186 if (atomic_read(&ps->num_sta_ps) > 0) in __ieee80211_beacon_add_tim()
4188 * checking byte-for-byte */ in __ieee80211_beacon_add_tim()
4189 have_bits = !bitmap_empty((unsigned long *)ps->tim, in __ieee80211_beacon_add_tim()
4192 if (ps->dtim_count == 0) in __ieee80211_beacon_add_tim()
4193 ps->dtim_count = sdata->vif.bss_conf.dtim_period - 1; in __ieee80211_beacon_add_tim()
4195 ps->dtim_count--; in __ieee80211_beacon_add_tim()
4201 *pos++ = ps->dtim_count; in __ieee80211_beacon_add_tim()
4202 *pos++ = sdata->vif.bss_conf.dtim_period; in __ieee80211_beacon_add_tim()
4204 if (ps->dtim_count == 0 && !skb_queue_empty(&ps->bc_buf)) in __ieee80211_beacon_add_tim()
4207 ps->dtim_bc_mc = aid0 == 1; in __ieee80211_beacon_add_tim()
4211 * (N1 x 8) - 1 in the bitmap are 0 and number N2 so that bits in __ieee80211_beacon_add_tim()
4215 if (ps->tim[i]) { in __ieee80211_beacon_add_tim()
4221 for (i = IEEE80211_MAX_TIM_LEN - 1; i >= n1; i--) { in __ieee80211_beacon_add_tim()
4222 if (ps->tim[i]) { in __ieee80211_beacon_add_tim()
4231 skb_put(skb, n2 - n1); in __ieee80211_beacon_add_tim()
4232 memcpy(pos, ps->tim + n1, n2 - n1 + 1); in __ieee80211_beacon_add_tim()
4234 tim[1] = n2 - n1 + 4; in __ieee80211_beacon_add_tim()
4245 struct ieee80211_local *local = sdata->local; in ieee80211_beacon_add_tim()
4251 * sta_lock to guarantee consistent and race-free update in ieee80211_beacon_add_tim()
4252 * of the tim bitmap in mac80211 and the driver. in ieee80211_beacon_add_tim()
4254 if (local->tim_in_locked_section) { in ieee80211_beacon_add_tim()
4257 spin_lock_bh(&local->tim_lock); in ieee80211_beacon_add_tim()
4259 spin_unlock_bh(&local->tim_lock); in ieee80211_beacon_add_tim()
4272 u8 count = beacon->csa_current_counter; in ieee80211_set_csa()
4274 switch (sdata->vif.type) { in ieee80211_set_csa()
4276 beacon_data = beacon->tail; in ieee80211_set_csa()
4277 beacon_data_len = beacon->tail_len; in ieee80211_set_csa()
4280 beacon_data = beacon->head; in ieee80211_set_csa()
4281 beacon_data_len = beacon->head_len; in ieee80211_set_csa()
4284 beacon_data = beacon->head; in ieee80211_set_csa()
4285 beacon_data_len = beacon->head_len; in ieee80211_set_csa()
4293 resp = rcu_dereference(sdata->u.ap.probe_resp); in ieee80211_set_csa()
4295 if (beacon->csa_counter_offsets[i]) { in ieee80211_set_csa()
4296 if (WARN_ON_ONCE(beacon->csa_counter_offsets[i] >= in ieee80211_set_csa()
4302 beacon_data[beacon->csa_counter_offsets[i]] = count; in ieee80211_set_csa()
4305 if (sdata->vif.type == NL80211_IFTYPE_AP && resp) in ieee80211_set_csa()
4306 resp->data[resp->csa_counter_offsets[i]] = count; in ieee80211_set_csa()
4313 beacon->csa_current_counter--; in __ieee80211_csa_update_counter()
4316 WARN_ON_ONCE(!beacon->csa_current_counter); in __ieee80211_csa_update_counter()
4318 return beacon->csa_current_counter; in __ieee80211_csa_update_counter()
4329 if (sdata->vif.type == NL80211_IFTYPE_AP) in ieee80211_csa_update_counter()
4330 beacon = rcu_dereference(sdata->u.ap.beacon); in ieee80211_csa_update_counter()
4331 else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) in ieee80211_csa_update_counter()
4332 beacon = rcu_dereference(sdata->u.ibss.presp); in ieee80211_csa_update_counter()
4333 else if (ieee80211_vif_is_mesh(&sdata->vif)) in ieee80211_csa_update_counter()
4334 beacon = rcu_dereference(sdata->u.mesh.beacon); in ieee80211_csa_update_counter()
4354 if (sdata->vif.type == NL80211_IFTYPE_AP) in ieee80211_csa_set_counter()
4355 beacon = rcu_dereference(sdata->u.ap.beacon); in ieee80211_csa_set_counter()
4356 else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) in ieee80211_csa_set_counter()
4357 beacon = rcu_dereference(sdata->u.ibss.presp); in ieee80211_csa_set_counter()
4358 else if (ieee80211_vif_is_mesh(&sdata->vif)) in ieee80211_csa_set_counter()
4359 beacon = rcu_dereference(sdata->u.mesh.beacon); in ieee80211_csa_set_counter()
4364 if (counter < beacon->csa_current_counter) in ieee80211_csa_set_counter()
4365 beacon->csa_current_counter = counter; in ieee80211_csa_set_counter()
4384 if (vif->type == NL80211_IFTYPE_AP) { in ieee80211_csa_is_complete()
4385 struct ieee80211_if_ap *ap = &sdata->u.ap; in ieee80211_csa_is_complete()
4387 beacon = rcu_dereference(ap->beacon); in ieee80211_csa_is_complete()
4388 if (WARN_ON(!beacon || !beacon->tail)) in ieee80211_csa_is_complete()
4389 goto out; in ieee80211_csa_is_complete()
4390 beacon_data = beacon->tail; in ieee80211_csa_is_complete()
4391 beacon_data_len = beacon->tail_len; in ieee80211_csa_is_complete()
4392 } else if (vif->type == NL80211_IFTYPE_ADHOC) { in ieee80211_csa_is_complete()
4393 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; in ieee80211_csa_is_complete()
4395 beacon = rcu_dereference(ifibss->presp); in ieee80211_csa_is_complete()
4397 goto out; in ieee80211_csa_is_complete()
4399 beacon_data = beacon->head; in ieee80211_csa_is_complete()
4400 beacon_data_len = beacon->head_len; in ieee80211_csa_is_complete()
4401 } else if (vif->type == NL80211_IFTYPE_MESH_POINT) { in ieee80211_csa_is_complete()
4402 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; in ieee80211_csa_is_complete()
4404 beacon = rcu_dereference(ifmsh->beacon); in ieee80211_csa_is_complete()
4406 goto out; in ieee80211_csa_is_complete()
4408 beacon_data = beacon->head; in ieee80211_csa_is_complete()
4409 beacon_data_len = beacon->head_len; in ieee80211_csa_is_complete()
4412 goto out; in ieee80211_csa_is_complete()
4415 if (!beacon->csa_counter_offsets[0]) in ieee80211_csa_is_complete()
4416 goto out; in ieee80211_csa_is_complete()
4418 if (WARN_ON_ONCE(beacon->csa_counter_offsets[0] > beacon_data_len)) in ieee80211_csa_is_complete()
4419 goto out; in ieee80211_csa_is_complete()
4421 if (beacon_data[beacon->csa_counter_offsets[0]] == 1) in ieee80211_csa_is_complete()
4423 out: in ieee80211_csa_is_complete()
4441 enum nl80211_band band; in __ieee80211_beacon_get() local
4449 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); in __ieee80211_beacon_get()
4452 goto out; in __ieee80211_beacon_get()
4457 if (sdata->vif.type == NL80211_IFTYPE_AP) { in __ieee80211_beacon_get()
4458 struct ieee80211_if_ap *ap = &sdata->u.ap; in __ieee80211_beacon_get()
4460 beacon = rcu_dereference(ap->beacon); in __ieee80211_beacon_get()
4462 if (beacon->csa_counter_offsets[0]) { in __ieee80211_beacon_get()
4473 skb = dev_alloc_skb(local->tx_headroom + in __ieee80211_beacon_get()
4474 beacon->head_len + in __ieee80211_beacon_get()
4475 beacon->tail_len + 256 + in __ieee80211_beacon_get()
4476 local->hw.extra_beacon_tailroom); in __ieee80211_beacon_get()
4478 goto out; in __ieee80211_beacon_get()
4480 skb_reserve(skb, local->tx_headroom); in __ieee80211_beacon_get()
4481 skb_put_data(skb, beacon->head, beacon->head_len); in __ieee80211_beacon_get()
4483 ieee80211_beacon_add_tim(sdata, &ap->ps, skb, in __ieee80211_beacon_get()
4487 offs->tim_offset = beacon->head_len; in __ieee80211_beacon_get()
4488 offs->tim_length = skb->len - beacon->head_len; in __ieee80211_beacon_get()
4491 csa_off_base = skb->len; in __ieee80211_beacon_get()
4494 if (beacon->tail) in __ieee80211_beacon_get()
4495 skb_put_data(skb, beacon->tail, in __ieee80211_beacon_get()
4496 beacon->tail_len); in __ieee80211_beacon_get()
4498 goto out; in __ieee80211_beacon_get()
4499 } else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) { in __ieee80211_beacon_get()
4500 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; in __ieee80211_beacon_get()
4503 beacon = rcu_dereference(ifibss->presp); in __ieee80211_beacon_get()
4505 goto out; in __ieee80211_beacon_get()
4507 if (beacon->csa_counter_offsets[0]) { in __ieee80211_beacon_get()
4514 skb = dev_alloc_skb(local->tx_headroom + beacon->head_len + in __ieee80211_beacon_get()
4515 local->hw.extra_beacon_tailroom); in __ieee80211_beacon_get()
4517 goto out; in __ieee80211_beacon_get()
4518 skb_reserve(skb, local->tx_headroom); in __ieee80211_beacon_get()
4519 skb_put_data(skb, beacon->head, beacon->head_len); in __ieee80211_beacon_get()
4521 hdr = (struct ieee80211_hdr *) skb->data; in __ieee80211_beacon_get()
4522 hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | in __ieee80211_beacon_get()
4524 } else if (ieee80211_vif_is_mesh(&sdata->vif)) { in __ieee80211_beacon_get()
4525 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; in __ieee80211_beacon_get()
4527 beacon = rcu_dereference(ifmsh->beacon); in __ieee80211_beacon_get()
4529 goto out; in __ieee80211_beacon_get()
4531 if (beacon->csa_counter_offsets[0]) { in __ieee80211_beacon_get()
4543 if (ifmsh->sync_ops) in __ieee80211_beacon_get()
4544 ifmsh->sync_ops->adjust_tsf(sdata, beacon); in __ieee80211_beacon_get()
4546 skb = dev_alloc_skb(local->tx_headroom + in __ieee80211_beacon_get()
4547 beacon->head_len + in __ieee80211_beacon_get()
4549 beacon->tail_len + in __ieee80211_beacon_get()
4550 local->hw.extra_beacon_tailroom); in __ieee80211_beacon_get()
4552 goto out; in __ieee80211_beacon_get()
4553 skb_reserve(skb, local->tx_headroom); in __ieee80211_beacon_get()
4554 skb_put_data(skb, beacon->head, beacon->head_len); in __ieee80211_beacon_get()
4555 ieee80211_beacon_add_tim(sdata, &ifmsh->ps, skb, is_template); in __ieee80211_beacon_get()
4558 offs->tim_offset = beacon->head_len; in __ieee80211_beacon_get()
4559 offs->tim_length = skb->len - beacon->head_len; in __ieee80211_beacon_get()
4562 skb_put_data(skb, beacon->tail, beacon->tail_len); in __ieee80211_beacon_get()
4565 goto out; in __ieee80211_beacon_get()
4573 u16 csa_off = beacon->csa_counter_offsets[i]; in __ieee80211_beacon_get()
4578 offs->csa_counter_offs[i] = csa_off_base + csa_off; in __ieee80211_beacon_get()
4582 band = chanctx_conf->def.chan->band; in __ieee80211_beacon_get()
4586 info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; in __ieee80211_beacon_get()
4587 info->flags |= IEEE80211_TX_CTL_NO_ACK; in __ieee80211_beacon_get()
4588 info->band = band; in __ieee80211_beacon_get()
4592 txrc.sband = local->hw.wiphy->bands[band]; in __ieee80211_beacon_get()
4593 txrc.bss_conf = &sdata->vif.bss_conf; in __ieee80211_beacon_get()
4595 txrc.reported_rate.idx = -1; in __ieee80211_beacon_get()
4596 txrc.rate_idx_mask = sdata->rc_rateidx_mask[band]; in __ieee80211_beacon_get()
4600 info->control.vif = vif; in __ieee80211_beacon_get()
4602 info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT | in __ieee80211_beacon_get()
4605 out: in __ieee80211_beacon_get()
4640 !hw_to_local(hw)->monitors) in ieee80211_beacon_get_tim()
4669 if (sdata->vif.type != NL80211_IFTYPE_AP) in ieee80211_proberesp_get()
4674 ap = &sdata->u.ap; in ieee80211_proberesp_get()
4675 presp = rcu_dereference(ap->probe_resp); in ieee80211_proberesp_get()
4677 goto out; in ieee80211_proberesp_get()
4679 skb = dev_alloc_skb(presp->len); in ieee80211_proberesp_get()
4681 goto out; in ieee80211_proberesp_get()
4683 skb_put_data(skb, presp->data, presp->len); in ieee80211_proberesp_get()
4685 hdr = (struct ieee80211_hdr *) skb->data; in ieee80211_proberesp_get()
4686 memset(hdr->addr1, 0, sizeof(hdr->addr1)); in ieee80211_proberesp_get()
4688 out: in ieee80211_proberesp_get()
4703 if (WARN_ON(vif->type != NL80211_IFTYPE_STATION)) in ieee80211_pspoll_get()
4707 ifmgd = &sdata->u.mgd; in ieee80211_pspoll_get()
4708 local = sdata->local; in ieee80211_pspoll_get()
4710 skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*pspoll)); in ieee80211_pspoll_get()
4714 skb_reserve(skb, local->hw.extra_tx_headroom); in ieee80211_pspoll_get()
4717 pspoll->frame_control = cpu_to_le16(IEEE80211_FTYPE_CTL | in ieee80211_pspoll_get()
4719 pspoll->aid = cpu_to_le16(ifmgd->aid); in ieee80211_pspoll_get()
4721 /* aid in PS-Poll has its two MSBs each set to 1 */ in ieee80211_pspoll_get()
4722 pspoll->aid |= cpu_to_le16(1 << 15 | 1 << 14); in ieee80211_pspoll_get()
4724 memcpy(pspoll->bssid, ifmgd->bssid, ETH_ALEN); in ieee80211_pspoll_get()
4725 memcpy(pspoll->ta, vif->addr, ETH_ALEN); in ieee80211_pspoll_get()
4742 if (WARN_ON(vif->type != NL80211_IFTYPE_STATION)) in ieee80211_nullfunc_get()
4746 ifmgd = &sdata->u.mgd; in ieee80211_nullfunc_get()
4747 local = sdata->local; in ieee80211_nullfunc_get()
4753 sta = sta_info_get(sdata, ifmgd->bssid); in ieee80211_nullfunc_get()
4754 qos = sta && sta->sta.wme; in ieee80211_nullfunc_get()
4758 skb = dev_alloc_skb(local->hw.extra_tx_headroom + in ieee80211_nullfunc_get()
4763 skb_reserve(skb, local->hw.extra_tx_headroom); in ieee80211_nullfunc_get()
4766 nullfunc->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA | in ieee80211_nullfunc_get()
4775 nullfunc->frame_control |= in ieee80211_nullfunc_get()
4777 skb->priority = 7; in ieee80211_nullfunc_get()
4782 memcpy(nullfunc->addr1, ifmgd->bssid, ETH_ALEN); in ieee80211_nullfunc_get()
4783 memcpy(nullfunc->addr2, vif->addr, ETH_ALEN); in ieee80211_nullfunc_get()
4784 memcpy(nullfunc->addr3, ifmgd->bssid, ETH_ALEN); in ieee80211_nullfunc_get()
4803 skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*hdr) + in ieee80211_probereq_get()
4808 skb_reserve(skb, local->hw.extra_tx_headroom); in ieee80211_probereq_get()
4811 hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | in ieee80211_probereq_get()
4813 eth_broadcast_addr(hdr->addr1); in ieee80211_probereq_get()
4814 memcpy(hdr->addr2, src_addr, ETH_ALEN); in ieee80211_probereq_get()
4815 eth_broadcast_addr(hdr->addr3); in ieee80211_probereq_get()
4835 rts->frame_control = in ieee80211_rts_get()
4837 rts->duration = ieee80211_rts_duration(hw, vif, frame_len, in ieee80211_rts_get()
4839 memcpy(rts->ra, hdr->addr1, sizeof(rts->ra)); in ieee80211_rts_get()
4840 memcpy(rts->ta, hdr->addr2, sizeof(rts->ta)); in ieee80211_rts_get()
4851 cts->frame_control = in ieee80211_ctstoself_get()
4853 cts->duration = ieee80211_ctstoself_duration(hw, vif, in ieee80211_ctstoself_get()
4855 memcpy(cts->ra, hdr->addr1, sizeof(cts->ra)); in ieee80211_ctstoself_get()
4874 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); in ieee80211_get_buffered_bc()
4877 goto out; in ieee80211_get_buffered_bc()
4879 if (sdata->vif.type == NL80211_IFTYPE_AP) { in ieee80211_get_buffered_bc()
4881 rcu_dereference(sdata->u.ap.beacon); in ieee80211_get_buffered_bc()
4883 if (!beacon || !beacon->head) in ieee80211_get_buffered_bc()
4884 goto out; in ieee80211_get_buffered_bc()
4886 ps = &sdata->u.ap.ps; in ieee80211_get_buffered_bc()
4887 } else if (ieee80211_vif_is_mesh(&sdata->vif)) { in ieee80211_get_buffered_bc()
4888 ps = &sdata->u.mesh.ps; in ieee80211_get_buffered_bc()
4890 goto out; in ieee80211_get_buffered_bc()
4893 if (ps->dtim_count != 0 || !ps->dtim_bc_mc) in ieee80211_get_buffered_bc()
4894 goto out; /* send buffered bc/mc only after DTIM beacon */ in ieee80211_get_buffered_bc()
4897 skb = skb_dequeue(&ps->bc_buf); in ieee80211_get_buffered_bc()
4899 goto out; in ieee80211_get_buffered_bc()
4900 local->total_ps_buffered--; in ieee80211_get_buffered_bc()
4902 if (!skb_queue_empty(&ps->bc_buf) && skb->len >= 2) { in ieee80211_get_buffered_bc()
4904 (struct ieee80211_hdr *) skb->data; in ieee80211_get_buffered_bc()
4908 hdr->frame_control |= in ieee80211_get_buffered_bc()
4912 if (sdata->vif.type == NL80211_IFTYPE_AP) in ieee80211_get_buffered_bc()
4913 sdata = IEEE80211_DEV_TO_SUB_IF(skb->dev); in ieee80211_get_buffered_bc()
4922 info->band = chanctx_conf->def.chan->band; in ieee80211_get_buffered_bc()
4926 out: in ieee80211_get_buffered_bc()
4936 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_reserve_tid()
4937 struct ieee80211_local *local = sdata->local; in ieee80211_reserve_tid()
4941 lockdep_assert_held(&local->sta_mtx); in ieee80211_reserve_tid()
4944 switch (sdata->vif.type) { in ieee80211_reserve_tid()
4951 return -EINVAL; in ieee80211_reserve_tid()
4955 return -EINVAL; in ieee80211_reserve_tid()
4957 if (sta->reserved_tid == tid) { in ieee80211_reserve_tid()
4959 goto out; in ieee80211_reserve_tid()
4962 if (sta->reserved_tid != IEEE80211_TID_UNRESERVED) { in ieee80211_reserve_tid()
4964 ret = -EALREADY; in ieee80211_reserve_tid()
4965 goto out; in ieee80211_reserve_tid()
4968 ieee80211_stop_vif_queues(sdata->local, sdata, in ieee80211_reserve_tid()
4974 if (ieee80211_hw_check(&local->hw, AMPDU_AGGREGATION)) { in ieee80211_reserve_tid()
4980 queues = BIT(sdata->vif.hw_queue[ieee802_1d_to_ac[tid]]); in ieee80211_reserve_tid()
4983 sta->reserved_tid = tid; in ieee80211_reserve_tid()
4988 if (ieee80211_hw_check(&local->hw, AMPDU_AGGREGATION)) in ieee80211_reserve_tid()
4992 out: in ieee80211_reserve_tid()
5000 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_unreserve_tid()
5002 lockdep_assert_held(&sdata->local->sta_mtx); in ieee80211_unreserve_tid()
5005 switch (sdata->vif.type) { in ieee80211_unreserve_tid()
5015 if (tid != sta->reserved_tid) { in ieee80211_unreserve_tid()
5020 sta->reserved_tid = IEEE80211_TID_UNRESERVED; in ieee80211_unreserve_tid()
5026 enum nl80211_band band, u32 txdata_flags) in __ieee80211_tx_skb_tid_band() argument
5032 skb->priority = tid; in __ieee80211_tx_skb_tid_band()
5034 skb->dev = sdata->dev; in __ieee80211_tx_skb_tid_band()
5042 IEEE80211_SKB_CB(skb)->band = band; in __ieee80211_tx_skb_tid_band()
5052 struct ieee80211_local *local = sdata->local; in ieee80211_tx_control_port()
5058 * or Pre-Authentication in ieee80211_tx_control_port()
5060 if (proto != sdata->control_port_protocol && in ieee80211_tx_control_port()
5062 return -EINVAL; in ieee80211_tx_control_port()
5069 skb = dev_alloc_skb(local->hw.extra_tx_headroom + in ieee80211_tx_control_port()
5072 return -ENOMEM; in ieee80211_tx_control_port()
5074 skb_reserve(skb, local->hw.extra_tx_headroom + sizeof(struct ethhdr)); in ieee80211_tx_control_port()
5079 memcpy(ehdr->h_dest, dest, ETH_ALEN); in ieee80211_tx_control_port()
5080 memcpy(ehdr->h_source, sdata->vif.addr, ETH_ALEN); in ieee80211_tx_control_port()
5081 ehdr->h_proto = proto; in ieee80211_tx_control_port()
5083 skb->dev = dev; in ieee80211_tx_control_port()
5084 skb->protocol = htons(ETH_P_802_3); in ieee80211_tx_control_port()
5089 __ieee80211_subif_start_xmit(skb, skb->dev, flags, 0); in ieee80211_tx_control_port()
5099 struct ieee80211_local *local = sdata->local; in ieee80211_probe_mesh_link()
5102 skb = dev_alloc_skb(local->hw.extra_tx_headroom + len + in ieee80211_probe_mesh_link()
5106 return -ENOMEM; in ieee80211_probe_mesh_link()
5108 skb_reserve(skb, local->hw.extra_tx_headroom); in ieee80211_probe_mesh_link()
5111 skb->dev = dev; in ieee80211_probe_mesh_link()
5112 skb->protocol = htons(ETH_P_802_3); in ieee80211_probe_mesh_link()
5117 __ieee80211_subif_start_xmit(skb, skb->dev, 0, in ieee80211_probe_mesh_link()