Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    3)  * Copyright 2002-2005, Instant802 Networks, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    4)  * Copyright 2005-2006, Devicescape Software, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    5)  * Copyright 2006-2007	Jiri Benc <jbenc@suse.cz>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    6)  * Copyright 2008-2010	Johannes Berg <johannes@sipsolutions.net>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    7)  * Copyright 2013-2014  Intel Mobile Communications GmbH
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    8)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   10) #include <linux/export.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   11) #include <linux/etherdevice.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   12) #include <net/mac80211.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   13) #include <asm/unaligned.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   14) #include "ieee80211_i.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   15) #include "rate.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   16) #include "mesh.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   17) #include "led.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   18) #include "wme.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   21) void ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   22) 				 struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   23) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   24) 	struct ieee80211_local *local = hw_to_local(hw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   25) 	struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   26) 	int tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   28) 	skb->pkt_type = IEEE80211_TX_STATUS_MSG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   29) 	skb_queue_tail(info->flags & IEEE80211_TX_CTL_REQ_TX_STATUS ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   30) 		       &local->skb_queue : &local->skb_queue_unreliable, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   31) 	tmp = skb_queue_len(&local->skb_queue) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   32) 		skb_queue_len(&local->skb_queue_unreliable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   33) 	while (tmp > IEEE80211_IRQSAFE_QUEUE_LIMIT &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   34) 	       (skb = skb_dequeue(&local->skb_queue_unreliable))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   35) 		ieee80211_free_txskb(hw, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   36) 		tmp--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   37) 		I802_DEBUG_INC(local->tx_status_drop);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   38) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   39) 	tasklet_schedule(&local->tasklet);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   40) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   41) EXPORT_SYMBOL(ieee80211_tx_status_irqsafe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   43) static void ieee80211_handle_filtered_frame(struct ieee80211_local *local,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   44) 					    struct sta_info *sta,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   45) 					    struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   46) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   47) 	struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   48) 	struct ieee80211_hdr *hdr = (void *)skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   49) 	int ac;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   51) 	if (info->flags & (IEEE80211_TX_CTL_NO_PS_BUFFER |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   52) 			   IEEE80211_TX_CTL_AMPDU |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   53) 			   IEEE80211_TX_CTL_HW_80211_ENCAP)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   54) 		ieee80211_free_txskb(&local->hw, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   55) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   56) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   58) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   59) 	 * This skb 'survived' a round-trip through the driver, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   60) 	 * hopefully the driver didn't mangle it too badly. However,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   61) 	 * we can definitely not rely on the control information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   62) 	 * being correct. Clear it so we don't get junk there, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   63) 	 * indicate that it needs new processing, but must not be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   64) 	 * modified/encrypted again.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   65) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   66) 	memset(&info->control, 0, sizeof(info->control));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   68) 	info->control.jiffies = jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   69) 	info->control.vif = &sta->sdata->vif;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   70) 	info->control.flags |= IEEE80211_TX_INTCFL_NEED_TXPROCESSING;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   71) 	info->flags |= IEEE80211_TX_INTFL_RETRANSMISSION;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   72) 	info->flags &= ~IEEE80211_TX_TEMPORARY_FLAGS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   74) 	sta->status_stats.filtered++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   76) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   77) 	 * Clear more-data bit on filtered frames, it might be set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   78) 	 * but later frames might time out so it might have to be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   79) 	 * clear again ... It's all rather unlikely (this frame
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   80) 	 * should time out first, right?) but let's not confuse
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   81) 	 * peers unnecessarily.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   82) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   83) 	if (hdr->frame_control & cpu_to_le16(IEEE80211_FCTL_MOREDATA))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   84) 		hdr->frame_control &= ~cpu_to_le16(IEEE80211_FCTL_MOREDATA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   86) 	if (ieee80211_is_data_qos(hdr->frame_control)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   87) 		u8 *p = ieee80211_get_qos_ctl(hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   88) 		int tid = *p & IEEE80211_QOS_CTL_TID_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   90) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   91) 		 * Clear EOSP if set, this could happen e.g.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   92) 		 * if an absence period (us being a P2P GO)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   93) 		 * shortens the SP.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   94) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   95) 		if (*p & IEEE80211_QOS_CTL_EOSP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   96) 			*p &= ~IEEE80211_QOS_CTL_EOSP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   97) 		ac = ieee80211_ac_from_tid(tid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   98) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   99) 		ac = IEEE80211_AC_BE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  100) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  102) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  103) 	 * Clear the TX filter mask for this STA when sending the next
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  104) 	 * packet. If the STA went to power save mode, this will happen
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  105) 	 * when it wakes up for the next time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  106) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  107) 	set_sta_flag(sta, WLAN_STA_CLEAR_PS_FILT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  108) 	ieee80211_clear_fast_xmit(sta);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  110) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  111) 	 * This code races in the following way:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  112) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  113) 	 *  (1) STA sends frame indicating it will go to sleep and does so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  114) 	 *  (2) hardware/firmware adds STA to filter list, passes frame up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  115) 	 *  (3) hardware/firmware processes TX fifo and suppresses a frame
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  116) 	 *  (4) we get TX status before having processed the frame and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  117) 	 *	knowing that the STA has gone to sleep.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  118) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  119) 	 * This is actually quite unlikely even when both those events are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  120) 	 * processed from interrupts coming in quickly after one another or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  121) 	 * even at the same time because we queue both TX status events and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  122) 	 * RX frames to be processed by a tasklet and process them in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  123) 	 * same order that they were received or TX status last. Hence, there
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  124) 	 * is no race as long as the frame RX is processed before the next TX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  125) 	 * status, which drivers can ensure, see below.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  126) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  127) 	 * Note that this can only happen if the hardware or firmware can
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  128) 	 * actually add STAs to the filter list, if this is done by the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  129) 	 * driver in response to set_tim() (which will only reduce the race
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  130) 	 * this whole filtering tries to solve, not completely solve it)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  131) 	 * this situation cannot happen.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  132) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  133) 	 * To completely solve this race drivers need to make sure that they
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  134) 	 *  (a) don't mix the irq-safe/not irq-safe TX status/RX processing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  135) 	 *	functions and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  136) 	 *  (b) always process RX events before TX status events if ordering
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  137) 	 *      can be unknown, for example with different interrupt status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  138) 	 *	bits.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  139) 	 *  (c) if PS mode transitions are manual (i.e. the flag
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  140) 	 *      %IEEE80211_HW_AP_LINK_PS is set), always process PS state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  141) 	 *      changes before calling TX status events if ordering can be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  142) 	 *	unknown.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  143) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  144) 	if (test_sta_flag(sta, WLAN_STA_PS_STA) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  145) 	    skb_queue_len(&sta->tx_filtered[ac]) < STA_MAX_TX_BUFFER) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  146) 		skb_queue_tail(&sta->tx_filtered[ac], skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  147) 		sta_info_recalc_tim(sta);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  149) 		if (!timer_pending(&local->sta_cleanup))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  150) 			mod_timer(&local->sta_cleanup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  151) 				  round_jiffies(jiffies +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  152) 						STA_INFO_CLEANUP_INTERVAL));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  153) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  154) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  155) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  156) 	if (!test_sta_flag(sta, WLAN_STA_PS_STA) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  157) 	    !(info->flags & IEEE80211_TX_INTFL_RETRIED)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  158) 		/* Software retry the packet once */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  159) 		info->flags |= IEEE80211_TX_INTFL_RETRIED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  160) 		ieee80211_add_pending_skb(local, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  161) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  162) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  163) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  164) 	ps_dbg_ratelimited(sta->sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  165) 			   "dropped TX filtered frame, queue_len=%d PS=%d @%lu\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  166) 			   skb_queue_len(&sta->tx_filtered[ac]),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  167) 			   !!test_sta_flag(sta, WLAN_STA_PS_STA), jiffies);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  168) 	ieee80211_free_txskb(&local->hw, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  169) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  170) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  171) static void ieee80211_check_pending_bar(struct sta_info *sta, u8 *addr, u8 tid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  172) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  173) 	struct tid_ampdu_tx *tid_tx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  174) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  175) 	tid_tx = rcu_dereference(sta->ampdu_mlme.tid_tx[tid]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  176) 	if (!tid_tx || !tid_tx->bar_pending)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  177) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  178) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  179) 	tid_tx->bar_pending = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  180) 	ieee80211_send_bar(&sta->sdata->vif, addr, tid, tid_tx->failed_bar_ssn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  181) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  182) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  183) static void ieee80211_frame_acked(struct sta_info *sta, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  184) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  185) 	struct ieee80211_mgmt *mgmt = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  186) 	struct ieee80211_local *local = sta->local;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  187) 	struct ieee80211_sub_if_data *sdata = sta->sdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  188) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  189) 	if (ieee80211_is_data_qos(mgmt->frame_control)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  190) 		struct ieee80211_hdr *hdr = (void *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  191) 		u8 *qc = ieee80211_get_qos_ctl(hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  192) 		u16 tid = qc[0] & 0xf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  193) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  194) 		ieee80211_check_pending_bar(sta, hdr->addr1, tid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  195) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  196) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  197) 	if (ieee80211_is_action(mgmt->frame_control) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  198) 	    !ieee80211_has_protected(mgmt->frame_control) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  199) 	    mgmt->u.action.category == WLAN_CATEGORY_HT &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  200) 	    mgmt->u.action.u.ht_smps.action == WLAN_HT_ACTION_SMPS &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  201) 	    ieee80211_sdata_running(sdata)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  202) 		enum ieee80211_smps_mode smps_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  203) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  204) 		switch (mgmt->u.action.u.ht_smps.smps_control) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  205) 		case WLAN_HT_SMPS_CONTROL_DYNAMIC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  206) 			smps_mode = IEEE80211_SMPS_DYNAMIC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  207) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  208) 		case WLAN_HT_SMPS_CONTROL_STATIC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  209) 			smps_mode = IEEE80211_SMPS_STATIC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  210) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  211) 		case WLAN_HT_SMPS_CONTROL_DISABLED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  212) 		default: /* shouldn't happen since we don't send that */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  213) 			smps_mode = IEEE80211_SMPS_OFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  214) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  215) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  216) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  217) 		if (sdata->vif.type == NL80211_IFTYPE_STATION) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  218) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  219) 			 * This update looks racy, but isn't -- if we come
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  220) 			 * here we've definitely got a station that we're
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  221) 			 * talking to, and on a managed interface that can
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  222) 			 * only be the AP. And the only other place updating
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  223) 			 * this variable in managed mode is before association.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  224) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  225) 			sdata->smps_mode = smps_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  226) 			ieee80211_queue_work(&local->hw, &sdata->recalc_smps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  227) 		} else if (sdata->vif.type == NL80211_IFTYPE_AP ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  228) 			   sdata->vif.type == NL80211_IFTYPE_AP_VLAN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  229) 			sta->known_smps_mode = smps_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  230) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  231) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  232) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  233) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  234) static void ieee80211_set_bar_pending(struct sta_info *sta, u8 tid, u16 ssn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  235) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  236) 	struct tid_ampdu_tx *tid_tx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  237) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  238) 	tid_tx = rcu_dereference(sta->ampdu_mlme.tid_tx[tid]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  239) 	if (!tid_tx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  240) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  241) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  242) 	tid_tx->failed_bar_ssn = ssn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  243) 	tid_tx->bar_pending = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  244) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  245) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  246) static int ieee80211_tx_radiotap_len(struct ieee80211_tx_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  247) 				     struct ieee80211_tx_status *status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  248) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  249) 	int len = sizeof(struct ieee80211_radiotap_header);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  250) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  251) 	/* IEEE80211_RADIOTAP_RATE rate */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  252) 	if (status && status->rate && !(status->rate->flags &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  253) 					(RATE_INFO_FLAGS_MCS |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  254) 					 RATE_INFO_FLAGS_DMG |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  255) 					 RATE_INFO_FLAGS_EDMG |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  256) 					 RATE_INFO_FLAGS_VHT_MCS |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  257) 					 RATE_INFO_FLAGS_HE_MCS)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  258) 		len += 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  259) 	else if (info->status.rates[0].idx >= 0 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  260) 		 !(info->status.rates[0].flags &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  261) 		   (IEEE80211_TX_RC_MCS | IEEE80211_TX_RC_VHT_MCS)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  262) 		len += 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  263) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  264) 	/* IEEE80211_RADIOTAP_TX_FLAGS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  265) 	len += 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  266) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  267) 	/* IEEE80211_RADIOTAP_DATA_RETRIES */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  268) 	len += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  269) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  270) 	/* IEEE80211_RADIOTAP_MCS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  271) 	 * IEEE80211_RADIOTAP_VHT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  272) 	if (status && status->rate) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  273) 		if (status->rate->flags & RATE_INFO_FLAGS_MCS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  274) 			len += 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  275) 		else if (status->rate->flags & RATE_INFO_FLAGS_VHT_MCS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  276) 			len = ALIGN(len, 2) + 12;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  277) 		else if (status->rate->flags & RATE_INFO_FLAGS_HE_MCS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  278) 			len = ALIGN(len, 2) + 12;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  279) 	} else if (info->status.rates[0].idx >= 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  280) 		if (info->status.rates[0].flags & IEEE80211_TX_RC_MCS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  281) 			len += 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  282) 		else if (info->status.rates[0].flags & IEEE80211_TX_RC_VHT_MCS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  283) 			len = ALIGN(len, 2) + 12;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  284) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  285) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  286) 	return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  287) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  288) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  289) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  290) ieee80211_add_tx_radiotap_header(struct ieee80211_local *local,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  291) 				 struct ieee80211_supported_band *sband,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  292) 				 struct sk_buff *skb, int retry_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  293) 				 int rtap_len, int shift,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  294) 				 struct ieee80211_tx_status *status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  295) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  296) 	struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  297) 	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  298) 	struct ieee80211_radiotap_header *rthdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  299) 	unsigned char *pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  300) 	u16 legacy_rate = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  301) 	u16 txflags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  302) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  303) 	rthdr = skb_push(skb, rtap_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  304) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  305) 	memset(rthdr, 0, rtap_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  306) 	rthdr->it_len = cpu_to_le16(rtap_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  307) 	rthdr->it_present =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  308) 		cpu_to_le32((1 << IEEE80211_RADIOTAP_TX_FLAGS) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  309) 			    (1 << IEEE80211_RADIOTAP_DATA_RETRIES));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  310) 	pos = (unsigned char *)(rthdr + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  311) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  312) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  313) 	 * XXX: Once radiotap gets the bitmap reset thing the vendor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  314) 	 *	extensions proposal contains, we can actually report
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  315) 	 *	the whole set of tries we did.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  316) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  317) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  318) 	/* IEEE80211_RADIOTAP_RATE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  319) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  320) 	if (status && status->rate) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  321) 		if (!(status->rate->flags & (RATE_INFO_FLAGS_MCS |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  322) 					     RATE_INFO_FLAGS_DMG |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  323) 					     RATE_INFO_FLAGS_EDMG |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  324) 					     RATE_INFO_FLAGS_VHT_MCS |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  325) 					     RATE_INFO_FLAGS_HE_MCS)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  326) 			legacy_rate = status->rate->legacy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  327) 	} else if (info->status.rates[0].idx >= 0 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  328) 		 !(info->status.rates[0].flags & (IEEE80211_TX_RC_MCS |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  329) 						  IEEE80211_TX_RC_VHT_MCS)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  330) 		legacy_rate =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  331) 			sband->bitrates[info->status.rates[0].idx].bitrate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  332) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  333) 	if (legacy_rate) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  334) 		rthdr->it_present |= cpu_to_le32(1 << IEEE80211_RADIOTAP_RATE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  335) 		*pos = DIV_ROUND_UP(legacy_rate, 5 * (1 << shift));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  336) 		/* padding for tx flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  337) 		pos += 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  338) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  339) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  340) 	/* IEEE80211_RADIOTAP_TX_FLAGS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  341) 	txflags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  342) 	if (!(info->flags & IEEE80211_TX_STAT_ACK) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  343) 	    !is_multicast_ether_addr(hdr->addr1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  344) 		txflags |= IEEE80211_RADIOTAP_F_TX_FAIL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  345) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  346) 	if (info->status.rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  347) 		txflags |= IEEE80211_RADIOTAP_F_TX_CTS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  348) 	if (info->status.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  349) 		txflags |= IEEE80211_RADIOTAP_F_TX_RTS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  350) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  351) 	put_unaligned_le16(txflags, pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  352) 	pos += 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  353) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  354) 	/* IEEE80211_RADIOTAP_DATA_RETRIES */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  355) 	/* for now report the total retry_count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  356) 	*pos = retry_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  357) 	pos++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  358) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  359) 	if (status && status->rate &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  360) 	    (status->rate->flags & RATE_INFO_FLAGS_MCS)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  361) 		rthdr->it_present |= cpu_to_le32(1 << IEEE80211_RADIOTAP_MCS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  362) 		pos[0] = IEEE80211_RADIOTAP_MCS_HAVE_MCS |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  363) 			 IEEE80211_RADIOTAP_MCS_HAVE_GI |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  364) 			 IEEE80211_RADIOTAP_MCS_HAVE_BW;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  365) 		if (status->rate->flags & RATE_INFO_FLAGS_SHORT_GI)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  366) 			pos[1] |= IEEE80211_RADIOTAP_MCS_SGI;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  367) 		if (status->rate->bw == RATE_INFO_BW_40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  368) 			pos[1] |= IEEE80211_RADIOTAP_MCS_BW_40;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  369) 		pos[2] = status->rate->mcs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  370) 		pos += 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  371) 	} else if (status && status->rate &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  372) 		   (status->rate->flags & RATE_INFO_FLAGS_VHT_MCS)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  373) 		u16 known = local->hw.radiotap_vht_details &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  374) 			(IEEE80211_RADIOTAP_VHT_KNOWN_GI |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  375) 			 IEEE80211_RADIOTAP_VHT_KNOWN_BANDWIDTH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  376) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  377) 		rthdr->it_present |= cpu_to_le32(1 << IEEE80211_RADIOTAP_VHT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  378) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  379) 		/* required alignment from rthdr */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  380) 		pos = (u8 *)rthdr + ALIGN(pos - (u8 *)rthdr, 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  381) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  382) 		/* u16 known - IEEE80211_RADIOTAP_VHT_KNOWN_* */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  383) 		put_unaligned_le16(known, pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  384) 		pos += 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  385) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  386) 		/* u8 flags - IEEE80211_RADIOTAP_VHT_FLAG_* */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  387) 		if (status->rate->flags & RATE_INFO_FLAGS_SHORT_GI)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  388) 			*pos |= IEEE80211_RADIOTAP_VHT_FLAG_SGI;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  389) 		pos++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  390) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  391) 		/* u8 bandwidth */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  392) 		switch (status->rate->bw) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  393) 		case RATE_INFO_BW_160:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  394) 			*pos = 11;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  395) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  396) 		case RATE_INFO_BW_80:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  397) 			*pos = 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  398) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  399) 		case RATE_INFO_BW_40:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  400) 			*pos = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  401) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  402) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  403) 			*pos = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  404) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  405) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  406) 		pos++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  407) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  408) 		/* u8 mcs_nss[4] */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  409) 		*pos = (status->rate->mcs << 4) | status->rate->nss;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  410) 		pos += 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  411) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  412) 		/* u8 coding */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  413) 		pos++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  414) 		/* u8 group_id */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  415) 		pos++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  416) 		/* u16 partial_aid */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  417) 		pos += 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  418) 	} else if (status && status->rate &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  419) 		   (status->rate->flags & RATE_INFO_FLAGS_HE_MCS)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  420) 		struct ieee80211_radiotap_he *he;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  421) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  422) 		rthdr->it_present |= cpu_to_le32(1 << IEEE80211_RADIOTAP_HE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  423) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  424) 		/* required alignment from rthdr */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  425) 		pos = (u8 *)rthdr + ALIGN(pos - (u8 *)rthdr, 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  426) 		he = (struct ieee80211_radiotap_he *)pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  427) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  428) 		he->data1 = cpu_to_le16(IEEE80211_RADIOTAP_HE_DATA1_FORMAT_SU |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  429) 					IEEE80211_RADIOTAP_HE_DATA1_DATA_MCS_KNOWN |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  430) 					IEEE80211_RADIOTAP_HE_DATA1_DATA_DCM_KNOWN |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  431) 					IEEE80211_RADIOTAP_HE_DATA1_BW_RU_ALLOC_KNOWN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  432) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  433) 		he->data2 = cpu_to_le16(IEEE80211_RADIOTAP_HE_DATA2_GI_KNOWN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  434) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  435) #define HE_PREP(f, val) le16_encode_bits(val, IEEE80211_RADIOTAP_HE_##f)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  436) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  437) 		he->data6 |= HE_PREP(DATA6_NSTS, status->rate->nss);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  438) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  439) #define CHECK_GI(s) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  440) 	BUILD_BUG_ON(IEEE80211_RADIOTAP_HE_DATA5_GI_##s != \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  441) 	(int)NL80211_RATE_INFO_HE_GI_##s)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  442) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  443) 		CHECK_GI(0_8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  444) 		CHECK_GI(1_6);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  445) 		CHECK_GI(3_2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  446) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  447) 		he->data3 |= HE_PREP(DATA3_DATA_MCS, status->rate->mcs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  448) 		he->data3 |= HE_PREP(DATA3_DATA_DCM, status->rate->he_dcm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  449) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  450) 		he->data5 |= HE_PREP(DATA5_GI, status->rate->he_gi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  451) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  452) 		switch (status->rate->bw) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  453) 		case RATE_INFO_BW_20:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  454) 			he->data5 |= HE_PREP(DATA5_DATA_BW_RU_ALLOC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  455) 					     IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_20MHZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  456) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  457) 		case RATE_INFO_BW_40:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  458) 			he->data5 |= HE_PREP(DATA5_DATA_BW_RU_ALLOC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  459) 					     IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_40MHZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  460) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  461) 		case RATE_INFO_BW_80:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  462) 			he->data5 |= HE_PREP(DATA5_DATA_BW_RU_ALLOC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  463) 					     IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_80MHZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  464) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  465) 		case RATE_INFO_BW_160:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  466) 			he->data5 |= HE_PREP(DATA5_DATA_BW_RU_ALLOC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  467) 					     IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_160MHZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  468) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  469) 		case RATE_INFO_BW_HE_RU:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  470) #define CHECK_RU_ALLOC(s) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  471) 	BUILD_BUG_ON(IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_##s##T != \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  472) 	NL80211_RATE_INFO_HE_RU_ALLOC_##s + 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  473) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  474) 			CHECK_RU_ALLOC(26);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  475) 			CHECK_RU_ALLOC(52);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  476) 			CHECK_RU_ALLOC(106);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  477) 			CHECK_RU_ALLOC(242);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  478) 			CHECK_RU_ALLOC(484);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  479) 			CHECK_RU_ALLOC(996);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  480) 			CHECK_RU_ALLOC(2x996);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  481) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  482) 			he->data5 |= HE_PREP(DATA5_DATA_BW_RU_ALLOC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  483) 					     status->rate->he_ru_alloc + 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  484) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  485) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  486) 			WARN_ONCE(1, "Invalid SU BW %d\n", status->rate->bw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  487) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  488) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  489) 		pos += sizeof(struct ieee80211_radiotap_he);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  490) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  491) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  492) 	if ((status && status->rate) || info->status.rates[0].idx < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  493) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  494) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  495) 	/* IEEE80211_RADIOTAP_MCS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  496) 	 * IEEE80211_RADIOTAP_VHT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  497) 	if (info->status.rates[0].flags & IEEE80211_TX_RC_MCS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  498) 		rthdr->it_present |= cpu_to_le32(1 << IEEE80211_RADIOTAP_MCS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  499) 		pos[0] = IEEE80211_RADIOTAP_MCS_HAVE_MCS |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  500) 			 IEEE80211_RADIOTAP_MCS_HAVE_GI |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  501) 			 IEEE80211_RADIOTAP_MCS_HAVE_BW;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  502) 		if (info->status.rates[0].flags & IEEE80211_TX_RC_SHORT_GI)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  503) 			pos[1] |= IEEE80211_RADIOTAP_MCS_SGI;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  504) 		if (info->status.rates[0].flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  505) 			pos[1] |= IEEE80211_RADIOTAP_MCS_BW_40;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  506) 		if (info->status.rates[0].flags & IEEE80211_TX_RC_GREEN_FIELD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  507) 			pos[1] |= IEEE80211_RADIOTAP_MCS_FMT_GF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  508) 		pos[2] = info->status.rates[0].idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  509) 		pos += 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  510) 	} else if (info->status.rates[0].flags & IEEE80211_TX_RC_VHT_MCS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  511) 		u16 known = local->hw.radiotap_vht_details &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  512) 			(IEEE80211_RADIOTAP_VHT_KNOWN_GI |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  513) 			 IEEE80211_RADIOTAP_VHT_KNOWN_BANDWIDTH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  514) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  515) 		rthdr->it_present |= cpu_to_le32(1 << IEEE80211_RADIOTAP_VHT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  516) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  517) 		/* required alignment from rthdr */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  518) 		pos = (u8 *)rthdr + ALIGN(pos - (u8 *)rthdr, 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  519) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  520) 		/* u16 known - IEEE80211_RADIOTAP_VHT_KNOWN_* */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  521) 		put_unaligned_le16(known, pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  522) 		pos += 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  523) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  524) 		/* u8 flags - IEEE80211_RADIOTAP_VHT_FLAG_* */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  525) 		if (info->status.rates[0].flags & IEEE80211_TX_RC_SHORT_GI)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  526) 			*pos |= IEEE80211_RADIOTAP_VHT_FLAG_SGI;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  527) 		pos++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  528) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  529) 		/* u8 bandwidth */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  530) 		if (info->status.rates[0].flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  531) 			*pos = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  532) 		else if (info->status.rates[0].flags & IEEE80211_TX_RC_80_MHZ_WIDTH)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  533) 			*pos = 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  534) 		else if (info->status.rates[0].flags & IEEE80211_TX_RC_160_MHZ_WIDTH)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  535) 			*pos = 11;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  536) 		else /* IEEE80211_TX_RC_{20_MHZ_WIDTH,FIXME:DUP_DATA} */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  537) 			*pos = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  538) 		pos++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  539) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  540) 		/* u8 mcs_nss[4] */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  541) 		*pos = (ieee80211_rate_get_vht_mcs(&info->status.rates[0]) << 4) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  542) 			ieee80211_rate_get_vht_nss(&info->status.rates[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  543) 		pos += 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  544) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  545) 		/* u8 coding */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  546) 		pos++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  547) 		/* u8 group_id */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  548) 		pos++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  549) 		/* u16 partial_aid */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  550) 		pos += 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  551) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  552) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  553) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  554) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  555)  * Handles the tx for TDLS teardown frames.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  556)  * If the frame wasn't ACKed by the peer - it will be re-sent through the AP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  557)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  558) static void ieee80211_tdls_td_tx_handle(struct ieee80211_local *local,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  559) 					struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  560) 					struct sk_buff *skb, u32 flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  561) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  562) 	struct sk_buff *teardown_skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  563) 	struct sk_buff *orig_teardown_skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  564) 	bool is_teardown = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  565) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  566) 	/* Get the teardown data we need and free the lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  567) 	spin_lock(&sdata->u.mgd.teardown_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  568) 	teardown_skb = sdata->u.mgd.teardown_skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  569) 	orig_teardown_skb = sdata->u.mgd.orig_teardown_skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  570) 	if ((skb == orig_teardown_skb) && teardown_skb) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  571) 		sdata->u.mgd.teardown_skb = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  572) 		sdata->u.mgd.orig_teardown_skb = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  573) 		is_teardown = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  574) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  575) 	spin_unlock(&sdata->u.mgd.teardown_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  576) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  577) 	if (is_teardown) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  578) 		/* This mechanism relies on being able to get ACKs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  579) 		WARN_ON(!ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  580) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  581) 		/* Check if peer has ACKed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  582) 		if (flags & IEEE80211_TX_STAT_ACK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  583) 			dev_kfree_skb_any(teardown_skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  584) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  585) 			tdls_dbg(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  586) 				 "TDLS Resending teardown through AP\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  587) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  588) 			ieee80211_subif_start_xmit(teardown_skb, skb->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  589) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  590) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  591) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  592) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  593) static struct ieee80211_sub_if_data *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  594) ieee80211_sdata_from_skb(struct ieee80211_local *local, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  595) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  596) 	struct ieee80211_sub_if_data *sdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  597) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  598) 	if (skb->dev) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  599) 		list_for_each_entry_rcu(sdata, &local->interfaces, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  600) 			if (!sdata->dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  601) 				continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  602) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  603) 			if (skb->dev == sdata->dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  604) 				return sdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  605) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  606) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  607) 		return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  608) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  609) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  610) 	return rcu_dereference(local->p2p_sdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  611) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  612) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  613) static void ieee80211_report_ack_skb(struct ieee80211_local *local,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  614) 				     struct ieee80211_tx_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  615) 				     bool acked, bool dropped)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  616) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  617) 	struct sk_buff *skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  618) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  619) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  620) 	spin_lock_irqsave(&local->ack_status_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  621) 	skb = idr_remove(&local->ack_status_frames, info->ack_frame_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  622) 	spin_unlock_irqrestore(&local->ack_status_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  623) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  624) 	if (!skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  625) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  626) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  627) 	if (info->flags & IEEE80211_TX_INTFL_NL80211_FRAME_TX) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  628) 		u64 cookie = IEEE80211_SKB_CB(skb)->ack.cookie;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  629) 		struct ieee80211_sub_if_data *sdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  630) 		struct ieee80211_hdr *hdr = (void *)skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  631) 		__be16 ethertype = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  632) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  633) 		if (skb->len >= ETH_HLEN && skb->protocol == cpu_to_be16(ETH_P_802_3))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  634) 			skb_copy_bits(skb, 2 * ETH_ALEN, &ethertype, ETH_TLEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  635) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  636) 		rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  637) 		sdata = ieee80211_sdata_from_skb(local, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  638) 		if (sdata) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  639) 			if (ethertype == sdata->control_port_protocol ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  640) 			    ethertype == cpu_to_be16(ETH_P_PREAUTH))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  641) 				cfg80211_control_port_tx_status(&sdata->wdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  642) 								cookie,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  643) 								skb->data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  644) 								skb->len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  645) 								acked,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  646) 								GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  647) 			else if (ieee80211_is_any_nullfunc(hdr->frame_control))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  648) 				cfg80211_probe_status(sdata->dev, hdr->addr1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  649) 						      cookie, acked,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  650) 						      info->status.ack_signal,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  651) 						      info->status.is_valid_ack_signal,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  652) 						      GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  653) 			else if (ieee80211_is_mgmt(hdr->frame_control))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  654) 				cfg80211_mgmt_tx_status(&sdata->wdev, cookie,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  655) 							skb->data, skb->len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  656) 							acked, GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  657) 			else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  658) 				pr_warn("Unknown status report in ack skb\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  659) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  660) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  661) 		rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  662) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  663) 		dev_kfree_skb_any(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  664) 	} else if (dropped) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  665) 		dev_kfree_skb_any(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  666) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  667) 		/* consumes skb */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  668) 		skb_complete_wifi_ack(skb, acked);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  669) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  670) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  671) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  672) static void ieee80211_report_used_skb(struct ieee80211_local *local,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  673) 				      struct sk_buff *skb, bool dropped)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  674) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  675) 	struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  676) 	u16 tx_time_est = ieee80211_info_get_tx_time_est(info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  677) 	struct ieee80211_hdr *hdr = (void *)skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  678) 	bool acked = info->flags & IEEE80211_TX_STAT_ACK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  679) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  680) 	if (dropped)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  681) 		acked = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  682) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  683) 	if (tx_time_est) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  684) 		struct sta_info *sta;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  685) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  686) 		rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  687) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  688) 		sta = sta_info_get_by_addrs(local, hdr->addr1, hdr->addr2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  689) 		ieee80211_sta_update_pending_airtime(local, sta,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  690) 						     skb_get_queue_mapping(skb),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  691) 						     tx_time_est,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  692) 						     true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  693) 		rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  694) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  695) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  696) 	if (info->flags & IEEE80211_TX_INTFL_MLME_CONN_TX) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  697) 		struct ieee80211_sub_if_data *sdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  698) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  699) 		rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  700) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  701) 		sdata = ieee80211_sdata_from_skb(local, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  702) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  703) 		if (!sdata) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  704) 			skb->dev = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  705) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  706) 			unsigned int hdr_size =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  707) 				ieee80211_hdrlen(hdr->frame_control);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  708) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  709) 			/* Check to see if packet is a TDLS teardown packet */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  710) 			if (ieee80211_is_data(hdr->frame_control) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  711) 			    (ieee80211_get_tdls_action(skb, hdr_size) ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  712) 			     WLAN_TDLS_TEARDOWN))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  713) 				ieee80211_tdls_td_tx_handle(local, sdata, skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  714) 							    info->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  715) 			else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  716) 				ieee80211_mgd_conn_tx_status(sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  717) 							     hdr->frame_control,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  718) 							     acked);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  719) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  720) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  721) 		rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  722) 	} else if (info->ack_frame_id) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  723) 		ieee80211_report_ack_skb(local, info, acked, dropped);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  724) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  725) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  726) 	if (!dropped && skb->destructor) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  727) 		skb->wifi_acked_valid = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  728) 		skb->wifi_acked = acked;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  729) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  730) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  731) 	ieee80211_led_tx(local);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  732) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  733) 	if (skb_has_frag_list(skb)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  734) 		kfree_skb_list(skb_shinfo(skb)->frag_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  735) 		skb_shinfo(skb)->frag_list = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  736) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  737) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  738) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  739) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  740)  * Use a static threshold for now, best value to be determined
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  741)  * by testing ...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  742)  * Should it depend on:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  743)  *  - on # of retransmissions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  744)  *  - current throughput (higher value for higher tpt)?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  745)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  746) #define STA_LOST_PKT_THRESHOLD	50
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  747) #define STA_LOST_PKT_TIME	HZ		/* 1 sec since last ACK */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  748) #define STA_LOST_TDLS_PKT_THRESHOLD	10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  749) #define STA_LOST_TDLS_PKT_TIME		(10*HZ) /* 10secs since last ACK */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  750) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  751) static void ieee80211_lost_packet(struct sta_info *sta,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  752) 				  struct ieee80211_tx_info *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  753) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  754) 	unsigned long pkt_time = STA_LOST_PKT_TIME;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  755) 	unsigned int pkt_thr = STA_LOST_PKT_THRESHOLD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  756) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  757) 	/* If driver relies on its own algorithm for station kickout, skip
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  758) 	 * mac80211 packet loss mechanism.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  759) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  760) 	if (ieee80211_hw_check(&sta->local->hw, REPORTS_LOW_ACK))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  761) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  762) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  763) 	/* This packet was aggregated but doesn't carry status info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  764) 	if ((info->flags & IEEE80211_TX_CTL_AMPDU) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  765) 	    !(info->flags & IEEE80211_TX_STAT_AMPDU))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  766) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  767) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  768) 	sta->status_stats.lost_packets++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  769) 	if (sta->sta.tdls) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  770) 		pkt_time = STA_LOST_TDLS_PKT_TIME;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  771) 		pkt_thr = STA_LOST_PKT_THRESHOLD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  772) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  773) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  774) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  775) 	 * If we're in TDLS mode, make sure that all STA_LOST_TDLS_PKT_THRESHOLD
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  776) 	 * of the last packets were lost, and that no ACK was received in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  777) 	 * last STA_LOST_TDLS_PKT_TIME ms, before triggering the CQM packet-loss
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  778) 	 * mechanism.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  779) 	 * For non-TDLS, use STA_LOST_PKT_THRESHOLD and STA_LOST_PKT_TIME
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  780) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  781) 	if (sta->status_stats.lost_packets < pkt_thr ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  782) 	    !time_after(jiffies, sta->status_stats.last_pkt_time + pkt_time))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  783) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  784) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  785) 	cfg80211_cqm_pktloss_notify(sta->sdata->dev, sta->sta.addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  786) 				    sta->status_stats.lost_packets, GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  787) 	sta->status_stats.lost_packets = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  788) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  789) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  790) static int ieee80211_tx_get_rates(struct ieee80211_hw *hw,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  791) 				  struct ieee80211_tx_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  792) 				  int *retry_count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  793) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  794) 	int count = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  795) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  796) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  797) 	for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  798) 		if ((info->flags & IEEE80211_TX_CTL_AMPDU) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  799) 		    !(info->flags & IEEE80211_TX_STAT_AMPDU)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  800) 			/* just the first aggr frame carry status info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  801) 			info->status.rates[i].idx = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  802) 			info->status.rates[i].count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  803) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  804) 		} else if (info->status.rates[i].idx < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  805) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  806) 		} else if (i >= hw->max_report_rates) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  807) 			/* the HW cannot have attempted that rate */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  808) 			info->status.rates[i].idx = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  809) 			info->status.rates[i].count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  810) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  811) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  812) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  813) 		count += info->status.rates[i].count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  814) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  815) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  816) 	if (count < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  817) 		count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  818) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  819) 	*retry_count = count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  820) 	return i - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  821) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  822) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  823) void ieee80211_tx_monitor(struct ieee80211_local *local, struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  824) 			  struct ieee80211_supported_band *sband,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  825) 			  int retry_count, int shift, bool send_to_cooked,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  826) 			  struct ieee80211_tx_status *status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  827) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  828) 	struct sk_buff *skb2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  829) 	struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  830) 	struct ieee80211_sub_if_data *sdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  831) 	struct net_device *prev_dev = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  832) 	int rtap_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  833) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  834) 	/* send frame to monitor interfaces now */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  835) 	rtap_len = ieee80211_tx_radiotap_len(info, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  836) 	if (WARN_ON_ONCE(skb_headroom(skb) < rtap_len)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  837) 		pr_err("ieee80211_tx_status: headroom too small\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  838) 		dev_kfree_skb(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  839) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  840) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  841) 	ieee80211_add_tx_radiotap_header(local, sband, skb, retry_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  842) 					 rtap_len, shift, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  843) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  844) 	/* XXX: is this sufficient for BPF? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  845) 	skb_reset_mac_header(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  846) 	skb->ip_summed = CHECKSUM_UNNECESSARY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  847) 	skb->pkt_type = PACKET_OTHERHOST;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  848) 	skb->protocol = htons(ETH_P_802_2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  849) 	memset(skb->cb, 0, sizeof(skb->cb));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  850) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  851) 	rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  852) 	list_for_each_entry_rcu(sdata, &local->interfaces, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  853) 		if (sdata->vif.type == NL80211_IFTYPE_MONITOR) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  854) 			if (!ieee80211_sdata_running(sdata))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  855) 				continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  856) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  857) 			if ((sdata->u.mntr.flags & MONITOR_FLAG_COOK_FRAMES) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  858) 			    !send_to_cooked)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  859) 				continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  860) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  861) 			if (prev_dev) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  862) 				skb2 = skb_clone(skb, GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  863) 				if (skb2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  864) 					skb2->dev = prev_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  865) 					netif_rx(skb2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  866) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  867) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  868) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  869) 			prev_dev = sdata->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  870) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  871) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  872) 	if (prev_dev) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  873) 		skb->dev = prev_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  874) 		netif_rx(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  875) 		skb = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  876) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  877) 	rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  878) 	dev_kfree_skb(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  879) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  880) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  881) static void __ieee80211_tx_status(struct ieee80211_hw *hw,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  882) 				  struct ieee80211_tx_status *status,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  883) 				  int rates_idx, int retry_count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  884) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  885) 	struct sk_buff *skb = status->skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  886) 	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  887) 	struct ieee80211_local *local = hw_to_local(hw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  888) 	struct ieee80211_tx_info *info = status->info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  889) 	struct sta_info *sta;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  890) 	__le16 fc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  891) 	struct ieee80211_supported_band *sband;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  892) 	bool send_to_cooked;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  893) 	bool acked;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  894) 	bool noack_success;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  895) 	struct ieee80211_bar *bar;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  896) 	int shift = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  897) 	int tid = IEEE80211_NUM_TIDS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  898) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  899) 	sband = local->hw.wiphy->bands[info->band];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  900) 	fc = hdr->frame_control;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  901) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  902) 	if (status->sta) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  903) 		sta = container_of(status->sta, struct sta_info, sta);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  904) 		shift = ieee80211_vif_get_shift(&sta->sdata->vif);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  905) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  906) 		if (info->flags & IEEE80211_TX_STATUS_EOSP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  907) 			clear_sta_flag(sta, WLAN_STA_SP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  908) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  909) 		acked = !!(info->flags & IEEE80211_TX_STAT_ACK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  910) 		noack_success = !!(info->flags &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  911) 				   IEEE80211_TX_STAT_NOACK_TRANSMITTED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  912) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  913) 		/* mesh Peer Service Period support */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  914) 		if (ieee80211_vif_is_mesh(&sta->sdata->vif) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  915) 		    ieee80211_is_data_qos(fc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  916) 			ieee80211_mpsp_trigger_process(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  917) 				ieee80211_get_qos_ctl(hdr), sta, true, acked);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  918) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  919) 		if (ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  920) 		    (ieee80211_is_data(hdr->frame_control)) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  921) 		    (rates_idx != -1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  922) 			sta->tx_stats.last_rate =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  923) 				info->status.rates[rates_idx];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  924) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  925) 		if ((info->flags & IEEE80211_TX_STAT_AMPDU_NO_BACK) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  926) 		    (ieee80211_is_data_qos(fc))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  927) 			u16 ssn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  928) 			u8 *qc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  929) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  930) 			qc = ieee80211_get_qos_ctl(hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  931) 			tid = qc[0] & 0xf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  932) 			ssn = ((le16_to_cpu(hdr->seq_ctrl) + 0x10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  933) 						& IEEE80211_SCTL_SEQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  934) 			ieee80211_send_bar(&sta->sdata->vif, hdr->addr1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  935) 					   tid, ssn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  936) 		} else if (ieee80211_is_data_qos(fc)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  937) 			u8 *qc = ieee80211_get_qos_ctl(hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  938) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  939) 			tid = qc[0] & 0xf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  940) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  941) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  942) 		if (!acked && ieee80211_is_back_req(fc)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  943) 			u16 control;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  944) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  945) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  946) 			 * BAR failed, store the last SSN and retry sending
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  947) 			 * the BAR when the next unicast transmission on the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  948) 			 * same TID succeeds.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  949) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  950) 			bar = (struct ieee80211_bar *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  951) 			control = le16_to_cpu(bar->control);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  952) 			if (!(control & IEEE80211_BAR_CTRL_MULTI_TID)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  953) 				u16 ssn = le16_to_cpu(bar->start_seq_num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  954) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  955) 				tid = (control &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  956) 				       IEEE80211_BAR_CTRL_TID_INFO_MASK) >>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  957) 				      IEEE80211_BAR_CTRL_TID_INFO_SHIFT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  958) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  959) 				ieee80211_set_bar_pending(sta, tid, ssn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  960) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  961) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  962) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  963) 		if (info->flags & IEEE80211_TX_STAT_TX_FILTERED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  964) 			ieee80211_handle_filtered_frame(local, sta, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  965) 			return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  966) 		} else if (ieee80211_is_data_present(fc)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  967) 			if (!acked && !noack_success)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  968) 				sta->status_stats.msdu_failed[tid]++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  969) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  970) 			sta->status_stats.msdu_retries[tid] +=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  971) 				retry_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  972) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  973) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  974) 		if (!(info->flags & IEEE80211_TX_CTL_INJECTED) && acked)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  975) 			ieee80211_frame_acked(sta, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  976) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  977) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  978) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  979) 	/* SNMP counters
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  980) 	 * Fragments are passed to low-level drivers as separate skbs, so these
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  981) 	 * are actually fragments, not frames. Update frame counters only for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  982) 	 * the first fragment of the frame. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  983) 	if ((info->flags & IEEE80211_TX_STAT_ACK) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  984) 	    (info->flags & IEEE80211_TX_STAT_NOACK_TRANSMITTED)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  985) 		if (ieee80211_is_first_frag(hdr->seq_ctrl)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  986) 			I802_DEBUG_INC(local->dot11TransmittedFrameCount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  987) 			if (is_multicast_ether_addr(ieee80211_get_DA(hdr)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  988) 				I802_DEBUG_INC(local->dot11MulticastTransmittedFrameCount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  989) 			if (retry_count > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  990) 				I802_DEBUG_INC(local->dot11RetryCount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  991) 			if (retry_count > 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  992) 				I802_DEBUG_INC(local->dot11MultipleRetryCount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  993) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  994) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  995) 		/* This counter shall be incremented for an acknowledged MPDU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  996) 		 * with an individual address in the address 1 field or an MPDU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  997) 		 * with a multicast address in the address 1 field of type Data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  998) 		 * or Management. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  999) 		if (!is_multicast_ether_addr(hdr->addr1) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) 		    ieee80211_is_data(fc) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) 		    ieee80211_is_mgmt(fc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) 			I802_DEBUG_INC(local->dot11TransmittedFragmentCount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) 		if (ieee80211_is_first_frag(hdr->seq_ctrl))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) 			I802_DEBUG_INC(local->dot11FailedCount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) 	if (ieee80211_is_any_nullfunc(fc) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) 	    ieee80211_has_pm(fc) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) 	    ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) 	    !(info->flags & IEEE80211_TX_CTL_INJECTED) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) 	    local->ps_sdata && !(local->scanning)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) 		if (info->flags & IEEE80211_TX_STAT_ACK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) 			local->ps_sdata->u.mgd.flags |=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) 					IEEE80211_STA_NULLFUNC_ACKED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) 		} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) 			mod_timer(&local->dynamic_ps_timer, jiffies +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) 					msecs_to_jiffies(10));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) 	ieee80211_report_used_skb(local, skb, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) 	/* this was a transmitted frame, but now we want to reuse it */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) 	skb_orphan(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) 	/* Need to make a copy before skb->cb gets cleared */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) 	send_to_cooked = !!(info->flags & IEEE80211_TX_CTL_INJECTED) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) 			 !(ieee80211_is_data(fc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) 	 * This is a bit racy but we can avoid a lot of work
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) 	 * with this test...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) 	if (!local->monitors && (!send_to_cooked || !local->cooked_mntrs)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) 		if (status->free_list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) 			list_add_tail(&skb->list, status->free_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) 			dev_kfree_skb(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) 	/* send to monitor interfaces */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) 	ieee80211_tx_monitor(local, skb, sband, retry_count, shift,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) 			     send_to_cooked, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) 	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) 	struct ieee80211_local *local = hw_to_local(hw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051) 	struct ieee80211_tx_status status = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) 		.skb = skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) 		.info = IEEE80211_SKB_CB(skb),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) 	struct sta_info *sta;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) 	rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) 	sta = sta_info_get_by_addrs(local, hdr->addr1, hdr->addr2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) 	if (sta)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) 		status.sta = &sta->sta;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) 	ieee80211_tx_status_ext(hw, &status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) 	rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066) EXPORT_SYMBOL(ieee80211_tx_status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) void ieee80211_tx_status_ext(struct ieee80211_hw *hw,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) 			     struct ieee80211_tx_status *status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) 	struct ieee80211_local *local = hw_to_local(hw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) 	struct ieee80211_tx_info *info = status->info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) 	struct ieee80211_sta *pubsta = status->sta;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) 	struct sk_buff *skb = status->skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) 	struct ieee80211_supported_band *sband;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076) 	struct sta_info *sta = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) 	int rates_idx, retry_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) 	bool acked, noack_success;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) 	u16 tx_time_est;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081) 	if (pubsta) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082) 		sta = container_of(pubsta, struct sta_info, sta);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084) 		if (status->rate)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085) 			sta->tx_stats.last_rate_info = *status->rate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088) 	if (skb && (tx_time_est =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089) 		    ieee80211_info_get_tx_time_est(IEEE80211_SKB_CB(skb))) > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090) 		/* Do this here to avoid the expensive lookup of the sta
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) 		 * in ieee80211_report_used_skb().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093) 		ieee80211_sta_update_pending_airtime(local, sta,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094) 						     skb_get_queue_mapping(skb),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095) 						     tx_time_est,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) 						     true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097) 		ieee80211_info_set_tx_time_est(IEEE80211_SKB_CB(skb), 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) 	if (!status->info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) 		goto free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103) 	rates_idx = ieee80211_tx_get_rates(hw, info, &retry_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) 	sband = hw->wiphy->bands[info->band];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107) 	acked = !!(info->flags & IEEE80211_TX_STAT_ACK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108) 	noack_success = !!(info->flags & IEEE80211_TX_STAT_NOACK_TRANSMITTED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) 	if (pubsta) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111) 		struct ieee80211_sub_if_data *sdata = sta->sdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113) 		if (!acked && !noack_success)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) 			sta->status_stats.retry_failed++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115) 		sta->status_stats.retry_count += retry_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117) 		if (ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) 			if (sdata->vif.type == NL80211_IFTYPE_STATION &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) 			    skb && !(info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120) 				ieee80211_sta_tx_notify(sdata, (void *) skb->data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121) 							acked, info->status.tx_time);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) 			if (acked) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124) 				sta->status_stats.last_ack = jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126) 				if (sta->status_stats.lost_packets)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) 					sta->status_stats.lost_packets = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129) 				/* Track when last packet was ACKed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130) 				sta->status_stats.last_pkt_time = jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132) 				/* Reset connection monitor */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133) 				if (sdata->vif.type == NL80211_IFTYPE_STATION &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134) 				    unlikely(sdata->u.mgd.probe_send_count > 0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135) 					sdata->u.mgd.probe_send_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137) 				if (info->status.is_valid_ack_signal) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138) 					sta->status_stats.last_ack_signal =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139) 							 (s8)info->status.ack_signal;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) 					sta->status_stats.ack_signal_filled = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141) 					ewma_avg_signal_add(&sta->status_stats.avg_ack_signal,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142) 							    -info->status.ack_signal);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144) 			} else if (test_sta_flag(sta, WLAN_STA_PS_STA)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145) 				/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146) 				 * The STA is in power save mode, so assume
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147) 				 * that this TX packet failed because of that.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148) 				 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149) 				if (skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150) 					ieee80211_handle_filtered_frame(local, sta, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151) 				return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) 			} else if (noack_success) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153) 				/* nothing to do here, do not account as lost */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154) 			} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155) 				ieee80211_lost_packet(sta, info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159) 		rate_control_tx_status(local, sband, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160) 		if (ieee80211_vif_is_mesh(&sta->sdata->vif))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) 			ieee80211s_update_metric(local, sta, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164) 	if (skb && !(info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) 		return __ieee80211_tx_status(hw, status, rates_idx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166) 					     retry_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168) 	if (acked || noack_success) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169) 		I802_DEBUG_INC(local->dot11TransmittedFrameCount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170) 		if (!pubsta)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171) 			I802_DEBUG_INC(local->dot11MulticastTransmittedFrameCount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172) 		if (retry_count > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173) 			I802_DEBUG_INC(local->dot11RetryCount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174) 		if (retry_count > 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175) 			I802_DEBUG_INC(local->dot11MultipleRetryCount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177) 		I802_DEBUG_INC(local->dot11FailedCount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180) free:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181) 	if (!skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184) 	ieee80211_report_used_skb(local, skb, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185) 	if (status->free_list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186) 		list_add_tail(&skb->list, status->free_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188) 		dev_kfree_skb(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190) EXPORT_SYMBOL(ieee80211_tx_status_ext);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192) void ieee80211_tx_rate_update(struct ieee80211_hw *hw,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193) 			      struct ieee80211_sta *pubsta,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194) 			      struct ieee80211_tx_info *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196) 	struct ieee80211_local *local = hw_to_local(hw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197) 	struct ieee80211_supported_band *sband = hw->wiphy->bands[info->band];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198) 	struct sta_info *sta = container_of(pubsta, struct sta_info, sta);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199) 	struct ieee80211_tx_status status = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200) 		.info = info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201) 		.sta = pubsta,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204) 	rate_control_tx_status(local, sband, &status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206) 	if (ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207) 		sta->tx_stats.last_rate = info->status.rates[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209) EXPORT_SYMBOL(ieee80211_tx_rate_update);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211) void ieee80211_tx_status_8023(struct ieee80211_hw *hw,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212) 			      struct ieee80211_vif *vif,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213) 			      struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215) 	struct ieee80211_sub_if_data *sdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216) 	struct ieee80211_tx_status status = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1217) 		.skb = skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1218) 		.info = IEEE80211_SKB_CB(skb),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1219) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1220) 	struct sta_info *sta;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1221) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1222) 	sdata = vif_to_sdata(vif);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1223) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1224) 	rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1225) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1226) 	if (!ieee80211_lookup_ra_sta(sdata, skb, &sta) && !IS_ERR(sta))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1227) 		status.sta = &sta->sta;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1228) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1229) 	ieee80211_tx_status_ext(hw, &status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1230) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1231) 	rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1232) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1233) EXPORT_SYMBOL(ieee80211_tx_status_8023);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1234) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1235) void ieee80211_report_low_ack(struct ieee80211_sta *pubsta, u32 num_packets)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1236) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1237) 	struct sta_info *sta = container_of(pubsta, struct sta_info, sta);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1238) 	cfg80211_cqm_pktloss_notify(sta->sdata->dev, sta->sta.addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1239) 				    num_packets, GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1240) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1241) EXPORT_SYMBOL(ieee80211_report_low_ack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1242) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1243) void ieee80211_free_txskb(struct ieee80211_hw *hw, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1244) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1245) 	struct ieee80211_local *local = hw_to_local(hw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1246) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1247) 	ieee80211_report_used_skb(local, skb, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1248) 	dev_kfree_skb_any(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1249) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1250) EXPORT_SYMBOL(ieee80211_free_txskb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1251) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1252) void ieee80211_purge_tx_queue(struct ieee80211_hw *hw,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1253) 			      struct sk_buff_head *skbs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1254) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1255) 	struct sk_buff *skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1256) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1257) 	while ((skb = __skb_dequeue(skbs)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1258) 		ieee80211_free_txskb(hw, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1259) }