Skip to content

Commit

Permalink
staging/rtl8192e: Register against lib80211
Browse files Browse the repository at this point in the history
Convert rtllib from registering the crypt drivers against rtllib_crypt
and instead register the against lib80211. The crypto functions have
R- prepended (R-CCMP, R-TKIP, R-WEP) so they will not clash with the
lib80211 versions.

We cannot use the lib80211 crypt drivers since the rtl8192e has some
hardware support that is not handled by the lib80211 crypt drivers.

Signed-off-by: Sean MacLennan <seanm@seanm.ca>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Sean MacLennan authored and Greg Kroah-Hartman committed Dec 22, 2011
1 parent 0ddcf5f commit 3b148be
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 96 deletions.
13 changes: 4 additions & 9 deletions drivers/staging/rtl8192e/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ config RTLLIB
tristate "Support for rtllib wireless devices"
depends on WLAN && m
default n
select RTLLIB_CRYPTO
select LIB80211
---help---
If you have a wireless card that uses rtllib, say
Y. Currently the only card is the rtl8192e.
Expand All @@ -11,14 +11,9 @@ config RTLLIB

if RTLLIB

config RTLLIB_CRYPTO
tristate "Support for rtllib crypto support"
---help---
Base crypto driver for rtllib.

config RTLLIB_CRYPTO_CCMP
tristate "Support for rtllib CCMP crypto"
depends on RTLLIB_CRYPTO
depends on RTLLIB
default y
---help---
CCMP crypto driver for rtllib.
Expand All @@ -27,7 +22,7 @@ config RTLLIB_CRYPTO_CCMP

config RTLLIB_CRYPTO_TKIP
tristate "Support for rtllib TKIP crypto"
depends on RTLLIB_CRYPTO
depends on RTLLIB
default y
---help---
TKIP crypto driver for rtllib.
Expand All @@ -36,7 +31,7 @@ config RTLLIB_CRYPTO_TKIP

config RTLLIB_CRYPTO_WEP
tristate "Support for rtllib WEP crypto"
depends on RTLLIB_CRYPTO
depends on RTLLIB
default y
---help---
TKIP crypto driver for rtllib.
Expand Down
1 change: 0 additions & 1 deletion drivers/staging/rtl8192e/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ rtllib-objs := \

obj-$(CONFIG_RTLLIB) += rtllib.o

obj-$(CONFIG_RTLLIB_CRYPTO) += rtllib_crypt.o
obj-$(CONFIG_RTLLIB_CRYPTO_CCMP) += rtllib_crypt_ccmp.o
obj-$(CONFIG_RTLLIB_CRYPTO_TKIP) += rtllib_crypt_tkip.o
obj-$(CONFIG_RTLLIB_CRYPTO_WEP) += rtllib_crypt_wep.o
Expand Down
26 changes: 1 addition & 25 deletions drivers/staging/rtl8192e/rtllib.h
Original file line number Diff line number Diff line change
Expand Up @@ -1060,8 +1060,6 @@ struct rtllib_stats {

struct rtllib_device;

#include "rtllib_crypt.h"

#define SEC_KEY_1 (1<<0)
#define SEC_KEY_2 (1<<1)
#define SEC_KEY_3 (1<<2)
Expand Down Expand Up @@ -2985,21 +2983,6 @@ static inline const char *escape_essid(const char *essid, u8 essid_len)
(HTMcsToDataRate(_ieee, (u8)_MGN_RATE)))

/* fun with the built-in rtllib stack... */
int rtllib_init(void);
void rtllib_exit(void);
int rtllib_crypto_init(void);
void rtllib_crypto_deinit(void);
int rtllib_crypto_tkip_init(void);
void rtllib_crypto_tkip_exit(void);
int rtllib_crypto_ccmp_init(void);
void rtllib_crypto_ccmp_exit(void);
int rtllib_crypto_wep_init(void);
void rtllib_crypto_wep_exit(void);

void rtllib_MgntDisconnectIBSS(struct rtllib_device *rtllib);
void rtllib_MlmeDisassociateRequest(struct rtllib_device *rtllib, u8 *asSta,
u8 asRsn);
void rtllib_MgntDisconnectAP(struct rtllib_device *rtllib, u8 asRsn);
bool rtllib_MgntDisconnect(struct rtllib_device *rtllib, u8 asRsn);


Expand Down Expand Up @@ -3066,12 +3049,5 @@ extern void rtllib_TURBO_Info(struct rtllib_device *ieee, u8 **tag_p);
#define MUTEX_LOCK_PRIV(pmutex) mutex_lock(pmutex)
#define MUTEX_UNLOCK_PRIV(pmutex) mutex_unlock(pmutex)
#endif
static inline void dump_buf(u8 *buf, u32 len)
{
u32 i;
printk(KERN_INFO "-----------------Len %d----------------\n", len);
for (i = 0; i < len; i++)
printk("%2.2x-", *(buf+i));
printk("\n");
}

#endif /* RTLLIB_H */
2 changes: 1 addition & 1 deletion drivers/staging/rtl8192e/rtllib_crypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ int __init rtllib_crypto_init(void)
INIT_LIST_HEAD(&hcrypt->algs);
spin_lock_init(&hcrypt->lock);

ret = rtllib_register_crypto_ops(&rtllib_crypt_null);
ret = lib80211_register_crypto_ops(&rtllib_crypt_null);
if (ret < 0) {
kfree(hcrypt);
hcrypt = NULL;
Expand Down
6 changes: 3 additions & 3 deletions drivers/staging/rtl8192e/rtllib_crypt_ccmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ static char *rtllib_ccmp_print_stats(char *p, void *priv)
}

static struct lib80211_crypto_ops rtllib_crypt_ccmp = {
.name = "CCMP",
.name = "R-CCMP",
.init = rtllib_ccmp_init,
.deinit = rtllib_ccmp_deinit,
.encrypt_mpdu = rtllib_ccmp_encrypt,
Expand All @@ -446,13 +446,13 @@ static struct lib80211_crypto_ops rtllib_crypt_ccmp = {

int __init rtllib_crypto_ccmp_init(void)
{
return rtllib_register_crypto_ops(&rtllib_crypt_ccmp);
return lib80211_register_crypto_ops(&rtllib_crypt_ccmp);
}


void __exit rtllib_crypto_ccmp_exit(void)
{
rtllib_unregister_crypto_ops(&rtllib_crypt_ccmp);
lib80211_unregister_crypto_ops(&rtllib_crypt_ccmp);
}

module_init(rtllib_crypto_ccmp_init);
Expand Down
6 changes: 3 additions & 3 deletions drivers/staging/rtl8192e/rtllib_crypt_tkip.c
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ static char *rtllib_tkip_print_stats(char *p, void *priv)
}

static struct lib80211_crypto_ops rtllib_crypt_tkip = {
.name = "TKIP",
.name = "R-TKIP",
.init = rtllib_tkip_init,
.deinit = rtllib_tkip_deinit,
.encrypt_mpdu = rtllib_tkip_encrypt,
Expand All @@ -754,13 +754,13 @@ static struct lib80211_crypto_ops rtllib_crypt_tkip = {

int __init rtllib_crypto_tkip_init(void)
{
return rtllib_register_crypto_ops(&rtllib_crypt_tkip);
return lib80211_register_crypto_ops(&rtllib_crypt_tkip);
}


void __exit rtllib_crypto_tkip_exit(void)
{
rtllib_unregister_crypto_ops(&rtllib_crypt_tkip);
lib80211_unregister_crypto_ops(&rtllib_crypt_tkip);
}

module_init(rtllib_crypto_tkip_init);
Expand Down
6 changes: 3 additions & 3 deletions drivers/staging/rtl8192e/rtllib_crypt_wep.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ static char *prism2_wep_print_stats(char *p, void *priv)
}

static struct lib80211_crypto_ops rtllib_crypt_wep = {
.name = "WEP",
.name = "R-WEP",
.init = prism2_wep_init,
.deinit = prism2_wep_deinit,
.encrypt_mpdu = prism2_wep_encrypt,
Expand All @@ -274,13 +274,13 @@ static struct lib80211_crypto_ops rtllib_crypt_wep = {

int __init rtllib_crypto_wep_init(void)
{
return rtllib_register_crypto_ops(&rtllib_crypt_wep);
return lib80211_register_crypto_ops(&rtllib_crypt_wep);
}


void __exit rtllib_crypto_wep_exit(void)
{
rtllib_unregister_crypto_ops(&rtllib_crypt_wep);
lib80211_unregister_crypto_ops(&rtllib_crypt_wep);
}

module_init(rtllib_crypto_wep_init);
Expand Down
23 changes: 4 additions & 19 deletions drivers/staging/rtl8192e/rtllib_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,6 @@ struct net_device *alloc_rtllib(int sizeof_priv)
ieee->host_decrypt = 1;
ieee->ieee802_1x = 1; /* Default to supporting 802.1x */

/* SAM Init here */
INIT_LIST_HEAD(&ieee->crypt_info.crypt_deinit_list);
_setup_timer(&ieee->crypt_info.crypt_deinit_timer,
rtllib_crypt_deinit_handler,
(unsigned long)&ieee->crypt_info);
ieee->rtllib_ap_sec_type = rtllib_ap_sec_type;

spin_lock_init(&ieee->lock);
Expand All @@ -150,6 +145,9 @@ struct net_device *alloc_rtllib(int sizeof_priv)
atomic_set(&(ieee->atm_chnlop), 0);
atomic_set(&(ieee->atm_swbw), 0);

/* SAM FIXME */
lib80211_crypt_info_init(&ieee->crypt_info, "RTLLIB", &ieee->lock);

ieee->bHalfNMode = false;
ieee->wpa_enabled = 0;
ieee->tkip_countermeasures = 0;
Expand Down Expand Up @@ -192,25 +190,12 @@ void free_rtllib(struct net_device *dev)
{
struct rtllib_device *ieee = (struct rtllib_device *)
netdev_priv_rsl(dev);
int i;

kfree(ieee->pHTInfo);
ieee->pHTInfo = NULL;
rtllib_softmac_free(ieee);

/* SAM cleanup */
del_timer_sync(&ieee->crypt_info.crypt_deinit_timer);
rtllib_crypt_deinit_entries(&ieee->crypt_info, 1);

for (i = 0; i < NUM_WEP_KEYS; i++) {
struct lib80211_crypt_data *crypt = ieee->crypt_info.crypt[i];
if (crypt) {
if (crypt->ops)
crypt->ops->deinit(crypt->priv);
kfree(crypt);
ieee->crypt_info.crypt[i] = NULL;
}
}
lib80211_crypt_info_free(&ieee->crypt_info);

rtllib_networks_free(ieee);
free_netdev(dev);
Expand Down
32 changes: 16 additions & 16 deletions drivers/staging/rtl8192e/rtllib_softmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ static struct sk_buff *rtllib_probe_resp(struct rtllib_device *ieee, u8 *dest)

crypt = ieee->crypt_info.crypt[ieee->crypt_info.tx_keyidx];
encrypt = ieee->host_encrypt && crypt && crypt->ops &&
((0 == strcmp(crypt->ops->name, "WEP") || wpa_ie_len));
((0 == strcmp(crypt->ops->name, "R-WEP") || wpa_ie_len));
if (ieee->pHTInfo->bCurrentHTSupport) {
tmp_ht_cap_buf = (u8 *) &(ieee->pHTInfo->SelfHTCap);
tmp_ht_cap_len = sizeof(ieee->pHTInfo->SelfHTCap);
Expand Down Expand Up @@ -1194,7 +1194,7 @@ inline struct sk_buff *rtllib_association_req(struct rtllib_network *beacon,
crypt = ieee->crypt_info.crypt[ieee->crypt_info.tx_keyidx];
if (crypt != NULL)
encrypt = ieee->host_encrypt && crypt && crypt->ops &&
((0 == strcmp(crypt->ops->name, "WEP") ||
((0 == strcmp(crypt->ops->name, "R-WEP") ||
wpa_ie_len));
else
encrypt = 0;
Expand Down Expand Up @@ -3377,7 +3377,7 @@ static int rtllib_wpa_set_encryption(struct rtllib_device *ieee,
sec.enabled = 0;
sec.level = SEC_LEVEL_0;
sec.flags |= SEC_ENABLED | SEC_LEVEL;
rtllib_crypt_delayed_deinit(&ieee->crypt_info, crypt);
lib80211_crypt_delayed_deinit(&ieee->crypt_info, crypt);
}
goto done;
}
Expand All @@ -3386,19 +3386,19 @@ static int rtllib_wpa_set_encryption(struct rtllib_device *ieee,

/* IPW HW cannot build TKIP MIC, host decryption still needed. */
if (!(ieee->host_encrypt || ieee->host_decrypt) &&
strcmp(param->u.crypt.alg, "TKIP"))
strcmp(param->u.crypt.alg, "R-TKIP"))
goto skip_host_crypt;

ops = rtllib_get_crypto_ops(param->u.crypt.alg);
if (ops == NULL && strcmp(param->u.crypt.alg, "WEP") == 0) {
ops = lib80211_get_crypto_ops(param->u.crypt.alg);
if (ops == NULL && strcmp(param->u.crypt.alg, "R-WEP") == 0) {
request_module("rtllib_crypt_wep");
ops = rtllib_get_crypto_ops(param->u.crypt.alg);
} else if (ops == NULL && strcmp(param->u.crypt.alg, "TKIP") == 0) {
ops = lib80211_get_crypto_ops(param->u.crypt.alg);
} else if (ops == NULL && strcmp(param->u.crypt.alg, "R-TKIP") == 0) {
request_module("rtllib_crypt_tkip");
ops = rtllib_get_crypto_ops(param->u.crypt.alg);
} else if (ops == NULL && strcmp(param->u.crypt.alg, "CCMP") == 0) {
ops = lib80211_get_crypto_ops(param->u.crypt.alg);
} else if (ops == NULL && strcmp(param->u.crypt.alg, "R-CCMP") == 0) {
request_module("rtllib_crypt_ccmp");
ops = rtllib_get_crypto_ops(param->u.crypt.alg);
ops = lib80211_get_crypto_ops(param->u.crypt.alg);
}
if (ops == NULL) {
printk(KERN_INFO "unknown crypto alg '%s'\n",
Expand All @@ -3410,7 +3410,7 @@ static int rtllib_wpa_set_encryption(struct rtllib_device *ieee,
if (*crypt == NULL || (*crypt)->ops != ops) {
struct lib80211_crypt_data *new_crypt;

rtllib_crypt_delayed_deinit(&ieee->crypt_info, crypt);
lib80211_crypt_delayed_deinit(&ieee->crypt_info, crypt);

new_crypt = (struct lib80211_crypt_data *)
kmalloc(sizeof(*new_crypt), GFP_KERNEL);
Expand Down Expand Up @@ -3459,13 +3459,13 @@ static int rtllib_wpa_set_encryption(struct rtllib_device *ieee,
sec.key_sizes[param->u.crypt.idx] = param->u.crypt.key_len;
sec.flags |= (1 << param->u.crypt.idx);

if (strcmp(param->u.crypt.alg, "WEP") == 0) {
if (strcmp(param->u.crypt.alg, "R-WEP") == 0) {
sec.flags |= SEC_LEVEL;
sec.level = SEC_LEVEL_1;
} else if (strcmp(param->u.crypt.alg, "TKIP") == 0) {
} else if (strcmp(param->u.crypt.alg, "R-TKIP") == 0) {
sec.flags |= SEC_LEVEL;
sec.level = SEC_LEVEL_2;
} else if (strcmp(param->u.crypt.alg, "CCMP") == 0) {
} else if (strcmp(param->u.crypt.alg, "R-CCMP") == 0) {
sec.flags |= SEC_LEVEL;
sec.level = SEC_LEVEL_3;
}
Expand Down Expand Up @@ -3568,7 +3568,7 @@ u8 rtllib_ap_sec_type(struct rtllib_device *ieee)
crypt = ieee->crypt_info.crypt[ieee->crypt_info.tx_keyidx];
encrypt = (ieee->current_network.capability & WLAN_CAPABILITY_PRIVACY)
|| (ieee->host_encrypt && crypt && crypt->ops &&
(0 == strcmp(crypt->ops->name, "WEP")));
(0 == strcmp(crypt->ops->name, "R-WEP")));

/* simply judge */
if (encrypt && (wpa_ie_len == 0)) {
Expand Down
Loading

0 comments on commit 3b148be

Please sign in to comment.