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
;
766 DECLARE_MAC_BUF(mac
);
769 list_for_each_entry(scan_info
, &wl
->network_list
, list
) {
770 pr_debug("%s: item %d\n", __func__
, i
++);
771 pr_debug("valid=%d eurusindex=%d last=%lx\n",
772 scan_info
->valid
, scan_info
->eurus_index
,
773 scan_info
->last_scanned
);
774 pr_debug("r_len=%d r_ext_len=%d essid_len=%d\n",
775 scan_info
->rate_len
, scan_info
->rate_ext_len
,
776 scan_info
->essid_len
);
778 pr_debug("bssid=%s\n",
779 print_mac(mac
, &scan_info
->hwinfo
->bssid
[2]));
780 pr_debug("essid=%s\n", scan_info
->hwinfo
->essid
);
785 static int gelic_wl_set_auth(struct net_device
*netdev
,
786 struct iw_request_info
*info
,
787 union iwreq_data
*data
, char *extra
)
789 struct iw_param
*param
= &data
->param
;
790 struct gelic_wl_info
*wl
= port_wl(netdev_port(netdev
));
791 unsigned long irqflag
;
794 pr_debug("%s: <- %d\n", __func__
, param
->flags
& IW_AUTH_INDEX
);
795 spin_lock_irqsave(&wl
->lock
, irqflag
);
796 switch (param
->flags
& IW_AUTH_INDEX
) {
797 case IW_AUTH_WPA_VERSION
:
798 if (param
->value
& IW_AUTH_WPA_VERSION_DISABLED
) {
799 pr_debug("%s: NO WPA selected\n", __func__
);
800 wl
->wpa_level
= GELIC_WL_WPA_LEVEL_NONE
;
801 wl
->group_cipher_method
= GELIC_WL_CIPHER_WEP
;
802 wl
->pairwise_cipher_method
= GELIC_WL_CIPHER_WEP
;
804 if (param
->value
& IW_AUTH_WPA_VERSION_WPA
) {
805 pr_debug("%s: WPA version 1 selected\n", __func__
);
806 wl
->wpa_level
= GELIC_WL_WPA_LEVEL_WPA
;
807 wl
->group_cipher_method
= GELIC_WL_CIPHER_TKIP
;
808 wl
->pairwise_cipher_method
= GELIC_WL_CIPHER_TKIP
;
809 wl
->auth_method
= GELIC_EURUS_AUTH_OPEN
;
811 if (param
->value
& IW_AUTH_WPA_VERSION_WPA2
) {
813 * As the hypervisor may not tell the cipher
814 * information of the AP if it is WPA2,
815 * you will not decide suitable cipher from
817 * You should have knowledge about the AP's
818 * cipher infomation in other method prior to
822 pr_info("%s: WPA2 may not work\n", __func__
);
823 if (wpa2_capable()) {
824 wl
->wpa_level
= GELIC_WL_WPA_LEVEL_WPA2
;
825 wl
->group_cipher_method
= GELIC_WL_CIPHER_AES
;
826 wl
->pairwise_cipher_method
=
828 wl
->auth_method
= GELIC_EURUS_AUTH_OPEN
;
834 case IW_AUTH_CIPHER_PAIRWISE
:
836 (IW_AUTH_CIPHER_WEP104
| IW_AUTH_CIPHER_WEP40
)) {
837 pr_debug("%s: WEP selected\n", __func__
);
838 wl
->pairwise_cipher_method
= GELIC_WL_CIPHER_WEP
;
840 if (param
->value
& IW_AUTH_CIPHER_TKIP
) {
841 pr_debug("%s: TKIP selected\n", __func__
);
842 wl
->pairwise_cipher_method
= GELIC_WL_CIPHER_TKIP
;
844 if (param
->value
& IW_AUTH_CIPHER_CCMP
) {
845 pr_debug("%s: CCMP selected\n", __func__
);
846 wl
->pairwise_cipher_method
= GELIC_WL_CIPHER_AES
;
848 if (param
->value
& IW_AUTH_CIPHER_NONE
) {
849 pr_debug("%s: no auth selected\n", __func__
);
850 wl
->pairwise_cipher_method
= GELIC_WL_CIPHER_NONE
;
853 case IW_AUTH_CIPHER_GROUP
:
855 (IW_AUTH_CIPHER_WEP104
| IW_AUTH_CIPHER_WEP40
)) {
856 pr_debug("%s: WEP selected\n", __func__
);
857 wl
->group_cipher_method
= GELIC_WL_CIPHER_WEP
;
859 if (param
->value
& IW_AUTH_CIPHER_TKIP
) {
860 pr_debug("%s: TKIP selected\n", __func__
);
861 wl
->group_cipher_method
= GELIC_WL_CIPHER_TKIP
;
863 if (param
->value
& IW_AUTH_CIPHER_CCMP
) {
864 pr_debug("%s: CCMP selected\n", __func__
);
865 wl
->group_cipher_method
= GELIC_WL_CIPHER_AES
;
867 if (param
->value
& IW_AUTH_CIPHER_NONE
) {
868 pr_debug("%s: no auth selected\n", __func__
);
869 wl
->group_cipher_method
= GELIC_WL_CIPHER_NONE
;
872 case IW_AUTH_80211_AUTH_ALG
:
873 if (param
->value
& IW_AUTH_ALG_SHARED_KEY
) {
874 pr_debug("%s: shared key specified\n", __func__
);
875 wl
->auth_method
= GELIC_EURUS_AUTH_SHARED
;
876 } else if (param
->value
& IW_AUTH_ALG_OPEN_SYSTEM
) {
877 pr_debug("%s: open system specified\n", __func__
);
878 wl
->auth_method
= GELIC_EURUS_AUTH_OPEN
;
883 case IW_AUTH_WPA_ENABLED
:
885 pr_debug("%s: WPA enabled\n", __func__
);
886 wl
->wpa_level
= GELIC_WL_WPA_LEVEL_WPA
;
888 pr_debug("%s: WPA disabled\n", __func__
);
889 wl
->wpa_level
= GELIC_WL_WPA_LEVEL_NONE
;
893 case IW_AUTH_KEY_MGMT
:
894 if (param
->value
& IW_AUTH_KEY_MGMT_PSK
)
896 /* intentionally fall through */
903 set_bit(GELIC_WL_STAT_CONFIGURED
, &wl
->stat
);
905 spin_unlock_irqrestore(&wl
->lock
, irqflag
);
906 pr_debug("%s: -> %d\n", __func__
, ret
);
910 static int gelic_wl_get_auth(struct net_device
*netdev
,
911 struct iw_request_info
*info
,
912 union iwreq_data
*iwreq
, char *extra
)
914 struct iw_param
*param
= &iwreq
->param
;
915 struct gelic_wl_info
*wl
= port_wl(netdev_port(netdev
));
916 unsigned long irqflag
;
919 pr_debug("%s: <- %d\n", __func__
, param
->flags
& IW_AUTH_INDEX
);
920 spin_lock_irqsave(&wl
->lock
, irqflag
);
921 switch (param
->flags
& IW_AUTH_INDEX
) {
922 case IW_AUTH_WPA_VERSION
:
923 switch (wl
->wpa_level
) {
924 case GELIC_WL_WPA_LEVEL_WPA
:
925 param
->value
|= IW_AUTH_WPA_VERSION_WPA
;
927 case GELIC_WL_WPA_LEVEL_WPA2
:
928 param
->value
|= IW_AUTH_WPA_VERSION_WPA2
;
931 param
->value
|= IW_AUTH_WPA_VERSION_DISABLED
;
935 case IW_AUTH_80211_AUTH_ALG
:
936 if (wl
->auth_method
== GELIC_EURUS_AUTH_SHARED
)
937 param
->value
= IW_AUTH_ALG_SHARED_KEY
;
938 else if (wl
->auth_method
== GELIC_EURUS_AUTH_OPEN
)
939 param
->value
= IW_AUTH_ALG_OPEN_SYSTEM
;
942 case IW_AUTH_WPA_ENABLED
:
943 switch (wl
->wpa_level
) {
944 case GELIC_WL_WPA_LEVEL_WPA
:
945 case GELIC_WL_WPA_LEVEL_WPA2
:
957 spin_unlock_irqrestore(&wl
->lock
, irqflag
);
958 pr_debug("%s: -> %d\n", __func__
, ret
);
962 /* SIOC{S,G}IWESSID */
963 static int gelic_wl_set_essid(struct net_device
*netdev
,
964 struct iw_request_info
*info
,
965 union iwreq_data
*data
, char *extra
)
967 struct gelic_wl_info
*wl
= port_wl(netdev_priv(netdev
));
968 unsigned long irqflag
;
970 pr_debug("%s: <- l=%d f=%d\n", __func__
,
971 data
->essid
.length
, data
->essid
.flags
);
972 if (IW_ESSID_MAX_SIZE
< data
->essid
.length
)
975 spin_lock_irqsave(&wl
->lock
, irqflag
);
976 if (data
->essid
.flags
) {
977 wl
->essid_len
= data
->essid
.length
;
978 memcpy(wl
->essid
, extra
, wl
->essid_len
);
979 pr_debug("%s: essid = '%s'\n", __func__
, extra
);
980 set_bit(GELIC_WL_STAT_ESSID_SET
, &wl
->stat
);
982 pr_debug("%s: ESSID any \n", __func__
);
983 clear_bit(GELIC_WL_STAT_ESSID_SET
, &wl
->stat
);
985 set_bit(GELIC_WL_STAT_CONFIGURED
, &wl
->stat
);
986 spin_unlock_irqrestore(&wl
->lock
, irqflag
);
989 gelic_wl_try_associate(netdev
); /* FIXME */
990 pr_debug("%s: -> \n", __func__
);
994 static int gelic_wl_get_essid(struct net_device
*netdev
,
995 struct iw_request_info
*info
,
996 union iwreq_data
*data
, char *extra
)
998 struct gelic_wl_info
*wl
= port_wl(netdev_priv(netdev
));
999 unsigned long irqflag
;
1001 pr_debug("%s: <- \n", __func__
);
1002 mutex_lock(&wl
->assoc_stat_lock
);
1003 spin_lock_irqsave(&wl
->lock
, irqflag
);
1004 if (test_bit(GELIC_WL_STAT_ESSID_SET
, &wl
->stat
) ||
1005 wl
->assoc_stat
== GELIC_WL_ASSOC_STAT_ASSOCIATED
) {
1006 memcpy(extra
, wl
->essid
, wl
->essid_len
);
1007 data
->essid
.length
= wl
->essid_len
;
1008 data
->essid
.flags
= 1;
1010 data
->essid
.flags
= 0;
1012 mutex_unlock(&wl
->assoc_stat_lock
);
1013 spin_unlock_irqrestore(&wl
->lock
, irqflag
);
1014 pr_debug("%s: -> len=%d \n", __func__
, data
->essid
.length
);
1019 /* SIO{S,G}IWENCODE */
1020 static int gelic_wl_set_encode(struct net_device
*netdev
,
1021 struct iw_request_info
*info
,
1022 union iwreq_data
*data
, char *extra
)
1024 struct gelic_wl_info
*wl
= port_wl(netdev_priv(netdev
));
1025 struct iw_point
*enc
= &data
->encoding
;
1027 unsigned int irqflag
;
1028 int key_index
, index_specified
;
1031 pr_debug("%s: <- \n", __func__
);
1032 flags
= enc
->flags
& IW_ENCODE_FLAGS
;
1033 key_index
= enc
->flags
& IW_ENCODE_INDEX
;
1035 pr_debug("%s: key_index = %d\n", __func__
, key_index
);
1036 pr_debug("%s: key_len = %d\n", __func__
, enc
->length
);
1037 pr_debug("%s: flag=%x\n", __func__
, enc
->flags
& IW_ENCODE_FLAGS
);
1039 if (GELIC_WEP_KEYS
< key_index
)
1042 spin_lock_irqsave(&wl
->lock
, irqflag
);
1044 index_specified
= 1;
1047 index_specified
= 0;
1048 key_index
= wl
->current_key
;
1051 if (flags
& IW_ENCODE_NOKEY
) {
1052 /* if just IW_ENCODE_NOKEY, change current key index */
1053 if (!flags
&& index_specified
) {
1054 wl
->current_key
= key_index
;
1058 if (flags
& IW_ENCODE_DISABLED
) {
1059 if (!index_specified
) {
1060 /* disable encryption */
1061 wl
->group_cipher_method
= GELIC_WL_CIPHER_NONE
;
1062 wl
->pairwise_cipher_method
=
1063 GELIC_WL_CIPHER_NONE
;
1064 /* invalidate all key */
1065 wl
->key_enabled
= 0;
1067 clear_bit(key_index
, &wl
->key_enabled
);
1070 if (flags
& IW_ENCODE_OPEN
)
1071 wl
->auth_method
= GELIC_EURUS_AUTH_OPEN
;
1072 if (flags
& IW_ENCODE_RESTRICTED
) {
1073 pr_info("%s: shared key mode enabled\n", __func__
);
1074 wl
->auth_method
= GELIC_EURUS_AUTH_SHARED
;
1077 if (IW_ENCODING_TOKEN_MAX
< enc
->length
) {
1081 wl
->key_len
[key_index
] = enc
->length
;
1082 memcpy(wl
->key
[key_index
], extra
, enc
->length
);
1083 set_bit(key_index
, &wl
->key_enabled
);
1084 wl
->pairwise_cipher_method
= GELIC_WL_CIPHER_WEP
;
1085 wl
->group_cipher_method
= GELIC_WL_CIPHER_WEP
;
1087 set_bit(GELIC_WL_STAT_CONFIGURED
, &wl
->stat
);
1089 spin_unlock_irqrestore(&wl
->lock
, irqflag
);
1090 pr_debug("%s: -> \n", __func__
);
1094 static int gelic_wl_get_encode(struct net_device
*netdev
,
1095 struct iw_request_info
*info
,
1096 union iwreq_data
*data
, char *extra
)
1098 struct gelic_wl_info
*wl
= port_wl(netdev_priv(netdev
));
1099 struct iw_point
*enc
= &data
->encoding
;
1100 unsigned int irqflag
;
1101 unsigned int key_index
, index_specified
;
1104 pr_debug("%s: <- \n", __func__
);
1105 key_index
= enc
->flags
& IW_ENCODE_INDEX
;
1106 pr_debug("%s: flag=%#x point=%p len=%d extra=%p\n", __func__
,
1107 enc
->flags
, enc
->pointer
, enc
->length
, extra
);
1108 if (GELIC_WEP_KEYS
< key_index
)
1111 spin_lock_irqsave(&wl
->lock
, irqflag
);
1113 index_specified
= 1;
1116 index_specified
= 0;
1117 key_index
= wl
->current_key
;
1120 if (wl
->group_cipher_method
== GELIC_WL_CIPHER_WEP
) {
1121 switch (wl
->auth_method
) {
1122 case GELIC_EURUS_AUTH_OPEN
:
1123 enc
->flags
= IW_ENCODE_OPEN
;
1125 case GELIC_EURUS_AUTH_SHARED
:
1126 enc
->flags
= IW_ENCODE_RESTRICTED
;
1130 enc
->flags
= IW_ENCODE_DISABLED
;
1132 if (test_bit(key_index
, &wl
->key_enabled
)) {
1133 if (enc
->length
< wl
->key_len
[key_index
]) {
1137 enc
->length
= wl
->key_len
[key_index
];
1138 memcpy(extra
, wl
->key
[key_index
], wl
->key_len
[key_index
]);
1141 enc
->flags
|= IW_ENCODE_NOKEY
;
1143 enc
->flags
|= key_index
+ 1;
1144 pr_debug("%s: -> flag=%x len=%d\n", __func__
,
1145 enc
->flags
, enc
->length
);
1148 spin_unlock_irqrestore(&wl
->lock
, irqflag
);
1153 static int gelic_wl_set_ap(struct net_device
*netdev
,
1154 struct iw_request_info
*info
,
1155 union iwreq_data
*data
, char *extra
)
1157 struct gelic_wl_info
*wl
= port_wl(netdev_priv(netdev
));
1158 unsigned long irqflag
;
1160 pr_debug("%s: <-\n", __func__
);
1161 if (data
->ap_addr
.sa_family
!= ARPHRD_ETHER
)
1164 spin_lock_irqsave(&wl
->lock
, irqflag
);
1165 if (is_valid_ether_addr(data
->ap_addr
.sa_data
)) {
1166 memcpy(wl
->bssid
, data
->ap_addr
.sa_data
,
1168 set_bit(GELIC_WL_STAT_BSSID_SET
, &wl
->stat
);
1169 set_bit(GELIC_WL_STAT_CONFIGURED
, &wl
->stat
);
1170 pr_debug("%s: bss=%02x:%02x:%02x:%02x:%02x:%02x\n",
1172 wl
->bssid
[0], wl
->bssid
[1],
1173 wl
->bssid
[2], wl
->bssid
[3],
1174 wl
->bssid
[4], wl
->bssid
[5]);
1176 pr_debug("%s: clear bssid\n", __func__
);
1177 clear_bit(GELIC_WL_STAT_BSSID_SET
, &wl
->stat
);
1178 memset(wl
->bssid
, 0, ETH_ALEN
);
1180 spin_unlock_irqrestore(&wl
->lock
, irqflag
);
1181 pr_debug("%s: ->\n", __func__
);
1185 static int gelic_wl_get_ap(struct net_device
*netdev
,
1186 struct iw_request_info
*info
,
1187 union iwreq_data
*data
, char *extra
)
1189 struct gelic_wl_info
*wl
= port_wl(netdev_priv(netdev
));
1190 unsigned long irqflag
;
1192 pr_debug("%s: <-\n", __func__
);
1193 mutex_lock(&wl
->assoc_stat_lock
);
1194 spin_lock_irqsave(&wl
->lock
, irqflag
);
1195 if (wl
->assoc_stat
== GELIC_WL_ASSOC_STAT_ASSOCIATED
) {
1196 data
->ap_addr
.sa_family
= ARPHRD_ETHER
;
1197 memcpy(data
->ap_addr
.sa_data
, wl
->active_bssid
,
1200 memset(data
->ap_addr
.sa_data
, 0, ETH_ALEN
);
1202 spin_unlock_irqrestore(&wl
->lock
, irqflag
);
1203 mutex_unlock(&wl
->assoc_stat_lock
);
1204 pr_debug("%s: ->\n", __func__
);
1208 /* SIOC{S,G}IWENCODEEXT */
1209 static int gelic_wl_set_encodeext(struct net_device
*netdev
,
1210 struct iw_request_info
*info
,
1211 union iwreq_data
*data
, char *extra
)
1213 struct gelic_wl_info
*wl
= port_wl(netdev_priv(netdev
));
1214 struct iw_point
*enc
= &data
->encoding
;
1215 struct iw_encode_ext
*ext
= (struct iw_encode_ext
*)extra
;
1218 unsigned int irqflag
;
1222 pr_debug("%s: <- \n", __func__
);
1223 flags
= enc
->flags
& IW_ENCODE_FLAGS
;
1225 key_index
= enc
->flags
& IW_ENCODE_INDEX
;
1227 pr_debug("%s: key_index = %d\n", __func__
, key_index
);
1228 pr_debug("%s: key_len = %d\n", __func__
, enc
->length
);
1229 pr_debug("%s: flag=%x\n", __func__
, enc
->flags
& IW_ENCODE_FLAGS
);
1230 pr_debug("%s: ext_flag=%x\n", __func__
, ext
->ext_flags
);
1231 pr_debug("%s: ext_key_len=%x\n", __func__
, ext
->key_len
);
1233 if (GELIC_WEP_KEYS
< key_index
)
1236 spin_lock_irqsave(&wl
->lock
, irqflag
);
1240 key_index
= wl
->current_key
;
1242 if (!enc
->length
&& (ext
->ext_flags
& IW_ENCODE_EXT_SET_TX_KEY
)) {
1243 /* reques to change default key index */
1244 pr_debug("%s: request to change default key to %d\n",
1245 __func__
, key_index
);
1246 wl
->current_key
= key_index
;
1250 if (alg
== IW_ENCODE_ALG_NONE
|| (flags
& IW_ENCODE_DISABLED
)) {
1251 pr_debug("%s: alg disabled\n", __func__
);
1252 wl
->wpa_level
= GELIC_WL_WPA_LEVEL_NONE
;
1253 wl
->group_cipher_method
= GELIC_WL_CIPHER_NONE
;
1254 wl
->pairwise_cipher_method
= GELIC_WL_CIPHER_NONE
;
1255 wl
->auth_method
= GELIC_EURUS_AUTH_OPEN
; /* should be open */
1256 } else if (alg
== IW_ENCODE_ALG_WEP
) {
1257 pr_debug("%s: WEP requested\n", __func__
);
1258 if (flags
& IW_ENCODE_OPEN
) {
1259 pr_debug("%s: open key mode\n", __func__
);
1260 wl
->auth_method
= GELIC_EURUS_AUTH_OPEN
;
1262 if (flags
& IW_ENCODE_RESTRICTED
) {
1263 pr_debug("%s: shared key mode\n", __func__
);
1264 wl
->auth_method
= GELIC_EURUS_AUTH_SHARED
;
1266 if (IW_ENCODING_TOKEN_MAX
< ext
->key_len
) {
1267 pr_info("%s: key is too long %d\n", __func__
,
1272 /* OK, update the key */
1273 wl
->key_len
[key_index
] = ext
->key_len
;
1274 memset(wl
->key
[key_index
], 0, IW_ENCODING_TOKEN_MAX
);
1275 memcpy(wl
->key
[key_index
], ext
->key
, ext
->key_len
);
1276 set_bit(key_index
, &wl
->key_enabled
);
1277 /* remember wep info changed */
1278 set_bit(GELIC_WL_STAT_CONFIGURED
, &wl
->stat
);
1279 } else if (alg
== IW_ENCODE_ALG_PMK
) {
1280 if (ext
->key_len
!= WPA_PSK_LEN
) {
1281 pr_err("%s: PSK length wrong %d\n", __func__
,
1286 memset(wl
->psk
, 0, sizeof(wl
->psk
));
1287 memcpy(wl
->psk
, ext
->key
, ext
->key_len
);
1288 wl
->psk_len
= ext
->key_len
;
1289 wl
->psk_type
= GELIC_EURUS_WPA_PSK_BIN
;
1290 /* remember PSK configured */
1291 set_bit(GELIC_WL_STAT_WPA_PSK_SET
, &wl
->stat
);
1294 spin_unlock_irqrestore(&wl
->lock
, irqflag
);
1295 pr_debug("%s: -> \n", __func__
);
1299 static int gelic_wl_get_encodeext(struct net_device
*netdev
,
1300 struct iw_request_info
*info
,
1301 union iwreq_data
*data
, char *extra
)
1303 struct gelic_wl_info
*wl
= port_wl(netdev_priv(netdev
));
1304 struct iw_point
*enc
= &data
->encoding
;
1305 struct iw_encode_ext
*ext
= (struct iw_encode_ext
*)extra
;
1306 unsigned int irqflag
;
1311 pr_debug("%s: <- \n", __func__
);
1313 max_key_len
= enc
->length
- sizeof(struct iw_encode_ext
);
1314 if (max_key_len
< 0)
1316 key_index
= enc
->flags
& IW_ENCODE_INDEX
;
1318 pr_debug("%s: key_index = %d\n", __func__
, key_index
);
1319 pr_debug("%s: key_len = %d\n", __func__
, enc
->length
);
1320 pr_debug("%s: flag=%x\n", __func__
, enc
->flags
& IW_ENCODE_FLAGS
);
1322 if (GELIC_WEP_KEYS
< key_index
)
1325 spin_lock_irqsave(&wl
->lock
, irqflag
);
1329 key_index
= wl
->current_key
;
1331 memset(ext
, 0, sizeof(struct iw_encode_ext
));
1332 switch (wl
->group_cipher_method
) {
1333 case GELIC_WL_CIPHER_WEP
:
1334 ext
->alg
= IW_ENCODE_ALG_WEP
;
1335 enc
->flags
|= IW_ENCODE_ENABLED
;
1337 case GELIC_WL_CIPHER_TKIP
:
1338 ext
->alg
= IW_ENCODE_ALG_TKIP
;
1339 enc
->flags
|= IW_ENCODE_ENABLED
;
1341 case GELIC_WL_CIPHER_AES
:
1342 ext
->alg
= IW_ENCODE_ALG_CCMP
;
1343 enc
->flags
|= IW_ENCODE_ENABLED
;
1345 case GELIC_WL_CIPHER_NONE
:
1347 ext
->alg
= IW_ENCODE_ALG_NONE
;
1348 enc
->flags
|= IW_ENCODE_NOKEY
;
1352 if (!(enc
->flags
& IW_ENCODE_NOKEY
)) {
1353 if (max_key_len
< wl
->key_len
[key_index
]) {
1357 if (test_bit(key_index
, &wl
->key_enabled
))
1358 memcpy(ext
->key
, wl
->key
[key_index
],
1359 wl
->key_len
[key_index
]);
1361 pr_debug("%s: disabled key requested ix=%d\n",
1362 __func__
, key_index
);
1365 spin_unlock_irqrestore(&wl
->lock
, irqflag
);
1366 pr_debug("%s: -> \n", __func__
);
1369 /* SIOC{S,G}IWMODE */
1370 static int gelic_wl_set_mode(struct net_device
*netdev
,
1371 struct iw_request_info
*info
,
1372 union iwreq_data
*data
, char *extra
)
1374 __u32 mode
= data
->mode
;
1377 pr_debug("%s: <- \n", __func__
);
1378 if (mode
== IW_MODE_INFRA
)
1382 pr_debug("%s: -> %d\n", __func__
, ret
);
1386 static int gelic_wl_get_mode(struct net_device
*netdev
,
1387 struct iw_request_info
*info
,
1388 union iwreq_data
*data
, char *extra
)
1390 __u32
*mode
= &data
->mode
;
1391 pr_debug("%s: <- \n", __func__
);
1392 *mode
= IW_MODE_INFRA
;
1393 pr_debug("%s: ->\n", __func__
);
1397 #ifdef CONFIG_GELIC_WIRELESS_OLD_PSK_INTERFACE
1398 /* SIOCIWFIRSTPRIV */
1399 static int hex2bin(u8
*str
, u8
*bin
, unsigned int len
)
1402 static unsigned char *hex
= "0123456789ABCDEF";
1403 unsigned char *p
, *q
;
1406 if (len
!= WPA_PSK_LEN
* 2)
1409 for (i
= 0; i
< WPA_PSK_LEN
* 2; i
+= 2) {
1410 p
= strchr(hex
, toupper(str
[i
]));
1411 q
= strchr(hex
, toupper(str
[i
+ 1]));
1413 pr_info("%s: unconvertible PSK digit=%d\n",
1417 tmp
= ((p
- hex
) << 4) + (q
- hex
);
1423 static int gelic_wl_priv_set_psk(struct net_device
*net_dev
,
1424 struct iw_request_info
*info
,
1425 union iwreq_data
*data
, char *extra
)
1427 struct gelic_wl_info
*wl
= port_wl(netdev_priv(net_dev
));
1429 unsigned int irqflag
;
1432 pr_debug("%s:<- len=%d\n", __func__
, data
->data
.length
);
1433 len
= data
->data
.length
- 1;
1437 spin_lock_irqsave(&wl
->lock
, irqflag
);
1438 if (extra
[0] == '"' && extra
[len
- 1] == '"') {
1439 pr_debug("%s: passphrase mode\n", __func__
);
1441 if (GELIC_WL_EURUS_PSK_MAX_LEN
< (len
- 2)) {
1442 pr_info("%s: passphrase too long\n", __func__
);
1446 memset(wl
->psk
, 0, sizeof(wl
->psk
));
1447 wl
->psk_len
= len
- 2;
1448 memcpy(wl
->psk
, &(extra
[1]), wl
->psk_len
);
1449 wl
->psk_type
= GELIC_EURUS_WPA_PSK_PASSPHRASE
;
1451 ret
= hex2bin(extra
, wl
->psk
, len
);
1454 wl
->psk_len
= WPA_PSK_LEN
;
1455 wl
->psk_type
= GELIC_EURUS_WPA_PSK_BIN
;
1457 set_bit(GELIC_WL_STAT_WPA_PSK_SET
, &wl
->stat
);
1459 spin_unlock_irqrestore(&wl
->lock
, irqflag
);
1460 pr_debug("%s:->\n", __func__
);
1464 static int gelic_wl_priv_get_psk(struct net_device
*net_dev
,
1465 struct iw_request_info
*info
,
1466 union iwreq_data
*data
, char *extra
)
1468 struct gelic_wl_info
*wl
= port_wl(netdev_priv(net_dev
));
1470 unsigned int irqflag
;
1473 pr_debug("%s:<-\n", __func__
);
1474 if (!capable(CAP_NET_ADMIN
))
1477 spin_lock_irqsave(&wl
->lock
, irqflag
);
1479 if (test_bit(GELIC_WL_STAT_WPA_PSK_SET
, &wl
->stat
)) {
1480 if (wl
->psk_type
== GELIC_EURUS_WPA_PSK_BIN
) {
1481 for (i
= 0; i
< wl
->psk_len
; i
++) {
1482 sprintf(p
, "%02xu", wl
->psk
[i
]);
1486 data
->data
.length
= wl
->psk_len
* 2;
1489 memcpy(p
, wl
->psk
, wl
->psk_len
);
1493 data
->data
.length
= wl
->psk_len
+ 2;
1497 data
->data
.length
= 0;
1498 spin_unlock_irqrestore(&wl
->lock
, irqflag
);
1499 pr_debug("%s:-> %d\n", __func__
, data
->data
.length
);
1505 static int gelic_wl_get_nick(struct net_device
*net_dev
,
1506 struct iw_request_info
*info
,
1507 union iwreq_data
*data
, char *extra
)
1509 strcpy(extra
, "gelic_wl");
1510 data
->data
.length
= strlen(extra
);
1511 data
->data
.flags
= 1;
1518 static struct iw_statistics
*gelic_wl_get_wireless_stats(
1519 struct net_device
*netdev
)
1522 struct gelic_wl_info
*wl
= port_wl(netdev_priv(netdev
));
1523 struct gelic_eurus_cmd
*cmd
;
1524 struct iw_statistics
*is
;
1525 struct gelic_eurus_rssi_info
*rssi
;
1528 pr_debug("%s: <-\n", __func__
);
1530 buf
= (void *)__get_free_page(GFP_KERNEL
);
1535 memset(is
, 0, sizeof(*is
));
1536 cmd
= gelic_eurus_sync_cmd(wl
, GELIC_EURUS_CMD_GET_RSSI_CFG
,
1537 buf
, sizeof(*rssi
));
1538 if (cmd
&& !cmd
->status
&& !cmd
->cmd_status
) {
1540 is
->qual
.level
= be16_to_cpu(rssi
->rssi
);
1541 is
->qual
.updated
= IW_QUAL_LEVEL_UPDATED
|
1542 IW_QUAL_QUAL_INVALID
| IW_QUAL_NOISE_INVALID
;
1544 /* not associated */
1545 is
->qual
.updated
= IW_QUAL_ALL_INVALID
;
1548 free_page((unsigned long)buf
);
1549 pr_debug("%s: ->\n", __func__
);
1556 static int gelic_wl_start_scan(struct gelic_wl_info
*wl
, int always_scan
,
1557 u8
*essid
, size_t essid_len
)
1559 struct gelic_eurus_cmd
*cmd
;
1564 pr_debug("%s: <- always=%d\n", __func__
, always_scan
);
1565 if (mutex_lock_interruptible(&wl
->scan_lock
))
1566 return -ERESTARTSYS
;
1569 * If already a scan in progress, do not trigger more
1571 if (wl
->scan_stat
== GELIC_WL_SCAN_STAT_SCANNING
) {
1572 pr_debug("%s: scanning now\n", __func__
);
1576 init_completion(&wl
->scan_done
);
1578 * If we have already a bss list, don't try to get new
1580 if (!always_scan
&& wl
->scan_stat
== GELIC_WL_SCAN_STAT_GOT_LIST
) {
1581 pr_debug("%s: already has the list\n", __func__
);
1582 complete(&wl
->scan_done
);
1587 if (essid_len
&& essid
) {
1588 buf
= (void *)__get_free_page(GFP_KERNEL
);
1593 len
= IW_ESSID_MAX_SIZE
; /* hypervisor always requires 32 */
1594 memset(buf
, 0, len
);
1595 memcpy(buf
, essid
, essid_len
);
1596 pr_debug("%s: essid scan='%s'\n", __func__
, (char *)buf
);
1601 * issue start scan request
1603 wl
->scan_stat
= GELIC_WL_SCAN_STAT_SCANNING
;
1604 cmd
= gelic_eurus_sync_cmd(wl
, GELIC_EURUS_CMD_START_SCAN
,
1606 if (!cmd
|| cmd
->status
|| cmd
->cmd_status
) {
1607 wl
->scan_stat
= GELIC_WL_SCAN_STAT_INIT
;
1608 complete(&wl
->scan_done
);
1614 free_page((unsigned long)buf
);
1615 mutex_unlock(&wl
->scan_lock
);
1616 pr_debug("%s: ->\n", __func__
);
1621 * retrieve scan result from the chip (hypervisor)
1622 * this function is invoked by schedule work.
1624 static void gelic_wl_scan_complete_event(struct gelic_wl_info
*wl
)
1626 struct gelic_eurus_cmd
*cmd
= NULL
;
1627 struct gelic_wl_scan_info
*target
, *tmp
;
1628 struct gelic_wl_scan_info
*oldest
= NULL
;
1629 struct gelic_eurus_scan_info
*scan_info
;
1630 unsigned int scan_info_size
;
1631 union iwreq_data data
;
1632 unsigned long this_time
= jiffies
;
1633 unsigned int data_len
, i
, found
, r
;
1635 DECLARE_MAC_BUF(mac
);
1637 pr_debug("%s:start\n", __func__
);
1638 mutex_lock(&wl
->scan_lock
);
1640 buf
= (void *)__get_free_page(GFP_KERNEL
);
1642 pr_info("%s: scan buffer alloc failed\n", __func__
);
1646 if (wl
->scan_stat
!= GELIC_WL_SCAN_STAT_SCANNING
) {
1648 * stop() may be called while scanning, ignore result
1650 pr_debug("%s: scan complete when stat != scanning(%d)\n",
1651 __func__
, wl
->scan_stat
);
1655 cmd
= gelic_eurus_sync_cmd(wl
, GELIC_EURUS_CMD_GET_SCAN
,
1657 if (!cmd
|| cmd
->status
|| cmd
->cmd_status
) {
1658 wl
->scan_stat
= GELIC_WL_SCAN_STAT_INIT
;
1659 pr_info("%s:cmd failed\n", __func__
);
1663 data_len
= cmd
->size
;
1664 pr_debug("%s: data_len = %d\n", __func__
, data_len
);
1667 /* OK, bss list retrieved */
1668 wl
->scan_stat
= GELIC_WL_SCAN_STAT_GOT_LIST
;
1670 /* mark all entries are old */
1671 list_for_each_entry_safe(target
, tmp
, &wl
->network_list
, list
) {
1673 /* expire too old entries */
1674 if (time_before(target
->last_scanned
+ wl
->scan_age
,
1676 kfree(target
->hwinfo
);
1677 target
->hwinfo
= NULL
;
1678 list_move_tail(&target
->list
, &wl
->network_free_list
);
1682 /* put them in the newtork_list */
1683 for (i
= 0, scan_info_size
= 0, scan_info
= buf
;
1684 scan_info_size
< data_len
;
1685 i
++, scan_info_size
+= be16_to_cpu(scan_info
->size
),
1686 scan_info
= (void *)scan_info
+ be16_to_cpu(scan_info
->size
)) {
1687 pr_debug("%s:size=%d bssid=%s scan_info=%p\n", __func__
,
1688 be16_to_cpu(scan_info
->size
),
1689 print_mac(mac
, &scan_info
->bssid
[2]), scan_info
);
1692 * The wireless firmware may return invalid channel 0 and/or
1693 * invalid rate if the AP emits zero length SSID ie. As this
1694 * scan information is useless, ignore it
1696 if (!be16_to_cpu(scan_info
->channel
) || !scan_info
->rate
[0]) {
1697 pr_debug("%s: invalid scan info\n", __func__
);
1703 list_for_each_entry(target
, &wl
->network_list
, list
) {
1704 if (!compare_ether_addr(&target
->hwinfo
->bssid
[2],
1705 &scan_info
->bssid
[2])) {
1707 pr_debug("%s: same BBS found scanned list\n",
1712 (target
->last_scanned
< oldest
->last_scanned
))
1717 /* not found in the list */
1718 if (list_empty(&wl
->network_free_list
)) {
1722 target
= list_entry(wl
->network_free_list
.next
,
1723 struct gelic_wl_scan_info
,
1728 /* update the item */
1729 target
->last_scanned
= this_time
;
1731 target
->eurus_index
= i
;
1732 kfree(target
->hwinfo
);
1733 target
->hwinfo
= kzalloc(be16_to_cpu(scan_info
->size
),
1735 if (!target
->hwinfo
) {
1736 pr_info("%s: kzalloc failed\n", __func__
);
1739 /* copy hw scan info */
1740 memcpy(target
->hwinfo
, scan_info
, scan_info
->size
);
1741 target
->essid_len
= strnlen(scan_info
->essid
,
1742 sizeof(scan_info
->essid
));
1743 target
->rate_len
= 0;
1744 for (r
= 0; r
< MAX_RATES_LENGTH
; r
++)
1745 if (scan_info
->rate
[r
])
1747 if (8 < target
->rate_len
)
1748 pr_info("%s: AP returns %d rates\n", __func__
,
1750 target
->rate_ext_len
= 0;
1751 for (r
= 0; r
< MAX_RATES_EX_LENGTH
; r
++)
1752 if (scan_info
->ext_rate
[r
])
1753 target
->rate_ext_len
++;
1754 list_move_tail(&target
->list
, &wl
->network_list
);
1756 memset(&data
, 0, sizeof(data
));
1757 wireless_send_event(port_to_netdev(wl_port(wl
)), SIOCGIWSCAN
, &data
,
1760 free_page((unsigned long)buf
);
1761 complete(&wl
->scan_done
);
1762 mutex_unlock(&wl
->scan_lock
);
1763 pr_debug("%s:end\n", __func__
);
1767 * Select an appropriate bss from current scan list regarding
1768 * current settings from userspace.
1769 * The caller must hold wl->scan_lock,
1770 * and on the state of wl->scan_state == GELIC_WL_SCAN_GOT_LIST
1772 static void update_best(struct gelic_wl_scan_info
**best
,
1773 struct gelic_wl_scan_info
*candid
,
1777 if (*best_weight
< ++(*weight
)) {
1778 *best_weight
= *weight
;
1784 struct gelic_wl_scan_info
*gelic_wl_find_best_bss(struct gelic_wl_info
*wl
)
1786 struct gelic_wl_scan_info
*scan_info
;
1787 struct gelic_wl_scan_info
*best_bss
;
1788 int weight
, best_weight
;
1790 DECLARE_MAC_BUF(mac
);
1792 pr_debug("%s: <-\n", __func__
);
1797 list_for_each_entry(scan_info
, &wl
->network_list
, list
) {
1798 pr_debug("%s: station %p\n", __func__
, scan_info
);
1800 if (!scan_info
->valid
) {
1801 pr_debug("%s: station invalid\n", __func__
);
1805 /* If bss specified, check it only */
1806 if (test_bit(GELIC_WL_STAT_BSSID_SET
, &wl
->stat
)) {
1807 if (!compare_ether_addr(&scan_info
->hwinfo
->bssid
[2],
1809 best_bss
= scan_info
;
1810 pr_debug("%s: bssid matched\n", __func__
);
1813 pr_debug("%s: bssid unmached\n", __func__
);
1821 security
= be16_to_cpu(scan_info
->hwinfo
->security
) &
1822 GELIC_EURUS_SCAN_SEC_MASK
;
1823 if (wl
->wpa_level
== GELIC_WL_WPA_LEVEL_WPA2
) {
1824 if (security
== GELIC_EURUS_SCAN_SEC_WPA2
)
1825 update_best(&best_bss
, scan_info
,
1826 &best_weight
, &weight
);
1829 } else if (wl
->wpa_level
== GELIC_WL_WPA_LEVEL_WPA
) {
1830 if (security
== GELIC_EURUS_SCAN_SEC_WPA
)
1831 update_best(&best_bss
, scan_info
,
1832 &best_weight
, &weight
);
1835 } else if (wl
->wpa_level
== GELIC_WL_WPA_LEVEL_NONE
&&
1836 wl
->group_cipher_method
== GELIC_WL_CIPHER_WEP
) {
1837 if (security
== GELIC_EURUS_SCAN_SEC_WEP
)
1838 update_best(&best_bss
, scan_info
,
1839 &best_weight
, &weight
);
1844 /* If ESSID is set, check it */
1845 if (test_bit(GELIC_WL_STAT_ESSID_SET
, &wl
->stat
)) {
1846 if ((scan_info
->essid_len
== wl
->essid_len
) &&
1848 scan_info
->hwinfo
->essid
,
1849 scan_info
->essid_len
))
1850 update_best(&best_bss
, scan_info
,
1851 &best_weight
, &weight
);
1858 pr_debug("%s: -> bss=%p\n", __func__
, best_bss
);
1860 pr_debug("%s:addr=%s\n", __func__
,
1861 print_mac(mac
, &best_bss
->hwinfo
->bssid
[2]));
1868 * Setup WEP configuration to the chip
1869 * The caller must hold wl->scan_lock,
1870 * and on the state of wl->scan_state == GELIC_WL_SCAN_GOT_LIST
1872 static int gelic_wl_do_wep_setup(struct gelic_wl_info
*wl
)
1875 struct gelic_eurus_wep_cfg
*wep
;
1876 struct gelic_eurus_cmd
*cmd
;
1881 pr_debug("%s: <-\n", __func__
);
1882 /* we can assume no one should uses the buffer */
1883 wep
= (struct gelic_eurus_wep_cfg
*)__get_free_page(GFP_KERNEL
);
1887 memset(wep
, 0, sizeof(*wep
));
1889 if (wl
->group_cipher_method
== GELIC_WL_CIPHER_WEP
) {
1890 pr_debug("%s: WEP mode\n", __func__
);
1891 for (i
= 0; i
< GELIC_WEP_KEYS
; i
++) {
1892 if (!test_bit(i
, &wl
->key_enabled
))
1895 pr_debug("%s: key#%d enabled\n", __func__
, i
);
1897 if (wl
->key_len
[i
] == 13)
1899 else if (wl
->key_len
[i
] != 5) {
1900 pr_info("%s: wrong wep key[%d]=%d\n",
1901 __func__
, i
, wl
->key_len
[i
]);
1905 memcpy(wep
->key
[i
], wl
->key
[i
], wl
->key_len
[i
]);
1909 pr_info("%s: all wep key disabled\n", __func__
);
1915 pr_debug("%s: 104bit key\n", __func__
);
1916 wep
->security
= cpu_to_be16(GELIC_EURUS_WEP_SEC_104BIT
);
1918 pr_debug("%s: 40bit key\n", __func__
);
1919 wep
->security
= cpu_to_be16(GELIC_EURUS_WEP_SEC_40BIT
);
1922 pr_debug("%s: NO encryption\n", __func__
);
1923 wep
->security
= cpu_to_be16(GELIC_EURUS_WEP_SEC_NONE
);
1926 /* issue wep setup */
1927 cmd
= gelic_eurus_sync_cmd(wl
, GELIC_EURUS_CMD_SET_WEP_CFG
,
1931 else if (cmd
->status
|| cmd
->cmd_status
)
1936 free_page((unsigned long)wep
);
1937 pr_debug("%s: ->\n", __func__
);
1942 static const char *wpasecstr(enum gelic_eurus_wpa_security sec
)
1945 case GELIC_EURUS_WPA_SEC_NONE
:
1948 case GELIC_EURUS_WPA_SEC_WPA_TKIP_TKIP
:
1949 return "WPA_TKIP_TKIP";
1951 case GELIC_EURUS_WPA_SEC_WPA_TKIP_AES
:
1952 return "WPA_TKIP_AES";
1954 case GELIC_EURUS_WPA_SEC_WPA_AES_AES
:
1955 return "WPA_AES_AES";
1957 case GELIC_EURUS_WPA_SEC_WPA2_TKIP_TKIP
:
1958 return "WPA2_TKIP_TKIP";
1960 case GELIC_EURUS_WPA_SEC_WPA2_TKIP_AES
:
1961 return "WPA2_TKIP_AES";
1963 case GELIC_EURUS_WPA_SEC_WPA2_AES_AES
:
1964 return "WPA2_AES_AES";
1971 static int gelic_wl_do_wpa_setup(struct gelic_wl_info
*wl
)
1973 struct gelic_eurus_wpa_cfg
*wpa
;
1974 struct gelic_eurus_cmd
*cmd
;
1978 pr_debug("%s: <-\n", __func__
);
1979 /* we can assume no one should uses the buffer */
1980 wpa
= (struct gelic_eurus_wpa_cfg
*)__get_free_page(GFP_KERNEL
);
1984 memset(wpa
, 0, sizeof(*wpa
));
1986 if (!test_bit(GELIC_WL_STAT_WPA_PSK_SET
, &wl
->stat
))
1987 pr_info("%s: PSK not configured yet\n", __func__
);
1990 memcpy(wpa
->psk
, wl
->psk
, wl
->psk_len
);
1992 /* set security level */
1993 if (wl
->wpa_level
== GELIC_WL_WPA_LEVEL_WPA2
) {
1994 if (wl
->group_cipher_method
== GELIC_WL_CIPHER_AES
) {
1995 security
= GELIC_EURUS_WPA_SEC_WPA2_AES_AES
;
1997 if (wl
->pairwise_cipher_method
== GELIC_WL_CIPHER_AES
&&
1999 security
= GELIC_EURUS_WPA_SEC_WPA2_TKIP_AES
;
2001 security
= GELIC_EURUS_WPA_SEC_WPA2_TKIP_TKIP
;
2004 if (wl
->group_cipher_method
== GELIC_WL_CIPHER_AES
) {
2005 security
= GELIC_EURUS_WPA_SEC_WPA_AES_AES
;
2007 if (wl
->pairwise_cipher_method
== GELIC_WL_CIPHER_AES
&&
2009 security
= GELIC_EURUS_WPA_SEC_WPA_TKIP_AES
;
2011 security
= GELIC_EURUS_WPA_SEC_WPA_TKIP_TKIP
;
2014 wpa
->security
= cpu_to_be16(security
);
2017 wpa
->psk_type
= cpu_to_be16(wl
->psk_type
);
2019 pr_debug("%s: sec=%s psktype=%s\nn", __func__
,
2020 wpasecstr(wpa
->security
),
2021 (wpa
->psk_type
== GELIC_EURUS_WPA_PSK_BIN
) ?
2022 "BIN" : "passphrase");
2025 * don't enable here if you plan to submit
2026 * the debug log because this dumps your precious
2029 pr_debug("%s: psk=%s\n",
2030 (wpa
->psk_type
== GELIC_EURUS_WPA_PSK_BIN
) ?
2031 (char *)"N/A" : (char *)wpa
->psk
);
2034 /* issue wpa setup */
2035 cmd
= gelic_eurus_sync_cmd(wl
, GELIC_EURUS_CMD_SET_WPA_CFG
,
2039 else if (cmd
->status
|| cmd
->cmd_status
)
2042 free_page((unsigned long)wpa
);
2043 pr_debug("%s: --> %d\n", __func__
, ret
);
2048 * Start association. caller must hold assoc_stat_lock
2050 static int gelic_wl_associate_bss(struct gelic_wl_info
*wl
,
2051 struct gelic_wl_scan_info
*bss
)
2053 struct gelic_eurus_cmd
*cmd
;
2054 struct gelic_eurus_common_cfg
*common
;
2058 pr_debug("%s: <-\n", __func__
);
2060 /* do common config */
2061 common
= (struct gelic_eurus_common_cfg
*)__get_free_page(GFP_KERNEL
);
2065 memset(common
, 0, sizeof(*common
));
2066 common
->bss_type
= cpu_to_be16(GELIC_EURUS_BSS_INFRA
);
2067 common
->op_mode
= cpu_to_be16(GELIC_EURUS_OPMODE_11BG
);
2069 common
->scan_index
= cpu_to_be16(bss
->eurus_index
);
2070 switch (wl
->auth_method
) {
2071 case GELIC_EURUS_AUTH_OPEN
:
2072 common
->auth_method
= cpu_to_be16(GELIC_EURUS_AUTH_OPEN
);
2074 case GELIC_EURUS_AUTH_SHARED
:
2075 common
->auth_method
= cpu_to_be16(GELIC_EURUS_AUTH_SHARED
);
2082 pr_debug("%s: common cfg index=%d bsstype=%d auth=%d\n", __func__
,
2083 be16_to_cpu(common
->scan_index
),
2084 be16_to_cpu(common
->bss_type
),
2085 be16_to_cpu(common
->auth_method
));
2087 cmd
= gelic_eurus_sync_cmd(wl
, GELIC_EURUS_CMD_SET_COMMON_CFG
,
2088 common
, sizeof(*common
));
2089 if (!cmd
|| cmd
->status
|| cmd
->cmd_status
) {
2097 switch (wl
->wpa_level
) {
2098 case GELIC_WL_WPA_LEVEL_NONE
:
2099 /* If WEP or no security, setup WEP config */
2100 ret
= gelic_wl_do_wep_setup(wl
);
2102 case GELIC_WL_WPA_LEVEL_WPA
:
2103 case GELIC_WL_WPA_LEVEL_WPA2
:
2104 ret
= gelic_wl_do_wpa_setup(wl
);
2109 pr_debug("%s: WEP/WPA setup failed %d\n", __func__
,
2113 /* start association */
2114 init_completion(&wl
->assoc_done
);
2115 wl
->assoc_stat
= GELIC_WL_ASSOC_STAT_ASSOCIATING
;
2116 cmd
= gelic_eurus_sync_cmd(wl
, GELIC_EURUS_CMD_ASSOC
,
2118 if (!cmd
|| cmd
->status
|| cmd
->cmd_status
) {
2119 pr_debug("%s: assoc request failed\n", __func__
);
2120 wl
->assoc_stat
= GELIC_WL_ASSOC_STAT_DISCONN
;
2123 gelic_wl_send_iwap_event(wl
, NULL
);
2128 /* wait for connected event */
2129 rc
= wait_for_completion_timeout(&wl
->assoc_done
, HZ
* 4);/*FIXME*/
2132 /* timeouted. Maybe key or cyrpt mode is wrong */
2133 pr_info("%s: connect timeout \n", __func__
);
2134 cmd
= gelic_eurus_sync_cmd(wl
, GELIC_EURUS_CMD_DISASSOC
,
2137 wl
->assoc_stat
= GELIC_WL_ASSOC_STAT_DISCONN
;
2138 gelic_wl_send_iwap_event(wl
, NULL
);
2141 wl
->assoc_stat
= GELIC_WL_ASSOC_STAT_ASSOCIATED
;
2143 memcpy(wl
->active_bssid
, &bss
->hwinfo
->bssid
[2], ETH_ALEN
);
2145 /* send connect event */
2146 gelic_wl_send_iwap_event(wl
, wl
->active_bssid
);
2147 pr_info("%s: connected\n", __func__
);
2150 free_page((unsigned long)common
);
2151 pr_debug("%s: ->\n", __func__
);
2158 static void gelic_wl_connected_event(struct gelic_wl_info
*wl
,
2161 u64 desired_event
= 0;
2163 switch (wl
->wpa_level
) {
2164 case GELIC_WL_WPA_LEVEL_NONE
:
2165 desired_event
= GELIC_LV1_WL_EVENT_CONNECTED
;
2167 case GELIC_WL_WPA_LEVEL_WPA
:
2168 case GELIC_WL_WPA_LEVEL_WPA2
:
2169 desired_event
= GELIC_LV1_WL_EVENT_WPA_CONNECTED
;
2173 if (desired_event
== event
) {
2174 pr_debug("%s: completed \n", __func__
);
2175 complete(&wl
->assoc_done
);
2176 netif_carrier_on(port_to_netdev(wl_port(wl
)));
2178 pr_debug("%s: event %#lx under wpa\n",
2185 static void gelic_wl_disconnect_event(struct gelic_wl_info
*wl
,
2188 struct gelic_eurus_cmd
*cmd
;
2192 * If we fall here in the middle of association,
2193 * associate_bss() should be waiting for complation of
2195 * As it waits with timeout, just leave assoc_done
2196 * uncompleted, then it terminates with timeout
2198 if (!mutex_trylock(&wl
->assoc_stat_lock
)) {
2199 pr_debug("%s: already locked\n", __func__
);
2202 pr_debug("%s: obtain lock\n", __func__
);
2206 cmd
= gelic_eurus_sync_cmd(wl
, GELIC_EURUS_CMD_DISASSOC
, NULL
, 0);
2209 /* send disconnected event to the supplicant */
2210 if (wl
->assoc_stat
== GELIC_WL_ASSOC_STAT_ASSOCIATED
)
2211 gelic_wl_send_iwap_event(wl
, NULL
);
2213 wl
->assoc_stat
= GELIC_WL_ASSOC_STAT_DISCONN
;
2214 netif_carrier_off(port_to_netdev(wl_port(wl
)));
2217 mutex_unlock(&wl
->assoc_stat_lock
);
2223 static const char *eventstr(enum gelic_lv1_wl_event event
)
2225 static char buf
[32];
2227 if (event
& GELIC_LV1_WL_EVENT_DEVICE_READY
)
2228 ret
= "EURUS_READY";
2229 else if (event
& GELIC_LV1_WL_EVENT_SCAN_COMPLETED
)
2230 ret
= "SCAN_COMPLETED";
2231 else if (event
& GELIC_LV1_WL_EVENT_DEAUTH
)
2233 else if (event
& GELIC_LV1_WL_EVENT_BEACON_LOST
)
2234 ret
= "BEACON_LOST";
2235 else if (event
& GELIC_LV1_WL_EVENT_CONNECTED
)
2237 else if (event
& GELIC_LV1_WL_EVENT_WPA_CONNECTED
)
2238 ret
= "WPA_CONNECTED";
2239 else if (event
& GELIC_LV1_WL_EVENT_WPA_ERROR
)
2242 sprintf(buf
, "Unknown(%#x)", event
);
2248 static const char *eventstr(enum gelic_lv1_wl_event event
)
2253 static void gelic_wl_event_worker(struct work_struct
*work
)
2255 struct gelic_wl_info
*wl
;
2256 struct gelic_port
*port
;
2260 pr_debug("%s:start\n", __func__
);
2261 wl
= container_of(work
, struct gelic_wl_info
, event_work
.work
);
2264 status
= lv1_net_control(bus_id(port
->card
), dev_id(port
->card
),
2265 GELIC_LV1_GET_WLAN_EVENT
, 0, 0, 0,
2268 if (status
!= LV1_NO_ENTRY
)
2269 pr_debug("%s:wlan event failed %d\n",
2271 /* got all events */
2272 pr_debug("%s:end\n", __func__
);
2275 pr_debug("%s: event=%s\n", __func__
, eventstr(event
));
2277 case GELIC_LV1_WL_EVENT_SCAN_COMPLETED
:
2278 gelic_wl_scan_complete_event(wl
);
2280 case GELIC_LV1_WL_EVENT_BEACON_LOST
:
2281 case GELIC_LV1_WL_EVENT_DEAUTH
:
2282 gelic_wl_disconnect_event(wl
, event
);
2284 case GELIC_LV1_WL_EVENT_CONNECTED
:
2285 case GELIC_LV1_WL_EVENT_WPA_CONNECTED
:
2286 gelic_wl_connected_event(wl
, event
);
2294 * association worker
2296 static void gelic_wl_assoc_worker(struct work_struct
*work
)
2298 struct gelic_wl_info
*wl
;
2300 struct gelic_wl_scan_info
*best_bss
;
2302 unsigned long irqflag
;
2306 wl
= container_of(work
, struct gelic_wl_info
, assoc_work
.work
);
2308 mutex_lock(&wl
->assoc_stat_lock
);
2310 if (wl
->assoc_stat
!= GELIC_WL_ASSOC_STAT_DISCONN
)
2313 spin_lock_irqsave(&wl
->lock
, irqflag
);
2314 if (test_bit(GELIC_WL_STAT_ESSID_SET
, &wl
->stat
)) {
2315 pr_debug("%s: assoc ESSID configured %s\n", __func__
,
2318 essid_len
= wl
->essid_len
;
2323 spin_unlock_irqrestore(&wl
->lock
, irqflag
);
2325 ret
= gelic_wl_start_scan(wl
, 0, essid
, essid_len
);
2326 if (ret
== -ERESTARTSYS
) {
2327 pr_debug("%s: scan start failed association\n", __func__
);
2328 schedule_delayed_work(&wl
->assoc_work
, HZ
/10); /*FIXME*/
2331 pr_info("%s: scan prerequisite failed\n", __func__
);
2336 * Wait for bss scan completion
2337 * If we have scan list already, gelic_wl_start_scan()
2338 * returns OK and raises the complete. Thus,
2339 * it's ok to wait unconditionally here
2341 wait_for_completion(&wl
->scan_done
);
2343 pr_debug("%s: scan done\n", __func__
);
2344 mutex_lock(&wl
->scan_lock
);
2345 if (wl
->scan_stat
!= GELIC_WL_SCAN_STAT_GOT_LIST
) {
2346 gelic_wl_send_iwap_event(wl
, NULL
);
2347 pr_info("%s: no scan list. association failed\n", __func__
);
2351 /* find best matching bss */
2352 best_bss
= gelic_wl_find_best_bss(wl
);
2354 gelic_wl_send_iwap_event(wl
, NULL
);
2355 pr_info("%s: no bss matched. association failed\n", __func__
);
2359 /* ok, do association */
2360 ret
= gelic_wl_associate_bss(wl
, best_bss
);
2362 pr_info("%s: association failed %d\n", __func__
, ret
);
2364 mutex_unlock(&wl
->scan_lock
);
2366 mutex_unlock(&wl
->assoc_stat_lock
);
2370 * Called from the ethernet interrupt handler
2371 * Processes wireless specific virtual interrupts only
2373 void gelic_wl_interrupt(struct net_device
*netdev
, u64 status
)
2375 struct gelic_wl_info
*wl
= port_wl(netdev_priv(netdev
));
2377 if (status
& GELIC_CARD_WLAN_COMMAND_COMPLETED
) {
2378 pr_debug("%s:cmd complete\n", __func__
);
2379 complete(&wl
->cmd_done_intr
);
2382 if (status
& GELIC_CARD_WLAN_EVENT_RECEIVED
) {
2383 pr_debug("%s:event received\n", __func__
);
2384 queue_delayed_work(wl
->event_queue
, &wl
->event_work
, 0);
2391 #define IW_IOCTL(n) [(n) - SIOCSIWCOMMIT]
2392 static const iw_handler gelic_wl_wext_handler
[] =
2394 IW_IOCTL(SIOCGIWNAME
) = gelic_wl_get_name
,
2395 IW_IOCTL(SIOCGIWRANGE
) = gelic_wl_get_range
,
2396 IW_IOCTL(SIOCSIWSCAN
) = gelic_wl_set_scan
,
2397 IW_IOCTL(SIOCGIWSCAN
) = gelic_wl_get_scan
,
2398 IW_IOCTL(SIOCSIWAUTH
) = gelic_wl_set_auth
,
2399 IW_IOCTL(SIOCGIWAUTH
) = gelic_wl_get_auth
,
2400 IW_IOCTL(SIOCSIWESSID
) = gelic_wl_set_essid
,
2401 IW_IOCTL(SIOCGIWESSID
) = gelic_wl_get_essid
,
2402 IW_IOCTL(SIOCSIWENCODE
) = gelic_wl_set_encode
,
2403 IW_IOCTL(SIOCGIWENCODE
) = gelic_wl_get_encode
,
2404 IW_IOCTL(SIOCSIWAP
) = gelic_wl_set_ap
,
2405 IW_IOCTL(SIOCGIWAP
) = gelic_wl_get_ap
,
2406 IW_IOCTL(SIOCSIWENCODEEXT
) = gelic_wl_set_encodeext
,
2407 IW_IOCTL(SIOCGIWENCODEEXT
) = gelic_wl_get_encodeext
,
2408 IW_IOCTL(SIOCSIWMODE
) = gelic_wl_set_mode
,
2409 IW_IOCTL(SIOCGIWMODE
) = gelic_wl_get_mode
,
2410 IW_IOCTL(SIOCGIWNICKN
) = gelic_wl_get_nick
,
2413 #ifdef CONFIG_GELIC_WIRELESS_OLD_PSK_INTERFACE
2414 static struct iw_priv_args gelic_wl_private_args
[] =
2417 .cmd
= GELIC_WL_PRIV_SET_PSK
,
2418 .set_args
= IW_PRIV_TYPE_CHAR
|
2419 (GELIC_WL_EURUS_PSK_MAX_LEN
+ 2),
2423 .cmd
= GELIC_WL_PRIV_GET_PSK
,
2424 .get_args
= IW_PRIV_TYPE_CHAR
|
2425 (GELIC_WL_EURUS_PSK_MAX_LEN
+ 2),
2430 static const iw_handler gelic_wl_private_handler
[] =
2432 gelic_wl_priv_set_psk
,
2433 gelic_wl_priv_get_psk
,
2437 static const struct iw_handler_def gelic_wl_wext_handler_def
= {
2438 .num_standard
= ARRAY_SIZE(gelic_wl_wext_handler
),
2439 .standard
= gelic_wl_wext_handler
,
2440 .get_wireless_stats
= gelic_wl_get_wireless_stats
,
2441 #ifdef CONFIG_GELIC_WIRELESS_OLD_PSK_INTERFACE
2442 .num_private
= ARRAY_SIZE(gelic_wl_private_handler
),
2443 .num_private_args
= ARRAY_SIZE(gelic_wl_private_args
),
2444 .private = gelic_wl_private_handler
,
2445 .private_args
= gelic_wl_private_args
,
2449 static struct net_device
*gelic_wl_alloc(struct gelic_card
*card
)
2451 struct net_device
*netdev
;
2452 struct gelic_port
*port
;
2453 struct gelic_wl_info
*wl
;
2456 pr_debug("%s:start\n", __func__
);
2457 netdev
= alloc_etherdev(sizeof(struct gelic_port
) +
2458 sizeof(struct gelic_wl_info
));
2459 pr_debug("%s: netdev =%p card=%p \np", __func__
, netdev
, card
);
2463 strcpy(netdev
->name
, "wlan%d");
2465 port
= netdev_priv(netdev
);
2466 port
->netdev
= netdev
;
2468 port
->type
= GELIC_PORT_WIRELESS
;
2471 pr_debug("%s: wl=%p port=%p\n", __func__
, wl
, port
);
2473 /* allocate scan list */
2474 wl
->networks
= kzalloc(sizeof(struct gelic_wl_scan_info
) *
2475 GELIC_WL_BSS_MAX_ENT
, GFP_KERNEL
);
2480 wl
->eurus_cmd_queue
= create_singlethread_workqueue("gelic_cmd");
2481 if (!wl
->eurus_cmd_queue
)
2482 goto fail_cmd_workqueue
;
2484 wl
->event_queue
= create_singlethread_workqueue("gelic_event");
2485 if (!wl
->event_queue
)
2486 goto fail_event_workqueue
;
2488 INIT_LIST_HEAD(&wl
->network_free_list
);
2489 INIT_LIST_HEAD(&wl
->network_list
);
2490 for (i
= 0; i
< GELIC_WL_BSS_MAX_ENT
; i
++)
2491 list_add_tail(&wl
->networks
[i
].list
,
2492 &wl
->network_free_list
);
2493 init_completion(&wl
->cmd_done_intr
);
2495 INIT_DELAYED_WORK(&wl
->event_work
, gelic_wl_event_worker
);
2496 INIT_DELAYED_WORK(&wl
->assoc_work
, gelic_wl_assoc_worker
);
2497 mutex_init(&wl
->scan_lock
);
2498 mutex_init(&wl
->assoc_stat_lock
);
2500 init_completion(&wl
->scan_done
);
2501 /* for the case that no scan request is issued and stop() is called */
2502 complete(&wl
->scan_done
);
2504 spin_lock_init(&wl
->lock
);
2506 wl
->scan_age
= 5*HZ
; /* FIXME */
2508 /* buffer for receiving scanned list etc */
2509 BUILD_BUG_ON(PAGE_SIZE
<
2510 sizeof(struct gelic_eurus_scan_info
) *
2511 GELIC_EURUS_MAX_SCAN
);
2512 pr_debug("%s:end\n", __func__
);
2515 fail_event_workqueue
:
2516 destroy_workqueue(wl
->eurus_cmd_queue
);
2518 kfree(wl
->networks
);
2520 free_netdev(netdev
);
2521 pr_debug("%s:end error\n", __func__
);
2526 static void gelic_wl_free(struct gelic_wl_info
*wl
)
2528 struct gelic_wl_scan_info
*scan_info
;
2531 pr_debug("%s: <-\n", __func__
);
2533 pr_debug("%s: destroy queues\n", __func__
);
2534 destroy_workqueue(wl
->eurus_cmd_queue
);
2535 destroy_workqueue(wl
->event_queue
);
2537 scan_info
= wl
->networks
;
2538 for (i
= 0; i
< GELIC_WL_BSS_MAX_ENT
; i
++, scan_info
++)
2539 kfree(scan_info
->hwinfo
);
2540 kfree(wl
->networks
);
2542 free_netdev(port_to_netdev(wl_port(wl
)));
2544 pr_debug("%s: ->\n", __func__
);
2547 static int gelic_wl_try_associate(struct net_device
*netdev
)
2549 struct gelic_wl_info
*wl
= port_wl(netdev_priv(netdev
));
2553 pr_debug("%s: <-\n", __func__
);
2555 /* check constraits for start association */
2556 /* for no access restriction AP */
2557 if (wl
->group_cipher_method
== GELIC_WL_CIPHER_NONE
) {
2558 if (test_bit(GELIC_WL_STAT_CONFIGURED
,
2562 pr_debug("%s: no wep, not configured\n", __func__
);
2567 /* for WEP, one of four keys should be set */
2568 if (wl
->group_cipher_method
== GELIC_WL_CIPHER_WEP
) {
2569 /* one of keys set */
2570 for (i
= 0; i
< GELIC_WEP_KEYS
; i
++) {
2571 if (test_bit(i
, &wl
->key_enabled
))
2574 pr_debug("%s: WEP, but no key specified\n", __func__
);
2578 /* for WPA[2], psk should be set */
2579 if ((wl
->group_cipher_method
== GELIC_WL_CIPHER_TKIP
) ||
2580 (wl
->group_cipher_method
== GELIC_WL_CIPHER_AES
)) {
2581 if (test_bit(GELIC_WL_STAT_WPA_PSK_SET
,
2585 pr_debug("%s: AES/TKIP, but PSK not configured\n",
2592 ret
= schedule_delayed_work(&wl
->assoc_work
, 0);
2593 pr_debug("%s: start association work %d\n", __func__
, ret
);
2600 static int gelic_wl_open(struct net_device
*netdev
)
2602 struct gelic_card
*card
= netdev_card(netdev
);
2604 pr_debug("%s:->%p\n", __func__
, netdev
);
2606 gelic_card_up(card
);
2608 /* try to associate */
2609 gelic_wl_try_associate(netdev
);
2611 netif_start_queue(netdev
);
2613 pr_debug("%s:<-\n", __func__
);
2618 * reset state machine
2620 static int gelic_wl_reset_state(struct gelic_wl_info
*wl
)
2622 struct gelic_wl_scan_info
*target
;
2623 struct gelic_wl_scan_info
*tmp
;
2625 /* empty scan list */
2626 list_for_each_entry_safe(target
, tmp
, &wl
->network_list
, list
) {
2627 list_move_tail(&target
->list
, &wl
->network_free_list
);
2629 wl
->scan_stat
= GELIC_WL_SCAN_STAT_INIT
;
2631 /* clear configuration */
2632 wl
->auth_method
= GELIC_EURUS_AUTH_OPEN
;
2633 wl
->group_cipher_method
= GELIC_WL_CIPHER_NONE
;
2634 wl
->pairwise_cipher_method
= GELIC_WL_CIPHER_NONE
;
2635 wl
->wpa_level
= GELIC_WL_WPA_LEVEL_NONE
;
2637 wl
->key_enabled
= 0;
2638 wl
->current_key
= 0;
2640 wl
->psk_type
= GELIC_EURUS_WPA_PSK_PASSPHRASE
;
2644 memset(wl
->essid
, 0, sizeof(wl
->essid
));
2645 memset(wl
->bssid
, 0, sizeof(wl
->bssid
));
2646 memset(wl
->active_bssid
, 0, sizeof(wl
->active_bssid
));
2648 wl
->assoc_stat
= GELIC_WL_ASSOC_STAT_DISCONN
;
2650 memset(&wl
->iwstat
, 0, sizeof(wl
->iwstat
));
2651 /* all status bit clear */
2657 * Tell eurus to terminate association
2659 static void gelic_wl_disconnect(struct net_device
*netdev
)
2661 struct gelic_port
*port
= netdev_priv(netdev
);
2662 struct gelic_wl_info
*wl
= port_wl(port
);
2663 struct gelic_eurus_cmd
*cmd
;
2666 * If scann process is running on chip,
2667 * further requests will be rejected
2669 if (wl
->scan_stat
== GELIC_WL_SCAN_STAT_SCANNING
)
2670 wait_for_completion_timeout(&wl
->scan_done
, HZ
);
2672 cmd
= gelic_eurus_sync_cmd(wl
, GELIC_EURUS_CMD_DISASSOC
, NULL
, 0);
2674 gelic_wl_send_iwap_event(wl
, NULL
);
2677 static int gelic_wl_stop(struct net_device
*netdev
)
2679 struct gelic_port
*port
= netdev_priv(netdev
);
2680 struct gelic_wl_info
*wl
= port_wl(port
);
2681 struct gelic_card
*card
= netdev_card(netdev
);
2683 pr_debug("%s:<-\n", __func__
);
2686 * Cancel pending association work.
2687 * event work can run after netdev down
2689 cancel_delayed_work(&wl
->assoc_work
);
2691 if (wl
->assoc_stat
== GELIC_WL_ASSOC_STAT_ASSOCIATED
)
2692 gelic_wl_disconnect(netdev
);
2694 /* reset our state machine */
2695 gelic_wl_reset_state(wl
);
2697 netif_stop_queue(netdev
);
2699 gelic_card_down(card
);
2701 pr_debug("%s:->\n", __func__
);
2707 static struct ethtool_ops gelic_wl_ethtool_ops
= {
2708 .get_drvinfo
= gelic_net_get_drvinfo
,
2709 .get_link
= gelic_wl_get_link
,
2710 .get_tx_csum
= ethtool_op_get_tx_csum
,
2711 .set_tx_csum
= ethtool_op_set_tx_csum
,
2712 .get_rx_csum
= gelic_net_get_rx_csum
,
2713 .set_rx_csum
= gelic_net_set_rx_csum
,
2716 static void gelic_wl_setup_netdev_ops(struct net_device
*netdev
)
2718 struct gelic_wl_info
*wl
;
2719 wl
= port_wl(netdev_priv(netdev
));
2721 netdev
->open
= &gelic_wl_open
;
2722 netdev
->stop
= &gelic_wl_stop
;
2723 netdev
->hard_start_xmit
= &gelic_net_xmit
;
2724 netdev
->set_multicast_list
= &gelic_net_set_multi
;
2725 netdev
->change_mtu
= &gelic_net_change_mtu
;
2726 netdev
->wireless_data
= &wl
->wireless_data
;
2727 netdev
->wireless_handlers
= &gelic_wl_wext_handler_def
;
2729 netdev
->tx_timeout
= &gelic_net_tx_timeout
;
2730 netdev
->watchdog_timeo
= GELIC_NET_WATCHDOG_TIMEOUT
;
2732 netdev
->ethtool_ops
= &gelic_wl_ethtool_ops
;
2733 #ifdef CONFIG_NET_POLL_CONTROLLER
2734 netdev
->poll_controller
= gelic_net_poll_controller
;
2739 * driver probe/remove
2741 int gelic_wl_driver_probe(struct gelic_card
*card
)
2744 struct net_device
*netdev
;
2746 pr_debug("%s:start\n", __func__
);
2748 if (ps3_compare_firmware_version(1, 6, 0) < 0)
2750 if (!card
->vlan
[GELIC_PORT_WIRELESS
].tx
)
2753 /* alloc netdevice for wireless */
2754 netdev
= gelic_wl_alloc(card
);
2758 /* setup net_device structure */
2759 SET_NETDEV_DEV(netdev
, &card
->dev
->core
);
2760 gelic_wl_setup_netdev_ops(netdev
);
2762 /* setup some of net_device and register it */
2763 ret
= gelic_net_setup_netdev(netdev
, card
);
2766 card
->netdev
[GELIC_PORT_WIRELESS
] = netdev
;
2768 /* add enable wireless interrupt */
2769 card
->irq_mask
|= GELIC_CARD_WLAN_EVENT_RECEIVED
|
2770 GELIC_CARD_WLAN_COMMAND_COMPLETED
;
2771 /* to allow wireless commands while both interfaces are down */
2772 gelic_card_set_irq_mask(card
, GELIC_CARD_WLAN_EVENT_RECEIVED
|
2773 GELIC_CARD_WLAN_COMMAND_COMPLETED
);
2774 pr_debug("%s:end\n", __func__
);
2778 gelic_wl_free(port_wl(netdev_port(netdev
)));
2783 int gelic_wl_driver_remove(struct gelic_card
*card
)
2785 struct gelic_wl_info
*wl
;
2786 struct net_device
*netdev
;
2788 pr_debug("%s:start\n", __func__
);
2790 if (ps3_compare_firmware_version(1, 6, 0) < 0)
2792 if (!card
->vlan
[GELIC_PORT_WIRELESS
].tx
)
2795 netdev
= card
->netdev
[GELIC_PORT_WIRELESS
];
2796 wl
= port_wl(netdev_priv(netdev
));
2798 /* if the interface was not up, but associated */
2799 if (wl
->assoc_stat
== GELIC_WL_ASSOC_STAT_ASSOCIATED
)
2800 gelic_wl_disconnect(netdev
);
2802 complete(&wl
->cmd_done_intr
);
2804 /* cancel all work queue */
2805 cancel_delayed_work(&wl
->assoc_work
);
2806 cancel_delayed_work(&wl
->event_work
);
2807 flush_workqueue(wl
->eurus_cmd_queue
);
2808 flush_workqueue(wl
->event_queue
);
2810 unregister_netdev(netdev
);
2812 /* disable wireless interrupt */
2813 pr_debug("%s: disable intr\n", __func__
);
2814 card
->irq_mask
&= ~(GELIC_CARD_WLAN_EVENT_RECEIVED
|
2815 GELIC_CARD_WLAN_COMMAND_COMPLETED
);
2816 /* free bss list, netdev*/
2818 pr_debug("%s:end\n", __func__
);