mac80211: make uapsd_* keys per-vif
authorEliad Peller <eliad@wizery.com>
Wed, 14 Mar 2012 14:15:03 +0000 (16:15 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Thu, 15 Mar 2012 17:43:12 +0000 (13:43 -0400)
uapsd_queues and uapsd_max_sp_len are relevant only for managed
interfaces, and can be configured differently for each vif.

Move them from the local struct to sdata->u.mgd, and update
the debugfs functions accordingly.

Signed-off-by: Eliad Peller <eliad@wizery.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
net/mac80211/debugfs.c
net/mac80211/debugfs_netdev.c
net/mac80211/ieee80211_i.h
net/mac80211/main.c
net/mac80211/mlme.c
net/mac80211/tx.c

index 483e96ed95c10b4f62b8c847db07dbc3d9f1ab8a..cc5b7a6e7e0b084d2e8cb7e2f06d0e3f392eabc1 100644 (file)
@@ -97,85 +97,6 @@ static const struct file_operations reset_ops = {
        .llseek = noop_llseek,
 };
 
-static ssize_t uapsd_queues_read(struct file *file, char __user *user_buf,
-                                size_t count, loff_t *ppos)
-{
-       struct ieee80211_local *local = file->private_data;
-       return mac80211_format_buffer(user_buf, count, ppos, "0x%x\n",
-                                     local->uapsd_queues);
-}
-
-static ssize_t uapsd_queues_write(struct file *file,
-                                 const char __user *user_buf,
-                                 size_t count, loff_t *ppos)
-{
-       struct ieee80211_local *local = file->private_data;
-       u8 val;
-       int ret;
-
-       ret = kstrtou8_from_user(user_buf, count, 0, &val);
-       if (ret)
-               return ret;
-
-       if (val & ~IEEE80211_WMM_IE_STA_QOSINFO_AC_MASK)
-               return -ERANGE;
-
-       local->uapsd_queues = val;
-
-       return count;
-}
-
-static const struct file_operations uapsd_queues_ops = {
-       .read = uapsd_queues_read,
-       .write = uapsd_queues_write,
-       .open = mac80211_open_file_generic,
-       .llseek = default_llseek,
-};
-
-static ssize_t uapsd_max_sp_len_read(struct file *file, char __user *user_buf,
-                                    size_t count, loff_t *ppos)
-{
-       struct ieee80211_local *local = file->private_data;
-
-       return mac80211_format_buffer(user_buf, count, ppos, "0x%x\n",
-                                     local->uapsd_max_sp_len);
-}
-
-static ssize_t uapsd_max_sp_len_write(struct file *file,
-                                     const char __user *user_buf,
-                                     size_t count, loff_t *ppos)
-{
-       struct ieee80211_local *local = file->private_data;
-       unsigned long val;
-       char buf[10];
-       size_t len;
-       int ret;
-
-       len = min(count, sizeof(buf) - 1);
-       if (copy_from_user(buf, user_buf, len))
-               return -EFAULT;
-       buf[len] = '\0';
-
-       ret = kstrtoul(buf, 0, &val);
-
-       if (ret)
-               return -EINVAL;
-
-       if (val & ~IEEE80211_WMM_IE_STA_QOSINFO_SP_MASK)
-               return -ERANGE;
-
-       local->uapsd_max_sp_len = val;
-
-       return count;
-}
-
-static const struct file_operations uapsd_max_sp_len_ops = {
-       .read = uapsd_max_sp_len_read,
-       .write = uapsd_max_sp_len_write,
-       .open = mac80211_open_file_generic,
-       .llseek = default_llseek,
-};
-
 static ssize_t channel_type_read(struct file *file, char __user *user_buf,
                       size_t count, loff_t *ppos)
 {
@@ -362,8 +283,6 @@ void debugfs_hw_add(struct ieee80211_local *local)
        DEBUGFS_ADD(wep_iv);
        DEBUGFS_ADD(queues);
        DEBUGFS_ADD_MODE(reset, 0200);
-       DEBUGFS_ADD(uapsd_queues);
-       DEBUGFS_ADD(uapsd_max_sp_len);
        DEBUGFS_ADD(channel_type);
        DEBUGFS_ADD(hwflags);
        DEBUGFS_ADD(user_power);
index ef5cf2685657ff9327861a09e7db28fc312b41d1..a32eeda04aa3f1bb980066f0183615c2acffd8df 100644 (file)
@@ -337,6 +337,62 @@ static ssize_t ieee80211_if_parse_tkip_mic_test(
 
 __IEEE80211_IF_FILE_W(tkip_mic_test);
 
+static ssize_t ieee80211_if_fmt_uapsd_queues(
+       const struct ieee80211_sub_if_data *sdata, char *buf, int buflen)
+{
+       const struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
+
+       return snprintf(buf, buflen, "0x%x\n", ifmgd->uapsd_queues);
+}
+
+static ssize_t ieee80211_if_parse_uapsd_queues(
+       struct ieee80211_sub_if_data *sdata, const char *buf, int buflen)
+{
+       struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
+       u8 val;
+       int ret;
+
+       ret = kstrtou8(buf, 0, &val);
+       if (ret)
+               return ret;
+
+       if (val & ~IEEE80211_WMM_IE_STA_QOSINFO_AC_MASK)
+               return -ERANGE;
+
+       ifmgd->uapsd_queues = val;
+
+       return buflen;
+}
+__IEEE80211_IF_FILE_W(uapsd_queues);
+
+static ssize_t ieee80211_if_fmt_uapsd_max_sp_len(
+       const struct ieee80211_sub_if_data *sdata, char *buf, int buflen)
+{
+       const struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
+
+       return snprintf(buf, buflen, "0x%x\n", ifmgd->uapsd_max_sp_len);
+}
+
+static ssize_t ieee80211_if_parse_uapsd_max_sp_len(
+       struct ieee80211_sub_if_data *sdata, const char *buf, int buflen)
+{
+       struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
+       unsigned long val;
+       int ret;
+
+       ret = kstrtoul(buf, 0, &val);
+       if (ret)
+               return -EINVAL;
+
+       if (val & ~IEEE80211_WMM_IE_STA_QOSINFO_SP_MASK)
+               return -ERANGE;
+
+       ifmgd->uapsd_max_sp_len = val;
+
+       return buflen;
+}
+__IEEE80211_IF_FILE_W(uapsd_max_sp_len);
+
 /* AP attributes */
 IEEE80211_IF_FILE(num_sta_authorized, u.ap.num_sta_authorized, ATOMIC);
 IEEE80211_IF_FILE(num_sta_ps, u.ap.num_sta_ps, ATOMIC);
@@ -469,6 +525,8 @@ static void add_sta_files(struct ieee80211_sub_if_data *sdata)
        DEBUGFS_ADD(ave_beacon);
        DEBUGFS_ADD_MODE(smps, 0600);
        DEBUGFS_ADD_MODE(tkip_mic_test, 0200);
+       DEBUGFS_ADD_MODE(uapsd_queues, 0600);
+       DEBUGFS_ADD_MODE(uapsd_max_sp_len, 0600);
 }
 
 static void add_ap_files(struct ieee80211_sub_if_data *sdata)
index 63fb0eb79d8e2751b3f965607022808cadb45c8d..d9798a307f20dabdeea69179e76008bccf144673 100644 (file)
@@ -459,6 +459,20 @@ struct ieee80211_if_managed {
                IEEE80211_MFP_REQUIRED
        } mfp; /* management frame protection */
 
+       /*
+        * Bitmask of enabled u-apsd queues,
+        * IEEE80211_WMM_IE_STA_QOSINFO_AC_BE & co. Needs a new association
+        * to take effect.
+        */
+       unsigned int uapsd_queues;
+
+       /*
+        * Maximum number of buffered frames AP can deliver during a
+        * service period, IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL or similar.
+        * Needs a new association to take effect.
+        */
+       unsigned int uapsd_max_sp_len;
+
        int wmm_last_param_set;
 
        u8 use_4addr;
@@ -1017,20 +1031,6 @@ struct ieee80211_local {
                                */
        unsigned int wmm_acm; /* bit field of ACM bits (BIT(802.1D tag)) */
 
-       /*
-        * Bitmask of enabled u-apsd queues,
-        * IEEE80211_WMM_IE_STA_QOSINFO_AC_BE & co. Needs a new association
-        * to take effect.
-        */
-       unsigned int uapsd_queues;
-
-       /*
-        * Maximum number of buffered frames AP can deliver during a
-        * service period, IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL or similar.
-        * Needs a new association to take effect.
-        */
-       unsigned int uapsd_max_sp_len;
-
        bool pspolling;
        bool offchannel_ps_enabled;
        /*
index 36fa8051296c80fab82c37f206a46d5892592435..b581a24fa15c43739538ea8d4ae0b4a843feedce 100644 (file)
@@ -595,8 +595,6 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
        local->hw.conf.long_frame_max_tx_count = wiphy->retry_long;
        local->hw.conf.short_frame_max_tx_count = wiphy->retry_short;
        local->user_power_level = -1;
-       local->uapsd_queues = IEEE80211_DEFAULT_UAPSD_QUEUES;
-       local->uapsd_max_sp_len = IEEE80211_DEFAULT_MAX_SP_LEN;
        wiphy->ht_capa_mod_mask = &mac80211_ht_capa_mod_mask;
 
        INIT_LIST_HEAD(&local->interfaces);
index 0df22372af8d7542ca06cdb6f669556ff099eea5..576fb25456dd7479a0ed51c50efad9c6a238c3d1 100644 (file)
@@ -572,8 +572,8 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata)
 
        if (assoc_data->wmm) {
                if (assoc_data->uapsd) {
-                       qos_info = local->uapsd_queues;
-                       qos_info |= (local->uapsd_max_sp_len <<
+                       qos_info = ifmgd->uapsd_queues;
+                       qos_info |= (ifmgd->uapsd_max_sp_len <<
                                     IEEE80211_WMM_IE_STA_QOSINFO_SP_SHIFT);
                } else {
                        qos_info = 0;
@@ -1192,7 +1192,7 @@ static void ieee80211_sta_wmm_params(struct ieee80211_local *local,
                return;
 
        if (ifmgd->flags & IEEE80211_STA_UAPSD_ENABLED)
-               uapsd_queues = local->uapsd_queues;
+               uapsd_queues = ifmgd->uapsd_queues;
 
        count = wmm_param[6] & 0x0f;
        if (count == ifmgd->wmm_last_param_set)
@@ -3013,6 +3013,8 @@ void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata)
 
        ifmgd->flags = 0;
        ifmgd->powersave = sdata->wdev.ps;
+       ifmgd->uapsd_queues = IEEE80211_DEFAULT_UAPSD_QUEUES;
+       ifmgd->uapsd_max_sp_len = IEEE80211_DEFAULT_MAX_SP_LEN;
 
        mutex_init(&ifmgd->mtx);
 
index d9e791d2b54310a04b8effc8ecc2c0083b30c54a..782a60198df46977754c8720f101ed8016b928e5 100644 (file)
@@ -226,12 +226,12 @@ ieee80211_tx_h_dynamic_ps(struct ieee80211_tx_data *tx)
         * have correct qos tag for some reason, due the network or the
         * peer application.
         *
-        * Note: local->uapsd_queues access is racy here. If the value is
+        * Note: ifmgd->uapsd_queues access is racy here. If the value is
         * changed via debugfs, user needs to reassociate manually to have
         * everything in sync.
         */
        if ((ifmgd->flags & IEEE80211_STA_UAPSD_ENABLED)
-           && (local->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VO)
+           && (ifmgd->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VO)
            && skb_get_queue_mapping(tx->skb) == 0)
                return TX_CONTINUE;