Skip to contentSkip to conversation

ath6kl: Enable uAPSD support in AP mode

PATCH New Thirumalai Pachamuthu 2 participants 4 messages Jan 12, 2012 – Jan 13, 2012 Atheros ATH6KL wireless driver

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ath6kl: Enable uAPSD support in AP mode

In addition to legacy power save, this patch adds support for uAPSD in AP mode.

When connected station goes into suspend state, the driver will start queuing pkts in the separate queue (called uapsd queue) until the station ask for it.

V2 Changes:

* Since inline functions wmi_data_hdr_set_more_bit and wmi_data_hdr_set_eosp_bit are used in one place, removed those functions and added the function defination in the place required.
* Removed macros WMI_DATA_HDR_EOSP_MASK, WMI_DATA_HDR_MORE_MASK, WMI_DATA_HDR_MORE_SHIFT, WMI_DATA_HDR_EOSP_SHIFT and added the MACRO WMI_DATA_HDR_MORE, WMI_DATA_HDR_EOSP.
* Added MACRO for the hardcoded values.
* Indendation issues are corrected in the function ath6kl_process_uapsdq ath6kl_process_psq.
* Fixed sparse errors.

I have taken care review comments given by Kalle in V2.

Thirumalai Pachamuthu (1):
ath6kl: Add support for uAPSD

 drivers/net/wireless/ath/ath6kl/cfg80211.c |    6 +
 drivers/net/wireless/ath/ath6kl/core.h     |   10 +-
 drivers/net/wireless/ath/ath6kl/main.c     |    9 +-
 drivers/net/wireless/ath/ath6kl/txrx.c     |  253 ++++++++++++++++++++++++----
 drivers/net/wireless/ath/ath6kl/wmi.c      |   62 ++++++-
 drivers/net/wireless/ath/ath6kl/wmi.h      |   41 ++++-
 6 files changed, 328 insertions(+), 53 deletions(-)
#1 lore raw

PATCH v2 1/1 ath6kl: Add support for uAPSD

* A new APSD power save queue is added in the station structure.
* When a station has APSD capability and goes to power save, the frame designated to the station will be buffered in APSD queue.
* When the host receives a frame which the firmware marked as trigger, host delivers the buffered frame from the APSD power save queue. Number of frames to deliver is decided by MAX SP length.
* When a station moves from sleep to awake state, all frames buffered in APSD power save queue are sent to the firmware.
* When a station is disconnected, all frames bufferes in APSD power save queue are dropped.
* When the host queues the first frame to the APSD queue or removes the last frame from the APSD queue, it is indicated to the firmware using WMI_AP_APSD_BUFFERED_TRAFFIC_CMD.

---
 drivers/net/wireless/ath/ath6kl/cfg80211.c |    6 +
 drivers/net/wireless/ath/ath6kl/core.h     |   10 +-
 drivers/net/wireless/ath/ath6kl/main.c     |    9 +-
 drivers/net/wireless/ath/ath6kl/txrx.c     |  253 ++++++++++++++++++++++++----
 drivers/net/wireless/ath/ath6kl/wmi.c      |   62 ++++++-
 drivers/net/wireless/ath/ath6kl/wmi.h      |   41 ++++-
 6 files changed, 328 insertions(+), 53 deletions(-)
drivers/net/wireless/ath/ath6kl/cfg80211.c +6 -0
index 14f180e..5a71984 100644
@@ -2254,6 +2254,11 @@ static int ath6kl_ap_beacon(struct wiphy *wiphy, struct net_device *dev,
 	p.dot11_auth_mode = vif->dot11_auth_mode;
 	p.ch = cpu_to_le16(vif->next_chan);
 
+	/* Enable uAPSD support by default */
+	res = ath6kl_wmi_ap_set_apsd(ar->wmi, vif->fw_vif_idx, true);
+	if (res < 0)
+		return res;
+
 	if (vif->wdev.iftype == NL80211_IFTYPE_P2P_GO) {
 		p.nw_subtype = SUBTYPE_P2PGO;
 	} else {
@@ -2742,6 +2747,7 @@ struct ath6kl *ath6kl_core_alloc(struct device *dev)
 	for (ctr = 0; ctr < AP_MAX_NUM_STA; ctr++) {
 		spin_lock_init(&ar->sta_list[ctr].psq_lock);
 		skb_queue_head_init(&ar->sta_list[ctr].psq);
+		skb_queue_head_init(&ar->sta_list[ctr].apsdq);
 	}
 
 	skb_queue_head_init(&ar->mcastpsq);
drivers/net/wireless/ath/ath6kl/core.h +9 -1
index 793c6a5..8239842 100644
@@ -44,6 +44,10 @@
 #define ATH6KL_MAX_ENDPOINTS   4
 #define MAX_NODE_NUM           15
 
+#define ATH6KL_APSD_ALL_FRAME		0xFFFF
+#define ATH6KL_APSD_NUM_OF_AC		0x4
+#define ATH6KL_APSD_FRAME_MASK		0xF
+
 /* Extra bytes for htc header alignment */
 #define ATH6KL_HTC_ALIGN_BYTES 3
 
@@ -146,6 +150,8 @@ struct ath6kl_fw_ie {
 #define STA_PS_AWAKE		BIT(0)
 #define	STA_PS_SLEEP		BIT(1)
 #define	STA_PS_POLLED		BIT(2)
+#define STA_PS_APSD_TRIGGER     BIT(3)
+#define STA_PS_APSD_EOSP        BIT(4)
 
 /* HTC TX packet tagging definitions */
 #define ATH6KL_CONTROL_PKT_TAG    HTC_TX_PACKET_TAG_USER_DEFINED
@@ -282,6 +288,8 @@ struct ath6kl_sta {
 	u8 wpa_ie[ATH6KL_MAX_IE];
 	struct sk_buff_head psq;
 	spinlock_t psq_lock;
+	u8 apsd_info;
+	struct sk_buff_head apsdq;
 };
 
 struct ath6kl_version {
@@ -715,7 +723,7 @@ void ath6kl_connect_event(struct ath6kl_vif *vif, u16 channel,
 void ath6kl_connect_ap_mode_bss(struct ath6kl_vif *vif, u16 channel);
 void ath6kl_connect_ap_mode_sta(struct ath6kl_vif *vif, u16 aid, u8 *mac_addr,
 				u8 keymgmt, u8 ucipher, u8 auth,
-				u8 assoc_req_len, u8 *assoc_info);
+				u8 assoc_req_len, u8 *assoc_info, u8 apsd_info);
 void ath6kl_disconnect_event(struct ath6kl_vif *vif, u8 reason,
 			     u8 *bssid, u8 assoc_resp_len,
 			     u8 *assoc_info, u16 prot_reason_status);
drivers/net/wireless/ath/ath6kl/main.c +6 -3
index 8742eaa..1b36a90 100644
@@ -53,7 +53,8 @@ struct ath6kl_sta *ath6kl_find_sta_by_aid(struct ath6kl *ar, u8 aid)
 }
 
 static void ath6kl_add_new_sta(struct ath6kl *ar, u8 *mac, u16 aid, u8 *wpaie,
-			size_t ielen, u8 keymgmt, u8 ucipher, u8 auth)
+			       size_t ielen, u8 keymgmt, u8 ucipher, u8 auth,
+			       u8 apsd_info)
 {
 	struct ath6kl_sta *sta;
 	u8 free_slot;
@@ -68,6 +69,7 @@ static void ath6kl_add_new_sta(struct ath6kl *ar, u8 *mac, u16 aid, u8 *wpaie,
 	sta->keymgmt = keymgmt;
 	sta->ucipher = ucipher;
 	sta->auth = auth;
+	sta->apsd_info = apsd_info;
 
 	ar->sta_list_index = ar->sta_list_index | (1 << free_slot);
 	ar->ap_stats.sta[free_slot].aid = cpu_to_le32(aid);
@@ -80,6 +82,7 @@ static void ath6kl_sta_cleanup(struct ath6kl *ar, u8 i)
 	/* empty the queued pkts in the PS queue if any */
 	spin_lock_bh(&sta->psq_lock);
 	skb_queue_purge(&sta->psq);
+	skb_queue_purge(&sta->apsdq);
 	spin_unlock_bh(&sta->psq_lock);
 
 	memset(&ar->ap_stats.sta[sta->aid - 1], 0,
@@ -425,7 +428,7 @@ void ath6kl_connect_ap_mode_bss(struct ath6kl_vif *vif, u16 channel)
 
 void ath6kl_connect_ap_mode_sta(struct ath6kl_vif *vif, u16 aid, u8 *mac_addr,
 				u8 keymgmt, u8 ucipher, u8 auth,
-				u8 assoc_req_len, u8 *assoc_info)
+				u8 assoc_req_len, u8 *assoc_info, u8 apsd_info)
 {
 	struct ath6kl *ar = vif->ar;
 	u8 *ies = NULL, *wpa_ie = NULL, *pos;
@@ -483,7 +486,7 @@ void ath6kl_connect_ap_mode_sta(struct ath6kl_vif *vif, u16 aid, u8 *mac_addr,
 
 	ath6kl_add_new_sta(ar, mac_addr, aid, wpa_ie,
 			   wpa_ie ? 2 + wpa_ie[1] : 0,
-			   keymgmt, ucipher, auth);
+			   keymgmt, ucipher, auth, apsd_info);
 
 	/* send event to application */
 	memset(&sinfo, 0, sizeof(sinfo));
drivers/net/wireless/ath/ath6kl/txrx.c +216 -37

334 lines not on this page · raw message

drivers/net/wireless/ath/ath6kl/wmi.c +54 -8

102 lines not on this page · raw message

drivers/net/wireless/ath/ath6kl/wmi.h +37 -4

86 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#2 lore raw

Re: [PATCH v2] ath6kl: Add support for uAPSD

Hi Thirumalai,

Quoted 14 lines · Thirumalai Pachamuthu

* A new APSD power save queue is added in the station structure.
* When a station has APSD capability and goes to power save, the frame designated to the station will be buffered in APSD queue.
* When the host receives a frame which the firmware marked as trigger, host delivers the buffered frame from the APSD power save queue. Number of frames to deliver is decided by MAX SP length.
* When a station moves from sleep to awake state, all frames buffered in APSD power save queue are sent to the firmware.
* When a station is disconnected, all frames bufferes in APSD power save queue are dropped.
* When the host queues the first frame to the APSD queue or removes the last frame from the APSD queue, it is indicated to the firmware using WMI_AP_APSD_BUFFERED_TRAFFIC_CMD.

Quoted 1 line

Thanks, I applied your patch with these changes below. Please check that I didn't break anything.

drivers/net/wireless/ath/ath6kl/txrx.c static u8 ath6kl_ibss_map_epid(struct sk_buff *skb, struct net_device *dev, · line 88

Quoted 9 lines
drivers/net/wireless/ath/ath6kl/txrx.c +9 -0
+static bool ath6kl_process_uapsdq(struct ath6kl_sta *conn,
+				struct ath6kl_vif *vif,
+				struct sk_buff *skb,
+				u32 *flags)
+{
+	struct ath6kl *ar = vif->ar;
+	bool is_apsdq_empty = false;
+	struct ethhdr *datap = (struct ethhdr *) skb->data;
+	u8 up = 0;

This is initilised in an else branch I added below.

drivers/net/wireless/ath/ath6kl/txrx.c static u8 ath6kl_ibss_map_epid(struct sk_buff *skb, struct net_device *dev, · line 92

Quoted 4 lines
drivers/net/wireless/ath/ath6kl/txrx.c +4 -0
+	u8 traffic_class;
+	u16 ether_type;
+	u8 *ip_hdr;
+	struct ath6kl_llc_snap_hdr *llc_hdr;

I combined the same type variable declarations here.

Quoted 25 lines
drivers/net/wireless/ath/ath6kl/txrx.c +25 -0
+
+	if (conn->sta_flags & STA_PS_APSD_TRIGGER) {
+		/*
+		 * This tx is because of a uAPSD trigger, determine
+		 * more and EOSP bit. Set EOSP if queue is empty
+		 * or sufficient frames are delivered for this trigger.
+		 */
+		spin_lock_bh(&conn->psq_lock);
+		if (!skb_queue_empty(&conn->apsdq))
+			*flags |= WMI_DATA_HDR_FLAGS_MORE;
+		else if (conn->sta_flags & STA_PS_APSD_EOSP)
+			*flags |= WMI_DATA_HDR_FLAGS_EOSP;
+		*flags |= WMI_DATA_HDR_FLAGS_UAPSD;
+		spin_unlock_bh(&conn->psq_lock);
+		return false;
+	} else if (!conn->apsd_info)
+		return false;
+
+	if (test_bit(WMM_ENABLED, &vif->flags)) {
+		ether_type = be16_to_cpu(datap->h_proto);
+		if (is_ethertype(ether_type)) {
+			/* packet is in DIX format  */
+			ip_hdr = (u8 *)(datap + 1);
+		} else {
+			/* packet is in 802.3 format */

drivers/net/wireless/ath/ath6kl/txrx.c static u8 ath6kl_ibss_map_epid(struct sk_buff *skb, struct net_device *dev, · line 127

Quoted 10 lines
drivers/net/wireless/ath/ath6kl/txrx.c +10 -0
+			llc_hdr = (struct ath6kl_llc_snap_hdr *)
+							(datap + 1);
+			ether_type = be16_to_cpu(llc_hdr->eth_type);
+			ip_hdr = (u8 *)(llc_hdr + 1);
+		}
+
+		if (ether_type == IP_ETHERTYPE)
+			up = ath6kl_wmi_determine_user_priority(
+							ip_hdr, 0);
+	}

I added the else branch here.

Quoted 6 lines
drivers/net/wireless/ath/ath6kl/txrx.c +6 -0
+static bool ath6kl_process_psq(struct ath6kl_sta *conn,
+				struct ath6kl_vif *vif,
+				struct sk_buff *skb,
+				u32 *flags)
+{
+	bool is_psq_empty = false;

drivers/net/wireless/ath/ath6kl/txrx.c static u8 ath6kl_ibss_map_epid(struct sk_buff *skb, struct net_device *dev, · line 169

Quoted 10 lines
drivers/net/wireless/ath/ath6kl/txrx.c +10 -0
+	struct ath6kl *ar = vif->ar;
+
+	if (conn->sta_flags & STA_PS_POLLED) {
+		spin_lock_bh(&conn->psq_lock);
+		if (!skb_queue_empty(&conn->psq))
+			*flags |= WMI_DATA_HDR_FLAGS_MORE;
+		spin_unlock_bh(&conn->psq_lock);
+		return false;
+	} else {
+		/* Queue the frames if the STA is sleeping */

The else block is not needed as there's a return in the if block above. So the code below can be taken out of the else block.

drivers/net/wireless/ath/ath6kl/txrx.c static bool aggr_process_recv_frm(struct aggr_info *agg_info, u8 tid, · line 1189

Quoted 9 lines
drivers/net/wireless/ath/ath6kl/txrx.c +9 -0
+static void ath6kl_uapsd_trigger_frame_rx(struct ath6kl_vif *vif,
+						 struct ath6kl_sta *conn)
+{
+	struct ath6kl *ar = vif->ar;
+	bool is_apsdq_empty;
+	bool is_apsdq_empty_at_start;
+	u32 num_frames_to_deliver;
+	struct sk_buff *skb = NULL;
+	u32 flags;

Combined variable declarations.

drivers/net/wireless/ath/ath6kl/txrx.c void ath6kl_rx(struct htc_target *target, struct htc_packet *packet) · line 1412

Quoted 9 lines
drivers/net/wireless/ath/ath6kl/txrx.c +6 -2
 				spin_lock_bh(&conn->psq_lock);
-				while ((skbuff = skb_dequeue(&conn->psq))
-				       != NULL) {
+				while ((skbuff = skb_dequeue(&conn->psq))) {
+					spin_unlock_bh(&conn->psq_lock);
+					ath6kl_data_tx(skbuff, vif->ndev);
+					spin_lock_bh(&conn->psq_lock);
+					skbuff = skb_dequeue(&conn->psq);
+				}

This was buggy now. After the first skb you will take two skbs in one round.

drivers/net/wireless/ath/ath6kl/txrx.c void ath6kl_rx(struct htc_target *target, struct htc_packet *packet) · line 1420

Quoted 8 lines
drivers/net/wireless/ath/ath6kl/txrx.c +4 -0
+
+				is_apsdq_empty = skb_queue_empty(&conn->apsdq);
+				while ((skbuff = skb_dequeue(&conn->apsdq))) {
 					spin_unlock_bh(&conn->psq_lock);
 					ath6kl_data_tx(skbuff, vif->ndev);
 					spin_lock_bh(&conn->psq_lock);
+					skbuff = skb_dequeue(&conn->apsdq);
 				}

And this had the same bug.

Kalle

#3 lore raw

Re: [PATCH v2] ath6kl: Add support for uAPSD

Quoted 11 lines · Kalle Valo
Quoted 9 lines

+static bool ath6kl_process_uapsdq(struct ath6kl_sta *conn,

drivers/net/wireless/ath/ath6kl/txrx.c static u8 ath6kl_ibss_map_epid(struct sk_buff *skb, struct net_device *dev, · line 88

Quoted 8 lines
drivers/net/wireless/ath/ath6kl/txrx.c +8 -0
+				struct ath6kl_vif *vif,
+				struct sk_buff *skb,
+				u32 *flags)
+{
+	struct ath6kl *ar = vif->ar;
+	bool is_apsdq_empty = false;
+	struct ethhdr *datap = (struct ethhdr *) skb->data;
+	u8 up = 0;

This is initilised in an else branch I added below.

This actually creates a compiler warning which I missed. I'll send a separate patch which reverts up initilisation back to the original.

Kalle