mac80211: Optimize tailroom_needed update checks
authorAlexander Wetzel <alexander@wetzel-home.de>
Sat, 16 Mar 2019 20:44:43 +0000 (21:44 +0100)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 26 Apr 2019 11:02:11 +0000 (13:02 +0200)
Optimize/cleanup the delay tailroom checks and adds one missing tailroom
update.

Signed-off-by: Alexander Wetzel <alexander@wetzel-home.de>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/key.c

index 4700718..41b8db3 100644 (file)
@@ -140,6 +140,12 @@ static int ieee80211_key_enable_hw_accel(struct ieee80211_key *key)
                 * so clear that flag now to avoid trying to remove
                 * it again later.
                 */
+               if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE &&
+                   !(key->conf.flags & (IEEE80211_KEY_FLAG_GENERATE_MMIC |
+                                        IEEE80211_KEY_FLAG_PUT_MIC_SPACE |
+                                        IEEE80211_KEY_FLAG_RESERVE_TAILROOM)))
+                       increment_tailroom_need_count(sdata);
+
                key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE;
                return -EINVAL;
        }
@@ -177,9 +183,9 @@ static int ieee80211_key_enable_hw_accel(struct ieee80211_key *key)
        if (!ret) {
                key->flags |= KEY_FLAG_UPLOADED_TO_HARDWARE;
 
-               if (!((key->conf.flags & (IEEE80211_KEY_FLAG_GENERATE_MMIC |
-                                          IEEE80211_KEY_FLAG_PUT_MIC_SPACE)) ||
-                     (key->conf.flags & IEEE80211_KEY_FLAG_RESERVE_TAILROOM)))
+               if (!(key->conf.flags & (IEEE80211_KEY_FLAG_GENERATE_MMIC |
+                                        IEEE80211_KEY_FLAG_PUT_MIC_SPACE |
+                                        IEEE80211_KEY_FLAG_RESERVE_TAILROOM)))
                        decrease_tailroom_need_count(sdata, 1);
 
                WARN_ON((key->conf.flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE) &&
@@ -243,9 +249,9 @@ static void ieee80211_key_disable_hw_accel(struct ieee80211_key *key)
        sta = key->sta;
        sdata = key->sdata;
 
-       if (!((key->conf.flags & (IEEE80211_KEY_FLAG_GENERATE_MMIC |
-                                  IEEE80211_KEY_FLAG_PUT_MIC_SPACE)) ||
-             (key->conf.flags & IEEE80211_KEY_FLAG_RESERVE_TAILROOM)))
+       if (!(key->conf.flags & (IEEE80211_KEY_FLAG_GENERATE_MMIC |
+                                IEEE80211_KEY_FLAG_PUT_MIC_SPACE |
+                                IEEE80211_KEY_FLAG_RESERVE_TAILROOM)))
                increment_tailroom_need_count(sdata);
 
        key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE;
@@ -1188,9 +1194,9 @@ void ieee80211_remove_key(struct ieee80211_key_conf *keyconf)
        if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) {
                key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE;
 
-               if (!((key->conf.flags & (IEEE80211_KEY_FLAG_GENERATE_MMIC |
-                                          IEEE80211_KEY_FLAG_PUT_MIC_SPACE)) ||
-                     (key->conf.flags & IEEE80211_KEY_FLAG_RESERVE_TAILROOM)))
+               if (!(key->conf.flags & (IEEE80211_KEY_FLAG_GENERATE_MMIC |
+                                        IEEE80211_KEY_FLAG_PUT_MIC_SPACE |
+                                        IEEE80211_KEY_FLAG_RESERVE_TAILROOM)))
                        increment_tailroom_need_count(key->sdata);
        }