2 * PS3 gelic network driver.
4 * Copyright (C) 2007 Sony Computer Entertainment Inc.
5 * Copyright 2007 Sony Corporation
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2
9 * as published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include <linux/kernel.h>
23 #include <linux/module.h>
25 #include <linux/etherdevice.h>
26 #include <linux/ethtool.h>
27 #include <linux/if_vlan.h>
31 #include <linux/tcp.h>
32 #include <linux/wireless.h>
33 #include <linux/ctype.h>
34 #include <linux/string.h>
35 #include <net/iw_handler.h>
36 #include <net/ieee80211.h>
38 #include <linux/dma-mapping.h>
39 #include <net/checksum.h>
40 #include <asm/firmware.h>
42 #include <asm/lv1call.h>
44 #include "ps3_gelic_net.h"
45 #include "ps3_gelic_wireless.h"
48 static int gelic_wl_start_scan(struct gelic_wl_info
*wl
, int always_scan
,
49 u8
*essid
, size_t essid_len
);
50 static int gelic_wl_try_associate(struct net_device
*netdev
);
56 /* 802.11b/g channel to freq in MHz */
57 static const int channel_freq
[] = {
58 2412, 2417, 2422, 2427, 2432,
59 2437, 2442, 2447, 2452, 2457,
60 2462, 2467, 2472, 2484
62 #define NUM_CHANNELS ARRAY_SIZE(channel_freq)
65 static const int bitrate_list
[] = {
79 #define NUM_BITRATES ARRAY_SIZE(bitrate_list)
82 * wpa2 support requires the hypervisor version 2.0 or later
84 static inline int wpa2_capable(void)
86 return (0 <= ps3_compare_firmware_version(2, 0, 0));
89 static inline int precise_ie(void)
91 return (0 <= ps3_compare_firmware_version(2, 2, 0));
94 * post_eurus_cmd helpers
96 struct eurus_cmd_arg_info
{
97 int pre_arg
; /* command requres arg1, arg2 at POST COMMAND */
98 int post_arg
; /* command requires arg1, arg2 at GET_RESULT */
101 static const struct eurus_cmd_arg_info cmd_info
[GELIC_EURUS_CMD_MAX_INDEX
] = {
102 [GELIC_EURUS_CMD_SET_COMMON_CFG
] = { .pre_arg
= 1},
103 [GELIC_EURUS_CMD_SET_WEP_CFG
] = { .pre_arg
= 1},
104 [GELIC_EURUS_CMD_SET_WPA_CFG
] = { .pre_arg
= 1},
105 [GELIC_EURUS_CMD_GET_COMMON_CFG
] = { .post_arg
= 1},
106 [GELIC_EURUS_CMD_GET_WEP_CFG
] = { .post_arg
= 1},
107 [GELIC_EURUS_CMD_GET_WPA_CFG
] = { .post_arg
= 1},
108 [GELIC_EURUS_CMD_GET_RSSI_CFG
] = { .post_arg
= 1},
109 [GELIC_EURUS_CMD_START_SCAN
] = { .pre_arg
= 1},
110 [GELIC_EURUS_CMD_GET_SCAN
] = { .post_arg
= 1},
114 static const char *cmdstr(enum gelic_eurus_command ix
)
117 case GELIC_EURUS_CMD_ASSOC
:
119 case GELIC_EURUS_CMD_DISASSOC
:
121 case GELIC_EURUS_CMD_START_SCAN
:
123 case GELIC_EURUS_CMD_GET_SCAN
:
125 case GELIC_EURUS_CMD_SET_COMMON_CFG
:
126 return "SET_COMMON_CFG";
127 case GELIC_EURUS_CMD_GET_COMMON_CFG
:
128 return "GET_COMMON_CFG";
129 case GELIC_EURUS_CMD_SET_WEP_CFG
:
130 return "SET_WEP_CFG";
131 case GELIC_EURUS_CMD_GET_WEP_CFG
:
132 return "GET_WEP_CFG";
133 case GELIC_EURUS_CMD_SET_WPA_CFG
:
134 return "SET_WPA_CFG";
135 case GELIC_EURUS_CMD_GET_WPA_CFG
:
136 return "GET_WPA_CFG";
137 case GELIC_EURUS_CMD_GET_RSSI_CFG
:
145 static inline const char *cmdstr(enum gelic_eurus_command ix
)
151 /* synchronously do eurus commands */
152 static void gelic_eurus_sync_cmd_worker(struct work_struct
*work
)
154 struct gelic_eurus_cmd
*cmd
;
155 struct gelic_card
*card
;
156 struct gelic_wl_info
*wl
;
160 pr_debug("%s: <-\n", __func__
);
161 cmd
= container_of(work
, struct gelic_eurus_cmd
, work
);
162 BUG_ON(cmd_info
[cmd
->cmd
].pre_arg
&&
163 cmd_info
[cmd
->cmd
].post_arg
);
165 card
= port_to_card(wl_port(wl
));
167 if (cmd_info
[cmd
->cmd
].pre_arg
) {
168 arg1
= (cmd
->buffer
) ?
169 ps3_mm_phys_to_lpar(__pa(cmd
->buffer
)) :
171 arg2
= cmd
->buf_size
;
176 init_completion(&wl
->cmd_done_intr
);
177 pr_debug("%s: cmd='%s' start\n", __func__
, cmdstr(cmd
->cmd
));
178 cmd
->status
= lv1_net_control(bus_id(card
), dev_id(card
),
179 GELIC_LV1_POST_WLAN_CMD
,
180 cmd
->cmd
, arg1
, arg2
,
181 &cmd
->tag
, &cmd
->size
);
183 complete(&cmd
->done
);
184 pr_info("%s: cmd issue failed\n", __func__
);
188 wait_for_completion(&wl
->cmd_done_intr
);
190 if (cmd_info
[cmd
->cmd
].post_arg
) {
191 arg1
= ps3_mm_phys_to_lpar(__pa(cmd
->buffer
));
192 arg2
= cmd
->buf_size
;
198 cmd
->status
= lv1_net_control(bus_id(card
), dev_id(card
),
199 GELIC_LV1_GET_WLAN_CMD_RESULT
,
200 cmd
->tag
, arg1
, arg2
,
201 &cmd
->cmd_status
, &cmd
->size
);
203 if (cmd
->status
|| cmd
->cmd_status
) {
204 pr_debug("%s: cmd done tag=%#lx arg1=%#lx, arg2=%#lx\n", __func__
,
205 cmd
->tag
, arg1
, arg2
);
206 pr_debug("%s: cmd done status=%#x cmd_status=%#lx size=%#lx\n",
207 __func__
, cmd
->status
, cmd
->cmd_status
, cmd
->size
);
210 complete(&cmd
->done
);
211 pr_debug("%s: cmd='%s' done\n", __func__
, cmdstr(cmd
->cmd
));
214 static struct gelic_eurus_cmd
*gelic_eurus_sync_cmd(struct gelic_wl_info
*wl
,
215 unsigned int eurus_cmd
,
217 unsigned int buf_size
)
219 struct gelic_eurus_cmd
*cmd
;
222 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
226 /* initialize members */
227 cmd
->cmd
= eurus_cmd
;
228 cmd
->buffer
= buffer
;
229 cmd
->buf_size
= buf_size
;
231 INIT_WORK(&cmd
->work
, gelic_eurus_sync_cmd_worker
);
232 init_completion(&cmd
->done
);
233 queue_work(wl
->eurus_cmd_queue
, &cmd
->work
);
235 /* wait for command completion */
236 wait_for_completion(&cmd
->done
);
241 static u32
gelic_wl_get_link(struct net_device
*netdev
)
243 struct gelic_wl_info
*wl
= port_wl(netdev_port(netdev
));
246 pr_debug("%s: <-\n", __func__
);
247 mutex_lock(&wl
->assoc_stat_lock
);
248 if (wl
->assoc_stat
== GELIC_WL_ASSOC_STAT_ASSOCIATED
)
252 mutex_unlock(&wl
->assoc_stat_lock
);
253 pr_debug("%s: ->\n", __func__
);
257 static void gelic_wl_send_iwap_event(struct gelic_wl_info
*wl
, u8
*bssid
)
259 union iwreq_data data
;
261 memset(&data
, 0, sizeof(data
));
263 memcpy(data
.ap_addr
.sa_data
, bssid
, ETH_ALEN
);
264 data
.ap_addr
.sa_family
= ARPHRD_ETHER
;
265 wireless_send_event(port_to_netdev(wl_port(wl
)), SIOCGIWAP
,
270 * wireless extension handlers and helpers
274 static int gelic_wl_get_name(struct net_device
*dev
,
275 struct iw_request_info
*info
,
276 union iwreq_data
*iwreq
, char *extra
)
278 strcpy(iwreq
->name
, "IEEE 802.11bg");
282 static void gelic_wl_get_ch_info(struct gelic_wl_info
*wl
)
284 struct gelic_card
*card
= port_to_card(wl_port(wl
));
285 u64 ch_info_raw
, tmp
;
288 if (!test_and_set_bit(GELIC_WL_STAT_CH_INFO
, &wl
->stat
)) {
289 status
= lv1_net_control(bus_id(card
), dev_id(card
),
290 GELIC_LV1_GET_CHANNEL
, 0, 0, 0,
293 /* some fw versions may return error */
295 if (status
!= LV1_NO_ENTRY
)
296 pr_info("%s: available ch unknown\n", __func__
);
297 wl
->ch_info
= 0x07ff;/* 11 ch */
299 /* 16 bits of MSB has available channels */
300 wl
->ch_info
= ch_info_raw
>> 48;
306 static int gelic_wl_get_range(struct net_device
*netdev
,
307 struct iw_request_info
*info
,
308 union iwreq_data
*iwreq
, char *extra
)
310 struct iw_point
*point
= &iwreq
->data
;
311 struct iw_range
*range
= (struct iw_range
*)extra
;
312 struct gelic_wl_info
*wl
= port_wl(netdev_port(netdev
));
315 pr_debug("%s: <-\n", __func__
);
316 point
->length
= sizeof(struct iw_range
);
317 memset(range
, 0, sizeof(struct iw_range
));
319 range
->we_version_compiled
= WIRELESS_EXT
;
320 range
->we_version_source
= 22;
322 /* available channels and frequencies */
323 gelic_wl_get_ch_info(wl
);
326 i
< NUM_CHANNELS
&& chs
< IW_MAX_FREQUENCIES
; i
++)
327 if (wl
->ch_info
& (1 << i
)) {
328 range
->freq
[chs
].i
= i
+ 1;
329 range
->freq
[chs
].m
= channel_freq
[i
];
330 range
->freq
[chs
].e
= 6;
333 range
->num_frequency
= chs
;
334 range
->old_num_frequency
= chs
;
335 range
->num_channels
= chs
;
336 range
->old_num_channels
= chs
;
339 for (i
= 0; i
< NUM_BITRATES
; i
++)
340 range
->bitrate
[i
] = bitrate_list
[i
];
341 range
->num_bitrates
= i
;
344 range
->max_qual
.qual
= 100; /* relative value */
345 range
->max_qual
.level
= 100;
346 range
->avg_qual
.qual
= 50;
347 range
->avg_qual
.level
= 50;
348 range
->sensitivity
= 0;
350 /* Event capability */
351 IW_EVENT_CAPA_SET_KERNEL(range
->event_capa
);
352 IW_EVENT_CAPA_SET(range
->event_capa
, SIOCGIWAP
);
353 IW_EVENT_CAPA_SET(range
->event_capa
, SIOCGIWSCAN
);
355 /* encryption capability */
356 range
->enc_capa
= IW_ENC_CAPA_WPA
|
357 IW_ENC_CAPA_CIPHER_TKIP
| IW_ENC_CAPA_CIPHER_CCMP
|
358 IW_ENC_CAPA_4WAY_HANDSHAKE
;
360 range
->enc_capa
|= IW_ENC_CAPA_WPA2
;
361 range
->encoding_size
[0] = 5; /* 40bit WEP */
362 range
->encoding_size
[1] = 13; /* 104bit WEP */
363 range
->encoding_size
[2] = 32; /* WPA-PSK */
364 range
->num_encoding_sizes
= 3;
365 range
->max_encoding_tokens
= GELIC_WEP_KEYS
;
367 /* scan capability */
368 range
->scan_capa
= IW_SCAN_CAPA_ESSID
;
370 pr_debug("%s: ->\n", __func__
);
375 /* SIOC{G,S}IWSCAN */
376 static int gelic_wl_set_scan(struct net_device
*netdev
,
377 struct iw_request_info
*info
,
378 union iwreq_data
*wrqu
, char *extra
)
380 struct gelic_wl_info
*wl
= port_wl(netdev_priv(netdev
));
381 struct iw_scan_req
*req
;
383 size_t essid_len
= 0;
385 if (wrqu
->data
.length
== sizeof(struct iw_scan_req
) &&
386 wrqu
->data
.flags
& IW_SCAN_THIS_ESSID
) {
387 req
= (struct iw_scan_req
*)extra
;
389 essid_len
= req
->essid_len
;
390 pr_debug("%s: ESSID scan =%s\n", __func__
, essid
);
392 return gelic_wl_start_scan(wl
, 1, essid
, essid_len
);
396 static const u8 rsn_oui
[OUI_LEN
] = { 0x00, 0x0f, 0xac };
397 static const u8 wpa_oui
[OUI_LEN
] = { 0x00, 0x50, 0xf2 };
400 * synthesize WPA/RSN IE data
401 * See WiFi WPA specification and IEEE 802.11-2007 7.3.2.25
404 static size_t gelic_wl_synthesize_ie(u8
*buf
,
405 struct gelic_eurus_scan_info
*scan
)
408 const u8
*oui_header
;
413 pr_debug("%s: <- sec=%16x\n", __func__
, scan
->security
);
414 switch (be16_to_cpu(scan
->security
) & GELIC_EURUS_SCAN_SEC_MASK
) {
415 case GELIC_EURUS_SCAN_SEC_WPA
:
418 case GELIC_EURUS_SCAN_SEC_WPA2
:
422 /* WEP or none. No IE returned */
426 switch (be16_to_cpu(scan
->security
) & GELIC_EURUS_SCAN_SEC_WPA_MASK
) {
427 case GELIC_EURUS_SCAN_SEC_WPA_TKIP
:
430 case GELIC_EURUS_SCAN_SEC_WPA_AES
:
436 pr_info("%s: no cipher info. defaulted to CCMP\n",
440 pr_info("%s: no cipher info. defaulted to TKIP\n",
446 oui_header
= rsn_oui
;
448 oui_header
= wpa_oui
;
452 *buf
++ = MFIE_TYPE_RSN
;
454 *buf
++ = MFIE_TYPE_GENERIC
;
456 /* length filed; set later */
459 /* wpa special header */
461 memcpy(buf
, wpa_oui
, OUI_LEN
);
467 *buf
++ = 0x01; /* version 1.0 */
471 memcpy(buf
, oui_header
, OUI_LEN
);
475 *buf
++ = 0x04; /* CCMP */
477 *buf
++ = 0x02; /* TKIP */
479 /* pairwise key count always 1 */
483 /* pairwise key suit */
484 memcpy(buf
, oui_header
, OUI_LEN
);
487 *buf
++ = 0x04; /* CCMP */
489 *buf
++ = 0x02; /* TKIP */
495 /* AKM suite is assumed as PSK*/
496 memcpy(buf
, oui_header
, OUI_LEN
);
498 *buf
++ = 0x02; /* PSK */
500 /* RSN capabilities is 0 */
504 /* set length field */
505 start
[1] = (buf
- start
- 2);
507 pr_debug("%s: ->\n", __func__
);
508 return (buf
- start
);
521 static void gelic_wl_parse_ie(u8
*data
, size_t len
,
522 struct ie_info
*ie_info
)
524 size_t data_left
= len
;
529 pr_debug("%s: data=%p len=%ld \n", __func__
,
531 memset(ie_info
, 0, sizeof(struct ie_info
));
533 while (2 <= data_left
) {
538 if (data_left
< item_len
)
542 case MFIE_TYPE_GENERIC
:
543 if ((OUI_LEN
+ 1 <= item_len
) &&
544 !memcmp(pos
, wpa_oui
, OUI_LEN
) &&
545 pos
[OUI_LEN
] == 0x01) {
546 ie_info
->wpa
.data
= pos
- 2;
547 ie_info
->wpa
.len
= item_len
+ 2;
551 ie_info
->rsn
.data
= pos
- 2;
552 /* length includes the header */
553 ie_info
->rsn
.len
= item_len
+ 2;
556 pr_debug("%s: ignore %#x,%d\n", __func__
,
561 data_left
-= item_len
;
563 pr_debug("%s: wpa=%p,%d wpa2=%p,%d\n", __func__
,
564 ie_info
->wpa
.data
, ie_info
->wpa
.len
,
565 ie_info
->rsn
.data
, ie_info
->rsn
.len
);
570 * translate the scan informations from hypervisor to a
573 static char *gelic_wl_translate_scan(struct net_device
*netdev
,
574 struct iw_request_info
*info
,
577 struct gelic_wl_scan_info
*network
)
580 struct gelic_eurus_scan_info
*scan
= network
->hwinfo
;
583 unsigned int i
, j
, len
;
584 u8 buf
[MAX_WPA_IE_LEN
];
586 pr_debug("%s: <-\n", __func__
);
588 /* first entry should be AP's mac address */
590 iwe
.u
.ap_addr
.sa_family
= ARPHRD_ETHER
;
591 memcpy(iwe
.u
.ap_addr
.sa_data
, &scan
->bssid
[2], ETH_ALEN
);
592 ev
= iwe_stream_add_event(info
, ev
, stop
, &iwe
, IW_EV_ADDR_LEN
);
595 iwe
.cmd
= SIOCGIWESSID
;
596 iwe
.u
.data
.flags
= 1;
597 iwe
.u
.data
.length
= strnlen(scan
->essid
, 32);
598 ev
= iwe_stream_add_point(info
, ev
, stop
, &iwe
, scan
->essid
);
601 iwe
.cmd
= SIOCGIWFREQ
;
602 iwe
.u
.freq
.m
= be16_to_cpu(scan
->channel
);
603 iwe
.u
.freq
.e
= 0; /* table value in MHz */
605 ev
= iwe_stream_add_event(info
, ev
, stop
, &iwe
, IW_EV_FREQ_LEN
);
608 iwe
.cmd
= SIOCGIWRATE
;
609 iwe
.u
.bitrate
.fixed
= iwe
.u
.bitrate
.disabled
= 0;
610 /* to stuff multiple values in one event */
611 tmp
= ev
+ iwe_stream_lcp_len(info
);
612 /* put them in ascendant order (older is first) */
615 pr_debug("%s: rates=%d rate=%d\n", __func__
,
616 network
->rate_len
, network
->rate_ext_len
);
617 while (i
< network
->rate_len
) {
618 if (j
< network
->rate_ext_len
&&
619 ((scan
->ext_rate
[j
] & 0x7f) < (scan
->rate
[i
] & 0x7f)))
620 rate
= scan
->ext_rate
[j
++] & 0x7f;
622 rate
= scan
->rate
[i
++] & 0x7f;
623 iwe
.u
.bitrate
.value
= rate
* 500000; /* 500kbps unit */
624 tmp
= iwe_stream_add_value(info
, ev
, tmp
, stop
, &iwe
,
627 while (j
< network
->rate_ext_len
) {
628 iwe
.u
.bitrate
.value
= (scan
->ext_rate
[j
++] & 0x7f) * 500000;
629 tmp
= iwe_stream_add_value(info
, ev
, tmp
, stop
, &iwe
,
632 /* Check if we added any rate */
633 if (iwe_stream_lcp_len(info
) < (tmp
- ev
))
637 iwe
.cmd
= SIOCGIWENCODE
;
638 if (be16_to_cpu(scan
->capability
) & WLAN_CAPABILITY_PRIVACY
)
639 iwe
.u
.data
.flags
= IW_ENCODE_ENABLED
| IW_ENCODE_NOKEY
;
641 iwe
.u
.data
.flags
= IW_ENCODE_DISABLED
;
642 iwe
.u
.data
.length
= 0;
643 ev
= iwe_stream_add_point(info
, ev
, stop
, &iwe
, scan
->essid
);
646 iwe
.cmd
= SIOCGIWMODE
;
647 if (be16_to_cpu(scan
->capability
) &
648 (WLAN_CAPABILITY_ESS
| WLAN_CAPABILITY_IBSS
)) {
649 if (be16_to_cpu(scan
->capability
) & WLAN_CAPABILITY_ESS
)
650 iwe
.u
.mode
= IW_MODE_MASTER
;
652 iwe
.u
.mode
= IW_MODE_ADHOC
;
653 ev
= iwe_stream_add_event(info
, ev
, stop
, &iwe
, IW_EV_UINT_LEN
);
658 iwe
.u
.qual
.updated
= IW_QUAL_ALL_UPDATED
|
659 IW_QUAL_QUAL_INVALID
| IW_QUAL_NOISE_INVALID
;
660 iwe
.u
.qual
.level
= be16_to_cpu(scan
->rssi
);
661 iwe
.u
.qual
.qual
= be16_to_cpu(scan
->rssi
);
662 iwe
.u
.qual
.noise
= 0;
663 ev
= iwe_stream_add_event(info
, ev
, stop
, &iwe
, IW_EV_QUAL_LEN
);
666 memset(&iwe
, 0, sizeof(iwe
));
667 if (be16_to_cpu(scan
->size
) <= sizeof(*scan
)) {
668 /* If wpa[2] capable station, synthesize IE and put it */
669 len
= gelic_wl_synthesize_ie(buf
, scan
);
672 iwe
.u
.data
.length
= len
;
673 ev
= iwe_stream_add_point(info
, ev
, stop
, &iwe
, buf
);
676 /* this scan info has IE data */
677 struct ie_info ie_info
;
680 data_len
= be16_to_cpu(scan
->size
) - sizeof(*scan
);
682 gelic_wl_parse_ie(scan
->elements
, data_len
, &ie_info
);
684 if (ie_info
.wpa
.len
&& (ie_info
.wpa
.len
<= sizeof(buf
))) {
685 memcpy(buf
, ie_info
.wpa
.data
, ie_info
.wpa
.len
);
687 iwe
.u
.data
.length
= ie_info
.wpa
.len
;
688 ev
= iwe_stream_add_point(info
, ev
, stop
, &iwe
, buf
);
691 if (ie_info
.rsn
.len
&& (ie_info
.rsn
.len
<= sizeof(buf
))) {
692 memset(&iwe
, 0, sizeof(iwe
));
693 memcpy(buf
, ie_info
.rsn
.data
, ie_info
.rsn
.len
);
695 iwe
.u
.data
.length
= ie_info
.rsn
.len
;
696 ev
= iwe_stream_add_point(info
, ev
, stop
, &iwe
, buf
);
700 pr_debug("%s: ->\n", __func__
);
705 static int gelic_wl_get_scan(struct net_device
*netdev
,
706 struct iw_request_info
*info
,
707 union iwreq_data
*wrqu
, char *extra
)
709 struct gelic_wl_info
*wl
= port_wl(netdev_priv(netdev
));
710 struct gelic_wl_scan_info
*scan_info
;
712 char *stop
= ev
+ wrqu
->data
.length
;
714 unsigned long this_time
= jiffies
;
716 pr_debug("%s: <-\n", __func__
);
717 if (mutex_lock_interruptible(&wl
->scan_lock
))
720 switch (wl
->scan_stat
) {
721 case GELIC_WL_SCAN_STAT_SCANNING
:
722 /* If a scan in progress, caller should call me again */
727 case GELIC_WL_SCAN_STAT_INIT
:
728 /* last scan request failed or never issued */
732 case GELIC_WL_SCAN_STAT_GOT_LIST
:
733 /* ok, use current list */
737 list_for_each_entry(scan_info
, &wl
->network_list
, list
) {
738 if (wl
->scan_age
== 0 ||
739 time_after(scan_info
->last_scanned
+ wl
->scan_age
,
741 ev
= gelic_wl_translate_scan(netdev
, info
,
745 pr_debug("%s:entry too old\n", __func__
);
747 if (stop
- ev
<= IW_EV_ADDR_LEN
) {
753 wrqu
->data
.length
= ev
- extra
;
754 wrqu
->data
.flags
= 0;
756 mutex_unlock(&wl
->scan_lock
);
757 pr_debug("%s: -> %d %d\n", __func__
, ret
, wrqu
->data
.length
);
762 static void scan_list_dump(struct gelic_wl_info
*wl
)
764 struct gelic_wl_scan_info
*scan_info
;
768 list_for_each_entry(scan_info
, &wl
->network_list
, list
) {
769 pr_debug("%s: item %d\n", __func__
, i
++);
770 pr_debug("valid=%d eurusindex=%d last=%lx\n",
771 scan_info
->valid
, scan_info
->eurus_index
,
772 scan_info
->last_scanned
);
773 pr_debug("r_len=%d r_ext_len=%d essid_len=%d\n",
774 scan_info
->rate_len
, scan_info
->rate_ext_len
,
775 scan_info
->essid_len
);
777 pr_debug("bssid=%pM\n", &scan_info
->hwinfo
->bssid
[2]);
778 pr_debug("essid=%s\n", scan_info
->hwinfo
->essid
);
783 static int gelic_wl_set_auth(struct net_device
*netdev
,
784 struct iw_request_info
*info
,
785 union iwreq_data
*data
, char *extra
)
787 struct iw_param
*param
= &data
->param
;
788 struct gelic_wl_info
*wl
= port_wl(netdev_port(netdev
));
789 unsigned long irqflag
;
792 pr_debug("%s: <- %d\n", __func__
, param
->flags
& IW_AUTH_INDEX
);
793 spin_lock_irqsave(&wl
->lock
, irqflag
);
794 switch (param
->flags
& IW_AUTH_INDEX
) {
795 case IW_AUTH_WPA_VERSION
:
796 if (param
->value
& IW_AUTH_WPA_VERSION_DISABLED
) {
797 pr_debug("%s: NO WPA selected\n", __func__
);
798 wl
->wpa_level
= GELIC_WL_WPA_LEVEL_NONE
;
799 wl
->group_cipher_method
= GELIC_WL_CIPHER_WEP
;
800 wl
->pairwise_cipher_method
= GELIC_WL_CIPHER_WEP
;
802 if (param
->value
& IW_AUTH_WPA_VERSION_WPA
) {
803 pr_debug("%s: WPA version 1 selected\n", __func__
);
804 wl
->wpa_level
= GELIC_WL_WPA_LEVEL_WPA
;
805 wl
->group_cipher_method
= GELIC_WL_CIPHER_TKIP
;
806 wl
->pairwise_cipher_method
= GELIC_WL_CIPHER_TKIP
;
807 wl
->auth_method
= GELIC_EURUS_AUTH_OPEN
;
809 if (param
->value
& IW_AUTH_WPA_VERSION_WPA2
) {
811 * As the hypervisor may not tell the cipher
812 * information of the AP if it is WPA2,
813 * you will not decide suitable cipher from
815 * You should have knowledge about the AP's
816 * cipher infomation in other method prior to
820 pr_info("%s: WPA2 may not work\n", __func__
);
821 if (wpa2_capable()) {
822 wl
->wpa_level
= GELIC_WL_WPA_LEVEL_WPA2
;
823 wl
->group_cipher_method
= GELIC_WL_CIPHER_AES
;
824 wl
->pairwise_cipher_method
=
826 wl
->auth_method
= GELIC_EURUS_AUTH_OPEN
;
832 case IW_AUTH_CIPHER_PAIRWISE
:
834 (IW_AUTH_CIPHER_WEP104
| IW_AUTH_CIPHER_WEP40
)) {
835 pr_debug("%s: WEP selected\n", __func__
);
836 wl
->pairwise_cipher_method
= GELIC_WL_CIPHER_WEP
;
838 if (param
->value
& IW_AUTH_CIPHER_TKIP
) {
839 pr_debug("%s: TKIP selected\n", __func__
);
840 wl
->pairwise_cipher_method
= GELIC_WL_CIPHER_TKIP
;
842 if (param
->value
& IW_AUTH_CIPHER_CCMP
) {
843 pr_debug("%s: CCMP selected\n", __func__
);
844 wl
->pairwise_cipher_method
= GELIC_WL_CIPHER_AES
;
846 if (param
->value
& IW_AUTH_CIPHER_NONE
) {
847 pr_debug("%s: no auth selected\n", __func__
);
848 wl
->pairwise_cipher_method
= GELIC_WL_CIPHER_NONE
;
851 case IW_AUTH_CIPHER_GROUP
:
853 (IW_AUTH_CIPHER_WEP104
| IW_AUTH_CIPHER_WEP40
)) {
854 pr_debug("%s: WEP selected\n", __func__
);
855 wl
->group_cipher_method
= GELIC_WL_CIPHER_WEP
;
857 if (param
->value
& IW_AUTH_CIPHER_TKIP
) {
858 pr_debug("%s: TKIP selected\n", __func__
);
859 wl
->group_cipher_method
= GELIC_WL_CIPHER_TKIP
;
861 if (param
->value
& IW_AUTH_CIPHER_CCMP
) {
862 pr_debug("%s: CCMP selected\n", __func__
);
863 wl
->group_cipher_method
= GELIC_WL_CIPHER_AES
;
865 if (param
->value
& IW_AUTH_CIPHER_NONE
) {
866 pr_debug("%s: no auth selected\n", __func__
);
867 wl
->group_cipher_method
= GELIC_WL_CIPHER_NONE
;
870 case IW_AUTH_80211_AUTH_ALG
:
871 if (param
->value
& IW_AUTH_ALG_SHARED_KEY
) {
872 pr_debug("%s: shared key specified\n", __func__
);
873 wl
->auth_method
= GELIC_EURUS_AUTH_SHARED
;
874 } else if (param
->value
& IW_AUTH_ALG_OPEN_SYSTEM
) {
875 pr_debug("%s: open system specified\n", __func__
);
876 wl
->auth_method
= GELIC_EURUS_AUTH_OPEN
;
881 case IW_AUTH_WPA_ENABLED
:
883 pr_debug("%s: WPA enabled\n", __func__
);
884 wl
->wpa_level
= GELIC_WL_WPA_LEVEL_WPA
;
886 pr_debug("%s: WPA disabled\n", __func__
);
887 wl
->wpa_level
= GELIC_WL_WPA_LEVEL_NONE
;
891 case IW_AUTH_KEY_MGMT
:
892 if (param
->value
& IW_AUTH_KEY_MGMT_PSK
)
894 /* intentionally fall through */
901 set_bit(GELIC_WL_STAT_CONFIGURED
, &wl
->stat
);
903 spin_unlock_irqrestore(&wl
->lock
, irqflag
);
904 pr_debug("%s: -> %d\n", __func__
, ret
);
908 static int gelic_wl_get_auth(struct net_device
*netdev
,
909 struct iw_request_info
*info
,
910 union iwreq_data
*iwreq
, char *extra
)
912 struct iw_param
*param
= &iwreq
->param
;
913 struct gelic_wl_info
*wl
= port_wl(netdev_port(netdev
));
914 unsigned long irqflag
;
917 pr_debug("%s: <- %d\n", __func__
, param
->flags
& IW_AUTH_INDEX
);
918 spin_lock_irqsave(&wl
->lock
, irqflag
);
919 switch (param
->flags
& IW_AUTH_INDEX
) {
920 case IW_AUTH_WPA_VERSION
:
921 switch (wl
->wpa_level
) {
922 case GELIC_WL_WPA_LEVEL_WPA
:
923 param
->value
|= IW_AUTH_WPA_VERSION_WPA
;
925 case GELIC_WL_WPA_LEVEL_WPA2
:
926 param
->value
|= IW_AUTH_WPA_VERSION_WPA2
;
929 param
->value
|= IW_AUTH_WPA_VERSION_DISABLED
;
933 case IW_AUTH_80211_AUTH_ALG
:
934 if (wl
->auth_method
== GELIC_EURUS_AUTH_SHARED
)
935 param
->value
= IW_AUTH_ALG_SHARED_KEY
;
936 else if (wl
->auth_method
== GELIC_EURUS_AUTH_OPEN
)
937 param
->value
= IW_AUTH_ALG_OPEN_SYSTEM
;
940 case IW_AUTH_WPA_ENABLED
:
941 switch (wl
->wpa_level
) {
942 case GELIC_WL_WPA_LEVEL_WPA
:
943 case GELIC_WL_WPA_LEVEL_WPA2
:
955 spin_unlock_irqrestore(&wl
->lock
, irqflag
);
956 pr_debug("%s: -> %d\n", __func__
, ret
);
960 /* SIOC{S,G}IWESSID */
961 static int gelic_wl_set_essid(struct net_device
*netdev
,
962 struct iw_request_info
*info
,
963 union iwreq_data
*data
, char *extra
)
965 struct gelic_wl_info
*wl
= port_wl(netdev_priv(netdev
));
966 unsigned long irqflag
;
968 pr_debug("%s: <- l=%d f=%d\n", __func__
,
969 data
->essid
.length
, data
->essid
.flags
);
970 if (IW_ESSID_MAX_SIZE
< data
->essid
.length
)
973 spin_lock_irqsave(&wl
->lock
, irqflag
);
974 if (data
->essid
.flags
) {
975 wl
->essid_len
= data
->essid
.length
;
976 memcpy(wl
->essid
, extra
, wl
->essid_len
);
977 pr_debug("%s: essid = '%s'\n", __func__
, extra
);
978 set_bit(GELIC_WL_STAT_ESSID_SET
, &wl
->stat
);
980 pr_debug("%s: ESSID any \n", __func__
);
981 clear_bit(GELIC_WL_STAT_ESSID_SET
, &wl
->stat
);
983 set_bit(GELIC_WL_STAT_CONFIGURED
, &wl
->stat
);
984 spin_unlock_irqrestore(&wl
->lock
, irqflag
);
987 gelic_wl_try_associate(netdev
); /* FIXME */
988 pr_debug("%s: -> \n", __func__
);
992 static int gelic_wl_get_essid(struct net_device
*netdev
,
993 struct iw_request_info
*info
,
994 union iwreq_data
*data
, char *extra
)
996 struct gelic_wl_info
*wl
= port_wl(netdev_priv(netdev
));
997 unsigned long irqflag
;
999 pr_debug("%s: <- \n", __func__
);
1000 mutex_lock(&wl
->assoc_stat_lock
);
1001 spin_lock_irqsave(&wl
->lock
, irqflag
);
1002 if (test_bit(GELIC_WL_STAT_ESSID_SET
, &wl
->stat
) ||
1003 wl
->assoc_stat
== GELIC_WL_ASSOC_STAT_ASSOCIATED
) {
1004 memcpy(extra
, wl
->essid
, wl
->essid_len
);
1005 data
->essid
.length
= wl
->essid_len
;
1006 data
->essid
.flags
= 1;
1008 data
->essid
.flags
= 0;
1010 mutex_unlock(&wl
->assoc_stat_lock
);
1011 spin_unlock_irqrestore(&wl
->lock
, irqflag
);
1012 pr_debug("%s: -> len=%d \n", __func__
, data
->essid
.length
);
1017 /* SIO{S,G}IWENCODE */
1018 static int gelic_wl_set_encode(struct net_device
*netdev
,
1019 struct iw_request_info
*info
,
1020 union iwreq_data
*data
, char *extra
)
1022 struct gelic_wl_info
*wl
= port_wl(netdev_priv(netdev
));
1023 struct iw_point
*enc
= &data
->encoding
;
1025 unsigned long irqflag
;
1026 int key_index
, index_specified
;
1029 pr_debug("%s: <- \n", __func__
);
1030 flags
= enc
->flags
& IW_ENCODE_FLAGS
;
1031 key_index
= enc
->flags
& IW_ENCODE_INDEX
;
1033 pr_debug("%s: key_index = %d\n", __func__
, key_index
);
1034 pr_debug("%s: key_len = %d\n", __func__
, enc
->length
);
1035 pr_debug("%s: flag=%x\n", __func__
, enc
->flags
& IW_ENCODE_FLAGS
);
1037 if (GELIC_WEP_KEYS
< key_index
)
1040 spin_lock_irqsave(&wl
->lock
, irqflag
);
1042 index_specified
= 1;
1045 index_specified
= 0;
1046 key_index
= wl
->current_key
;
1049 if (flags
& IW_ENCODE_NOKEY
) {
1050 /* if just IW_ENCODE_NOKEY, change current key index */
1051 if (!flags
&& index_specified
) {
1052 wl
->current_key
= key_index
;
1056 if (flags
& IW_ENCODE_DISABLED
) {
1057 if (!index_specified
) {
1058 /* disable encryption */
1059 wl
->group_cipher_method
= GELIC_WL_CIPHER_NONE
;
1060 wl
->pairwise_cipher_method
=
1061 GELIC_WL_CIPHER_NONE
;
1062 /* invalidate all key */
1063 wl
->key_enabled
= 0;
1065 clear_bit(key_index
, &wl
->key_enabled
);
1068 if (flags
& IW_ENCODE_OPEN
)
1069 wl
->auth_method
= GELIC_EURUS_AUTH_OPEN
;
1070 if (flags
& IW_ENCODE_RESTRICTED
) {
1071 pr_info("%s: shared key mode enabled\n", __func__
);
1072 wl
->auth_method
= GELIC_EURUS_AUTH_SHARED
;
1075 if (IW_ENCODING_TOKEN_MAX
< enc
->length
) {
1079 wl
->key_len
[key_index
] = enc
->length
;
1080 memcpy(wl
->key
[key_index
], extra
, enc
->length
);
1081 set_bit(key_index
, &wl
->key_enabled
);
1082 wl
->pairwise_cipher_method
= GELIC_WL_CIPHER_WEP
;
1083 wl
->group_cipher_method
= GELIC_WL_CIPHER_WEP
;
1085 set_bit(GELIC_WL_STAT_CONFIGURED
, &wl
->stat
);
1087 spin_unlock_irqrestore(&wl
->lock
, irqflag
);
1088 pr_debug("%s: -> \n", __func__
);
1092 static int gelic_wl_get_encode(struct net_device
*netdev
,
1093 struct iw_request_info
*info
,
1094 union iwreq_data
*data
, char *extra
)
1096 struct gelic_wl_info
*wl
= port_wl(netdev_priv(netdev
));
1097 struct iw_point
*enc
= &data
->encoding
;
1098 unsigned long irqflag
;
1099 unsigned int key_index
, index_specified
;
1102 pr_debug("%s: <- \n", __func__
);
1103 key_index
= enc
->flags
& IW_ENCODE_INDEX
;
1104 pr_debug("%s: flag=%#x point=%p len=%d extra=%p\n", __func__
,
1105 enc
->flags
, enc
->pointer
, enc
->length
, extra
);
1106 if (GELIC_WEP_KEYS
< key_index
)
1109 spin_lock_irqsave(&wl
->lock
, irqflag
);
1111 index_specified
= 1;
1114 index_specified
= 0;
1115 key_index
= wl
->current_key
;
1118 if (wl
->group_cipher_method
== GELIC_WL_CIPHER_WEP
) {
1119 switch (wl
->auth_method
) {
1120 case GELIC_EURUS_AUTH_OPEN
:
1121 enc
->flags
= IW_ENCODE_OPEN
;
1123 case GELIC_EURUS_AUTH_SHARED
:
1124 enc
->flags
= IW_ENCODE_RESTRICTED
;
1128 enc
->flags
= IW_ENCODE_DISABLED
;
1130 if (test_bit(key_index
, &wl
->key_enabled
)) {
1131 if (enc
->length
< wl
->key_len
[key_index
]) {
1135 enc
->length
= wl
->key_len
[key_index
];
1136 memcpy(extra
, wl
->key
[key_index
], wl
->key_len
[key_index
]);
1139 enc
->flags
|= IW_ENCODE_NOKEY
;
1141 enc
->flags
|= key_index
+ 1;
1142 pr_debug("%s: -> flag=%x len=%d\n", __func__
,
1143 enc
->flags
, enc
->length
);
1146 spin_unlock_irqrestore(&wl
->lock
, irqflag
);
1151 static int gelic_wl_set_ap(struct net_device
*netdev
,
1152 struct iw_request_info
*info
,
1153 union iwreq_data
*data
, char *extra
)
1155 struct gelic_wl_info
*wl
= port_wl(netdev_priv(netdev
));
1156 unsigned long irqflag
;
1158 pr_debug("%s: <-\n", __func__
);
1159 if (data
->ap_addr
.sa_family
!= ARPHRD_ETHER
)
1162 spin_lock_irqsave(&wl
->lock
, irqflag
);
1163 if (is_valid_ether_addr(data
->ap_addr
.sa_data
)) {
1164 memcpy(wl
->bssid
, data
->ap_addr
.sa_data
,
1166 set_bit(GELIC_WL_STAT_BSSID_SET
, &wl
->stat
);
1167 set_bit(GELIC_WL_STAT_CONFIGURED
, &wl
->stat
);
1168 pr_debug("%s: bss=%pM\n", __func__
, wl
->bssid
);
1170 pr_debug("%s: clear bssid\n", __func__
);
1171 clear_bit(GELIC_WL_STAT_BSSID_SET
, &wl
->stat
);
1172 memset(wl
->bssid
, 0, ETH_ALEN
);
1174 spin_unlock_irqrestore(&wl
->lock
, irqflag
);
1175 pr_debug("%s: ->\n", __func__
);
1179 static int gelic_wl_get_ap(struct net_device
*netdev
,
1180 struct iw_request_info
*info
,
1181 union iwreq_data
*data
, char *extra
)
1183 struct gelic_wl_info
*wl
= port_wl(netdev_priv(netdev
));
1184 unsigned long irqflag
;
1186 pr_debug("%s: <-\n", __func__
);
1187 mutex_lock(&wl
->assoc_stat_lock
);
1188 spin_lock_irqsave(&wl
->lock
, irqflag
);
1189 if (wl
->assoc_stat
== GELIC_WL_ASSOC_STAT_ASSOCIATED
) {
1190 data
->ap_addr
.sa_family
= ARPHRD_ETHER
;
1191 memcpy(data
->ap_addr
.sa_data
, wl
->active_bssid
,
1194 memset(data
->ap_addr
.sa_data
, 0, ETH_ALEN
);
1196 spin_unlock_irqrestore(&wl
->lock
, irqflag
);
1197 mutex_unlock(&wl
->assoc_stat_lock
);
1198 pr_debug("%s: ->\n", __func__
);
1202 /* SIOC{S,G}IWENCODEEXT */
1203 static int gelic_wl_set_encodeext(struct net_device
*netdev
,
1204 struct iw_request_info
*info
,
1205 union iwreq_data
*data
, char *extra
)
1207 struct gelic_wl_info
*wl
= port_wl(netdev_priv(netdev
));
1208 struct iw_point
*enc
= &data
->encoding
;
1209 struct iw_encode_ext
*ext
= (struct iw_encode_ext
*)extra
;
1212 unsigned long irqflag
;
1216 pr_debug("%s: <- \n", __func__
);
1217 flags
= enc
->flags
& IW_ENCODE_FLAGS
;
1219 key_index
= enc
->flags
& IW_ENCODE_INDEX
;
1221 pr_debug("%s: key_index = %d\n", __func__
, key_index
);
1222 pr_debug("%s: key_len = %d\n", __func__
, enc
->length
);
1223 pr_debug("%s: flag=%x\n", __func__
, enc
->flags
& IW_ENCODE_FLAGS
);
1224 pr_debug("%s: ext_flag=%x\n", __func__
, ext
->ext_flags
);
1225 pr_debug("%s: ext_key_len=%x\n", __func__
, ext
->key_len
);
1227 if (GELIC_WEP_KEYS
< key_index
)
1230 spin_lock_irqsave(&wl
->lock
, irqflag
);
1234 key_index
= wl
->current_key
;
1236 if (!enc
->length
&& (ext
->ext_flags
& IW_ENCODE_EXT_SET_TX_KEY
)) {
1237 /* reques to change default key index */
1238 pr_debug("%s: request to change default key to %d\n",
1239 __func__
, key_index
);
1240 wl
->current_key
= key_index
;
1244 if (alg
== IW_ENCODE_ALG_NONE
|| (flags
& IW_ENCODE_DISABLED
)) {
1245 pr_debug("%s: alg disabled\n", __func__
);
1246 wl
->wpa_level
= GELIC_WL_WPA_LEVEL_NONE
;
1247 wl
->group_cipher_method
= GELIC_WL_CIPHER_NONE
;
1248 wl
->pairwise_cipher_method
= GELIC_WL_CIPHER_NONE
;
1249 wl
->auth_method
= GELIC_EURUS_AUTH_OPEN
; /* should be open */
1250 } else if (alg
== IW_ENCODE_ALG_WEP
) {
1251 pr_debug("%s: WEP requested\n", __func__
);
1252 if (flags
& IW_ENCODE_OPEN
) {
1253 pr_debug("%s: open key mode\n", __func__
);
1254 wl
->auth_method
= GELIC_EURUS_AUTH_OPEN
;
1256 if (flags
& IW_ENCODE_RESTRICTED
) {
1257 pr_debug("%s: shared key mode\n", __func__
);
1258 wl
->auth_method
= GELIC_EURUS_AUTH_SHARED
;
1260 if (IW_ENCODING_TOKEN_MAX
< ext
->key_len
) {
1261 pr_info("%s: key is too long %d\n", __func__
,
1266 /* OK, update the key */
1267 wl
->key_len
[key_index
] = ext
->key_len
;
1268 memset(wl
->key
[key_index
], 0, IW_ENCODING_TOKEN_MAX
);
1269 memcpy(wl
->key
[key_index
], ext
->key
, ext
->key_len
);
1270 set_bit(key_index
, &wl
->key_enabled
);
1271 /* remember wep info changed */
1272 set_bit(GELIC_WL_STAT_CONFIGURED
, &wl
->stat
);
1273 } else if (alg
== IW_ENCODE_ALG_PMK
) {
1274 if (ext
->key_len
!= WPA_PSK_LEN
) {
1275 pr_err("%s: PSK length wrong %d\n", __func__
,
1280 memset(wl
->psk
, 0, sizeof(wl
->psk
));
1281 memcpy(wl
->psk
, ext
->key
, ext
->key_len
);
1282 wl
->psk_len
= ext
->key_len
;
1283 wl
->psk_type
= GELIC_EURUS_WPA_PSK_BIN
;
1284 /* remember PSK configured */
1285 set_bit(GELIC_WL_STAT_WPA_PSK_SET
, &wl
->stat
);
1288 spin_unlock_irqrestore(&wl
->lock
, irqflag
);
1289 pr_debug("%s: -> \n", __func__
);
1293 static int gelic_wl_get_encodeext(struct net_device
*netdev
,
1294 struct iw_request_info
*info
,
1295 union iwreq_data
*data
, char *extra
)
1297 struct gelic_wl_info
*wl
= port_wl(netdev_priv(netdev
));
1298 struct iw_point
*enc
= &data
->encoding
;
1299 struct iw_encode_ext
*ext
= (struct iw_encode_ext
*)extra
;
1300 unsigned long irqflag
;
1305 pr_debug("%s: <- \n", __func__
);
1307 max_key_len
= enc
->length
- sizeof(struct iw_encode_ext
);
1308 if (max_key_len
< 0)
1310 key_index
= enc
->flags
& IW_ENCODE_INDEX
;
1312 pr_debug("%s: key_index = %d\n", __func__
, key_index
);
1313 pr_debug("%s: key_len = %d\n", __func__
, enc
->length
);
1314 pr_debug("%s: flag=%x\n", __func__
, enc
->flags
& IW_ENCODE_FLAGS
);
1316 if (GELIC_WEP_KEYS
< key_index
)
1319 spin_lock_irqsave(&wl
->lock
, irqflag
);
1323 key_index
= wl
->current_key
;
1325 memset(ext
, 0, sizeof(struct iw_encode_ext
));
1326 switch (wl
->group_cipher_method
) {
1327 case GELIC_WL_CIPHER_WEP
:
1328 ext
->alg
= IW_ENCODE_ALG_WEP
;
1329 enc
->flags
|= IW_ENCODE_ENABLED
;
1331 case GELIC_WL_CIPHER_TKIP
:
1332 ext
->alg
= IW_ENCODE_ALG_TKIP
;
1333 enc
->flags
|= IW_ENCODE_ENABLED
;
1335 case GELIC_WL_CIPHER_AES
:
1336 ext
->alg
= IW_ENCODE_ALG_CCMP
;
1337 enc
->flags
|= IW_ENCODE_ENABLED
;
1339 case GELIC_WL_CIPHER_NONE
:
1341 ext
->alg
= IW_ENCODE_ALG_NONE
;
1342 enc
->flags
|= IW_ENCODE_NOKEY
;
1346 if (!(enc
->flags
& IW_ENCODE_NOKEY
)) {
1347 if (max_key_len
< wl
->key_len
[key_index
]) {
1351 if (test_bit(key_index
, &wl
->key_enabled
))
1352 memcpy(ext
->key
, wl
->key
[key_index
],
1353 wl
->key_len
[key_index
]);
1355 pr_debug("%s: disabled key requested ix=%d\n",
1356 __func__
, key_index
);
1359 spin_unlock_irqrestore(&wl
->lock
, irqflag
);
1360 pr_debug("%s: -> \n", __func__
);
1363 /* SIOC{S,G}IWMODE */
1364 static int gelic_wl_set_mode(struct net_device
*netdev
,
1365 struct iw_request_info
*info
,
1366 union iwreq_data
*data
, char *extra
)
1368 __u32 mode
= data
->mode
;
1371 pr_debug("%s: <- \n", __func__
);
1372 if (mode
== IW_MODE_INFRA
)
1376 pr_debug("%s: -> %d\n", __func__
, ret
);
1380 static int gelic_wl_get_mode(struct net_device
*netdev
,
1381 struct iw_request_info
*info
,
1382 union iwreq_data
*data
, char *extra
)
1384 __u32
*mode
= &data
->mode
;
1385 pr_debug("%s: <- \n", __func__
);
1386 *mode
= IW_MODE_INFRA
;
1387 pr_debug("%s: ->\n", __func__
);
1391 #ifdef CONFIG_GELIC_WIRELESS_OLD_PSK_INTERFACE
1392 /* SIOCIWFIRSTPRIV */
1393 static int hex2bin(u8
*str
, u8
*bin
, unsigned int len
)
1396 static unsigned char *hex
= "0123456789ABCDEF";
1397 unsigned char *p
, *q
;
1400 if (len
!= WPA_PSK_LEN
* 2)
1403 for (i
= 0; i
< WPA_PSK_LEN
* 2; i
+= 2) {
1404 p
= strchr(hex
, toupper(str
[i
]));
1405 q
= strchr(hex
, toupper(str
[i
+ 1]));
1407 pr_info("%s: unconvertible PSK digit=%d\n",
1411 tmp
= ((p
- hex
) << 4) + (q
- hex
);
1417 static int gelic_wl_priv_set_psk(struct net_device
*net_dev
,
1418 struct iw_request_info
*info
,
1419 union iwreq_data
*data
, char *extra
)
1421 struct gelic_wl_info
*wl
= port_wl(netdev_priv(net_dev
));
1423 unsigned long irqflag
;
1426 pr_debug("%s:<- len=%d\n", __func__
, data
->data
.length
);
1427 len
= data
->data
.length
- 1;
1431 spin_lock_irqsave(&wl
->lock
, irqflag
);
1432 if (extra
[0] == '"' && extra
[len
- 1] == '"') {
1433 pr_debug("%s: passphrase mode\n", __func__
);
1435 if (GELIC_WL_EURUS_PSK_MAX_LEN
< (len
- 2)) {
1436 pr_info("%s: passphrase too long\n", __func__
);
1440 memset(wl
->psk
, 0, sizeof(wl
->psk
));
1441 wl
->psk_len
= len
- 2;
1442 memcpy(wl
->psk
, &(extra
[1]), wl
->psk_len
);
1443 wl
->psk_type
= GELIC_EURUS_WPA_PSK_PASSPHRASE
;
1445 ret
= hex2bin(extra
, wl
->psk
, len
);
1448 wl
->psk_len
= WPA_PSK_LEN
;
1449 wl
->psk_type
= GELIC_EURUS_WPA_PSK_BIN
;
1451 set_bit(GELIC_WL_STAT_WPA_PSK_SET
, &wl
->stat
);
1453 spin_unlock_irqrestore(&wl
->lock
, irqflag
);
1454 pr_debug("%s:->\n", __func__
);
1458 static int gelic_wl_priv_get_psk(struct net_device
*net_dev
,
1459 struct iw_request_info
*info
,
1460 union iwreq_data
*data
, char *extra
)
1462 struct gelic_wl_info
*wl
= port_wl(netdev_priv(net_dev
));
1464 unsigned long irqflag
;
1467 pr_debug("%s:<-\n", __func__
);
1468 if (!capable(CAP_NET_ADMIN
))
1471 spin_lock_irqsave(&wl
->lock
, irqflag
);
1473 if (test_bit(GELIC_WL_STAT_WPA_PSK_SET
, &wl
->stat
)) {
1474 if (wl
->psk_type
== GELIC_EURUS_WPA_PSK_BIN
) {
1475 for (i
= 0; i
< wl
->psk_len
; i
++) {
1476 sprintf(p
, "%02xu", wl
->psk
[i
]);
1480 data
->data
.length
= wl
->psk_len
* 2;
1483 memcpy(p
, wl
->psk
, wl
->psk_len
);
1487 data
->data
.length
= wl
->psk_len
+ 2;
1491 data
->data
.length
= 0;
1492 spin_unlock_irqrestore(&wl
->lock
, irqflag
);
1493 pr_debug("%s:-> %d\n", __func__
, data
->data
.length
);
1499 static int gelic_wl_get_nick(struct net_device
*net_dev
,
1500 struct iw_request_info
*info
,
1501 union iwreq_data
*data
, char *extra
)
1503 strcpy(extra
, "gelic_wl");
1504 data
->data
.length
= strlen(extra
);
1505 data
->data
.flags
= 1;
1512 static struct iw_statistics
*gelic_wl_get_wireless_stats(
1513 struct net_device
*netdev
)
1516 struct gelic_wl_info
*wl
= port_wl(netdev_priv(netdev
));
1517 struct gelic_eurus_cmd
*cmd
;
1518 struct iw_statistics
*is
;
1519 struct gelic_eurus_rssi_info
*rssi
;
1522 pr_debug("%s: <-\n", __func__
);
1524 buf
= (void *)__get_free_page(GFP_KERNEL
);
1529 memset(is
, 0, sizeof(*is
));
1530 cmd
= gelic_eurus_sync_cmd(wl
, GELIC_EURUS_CMD_GET_RSSI_CFG
,
1531 buf
, sizeof(*rssi
));
1532 if (cmd
&& !cmd
->status
&& !cmd
->cmd_status
) {
1534 is
->qual
.level
= be16_to_cpu(rssi
->rssi
);
1535 is
->qual
.updated
= IW_QUAL_LEVEL_UPDATED
|
1536 IW_QUAL_QUAL_INVALID
| IW_QUAL_NOISE_INVALID
;
1538 /* not associated */
1539 is
->qual
.updated
= IW_QUAL_ALL_INVALID
;
1542 free_page((unsigned long)buf
);
1543 pr_debug("%s: ->\n", __func__
);
1550 static int gelic_wl_start_scan(struct gelic_wl_info
*wl
, int always_scan
,
1551 u8
*essid
, size_t essid_len
)
1553 struct gelic_eurus_cmd
*cmd
;
1558 pr_debug("%s: <- always=%d\n", __func__
, always_scan
);
1559 if (mutex_lock_interruptible(&wl
->scan_lock
))
1560 return -ERESTARTSYS
;
1563 * If already a scan in progress, do not trigger more
1565 if (wl
->scan_stat
== GELIC_WL_SCAN_STAT_SCANNING
) {
1566 pr_debug("%s: scanning now\n", __func__
);
1570 init_completion(&wl
->scan_done
);
1572 * If we have already a bss list, don't try to get new
1574 if (!always_scan
&& wl
->scan_stat
== GELIC_WL_SCAN_STAT_GOT_LIST
) {
1575 pr_debug("%s: already has the list\n", __func__
);
1576 complete(&wl
->scan_done
);
1581 if (essid_len
&& essid
) {
1582 buf
= (void *)__get_free_page(GFP_KERNEL
);
1587 len
= IW_ESSID_MAX_SIZE
; /* hypervisor always requires 32 */
1588 memset(buf
, 0, len
);
1589 memcpy(buf
, essid
, essid_len
);
1590 pr_debug("%s: essid scan='%s'\n", __func__
, (char *)buf
);
1595 * issue start scan request
1597 wl
->scan_stat
= GELIC_WL_SCAN_STAT_SCANNING
;
1598 cmd
= gelic_eurus_sync_cmd(wl
, GELIC_EURUS_CMD_START_SCAN
,
1600 if (!cmd
|| cmd
->status
|| cmd
->cmd_status
) {
1601 wl
->scan_stat
= GELIC_WL_SCAN_STAT_INIT
;
1602 complete(&wl
->scan_done
);
1608 free_page((unsigned long)buf
);
1609 mutex_unlock(&wl
->scan_lock
);
1610 pr_debug("%s: ->\n", __func__
);
1615 * retrieve scan result from the chip (hypervisor)
1616 * this function is invoked by schedule work.
1618 static void gelic_wl_scan_complete_event(struct gelic_wl_info
*wl
)
1620 struct gelic_eurus_cmd
*cmd
= NULL
;
1621 struct gelic_wl_scan_info
*target
, *tmp
;
1622 struct gelic_wl_scan_info
*oldest
= NULL
;
1623 struct gelic_eurus_scan_info
*scan_info
;
1624 unsigned int scan_info_size
;
1625 union iwreq_data data
;
1626 unsigned long this_time
= jiffies
;
1627 unsigned int data_len
, i
, found
, r
;
1630 pr_debug("%s:start\n", __func__
);
1631 mutex_lock(&wl
->scan_lock
);
1633 buf
= (void *)__get_free_page(GFP_KERNEL
);
1635 pr_info("%s: scan buffer alloc failed\n", __func__
);
1639 if (wl
->scan_stat
!= GELIC_WL_SCAN_STAT_SCANNING
) {
1641 * stop() may be called while scanning, ignore result
1643 pr_debug("%s: scan complete when stat != scanning(%d)\n",
1644 __func__
, wl
->scan_stat
);
1648 cmd
= gelic_eurus_sync_cmd(wl
, GELIC_EURUS_CMD_GET_SCAN
,
1650 if (!cmd
|| cmd
->status
|| cmd
->cmd_status
) {
1651 wl
->scan_stat
= GELIC_WL_SCAN_STAT_INIT
;
1652 pr_info("%s:cmd failed\n", __func__
);
1656 data_len
= cmd
->size
;
1657 pr_debug("%s: data_len = %d\n", __func__
, data_len
);
1660 /* OK, bss list retrieved */
1661 wl
->scan_stat
= GELIC_WL_SCAN_STAT_GOT_LIST
;
1663 /* mark all entries are old */
1664 list_for_each_entry_safe(target
, tmp
, &wl
->network_list
, list
) {
1666 /* expire too old entries */
1667 if (time_before(target
->last_scanned
+ wl
->scan_age
,
1669 kfree(target
->hwinfo
);
1670 target
->hwinfo
= NULL
;
1671 list_move_tail(&target
->list
, &wl
->network_free_list
);
1675 /* put them in the newtork_list */
1676 for (i
= 0, scan_info_size
= 0, scan_info
= buf
;
1677 scan_info_size
< data_len
;
1678 i
++, scan_info_size
+= be16_to_cpu(scan_info
->size
),
1679 scan_info
= (void *)scan_info
+ be16_to_cpu(scan_info
->size
)) {
1680 pr_debug("%s:size=%d bssid=%pM scan_info=%p\n", __func__
,
1681 be16_to_cpu(scan_info
->size
),
1682 &scan_info
->bssid
[2], scan_info
);
1685 * The wireless firmware may return invalid channel 0 and/or
1686 * invalid rate if the AP emits zero length SSID ie. As this
1687 * scan information is useless, ignore it
1689 if (!be16_to_cpu(scan_info
->channel
) || !scan_info
->rate
[0]) {
1690 pr_debug("%s: invalid scan info\n", __func__
);
1696 list_for_each_entry(target
, &wl
->network_list
, list
) {
1697 if (!compare_ether_addr(&target
->hwinfo
->bssid
[2],
1698 &scan_info
->bssid
[2])) {
1700 pr_debug("%s: same BBS found scanned list\n",
1705 (target
->last_scanned
< oldest
->last_scanned
))
1710 /* not found in the list */
1711 if (list_empty(&wl
->network_free_list
)) {
1715 target
= list_entry(wl
->network_free_list
.next
,
1716 struct gelic_wl_scan_info
,
1721 /* update the item */
1722 target
->last_scanned
= this_time
;
1724 target
->eurus_index
= i
;
1725 kfree(target
->hwinfo
);
1726 target
->hwinfo
= kzalloc(be16_to_cpu(scan_info
->size
),
1728 if (!target
->hwinfo
) {
1729 pr_info("%s: kzalloc failed\n", __func__
);
1732 /* copy hw scan info */
1733 memcpy(target
->hwinfo
, scan_info
, scan_info
->size
);
1734 target
->essid_len
= strnlen(scan_info
->essid
,
1735 sizeof(scan_info
->essid
));
1736 target
->rate_len
= 0;
1737 for (r
= 0; r
< MAX_RATES_LENGTH
; r
++)
1738 if (scan_info
->rate
[r
])
1740 if (8 < target
->rate_len
)
1741 pr_info("%s: AP returns %d rates\n", __func__
,
1743 target
->rate_ext_len
= 0;
1744 for (r
= 0; r
< MAX_RATES_EX_LENGTH
; r
++)
1745 if (scan_info
->ext_rate
[r
])
1746 target
->rate_ext_len
++;
1747 list_move_tail(&target
->list
, &wl
->network_list
);
1749 memset(&data
, 0, sizeof(data
));
1750 wireless_send_event(port_to_netdev(wl_port(wl
)), SIOCGIWSCAN
, &data
,
1753 free_page((unsigned long)buf
);
1754 complete(&wl
->scan_done
);
1755 mutex_unlock(&wl
->scan_lock
);
1756 pr_debug("%s:end\n", __func__
);
1760 * Select an appropriate bss from current scan list regarding
1761 * current settings from userspace.
1762 * The caller must hold wl->scan_lock,
1763 * and on the state of wl->scan_state == GELIC_WL_SCAN_GOT_LIST
1765 static void update_best(struct gelic_wl_scan_info
**best
,
1766 struct gelic_wl_scan_info
*candid
,
1770 if (*best_weight
< ++(*weight
)) {
1771 *best_weight
= *weight
;
1777 struct gelic_wl_scan_info
*gelic_wl_find_best_bss(struct gelic_wl_info
*wl
)
1779 struct gelic_wl_scan_info
*scan_info
;
1780 struct gelic_wl_scan_info
*best_bss
;
1781 int weight
, best_weight
;
1784 pr_debug("%s: <-\n", __func__
);
1789 list_for_each_entry(scan_info
, &wl
->network_list
, list
) {
1790 pr_debug("%s: station %p\n", __func__
, scan_info
);
1792 if (!scan_info
->valid
) {
1793 pr_debug("%s: station invalid\n", __func__
);
1797 /* If bss specified, check it only */
1798 if (test_bit(GELIC_WL_STAT_BSSID_SET
, &wl
->stat
)) {
1799 if (!compare_ether_addr(&scan_info
->hwinfo
->bssid
[2],
1801 best_bss
= scan_info
;
1802 pr_debug("%s: bssid matched\n", __func__
);
1805 pr_debug("%s: bssid unmached\n", __func__
);
1813 security
= be16_to_cpu(scan_info
->hwinfo
->security
) &
1814 GELIC_EURUS_SCAN_SEC_MASK
;
1815 if (wl
->wpa_level
== GELIC_WL_WPA_LEVEL_WPA2
) {
1816 if (security
== GELIC_EURUS_SCAN_SEC_WPA2
)
1817 update_best(&best_bss
, scan_info
,
1818 &best_weight
, &weight
);
1821 } else if (wl
->wpa_level
== GELIC_WL_WPA_LEVEL_WPA
) {
1822 if (security
== GELIC_EURUS_SCAN_SEC_WPA
)
1823 update_best(&best_bss
, scan_info
,
1824 &best_weight
, &weight
);
1827 } else if (wl
->wpa_level
== GELIC_WL_WPA_LEVEL_NONE
&&
1828 wl
->group_cipher_method
== GELIC_WL_CIPHER_WEP
) {
1829 if (security
== GELIC_EURUS_SCAN_SEC_WEP
)
1830 update_best(&best_bss
, scan_info
,
1831 &best_weight
, &weight
);
1836 /* If ESSID is set, check it */
1837 if (test_bit(GELIC_WL_STAT_ESSID_SET
, &wl
->stat
)) {
1838 if ((scan_info
->essid_len
== wl
->essid_len
) &&
1840 scan_info
->hwinfo
->essid
,
1841 scan_info
->essid_len
))
1842 update_best(&best_bss
, scan_info
,
1843 &best_weight
, &weight
);
1850 pr_debug("%s: -> bss=%p\n", __func__
, best_bss
);
1852 pr_debug("%s:addr=%pM\n", __func__
,
1853 &best_bss
->hwinfo
->bssid
[2]);
1860 * Setup WEP configuration to the chip
1861 * The caller must hold wl->scan_lock,
1862 * and on the state of wl->scan_state == GELIC_WL_SCAN_GOT_LIST
1864 static int gelic_wl_do_wep_setup(struct gelic_wl_info
*wl
)
1867 struct gelic_eurus_wep_cfg
*wep
;
1868 struct gelic_eurus_cmd
*cmd
;
1873 pr_debug("%s: <-\n", __func__
);
1874 /* we can assume no one should uses the buffer */
1875 wep
= (struct gelic_eurus_wep_cfg
*)__get_free_page(GFP_KERNEL
);
1879 memset(wep
, 0, sizeof(*wep
));
1881 if (wl
->group_cipher_method
== GELIC_WL_CIPHER_WEP
) {
1882 pr_debug("%s: WEP mode\n", __func__
);
1883 for (i
= 0; i
< GELIC_WEP_KEYS
; i
++) {
1884 if (!test_bit(i
, &wl
->key_enabled
))
1887 pr_debug("%s: key#%d enabled\n", __func__
, i
);
1889 if (wl
->key_len
[i
] == 13)
1891 else if (wl
->key_len
[i
] != 5) {
1892 pr_info("%s: wrong wep key[%d]=%d\n",
1893 __func__
, i
, wl
->key_len
[i
]);
1897 memcpy(wep
->key
[i
], wl
->key
[i
], wl
->key_len
[i
]);
1901 pr_info("%s: all wep key disabled\n", __func__
);
1907 pr_debug("%s: 104bit key\n", __func__
);
1908 wep
->security
= cpu_to_be16(GELIC_EURUS_WEP_SEC_104BIT
);
1910 pr_debug("%s: 40bit key\n", __func__
);
1911 wep
->security
= cpu_to_be16(GELIC_EURUS_WEP_SEC_40BIT
);
1914 pr_debug("%s: NO encryption\n", __func__
);
1915 wep
->security
= cpu_to_be16(GELIC_EURUS_WEP_SEC_NONE
);
1918 /* issue wep setup */
1919 cmd
= gelic_eurus_sync_cmd(wl
, GELIC_EURUS_CMD_SET_WEP_CFG
,
1923 else if (cmd
->status
|| cmd
->cmd_status
)
1928 free_page((unsigned long)wep
);
1929 pr_debug("%s: ->\n", __func__
);
1934 static const char *wpasecstr(enum gelic_eurus_wpa_security sec
)
1937 case GELIC_EURUS_WPA_SEC_NONE
:
1940 case GELIC_EURUS_WPA_SEC_WPA_TKIP_TKIP
:
1941 return "WPA_TKIP_TKIP";
1943 case GELIC_EURUS_WPA_SEC_WPA_TKIP_AES
:
1944 return "WPA_TKIP_AES";
1946 case GELIC_EURUS_WPA_SEC_WPA_AES_AES
:
1947 return "WPA_AES_AES";
1949 case GELIC_EURUS_WPA_SEC_WPA2_TKIP_TKIP
:
1950 return "WPA2_TKIP_TKIP";
1952 case GELIC_EURUS_WPA_SEC_WPA2_TKIP_AES
:
1953 return "WPA2_TKIP_AES";
1955 case GELIC_EURUS_WPA_SEC_WPA2_AES_AES
:
1956 return "WPA2_AES_AES";
1963 static int gelic_wl_do_wpa_setup(struct gelic_wl_info
*wl
)
1965 struct gelic_eurus_wpa_cfg
*wpa
;
1966 struct gelic_eurus_cmd
*cmd
;
1970 pr_debug("%s: <-\n", __func__
);
1971 /* we can assume no one should uses the buffer */
1972 wpa
= (struct gelic_eurus_wpa_cfg
*)__get_free_page(GFP_KERNEL
);
1976 memset(wpa
, 0, sizeof(*wpa
));
1978 if (!test_bit(GELIC_WL_STAT_WPA_PSK_SET
, &wl
->stat
))
1979 pr_info("%s: PSK not configured yet\n", __func__
);
1982 memcpy(wpa
->psk
, wl
->psk
, wl
->psk_len
);
1984 /* set security level */
1985 if (wl
->wpa_level
== GELIC_WL_WPA_LEVEL_WPA2
) {
1986 if (wl
->group_cipher_method
== GELIC_WL_CIPHER_AES
) {
1987 security
= GELIC_EURUS_WPA_SEC_WPA2_AES_AES
;
1989 if (wl
->pairwise_cipher_method
== GELIC_WL_CIPHER_AES
&&
1991 security
= GELIC_EURUS_WPA_SEC_WPA2_TKIP_AES
;
1993 security
= GELIC_EURUS_WPA_SEC_WPA2_TKIP_TKIP
;
1996 if (wl
->group_cipher_method
== GELIC_WL_CIPHER_AES
) {
1997 security
= GELIC_EURUS_WPA_SEC_WPA_AES_AES
;
1999 if (wl
->pairwise_cipher_method
== GELIC_WL_CIPHER_AES
&&
2001 security
= GELIC_EURUS_WPA_SEC_WPA_TKIP_AES
;
2003 security
= GELIC_EURUS_WPA_SEC_WPA_TKIP_TKIP
;
2006 wpa
->security
= cpu_to_be16(security
);
2009 wpa
->psk_type
= cpu_to_be16(wl
->psk_type
);
2011 pr_debug("%s: sec=%s psktype=%s\nn", __func__
,
2012 wpasecstr(wpa
->security
),
2013 (wpa
->psk_type
== GELIC_EURUS_WPA_PSK_BIN
) ?
2014 "BIN" : "passphrase");
2017 * don't enable here if you plan to submit
2018 * the debug log because this dumps your precious
2021 pr_debug("%s: psk=%s\n",
2022 (wpa
->psk_type
== GELIC_EURUS_WPA_PSK_BIN
) ?
2023 (char *)"N/A" : (char *)wpa
->psk
);
2026 /* issue wpa setup */
2027 cmd
= gelic_eurus_sync_cmd(wl
, GELIC_EURUS_CMD_SET_WPA_CFG
,
2031 else if (cmd
->status
|| cmd
->cmd_status
)
2034 free_page((unsigned long)wpa
);
2035 pr_debug("%s: --> %d\n", __func__
, ret
);
2040 * Start association. caller must hold assoc_stat_lock
2042 static int gelic_wl_associate_bss(struct gelic_wl_info
*wl
,
2043 struct gelic_wl_scan_info
*bss
)
2045 struct gelic_eurus_cmd
*cmd
;
2046 struct gelic_eurus_common_cfg
*common
;
2050 pr_debug("%s: <-\n", __func__
);
2052 /* do common config */
2053 common
= (struct gelic_eurus_common_cfg
*)__get_free_page(GFP_KERNEL
);
2057 memset(common
, 0, sizeof(*common
));
2058 common
->bss_type
= cpu_to_be16(GELIC_EURUS_BSS_INFRA
);
2059 common
->op_mode
= cpu_to_be16(GELIC_EURUS_OPMODE_11BG
);
2061 common
->scan_index
= cpu_to_be16(bss
->eurus_index
);
2062 switch (wl
->auth_method
) {
2063 case GELIC_EURUS_AUTH_OPEN
:
2064 common
->auth_method
= cpu_to_be16(GELIC_EURUS_AUTH_OPEN
);
2066 case GELIC_EURUS_AUTH_SHARED
:
2067 common
->auth_method
= cpu_to_be16(GELIC_EURUS_AUTH_SHARED
);
2074 pr_debug("%s: common cfg index=%d bsstype=%d auth=%d\n", __func__
,
2075 be16_to_cpu(common
->scan_index
),
2076 be16_to_cpu(common
->bss_type
),
2077 be16_to_cpu(common
->auth_method
));
2079 cmd
= gelic_eurus_sync_cmd(wl
, GELIC_EURUS_CMD_SET_COMMON_CFG
,
2080 common
, sizeof(*common
));
2081 if (!cmd
|| cmd
->status
|| cmd
->cmd_status
) {
2089 switch (wl
->wpa_level
) {
2090 case GELIC_WL_WPA_LEVEL_NONE
:
2091 /* If WEP or no security, setup WEP config */
2092 ret
= gelic_wl_do_wep_setup(wl
);
2094 case GELIC_WL_WPA_LEVEL_WPA
:
2095 case GELIC_WL_WPA_LEVEL_WPA2
:
2096 ret
= gelic_wl_do_wpa_setup(wl
);
2101 pr_debug("%s: WEP/WPA setup failed %d\n", __func__
,
2105 /* start association */
2106 init_completion(&wl
->assoc_done
);
2107 wl
->assoc_stat
= GELIC_WL_ASSOC_STAT_ASSOCIATING
;
2108 cmd
= gelic_eurus_sync_cmd(wl
, GELIC_EURUS_CMD_ASSOC
,
2110 if (!cmd
|| cmd
->status
|| cmd
->cmd_status
) {
2111 pr_debug("%s: assoc request failed\n", __func__
);
2112 wl
->assoc_stat
= GELIC_WL_ASSOC_STAT_DISCONN
;
2115 gelic_wl_send_iwap_event(wl
, NULL
);
2120 /* wait for connected event */
2121 rc
= wait_for_completion_timeout(&wl
->assoc_done
, HZ
* 4);/*FIXME*/
2124 /* timeouted. Maybe key or cyrpt mode is wrong */
2125 pr_info("%s: connect timeout \n", __func__
);
2126 cmd
= gelic_eurus_sync_cmd(wl
, GELIC_EURUS_CMD_DISASSOC
,
2129 wl
->assoc_stat
= GELIC_WL_ASSOC_STAT_DISCONN
;
2130 gelic_wl_send_iwap_event(wl
, NULL
);
2133 wl
->assoc_stat
= GELIC_WL_ASSOC_STAT_ASSOCIATED
;
2135 memcpy(wl
->active_bssid
, &bss
->hwinfo
->bssid
[2], ETH_ALEN
);
2137 /* send connect event */
2138 gelic_wl_send_iwap_event(wl
, wl
->active_bssid
);
2139 pr_info("%s: connected\n", __func__
);
2142 free_page((unsigned long)common
);
2143 pr_debug("%s: ->\n", __func__
);
2150 static void gelic_wl_connected_event(struct gelic_wl_info
*wl
,
2153 u64 desired_event
= 0;
2155 switch (wl
->wpa_level
) {
2156 case GELIC_WL_WPA_LEVEL_NONE
:
2157 desired_event
= GELIC_LV1_WL_EVENT_CONNECTED
;
2159 case GELIC_WL_WPA_LEVEL_WPA
:
2160 case GELIC_WL_WPA_LEVEL_WPA2
:
2161 desired_event
= GELIC_LV1_WL_EVENT_WPA_CONNECTED
;
2165 if (desired_event
== event
) {
2166 pr_debug("%s: completed \n", __func__
);
2167 complete(&wl
->assoc_done
);
2168 netif_carrier_on(port_to_netdev(wl_port(wl
)));
2170 pr_debug("%s: event %#lx under wpa\n",
2177 static void gelic_wl_disconnect_event(struct gelic_wl_info
*wl
,
2180 struct gelic_eurus_cmd
*cmd
;
2184 * If we fall here in the middle of association,
2185 * associate_bss() should be waiting for complation of
2187 * As it waits with timeout, just leave assoc_done
2188 * uncompleted, then it terminates with timeout
2190 if (!mutex_trylock(&wl
->assoc_stat_lock
)) {
2191 pr_debug("%s: already locked\n", __func__
);
2194 pr_debug("%s: obtain lock\n", __func__
);
2198 cmd
= gelic_eurus_sync_cmd(wl
, GELIC_EURUS_CMD_DISASSOC
, NULL
, 0);
2201 /* send disconnected event to the supplicant */
2202 if (wl
->assoc_stat
== GELIC_WL_ASSOC_STAT_ASSOCIATED
)
2203 gelic_wl_send_iwap_event(wl
, NULL
);
2205 wl
->assoc_stat
= GELIC_WL_ASSOC_STAT_DISCONN
;
2206 netif_carrier_off(port_to_netdev(wl_port(wl
)));
2209 mutex_unlock(&wl
->assoc_stat_lock
);
2215 static const char *eventstr(enum gelic_lv1_wl_event event
)
2217 static char buf
[32];
2219 if (event
& GELIC_LV1_WL_EVENT_DEVICE_READY
)
2220 ret
= "EURUS_READY";
2221 else if (event
& GELIC_LV1_WL_EVENT_SCAN_COMPLETED
)
2222 ret
= "SCAN_COMPLETED";
2223 else if (event
& GELIC_LV1_WL_EVENT_DEAUTH
)
2225 else if (event
& GELIC_LV1_WL_EVENT_BEACON_LOST
)
2226 ret
= "BEACON_LOST";
2227 else if (event
& GELIC_LV1_WL_EVENT_CONNECTED
)
2229 else if (event
& GELIC_LV1_WL_EVENT_WPA_CONNECTED
)
2230 ret
= "WPA_CONNECTED";
2231 else if (event
& GELIC_LV1_WL_EVENT_WPA_ERROR
)
2234 sprintf(buf
, "Unknown(%#x)", event
);
2240 static const char *eventstr(enum gelic_lv1_wl_event event
)
2245 static void gelic_wl_event_worker(struct work_struct
*work
)
2247 struct gelic_wl_info
*wl
;
2248 struct gelic_port
*port
;
2252 pr_debug("%s:start\n", __func__
);
2253 wl
= container_of(work
, struct gelic_wl_info
, event_work
.work
);
2256 status
= lv1_net_control(bus_id(port
->card
), dev_id(port
->card
),
2257 GELIC_LV1_GET_WLAN_EVENT
, 0, 0, 0,
2260 if (status
!= LV1_NO_ENTRY
)
2261 pr_debug("%s:wlan event failed %d\n",
2263 /* got all events */
2264 pr_debug("%s:end\n", __func__
);
2267 pr_debug("%s: event=%s\n", __func__
, eventstr(event
));
2269 case GELIC_LV1_WL_EVENT_SCAN_COMPLETED
:
2270 gelic_wl_scan_complete_event(wl
);
2272 case GELIC_LV1_WL_EVENT_BEACON_LOST
:
2273 case GELIC_LV1_WL_EVENT_DEAUTH
:
2274 gelic_wl_disconnect_event(wl
, event
);
2276 case GELIC_LV1_WL_EVENT_CONNECTED
:
2277 case GELIC_LV1_WL_EVENT_WPA_CONNECTED
:
2278 gelic_wl_connected_event(wl
, event
);
2286 * association worker
2288 static void gelic_wl_assoc_worker(struct work_struct
*work
)
2290 struct gelic_wl_info
*wl
;
2292 struct gelic_wl_scan_info
*best_bss
;
2294 unsigned long irqflag
;
2298 wl
= container_of(work
, struct gelic_wl_info
, assoc_work
.work
);
2300 mutex_lock(&wl
->assoc_stat_lock
);
2302 if (wl
->assoc_stat
!= GELIC_WL_ASSOC_STAT_DISCONN
)
2305 spin_lock_irqsave(&wl
->lock
, irqflag
);
2306 if (test_bit(GELIC_WL_STAT_ESSID_SET
, &wl
->stat
)) {
2307 pr_debug("%s: assoc ESSID configured %s\n", __func__
,
2310 essid_len
= wl
->essid_len
;
2315 spin_unlock_irqrestore(&wl
->lock
, irqflag
);
2317 ret
= gelic_wl_start_scan(wl
, 0, essid
, essid_len
);
2318 if (ret
== -ERESTARTSYS
) {
2319 pr_debug("%s: scan start failed association\n", __func__
);
2320 schedule_delayed_work(&wl
->assoc_work
, HZ
/10); /*FIXME*/
2323 pr_info("%s: scan prerequisite failed\n", __func__
);
2328 * Wait for bss scan completion
2329 * If we have scan list already, gelic_wl_start_scan()
2330 * returns OK and raises the complete. Thus,
2331 * it's ok to wait unconditionally here
2333 wait_for_completion(&wl
->scan_done
);
2335 pr_debug("%s: scan done\n", __func__
);
2336 mutex_lock(&wl
->scan_lock
);
2337 if (wl
->scan_stat
!= GELIC_WL_SCAN_STAT_GOT_LIST
) {
2338 gelic_wl_send_iwap_event(wl
, NULL
);
2339 pr_info("%s: no scan list. association failed\n", __func__
);
2343 /* find best matching bss */
2344 best_bss
= gelic_wl_find_best_bss(wl
);
2346 gelic_wl_send_iwap_event(wl
, NULL
);
2347 pr_info("%s: no bss matched. association failed\n", __func__
);
2351 /* ok, do association */
2352 ret
= gelic_wl_associate_bss(wl
, best_bss
);
2354 pr_info("%s: association failed %d\n", __func__
, ret
);
2356 mutex_unlock(&wl
->scan_lock
);
2358 mutex_unlock(&wl
->assoc_stat_lock
);
2362 * Called from the ethernet interrupt handler
2363 * Processes wireless specific virtual interrupts only
2365 void gelic_wl_interrupt(struct net_device
*netdev
, u64 status
)
2367 struct gelic_wl_info
*wl
= port_wl(netdev_priv(netdev
));
2369 if (status
& GELIC_CARD_WLAN_COMMAND_COMPLETED
) {
2370 pr_debug("%s:cmd complete\n", __func__
);
2371 complete(&wl
->cmd_done_intr
);
2374 if (status
& GELIC_CARD_WLAN_EVENT_RECEIVED
) {
2375 pr_debug("%s:event received\n", __func__
);
2376 queue_delayed_work(wl
->event_queue
, &wl
->event_work
, 0);
2383 #define IW_IOCTL(n) [(n) - SIOCSIWCOMMIT]
2384 static const iw_handler gelic_wl_wext_handler
[] =
2386 IW_IOCTL(SIOCGIWNAME
) = gelic_wl_get_name
,
2387 IW_IOCTL(SIOCGIWRANGE
) = gelic_wl_get_range
,
2388 IW_IOCTL(SIOCSIWSCAN
) = gelic_wl_set_scan
,
2389 IW_IOCTL(SIOCGIWSCAN
) = gelic_wl_get_scan
,
2390 IW_IOCTL(SIOCSIWAUTH
) = gelic_wl_set_auth
,
2391 IW_IOCTL(SIOCGIWAUTH
) = gelic_wl_get_auth
,
2392 IW_IOCTL(SIOCSIWESSID
) = gelic_wl_set_essid
,
2393 IW_IOCTL(SIOCGIWESSID
) = gelic_wl_get_essid
,
2394 IW_IOCTL(SIOCSIWENCODE
) = gelic_wl_set_encode
,
2395 IW_IOCTL(SIOCGIWENCODE
) = gelic_wl_get_encode
,
2396 IW_IOCTL(SIOCSIWAP
) = gelic_wl_set_ap
,
2397 IW_IOCTL(SIOCGIWAP
) = gelic_wl_get_ap
,
2398 IW_IOCTL(SIOCSIWENCODEEXT
) = gelic_wl_set_encodeext
,
2399 IW_IOCTL(SIOCGIWENCODEEXT
) = gelic_wl_get_encodeext
,
2400 IW_IOCTL(SIOCSIWMODE
) = gelic_wl_set_mode
,
2401 IW_IOCTL(SIOCGIWMODE
) = gelic_wl_get_mode
,
2402 IW_IOCTL(SIOCGIWNICKN
) = gelic_wl_get_nick
,
2405 #ifdef CONFIG_GELIC_WIRELESS_OLD_PSK_INTERFACE
2406 static struct iw_priv_args gelic_wl_private_args
[] =
2409 .cmd
= GELIC_WL_PRIV_SET_PSK
,
2410 .set_args
= IW_PRIV_TYPE_CHAR
|
2411 (GELIC_WL_EURUS_PSK_MAX_LEN
+ 2),
2415 .cmd
= GELIC_WL_PRIV_GET_PSK
,
2416 .get_args
= IW_PRIV_TYPE_CHAR
|
2417 (GELIC_WL_EURUS_PSK_MAX_LEN
+ 2),
2422 static const iw_handler gelic_wl_private_handler
[] =
2424 gelic_wl_priv_set_psk
,
2425 gelic_wl_priv_get_psk
,
2429 static const struct iw_handler_def gelic_wl_wext_handler_def
= {
2430 .num_standard
= ARRAY_SIZE(gelic_wl_wext_handler
),
2431 .standard
= gelic_wl_wext_handler
,
2432 .get_wireless_stats
= gelic_wl_get_wireless_stats
,
2433 #ifdef CONFIG_GELIC_WIRELESS_OLD_PSK_INTERFACE
2434 .num_private
= ARRAY_SIZE(gelic_wl_private_handler
),
2435 .num_private_args
= ARRAY_SIZE(gelic_wl_private_args
),
2436 .private = gelic_wl_private_handler
,
2437 .private_args
= gelic_wl_private_args
,
2441 static struct net_device
*gelic_wl_alloc(struct gelic_card
*card
)
2443 struct net_device
*netdev
;
2444 struct gelic_port
*port
;
2445 struct gelic_wl_info
*wl
;
2448 pr_debug("%s:start\n", __func__
);
2449 netdev
= alloc_etherdev(sizeof(struct gelic_port
) +
2450 sizeof(struct gelic_wl_info
));
2451 pr_debug("%s: netdev =%p card=%p \np", __func__
, netdev
, card
);
2455 strcpy(netdev
->name
, "wlan%d");
2457 port
= netdev_priv(netdev
);
2458 port
->netdev
= netdev
;
2460 port
->type
= GELIC_PORT_WIRELESS
;
2463 pr_debug("%s: wl=%p port=%p\n", __func__
, wl
, port
);
2465 /* allocate scan list */
2466 wl
->networks
= kzalloc(sizeof(struct gelic_wl_scan_info
) *
2467 GELIC_WL_BSS_MAX_ENT
, GFP_KERNEL
);
2472 wl
->eurus_cmd_queue
= create_singlethread_workqueue("gelic_cmd");
2473 if (!wl
->eurus_cmd_queue
)
2474 goto fail_cmd_workqueue
;
2476 wl
->event_queue
= create_singlethread_workqueue("gelic_event");
2477 if (!wl
->event_queue
)
2478 goto fail_event_workqueue
;
2480 INIT_LIST_HEAD(&wl
->network_free_list
);
2481 INIT_LIST_HEAD(&wl
->network_list
);
2482 for (i
= 0; i
< GELIC_WL_BSS_MAX_ENT
; i
++)
2483 list_add_tail(&wl
->networks
[i
].list
,
2484 &wl
->network_free_list
);
2485 init_completion(&wl
->cmd_done_intr
);
2487 INIT_DELAYED_WORK(&wl
->event_work
, gelic_wl_event_worker
);
2488 INIT_DELAYED_WORK(&wl
->assoc_work
, gelic_wl_assoc_worker
);
2489 mutex_init(&wl
->scan_lock
);
2490 mutex_init(&wl
->assoc_stat_lock
);
2492 init_completion(&wl
->scan_done
);
2493 /* for the case that no scan request is issued and stop() is called */
2494 complete(&wl
->scan_done
);
2496 spin_lock_init(&wl
->lock
);
2498 wl
->scan_age
= 5*HZ
; /* FIXME */
2500 /* buffer for receiving scanned list etc */
2501 BUILD_BUG_ON(PAGE_SIZE
<
2502 sizeof(struct gelic_eurus_scan_info
) *
2503 GELIC_EURUS_MAX_SCAN
);
2504 pr_debug("%s:end\n", __func__
);
2507 fail_event_workqueue
:
2508 destroy_workqueue(wl
->eurus_cmd_queue
);
2510 kfree(wl
->networks
);
2512 free_netdev(netdev
);
2513 pr_debug("%s:end error\n", __func__
);
2518 static void gelic_wl_free(struct gelic_wl_info
*wl
)
2520 struct gelic_wl_scan_info
*scan_info
;
2523 pr_debug("%s: <-\n", __func__
);
2525 pr_debug("%s: destroy queues\n", __func__
);
2526 destroy_workqueue(wl
->eurus_cmd_queue
);
2527 destroy_workqueue(wl
->event_queue
);
2529 scan_info
= wl
->networks
;
2530 for (i
= 0; i
< GELIC_WL_BSS_MAX_ENT
; i
++, scan_info
++)
2531 kfree(scan_info
->hwinfo
);
2532 kfree(wl
->networks
);
2534 free_netdev(port_to_netdev(wl_port(wl
)));
2536 pr_debug("%s: ->\n", __func__
);
2539 static int gelic_wl_try_associate(struct net_device
*netdev
)
2541 struct gelic_wl_info
*wl
= port_wl(netdev_priv(netdev
));
2545 pr_debug("%s: <-\n", __func__
);
2547 /* check constraits for start association */
2548 /* for no access restriction AP */
2549 if (wl
->group_cipher_method
== GELIC_WL_CIPHER_NONE
) {
2550 if (test_bit(GELIC_WL_STAT_CONFIGURED
,
2554 pr_debug("%s: no wep, not configured\n", __func__
);
2559 /* for WEP, one of four keys should be set */
2560 if (wl
->group_cipher_method
== GELIC_WL_CIPHER_WEP
) {
2561 /* one of keys set */
2562 for (i
= 0; i
< GELIC_WEP_KEYS
; i
++) {
2563 if (test_bit(i
, &wl
->key_enabled
))
2566 pr_debug("%s: WEP, but no key specified\n", __func__
);
2570 /* for WPA[2], psk should be set */
2571 if ((wl
->group_cipher_method
== GELIC_WL_CIPHER_TKIP
) ||
2572 (wl
->group_cipher_method
== GELIC_WL_CIPHER_AES
)) {
2573 if (test_bit(GELIC_WL_STAT_WPA_PSK_SET
,
2577 pr_debug("%s: AES/TKIP, but PSK not configured\n",
2584 ret
= schedule_delayed_work(&wl
->assoc_work
, 0);
2585 pr_debug("%s: start association work %d\n", __func__
, ret
);
2592 static int gelic_wl_open(struct net_device
*netdev
)
2594 struct gelic_card
*card
= netdev_card(netdev
);
2596 pr_debug("%s:->%p\n", __func__
, netdev
);
2598 gelic_card_up(card
);
2600 /* try to associate */
2601 gelic_wl_try_associate(netdev
);
2603 netif_start_queue(netdev
);
2605 pr_debug("%s:<-\n", __func__
);
2610 * reset state machine
2612 static int gelic_wl_reset_state(struct gelic_wl_info
*wl
)
2614 struct gelic_wl_scan_info
*target
;
2615 struct gelic_wl_scan_info
*tmp
;
2617 /* empty scan list */
2618 list_for_each_entry_safe(target
, tmp
, &wl
->network_list
, list
) {
2619 list_move_tail(&target
->list
, &wl
->network_free_list
);
2621 wl
->scan_stat
= GELIC_WL_SCAN_STAT_INIT
;
2623 /* clear configuration */
2624 wl
->auth_method
= GELIC_EURUS_AUTH_OPEN
;
2625 wl
->group_cipher_method
= GELIC_WL_CIPHER_NONE
;
2626 wl
->pairwise_cipher_method
= GELIC_WL_CIPHER_NONE
;
2627 wl
->wpa_level
= GELIC_WL_WPA_LEVEL_NONE
;
2629 wl
->key_enabled
= 0;
2630 wl
->current_key
= 0;
2632 wl
->psk_type
= GELIC_EURUS_WPA_PSK_PASSPHRASE
;
2636 memset(wl
->essid
, 0, sizeof(wl
->essid
));
2637 memset(wl
->bssid
, 0, sizeof(wl
->bssid
));
2638 memset(wl
->active_bssid
, 0, sizeof(wl
->active_bssid
));
2640 wl
->assoc_stat
= GELIC_WL_ASSOC_STAT_DISCONN
;
2642 memset(&wl
->iwstat
, 0, sizeof(wl
->iwstat
));
2643 /* all status bit clear */
2649 * Tell eurus to terminate association
2651 static void gelic_wl_disconnect(struct net_device
*netdev
)
2653 struct gelic_port
*port
= netdev_priv(netdev
);
2654 struct gelic_wl_info
*wl
= port_wl(port
);
2655 struct gelic_eurus_cmd
*cmd
;
2658 * If scann process is running on chip,
2659 * further requests will be rejected
2661 if (wl
->scan_stat
== GELIC_WL_SCAN_STAT_SCANNING
)
2662 wait_for_completion_timeout(&wl
->scan_done
, HZ
);
2664 cmd
= gelic_eurus_sync_cmd(wl
, GELIC_EURUS_CMD_DISASSOC
, NULL
, 0);
2666 gelic_wl_send_iwap_event(wl
, NULL
);
2669 static int gelic_wl_stop(struct net_device
*netdev
)
2671 struct gelic_port
*port
= netdev_priv(netdev
);
2672 struct gelic_wl_info
*wl
= port_wl(port
);
2673 struct gelic_card
*card
= netdev_card(netdev
);
2675 pr_debug("%s:<-\n", __func__
);
2678 * Cancel pending association work.
2679 * event work can run after netdev down
2681 cancel_delayed_work(&wl
->assoc_work
);
2683 if (wl
->assoc_stat
== GELIC_WL_ASSOC_STAT_ASSOCIATED
)
2684 gelic_wl_disconnect(netdev
);
2686 /* reset our state machine */
2687 gelic_wl_reset_state(wl
);
2689 netif_stop_queue(netdev
);
2691 gelic_card_down(card
);
2693 pr_debug("%s:->\n", __func__
);
2699 static struct ethtool_ops gelic_wl_ethtool_ops
= {
2700 .get_drvinfo
= gelic_net_get_drvinfo
,
2701 .get_link
= gelic_wl_get_link
,
2702 .get_tx_csum
= ethtool_op_get_tx_csum
,
2703 .set_tx_csum
= ethtool_op_set_tx_csum
,
2704 .get_rx_csum
= gelic_net_get_rx_csum
,
2705 .set_rx_csum
= gelic_net_set_rx_csum
,
2708 static void gelic_wl_setup_netdev_ops(struct net_device
*netdev
)
2710 struct gelic_wl_info
*wl
;
2711 wl
= port_wl(netdev_priv(netdev
));
2713 netdev
->open
= &gelic_wl_open
;
2714 netdev
->stop
= &gelic_wl_stop
;
2715 netdev
->hard_start_xmit
= &gelic_net_xmit
;
2716 netdev
->set_multicast_list
= &gelic_net_set_multi
;
2717 netdev
->change_mtu
= &gelic_net_change_mtu
;
2718 netdev
->wireless_data
= &wl
->wireless_data
;
2719 netdev
->wireless_handlers
= &gelic_wl_wext_handler_def
;
2721 netdev
->tx_timeout
= &gelic_net_tx_timeout
;
2722 netdev
->watchdog_timeo
= GELIC_NET_WATCHDOG_TIMEOUT
;
2724 netdev
->ethtool_ops
= &gelic_wl_ethtool_ops
;
2725 #ifdef CONFIG_NET_POLL_CONTROLLER
2726 netdev
->poll_controller
= gelic_net_poll_controller
;
2731 * driver probe/remove
2733 int gelic_wl_driver_probe(struct gelic_card
*card
)
2736 struct net_device
*netdev
;
2738 pr_debug("%s:start\n", __func__
);
2740 if (ps3_compare_firmware_version(1, 6, 0) < 0)
2742 if (!card
->vlan
[GELIC_PORT_WIRELESS
].tx
)
2745 /* alloc netdevice for wireless */
2746 netdev
= gelic_wl_alloc(card
);
2750 /* setup net_device structure */
2751 SET_NETDEV_DEV(netdev
, &card
->dev
->core
);
2752 gelic_wl_setup_netdev_ops(netdev
);
2754 /* setup some of net_device and register it */
2755 ret
= gelic_net_setup_netdev(netdev
, card
);
2758 card
->netdev
[GELIC_PORT_WIRELESS
] = netdev
;
2760 /* add enable wireless interrupt */
2761 card
->irq_mask
|= GELIC_CARD_WLAN_EVENT_RECEIVED
|
2762 GELIC_CARD_WLAN_COMMAND_COMPLETED
;
2763 /* to allow wireless commands while both interfaces are down */
2764 gelic_card_set_irq_mask(card
, GELIC_CARD_WLAN_EVENT_RECEIVED
|
2765 GELIC_CARD_WLAN_COMMAND_COMPLETED
);
2766 pr_debug("%s:end\n", __func__
);
2770 gelic_wl_free(port_wl(netdev_port(netdev
)));
2775 int gelic_wl_driver_remove(struct gelic_card
*card
)
2777 struct gelic_wl_info
*wl
;
2778 struct net_device
*netdev
;
2780 pr_debug("%s:start\n", __func__
);
2782 if (ps3_compare_firmware_version(1, 6, 0) < 0)
2784 if (!card
->vlan
[GELIC_PORT_WIRELESS
].tx
)
2787 netdev
= card
->netdev
[GELIC_PORT_WIRELESS
];
2788 wl
= port_wl(netdev_priv(netdev
));
2790 /* if the interface was not up, but associated */
2791 if (wl
->assoc_stat
== GELIC_WL_ASSOC_STAT_ASSOCIATED
)
2792 gelic_wl_disconnect(netdev
);
2794 complete(&wl
->cmd_done_intr
);
2796 /* cancel all work queue */
2797 cancel_delayed_work(&wl
->assoc_work
);
2798 cancel_delayed_work(&wl
->event_work
);
2799 flush_workqueue(wl
->eurus_cmd_queue
);
2800 flush_workqueue(wl
->event_queue
);
2802 unregister_netdev(netdev
);
2804 /* disable wireless interrupt */
2805 pr_debug("%s: disable intr\n", __func__
);
2806 card
->irq_mask
&= ~(GELIC_CARD_WLAN_EVENT_RECEIVED
|
2807 GELIC_CARD_WLAN_COMMAND_COMPLETED
);
2808 /* free bss list, netdev*/
2810 pr_debug("%s:end\n", __func__
);