aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvo van Doorn <ivdoorn@gmail.com>2008-04-17 13:41:02 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-05-07 15:02:11 -0400
commit1c014420583564ac09e3b67006f2e7050861e66b (patch)
tree12f075007d1e7d603a6142ba0a4f32b2dee1cefb
parent6f4083aadd57e3da12fa4e67fcadaec23138a315 (diff)
mac80211: Replace ieee80211_tx_control->key_idx with ieee80211_key_conf
The hw_key_idx inside the ieee80211_key_conf structure does not provide all the information drivers might need to perform hardware encryption. This is in particular true for rt2x00 who needs to know the key algorithm and whether it is a shared or pairwise key. By passing the ieee80211_key_conf pointer it assures us that drivers can make full use of all information that it should know about a particular key. Additionally this patch updates all drivers to grab the hw_key_idx from the ieee80211_key_conf structure. v2: Removed bogus u16 cast v3: Add warning about ieee80211_tx_control pointers v4: Update warning about ieee80211_tx_control pointers Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Acked-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/ath5k/base.c2
-rw-r--r--drivers/net/wireless/b43/xmit.c2
-rw-r--r--drivers/net/wireless/b43legacy/xmit.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c7
-rw-r--r--drivers/net/wireless/iwlwifi/iwl4965-base.c6
-rw-r--r--include/net/mac80211.h19
-rw-r--r--net/mac80211/wep.c2
-rw-r--r--net/mac80211/wpa.c8
8 files changed, 30 insertions, 18 deletions
diff --git a/drivers/net/wireless/ath5k/base.c b/drivers/net/wireless/ath5k/base.c
index 4e5c8fc35200..3854619f3514 100644
--- a/drivers/net/wireless/ath5k/base.c
+++ b/drivers/net/wireless/ath5k/base.c
@@ -1319,7 +1319,7 @@ ath5k_txbuf_setup(struct ath5k_softc *sc, struct ath5k_buf *bf,
1319 pktlen = skb->len; 1319 pktlen = skb->len;
1320 1320
1321 if (!(ctl->flags & IEEE80211_TXCTL_DO_NOT_ENCRYPT)) { 1321 if (!(ctl->flags & IEEE80211_TXCTL_DO_NOT_ENCRYPT)) {
1322 keyidx = ctl->key_idx; 1322 keyidx = ctl->hw_key->hw_key_idx;
1323 pktlen += ctl->icv_len; 1323 pktlen += ctl->icv_len;
1324 } 1324 }
1325 1325
diff --git a/drivers/net/wireless/b43/xmit.c b/drivers/net/wireless/b43/xmit.c
index 19aefbfb2c93..88491947a209 100644
--- a/drivers/net/wireless/b43/xmit.c
+++ b/drivers/net/wireless/b43/xmit.c
@@ -235,7 +235,7 @@ int b43_generate_txhdr(struct b43_wldev *dev,
235 235
236 plcp_fragment_len = fragment_len + FCS_LEN; 236 plcp_fragment_len = fragment_len + FCS_LEN;
237 if (use_encryption) { 237 if (use_encryption) {
238 u8 key_idx = (u16) (txctl->key_idx); 238 u8 key_idx = txctl->hw_key->hw_key_idx;
239 struct b43_key *key; 239 struct b43_key *key;
240 int wlhdr_len; 240 int wlhdr_len;
241 size_t iv_len; 241 size_t iv_len;
diff --git a/drivers/net/wireless/b43legacy/xmit.c b/drivers/net/wireless/b43legacy/xmit.c
index dcad2491a606..fc83dab6e2c7 100644
--- a/drivers/net/wireless/b43legacy/xmit.c
+++ b/drivers/net/wireless/b43legacy/xmit.c
@@ -232,7 +232,7 @@ static int generate_txhdr_fw3(struct b43legacy_wldev *dev,
232 232
233 plcp_fragment_len = fragment_len + FCS_LEN; 233 plcp_fragment_len = fragment_len + FCS_LEN;
234 if (use_encryption) { 234 if (use_encryption) {
235 u8 key_idx = (u16)(txctl->key_idx); 235 u8 key_idx = txctl->hw_key->hw_key_idx;
236 struct b43legacy_key *key; 236 struct b43legacy_key *key;
237 int wlhdr_len; 237 int wlhdr_len;
238 size_t iv_len; 238 size_t iv_len;
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index 13925b627e3b..7bdffa9cfea6 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -2391,7 +2391,8 @@ static void iwl3945_build_tx_cmd_hwcrypto(struct iwl3945_priv *priv,
2391 struct sk_buff *skb_frag, 2391 struct sk_buff *skb_frag,
2392 int last_frag) 2392 int last_frag)
2393{ 2393{
2394 struct iwl3945_hw_key *keyinfo = &priv->stations[ctl->key_idx].keyinfo; 2394 struct iwl3945_hw_key *keyinfo =
2395 &priv->stations[ctl->hw_key->hw_key_idx].keyinfo;
2395 2396
2396 switch (keyinfo->alg) { 2397 switch (keyinfo->alg) {
2397 case ALG_CCMP: 2398 case ALG_CCMP:
@@ -2414,7 +2415,7 @@ static void iwl3945_build_tx_cmd_hwcrypto(struct iwl3945_priv *priv,
2414 2415
2415 case ALG_WEP: 2416 case ALG_WEP:
2416 cmd->cmd.tx.sec_ctl = TX_CMD_SEC_WEP | 2417 cmd->cmd.tx.sec_ctl = TX_CMD_SEC_WEP |
2417 (ctl->key_idx & TX_CMD_SEC_MSK) << TX_CMD_SEC_SHIFT; 2418 (ctl->hw_key->hw_key_idx & TX_CMD_SEC_MSK) << TX_CMD_SEC_SHIFT;
2418 2419
2419 if (keyinfo->keylen == 13) 2420 if (keyinfo->keylen == 13)
2420 cmd->cmd.tx.sec_ctl |= TX_CMD_SEC_KEY128; 2421 cmd->cmd.tx.sec_ctl |= TX_CMD_SEC_KEY128;
@@ -2422,7 +2423,7 @@ static void iwl3945_build_tx_cmd_hwcrypto(struct iwl3945_priv *priv,
2422 memcpy(&cmd->cmd.tx.key[3], keyinfo->key, keyinfo->keylen); 2423 memcpy(&cmd->cmd.tx.key[3], keyinfo->key, keyinfo->keylen);
2423 2424
2424 IWL_DEBUG_TX("Configuring packet for WEP encryption " 2425 IWL_DEBUG_TX("Configuring packet for WEP encryption "
2425 "with key %d\n", ctl->key_idx); 2426 "with key %d\n", ctl->hw_key->hw_key_idx);
2426 break; 2427 break;
2427 2428
2428 default: 2429 default:
diff --git a/drivers/net/wireless/iwlwifi/iwl4965-base.c b/drivers/net/wireless/iwlwifi/iwl4965-base.c
index c8cbf70600da..e43ea5377d8e 100644
--- a/drivers/net/wireless/iwlwifi/iwl4965-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl4965-base.c
@@ -1926,7 +1926,7 @@ static void iwl4965_build_tx_cmd_hwcrypto(struct iwl_priv *priv,
1926 struct iwl_wep_key *wepkey; 1926 struct iwl_wep_key *wepkey;
1927 int keyidx = 0; 1927 int keyidx = 0;
1928 1928
1929 BUG_ON(ctl->key_idx > 3); 1929 BUG_ON(ctl->hw_key->hw_key_idx > 3);
1930 1930
1931 switch (keyinfo->alg) { 1931 switch (keyinfo->alg) {
1932 case ALG_CCMP: 1932 case ALG_CCMP:
@@ -1945,11 +1945,11 @@ static void iwl4965_build_tx_cmd_hwcrypto(struct iwl_priv *priv,
1945 break; 1945 break;
1946 1946
1947 case ALG_WEP: 1947 case ALG_WEP:
1948 wepkey = &priv->wep_keys[ctl->key_idx]; 1948 wepkey = &priv->wep_keys[ctl->hw_key->hw_key_idx];
1949 cmd->cmd.tx.sec_ctl = 0; 1949 cmd->cmd.tx.sec_ctl = 0;
1950 if (priv->default_wep_key) { 1950 if (priv->default_wep_key) {
1951 /* the WEP key was sent as static */ 1951 /* the WEP key was sent as static */
1952 keyidx = ctl->key_idx; 1952 keyidx = ctl->hw_key->hw_key_idx;
1953 memcpy(&cmd->cmd.tx.key[3], wepkey->key, 1953 memcpy(&cmd->cmd.tx.key[3], wepkey->key,
1954 wepkey->key_size); 1954 wepkey->key_size);
1955 if (wepkey->key_size == WEP_KEY_LEN_128) 1955 if (wepkey->key_size == WEP_KEY_LEN_128)
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 4a80d74975e8..27ef9f761ac5 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -286,8 +286,17 @@ enum mac80211_tx_control_flags {
286 286
287/* Transmit control fields. This data structure is passed to low-level driver 287/* Transmit control fields. This data structure is passed to low-level driver
288 * with each TX frame. The low-level driver is responsible for configuring 288 * with each TX frame. The low-level driver is responsible for configuring
289 * the hardware to use given values (depending on what is supported). */ 289 * the hardware to use given values (depending on what is supported).
290 290 *
291 * NOTE: Be careful with using the pointers outside of the ieee80211_ops->tx()
292 * context (i.e. when defering the work to a workqueue).
293 * The vif pointer is valid until the it has been removed with the
294 * ieee80211_ops->remove_interface() callback funtion.
295 * The hw_key pointer is valid until it has been removed with the
296 * ieee80211_ops->set_key() callback function.
297 * The tx_rate and alt_retry_rate pointers are valid until the phy is
298 * deregistered.
299 */
291struct ieee80211_tx_control { 300struct ieee80211_tx_control {
292 struct ieee80211_vif *vif; 301 struct ieee80211_vif *vif;
293 struct ieee80211_rate *tx_rate; 302 struct ieee80211_rate *tx_rate;
@@ -298,9 +307,11 @@ struct ieee80211_tx_control {
298 /* retry rate for the last retries */ 307 /* retry rate for the last retries */
299 struct ieee80211_rate *alt_retry_rate; 308 struct ieee80211_rate *alt_retry_rate;
300 309
310 /* Key used for hardware encryption
311 * NULL if IEEE80211_TXCTL_DO_NOT_ENCRYPT is set */
312 struct ieee80211_key_conf *hw_key;
313
301 u32 flags; /* tx control flags defined above */ 314 u32 flags; /* tx control flags defined above */
302 u8 key_idx; /* keyidx from hw->set_key(), undefined if
303 * IEEE80211_TXCTL_DO_NOT_ENCRYPT is set */
304 u8 retry_limit; /* 1 = only first attempt, 2 = one retry, .. 315 u8 retry_limit; /* 1 = only first attempt, 2 = one retry, ..
305 * This could be used when set_retry_limit 316 * This could be used when set_retry_limit
306 * is not implemented by the driver */ 317 * is not implemented by the driver */
diff --git a/net/mac80211/wep.c b/net/mac80211/wep.c
index affcecd78c10..3cbae42ec504 100644
--- a/net/mac80211/wep.c
+++ b/net/mac80211/wep.c
@@ -337,7 +337,7 @@ static int wep_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb)
337 if (ieee80211_wep_encrypt(tx->local, skb, tx->key)) 337 if (ieee80211_wep_encrypt(tx->local, skb, tx->key))
338 return -1; 338 return -1;
339 } else { 339 } else {
340 tx->control->key_idx = tx->key->conf.hw_key_idx; 340 tx->control->hw_key = &tx->key->conf;
341 if (tx->key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV) { 341 if (tx->key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV) {
342 if (!ieee80211_wep_add_iv(tx->local, skb, tx->key)) 342 if (!ieee80211_wep_add_iv(tx->local, skb, tx->key))
343 return -1; 343 return -1;
diff --git a/net/mac80211/wpa.c b/net/mac80211/wpa.c
index 45709ada8fee..42f3654e1c5e 100644
--- a/net/mac80211/wpa.c
+++ b/net/mac80211/wpa.c
@@ -228,7 +228,7 @@ static int tkip_encrypt_skb(struct ieee80211_tx_data *tx,
228 0x7f), 228 0x7f),
229 (u8) key->u.tkip.iv16); 229 (u8) key->u.tkip.iv16);
230 230
231 tx->control->key_idx = tx->key->conf.hw_key_idx; 231 tx->control->hw_key = &tx->key->conf;
232 return 0; 232 return 0;
233 } 233 }
234 234
@@ -256,7 +256,7 @@ ieee80211_crypto_tkip_encrypt(struct ieee80211_tx_data *tx)
256 !(tx->key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV) && 256 !(tx->key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV) &&
257 !wpa_test) { 257 !wpa_test) {
258 /* hwaccel - with no need for preallocated room for IV/ICV */ 258 /* hwaccel - with no need for preallocated room for IV/ICV */
259 tx->control->key_idx = tx->key->conf.hw_key_idx; 259 tx->control->hw_key = &tx->key->conf;
260 return TX_CONTINUE; 260 return TX_CONTINUE;
261 } 261 }
262 262
@@ -478,7 +478,7 @@ static int ccmp_encrypt_skb(struct ieee80211_tx_data *tx,
478 478
479 if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) { 479 if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) {
480 /* hwaccel - with preallocated room for CCMP header */ 480 /* hwaccel - with preallocated room for CCMP header */
481 tx->control->key_idx = key->conf.hw_key_idx; 481 tx->control->hw_key = &tx->key->conf;
482 return 0; 482 return 0;
483 } 483 }
484 484
@@ -505,7 +505,7 @@ ieee80211_crypto_ccmp_encrypt(struct ieee80211_tx_data *tx)
505 !(tx->key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)) { 505 !(tx->key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)) {
506 /* hwaccel - with no need for preallocated room for CCMP " 506 /* hwaccel - with no need for preallocated room for CCMP "
507 * header or MIC fields */ 507 * header or MIC fields */
508 tx->control->key_idx = tx->key->conf.hw_key_idx; 508 tx->control->hw_key = &tx->key->conf;
509 return TX_CONTINUE; 509 return TX_CONTINUE;
510 } 510 }
511 511