]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
mac80211: Re-fix accounting of the tailroom-needed counter
authorIdo Yariv <ido@wizery.com>
Tue, 6 Jan 2015 13:39:02 +0000 (08:39 -0500)
committerJohannes Berg <johannes.berg@intel.com>
Wed, 7 Jan 2015 13:39:32 +0000 (14:39 +0100)
When hw acceleration is enabled, the GENERATE_IV or PUT_IV_SPACE flags
only require headroom space. Therefore, the tailroom-needed counter can
safely be decremented for most drivers.

The older incarnation of this patch (ca34e3b5) assumed that the above
holds true for all drivers. As reported by Christopher Chavez and
researched by Christian Lamparter and Larry Finger, this isn't a valid
assumption for p54 and cw1200.

Drivers that still require tailroom for ICV/MIC even when HW encryption
is enabled can use IEEE80211_KEY_FLAG_RESERVE_TAILROOM to indicate it.

Signed-off-by: Ido Yariv <idox.yariv@intel.com>
Cc: Christopher Chavez <chrischavez@gmx.us>
Cc: Christian Lamparter <chunkeey@googlemail.com>
Cc: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Solomon Peachy <pizza@shaftnet.org>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
drivers/net/wireless/cw1200/sta.c
drivers/net/wireless/p54/main.c
include/net/mac80211.h
net/mac80211/key.c

index a1e3237c0be8f7cae45ea501c5c02d9b6e1d68d8..4a47c7f8a246dac5c2fd3770163341adbeeec73b 100644 (file)
@@ -709,7 +709,8 @@ int cw1200_set_key(struct ieee80211_hw *dev, enum set_key_cmd cmd,
                if (sta)
                        peer_addr = sta->addr;
 
-               key->flags |= IEEE80211_KEY_FLAG_PUT_IV_SPACE;
+               key->flags |= IEEE80211_KEY_FLAG_PUT_IV_SPACE |
+                             IEEE80211_KEY_FLAG_RESERVE_TAILROOM;
 
                switch (key->cipher) {
                case WLAN_CIPHER_SUITE_WEP40:
index 97aeff0edb84b52b5bbe5821caae9541e13ef554..13a30c4a27f29897b5f8213d433390da70ca08a8 100644 (file)
@@ -575,6 +575,8 @@ static int p54_set_key(struct ieee80211_hw *dev, enum set_key_cmd cmd,
                        key->hw_key_idx = 0xff;
                        goto out_unlock;
                }
+
+               key->flags |= IEEE80211_KEY_FLAG_RESERVE_TAILROOM;
        } else {
                slot = key->hw_key_idx;
 
index ece1a546587eb3f140a13ac24bb5773705886fbc..555a845ad51e708cba71100d12cb8f2ca5c95e2a 100644 (file)
@@ -1281,7 +1281,8 @@ struct ieee80211_vif *wdev_to_ieee80211_vif(struct wireless_dev *wdev);
  *
  * @IEEE80211_KEY_FLAG_GENERATE_IV: This flag should be set by the
  *     driver to indicate that it requires IV generation for this
- *     particular key.
+ *     particular key. Setting this flag does not necessarily mean that SKBs
+ *     will have sufficient tailroom for ICV or MIC.
  * @IEEE80211_KEY_FLAG_GENERATE_MMIC: This flag should be set by
  *     the driver for a TKIP key if it requires Michael MIC
  *     generation in software.
@@ -1293,7 +1294,9 @@ struct ieee80211_vif *wdev_to_ieee80211_vif(struct wireless_dev *wdev);
  * @IEEE80211_KEY_FLAG_PUT_IV_SPACE: This flag should be set by the driver
  *     if space should be prepared for the IV, but the IV
  *     itself should not be generated. Do not set together with
- *     @IEEE80211_KEY_FLAG_GENERATE_IV on the same key.
+ *     @IEEE80211_KEY_FLAG_GENERATE_IV on the same key. Setting this flag does
+ *     not necessarily mean that SKBs will have sufficient tailroom for ICV or
+ *     MIC.
  * @IEEE80211_KEY_FLAG_RX_MGMT: This key will be used to decrypt received
  *     management frames. The flag can help drivers that have a hardware
  *     crypto implementation that doesn't deal with management frames
@@ -1304,6 +1307,9 @@ struct ieee80211_vif *wdev_to_ieee80211_vif(struct wireless_dev *wdev);
  * @IEEE80211_KEY_FLAG_GENERATE_IV_MGMT: This flag should be set by the
  *     driver for a CCMP key to indicate that is requires IV generation
  *     only for managment frames (MFP).
+ * @IEEE80211_KEY_FLAG_RESERVE_TAILROOM: This flag should be set by the
+ *     driver for a key to indicate that sufficient tailroom must always
+ *     be reserved for ICV or MIC, even when HW encryption is enabled.
  */
 enum ieee80211_key_flags {
        IEEE80211_KEY_FLAG_GENERATE_IV_MGMT     = BIT(0),
@@ -1313,6 +1319,7 @@ enum ieee80211_key_flags {
        IEEE80211_KEY_FLAG_SW_MGMT_TX           = BIT(4),
        IEEE80211_KEY_FLAG_PUT_IV_SPACE         = BIT(5),
        IEEE80211_KEY_FLAG_RX_MGMT              = BIT(6),
+       IEEE80211_KEY_FLAG_RESERVE_TAILROOM     = BIT(7),
 };
 
 /**
index bd4e46ec32bd3d43473c2ee3ac2b0b9888d397de..f8d9f0ee59bf1b549ba18c4be160bbf3533e2249 100644 (file)
@@ -141,8 +141,7 @@ static int ieee80211_key_enable_hw_accel(struct ieee80211_key *key)
                key->flags |= KEY_FLAG_UPLOADED_TO_HARDWARE;
 
                if (!((key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC) ||
-                     (key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV) ||
-                     (key->conf.flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE)))
+                     (key->conf.flags & IEEE80211_KEY_FLAG_RESERVE_TAILROOM)))
                        sdata->crypto_tx_tailroom_needed_cnt--;
 
                WARN_ON((key->conf.flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE) &&
@@ -191,8 +190,7 @@ static void ieee80211_key_disable_hw_accel(struct ieee80211_key *key)
        sdata = key->sdata;
 
        if (!((key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC) ||
-             (key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV) ||
-             (key->conf.flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE)))
+             (key->conf.flags & IEEE80211_KEY_FLAG_RESERVE_TAILROOM)))
                increment_tailroom_need_count(sdata);
 
        ret = drv_set_key(key->local, DISABLE_KEY, sdata,
@@ -889,8 +887,7 @@ void ieee80211_remove_key(struct ieee80211_key_conf *keyconf)
                key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE;
 
                if (!((key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC) ||
-                     (key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV) ||
-                     (key->conf.flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE)))
+                     (key->conf.flags & IEEE80211_KEY_FLAG_RESERVE_TAILROOM)))
                        increment_tailroom_need_count(key->sdata);
        }