Skip to contentSkip to conversation

ar9170: aggregation xmit (aka the _other_ part)

RFC New Christian Lamparter 1 participant 1 message Jun 6, 2009

lore
Share & tools
lore
#0 lore raw

RFC 1/1 ar9170: aggregation xmit (aka the _other_ part)

This is a first shot at HT xmit aggregation.

This code is experimental.
So, you better know what you're doing!

So far I managed to continuously send with up to 60mbits (iperf tcp), Which is - i hope - good enough to get other people, with spare time, more devices and/or access to the specs, in the boat.

--- content (patches)
7-txagg-v06-rfc-2.diff adds A-MPDU _feature_ to ar9170,

IMPORTANT:
Since 11n isn't stable, so that's why it must be enabled with the ht=1 module parameter.

8-fake-mcs-rate.diff - literally maps 802.11b/g rates to HT MCS indexes. This is just a quick hack (until minstrel supports HT MCS indexes). (Note: the rate can also be set with iwconfig wlanX rate ${802.11b/g rate})

--- requirements
- wireless-testing [with [PATCH] ar9170: xmit code revamp (or better)]
- better be close (but not too close!) to the 11n AP.
- as always: luck.
- ...

--- missing, or untested
- all marvell / broadcom (etc...) workarounds
- mimo powersave?
- ANI/calibration (for better range and throughput)
- encryption (only tested with a unencrypted network)
- spec conformance (I don't have them...
And this is always a good source for bugs!)
- only tested with the old PHASE_2 firmware
- extended testing in crowed areas, roaming, really big transfer volumes (e.g up to 100GB), etc.

Regards,
Chr
---

drivers/net/wireless/ath/ar9170/ar9170.h +58 -0
index bb97981..47c1630 100644
@@ -109,11 +109,53 @@ struct ar9170_rxstream_mpdu_merge {
 	bool has_plcp;
 };
 
+#define AR9170_NUM_MAX_BA_RETRY	5
+#define AR9170_NUM_TID	16
+#define WME_BA_BMP_SIZE         64
+#define AR9170_NUM_MAX_AGG_LEN	(2 * WME_BA_BMP_SIZE)
+
+#define WME_AC_BE   2
+#define WME_AC_BK   3
+#define WME_AC_VI   1
+#define WME_AC_VO   0
+
+#define TID_TO_WME_AC(_tid)				\
+	((((_tid) == 0) || ((_tid) == 3)) ? WME_AC_BE :	\
+	 (((_tid) == 1) || ((_tid) == 2)) ? WME_AC_BK :	\
+	 (((_tid) == 4) || ((_tid) == 5)) ? WME_AC_VI :	\
+	 WME_AC_VO)
+
+#define BAW_WITHIN(_start, _bawsz, _seqno) \
+	((((_seqno) - (_start)) & 0xfff) < (_bawsz))
+
+enum ar9170_tid_state {
+	AR9170_TID_STATE_INVALID,
+	AR9170_TID_STATE_SHUTDOWN,
+	AR9170_TID_STATE_STARTING,
+	AR9170_TID_STATE_PROGRESS,
+	AR9170_TID_STATE_COMPLETE,
+};
+
+struct ar9170_sta_tid {
+	struct list_head list;
+	struct sk_buff_head queue;
+	u8 addr[ETH_ALEN];
+	u16 ssn;
+	u16 tid;
+	enum ar9170_tid_state state;
+	bool active;
+	u8 retry;
+};
+
 #define AR9170_QUEUE_TIMEOUT		64
 #define AR9170_TX_TIMEOUT		8
+#define AR9170_BA_TIMEOUT		4
 #define AR9170_JANITOR_DELAY		128
 #define AR9170_TX_INVALID_RATE		0xffffffff
 
+#define AR9170_NUM_TX_STATUS		128
+#define AR9170_NUM_TX_AGG_MAX		30
+
 struct ar9170 {
 	struct ieee80211_hw *hw;
 	struct mutex mutex;
@@ -187,14 +229,30 @@ struct ar9170 {
 	struct sk_buff_head tx_pending[__AR9170_NUM_TXQ];
 	struct sk_buff_head tx_status[__AR9170_NUM_TXQ];
 	struct delayed_work tx_janitor;
+	/* tx ampdu */
+	struct sk_buff_head tx_status_ampdu;
+
+	spinlock_t tx_ampdu_list_lock;
+	struct list_head tx_ampdu_list;
+	unsigned int tx_ampdu_pending;
+
+	spinlock_t addba_list_lock;
+	struct list_head addba_list;
+	struct work_struct start_tx_ba_work;
 
 	/* rxstream mpdu merge */
 	struct ar9170_rxstream_mpdu_merge rx_mpdu;
 	struct sk_buff *rx_failover;
 	int rx_failover_missing;
+
+	/* (cached) HW A-MPDU settings */
+	u8 global_ampdu_density;
+	u8 global_ampdu_factor;
 };
 
 struct ar9170_sta_info {
+	struct ar9170_sta_tid agg[AR9170_NUM_TID];
+	unsigned int ampdu_max_len;
 };
 
 #define AR9170_TX_FLAG_WAIT_FOR_ACK	BIT(0)
drivers/net/wireless/ath/ar9170/main.c +677 -27

938 lines not on this page · raw message

drivers/net/wireless/ath/ar9170/main.c +20 -2
index e7d4a98..c781980 100644
@@ -1452,6 +1452,11 @@ static int ar9170_tx_prepare(struct ar9170 *ar, struct sk_buff *skb)
 			txc->mac_control |= cpu_to_le16(AR9170_TX_MAC_AGGR);
 			arinfo->flags = AR9170_TX_FLAG_BLOCK_ACK;
 
+#ifndef AR9170_MAC80211_RC_MCS
+			txrate->flags &= ~IEEE80211_TX_RC_USE_SHORT_PREAMBLE;
+			txrate->flags |= IEEE80211_TX_RC_MCS;
+#endif /* AR9170_MAC80211_RC_MCS */
+
 			goto out;
 		}
 
@@ -1513,6 +1518,15 @@ static void ar9170_tx_prepare_phy(struct ar9170 *ar, struct sk_buff *skb)
 		u32 r = txrate->idx;
 		u8 *txpower;
 
+#ifndef AR9170_MAC80211_RC_MCS
+		txrate->flags &= ~IEEE80211_TX_RC_MCS;
+
+		if (ar->eeprom.tx_mask == 1)
+			txrate->idx = r = min_t(s8, txrate->idx, 7);
+		else
+			txrate->idx = r = min_t(s8, txrate->idx, 15);
+#endif /* AR9170_MAC80211_RC_MCS */
+
 		/* heavy clip control */
 		txc->phy_control |= cpu_to_le32((r & 0x7) << 7);
 
@@ -1576,8 +1590,12 @@ static void ar9170_tx_prepare_phy(struct ar9170 *ar, struct sk_buff *skb)
 		chains = AR9170_TX_PHY_TXCHAIN_2;
 
 		/* >= 36M legacy OFDM - use only one chain */
-		if (rate && rate->bitrate >= 360)
-			chains = AR9170_TX_PHY_TXCHAIN_1;
+		if (rate && rate->bitrate >= 360) {
+#ifndef AR9170_MAC80211_RC_MCS
+			if (!(txrate->flags & IEEE80211_TX_RC_MCS))
+#endif /* AR9170_MAC80211_RC_MCS */
+				chains = AR9170_TX_PHY_TXCHAIN_1;
+		}
 	}
 	txc->phy_control |= cpu_to_le32(chains << AR9170_TX_PHY_TXCHAIN_SHIFT);
 }