aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIdo Yariv <ido@wizery.com>2015-01-06 08:39:02 -0500
committerJohannes Berg <johannes.berg@intel.com>2015-01-07 08:39:32 -0500
commitdb12847ca84b7a315a3ba77c939c9d08df17d54f (patch)
tree81c6aed1a2c6c43cab47f3ca2117d645dcc6c355
parent3a4b0c948d286523ba062985c03487b55326eaae (diff)
mac80211: Re-fix accounting of the tailroom-needed counter
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>
-rw-r--r--drivers/net/wireless/cw1200/sta.c3
-rw-r--r--drivers/net/wireless/p54/main.c2
-rw-r--r--include/net/mac80211.h11
-rw-r--r--net/mac80211/key.c9
4 files changed, 16 insertions, 9 deletions
diff --git a/drivers/net/wireless/cw1200/sta.c b/drivers/net/wireless/cw1200/sta.c
index a1e3237c0be8..4a47c7f8a246 100644
--- a/drivers/net/wireless/cw1200/sta.c
+++ b/drivers/net/wireless/cw1200/sta.c
@@ -709,7 +709,8 @@ int cw1200_set_key(struct ieee80211_hw *dev, enum set_key_cmd cmd,
709 if (sta) 709 if (sta)
710 peer_addr = sta->addr; 710 peer_addr = sta->addr;
711 711
712 key->flags |= IEEE80211_KEY_FLAG_PUT_IV_SPACE; 712 key->flags |= IEEE80211_KEY_FLAG_PUT_IV_SPACE |
713 IEEE80211_KEY_FLAG_RESERVE_TAILROOM;
713 714
714 switch (key->cipher) { 715 switch (key->cipher) {
715 case WLAN_CIPHER_SUITE_WEP40: 716 case WLAN_CIPHER_SUITE_WEP40:
diff --git a/drivers/net/wireless/p54/main.c b/drivers/net/wireless/p54/main.c
index 97aeff0edb84..13a30c4a27f2 100644
--- a/drivers/net/wireless/p54/main.c
+++ b/drivers/net/wireless/p54/main.c
@@ -575,6 +575,8 @@ static int p54_set_key(struct ieee80211_hw *dev, enum set_key_cmd cmd,
575 key->hw_key_idx = 0xff; 575 key->hw_key_idx = 0xff;
576 goto out_unlock; 576 goto out_unlock;
577 } 577 }
578
579 key->flags |= IEEE80211_KEY_FLAG_RESERVE_TAILROOM;
578 } else { 580 } else {
579 slot = key->hw_key_idx; 581 slot = key->hw_key_idx;
580 582
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index ece1a546587e..555a845ad51e 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -1281,7 +1281,8 @@ struct ieee80211_vif *wdev_to_ieee80211_vif(struct wireless_dev *wdev);
1281 * 1281 *
1282 * @IEEE80211_KEY_FLAG_GENERATE_IV: This flag should be set by the 1282 * @IEEE80211_KEY_FLAG_GENERATE_IV: This flag should be set by the
1283 * driver to indicate that it requires IV generation for this 1283 * driver to indicate that it requires IV generation for this
1284 * particular key. 1284 * particular key. Setting this flag does not necessarily mean that SKBs
1285 * will have sufficient tailroom for ICV or MIC.
1285 * @IEEE80211_KEY_FLAG_GENERATE_MMIC: This flag should be set by 1286 * @IEEE80211_KEY_FLAG_GENERATE_MMIC: This flag should be set by
1286 * the driver for a TKIP key if it requires Michael MIC 1287 * the driver for a TKIP key if it requires Michael MIC
1287 * generation in software. 1288 * generation in software.
@@ -1293,7 +1294,9 @@ struct ieee80211_vif *wdev_to_ieee80211_vif(struct wireless_dev *wdev);
1293 * @IEEE80211_KEY_FLAG_PUT_IV_SPACE: This flag should be set by the driver 1294 * @IEEE80211_KEY_FLAG_PUT_IV_SPACE: This flag should be set by the driver
1294 * if space should be prepared for the IV, but the IV 1295 * if space should be prepared for the IV, but the IV
1295 * itself should not be generated. Do not set together with 1296 * itself should not be generated. Do not set together with
1296 * @IEEE80211_KEY_FLAG_GENERATE_IV on the same key. 1297 * @IEEE80211_KEY_FLAG_GENERATE_IV on the same key. Setting this flag does
1298 * not necessarily mean that SKBs will have sufficient tailroom for ICV or
1299 * MIC.
1297 * @IEEE80211_KEY_FLAG_RX_MGMT: This key will be used to decrypt received 1300 * @IEEE80211_KEY_FLAG_RX_MGMT: This key will be used to decrypt received
1298 * management frames. The flag can help drivers that have a hardware 1301 * management frames. The flag can help drivers that have a hardware
1299 * crypto implementation that doesn't deal with management frames 1302 * crypto implementation that doesn't deal with management frames
@@ -1304,6 +1307,9 @@ struct ieee80211_vif *wdev_to_ieee80211_vif(struct wireless_dev *wdev);
1304 * @IEEE80211_KEY_FLAG_GENERATE_IV_MGMT: This flag should be set by the 1307 * @IEEE80211_KEY_FLAG_GENERATE_IV_MGMT: This flag should be set by the
1305 * driver for a CCMP key to indicate that is requires IV generation 1308 * driver for a CCMP key to indicate that is requires IV generation
1306 * only for managment frames (MFP). 1309 * only for managment frames (MFP).
1310 * @IEEE80211_KEY_FLAG_RESERVE_TAILROOM: This flag should be set by the
1311 * driver for a key to indicate that sufficient tailroom must always
1312 * be reserved for ICV or MIC, even when HW encryption is enabled.
1307 */ 1313 */
1308enum ieee80211_key_flags { 1314enum ieee80211_key_flags {
1309 IEEE80211_KEY_FLAG_GENERATE_IV_MGMT = BIT(0), 1315 IEEE80211_KEY_FLAG_GENERATE_IV_MGMT = BIT(0),
@@ -1313,6 +1319,7 @@ enum ieee80211_key_flags {
1313 IEEE80211_KEY_FLAG_SW_MGMT_TX = BIT(4), 1319 IEEE80211_KEY_FLAG_SW_MGMT_TX = BIT(4),
1314 IEEE80211_KEY_FLAG_PUT_IV_SPACE = BIT(5), 1320 IEEE80211_KEY_FLAG_PUT_IV_SPACE = BIT(5),
1315 IEEE80211_KEY_FLAG_RX_MGMT = BIT(6), 1321 IEEE80211_KEY_FLAG_RX_MGMT = BIT(6),
1322 IEEE80211_KEY_FLAG_RESERVE_TAILROOM = BIT(7),
1316}; 1323};
1317 1324
1318/** 1325/**
diff --git a/net/mac80211/key.c b/net/mac80211/key.c
index bd4e46ec32bd..f8d9f0ee59bf 100644
--- a/net/mac80211/key.c
+++ b/net/mac80211/key.c
@@ -141,8 +141,7 @@ static int ieee80211_key_enable_hw_accel(struct ieee80211_key *key)
141 key->flags |= KEY_FLAG_UPLOADED_TO_HARDWARE; 141 key->flags |= KEY_FLAG_UPLOADED_TO_HARDWARE;
142 142
143 if (!((key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC) || 143 if (!((key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC) ||
144 (key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV) || 144 (key->conf.flags & IEEE80211_KEY_FLAG_RESERVE_TAILROOM)))
145 (key->conf.flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE)))
146 sdata->crypto_tx_tailroom_needed_cnt--; 145 sdata->crypto_tx_tailroom_needed_cnt--;
147 146
148 WARN_ON((key->conf.flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE) && 147 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)
191 sdata = key->sdata; 190 sdata = key->sdata;
192 191
193 if (!((key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC) || 192 if (!((key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC) ||
194 (key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV) || 193 (key->conf.flags & IEEE80211_KEY_FLAG_RESERVE_TAILROOM)))
195 (key->conf.flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE)))
196 increment_tailroom_need_count(sdata); 194 increment_tailroom_need_count(sdata);
197 195
198 ret = drv_set_key(key->local, DISABLE_KEY, sdata, 196 ret = drv_set_key(key->local, DISABLE_KEY, sdata,
@@ -889,8 +887,7 @@ void ieee80211_remove_key(struct ieee80211_key_conf *keyconf)
889 key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE; 887 key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE;
890 888
891 if (!((key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC) || 889 if (!((key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC) ||
892 (key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV) || 890 (key->conf.flags & IEEE80211_KEY_FLAG_RESERVE_TAILROOM)))
893 (key->conf.flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE)))
894 increment_tailroom_need_count(key->sdata); 891 increment_tailroom_need_count(key->sdata);
895 } 892 }
896 893