]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
mac80211: Update CSA counters in mgmt frames
authorAndrei Otcheretianski <andrei.otcheretianski@intel.com>
Fri, 9 May 2014 11:11:45 +0000 (14:11 +0300)
committerJohannes Berg <johannes.berg@intel.com>
Thu, 15 May 2014 12:54:32 +0000 (14:54 +0200)
Track current csa counter value and use it
to update mgmt frames at the provided offsets.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/cfg.c
net/mac80211/ieee80211_i.h
net/mac80211/tx.c

index 7c56445722537d025d9d27295d22408e0f03c3b6..8e4754ebc2d85c606d4dfff2c79097b3b9bd77d9 100644 (file)
@@ -3338,6 +3338,7 @@ __ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
        sdata->csa_radar_required = params->radar_required;
        sdata->csa_chandef = params->chandef;
        sdata->csa_block_tx = params->block_tx;
+       sdata->csa_current_counter = params->count;
        sdata->vif.csa_active = true;
 
        if (sdata->csa_block_tx)
@@ -3382,6 +3383,7 @@ static int ieee80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
        bool need_offchan = false;
        u32 flags;
        int ret;
+       u8 *data;
 
        if (params->dont_wait_for_ack)
                flags = IEEE80211_TX_CTL_NO_ACK;
@@ -3475,7 +3477,20 @@ static int ieee80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
        }
        skb_reserve(skb, local->hw.extra_tx_headroom);
 
-       memcpy(skb_put(skb, params->len), params->buf, params->len);
+       data = skb_put(skb, params->len);
+       memcpy(data, params->buf, params->len);
+
+       /* Update CSA counters */
+       if (sdata->vif.csa_active &&
+           (sdata->vif.type == NL80211_IFTYPE_AP ||
+            sdata->vif.type == NL80211_IFTYPE_ADHOC) &&
+           params->n_csa_offsets) {
+               int i;
+
+               for (i = 0; i < params->n_csa_offsets; i++)
+                       data[params->csa_offsets[i]] =
+                                       sdata->csa_current_counter;
+       }
 
        IEEE80211_SKB_CB(skb)->flags = flags;
 
index 4668ce9a1d3f7c964e5c9abba263c8f91297a1e9..fb2d9e7551584f223e446311580f7c27c468ad92 100644 (file)
@@ -766,6 +766,7 @@ struct ieee80211_sub_if_data {
        struct ieee80211_chanctx *reserved_chanctx;
        struct cfg80211_chan_def reserved_chandef;
        bool reserved_radar_required;
+       u8 csa_current_counter;
 
        /* used to reconfigure hardware SM PS */
        struct work_struct recalc_smps;
index 19d36d4117e0da0b5524b7e3f8102a86810dceed..263dea5a5cbb920a7a51a48c1e3f826e6e8ee8d5 100644 (file)
@@ -2449,7 +2449,8 @@ static void ieee80211_update_csa(struct ieee80211_sub_if_data *sdata,
        if (WARN_ON(beacon_data[counter_offset_beacon] == 1))
                return;
 
-       beacon_data[counter_offset_beacon]--;
+       sdata->csa_current_counter--;
+       beacon_data[counter_offset_beacon] = sdata->csa_current_counter;
 
        if (sdata->vif.type == NL80211_IFTYPE_AP && counter_offset_presp) {
                rcu_read_lock();
@@ -2460,7 +2461,7 @@ static void ieee80211_update_csa(struct ieee80211_sub_if_data *sdata,
                        rcu_read_unlock();
                        return;
                }
-               resp->data[counter_offset_presp]--;
+               resp->data[counter_offset_presp] = sdata->csa_current_counter;
                rcu_read_unlock();
        }
 }