Skip to contentSkip to conversation

mac80211/iwlwifi: integrate IEEE802.11n A-MPDU Rx MLME

PATCH Superseded Ron Rindjunsky 3 participants 18 messages Dec 20, 2007 – Dec 25, 2007

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover mac80211/iwlwifi: integrate IEEE802.11n A-MPDU Rx MLME

This series of patches contains implementation for the IEEE802.11n aggregated MPDUs (A-MPDU) MLME. The series handles Rx A-MPDU (recipient party).

Please notice:
===============
Patch "mac80211: A-MPDU Rx adding BAR handling capability" depends on patch "mac80211: pass in PS_POLL frames" that was accepted as a stand alone patch.

Notes to this series:
======================
This series of patches splits into:
- patches 1-7 add 802.11n Rx A-MPDU MLME support to mac80211.
- patch 8 demonstrates the use of the above mac80211's MLME through iwl4965 low level driver

The patches in the series should not be treated as stand alone patches, but as a complete MLME according to IEEE802.11n spec, although separation to patches by subjects was made for ease of handling.

The patches do _not_ break any existing driver.
Patches were made (and tested to work) with wireless branch 2.6.24-rc3 (#everything)

The MLME framework includes the following:
- A-MPDU MLME (for aggregated Rx per STA/TID)
- addBA request support.
- delBA request support (recipient party).
- Block Ack Request (BAR) support.
- A-MPDU reordering.

---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.

#1 lore raw

PATCH v2 1/8 mac80211: A-MPDU Rx add low level driver API

This patch adds the API to perform A-MPDU actions between mac80211 and low level driver.

---
 include/net/mac80211.h |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)
include/net/mac80211.h +21 -0
index 0d67b33..418cd38 100644
@@ -915,6 +915,18 @@ enum ieee80211_erp_change_flags {
 	IEEE80211_ERP_CHANGE_PREAMBLE	= 1<<1,
 };
 
+/**
+ * enum ieee80211_ampdu_mlme_action - A-MPDU actions
+ *
+ * These flags are used with the ampdu_action() callback in
+ * &struct ieee80211_ops to indicate which action is needed.
+ * @IEEE80211_AMPDU_RX_START: start Rx aggregation
+ * @IEEE80211_AMPDU_RX_STOP: stop Rx aggregation
+ */
+enum ieee80211_ampdu_mlme_action {
+	IEEE80211_AMPDU_RX_START,
+	IEEE80211_AMPDU_RX_STOP,
+};
 
 /**
  * struct ieee80211_ops - callbacks from mac80211 to the driver
@@ -1043,6 +1055,12 @@ enum ieee80211_erp_change_flags {
  *	used to determine whether to reply to Probe Requests.
  *
  * @conf_ht: Configures low level driver with 802.11n HT data. Must be atomic.
+ *
+ * @ampdu_action: Perform a certain A-MPDU action
+ * 	The RA/TID combination determines the destination and TID we want
+ * 	the ampdu action to be performed for. The action is defined through
+ * 	ieee80211_ampdu_mlme_action. Starting sequence number (@ssn)
+ * 	is the first frame we expect to perform the action on.
  */
 struct ieee80211_ops {
 	int (*tx)(struct ieee80211_hw *hw, struct sk_buff *skb,
@@ -1089,6 +1107,9 @@ struct ieee80211_ops {
 			     struct ieee80211_tx_control *control);
 	int (*tx_last_beacon)(struct ieee80211_hw *hw);
 	int (*conf_ht)(struct ieee80211_hw *hw, struct ieee80211_conf *conf);
+	int (*ampdu_action)(struct ieee80211_hw *hw,
+			    enum ieee80211_ampdu_mlme_action action,
+			    const u8 *ra, u16 tid, u16 ssn);
 };
 
 /**
Signature · 9 lines
1.5.3.3

---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
#2 lore raw

PATCH v2 2/8 mac80211: A-MPDU Rx add MLME structures

In reply to Ron Rindjunsky

This patch adds the needed structures to describe the Rx aggregation MLME per STA new:
- struct tid_ampdu_rx: TID aggregation information (Rx)
- struct sta_ampdu_mlme: MLME aggregation information for STA
changed:
- struct sta_info: ampdu_mlme added to describe A-MPDU MLME per STA, and timer_to_tid added to map timer id into TID

---
 net/mac80211/sta_info.h |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 47 insertions(+), 0 deletions(-)
net/mac80211/sta_info.h +47 -0
index e1a4ac1..96fe3ed 100644
@@ -31,6 +31,51 @@
 #define WLAN_STA_WME BIT(9)
 #define WLAN_STA_WDS BIT(27)
 
+#define STA_TID_NUM 16
+#define ADDBA_RESP_INTERVAL HZ
+
+#define HT_AGG_STATE_INITIATOR_SHIFT	(4)
+
+#define HT_AGG_STATE_REQ_STOP_BA_MSK	BIT(3)
+
+#define HT_AGG_STATE_IDLE		(0x0)
+#define HT_AGG_STATE_OPERATIONAL	(0x7)
+
+/**
+ * struct tid_ampdu_rx - TID aggregation information (Rx).
+ *
+ * @state: TID's state in session state machine.
+ * @dialog_token: dialog token for aggregation session
+ * @ssn: Starting Sequence Number expected to be aggregated.
+ * @buf_size: buffer size for incoming A-MPDUs
+ * @timeout: reset timer value.
+ * @head_seq_num: head sequence number in reordering buffer.
+ * @stored_mpdu_num: number of MPDUs in reordering buffer
+ * @reorder_buf: buffer to reorder incoming aggregated MPDUs
+ * @session_timer: check if peer keeps Tx-ing on the TID (by timeout value)
+ */
+struct tid_ampdu_rx {
+	u8 state;
+	u8 dialog_token;
+	u16 ssn;
+	u16 buf_size;
+	u16 timeout;
+	u16 head_seq_num;
+	u16 stored_mpdu_num;
+	struct sk_buff **reorder_buf;
+	struct timer_list session_timer;
+};
+
+/**
+ * struct sta_ampdu_mlme - STA aggregation information.
+ *
+ * @tid_agg_info_rx: aggregation info for Rx per TID
+ * @ampdu_rx: for locking sections in aggregation Rx flow
+ */
+struct sta_ampdu_mlme {
+	struct tid_ampdu_rx tid_rx[STA_TID_NUM];
+	spinlock_t ampdu_rx;
+};
 
 struct sta_info {
 	struct kref kref;
@@ -101,6 +146,8 @@ struct sta_info {
 
 	struct ieee80211_ht_info ht_info; /* 802.11n HT capabilities
 					     of this STA */
+	struct sta_ampdu_mlme ampdu_mlme;
+	u8 timer_to_tid[STA_TID_NUM];	/* convert timer id to tid */
 
 #ifdef CONFIG_MAC80211_DEBUGFS
 	struct sta_info_debugfsdentries {
Signature · 9 lines
1.5.3.3

---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
#3 lore raw

PATCH v2 3/8 mac80211: A-MPDU Rx adding basic functionality

In reply to Ron Rindjunsky

This patch adds the basic needed abilities and functions for A-MPDU Rx session changed functions:
- ieee80211_sta_process_addba_request - Rx A-MPDU initialization enabled
added functions:
- ieee80211_send_delba - used for sending out Del BA in A-MPDU sessions
- ieee80211_sta_stop_rx_BA_session - stopping Rx A-MPDU session
- sta_rx_agg_session_timer_expired - stops A-MPDU Rx use if load is too low

---
 include/linux/ieee80211.h    |    7 ++
 net/mac80211/ieee80211_i.h   |    3 +
 net/mac80211/ieee80211_sta.c |  228 ++++++++++++++++++++++++++++++++++++++++--
 net/mac80211/sta_info.c      |    3 +
 4 files changed, 231 insertions(+), 10 deletions(-)
include/linux/ieee80211.h +7 -0
index 3e64159..4d5a4c9 100644
@@ -472,6 +472,13 @@ enum ieee80211_back_actioncode {
 	WLAN_ACTION_DELBA = 2,
 };
 
+/* BACK (block-ack) parties */
+enum ieee80211_back_parties {
+	WLAN_BACK_RECIPIENT = 0,
+	WLAN_BACK_INITIATOR = 1,
+	WLAN_BACK_TIMER = 2,
+};
+
 /* A-MSDU 802.11n */
 #define IEEE80211_QOS_CONTROL_A_MSDU_PRESENT 0x0080
 
net/mac80211/ieee80211_i.h +3 -0
index b54ed5f..cf2256b 100644
@@ -770,6 +770,9 @@ int ieee80211_ht_cap_ie_to_ht_info(struct ieee80211_ht_cap *ht_cap_ie,
 int ieee80211_ht_addt_info_ie_to_ht_bss_info(
 			struct ieee80211_ht_addt_info *ht_add_info_ie,
 			struct ieee80211_ht_bss_info *bss_info);
+void ieee80211_sta_stop_rx_BA_session(struct net_device *dev, u8 *da,
+				u16 tid, u16 initiator, u16 reason);
+void sta_rx_agg_session_timer_expired(unsigned long data);
 /* ieee80211_iface.c */
 int ieee80211_if_add(struct net_device *dev, const char *name,
 		     struct net_device **new_dev, int type);
net/mac80211/ieee80211_sta.c +218 -10

261 lines not on this page · raw message

net/mac80211/sta_info.c +3 -0
index e849155..cc28e82 100644
@@ -103,6 +103,7 @@ static void sta_info_release(struct kref *kref)
 	struct sta_info *sta = container_of(kref, struct sta_info, kref);
 	struct ieee80211_local *local = sta->local;
 	struct sk_buff *skb;
+	int i;
 
 	/* free sta structure; it has already been removed from
 	 * hash table etc. external structures. Make sure that all
@@ -115,6 +116,8 @@ static void sta_info_release(struct kref *kref)
 	while ((skb = skb_dequeue(&sta->tx_filtered)) != NULL) {
 		dev_kfree_skb_any(skb);
 	}
+	for (i = 0; i <  STA_TID_NUM; i++)
+		del_timer_sync(&sta->ampdu_mlme.tid_rx[i].session_timer);
 	rate_control_free_sta(sta->rate_ctrl, sta->rate_ctrl_priv);
 	rate_control_put(sta->rate_ctrl);
 	kfree(sta);
Signature · 9 lines
1.5.3.3

---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
maintainer
#4 lore raw

Re: [PATCH 3/8 v2] mac80211: A-MPDU Rx adding basic functionality

A few minor comments, looks good otherwise.

net/mac80211/ieee80211_sta.c static void ieee80211_sta_process_addba_request(struct net_device *dev, · line 1085

Quoted 3 lines
net/mac80211/ieee80211_sta.c +1 -0
 	status = WLAN_STATUS_REQUEST_DECLINED;
 
+

spurious newline added, I'd think.

net/mac80211/ieee80211_sta.c static void ieee80211_sta_process_addba_request(struct net_device *dev, · line 1129

Quoted 6 lines
net/mac80211/ieee80211_sta.c +6 -0
+	/* prepare reordering buffer */
+	tid_agg_rx->reorder_buf =
+		kmalloc(buf_size * sizeof(struct sk_buf *), GFP_ATOMIC);
+	if (!tid_agg_rx->reorder_buf) {
+		printk(KERN_ERR "can not allocate reordering buffer "
+						"to tid %d\n", tid);

Should that be ratelimited just in case somebody is trying over and over again while we're under memory pressure?

net/mac80211/ieee80211_sta.c static void ieee80211_sta_process_addba_request(struct net_device *dev, · line 1176

Quoted 2 lines
net/mac80211/ieee80211_sta.c +2 -0
+	skb = dev_alloc_skb(sizeof(*mgmt) + local->hw.extra_tx_headroom + 1 +
+					sizeof(mgmt->u.action.u.delba));

What's "+ 1"?

net/mac80211/ieee80211_sta.c static void ieee80211_sta_process_addba_request(struct net_device *dev, · line 1228

Quoted 2 lines
net/mac80211/ieee80211_sta.c +2 -0
+			printk(KERN_DEBUG "rx BA session requested to stop on "
+				"unactive tid %d\n", tid);

typo: "inactive"

net/mac80211/ieee80211_sta.c static void ieee80211_sta_process_addba_request(struct net_device *dev, · line 1285

Quoted 4 lines
net/mac80211/ieee80211_sta.c +4 -0
+	sta = sta_info_get(local, temp_sta->addr);
+
+	if (!sta)
+		return;

Still have that?

Thanks,
johannes

#5 lore raw

Re: [PATCH 3/8 v2] mac80211: A-MPDU Rx adding basic functionality

Quoted 7 lines

A few minor comments, looks good otherwise.

Quoted 3 lines
      status = WLAN_STATUS_REQUEST_DECLINED;

+

spurious newline added, I'd think.

will do

Quoted 11 lines

net/mac80211/ieee80211_sta.c static void ieee80211_sta_process_addba_request(struct net_device *dev, · line 1129

Quoted 7 lines
net/mac80211/ieee80211_sta.c +6 -0
+     /* prepare reordering buffer */
+     tid_agg_rx->reorder_buf =
+             kmalloc(buf_size * sizeof(struct sk_buf *), GFP_ATOMIC);
+     if (!tid_agg_rx->reorder_buf) {
+             printk(KERN_ERR "can not allocate reordering buffer "
+                                             "to tid %d\n", tid);

Should that be ratelimited just in case somebody is trying over and over again while we're under memory pressure?

done

Quoted 4 lines

net/mac80211/ieee80211_sta.c static void ieee80211_sta_process_addba_request(struct net_device *dev, · line 1176

Quoted 2 lines
net/mac80211/ieee80211_sta.c +2 -0
+     skb = dev_alloc_skb(sizeof(*mgmt) + local->hw.extra_tx_headroom + 1 +
+                                     sizeof(mgmt->u.action.u.delba));

What's "+ 1"?

that's for the category byte. in fact i think that the problem is not here, but in a wrong allocation size in send_addba_resp that i will fix.

Quoted 5 lines

net/mac80211/ieee80211_sta.c static void ieee80211_sta_process_addba_request(struct net_device *dev, · line 1228

Quoted 3 lines
net/mac80211/ieee80211_sta.c +2 -0
+                     printk(KERN_DEBUG "rx BA session requested to stop on "
+                             "unactive tid %d\n", tid);

typo: "inactive"

thanks

Quoted 8 lines

net/mac80211/ieee80211_sta.c static void ieee80211_sta_process_addba_request(struct net_device *dev, · line 1285

Quoted 5 lines
net/mac80211/ieee80211_sta.c +4 -0
+     sta = sta_info_get(local, temp_sta->addr);
+
+     if (!sta)
+             return;

Still have that?

i have cleaned it now, thatnks.

Quoted 4 lines

Thanks,
johannes

#6 lore raw

PATCH v2 4/8 mac80211: A-MPDU Rx MLME data initialization

In reply to Ron Rindjunsky

This patch initialize A-MPDU MLME data for Rx sessions.

---
 net/mac80211/sta_info.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
net/mac80211/sta_info.c +14 -0
index cc28e82..c03a714 100644
@@ -135,6 +135,7 @@ struct sta_info * sta_info_add(struct ieee80211_local *local,
 			       struct net_device *dev, u8 *addr, gfp_t gfp)
 {
 	struct sta_info *sta;
+	int i;
 	DECLARE_MAC_BUF(mac);
 
 	sta = kzalloc(sizeof(*sta), gfp);
@@ -154,6 +155,19 @@ struct sta_info * sta_info_add(struct ieee80211_local *local,
 	memcpy(sta->addr, addr, ETH_ALEN);
 	sta->local = local;
 	sta->dev = dev;
+	spin_lock_init(&sta->ampdu_mlme.ampdu_rx);
+	for (i = 0; i < STA_TID_NUM; i++) {
+		/* timer_to_tid must be initialized with identity mapping to
+		 * enable session_timer's data differentiation. refer to
+		 * sta_rx_agg_session_timer_expired for useage */
+		sta->timer_to_tid[i] = i;
+		/* rx timers */
+		sta->ampdu_mlme.tid_rx[i].session_timer.function =
+			sta_rx_agg_session_timer_expired;
+		sta->ampdu_mlme.tid_rx[i].session_timer.data =
+			(unsigned long)&sta->timer_to_tid[i];
+		init_timer(&sta->ampdu_mlme.tid_rx[i].session_timer);
+	}
 	skb_queue_head_init(&sta->ps_tx_buf);
 	skb_queue_head_init(&sta->tx_filtered);
 	__sta_info_get(sta);	/* sta used by caller, decremented by
Signature · 9 lines
1.5.3.3

---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
#7 lore raw

PATCH v2 5/8 mac80211: A-MPDU Rx handling aggregation reordering

In reply to Ron Rindjunsky

This patch handles the reordering of the Rx A-MPDU.
This issue occurs when the sequence of the internal MPDUs is not in the right order. such a case can be encountered for example when some MPDUs from previous aggregations were recieved, while others failed, so current A-MPDU will contain a mix of re-transmited MPDUs and new ones.

---
 include/net/mac80211.h       |   19 +++++
 net/mac80211/ieee80211_i.h   |    5 -
 net/mac80211/ieee80211_sta.c |   17 ++++-
 net/mac80211/rx.c            |  169 +++++++++++++++++++++++++++++++++++++++++-
 4 files changed, 203 insertions(+), 7 deletions(-)
include/net/mac80211.h +19 -0
index 418cd38..246c012 100644
@@ -361,6 +361,23 @@ enum mac80211_rx_flags {
 	RX_FLAG_FAILED_PLCP_CRC = 1<<6,
 };
 
+/*
+ * enum ieee80211_txrx_result - frame's status in Tx/Rx flow
+ *
+ * This enum gives an indication about the frame's current
+ * status in the flow. this enum is relevant both to Tx and Rx
+ * flows.
+ * @TXRX_CONTINUE: frame may proceed to next stage of the flow.
+ * @TXRX_DROP: frame should be dropped.
+ * @TXRX_QUEUED: frame is queued at this point, but may be
+ * 	put back in the flow in the future.
+ */
+typedef enum {
+	TXRX_CONTINUE,
+	TXRX_DROP,
+	TXRX_QUEUED
+} ieee80211_txrx_result;
+
 /**
  * struct ieee80211_rx_status - receive status
  *
@@ -376,6 +393,7 @@ enum mac80211_rx_flags {
  * @noise: PHY noise when receiving this frame
  * @antenna: antenna used
  * @rate: data rate
+ * @ordered: used in A-MPSDU reordering scheme
  * @flag: %RX_FLAG_*
  */
 struct ieee80211_rx_status {
@@ -388,6 +406,7 @@ struct ieee80211_rx_status {
 	int noise;
 	int antenna;
 	int rate;
+	ieee80211_txrx_result ordered;
 	int flag;
 };
 
net/mac80211/ieee80211_i.h +0 -5
index cf2256b..1034b71 100644
@@ -108,11 +108,6 @@ struct ieee80211_sta_bss {
 	u8 erp_value;
 };
 
-
-typedef enum {
-	TXRX_CONTINUE, TXRX_DROP, TXRX_QUEUED
-} ieee80211_txrx_result;
-
 /* flags used in struct ieee80211_txrx_data.flags */
 /* whether the MSDU was fragmented */
 #define IEEE80211_TXRXD_FRAGMENTED		BIT(0)
net/mac80211/ieee80211_sta.c +16 -1
index f696dbc..00ffa81 100644
@@ -1212,7 +1212,8 @@ void ieee80211_sta_stop_rx_BA_session(struct net_device *dev, u8 *ra, u16 tid,
 	struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
 	struct ieee80211_hw *hw = &local->hw;
 	struct sta_info *sta;
-	int ret;
+	struct ieee80211_rx_status status;
+	int ret, i;
 
 	sta = sta_info_get(local, ra);
 	if (!sta)
@@ -1254,6 +1255,20 @@ void ieee80211_sta_stop_rx_BA_session(struct net_device *dev, u8 *ra, u16 tid,
 		ieee80211_send_delba(dev, ra, tid, 0, reason);
 
 	/* free the reordering buffer */
+	for (i = 0; i < sta->ampdu_mlme.tid_rx[tid].buf_size; i++) {
+		if (sta->ampdu_mlme.tid_rx[tid].reorder_buf[i]) {
+			/* release the reordered frames to stack,
+			 * but drop them there */
+			memcpy(&status, sta->ampdu_mlme.tid_rx[tid].
+				reorder_buf[i]->cb, sizeof(status));
+			status.ordered = TXRX_DROP;
+			__ieee80211_rx(hw, sta->ampdu_mlme.
+				       tid_rx[tid].reorder_buf[i],
+				       &status);
+			sta->ampdu_mlme.tid_rx[tid].stored_mpdu_num--;
+			sta->ampdu_mlme.tid_rx[tid].reorder_buf[i] = NULL;
+		}
+	}
 	kfree(sta->ampdu_mlme.tid_rx[tid].reorder_buf);
 
 	sta->ampdu_mlme.tid_rx[tid].state = HT_AGG_STATE_IDLE;
net/mac80211/rx.c +168 -1

191 lines not on this page · raw message

Signature · 9 lines
1.5.3.3

---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
maintainer
#8 lore raw

Re: [PATCH 5/8 v2] mac80211: A-MPDU Rx handling aggregation reordering

Quoted 12 lines
net/mac80211/ieee80211_sta.c +2 -1
@@ -1212,7 +1212,8 @@ void ieee80211_sta_stop_rx_BA_session(struct net_device *dev, u8 *ra, u16 tid,
 	struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
 	struct ieee80211_hw *hw = &local->hw;
 	struct sta_info *sta;
-	int ret;
+	struct ieee80211_rx_status status;
+	int ret, i;
 
 	sta = sta_info_get(local, ra);
 	if (!sta)

net/mac80211/ieee80211_sta.c void ieee80211_sta_stop_rx_BA_session(struct net_device *dev, u8 *ra, u16 tid, · line 1258

Quoted 4 lines
net/mac80211/ieee80211_sta.c +1 -0
@@ -1254,6 +1255,20 @@ void ieee80211_sta_stop_rx_BA_session(struct net_device *dev, u8 *ra, u16 tid,
 		ieee80211_send_delba(dev, ra, tid, 0, reason);
 
 	/* free the reordering buffer */
+	for (i = 0; i < sta->ampdu_mlme.tid_rx[tid].buf_size; i++) {

Something I just thought of but probably simply missed: where's the session torn down when we ifdown an interface while an A-MPDU session is active? I didn't go through all the patches again, did I miss that somewhere?

johannes

#9 lore raw

Re: [PATCH 5/8 v2] mac80211: A-MPDU Rx handling aggregation reordering

Quoted 13 lines
Quoted 13 lines
net/mac80211/ieee80211_sta.c +2 -1
@@ -1212,7 +1212,8 @@ void ieee80211_sta_stop_rx_BA_session(struct net_device *dev, u8 *ra, u16 tid,
      struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
      struct ieee80211_hw *hw = &local->hw;
      struct sta_info *sta;
-     int ret;
+     struct ieee80211_rx_status status;
+     int ret, i;
 
      sta = sta_info_get(local, ra);
      if (!sta)
@@ -1254,6 +1255,20 @@ void ieee80211_sta_stop_rx_BA_session(struct net_device *dev, u8 *ra, u16 tid,
              ieee80211_send_delba(dev, ra, tid, 0, reason);
 
Quoted 8 lines

net/mac80211/ieee80211_sta.c void ieee80211_sta_stop_rx_BA_session(struct net_device *dev, u8 *ra, u16 tid, · line 1258

Quoted 2 lines
net/mac80211/ieee80211_sta.c +1 -0
      /* free the reordering buffer */
+     for (i = 0; i < sta->ampdu_mlme.tid_rx[tid].buf_size; i++) {

Something I just thought of but probably simply missed: where's the session torn down when we ifdown an interface while an A-MPDU session is active? I didn't go through all the patches again, did I miss that somewhere?

No, and it should be done.
were would you recommend to put this tear down? i need a flow were i can be sta specific, and is called only once per ifdown. sta_info_release related flow, were i thought to put it, is risking me with endless loops of kref_put calls.

Quoted 3 lines

johannes

maintainer
#10 lore raw

Re: [PATCH 5/8 v2] mac80211: A-MPDU Rx handling aggregation reordering

Quoted 6 lines

No, and it should be done.
were would you recommend to put this tear down? i need a flow were i can be sta specific, and is called only once per ifdown. sta_info_release related flow, were i thought to put it, is risking me with endless loops of kref_put calls.

That's actually an interesting question. We should, like with keys, remove all STA info from the driver when the corresponding interface is down. I'd think it should happen at the same time. I guess you'll have to add some sort of loop to tear down stations to the down code, I don't really see any easy way right now.

johannes

#11 lore raw

Re: [PATCH 5/8 v2] mac80211: A-MPDU Rx handling aggregation reordering

Quoted 6 lines
Quoted 5 lines

No, and it should be done.
were would you recommend to put this tear down? i need a flow were i can be sta specific, and is called only once per ifdown. sta_info_release related flow, were i thought to put it, is risking me with endless loops of kref_put calls.

Quoted 6 lines

That's actually an interesting question. We should, like with keys, remove all STA info from the driver when the corresponding interface is down. I'd think it should happen at the same time. I guess you'll have to add some sort of loop to tear down stations to the down code, I don't really see any easy way right now.

what about list_for_each_entry sta inside ieee80211_stop to stop the session? i tried it and it worked really well.

Quoted 3 lines

johannes

maintainer
#12 lore raw

Re: [PATCH 5/8 v2] mac80211: A-MPDU Rx handling aggregation reordering

Quoted 3 lines

what about list_for_each_entry sta inside ieee80211_stop to stop the session? i tried it and it worked really well.

Sounds about right, you just need to make sure that you have the right locks and only tear down sessions for the virtual interface that's being stopped, not all if you have sessions on different virtual interfaces (say on a multi-BSS AP when one BSS is stopped)

johannes

#13 lore raw

Re: [PATCH 5/8 v2] mac80211: A-MPDU Rx handling aggregation reordering

Quoted 7 lines
Quoted 2 lines

what about list_for_each_entry sta inside ieee80211_stop to stop the session? i tried it and it worked really well.

Sounds about right, you just need to make sure that you have the right locks and only tear down sessions for the virtual interface that's being stopped, not all if you have sessions on different virtual interfaces (say on a multi-BSS AP when one BSS is stopped)

ok. i not sure i got it all the way right, but it is in the patch. As i don't want to hold the whole series any more, i am sending the series over, and if this specific issue is not well i'll issue only a patch for it.
thanks
ron

Quoted 4 lines

johannes

#14 lore raw

PATCH v2 6/8 mac80211: A-MPDU Rx adding BAR handling capability

In reply to Ron Rindjunsky

This patch adds the ability to handle Block Ack Request

---
 net/mac80211/ieee80211_i.h |    3 +-
 net/mac80211/rx.c          |   53 ++++++++++++++++++++++++++++++++++++++++---
 net/mac80211/util.c        |   15 +++++++++++-
 3 files changed, 65 insertions(+), 6 deletions(-)
net/mac80211/ieee80211_i.h +2 -1
index 1034b71..9215c22 100644
@@ -799,7 +799,8 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb, struct net_device *dev);
 extern void *mac80211_wiphy_privid; /* for wiphy privid */
 extern const unsigned char rfc1042_header[6];
 extern const unsigned char bridge_tunnel_header[6];
-u8 *ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len);
+u8 *ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len,
+			enum ieee80211_if_types type);
 int ieee80211_is_eapol(const struct sk_buff *skb, int hdrlen);
 int ieee80211_frame_duration(struct ieee80211_local *local, size_t len,
 			     int rate, int erp, int short_preamble);
net/mac80211/rx.c +49 -4

89 lines not on this page · raw message

net/mac80211/util.c +14 -1
index fb7fd89..d567b83 100644
@@ -131,7 +131,8 @@ void ieee80211_prepare_rates(struct ieee80211_local *local,
 	}
 }
 
-u8 *ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len)
+u8 *ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len,
+			enum ieee80211_if_types type)
 {
 	u16 fc;
 
@@ -163,6 +164,18 @@ u8 *ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len)
 	case IEEE80211_FTYPE_CTL:
 		if ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PSPOLL)
 			return hdr->addr1;
+		else if ((fc & IEEE80211_FCTL_STYPE) ==
+						IEEE80211_STYPE_BACK_REQ) {
+			switch (type) {
+			case IEEE80211_IF_TYPE_STA:
+				return hdr->addr2;
+			case IEEE80211_IF_TYPE_AP:
+			case IEEE80211_IF_TYPE_VLAN:
+				return hdr->addr1;
+			default:
+				return NULL;
+			}
+		}
 		else
 			return NULL;
 	}
Signature · 9 lines
1.5.3.3

---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
#15 lore raw

PATCH v2 7/8 mac80211: A-MPDU Rx handling DELBA requests

In reply to Ron Rindjunsky

This patch opens the flow to DELBA management frames, and handles end of A-MPDU session produced by this event.

---
 net/mac80211/ieee80211_sta.c |   40 +++++++++++++++++++++++++++++++++++++++-
 1 files changed, 39 insertions(+), 1 deletions(-)
net/mac80211/ieee80211_sta.c +39 -1
index 00ffa81..9301a53 100644
@@ -63,6 +63,8 @@
 #define IEEE80211_ADDBA_PARAM_POLICY_MASK 0x0002
 #define IEEE80211_ADDBA_PARAM_TID_MASK 0x003C
 #define IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK 0xFFA0
+#define IEEE80211_DELBA_PARAM_TID_MASK 0xF000
+#define IEEE80211_DELBA_PARAM_INITIATOR_MASK 0x0800
 
 /* next values represent the buffer size for A-MPDU frame.
  * According to IEEE802.11n spec size varies from 8K to 64K (in powers of 2) */
@@ -1275,6 +1277,36 @@ void ieee80211_sta_stop_rx_BA_session(struct net_device *dev, u8 *ra, u16 tid,
 	sta_info_put(sta);
 }
 
+static void ieee80211_sta_process_delba(struct net_device *dev,
+			struct ieee80211_mgmt *mgmt, size_t len)
+{
+	struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
+	struct sta_info *sta;
+	u16 tid, params;
+	u16 initiator;
+	DECLARE_MAC_BUF(mac);
+
+	sta = sta_info_get(local, mgmt->sa);
+	if (!sta)
+		return;
+
+	params = le16_to_cpu(mgmt->u.action.u.delba.params);
+	tid = (params & IEEE80211_DELBA_PARAM_TID_MASK) >> 12;
+	initiator = (params & IEEE80211_DELBA_PARAM_INITIATOR_MASK) >> 11;
+
+#ifdef CONFIG_MAC80211_HT_DEBUG
+	if (net_ratelimit())
+		printk(KERN_DEBUG "delba from %s on tid %d reason code %d\n",
+			print_mac(mac, mgmt->sa), tid,
+			mgmt->u.action.u.delba.reason_code);
+#endif /* CONFIG_MAC80211_HT_DEBUG */
+
+	if (initiator == WLAN_BACK_INITIATOR)
+		ieee80211_sta_stop_rx_BA_session(dev, sta->addr, tid,
+						 WLAN_BACK_INITIATOR, 0);
+	sta_info_put(sta);
+}
+
 /*
  * After receiving Block Ack Request (BAR) we activated a
  * timer after each frame arrives from the originator.
@@ -2238,9 +2270,15 @@ void ieee80211_rx_mgmt_action(struct net_device *dev,
 				break;
 			ieee80211_sta_process_addba_request(dev, mgmt, len);
 			break;
+		case WLAN_ACTION_DELBA:
+			if (len < (IEEE80211_MIN_ACTION_SIZE +
+				   sizeof(mgmt->u.action.u.delba)))
+				break;
+			ieee80211_sta_process_delba(dev, mgmt, len);
+			break;
 		default:
 			if (net_ratelimit())
-			   printk(KERN_DEBUG "%s: received unsupported BACK\n",
+			   printk(KERN_DEBUG "%s: Rx unknown A-MPDU action\n",
 					dev->name);
 			break;
 		}
Signature · 9 lines
1.5.3.3

---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
#16 lore raw

PATCH v2 8/8 iwlwifi: A-MPDU Rx flow enabled

In reply to Ron Rindjunsky

This patch enables the A-MPDU Rx flow. it contains several adjustments to new mac80211 A-MPDU Rx flow.

---
 drivers/net/wireless/iwlwifi/iwl-4965.c     |   66 +++++++++++++--------------
 drivers/net/wireless/iwlwifi/iwl-4965.h     |    7 +--
 drivers/net/wireless/iwlwifi/iwl4965-base.c |    3 +-
 3 files changed, 36 insertions(+), 40 deletions(-)
drivers/net/wireless/iwlwifi/iwl-4965.c +32 -34
Index: wl2_6_24_rc5/drivers/net/wireless/iwlwifi/iwl-4965.c
===================================================================
@@ -3868,9 +3868,7 @@ static void iwl4965_rx_reply_rx(struct i
 		.antenna = 0,
 		.rate = iwl4965_hw_get_rate(rx_start->rate_n_flags),
 		.flag = 0,
-#ifdef CONFIG_IWL4965_HT_AGG
-		.ordered = 0
-#endif /* CONFIG_IWL4965_HT_AGG */
+		.ordered = TXRX_CONTINUE
 	};
 	u8 network_packet;
 
@@ -4065,7 +4063,7 @@ static void iwl4965_rx_reply_rx(struct i
 		break;
 
 	case IEEE80211_FTYPE_CTL:
-#ifdef CONFIG_IWL4965_HT_AGG
+#ifdef CONFIG_IWL4965_HT
 		switch (fc & IEEE80211_FCTL_STYPE) {
 		case IEEE80211_STYPE_BACK_REQ:
 			IWL_DEBUG_HT("IEEE80211_STYPE_BACK_REQ arrived\n");
@@ -4076,7 +4074,6 @@ static void iwl4965_rx_reply_rx(struct i
 			break;
 		}
 #endif
-
 		break;
 
 	case IEEE80211_FTYPE_DATA: {
@@ -4663,8 +4660,6 @@ void iwl4965_set_ht_add_station(struct i
 	return;
 }
 
-#ifdef CONFIG_IWL4965_HT_AGG
-
 static void iwl4965_sta_modify_add_ba_tid(struct iwl4965_priv *priv,
 					  int sta_id, int tid, u16 ssn)
 {
@@ -4696,6 +4691,36 @@ static void iwl4965_sta_modify_del_ba_ti
 	iwl4965_send_add_station(priv, &priv->stations[sta_id].sta, CMD_ASYNC);
 }
 
+int iwl4965_mac_ampdu_action(struct ieee80211_hw *hw,
+			     enum ieee80211_ampdu_mlme_action action,
+			     const u8 *addr, u16 tid, u16 ssn)
+{
+	struct iwl4965_priv *priv = hw->priv;
+	int sta_id;
+	DECLARE_MAC_BUF(mac);
+
+	IWL_DEBUG_HT("A-MPDU action on da=%s tid=%d ",
+			print_mac(mac, addr), tid);
+	sta_id = iwl4965_hw_find_station(priv, addr);
+	switch (action) {
+	case IEEE80211_AMPDU_RX_START:
+		IWL_DEBUG_HT("start Rx\n");
+		iwl4965_sta_modify_add_ba_tid(priv, sta_id, tid, ssn);
+		break;
+	case IEEE80211_AMPDU_RX_STOP:
+		IWL_DEBUG_HT("stop Rx\n");
+		iwl4965_sta_modify_del_ba_tid(priv, sta_id, tid);
+		break;
+	default:
+		IWL_DEBUG_HT("unknown\n");
+		return -EINVAL;
+		break;
+	}
+	return 0;
+}
+
+#ifdef CONFIG_IWL4965_HT_AGG
+
 static const u16 default_tid_to_tx_fifo[] = {
 	IWL_TX_FIFO_AC1,
 	IWL_TX_FIFO_AC0,
@@ -4825,33 +4850,6 @@ int iwl4965_mac_ht_tx_agg_stop(struct ie
 	return 0;
 }
 
-int iwl4965_mac_ht_rx_agg_start(struct ieee80211_hw *hw, u8 *da,
-			    u16 tid, u16 start_seq_num)
-{
-	struct iwl4965_priv *priv = hw->priv;
-	int sta_id;
-	DECLARE_MAC_BUF(mac);
-
-	IWL_WARNING("iwl-AGG iwl4965_mac_ht_rx_agg_start on da=%s"
-		    " tid=%d\n", print_mac(mac, da), tid);
-	sta_id = iwl4965_hw_find_station(priv, da);
-	iwl4965_sta_modify_add_ba_tid(priv, sta_id, tid, start_seq_num);
-	return 0;
-}
-
-int iwl4965_mac_ht_rx_agg_stop(struct ieee80211_hw *hw, u8 *da,
-			   u16 tid, int generator)
-{
-	struct iwl4965_priv *priv = hw->priv;
-	int sta_id;
-	DECLARE_MAC_BUF(mac);
-
-	IWL_WARNING("iwl-AGG iwl4965_mac_ht_rx_agg_stop on da=%s tid=%d\n",
-		    print_mac(mac, da), tid);
-	sta_id = iwl4965_hw_find_station(priv, da);
-	iwl4965_sta_modify_del_ba_tid(priv, sta_id, tid);
-	return 0;
-}
 
 #endif /* CONFIG_IWL4965_HT_AGG */
 #endif /* CONFIG_IWL4965_HT */
drivers/net/wireless/iwlwifi/iwl-4965.h +3 -4
Index: wl2_6_24_rc5/drivers/net/wireless/iwlwifi/iwl-4965.h
===================================================================
@@ -802,13 +802,12 @@ extern void iwl4965_set_rxon_ht(struct i
 				struct iwl_ht_info *ht_info);
 extern void iwl4965_set_ht_add_station(struct iwl4965_priv *priv, u8 index,
 				struct ieee80211_ht_info *sta_ht_inf);
+extern int iwl4965_mac_ampdu_action(struct ieee80211_hw *hw,
+				    enum ieee80211_ampdu_mlme_action action,
+				    const u8 *addr, u16 tid, u16 ssn);
 #ifdef CONFIG_IWL4965_HT_AGG
 extern int iwl4965_mac_ht_tx_agg_start(struct ieee80211_hw *hw, u8 *da,
 				   u16 tid, u16 *start_seq_num);
-extern int iwl4965_mac_ht_rx_agg_start(struct ieee80211_hw *hw, u8 *da,
-				   u16 tid, u16 start_seq_num);
-extern int iwl4965_mac_ht_rx_agg_stop(struct ieee80211_hw *hw, u8 *da,
-				  u16 tid, int generator);
 extern int iwl4965_mac_ht_tx_agg_stop(struct ieee80211_hw *hw, u8 *da,
 				  u16 tid, int generator);
 extern void iwl4965_turn_off_agg(struct iwl4965_priv *priv, u8 tid);
drivers/net/wireless/iwlwifi/iwl4965-base.c +1 -2
Index: wl2_6_24_rc5/drivers/net/wireless/iwlwifi/iwl4965-base.c
===================================================================
@@ -9054,11 +9054,10 @@ static struct ieee80211_ops iwl4965_hw_o
 	.erp_ie_changed = iwl4965_mac_erp_ie_changed,
 #ifdef CONFIG_IWL4965_HT
 	.conf_ht = iwl4965_mac_conf_ht,
+	.ampdu_action = iwl4965_mac_ampdu_action,
 #ifdef CONFIG_IWL4965_HT_AGG
 	.ht_tx_agg_start = iwl4965_mac_ht_tx_agg_start,
 	.ht_tx_agg_stop = iwl4965_mac_ht_tx_agg_stop,
-	.ht_rx_agg_start = iwl4965_mac_ht_rx_agg_start,
-	.ht_rx_agg_stop = iwl4965_mac_ht_rx_agg_stop,
 #endif  /* CONFIG_IWL4965_HT_AGG */
 #endif  /* CONFIG_IWL4965_HT */
 	.hw_scan = iwl4965_mac_hw_scan

---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.

maintainer
#17 lore raw
In reply to Ron Rindjunsky
Quoted 2 lines · Ron Rindjunsky

This series of patches contains implementation for the IEEE802.11n aggregated MPDUs (A-MPDU) MLME. The series handles Rx A-MPDU (recipient party).

Thanks. I'll re-review once you've commented on my last mail from this morning.

johannes