mac80211: add block ack request capability
authorRon Rindjunsky <ron.rindjunsky@intel.com>
Tue, 1 Jul 2008 11:16:03 +0000 (14:16 +0300)
committerJohn W. Linville <linville@tuxdriver.com>
Tue, 8 Jul 2008 14:21:34 +0000 (10:21 -0400)
This patch adds block ack request capability

Signed-off-by: Ester Kummer <ester.kummer@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Ron Rindjunsky <ron.rindjunsky@intel.com>
Acked-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
include/linux/ieee80211.h
include/net/mac80211.h
net/mac80211/ieee80211_i.h
net/mac80211/main.c
net/mac80211/mlme.c

index cffd6d0094f9c00b2a93d735d7c07f15fd13c8c6..aa603c3d76d161e55a7fe1bed6fbc4c11354daf5 100644 (file)
@@ -658,6 +658,10 @@ struct ieee80211_bar {
        __le16 start_seq_num;
 } __attribute__((packed));
 
+/* 802.11 BAR control masks */
+#define IEEE80211_BAR_CTRL_ACK_POLICY_NORMAL     0x0000
+#define IEEE80211_BAR_CTRL_CBMTID_COMPRESSED_BA  0x0004
+
 /**
  * struct ieee80211_ht_cap - HT capabilities
  *
index 3a204acad90166d0f4ff1d7eadbaa1b292dcd119..0a5de3ef527a89d42bd229c398f7cf6f7cd6490b 100644 (file)
@@ -235,6 +235,8 @@ struct ieee80211_bss_conf {
  * @IEEE80211_TX_STAT_ACK: Frame was acknowledged
  * @IEEE80211_TX_STAT_AMPDU: The frame was aggregated, so status
  *     is for the whole aggregation.
+ * @IEEE80211_TX_STAT_AMPDU_NO_BACK: no block ack was returned,
+ *     so consider using block ack request (BAR).
  */
 enum mac80211_tx_control_flags {
        IEEE80211_TX_CTL_REQ_TX_STATUS          = BIT(0),
@@ -260,6 +262,7 @@ enum mac80211_tx_control_flags {
        IEEE80211_TX_STAT_TX_FILTERED           = BIT(20),
        IEEE80211_TX_STAT_ACK                   = BIT(21),
        IEEE80211_TX_STAT_AMPDU                 = BIT(22),
+       IEEE80211_TX_STAT_AMPDU_NO_BACK         = BIT(23),
 };
 
 
index f90da1bbec491fd926c2d75bdd9b4fafed90e989..175cbdd36d7f3d7cb0ba747af00d83322f9c32a4 100644 (file)
@@ -904,6 +904,7 @@ void ieee80211_send_addba_request(struct net_device *dev, const u8 *da,
                                  u16 agg_size, u16 timeout);
 void ieee80211_send_delba(struct net_device *dev, const u8 *da, u16 tid,
                                u16 initiator, u16 reason_code);
+void ieee80211_send_bar(struct net_device *dev, u8 *ra, u16 tid, u16 ssn);
 
 void ieee80211_sta_stop_rx_ba_session(struct net_device *dev, u8 *da,
                                u16 tid, u16 initiator, u16 reason);
index f18cfd7278726a53e9cd261b6bb91a4777ae4153..074f71a62a6def263807c23006d4f72ce56c64e5 100644 (file)
@@ -1404,14 +1404,15 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb)
        struct ieee80211_local *local = hw_to_local(hw);
        struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
        u16 frag, type;
+       __le16 fc;
        struct ieee80211_tx_status_rtap_hdr *rthdr;
        struct ieee80211_sub_if_data *sdata;
        struct net_device *prev_dev = NULL;
+       struct sta_info *sta;
 
        rcu_read_lock();
 
        if (info->status.excessive_retries) {
-               struct sta_info *sta;
                sta = sta_info_get(local, hdr->addr1);
                if (sta) {
                        if (test_sta_flags(sta, WLAN_STA_PS)) {
@@ -1426,8 +1427,24 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb)
                }
        }
 
+       fc = hdr->frame_control;
+
+       if ((info->flags & IEEE80211_TX_STAT_AMPDU_NO_BACK) &&
+           (ieee80211_is_data_qos(fc))) {
+               u16 tid, ssn;
+               u8 *qc;
+               sta = sta_info_get(local, hdr->addr1);
+               if (sta) {
+                       qc = ieee80211_get_qos_ctl(hdr);
+                       tid = qc[0] & 0xf;
+                       ssn = ((le16_to_cpu(hdr->seq_ctrl) + 0x10)
+                                               & IEEE80211_SCTL_SEQ);
+                       ieee80211_send_bar(sta->sdata->dev, hdr->addr1,
+                                          tid, ssn);
+               }
+       }
+
        if (info->flags & IEEE80211_TX_STAT_TX_FILTERED) {
-               struct sta_info *sta;
                sta = sta_info_get(local, hdr->addr1);
                if (sta) {
                        ieee80211_handle_filtered_frame(local, sta, skb);
index 86abdf96390c9bd59dc693137c88aff748fde5c7..e080482b63cd93522412180354839f404d89b3cd 100644 (file)
@@ -1536,6 +1536,35 @@ void ieee80211_send_delba(struct net_device *dev, const u8 *da, u16 tid,
        ieee80211_sta_tx(dev, skb, 0);
 }
 
+void ieee80211_send_bar(struct net_device *dev, u8 *ra, u16 tid, u16 ssn)
+{
+       struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
+       struct sk_buff *skb;
+       struct ieee80211_bar *bar;
+       u16 bar_control = 0;
+
+       skb = dev_alloc_skb(sizeof(*bar) + local->hw.extra_tx_headroom);
+       if (!skb) {
+               printk(KERN_ERR "%s: failed to allocate buffer for "
+                       "bar frame\n", dev->name);
+               return;
+       }
+       skb_reserve(skb, local->hw.extra_tx_headroom);
+       bar = (struct ieee80211_bar *)skb_put(skb, sizeof(*bar));
+       memset(bar, 0, sizeof(*bar));
+       bar->frame_control = IEEE80211_FC(IEEE80211_FTYPE_CTL,
+                                       IEEE80211_STYPE_BACK_REQ);
+       memcpy(bar->ra, ra, ETH_ALEN);
+       memcpy(bar->ta, dev->dev_addr, ETH_ALEN);
+       bar_control |= (u16)IEEE80211_BAR_CTRL_ACK_POLICY_NORMAL;
+       bar_control |= (u16)IEEE80211_BAR_CTRL_CBMTID_COMPRESSED_BA;
+       bar_control |= (u16)(tid << 12);
+       bar->control = cpu_to_le16(bar_control);
+       bar->start_seq_num = cpu_to_le16(ssn);
+
+       ieee80211_sta_tx(dev, skb, 0);
+}
+
 void ieee80211_sta_stop_rx_ba_session(struct net_device *dev, u8 *ra, u16 tid,
                                        u16 initiator, u16 reason)
 {