Skip to contentSkip to conversation

mac80211: Skip tailroom reservation for full HW-crypto devices with race fix

PATCH Superseded Yogesh Ashok Powar 2 participants 2 messages Jun 28, 2011 mac80211

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mac80211: Skip tailroom reservation for full HW-crypto devices with race fix

Based on inputs from Johannes Berg <[email protected]> from http://markmail.org/thread/t4acssvlgb5gamt2 and
http://markmail.org/thread/mydlihrhvfvevuim

In xmit path, devices that do full hardware crypto (including MMIC and ICV) need no tailroom. For such devices, tailroom reservation can be skipped if all the keys are programmed into the hardware (i.e software crypto is not used for any of the keys) and none of the keys wants software to generate Michael MIC and IV.

v2: Added check for IV along with MMIC to avoid

Quoted 1 line
WARNING: at net/mac80211/wep.c:101 ieee80211_wep_add_iv+0x56/0xf3()

v3: Fixing races to avoid

Quoted 1 line
WARNING: at net/mac80211/wpa.c:397 ccmp_encrypt_skb+0xc4/0x1f0
---
 net/mac80211/ieee80211_i.h |    3 ++
 net/mac80211/key.c         |   51 ++++++++++++++++++++++++++++++++++++++++++-
 net/mac80211/tx.c          |   14 ++++-------
 3 files changed, 57 insertions(+), 11 deletions(-)
net/mac80211/ieee80211_i.h +3 -0
index 25c15cc..4f2e424 100644
@@ -544,6 +544,9 @@ struct ieee80211_sub_if_data {
 	/* keys */
 	struct list_head key_list;
 
+	/* count for keys needing tailroom space allocation */
+	int crypto_tx_tailroom_needed_cnt;
+
 	struct net_device *dev;
 	struct ieee80211_local *local;
 
net/mac80211/key.c +49 -2

89 lines not on this page · raw message

net/mac80211/tx.c +5 -9
index 3104c84..e8d0d2d 100644
@@ -1474,18 +1474,14 @@ static bool ieee80211_tx(struct ieee80211_sub_if_data *sdata,
 
 /* device xmit handlers */
 
-static int ieee80211_skb_resize(struct ieee80211_local *local,
+static int ieee80211_skb_resize(struct ieee80211_sub_if_data *sdata,
 				struct sk_buff *skb,
 				int head_need, bool may_encrypt)
 {
+	struct ieee80211_local *local = sdata->local;
 	int tail_need = 0;
 
-	/*
-	 * This could be optimised, devices that do full hardware
-	 * crypto (including TKIP MMIC) need no tailroom... But we
-	 * have no drivers for such devices currently.
-	 */
-	if (may_encrypt) {
+	if (may_encrypt && sdata->crypto_tx_tailroom_needed_cnt) {
 		tail_need = IEEE80211_ENCRYPT_TAILROOM;
 		tail_need -= skb_tailroom(skb);
 		tail_need = max_t(int, tail_need, 0);
@@ -1578,7 +1574,7 @@ static void ieee80211_xmit(struct ieee80211_sub_if_data *sdata,
 	headroom -= skb_headroom(skb);
 	headroom = max_t(int, 0, headroom);
 
-	if (ieee80211_skb_resize(local, skb, headroom, may_encrypt)) {
+	if (ieee80211_skb_resize(sdata, skb, headroom, may_encrypt)) {
 		dev_kfree_skb(skb);
 		rcu_read_unlock();
 		return;
@@ -1945,7 +1941,7 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
 		head_need += IEEE80211_ENCRYPT_HEADROOM;
 		head_need += local->tx_headroom;
 		head_need = max_t(int, 0, head_need);
-		if (ieee80211_skb_resize(local, skb, head_need, true))
+		if (ieee80211_skb_resize(sdata, skb, head_need, true))
 			goto fail;
 	}
 
Signature · 1 line
1.5.4.1
maintainer
#1 lore raw
Quoted 18 lines · Yogesh Ashok Powar

Based on inputs from Johannes Berg <[email protected]> from http://markmail.org/thread/t4acssvlgb5gamt2 and
http://markmail.org/thread/mydlihrhvfvevuim

In xmit path, devices that do full hardware crypto (including MMIC and ICV) need no tailroom. For such devices, tailroom reservation can be skipped if all the keys are programmed into the hardware (i.e software crypto is not used for any of the keys) and none of the keys wants software to generate Michael MIC and IV.

v2: Added check for IV along with MMIC to avoid

Quoted 1 line
WARNING: at net/mac80211/wep.c:101 ieee80211_wep_add_iv+0x56/0xf3()
Quoted 5 lines

v3: Fixing races to avoid

Quoted 1 line
WARNING: at net/mac80211/wpa.c:397 ccmp_encrypt_skb+0xc4/0x1f0

This changelog entry is kinda messed up.

net/mac80211/key.c static struct ieee80211_sta *get_sta_for_key(struct ieee80211_key *key) · line 82

Quoted 2 lines
net/mac80211/key.c +2 -0
+	 * Solution has been explained at
+	 * http://markmail.org/message/c3ykchyv6azzmdum

Nothing against markmail, but I prefer links that contain a message ID so if the link ever goes dead, you can google for the message ID. Maybe use
http://mid.gmane.org/[email protected]

johannes