aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/airo.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/airo.c')
-rw-r--r--drivers/net/wireless/airo.c96
1 files changed, 44 insertions, 52 deletions
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index 4069b79d8259..ba737c6cebec 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -19,7 +19,7 @@
19 19
20======================================================================*/ 20======================================================================*/
21 21
22#include <linux/config.h> 22#include <linux/err.h>
23#include <linux/init.h> 23#include <linux/init.h>
24 24
25#include <linux/kernel.h> 25#include <linux/kernel.h>
@@ -48,6 +48,7 @@
48#include <linux/pci.h> 48#include <linux/pci.h>
49#include <asm/uaccess.h> 49#include <asm/uaccess.h>
50#include <net/ieee80211.h> 50#include <net/ieee80211.h>
51#include <linux/kthread.h>
51 52
52#include "airo.h" 53#include "airo.h"
53 54
@@ -1188,11 +1189,10 @@ struct airo_info {
1188 int whichbap); 1189 int whichbap);
1189 unsigned short *flash; 1190 unsigned short *flash;
1190 tdsRssiEntry *rssi; 1191 tdsRssiEntry *rssi;
1191 struct task_struct *task; 1192 struct task_struct *list_bss_task;
1193 struct task_struct *airo_thread_task;
1192 struct semaphore sem; 1194 struct semaphore sem;
1193 pid_t thr_pid;
1194 wait_queue_head_t thr_wait; 1195 wait_queue_head_t thr_wait;
1195 struct completion thr_exited;
1196 unsigned long expires; 1196 unsigned long expires;
1197 struct { 1197 struct {
1198 struct sk_buff *skb; 1198 struct sk_buff *skb;
@@ -1204,7 +1204,7 @@ struct airo_info {
1204 struct iw_spy_data spy_data; 1204 struct iw_spy_data spy_data;
1205 struct iw_public_data wireless_data; 1205 struct iw_public_data wireless_data;
1206 /* MIC stuff */ 1206 /* MIC stuff */
1207 struct crypto_tfm *tfm; 1207 struct crypto_cipher *tfm;
1208 mic_module mod[2]; 1208 mic_module mod[2];
1209 mic_statistics micstats; 1209 mic_statistics micstats;
1210 HostRxDesc rxfids[MPI_MAX_FIDS]; // rx/tx/config MPI350 descriptors 1210 HostRxDesc rxfids[MPI_MAX_FIDS]; // rx/tx/config MPI350 descriptors
@@ -1272,7 +1272,8 @@ static int flashrestart(struct airo_info *ai,struct net_device *dev);
1272 1272
1273static int RxSeqValid (struct airo_info *ai,miccntx *context,int mcast,u32 micSeq); 1273static int RxSeqValid (struct airo_info *ai,miccntx *context,int mcast,u32 micSeq);
1274static void MoveWindow(miccntx *context, u32 micSeq); 1274static void MoveWindow(miccntx *context, u32 micSeq);
1275static void emmh32_setseed(emmh32_context *context, u8 *pkey, int keylen, struct crypto_tfm *); 1275static void emmh32_setseed(emmh32_context *context, u8 *pkey, int keylen,
1276 struct crypto_cipher *tfm);
1276static void emmh32_init(emmh32_context *context); 1277static void emmh32_init(emmh32_context *context);
1277static void emmh32_update(emmh32_context *context, u8 *pOctets, int len); 1278static void emmh32_update(emmh32_context *context, u8 *pOctets, int len);
1278static void emmh32_final(emmh32_context *context, u8 digest[4]); 1279static void emmh32_final(emmh32_context *context, u8 digest[4]);
@@ -1340,10 +1341,11 @@ static int micsetup(struct airo_info *ai) {
1340 int i; 1341 int i;
1341 1342
1342 if (ai->tfm == NULL) 1343 if (ai->tfm == NULL)
1343 ai->tfm = crypto_alloc_tfm("aes", CRYPTO_TFM_REQ_MAY_SLEEP); 1344 ai->tfm = crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC);
1344 1345
1345 if (ai->tfm == NULL) { 1346 if (IS_ERR(ai->tfm)) {
1346 airo_print_err(ai->dev->name, "failed to load transform for AES"); 1347 airo_print_err(ai->dev->name, "failed to load transform for AES");
1348 ai->tfm = NULL;
1347 return ERROR; 1349 return ERROR;
1348 } 1350 }
1349 1351
@@ -1609,7 +1611,8 @@ static void MoveWindow(miccntx *context, u32 micSeq)
1609static unsigned char aes_counter[16]; 1611static unsigned char aes_counter[16];
1610 1612
1611/* expand the key to fill the MMH coefficient array */ 1613/* expand the key to fill the MMH coefficient array */
1612static void emmh32_setseed(emmh32_context *context, u8 *pkey, int keylen, struct crypto_tfm *tfm) 1614static void emmh32_setseed(emmh32_context *context, u8 *pkey, int keylen,
1615 struct crypto_cipher *tfm)
1613{ 1616{
1614 /* take the keying material, expand if necessary, truncate at 16-bytes */ 1617 /* take the keying material, expand if necessary, truncate at 16-bytes */
1615 /* run through AES counter mode to generate context->coeff[] */ 1618 /* run through AES counter mode to generate context->coeff[] */
@@ -1617,7 +1620,6 @@ static void emmh32_setseed(emmh32_context *context, u8 *pkey, int keylen, struct
1617 int i,j; 1620 int i,j;
1618 u32 counter; 1621 u32 counter;
1619 u8 *cipher, plain[16]; 1622 u8 *cipher, plain[16];
1620 struct scatterlist sg[1];
1621 1623
1622 crypto_cipher_setkey(tfm, pkey, 16); 1624 crypto_cipher_setkey(tfm, pkey, 16);
1623 counter = 0; 1625 counter = 0;
@@ -1628,9 +1630,8 @@ static void emmh32_setseed(emmh32_context *context, u8 *pkey, int keylen, struct
1628 aes_counter[12] = (u8)(counter >> 24); 1630 aes_counter[12] = (u8)(counter >> 24);
1629 counter++; 1631 counter++;
1630 memcpy (plain, aes_counter, 16); 1632 memcpy (plain, aes_counter, 16);
1631 sg_set_buf(sg, plain, 16); 1633 crypto_cipher_encrypt_one(tfm, plain, plain);
1632 crypto_cipher_encrypt(tfm, sg, sg, 16); 1634 cipher = plain;
1633 cipher = kmap(sg->page) + sg->offset;
1634 for (j=0; (j<16) && (i< (sizeof(context->coeff)/sizeof(context->coeff[0]))); ) { 1635 for (j=0; (j<16) && (i< (sizeof(context->coeff)/sizeof(context->coeff[0]))); ) {
1635 context->coeff[i++] = ntohl(*(u32 *)&cipher[j]); 1636 context->coeff[i++] = ntohl(*(u32 *)&cipher[j]);
1636 j += 4; 1637 j += 4;
@@ -1734,12 +1735,12 @@ static int readBSSListRid(struct airo_info *ai, int first,
1734 cmd.cmd=CMD_LISTBSS; 1735 cmd.cmd=CMD_LISTBSS;
1735 if (down_interruptible(&ai->sem)) 1736 if (down_interruptible(&ai->sem))
1736 return -ERESTARTSYS; 1737 return -ERESTARTSYS;
1738 ai->list_bss_task = current;
1737 issuecommand(ai, &cmd, &rsp); 1739 issuecommand(ai, &cmd, &rsp);
1738 up(&ai->sem); 1740 up(&ai->sem);
1739 /* Let the command take effect */ 1741 /* Let the command take effect */
1740 ai->task = current; 1742 schedule_timeout_uninterruptible(3 * HZ);
1741 ssleep(3); 1743 ai->list_bss_task = NULL;
1742 ai->task = NULL;
1743 } 1744 }
1744 rc = PC4500_readrid(ai, first ? ai->bssListFirst : ai->bssListNext, 1745 rc = PC4500_readrid(ai, first ? ai->bssListFirst : ai->bssListNext,
1745 list, ai->bssListRidLen, 1); 1746 list, ai->bssListRidLen, 1);
@@ -2401,8 +2402,7 @@ void stop_airo_card( struct net_device *dev, int freeres )
2401 clear_bit(FLAG_REGISTERED, &ai->flags); 2402 clear_bit(FLAG_REGISTERED, &ai->flags);
2402 } 2403 }
2403 set_bit(JOB_DIE, &ai->jobs); 2404 set_bit(JOB_DIE, &ai->jobs);
2404 kill_proc(ai->thr_pid, SIGTERM, 1); 2405 kthread_stop(ai->airo_thread_task);
2405 wait_for_completion(&ai->thr_exited);
2406 2406
2407 /* 2407 /*
2408 * Clean out tx queue 2408 * Clean out tx queue
@@ -2433,7 +2433,7 @@ void stop_airo_card( struct net_device *dev, int freeres )
2433 ai->shared, ai->shared_dma); 2433 ai->shared, ai->shared_dma);
2434 } 2434 }
2435 } 2435 }
2436 crypto_free_tfm(ai->tfm); 2436 crypto_free_cipher(ai->tfm);
2437 del_airo_dev( dev ); 2437 del_airo_dev( dev );
2438 free_netdev( dev ); 2438 free_netdev( dev );
2439} 2439}
@@ -2812,9 +2812,8 @@ static struct net_device *_init_airo_card( unsigned short irq, int port,
2812 ai->config.len = 0; 2812 ai->config.len = 0;
2813 ai->pci = pci; 2813 ai->pci = pci;
2814 init_waitqueue_head (&ai->thr_wait); 2814 init_waitqueue_head (&ai->thr_wait);
2815 init_completion (&ai->thr_exited); 2815 ai->airo_thread_task = kthread_run(airo_thread, dev, dev->name);
2816 ai->thr_pid = kernel_thread(airo_thread, dev, CLONE_FS | CLONE_FILES); 2816 if (IS_ERR(ai->airo_thread_task))
2817 if (ai->thr_pid < 0)
2818 goto err_out_free; 2817 goto err_out_free;
2819 ai->tfm = NULL; 2818 ai->tfm = NULL;
2820 rc = add_airo_dev( dev ); 2819 rc = add_airo_dev( dev );
@@ -2849,7 +2848,7 @@ static struct net_device *_init_airo_card( unsigned short irq, int port,
2849 reset_card (dev, 1); 2848 reset_card (dev, 1);
2850 msleep(400); 2849 msleep(400);
2851 2850
2852 rc = request_irq( dev->irq, airo_interrupt, SA_SHIRQ, dev->name, dev ); 2851 rc = request_irq( dev->irq, airo_interrupt, IRQF_SHARED, dev->name, dev );
2853 if (rc) { 2852 if (rc) {
2854 airo_print_err(dev->name, "register interrupt %d failed, rc %d", 2853 airo_print_err(dev->name, "register interrupt %d failed, rc %d",
2855 irq, rc); 2854 irq, rc);
@@ -2931,8 +2930,7 @@ err_out_unlink:
2931 del_airo_dev(dev); 2930 del_airo_dev(dev);
2932err_out_thr: 2931err_out_thr:
2933 set_bit(JOB_DIE, &ai->jobs); 2932 set_bit(JOB_DIE, &ai->jobs);
2934 kill_proc(ai->thr_pid, SIGTERM, 1); 2933 kthread_stop(ai->airo_thread_task);
2935 wait_for_completion(&ai->thr_exited);
2936err_out_free: 2934err_out_free:
2937 free_netdev(dev); 2935 free_netdev(dev);
2938 return NULL; 2936 return NULL;
@@ -3064,13 +3062,7 @@ static int airo_thread(void *data) {
3064 struct airo_info *ai = dev->priv; 3062 struct airo_info *ai = dev->priv;
3065 int locked; 3063 int locked;
3066 3064
3067 daemonize("%s", dev->name);
3068 allow_signal(SIGTERM);
3069
3070 while(1) { 3065 while(1) {
3071 if (signal_pending(current))
3072 flush_signals(current);
3073
3074 /* make swsusp happy with our thread */ 3066 /* make swsusp happy with our thread */
3075 try_to_freeze(); 3067 try_to_freeze();
3076 3068
@@ -3098,7 +3090,7 @@ static int airo_thread(void *data) {
3098 set_bit(JOB_AUTOWEP, &ai->jobs); 3090 set_bit(JOB_AUTOWEP, &ai->jobs);
3099 break; 3091 break;
3100 } 3092 }
3101 if (!signal_pending(current)) { 3093 if (!kthread_should_stop()) {
3102 unsigned long wake_at; 3094 unsigned long wake_at;
3103 if (!ai->expires || !ai->scan_timeout) { 3095 if (!ai->expires || !ai->scan_timeout) {
3104 wake_at = max(ai->expires, 3096 wake_at = max(ai->expires,
@@ -3110,7 +3102,7 @@ static int airo_thread(void *data) {
3110 schedule_timeout(wake_at - jiffies); 3102 schedule_timeout(wake_at - jiffies);
3111 continue; 3103 continue;
3112 } 3104 }
3113 } else if (!signal_pending(current)) { 3105 } else if (!kthread_should_stop()) {
3114 schedule(); 3106 schedule();
3115 continue; 3107 continue;
3116 } 3108 }
@@ -3155,7 +3147,8 @@ static int airo_thread(void *data) {
3155 else /* Shouldn't get here, but we make sure to unlock */ 3147 else /* Shouldn't get here, but we make sure to unlock */
3156 up(&ai->sem); 3148 up(&ai->sem);
3157 } 3149 }
3158 complete_and_exit (&ai->thr_exited, 0); 3150
3151 return 0;
3159} 3152}
3160 3153
3161static irqreturn_t airo_interrupt ( int irq, void* dev_id, struct pt_regs *regs) { 3154static irqreturn_t airo_interrupt ( int irq, void* dev_id, struct pt_regs *regs) {
@@ -3236,8 +3229,8 @@ static irqreturn_t airo_interrupt ( int irq, void* dev_id, struct pt_regs *regs)
3236 if(newStatus == ASSOCIATED || newStatus == REASSOCIATED) { 3229 if(newStatus == ASSOCIATED || newStatus == REASSOCIATED) {
3237 if (auto_wep) 3230 if (auto_wep)
3238 apriv->expires = 0; 3231 apriv->expires = 0;
3239 if (apriv->task) 3232 if (apriv->list_bss_task)
3240 wake_up_process (apriv->task); 3233 wake_up_process(apriv->list_bss_task);
3241 set_bit(FLAG_UPDATE_UNI, &apriv->flags); 3234 set_bit(FLAG_UPDATE_UNI, &apriv->flags);
3242 set_bit(FLAG_UPDATE_MULTI, &apriv->flags); 3235 set_bit(FLAG_UPDATE_MULTI, &apriv->flags);
3243 3236
@@ -3951,13 +3944,11 @@ static u16 issuecommand(struct airo_info *ai, Cmd *pCmd, Resp *pRsp) {
3951 pRsp->rsp0 = IN4500(ai, RESP0); 3944 pRsp->rsp0 = IN4500(ai, RESP0);
3952 pRsp->rsp1 = IN4500(ai, RESP1); 3945 pRsp->rsp1 = IN4500(ai, RESP1);
3953 pRsp->rsp2 = IN4500(ai, RESP2); 3946 pRsp->rsp2 = IN4500(ai, RESP2);
3954 if ((pRsp->status & 0xff00)!=0 && pCmd->cmd != CMD_SOFTRESET) { 3947 if ((pRsp->status & 0xff00)!=0 && pCmd->cmd != CMD_SOFTRESET)
3955 airo_print_err(ai->dev->name, "cmd= %x\n", pCmd->cmd); 3948 airo_print_err(ai->dev->name,
3956 airo_print_err(ai->dev->name, "status= %x\n", pRsp->status); 3949 "cmd:%x status:%x rsp0:%x rsp1:%x rsp2:%x",
3957 airo_print_err(ai->dev->name, "Rsp0= %x\n", pRsp->rsp0); 3950 pCmd->cmd, pRsp->status, pRsp->rsp0, pRsp->rsp1,
3958 airo_print_err(ai->dev->name, "Rsp1= %x\n", pRsp->rsp1); 3951 pRsp->rsp2);
3959 airo_print_err(ai->dev->name, "Rsp2= %x\n", pRsp->rsp2);
3960 }
3961 3952
3962 // clear stuck command busy if necessary 3953 // clear stuck command busy if necessary
3963 if (IN4500(ai, COMMAND) & COMMAND_BUSY) { 3954 if (IN4500(ai, COMMAND) & COMMAND_BUSY) {
@@ -5877,7 +5868,7 @@ static int airo_set_essid(struct net_device *dev,
5877 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1; 5868 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
5878 5869
5879 /* Check the size of the string */ 5870 /* Check the size of the string */
5880 if(dwrq->length > IW_ESSID_MAX_SIZE+1) { 5871 if(dwrq->length > IW_ESSID_MAX_SIZE) {
5881 return -E2BIG ; 5872 return -E2BIG ;
5882 } 5873 }
5883 /* Check if index is valid */ 5874 /* Check if index is valid */
@@ -5889,7 +5880,7 @@ static int airo_set_essid(struct net_device *dev,
5889 memset(SSID_rid.ssids[index].ssid, 0, 5880 memset(SSID_rid.ssids[index].ssid, 0,
5890 sizeof(SSID_rid.ssids[index].ssid)); 5881 sizeof(SSID_rid.ssids[index].ssid));
5891 memcpy(SSID_rid.ssids[index].ssid, extra, dwrq->length); 5882 memcpy(SSID_rid.ssids[index].ssid, extra, dwrq->length);
5892 SSID_rid.ssids[index].len = dwrq->length - 1; 5883 SSID_rid.ssids[index].len = dwrq->length;
5893 } 5884 }
5894 SSID_rid.len = sizeof(SSID_rid); 5885 SSID_rid.len = sizeof(SSID_rid);
5895 /* Write it to the card */ 5886 /* Write it to the card */
@@ -5999,7 +5990,7 @@ static int airo_set_nick(struct net_device *dev,
5999 struct airo_info *local = dev->priv; 5990 struct airo_info *local = dev->priv;
6000 5991
6001 /* Check the size of the string */ 5992 /* Check the size of the string */
6002 if(dwrq->length > 16 + 1) { 5993 if(dwrq->length > 16) {
6003 return -E2BIG; 5994 return -E2BIG;
6004 } 5995 }
6005 readConfigRid(local, 1); 5996 readConfigRid(local, 1);
@@ -6024,7 +6015,7 @@ static int airo_get_nick(struct net_device *dev,
6024 readConfigRid(local, 1); 6015 readConfigRid(local, 1);
6025 strncpy(extra, local->config.nodeName, 16); 6016 strncpy(extra, local->config.nodeName, 16);
6026 extra[16] = '\0'; 6017 extra[16] = '\0';
6027 dwrq->length = strlen(extra) + 1; 6018 dwrq->length = strlen(extra);
6028 6019
6029 return 0; 6020 return 0;
6030} 6021}
@@ -6776,9 +6767,9 @@ static int airo_set_retry(struct net_device *dev,
6776 } 6767 }
6777 readConfigRid(local, 1); 6768 readConfigRid(local, 1);
6778 if(vwrq->flags & IW_RETRY_LIMIT) { 6769 if(vwrq->flags & IW_RETRY_LIMIT) {
6779 if(vwrq->flags & IW_RETRY_MAX) 6770 if(vwrq->flags & IW_RETRY_LONG)
6780 local->config.longRetryLimit = vwrq->value; 6771 local->config.longRetryLimit = vwrq->value;
6781 else if (vwrq->flags & IW_RETRY_MIN) 6772 else if (vwrq->flags & IW_RETRY_SHORT)
6782 local->config.shortRetryLimit = vwrq->value; 6773 local->config.shortRetryLimit = vwrq->value;
6783 else { 6774 else {
6784 /* No modifier : set both */ 6775 /* No modifier : set both */
@@ -6814,14 +6805,14 @@ static int airo_get_retry(struct net_device *dev,
6814 if((vwrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) { 6805 if((vwrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) {
6815 vwrq->flags = IW_RETRY_LIFETIME; 6806 vwrq->flags = IW_RETRY_LIFETIME;
6816 vwrq->value = (int)local->config.txLifetime * 1024; 6807 vwrq->value = (int)local->config.txLifetime * 1024;
6817 } else if((vwrq->flags & IW_RETRY_MAX)) { 6808 } else if((vwrq->flags & IW_RETRY_LONG)) {
6818 vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_MAX; 6809 vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
6819 vwrq->value = (int)local->config.longRetryLimit; 6810 vwrq->value = (int)local->config.longRetryLimit;
6820 } else { 6811 } else {
6821 vwrq->flags = IW_RETRY_LIMIT; 6812 vwrq->flags = IW_RETRY_LIMIT;
6822 vwrq->value = (int)local->config.shortRetryLimit; 6813 vwrq->value = (int)local->config.shortRetryLimit;
6823 if((int)local->config.shortRetryLimit != (int)local->config.longRetryLimit) 6814 if((int)local->config.shortRetryLimit != (int)local->config.longRetryLimit)
6824 vwrq->flags |= IW_RETRY_MIN; 6815 vwrq->flags |= IW_RETRY_SHORT;
6825 } 6816 }
6826 6817
6827 return 0; 6818 return 0;
@@ -6999,6 +6990,7 @@ static int airo_set_power(struct net_device *dev,
6999 local->config.rmode |= RXMODE_BC_MC_ADDR; 6990 local->config.rmode |= RXMODE_BC_MC_ADDR;
7000 set_bit (FLAG_COMMIT, &local->flags); 6991 set_bit (FLAG_COMMIT, &local->flags);
7001 case IW_POWER_ON: 6992 case IW_POWER_ON:
6993 /* This is broken, fixme ;-) */
7002 break; 6994 break;
7003 default: 6995 default:
7004 return -EINVAL; 6996 return -EINVAL;