aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2007-09-14 11:10:25 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 19:49:29 -0400
commit6a7664d451e7014b1a6828e50ccb3308d0b84816 (patch)
tree01c319d33d8c5b61d1946e6c76e27ec9dd44329b
parent7ac1bd6aecc92cfe6ec11891819dd4c26f2f7879 (diff)
[MAC80211]: remove HW_KEY_IDX_INVALID
This patch makes the mac80211/driver interface rely only on the IEEE80211_TXCTL_DO_NOT_ENCRYPT flag to signal to the driver whether a frame should be encrypted or not, since mac80211 internally no longer relies on HW_KEY_IDX_INVALID either this removes it, changes the key index to be a u8 in all places and makes the full range of the value available to drivers. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Acked-by: Michael Wu <flamingice@sourmilk.net> Signed-off-by: John W. Linville <linville@tuxdriver.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/net/mac80211.h17
-rw-r--r--net/mac80211/key.c4
-rw-r--r--net/mac80211/tx.c16
3 files changed, 20 insertions, 17 deletions
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 950a4827507f..652dced0f3ec 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -164,7 +164,6 @@ struct ieee80211_low_level_stats {
164/* Transmit control fields. This data structure is passed to low-level driver 164/* Transmit control fields. This data structure is passed to low-level driver
165 * with each TX frame. The low-level driver is responsible for configuring 165 * with each TX frame. The low-level driver is responsible for configuring
166 * the hardware to use given values (depending on what is supported). */ 166 * the hardware to use given values (depending on what is supported). */
167#define HW_KEY_IDX_INVALID -1
168 167
169struct ieee80211_tx_control { 168struct ieee80211_tx_control {
170 int tx_rate; /* Transmit rate, given as the hw specific value for the 169 int tx_rate; /* Transmit rate, given as the hw specific value for the
@@ -197,13 +196,13 @@ struct ieee80211_tx_control {
197 * long retry value */ 196 * long retry value */
198 u32 flags; /* tx control flags defined 197 u32 flags; /* tx control flags defined
199 * above */ 198 * above */
199 u8 key_idx; /* keyidx from hw->set_key(), undefined if
200 * IEEE80211_TXCTL_DO_NOT_ENCRYPT is set */
200 u8 retry_limit; /* 1 = only first attempt, 2 = one retry, .. 201 u8 retry_limit; /* 1 = only first attempt, 2 = one retry, ..
201 * This could be used when set_retry_limit 202 * This could be used when set_retry_limit
202 * is not implemented by the driver */ 203 * is not implemented by the driver */
203 u8 power_level; /* per-packet transmit power level, in dBm */ 204 u8 power_level; /* per-packet transmit power level, in dBm */
204 u8 antenna_sel_tx; /* 0 = default/diversity, 1 = Ant0, 2 = Ant1 */ 205 u8 antenna_sel_tx; /* 0 = default/diversity, 1 = Ant0, 2 = Ant1 */
205 s8 key_idx; /* HW_KEY_IDX_INVALID = do not encrypt,
206 * other values: keyidx from hw->set_key() */
207 u8 icv_len; /* length of the ICV/MIC field in octets */ 206 u8 icv_len; /* length of the ICV/MIC field in octets */
208 u8 iv_len; /* length of the IV field in octets */ 207 u8 iv_len; /* length of the IV field in octets */
209 u8 tkip_key[16]; /* generated phase2/phase1 key for hw TKIP */ 208 u8 tkip_key[16]; /* generated phase2/phase1 key for hw TKIP */
@@ -467,8 +466,7 @@ enum ieee80211_key_flags {
467 * 466 *
468 * @hw_key_idx: To be set by the driver, this is the key index the driver 467 * @hw_key_idx: To be set by the driver, this is the key index the driver
469 * wants to be given when a frame is transmitted and needs to be 468 * wants to be given when a frame is transmitted and needs to be
470 * encrypted in hardware. It defaults to %HW_KEY_IDX_INVALID which 469 * encrypted in hardware.
471 * the driver may not use.
472 * @alg: The key algorithm. 470 * @alg: The key algorithm.
473 * @flags: key flags, see &enum ieee80211_key_flags. 471 * @flags: key flags, see &enum ieee80211_key_flags.
474 * @keyidx: the key index (0-3) 472 * @keyidx: the key index (0-3)
@@ -476,8 +474,8 @@ enum ieee80211_key_flags {
476 * @key: key material 474 * @key: key material
477 */ 475 */
478struct ieee80211_key_conf { 476struct ieee80211_key_conf {
479 int hw_key_idx;
480 ieee80211_key_alg alg; 477 ieee80211_key_alg alg;
478 u8 hw_key_idx;
481 u8 flags; 479 u8 flags;
482 s8 keyidx; 480 s8 keyidx;
483 u8 keylen; 481 u8 keylen;
@@ -686,9 +684,10 @@ struct ieee80211_ops {
686 * selected by the low-level driver. 684 * selected by the low-level driver.
687 * 685 *
688 * Return 0 if the key is now in use, -EOPNOTSUPP or -ENOSPC if it 686 * Return 0 if the key is now in use, -EOPNOTSUPP or -ENOSPC if it
689 * couldn't be added; if you return 0 then hw_key_idx must be 687 * couldn't be added; if you return 0 then hw_key_idx must be assigned
690 * assigned to something other than HW_KEY_IDX_INVALID. When the cmd 688 * to the hardware key index, you are free to use the full u8 range.
691 * is DISABLE_KEY then it must succeed. 689 *
690 * When the cmd is DISABLE_KEY then it must succeed.
692 * 691 *
693 * Note that it is permissible to not decrypt a frame even if a key 692 * Note that it is permissible to not decrypt a frame even if a key
694 * for it has been uploaded to hardware, the stack will not make any 693 * for it has been uploaded to hardware, the stack will not make any
diff --git a/net/mac80211/key.c b/net/mac80211/key.c
index b10e33deb63e..dd6fc4aa3ff5 100644
--- a/net/mac80211/key.c
+++ b/net/mac80211/key.c
@@ -73,8 +73,6 @@ static void ieee80211_key_enable_hw_accel(struct ieee80211_key *key)
73 key->sdata->dev->dev_addr, addr, 73 key->sdata->dev->dev_addr, addr,
74 &key->conf); 74 &key->conf);
75 75
76 WARN_ON(!ret && (key->conf.hw_key_idx == HW_KEY_IDX_INVALID));
77
78 if (!ret) 76 if (!ret)
79 key->flags |= KEY_FLAG_UPLOADED_TO_HARDWARE; 77 key->flags |= KEY_FLAG_UPLOADED_TO_HARDWARE;
80 78
@@ -109,7 +107,6 @@ static void ieee80211_key_disable_hw_accel(struct ieee80211_key *key)
109 key->conf.keyidx, MAC_ARG(addr), ret); 107 key->conf.keyidx, MAC_ARG(addr), ret);
110 108
111 key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE; 109 key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE;
112 key->conf.hw_key_idx = HW_KEY_IDX_INVALID;
113} 110}
114 111
115struct ieee80211_key *ieee80211_key_alloc(struct ieee80211_sub_if_data *sdata, 112struct ieee80211_key *ieee80211_key_alloc(struct ieee80211_sub_if_data *sdata,
@@ -132,7 +129,6 @@ struct ieee80211_key *ieee80211_key_alloc(struct ieee80211_sub_if_data *sdata,
132 * Default to software encryption; we'll later upload the 129 * Default to software encryption; we'll later upload the
133 * key to the hardware if possible. 130 * key to the hardware if possible.
134 */ 131 */
135 key->conf.hw_key_idx = HW_KEY_IDX_INVALID;
136 key->conf.flags = 0; 132 key->conf.flags = 0;
137 key->flags = 0; 133 key->flags = 0;
138 134
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index e2ae1e1fcc7b..3d57e6d80f6d 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -430,8 +430,6 @@ ieee80211_tx_h_select_key(struct ieee80211_txrx_data *tx)
430{ 430{
431 struct ieee80211_key *key; 431 struct ieee80211_key *key;
432 432
433 tx->u.tx.control->key_idx = HW_KEY_IDX_INVALID;
434
435 if (unlikely(tx->u.tx.control->flags & IEEE80211_TXCTL_DO_NOT_ENCRYPT)) 433 if (unlikely(tx->u.tx.control->flags & IEEE80211_TXCTL_DO_NOT_ENCRYPT))
436 tx->key = NULL; 434 tx->key = NULL;
437 else if (tx->sta && (key = rcu_dereference(tx->sta->key))) 435 else if (tx->sta && (key = rcu_dereference(tx->sta->key)))
@@ -442,8 +440,10 @@ ieee80211_tx_h_select_key(struct ieee80211_txrx_data *tx)
442 !(tx->sdata->eapol && ieee80211_is_eapol(tx->skb))) { 440 !(tx->sdata->eapol && ieee80211_is_eapol(tx->skb))) {
443 I802_DEBUG_INC(tx->local->tx_handlers_drop_unencrypted); 441 I802_DEBUG_INC(tx->local->tx_handlers_drop_unencrypted);
444 return TXRX_DROP; 442 return TXRX_DROP;
445 } else 443 } else {
446 tx->key = NULL; 444 tx->key = NULL;
445 tx->u.tx.control->flags |= IEEE80211_TXCTL_DO_NOT_ENCRYPT;
446 }
447 447
448 if (tx->key) { 448 if (tx->key) {
449 tx->key->tx_rx_count++; 449 tx->key->tx_rx_count++;
@@ -724,6 +724,15 @@ ieee80211_tx_h_misc(struct ieee80211_txrx_data *tx)
724 } 724 }
725 } 725 }
726 726
727 /*
728 * Tell hardware to not encrypt when we had sw crypto.
729 * Because we use the same flag to internally indicate that
730 * no (software) encryption should be done, we have to set it
731 * after all crypto handlers.
732 */
733 if (tx->key && !(tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE))
734 tx->u.tx.control->flags |= IEEE80211_TXCTL_DO_NOT_ENCRYPT;
735
727 return TXRX_CONTINUE; 736 return TXRX_CONTINUE;
728} 737}
729 738
@@ -833,7 +842,6 @@ __ieee80211_parse_tx_radiotap(
833 */ 842 */
834 843
835 control->retry_limit = 1; /* no retry */ 844 control->retry_limit = 1; /* no retry */
836 control->key_idx = HW_KEY_IDX_INVALID;
837 control->flags &= ~(IEEE80211_TXCTL_USE_RTS_CTS | 845 control->flags &= ~(IEEE80211_TXCTL_USE_RTS_CTS |
838 IEEE80211_TXCTL_USE_CTS_PROTECT); 846 IEEE80211_TXCTL_USE_CTS_PROTECT);
839 control->flags |= IEEE80211_TXCTL_DO_NOT_ENCRYPT | 847 control->flags |= IEEE80211_TXCTL_DO_NOT_ENCRYPT |