Skip to content

Commit 274bfb8

Browse files
committed
lib80211: absorb crypto bits from net/ieee80211
These bits are shared already between ipw2x00 and hostap, and could probably be shared both more cleanly and with other drivers. This commit simply relocates the code to lib80211 and adjusts the drivers appropriately. Signed-off-by: John W. Linville <linville@tuxdriver.com>
1 parent dfe1baf commit 274bfb8

30 files changed

Lines changed: 680 additions & 694 deletions

‎drivers/net/wireless/hostap/Kconfig‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ config HOSTAP
22
tristate "IEEE 802.11 for Host AP (Prism2/2.5/3 and WEP/TKIP/CCMP)"
33
depends on WLAN_80211
44
select WIRELESS_EXT
5-
select IEEE80211
6-
select IEEE80211_CRYPT_WEP
5+
select LIB80211
6+
select LIB80211_CRYPT_WEP
7+
select LIB80211_CRYPT_TKIP
8+
select LIB80211_CRYPT_CCMP
79
---help---
810
Shared driver code for IEEE 802.11b wireless cards based on
911
Intersil Prism2/2.5/3 chipset. This driver supports so called

‎drivers/net/wireless/hostap/hostap.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ void ap_control_flush_macs(struct mac_restrictions *mac_restrictions);
6363
int ap_control_kick_mac(struct ap_data *ap, struct net_device *dev, u8 *mac);
6464
void ap_control_kickall(struct ap_data *ap);
6565
void * ap_crypt_get_ptrs(struct ap_data *ap, u8 *addr, int permanent,
66-
struct ieee80211_crypt_data ***crypt);
66+
struct lib80211_crypt_data ***crypt);
6767
int prism2_ap_get_sta_qual(local_info_t *local, struct sockaddr addr[],
6868
struct iw_quality qual[], int buf_size,
6969
int aplist);

‎drivers/net/wireless/hostap/hostap_80211.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define HOSTAP_80211_H
33

44
#include <linux/types.h>
5-
#include <net/ieee80211_crypt.h>
5+
#include <net/ieee80211.h>
66

77
struct hostap_ieee80211_mgmt {
88
__le16 frame_control;

‎drivers/net/wireless/hostap/hostap_80211_rx.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include <linux/etherdevice.h>
2-
#include <net/ieee80211_crypt.h>
2+
#include <net/lib80211.h>
33

44
#include "hostap_80211.h"
55
#include "hostap.h"
@@ -649,7 +649,7 @@ static int hostap_is_eapol_frame(local_info_t *local, struct sk_buff *skb)
649649
/* Called only as a tasklet (software IRQ) */
650650
static int
651651
hostap_rx_frame_decrypt(local_info_t *local, struct sk_buff *skb,
652-
struct ieee80211_crypt_data *crypt)
652+
struct lib80211_crypt_data *crypt)
653653
{
654654
struct ieee80211_hdr_4addr *hdr;
655655
int res, hdrlen;
@@ -687,7 +687,7 @@ hostap_rx_frame_decrypt(local_info_t *local, struct sk_buff *skb,
687687
/* Called only as a tasklet (software IRQ) */
688688
static int
689689
hostap_rx_frame_decrypt_msdu(local_info_t *local, struct sk_buff *skb,
690-
int keyidx, struct ieee80211_crypt_data *crypt)
690+
int keyidx, struct lib80211_crypt_data *crypt)
691691
{
692692
struct ieee80211_hdr_4addr *hdr;
693693
int res, hdrlen;
@@ -733,7 +733,7 @@ void hostap_80211_rx(struct net_device *dev, struct sk_buff *skb,
733733
int from_assoc_ap = 0;
734734
u8 dst[ETH_ALEN];
735735
u8 src[ETH_ALEN];
736-
struct ieee80211_crypt_data *crypt = NULL;
736+
struct lib80211_crypt_data *crypt = NULL;
737737
void *sta = NULL;
738738
int keyidx = 0;
739739

@@ -785,7 +785,7 @@ void hostap_80211_rx(struct net_device *dev, struct sk_buff *skb,
785785
int idx = 0;
786786
if (skb->len >= hdrlen + 3)
787787
idx = skb->data[hdrlen + 3] >> 6;
788-
crypt = local->crypt[idx];
788+
crypt = local->crypt_info.crypt[idx];
789789
sta = NULL;
790790

791791
/* Use station specific key to override default keys if the

‎drivers/net/wireless/hostap/hostap_80211_tx.c‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ int hostap_mgmt_start_xmit(struct sk_buff *skb, struct net_device *dev)
306306

307307
/* Called only from software IRQ */
308308
static struct sk_buff * hostap_tx_encrypt(struct sk_buff *skb,
309-
struct ieee80211_crypt_data *crypt)
309+
struct lib80211_crypt_data *crypt)
310310
{
311311
struct hostap_interface *iface;
312312
local_info_t *local;
@@ -405,7 +405,7 @@ int hostap_master_start_xmit(struct sk_buff *skb, struct net_device *dev)
405405
if (local->host_encrypt) {
406406
/* Set crypt to default algorithm and key; will be replaced in
407407
* AP code if STA has own alg/key */
408-
tx.crypt = local->crypt[local->tx_keyidx];
408+
tx.crypt = local->crypt_info.crypt[local->crypt_info.tx_keyidx];
409409
tx.host_encrypt = 1;
410410
} else {
411411
tx.crypt = NULL;
@@ -487,7 +487,9 @@ int hostap_master_start_xmit(struct sk_buff *skb, struct net_device *dev)
487487

488488
if (tx.crypt && (!tx.crypt->ops || !tx.crypt->ops->encrypt_mpdu))
489489
tx.crypt = NULL;
490-
else if ((tx.crypt || local->crypt[local->tx_keyidx]) && !no_encrypt) {
490+
else if ((tx.crypt ||
491+
local->crypt_info.crypt[local->crypt_info.tx_keyidx]) &&
492+
!no_encrypt) {
491493
/* Add ISWEP flag both for firmware and host based encryption
492494
*/
493495
fc |= IEEE80211_FCTL_PROTECTED;

‎drivers/net/wireless/hostap/hostap_ap.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,7 +1206,7 @@ static void prism2_check_tx_rates(struct sta_info *sta)
12061206

12071207
static void ap_crypt_init(struct ap_data *ap)
12081208
{
1209-
ap->crypt = ieee80211_get_crypto_ops("WEP");
1209+
ap->crypt = lib80211_get_crypto_ops("WEP");
12101210

12111211
if (ap->crypt) {
12121212
if (ap->crypt->init) {
@@ -1224,7 +1224,7 @@ static void ap_crypt_init(struct ap_data *ap)
12241224

12251225
if (ap->crypt == NULL) {
12261226
printk(KERN_WARNING "AP could not initialize WEP: load module "
1227-
"ieee80211_crypt_wep.ko\n");
1227+
"lib80211_crypt_wep.ko\n");
12281228
}
12291229
}
12301230

@@ -1293,7 +1293,7 @@ static void handle_authen(local_info_t *local, struct sk_buff *skb,
12931293
__le16 *pos;
12941294
u16 resp = WLAN_STATUS_SUCCESS, fc;
12951295
struct sta_info *sta = NULL;
1296-
struct ieee80211_crypt_data *crypt;
1296+
struct lib80211_crypt_data *crypt;
12971297
char *txt = "";
12981298

12991299
len = skb->len - IEEE80211_MGMT_HDR_LEN;
@@ -1319,7 +1319,7 @@ static void handle_authen(local_info_t *local, struct sk_buff *skb,
13191319
int idx = 0;
13201320
if (skb->len >= hdrlen + 3)
13211321
idx = skb->data[hdrlen + 3] >> 6;
1322-
crypt = local->crypt[idx];
1322+
crypt = local->crypt_info.crypt[idx];
13231323
}
13241324

13251325
pos = (__le16 *) (skb->data + IEEE80211_MGMT_HDR_LEN);
@@ -3065,7 +3065,7 @@ ap_rx_ret hostap_handle_sta_rx(local_info_t *local, struct net_device *dev,
30653065
/* Called only as a tasklet (software IRQ) */
30663066
int hostap_handle_sta_crypto(local_info_t *local,
30673067
struct ieee80211_hdr_4addr *hdr,
3068-
struct ieee80211_crypt_data **crypt,
3068+
struct lib80211_crypt_data **crypt,
30693069
void **sta_ptr)
30703070
{
30713071
struct sta_info *sta;
@@ -3213,7 +3213,7 @@ void hostap_update_rates(local_info_t *local)
32133213

32143214

32153215
void * ap_crypt_get_ptrs(struct ap_data *ap, u8 *addr, int permanent,
3216-
struct ieee80211_crypt_data ***crypt)
3216+
struct lib80211_crypt_data ***crypt)
32173217
{
32183218
struct sta_info *sta;
32193219

‎drivers/net/wireless/hostap/hostap_ap.h‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ struct sta_info {
7474
u32 tx_since_last_failure;
7575
u32 tx_consecutive_exc;
7676

77-
struct ieee80211_crypt_data *crypt;
77+
struct lib80211_crypt_data *crypt;
7878

7979
int ap; /* whether this station is an AP */
8080

@@ -209,7 +209,7 @@ struct ap_data {
209209

210210
/* WEP operations for generating challenges to be used with shared key
211211
* authentication */
212-
struct ieee80211_crypto_ops *crypt;
212+
struct lib80211_crypto_ops *crypt;
213213
void *crypt_priv;
214214
#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
215215
};
@@ -229,7 +229,7 @@ typedef enum {
229229
struct hostap_tx_data {
230230
struct sk_buff *skb;
231231
int host_encrypt;
232-
struct ieee80211_crypt_data *crypt;
232+
struct lib80211_crypt_data *crypt;
233233
void *sta_ptr;
234234
};
235235
ap_tx_ret hostap_handle_sta_tx(local_info_t *local, struct hostap_tx_data *tx);
@@ -244,7 +244,7 @@ ap_rx_ret hostap_handle_sta_rx(local_info_t *local, struct net_device *dev,
244244
struct hostap_80211_rx_status *rx_stats,
245245
int wds);
246246
int hostap_handle_sta_crypto(local_info_t *local, struct ieee80211_hdr_4addr *hdr,
247-
struct ieee80211_crypt_data **crypt,
247+
struct lib80211_crypt_data **crypt,
248248
void **sta_ptr);
249249
int hostap_is_sta_assoc(struct ap_data *ap, u8 *sta_addr);
250250
int hostap_is_sta_authorized(struct ap_data *ap, u8 *sta_addr);

‎drivers/net/wireless/hostap/hostap_hw.c‎

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
#include <linux/wireless.h>
4848
#include <net/iw_handler.h>
4949
#include <net/ieee80211.h>
50-
#include <net/ieee80211_crypt.h>
50+
#include <net/lib80211.h>
5151
#include <asm/irq.h>
5252

5353
#include "hostap_80211.h"
@@ -2791,11 +2791,12 @@ static void prism2_check_sta_fw_version(local_info_t *local)
27912791
static void prism2_crypt_deinit_entries(local_info_t *local, int force)
27922792
{
27932793
struct list_head *ptr, *n;
2794-
struct ieee80211_crypt_data *entry;
2794+
struct lib80211_crypt_data *entry;
27952795

2796-
for (ptr = local->crypt_deinit_list.next, n = ptr->next;
2797-
ptr != &local->crypt_deinit_list; ptr = n, n = ptr->next) {
2798-
entry = list_entry(ptr, struct ieee80211_crypt_data, list);
2796+
for (ptr = local->crypt_info.crypt_deinit_list.next, n = ptr->next;
2797+
ptr != &local->crypt_info.crypt_deinit_list;
2798+
ptr = n, n = ptr->next) {
2799+
entry = list_entry(ptr, struct lib80211_crypt_data, list);
27992800

28002801
if (atomic_read(&entry->refcnt) != 0 && !force)
28012802
continue;
@@ -2816,11 +2817,11 @@ static void prism2_crypt_deinit_handler(unsigned long data)
28162817

28172818
spin_lock_irqsave(&local->lock, flags);
28182819
prism2_crypt_deinit_entries(local, 0);
2819-
if (!list_empty(&local->crypt_deinit_list)) {
2820+
if (!list_empty(&local->crypt_info.crypt_deinit_list)) {
28202821
printk(KERN_DEBUG "%s: entries remaining in delayed crypt "
28212822
"deletion list\n", local->dev->name);
2822-
local->crypt_deinit_timer.expires = jiffies + HZ;
2823-
add_timer(&local->crypt_deinit_timer);
2823+
local->crypt_info.crypt_deinit_timer.expires = jiffies + HZ;
2824+
add_timer(&local->crypt_info.crypt_deinit_timer);
28242825
}
28252826
spin_unlock_irqrestore(&local->lock, flags);
28262827

@@ -3250,10 +3251,13 @@ while (0)
32503251

32513252
INIT_LIST_HEAD(&local->cmd_queue);
32523253
init_waitqueue_head(&local->hostscan_wq);
3253-
INIT_LIST_HEAD(&local->crypt_deinit_list);
3254-
init_timer(&local->crypt_deinit_timer);
3255-
local->crypt_deinit_timer.data = (unsigned long) local;
3256-
local->crypt_deinit_timer.function = prism2_crypt_deinit_handler;
3254+
3255+
local->crypt_info.name = dev->name;
3256+
local->crypt_info.lock = &local->lock;
3257+
INIT_LIST_HEAD(&local->crypt_info.crypt_deinit_list);
3258+
init_timer(&local->crypt_info.crypt_deinit_timer);
3259+
local->crypt_info.crypt_deinit_timer.data = (unsigned long) local;
3260+
local->crypt_info.crypt_deinit_timer.function = prism2_crypt_deinit_handler;
32573261

32583262
init_timer(&local->passive_scan_timer);
32593263
local->passive_scan_timer.data = (unsigned long) local;
@@ -3354,8 +3358,8 @@ static void prism2_free_local_data(struct net_device *dev)
33543358

33553359
flush_scheduled_work();
33563360

3357-
if (timer_pending(&local->crypt_deinit_timer))
3358-
del_timer(&local->crypt_deinit_timer);
3361+
if (timer_pending(&local->crypt_info.crypt_deinit_timer))
3362+
del_timer(&local->crypt_info.crypt_deinit_timer);
33593363
prism2_crypt_deinit_entries(local, 1);
33603364

33613365
if (timer_pending(&local->passive_scan_timer))
@@ -3374,12 +3378,12 @@ static void prism2_free_local_data(struct net_device *dev)
33743378
prism2_callback(local, PRISM2_CALLBACK_DISABLE);
33753379

33763380
for (i = 0; i < WEP_KEYS; i++) {
3377-
struct ieee80211_crypt_data *crypt = local->crypt[i];
3381+
struct lib80211_crypt_data *crypt = local->crypt_info.crypt[i];
33783382
if (crypt) {
33793383
if (crypt->ops)
33803384
crypt->ops->deinit(crypt->priv);
33813385
kfree(crypt);
3382-
local->crypt[i] = NULL;
3386+
local->crypt_info.crypt[i] = NULL;
33833387
}
33843388
}
33853389

0 commit comments

Comments
 (0)