From ccfc82df2beaf7ab51f1e7e60f0ba396c0686460 Mon Sep 17 00:00:00 2001
From: nbd <nbd@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Date: Tue, 4 Jun 2013 10:21:44 +0000
Subject: [PATCH] ath9k: fix some issues in the ap powersave fixes

Signed-off-by: Felix Fietkau <nbd@openwrt.org>

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@36829 3c298f89-4303-0410-b956-a3cf2f4a3e73
---
 .../mac80211/patches/300-pending_work.patch   | 71 ++++++++++++++-----
 .../patches/520-mac80211_cur_txpower.patch    |  2 +-
 .../523-mac80211_configure_antenna_gain.patch |  4 +-
 3 files changed, 56 insertions(+), 21 deletions(-)

diff --git a/package/mac80211/patches/300-pending_work.patch b/package/mac80211/patches/300-pending_work.patch
index 2ad482857a..46e539bebf 100644
--- a/package/mac80211/patches/300-pending_work.patch
+++ b/package/mac80211/patches/300-pending_work.patch
@@ -822,7 +822,24 @@
   * @ssid_len: Length of SSID given in @ssid.
   * @hidden_ssid: The SSID of the current vif is hidden. Only valid in AP-mode.
   * @txpower: TX power in dBm
-@@ -562,6 +562,9 @@ enum mac80211_rate_control_flags {
+@@ -459,6 +459,8 @@ struct ieee80211_bss_conf {
+  * @IEEE80211_TX_CTL_DONTFRAG: Don't fragment this packet even if it
+  *	would be fragmented by size (this is optional, only used for
+  *	monitor injection).
++ * @IEEE80211_TX_CTL_PS_RESPONSE: This frame is a response to a poll
++ *	frame (PS-Poll or uAPSD).
+  *
+  * Note: If you have to add new flags to the enumeration, then don't
+  *	 forget to update %IEEE80211_TX_TEMPORARY_FLAGS when necessary.
+@@ -494,6 +496,7 @@ enum mac80211_tx_control_flags {
+ 	IEEE80211_TX_STATUS_EOSP		= BIT(28),
+ 	IEEE80211_TX_CTL_USE_MINRATE		= BIT(29),
+ 	IEEE80211_TX_CTL_DONTFRAG		= BIT(30),
++	IEEE80211_TX_CTL_PS_RESPONSE		= BIT(31),
+ };
+ 
+ #define IEEE80211_TX_CTL_STBC_SHIFT		23
+@@ -562,6 +565,9 @@ enum mac80211_rate_control_flags {
  /* maximum number of rate stages */
  #define IEEE80211_TX_MAX_RATES	4
  
@@ -832,7 +849,7 @@
  /**
   * struct ieee80211_tx_rate - rate selection/status
   *
-@@ -602,8 +605,8 @@ static inline void ieee80211_rate_set_vh
+@@ -602,8 +608,8 @@ static inline void ieee80211_rate_set_vh
  					  u8 mcs, u8 nss)
  {
  	WARN_ON(mcs & ~0xF);
@@ -843,7 +860,7 @@
  }
  
  static inline u8
-@@ -615,7 +618,7 @@ ieee80211_rate_get_vht_mcs(const struct 
+@@ -615,7 +621,7 @@ ieee80211_rate_get_vht_mcs(const struct 
  static inline u8
  ieee80211_rate_get_vht_nss(const struct ieee80211_tx_rate *rate)
  {
@@ -852,7 +869,7 @@
  }
  
  /**
-@@ -656,7 +659,11 @@ struct ieee80211_tx_info {
+@@ -656,7 +662,11 @@ struct ieee80211_tx_info {
  					struct ieee80211_tx_rate rates[
  						IEEE80211_TX_MAX_RATES];
  					s8 rts_cts_rate_idx;
@@ -865,7 +882,7 @@
  				};
  				/* only needed before rate control */
  				unsigned long jiffies;
-@@ -677,6 +684,8 @@ struct ieee80211_tx_info {
+@@ -677,6 +687,8 @@ struct ieee80211_tx_info {
  		struct {
  			struct ieee80211_tx_rate driver_rates[
  				IEEE80211_TX_MAX_RATES];
@@ -874,7 +891,7 @@
  			void *rate_driver_data[
  				IEEE80211_TX_INFO_RATE_DRIVER_DATA_SIZE / sizeof(void *)];
  		};
-@@ -840,6 +849,9 @@ enum mac80211_rx_flags {
+@@ -840,6 +852,9 @@ enum mac80211_rx_flags {
   * @signal: signal strength when receiving this frame, either in dBm, in dB or
   *	unspecified depending on the hardware capabilities flags
   *	@IEEE80211_HW_SIGNAL_*
@@ -884,7 +901,7 @@
   * @antenna: antenna used
   * @rate_idx: index of data rate into band's supported rates or MCS index if
   *	HT or VHT is used (%RX_FLAG_HT/%RX_FLAG_VHT)
-@@ -871,6 +883,8 @@ struct ieee80211_rx_status {
+@@ -871,6 +886,8 @@ struct ieee80211_rx_status {
  	u8 band;
  	u8 antenna;
  	s8 signal;
@@ -893,7 +910,7 @@
  	u8 ampdu_delimiter_crc;
  	u8 vendor_radiotap_align;
  	u8 vendor_radiotap_oui[3];
-@@ -1018,13 +1032,13 @@ struct ieee80211_conf {
+@@ -1018,13 +1035,13 @@ struct ieee80211_conf {
   *	the driver passed into mac80211.
   * @block_tx: Indicates whether transmission must be blocked before the
   *	scheduled channel switch, as indicated by the AP.
@@ -909,7 +926,7 @@
  	u8 count;
  };
  
-@@ -1222,6 +1236,24 @@ enum ieee80211_sta_rx_bandwidth {
+@@ -1222,6 +1239,24 @@ enum ieee80211_sta_rx_bandwidth {
  };
  
  /**
@@ -934,7 +951,7 @@
   * struct ieee80211_sta - station table entry
   *
   * A station table entry represents a station we are possibly
-@@ -1248,6 +1280,7 @@ enum ieee80211_sta_rx_bandwidth {
+@@ -1248,6 +1283,7 @@ enum ieee80211_sta_rx_bandwidth {
   *	notifications and capabilities. The value is only valid after
   *	the station moves to associated state.
   * @smps_mode: current SMPS mode (off, static or dynamic)
@@ -942,7 +959,7 @@
   */
  struct ieee80211_sta {
  	u32 supp_rates[IEEE80211_NUM_BANDS];
-@@ -1261,6 +1294,7 @@ struct ieee80211_sta {
+@@ -1261,6 +1297,7 @@ struct ieee80211_sta {
  	u8 rx_nss;
  	enum ieee80211_sta_rx_bandwidth bandwidth;
  	enum ieee80211_smps_mode smps_mode;
@@ -950,7 +967,7 @@
  
  	/* must be last */
  	u8 drv_priv[0] __aligned(sizeof(void *));
-@@ -1416,6 +1450,9 @@ struct ieee80211_tx_control {
+@@ -1416,6 +1453,9 @@ struct ieee80211_tx_control {
   *	for different virtual interfaces. See the doc section on HW queue
   *	control for more details.
   *
@@ -960,7 +977,7 @@
   * @IEEE80211_HW_P2P_DEV_ADDR_FOR_INTF: Use the P2P Device address for any
   *	P2P Interface. This will be honoured even if more than one interface
   *	is supported.
-@@ -1448,6 +1485,7 @@ enum ieee80211_hw_flags {
+@@ -1448,6 +1488,7 @@ enum ieee80211_hw_flags {
  	IEEE80211_HW_SUPPORTS_PER_STA_GTK		= 1<<21,
  	IEEE80211_HW_AP_LINK_PS				= 1<<22,
  	IEEE80211_HW_TX_AMPDU_SETUP_IN_HW		= 1<<23,
@@ -968,7 +985,7 @@
  	IEEE80211_HW_P2P_DEV_ADDR_FOR_INTF		= 1<<25,
  	IEEE80211_HW_TIMING_BEACON_ONLY			= 1<<26,
  };
-@@ -3144,6 +3182,25 @@ void ieee80211_sta_set_buffered(struct i
+@@ -3144,6 +3185,25 @@ void ieee80211_sta_set_buffered(struct i
  				u8 tid, bool buffered);
  
  /**
@@ -994,7 +1011,7 @@
   * ieee80211_tx_status - transmit status callback
   *
   * Call this function for all transmitted frames after they have been
-@@ -4118,7 +4175,7 @@ void ieee80211_send_bar(struct ieee80211
+@@ -4118,7 +4178,7 @@ void ieee80211_send_bar(struct ieee80211
   *	(deprecated; this will be removed once drivers get updated to use
   *	rate_idx_mask)
   * @rate_idx_mask: user-requested (legacy) rate mask
@@ -1003,7 +1020,7 @@
   * @bss: whether this frame is sent out in AP or IBSS mode
   */
  struct ieee80211_tx_rate_control {
-@@ -4130,7 +4187,7 @@ struct ieee80211_tx_rate_control {
+@@ -4130,7 +4190,7 @@ struct ieee80211_tx_rate_control {
  	bool rts, short_preamble;
  	u8 max_rate_idx;
  	u32 rate_idx_mask;
@@ -1012,7 +1029,7 @@
  	bool bss;
  };
  
-@@ -4219,6 +4276,22 @@ bool rate_usable_index_exists(struct iee
+@@ -4219,6 +4279,22 @@ bool rate_usable_index_exists(struct iee
  	return false;
  }
  
@@ -3952,6 +3969,24 @@
  
  	if (sta_prepare_rate_control(local, sta, gfp)) {
  		kfree(sta);
+@@ -1130,6 +1132,7 @@ static void ieee80211_send_null_response
+ 	 * ends the poll/service period.
+ 	 */
+ 	info->flags |= IEEE80211_TX_CTL_NO_PS_BUFFER |
++		       IEEE80211_TX_CTL_PS_RESPONSE |
+ 		       IEEE80211_TX_STATUS_EOSP |
+ 		       IEEE80211_TX_CTL_REQ_TX_STATUS;
+ 
+@@ -1267,7 +1270,8 @@ ieee80211_sta_ps_deliver_response(struct
+ 			 * STA may still remain is PS mode after this frame
+ 			 * exchange.
+ 			 */
+-			info->flags |= IEEE80211_TX_CTL_NO_PS_BUFFER;
++			info->flags |= IEEE80211_TX_CTL_NO_PS_BUFFER |
++				       IEEE80211_TX_CTL_PS_RESPONSE;
+ 
+ 			/*
+ 			 * Use MoreData flag to indicate whether there are
 --- a/net/wireless/nl80211.c
 +++ b/net/wireless/nl80211.c
 @@ -2270,6 +2270,7 @@ static const struct nla_policy mntr_flag
@@ -4737,7 +4772,7 @@
  	}
  
 -	ath_tx_start_dma(sc, skb, txctl);
-+	if (info->flags & IEEE80211_TX_CTL_NO_PS_BUFFER) {
++	if (info->flags & IEEE80211_TX_CTL_PS_RESPONSE) {
 +		ath_txq_unlock(sc, txq);
 +		txq = sc->tx.uapsdq;
 +		ath_txq_lock(sc, txq);
diff --git a/package/mac80211/patches/520-mac80211_cur_txpower.patch b/package/mac80211/patches/520-mac80211_cur_txpower.patch
index 54ba91f974..e2759edf92 100644
--- a/package/mac80211/patches/520-mac80211_cur_txpower.patch
+++ b/package/mac80211/patches/520-mac80211_cur_txpower.patch
@@ -1,6 +1,6 @@
 --- a/include/net/mac80211.h
 +++ b/include/net/mac80211.h
-@@ -1605,6 +1605,7 @@ struct ieee80211_hw {
+@@ -1608,6 +1608,7 @@ struct ieee80211_hw {
  	u8 max_tx_aggregation_subframes;
  	u8 offchannel_tx_hw_queue;
  	u8 radiotap_mcs_details;
diff --git a/package/mac80211/patches/523-mac80211_configure_antenna_gain.patch b/package/mac80211/patches/523-mac80211_configure_antenna_gain.patch
index 1b0730bd60..d5c8ccf04c 100644
--- a/package/mac80211/patches/523-mac80211_configure_antenna_gain.patch
+++ b/package/mac80211/patches/523-mac80211_configure_antenna_gain.patch
@@ -1,6 +1,6 @@
 --- a/include/net/mac80211.h
 +++ b/include/net/mac80211.h
-@@ -988,6 +988,7 @@ enum ieee80211_smps_mode {
+@@ -991,6 +991,7 @@ enum ieee80211_smps_mode {
   *
   * @power_level: requested transmit power (in dBm), backward compatibility
   *	value only that is set to the minimum of all interfaces
@@ -8,7 +8,7 @@
   *
   * @chandef: the channel definition to tune to
   * @radar_enabled: whether radar detection is enabled
-@@ -1009,6 +1010,7 @@ struct ieee80211_conf {
+@@ -1012,6 +1013,7 @@ struct ieee80211_conf {
  	u32 flags;
  	int power_level, dynamic_ps_timeout;
  	int max_sleep_period;
-- 
GitLab