2 * WL3501 Wireless LAN PCMCIA Card Driver for Linux
3 * Written originally for Linux 2.0.30 by Fox Chen, mhchen@golf.ccl.itri.org.tw
4 * Ported to 2.2, 2.4 & 2.5 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
5 * Wireless extensions in 2.4 by Gustavo Niemeyer <niemeyer@conectiva.com>
7 * References used by Fox Chen while writing the original driver for 2.0.30:
9 * 1. WL24xx packet drivers (tooasm.asm)
10 * 2. Access Point Firmware Interface Specification for IEEE 802.11 SUTRO
12 * 4. Linux network driver (/usr/src/linux/drivers/net)
13 * 5. ISA card driver - wl24.c
14 * 6. Linux PCMCIA skeleton driver - skeleton.c
15 * 7. Linux PCMCIA 3c589 network driver - 3c589_cs.c
17 * Tested with WL2400 firmware 1.2, Linux 2.0.30, and pcmcia-cs-2.9.12
18 * 1. Performance: about 165 Kbytes/sec in TCP/IP with Ad-Hoc mode.
19 * rsh 192.168.1.3 "dd if=/dev/zero bs=1k count=1000" > /dev/null
20 * (Specification 2M bits/sec. is about 250 Kbytes/sec., but we must deduct
21 * ETHER/IP/UDP/TCP header, and acknowledgement overhead)
23 * Tested with Planet AP in 2.4.17, 184 Kbytes/s in UDP in Infrastructure mode,
24 * 173 Kbytes/s in TCP.
26 * Tested with Planet AP in 2.5.73-bk, 216 Kbytes/s in Infrastructure mode
27 * with a SMP machine (dual pentium 100), using pktgen, 432 pps (pkt_size = 60)
30 #include <linux/delay.h>
31 #include <linux/types.h>
32 #include <linux/ethtool.h>
33 #include <linux/init.h>
34 #include <linux/interrupt.h>
36 #include <linux/kernel.h>
37 #include <linux/module.h>
38 #include <linux/fcntl.h>
39 #include <linux/if_arp.h>
40 #include <linux/ioport.h>
41 #include <linux/netdevice.h>
42 #include <linux/etherdevice.h>
43 #include <linux/skbuff.h>
44 #include <linux/slab.h>
45 #include <linux/string.h>
46 #include <linux/wireless.h>
48 #include <net/iw_handler.h>
50 #include <pcmcia/cs_types.h>
51 #include <pcmcia/cs.h>
52 #include <pcmcia/cistpl.h>
53 #include <pcmcia/cisreg.h>
54 #include <pcmcia/ds.h>
57 #include <asm/uaccess.h>
58 #include <asm/system.h>
63 #define slow_down_io()
66 /* For rough constant delay */
67 #define WL3501_NOPLOOP(n) { int x = 0; while (x++ < n) slow_down_io(); }
70 * All the PCMCIA modules use PCMCIA_DEBUG to control debugging. If you do not
71 * define PCMCIA_DEBUG at all, all the debug code will be left out. If you
72 * compile with PCMCIA_DEBUG=0, the debug code will be present but disabled --
73 * but it can then be enabled for specific modules at load time with a
74 * 'pc_debug=#' option to insmod.
76 #define PCMCIA_DEBUG 0
78 static int pc_debug
= PCMCIA_DEBUG
;
79 module_param(pc_debug
, int, 0);
80 #define dprintk(n, format, args...) \
81 { if (pc_debug > (n)) \
82 printk(KERN_INFO "%s: " format "\n", __FUNCTION__ , ##args); }
84 #define dprintk(n, format, args...)
87 #define wl3501_outb(a, b) { outb(a, b); slow_down_io(); }
88 #define wl3501_outb_p(a, b) { outb_p(a, b); slow_down_io(); }
89 #define wl3501_outsb(a, b, c) { outsb(a, b, c); slow_down_io(); }
91 #define WL3501_RELEASE_TIMEOUT (25 * HZ)
92 #define WL3501_MAX_ADHOC_TRIES 16
94 #define WL3501_RESUME 0
95 #define WL3501_SUSPEND 1
98 * The event() function is this driver's Card Services event handler. It will
99 * be called by Card Services when an appropriate card status event is
100 * received. The config() and release() entry points are used to configure or
101 * release a socket, in response to card insertion and ejection events. They
102 * are invoked from the wl24 event handler.
104 static int wl3501_config(struct pcmcia_device
*link
);
105 static void wl3501_release(struct pcmcia_device
*link
);
108 * The dev_info variable is the "key" that is used to match up this
109 * device driver with appropriate cards, through the card configuration
112 static dev_info_t wl3501_dev_info
= "wl3501_cs";
114 static int wl3501_chan2freq
[] = {
115 [0] = 2412, [1] = 2417, [2] = 2422, [3] = 2427, [4] = 2432,
116 [5] = 2437, [6] = 2442, [7] = 2447, [8] = 2452, [9] = 2457,
117 [10] = 2462, [11] = 2467, [12] = 2472, [13] = 2477,
120 static const struct {
123 } iw_channel_table
[] = {
125 .reg_domain
= IW_REG_DOMAIN_FCC
,
131 .reg_domain
= IW_REG_DOMAIN_DOC
,
137 .reg_domain
= IW_REG_DOMAIN_ETSI
,
143 .reg_domain
= IW_REG_DOMAIN_SPAIN
,
149 .reg_domain
= IW_REG_DOMAIN_FRANCE
,
155 .reg_domain
= IW_REG_DOMAIN_MKK
,
161 .reg_domain
= IW_REG_DOMAIN_MKK1
,
167 .reg_domain
= IW_REG_DOMAIN_ISRAEL
,
175 * iw_valid_channel - validate channel in regulatory domain
176 * @reg_comain - regulatory domain
177 * @channel - channel to validate
179 * Returns 0 if invalid in the specified regulatory domain, non-zero if valid.
181 static int iw_valid_channel(int reg_domain
, int channel
)
185 for (i
= 0; i
< ARRAY_SIZE(iw_channel_table
); i
++)
186 if (reg_domain
== iw_channel_table
[i
].reg_domain
) {
187 rc
= channel
>= iw_channel_table
[i
].min
&&
188 channel
<= iw_channel_table
[i
].max
;
195 * iw_default_channel - get default channel for a regulatory domain
196 * @reg_comain - regulatory domain
198 * Returns the default channel for a regulatory domain
200 static int iw_default_channel(int reg_domain
)
204 for (i
= 0; i
< ARRAY_SIZE(iw_channel_table
); i
++)
205 if (reg_domain
== iw_channel_table
[i
].reg_domain
) {
206 rc
= iw_channel_table
[i
].deflt
;
212 static void iw_set_mgmt_info_element(enum iw_mgmt_info_element_ids id
,
213 struct iw_mgmt_info_element
*el
,
214 void *value
, int len
)
218 memcpy(el
->data
, value
, len
);
221 static void iw_copy_mgmt_info_element(struct iw_mgmt_info_element
*to
,
222 struct iw_mgmt_info_element
*from
)
224 iw_set_mgmt_info_element(from
->id
, to
, from
->data
, from
->len
);
227 static inline void wl3501_switch_page(struct wl3501_card
*this, u8 page
)
229 wl3501_outb(page
, this->base_addr
+ WL3501_NIC_BSS
);
233 * Get Ethernet MAC addresss.
235 * WARNING: We switch to FPAGE0 and switc back again.
236 * Making sure there is no other WL function beening called by ISR.
238 static int wl3501_get_flash_mac_addr(struct wl3501_card
*this)
240 int base_addr
= this->base_addr
;
243 wl3501_outb(WL3501_BSS_FPAGE3
, base_addr
+ WL3501_NIC_BSS
); /* BSS */
244 wl3501_outb(0x00, base_addr
+ WL3501_NIC_LMAL
); /* LMAL */
245 wl3501_outb(0x40, base_addr
+ WL3501_NIC_LMAH
); /* LMAH */
247 /* wait for reading EEPROM */
249 this->mac_addr
[0] = inb(base_addr
+ WL3501_NIC_IODPA
);
251 this->mac_addr
[1] = inb(base_addr
+ WL3501_NIC_IODPA
);
253 this->mac_addr
[2] = inb(base_addr
+ WL3501_NIC_IODPA
);
255 this->mac_addr
[3] = inb(base_addr
+ WL3501_NIC_IODPA
);
257 this->mac_addr
[4] = inb(base_addr
+ WL3501_NIC_IODPA
);
259 this->mac_addr
[5] = inb(base_addr
+ WL3501_NIC_IODPA
);
261 this->reg_domain
= inb(base_addr
+ WL3501_NIC_IODPA
);
263 wl3501_outb(WL3501_BSS_FPAGE0
, base_addr
+ WL3501_NIC_BSS
);
264 wl3501_outb(0x04, base_addr
+ WL3501_NIC_LMAL
);
265 wl3501_outb(0x40, base_addr
+ WL3501_NIC_LMAH
);
267 this->version
[0] = inb(base_addr
+ WL3501_NIC_IODPA
);
269 this->version
[1] = inb(base_addr
+ WL3501_NIC_IODPA
);
270 /* switch to SRAM Page 0 (for safety) */
271 wl3501_switch_page(this, WL3501_BSS_SPAGE0
);
273 /* The MAC addr should be 00:60:... */
274 return this->mac_addr
[0] == 0x00 && this->mac_addr
[1] == 0x60;
278 * wl3501_set_to_wla - Move 'size' bytes from PC to card
279 * @dest: Card addressing space
280 * @src: PC addressing space
281 * @size: Bytes to move
283 * Move 'size' bytes from PC to card. (Shouldn't be interrupted)
285 static void wl3501_set_to_wla(struct wl3501_card
*this, u16 dest
, void *src
,
288 /* switch to SRAM Page 0 */
289 wl3501_switch_page(this, (dest
& 0x8000) ? WL3501_BSS_SPAGE1
:
291 /* set LMAL and LMAH */
292 wl3501_outb(dest
& 0xff, this->base_addr
+ WL3501_NIC_LMAL
);
293 wl3501_outb(((dest
>> 8) & 0x7f), this->base_addr
+ WL3501_NIC_LMAH
);
295 /* rep out to Port A */
296 wl3501_outsb(this->base_addr
+ WL3501_NIC_IODPA
, src
, size
);
300 * wl3501_get_from_wla - Move 'size' bytes from card to PC
301 * @src: Card addressing space
302 * @dest: PC addressing space
303 * @size: Bytes to move
305 * Move 'size' bytes from card to PC. (Shouldn't be interrupted)
307 static void wl3501_get_from_wla(struct wl3501_card
*this, u16 src
, void *dest
,
310 /* switch to SRAM Page 0 */
311 wl3501_switch_page(this, (src
& 0x8000) ? WL3501_BSS_SPAGE1
:
313 /* set LMAL and LMAH */
314 wl3501_outb(src
& 0xff, this->base_addr
+ WL3501_NIC_LMAL
);
315 wl3501_outb((src
>> 8) & 0x7f, this->base_addr
+ WL3501_NIC_LMAH
);
317 /* rep get from Port A */
318 insb(this->base_addr
+ WL3501_NIC_IODPA
, dest
, size
);
322 * Get/Allocate a free Tx Data Buffer
324 * *--------------*-----------------*----------------------------------*
325 * | PLCP | MAC Header | DST SRC Data ... |
326 * | (24 bytes) | (30 bytes) | (6) (6) (Ethernet Row Data) |
327 * *--------------*-----------------*----------------------------------*
328 * \ \- IEEE 802.11 -/ \-------------- len --------------/
329 * \-struct wl3501_80211_tx_hdr--/ \-------- Ethernet Frame -------/
331 * Return = Postion in Card
333 static u16
wl3501_get_tx_buffer(struct wl3501_card
*this, u16 len
)
335 u16 next
, blk_cnt
= 0, zero
= 0;
336 u16 full_len
= sizeof(struct wl3501_80211_tx_hdr
) + len
;
339 if (full_len
> this->tx_buffer_cnt
* 254)
341 ret
= this->tx_buffer_head
;
347 wl3501_get_from_wla(this, this->tx_buffer_head
, &next
,
350 wl3501_set_to_wla(this, this->tx_buffer_head
, &zero
,
352 this->tx_buffer_head
= next
;
354 /* if buffer is not enough */
355 if (!next
&& full_len
) {
356 this->tx_buffer_head
= ret
;
361 this->tx_buffer_cnt
-= blk_cnt
;
367 * Free an allocated Tx Buffer. ptr must be correct position.
369 static void wl3501_free_tx_buffer(struct wl3501_card
*this, u16 ptr
)
371 /* check if all space is not free */
372 if (!this->tx_buffer_head
)
373 this->tx_buffer_head
= ptr
;
375 wl3501_set_to_wla(this, this->tx_buffer_tail
,
380 this->tx_buffer_cnt
++;
381 wl3501_get_from_wla(this, ptr
, &next
, sizeof(next
));
382 this->tx_buffer_tail
= ptr
;
387 static int wl3501_esbq_req_test(struct wl3501_card
*this)
391 wl3501_get_from_wla(this, this->esbq_req_head
+ 3, &tmp
, sizeof(tmp
));
395 static void wl3501_esbq_req(struct wl3501_card
*this, u16
*ptr
)
399 wl3501_set_to_wla(this, this->esbq_req_head
, ptr
, 2);
400 wl3501_set_to_wla(this, this->esbq_req_head
+ 2, &tmp
, sizeof(tmp
));
401 this->esbq_req_head
+= 4;
402 if (this->esbq_req_head
>= this->esbq_req_end
)
403 this->esbq_req_head
= this->esbq_req_start
;
406 static int wl3501_esbq_exec(struct wl3501_card
*this, void *sig
, int sig_size
)
410 if (wl3501_esbq_req_test(this)) {
411 u16 ptr
= wl3501_get_tx_buffer(this, sig_size
);
413 wl3501_set_to_wla(this, ptr
, sig
, sig_size
);
414 wl3501_esbq_req(this, &ptr
);
421 static int wl3501_get_mib_value(struct wl3501_card
*this, u8 index
,
424 struct wl3501_get_req sig
= {
425 .sig_id
= WL3501_SIG_GET_REQ
,
431 spin_lock_irqsave(&this->lock
, flags
);
432 if (wl3501_esbq_req_test(this)) {
433 u16 ptr
= wl3501_get_tx_buffer(this, sizeof(sig
));
435 wl3501_set_to_wla(this, ptr
, &sig
, sizeof(sig
));
436 wl3501_esbq_req(this, &ptr
);
437 this->sig_get_confirm
.mib_status
= 255;
438 spin_unlock_irqrestore(&this->lock
, flags
);
439 rc
= wait_event_interruptible(this->wait
,
440 this->sig_get_confirm
.mib_status
!= 255);
442 memcpy(bf
, this->sig_get_confirm
.mib_value
,
447 spin_unlock_irqrestore(&this->lock
, flags
);
452 static int wl3501_pwr_mgmt(struct wl3501_card
*this, int suspend
)
454 struct wl3501_pwr_mgmt_req sig
= {
455 .sig_id
= WL3501_SIG_PWR_MGMT_REQ
,
463 spin_lock_irqsave(&this->lock
, flags
);
464 if (wl3501_esbq_req_test(this)) {
465 u16 ptr
= wl3501_get_tx_buffer(this, sizeof(sig
));
467 wl3501_set_to_wla(this, ptr
, &sig
, sizeof(sig
));
468 wl3501_esbq_req(this, &ptr
);
469 this->sig_pwr_mgmt_confirm
.status
= 255;
470 spin_unlock_irqrestore(&this->lock
, flags
);
471 rc
= wait_event_interruptible(this->wait
,
472 this->sig_pwr_mgmt_confirm
.status
!= 255);
473 printk(KERN_INFO
"%s: %s status=%d\n", __FUNCTION__
,
474 suspend
? "suspend" : "resume",
475 this->sig_pwr_mgmt_confirm
.status
);
479 spin_unlock_irqrestore(&this->lock
, flags
);
485 * wl3501_send_pkt - Send a packet.
490 * data = Ethernet raw frame. (e.g. data[0] - data[5] is Dest MAC Addr,
491 * data[6] - data[11] is Src MAC Addr)
494 static int wl3501_send_pkt(struct wl3501_card
*this, u8
*data
, u16 len
)
496 u16 bf
, sig_bf
, next
, tmplen
, pktlen
;
497 struct wl3501_md_req sig
= {
498 .sig_id
= WL3501_SIG_MD_REQ
,
500 u8
*pdata
= (char *)data
;
503 if (wl3501_esbq_req_test(this)) {
504 sig_bf
= wl3501_get_tx_buffer(this, sizeof(sig
));
506 if (!sig_bf
) /* No free buffer available */
508 bf
= wl3501_get_tx_buffer(this, len
+ 26 + 24);
510 /* No free buffer available */
511 wl3501_free_tx_buffer(this, sig_bf
);
515 memcpy(&sig
.daddr
[0], pdata
, 12);
519 if (((*pdata
) * 256 + (*(pdata
+ 1))) > 1500) {
520 u8 addr4
[ETH_ALEN
] = {
521 [0] = 0xAA, [1] = 0xAA, [2] = 0x03, [4] = 0x00,
524 wl3501_set_to_wla(this, bf
+ 2 +
525 offsetof(struct wl3501_tx_hdr
, addr4
),
526 addr4
, sizeof(addr4
));
527 sig
.size
= pktlen
+ 24 + 4 + 6;
528 if (pktlen
> (254 - sizeof(struct wl3501_tx_hdr
))) {
529 tmplen
= 254 - sizeof(struct wl3501_tx_hdr
);
535 wl3501_set_to_wla(this,
536 bf
+ 2 + sizeof(struct wl3501_tx_hdr
),
539 wl3501_get_from_wla(this, bf
, &next
, sizeof(next
));
542 sig
.size
= pktlen
+ 24 + 4 - 2;
545 if (pktlen
> (254 - sizeof(struct wl3501_tx_hdr
) + 6)) {
546 tmplen
= 254 - sizeof(struct wl3501_tx_hdr
) + 6;
552 wl3501_set_to_wla(this, bf
+ 2 +
553 offsetof(struct wl3501_tx_hdr
, addr4
),
556 wl3501_get_from_wla(this, bf
, &next
, sizeof(next
));
567 wl3501_set_to_wla(this, bf
+ 2, pdata
, tmplen
);
569 wl3501_get_from_wla(this, bf
, &next
, sizeof(next
));
572 wl3501_set_to_wla(this, sig_bf
, &sig
, sizeof(sig
));
573 wl3501_esbq_req(this, &sig_bf
);
579 static int wl3501_mgmt_resync(struct wl3501_card
*this)
581 struct wl3501_resync_req sig
= {
582 .sig_id
= WL3501_SIG_RESYNC_REQ
,
585 return wl3501_esbq_exec(this, &sig
, sizeof(sig
));
588 static inline int wl3501_fw_bss_type(struct wl3501_card
*this)
590 return this->net_type
== IW_MODE_INFRA
? WL3501_NET_TYPE_INFRA
:
591 WL3501_NET_TYPE_ADHOC
;
594 static inline int wl3501_fw_cap_info(struct wl3501_card
*this)
596 return this->net_type
== IW_MODE_INFRA
? WL3501_MGMT_CAPABILITY_ESS
:
597 WL3501_MGMT_CAPABILITY_IBSS
;
600 static int wl3501_mgmt_scan(struct wl3501_card
*this, u16 chan_time
)
602 struct wl3501_scan_req sig
= {
603 .sig_id
= WL3501_SIG_SCAN_REQ
,
604 .scan_type
= WL3501_SCAN_TYPE_ACTIVE
,
606 .min_chan_time
= chan_time
,
607 .max_chan_time
= chan_time
,
608 .bss_type
= wl3501_fw_bss_type(this),
611 this->bss_cnt
= this->join_sta_bss
= 0;
612 return wl3501_esbq_exec(this, &sig
, sizeof(sig
));
615 static int wl3501_mgmt_join(struct wl3501_card
*this, u16 stas
)
617 struct wl3501_join_req sig
= {
618 .sig_id
= WL3501_SIG_JOIN_REQ
,
622 .id
= IW_MGMT_INFO_ELEMENT_DS_PARAMETER_SET
,
629 memcpy(&sig
.beacon_period
, &this->bss_set
[stas
].beacon_period
, 72);
630 return wl3501_esbq_exec(this, &sig
, sizeof(sig
));
633 static int wl3501_mgmt_start(struct wl3501_card
*this)
635 struct wl3501_start_req sig
= {
636 .sig_id
= WL3501_SIG_START_REQ
,
637 .beacon_period
= 400,
641 .id
= IW_MGMT_INFO_ELEMENT_DS_PARAMETER_SET
,
648 .id
= IW_MGMT_INFO_ELEMENT_SUPPORTED_RATES
,
651 .data_rate_labels
= {
652 [0] = IW_MGMT_RATE_LABEL_MANDATORY
|
653 IW_MGMT_RATE_LABEL_1MBIT
,
654 [1] = IW_MGMT_RATE_LABEL_MANDATORY
|
655 IW_MGMT_RATE_LABEL_2MBIT
,
658 .operational_rset
= {
660 .id
= IW_MGMT_INFO_ELEMENT_SUPPORTED_RATES
,
663 .data_rate_labels
= {
664 [0] = IW_MGMT_RATE_LABEL_MANDATORY
|
665 IW_MGMT_RATE_LABEL_1MBIT
,
666 [1] = IW_MGMT_RATE_LABEL_MANDATORY
|
667 IW_MGMT_RATE_LABEL_2MBIT
,
672 .id
= IW_MGMT_INFO_ELEMENT_IBSS_PARAMETER_SET
,
677 .bss_type
= wl3501_fw_bss_type(this),
678 .cap_info
= wl3501_fw_cap_info(this),
681 iw_copy_mgmt_info_element(&sig
.ssid
.el
, &this->essid
.el
);
682 iw_copy_mgmt_info_element(&this->keep_essid
.el
, &this->essid
.el
);
683 return wl3501_esbq_exec(this, &sig
, sizeof(sig
));
686 static void wl3501_mgmt_scan_confirm(struct wl3501_card
*this, u16 addr
)
690 struct wl3501_scan_confirm sig
;
693 wl3501_get_from_wla(this, addr
, &sig
, sizeof(sig
));
694 if (sig
.status
== WL3501_STATUS_SUCCESS
) {
695 dprintk(3, "success");
696 if ((this->net_type
== IW_MODE_INFRA
&&
697 (sig
.cap_info
& WL3501_MGMT_CAPABILITY_ESS
)) ||
698 (this->net_type
== IW_MODE_ADHOC
&&
699 (sig
.cap_info
& WL3501_MGMT_CAPABILITY_IBSS
)) ||
700 this->net_type
== IW_MODE_AUTO
) {
701 if (!this->essid
.el
.len
)
703 else if (this->essid
.el
.len
== 3 &&
704 !memcmp(this->essid
.essid
, "ANY", 3))
706 else if (this->essid
.el
.len
!= sig
.ssid
.el
.len
)
708 else if (memcmp(this->essid
.essid
, sig
.ssid
.essid
,
714 for (i
= 0; i
< this->bss_cnt
; i
++) {
715 if (!memcmp(this->bss_set
[i
].bssid
,
716 sig
.bssid
, ETH_ALEN
)) {
722 if (matchflag
&& (i
< 20)) {
723 memcpy(&this->bss_set
[i
].beacon_period
,
724 &sig
.beacon_period
, 73);
726 this->rssi
= sig
.rssi
;
729 } else if (sig
.status
== WL3501_STATUS_TIMEOUT
) {
730 dprintk(3, "timeout");
731 this->join_sta_bss
= 0;
732 for (i
= this->join_sta_bss
; i
< this->bss_cnt
; i
++)
733 if (!wl3501_mgmt_join(this, i
))
735 this->join_sta_bss
= i
;
736 if (this->join_sta_bss
== this->bss_cnt
) {
737 if (this->net_type
== IW_MODE_INFRA
)
738 wl3501_mgmt_scan(this, 100);
741 if (this->adhoc_times
> WL3501_MAX_ADHOC_TRIES
)
742 wl3501_mgmt_start(this);
744 wl3501_mgmt_scan(this, 100);
751 * wl3501_block_interrupt - Mask interrupt from SUTRO
754 * Mask interrupt from SUTRO. (i.e. SUTRO cannot interrupt the HOST)
755 * Return: 1 if interrupt is originally enabled
757 static int wl3501_block_interrupt(struct wl3501_card
*this)
759 u8 old
= inb(this->base_addr
+ WL3501_NIC_GCR
);
760 u8
new = old
& (~(WL3501_GCR_ECINT
| WL3501_GCR_INT2EC
|
761 WL3501_GCR_ENECINT
));
763 wl3501_outb(new, this->base_addr
+ WL3501_NIC_GCR
);
764 return old
& WL3501_GCR_ENECINT
;
768 * wl3501_unblock_interrupt - Enable interrupt from SUTRO
771 * Enable interrupt from SUTRO. (i.e. SUTRO can interrupt the HOST)
772 * Return: 1 if interrupt is originally enabled
774 static int wl3501_unblock_interrupt(struct wl3501_card
*this)
776 u8 old
= inb(this->base_addr
+ WL3501_NIC_GCR
);
777 u8
new = (old
& ~(WL3501_GCR_ECINT
| WL3501_GCR_INT2EC
)) |
780 wl3501_outb(new, this->base_addr
+ WL3501_NIC_GCR
);
781 return old
& WL3501_GCR_ENECINT
;
785 * wl3501_receive - Receive data from Receive Queue.
787 * Receive data from Receive Queue.
790 * @bf: address of host
791 * @size: size of buffer.
793 static u16
wl3501_receive(struct wl3501_card
*this, u8
*bf
, u16 size
)
795 u16 next_addr
, next_addr1
;
799 wl3501_get_from_wla(this, this->start_seg
+ 2,
800 &next_addr
, sizeof(next_addr
));
801 if (size
> WL3501_BLKSZ
- sizeof(struct wl3501_rx_hdr
)) {
802 wl3501_get_from_wla(this,
804 sizeof(struct wl3501_rx_hdr
), data
,
806 sizeof(struct wl3501_rx_hdr
));
807 size
-= WL3501_BLKSZ
- sizeof(struct wl3501_rx_hdr
);
808 data
+= WL3501_BLKSZ
- sizeof(struct wl3501_rx_hdr
);
810 wl3501_get_from_wla(this,
812 sizeof(struct wl3501_rx_hdr
),
817 if (size
> WL3501_BLKSZ
- 5) {
818 wl3501_get_from_wla(this, next_addr
+ 5, data
,
820 size
-= WL3501_BLKSZ
- 5;
821 data
+= WL3501_BLKSZ
- 5;
822 wl3501_get_from_wla(this, next_addr
+ 2, &next_addr1
,
824 next_addr
= next_addr1
;
826 wl3501_get_from_wla(this, next_addr
+ 5, data
, size
);
833 static void wl3501_esbq_req_free(struct wl3501_card
*this)
838 if (this->esbq_req_head
== this->esbq_req_tail
)
840 wl3501_get_from_wla(this, this->esbq_req_tail
+ 3, &tmp
, sizeof(tmp
));
843 wl3501_get_from_wla(this, this->esbq_req_tail
, &addr
, sizeof(addr
));
844 wl3501_free_tx_buffer(this, addr
);
845 this->esbq_req_tail
+= 4;
846 if (this->esbq_req_tail
>= this->esbq_req_end
)
847 this->esbq_req_tail
= this->esbq_req_start
;
852 static int wl3501_esbq_confirm(struct wl3501_card
*this)
856 wl3501_get_from_wla(this, this->esbq_confirm
+ 3, &tmp
, sizeof(tmp
));
860 static void wl3501_online(struct net_device
*dev
)
862 struct wl3501_card
*this = netdev_priv(dev
);
863 DECLARE_MAC_BUF(mac
);
865 printk(KERN_INFO
"%s: Wireless LAN online. BSSID: %s\n",
866 dev
->name
, print_mac(mac
, this->bssid
));
867 netif_wake_queue(dev
);
870 static void wl3501_esbq_confirm_done(struct wl3501_card
*this)
874 wl3501_set_to_wla(this, this->esbq_confirm
+ 3, &tmp
, sizeof(tmp
));
875 this->esbq_confirm
+= 4;
876 if (this->esbq_confirm
>= this->esbq_confirm_end
)
877 this->esbq_confirm
= this->esbq_confirm_start
;
880 static int wl3501_mgmt_auth(struct wl3501_card
*this)
882 struct wl3501_auth_req sig
= {
883 .sig_id
= WL3501_SIG_AUTH_REQ
,
884 .type
= WL3501_SYS_TYPE_OPEN
,
889 memcpy(sig
.mac_addr
, this->bssid
, ETH_ALEN
);
890 return wl3501_esbq_exec(this, &sig
, sizeof(sig
));
893 static int wl3501_mgmt_association(struct wl3501_card
*this)
895 struct wl3501_assoc_req sig
= {
896 .sig_id
= WL3501_SIG_ASSOC_REQ
,
898 .listen_interval
= 5,
899 .cap_info
= this->cap_info
,
903 memcpy(sig
.mac_addr
, this->bssid
, ETH_ALEN
);
904 return wl3501_esbq_exec(this, &sig
, sizeof(sig
));
907 static void wl3501_mgmt_join_confirm(struct net_device
*dev
, u16 addr
)
909 struct wl3501_card
*this = netdev_priv(dev
);
910 struct wl3501_join_confirm sig
;
913 wl3501_get_from_wla(this, addr
, &sig
, sizeof(sig
));
914 if (sig
.status
== WL3501_STATUS_SUCCESS
) {
915 if (this->net_type
== IW_MODE_INFRA
) {
916 if (this->join_sta_bss
< this->bss_cnt
) {
917 const int i
= this->join_sta_bss
;
919 this->bss_set
[i
].bssid
, ETH_ALEN
);
920 this->chan
= this->bss_set
[i
].ds_pset
.chan
;
921 iw_copy_mgmt_info_element(&this->keep_essid
.el
,
922 &this->bss_set
[i
].ssid
.el
);
923 wl3501_mgmt_auth(this);
926 const int i
= this->join_sta_bss
;
928 memcpy(&this->bssid
, &this->bss_set
[i
].bssid
, ETH_ALEN
);
929 this->chan
= this->bss_set
[i
].ds_pset
.chan
;
930 iw_copy_mgmt_info_element(&this->keep_essid
.el
,
931 &this->bss_set
[i
].ssid
.el
);
936 this->join_sta_bss
++;
937 for (i
= this->join_sta_bss
; i
< this->bss_cnt
; i
++)
938 if (!wl3501_mgmt_join(this, i
))
940 this->join_sta_bss
= i
;
941 if (this->join_sta_bss
== this->bss_cnt
) {
942 if (this->net_type
== IW_MODE_INFRA
)
943 wl3501_mgmt_scan(this, 100);
946 if (this->adhoc_times
> WL3501_MAX_ADHOC_TRIES
)
947 wl3501_mgmt_start(this);
949 wl3501_mgmt_scan(this, 100);
955 static inline void wl3501_alarm_interrupt(struct net_device
*dev
,
956 struct wl3501_card
*this)
958 if (this->net_type
== IW_MODE_INFRA
) {
959 printk(KERN_INFO
"Wireless LAN offline\n");
960 netif_stop_queue(dev
);
961 wl3501_mgmt_resync(this);
965 static inline void wl3501_md_confirm_interrupt(struct net_device
*dev
,
966 struct wl3501_card
*this,
969 struct wl3501_md_confirm sig
;
972 wl3501_get_from_wla(this, addr
, &sig
, sizeof(sig
));
973 wl3501_free_tx_buffer(this, sig
.data
);
974 if (netif_queue_stopped(dev
))
975 netif_wake_queue(dev
);
978 static inline void wl3501_md_ind_interrupt(struct net_device
*dev
,
979 struct wl3501_card
*this, u16 addr
)
981 struct wl3501_md_ind sig
;
983 u8 rssi
, addr4
[ETH_ALEN
];
986 wl3501_get_from_wla(this, addr
, &sig
, sizeof(sig
));
987 this->start_seg
= sig
.data
;
988 wl3501_get_from_wla(this,
989 sig
.data
+ offsetof(struct wl3501_rx_hdr
, rssi
),
990 &rssi
, sizeof(rssi
));
991 this->rssi
= rssi
<= 63 ? (rssi
* 100) / 64 : 255;
993 wl3501_get_from_wla(this,
995 offsetof(struct wl3501_rx_hdr
, addr4
),
996 &addr4
, sizeof(addr4
));
997 if (!(addr4
[0] == 0xAA && addr4
[1] == 0xAA &&
998 addr4
[2] == 0x03 && addr4
[4] == 0x00)) {
999 printk(KERN_INFO
"Insupported packet type!\n");
1002 pkt_len
= sig
.size
+ 12 - 24 - 4 - 6;
1004 skb
= dev_alloc_skb(pkt_len
+ 5);
1007 printk(KERN_WARNING
"%s: Can't alloc a sk_buff of size %d.\n",
1008 dev
->name
, pkt_len
);
1009 this->stats
.rx_dropped
++;
1012 skb_reserve(skb
, 2); /* IP headers on 16 bytes boundaries */
1013 skb_copy_to_linear_data(skb
, (unsigned char *)&sig
.daddr
, 12);
1014 wl3501_receive(this, skb
->data
, pkt_len
);
1015 skb_put(skb
, pkt_len
);
1016 skb
->protocol
= eth_type_trans(skb
, dev
);
1017 dev
->last_rx
= jiffies
;
1018 this->stats
.rx_packets
++;
1019 this->stats
.rx_bytes
+= skb
->len
;
1024 static inline void wl3501_get_confirm_interrupt(struct wl3501_card
*this,
1025 u16 addr
, void *sig
, int size
)
1027 dprintk(3, "entry");
1028 wl3501_get_from_wla(this, addr
, &this->sig_get_confirm
,
1029 sizeof(this->sig_get_confirm
));
1030 wake_up(&this->wait
);
1033 static inline void wl3501_start_confirm_interrupt(struct net_device
*dev
,
1034 struct wl3501_card
*this,
1037 struct wl3501_start_confirm sig
;
1039 dprintk(3, "entry");
1040 wl3501_get_from_wla(this, addr
, &sig
, sizeof(sig
));
1041 if (sig
.status
== WL3501_STATUS_SUCCESS
)
1042 netif_wake_queue(dev
);
1045 static inline void wl3501_assoc_confirm_interrupt(struct net_device
*dev
,
1048 struct wl3501_card
*this = netdev_priv(dev
);
1049 struct wl3501_assoc_confirm sig
;
1051 dprintk(3, "entry");
1052 wl3501_get_from_wla(this, addr
, &sig
, sizeof(sig
));
1054 if (sig
.status
== WL3501_STATUS_SUCCESS
)
1058 static inline void wl3501_auth_confirm_interrupt(struct wl3501_card
*this,
1061 struct wl3501_auth_confirm sig
;
1063 dprintk(3, "entry");
1064 wl3501_get_from_wla(this, addr
, &sig
, sizeof(sig
));
1066 if (sig
.status
== WL3501_STATUS_SUCCESS
)
1067 wl3501_mgmt_association(this);
1069 wl3501_mgmt_resync(this);
1072 static inline void wl3501_rx_interrupt(struct net_device
*dev
)
1077 struct wl3501_card
*this = netdev_priv(dev
);
1079 dprintk(3, "entry");
1082 if (!wl3501_esbq_confirm(this))
1084 wl3501_get_from_wla(this, this->esbq_confirm
, &addr
, sizeof(addr
));
1085 wl3501_get_from_wla(this, addr
+ 2, &sig_id
, sizeof(sig_id
));
1088 case WL3501_SIG_DEAUTH_IND
:
1089 case WL3501_SIG_DISASSOC_IND
:
1090 case WL3501_SIG_ALARM
:
1091 wl3501_alarm_interrupt(dev
, this);
1093 case WL3501_SIG_MD_CONFIRM
:
1094 wl3501_md_confirm_interrupt(dev
, this, addr
);
1096 case WL3501_SIG_MD_IND
:
1097 wl3501_md_ind_interrupt(dev
, this, addr
);
1099 case WL3501_SIG_GET_CONFIRM
:
1100 wl3501_get_confirm_interrupt(this, addr
,
1101 &this->sig_get_confirm
,
1102 sizeof(this->sig_get_confirm
));
1104 case WL3501_SIG_PWR_MGMT_CONFIRM
:
1105 wl3501_get_confirm_interrupt(this, addr
,
1106 &this->sig_pwr_mgmt_confirm
,
1107 sizeof(this->sig_pwr_mgmt_confirm
));
1109 case WL3501_SIG_START_CONFIRM
:
1110 wl3501_start_confirm_interrupt(dev
, this, addr
);
1112 case WL3501_SIG_SCAN_CONFIRM
:
1113 wl3501_mgmt_scan_confirm(this, addr
);
1115 case WL3501_SIG_JOIN_CONFIRM
:
1116 wl3501_mgmt_join_confirm(dev
, addr
);
1118 case WL3501_SIG_ASSOC_CONFIRM
:
1119 wl3501_assoc_confirm_interrupt(dev
, addr
);
1121 case WL3501_SIG_AUTH_CONFIRM
:
1122 wl3501_auth_confirm_interrupt(this, addr
);
1124 case WL3501_SIG_RESYNC_CONFIRM
:
1125 wl3501_mgmt_resync(this); /* FIXME: should be resync_confirm */
1128 wl3501_esbq_confirm_done(this);
1130 /* free request if necessary */
1132 wl3501_esbq_req_free(this);
1137 static inline void wl3501_ack_interrupt(struct wl3501_card
*this)
1139 wl3501_outb(WL3501_GCR_ECINT
, this->base_addr
+ WL3501_NIC_GCR
);
1143 * wl3501_interrupt - Hardware interrupt from card.
1144 * @irq - Interrupt number
1145 * @dev_id - net_device
1147 * We must acknowledge the interrupt as soon as possible, and block the
1148 * interrupt from the same card immediately to prevent re-entry.
1150 * Before accessing the Control_Status_Block, we must lock SUTRO first.
1151 * On the other hand, to prevent SUTRO from malfunctioning, we must
1152 * unlock the SUTRO as soon as possible.
1154 static irqreturn_t
wl3501_interrupt(int irq
, void *dev_id
)
1156 struct net_device
*dev
= dev_id
;
1157 struct wl3501_card
*this;
1159 this = netdev_priv(dev
);
1160 spin_lock(&this->lock
);
1161 wl3501_ack_interrupt(this);
1162 wl3501_block_interrupt(this);
1163 wl3501_rx_interrupt(dev
);
1164 wl3501_unblock_interrupt(this);
1165 spin_unlock(&this->lock
);
1170 static int wl3501_reset_board(struct wl3501_card
*this)
1176 wl3501_outb_p(WL3501_GCR_CORESET
, this->base_addr
+ WL3501_NIC_GCR
);
1177 wl3501_outb_p(0, this->base_addr
+ WL3501_NIC_GCR
);
1178 wl3501_outb_p(WL3501_GCR_CORESET
, this->base_addr
+ WL3501_NIC_GCR
);
1180 /* Reset SRAM 0x480 to zero */
1181 wl3501_set_to_wla(this, 0x480, &tmp
, sizeof(tmp
));
1184 wl3501_outb_p(0, this->base_addr
+ WL3501_NIC_GCR
);
1186 WL3501_NOPLOOP(1024 * 50);
1188 wl3501_unblock_interrupt(this); /* acme: was commented */
1190 /* Polling Self_Test_Status */
1191 for (i
= 0; i
< 10000; i
++) {
1192 wl3501_get_from_wla(this, 0x480, &tmp
, sizeof(tmp
));
1195 /* firmware complete all test successfully */
1197 wl3501_set_to_wla(this, 0x480, &tmp
, sizeof(tmp
));
1202 printk(KERN_WARNING
"%s: failed to reset the board!\n", __FUNCTION__
);
1208 static int wl3501_init_firmware(struct wl3501_card
*this)
1211 int rc
= wl3501_reset_board(this);
1215 this->card_name
[0] = '\0';
1216 wl3501_get_from_wla(this, 0x1a00,
1217 this->card_name
, sizeof(this->card_name
));
1218 this->card_name
[sizeof(this->card_name
) - 1] = '\0';
1219 this->firmware_date
[0] = '\0';
1220 wl3501_get_from_wla(this, 0x1a40,
1221 this->firmware_date
, sizeof(this->firmware_date
));
1222 this->firmware_date
[sizeof(this->firmware_date
) - 1] = '\0';
1223 /* Switch to SRAM Page 0 */
1224 wl3501_switch_page(this, WL3501_BSS_SPAGE0
);
1225 /* Read parameter from card */
1226 wl3501_get_from_wla(this, 0x482, &this->esbq_req_start
, 2);
1227 wl3501_get_from_wla(this, 0x486, &this->esbq_req_end
, 2);
1228 wl3501_get_from_wla(this, 0x488, &this->esbq_confirm_start
, 2);
1229 wl3501_get_from_wla(this, 0x48c, &this->esbq_confirm_end
, 2);
1230 wl3501_get_from_wla(this, 0x48e, &this->tx_buffer_head
, 2);
1231 wl3501_get_from_wla(this, 0x492, &this->tx_buffer_size
, 2);
1232 this->esbq_req_tail
= this->esbq_req_head
= this->esbq_req_start
;
1233 this->esbq_req_end
+= this->esbq_req_start
;
1234 this->esbq_confirm
= this->esbq_confirm_start
;
1235 this->esbq_confirm_end
+= this->esbq_confirm_start
;
1236 /* Initial Tx Buffer */
1237 this->tx_buffer_cnt
= 1;
1238 ptr
= this->tx_buffer_head
;
1239 next
= ptr
+ WL3501_BLKSZ
;
1240 while ((next
- this->tx_buffer_head
) < this->tx_buffer_size
) {
1241 this->tx_buffer_cnt
++;
1242 wl3501_set_to_wla(this, ptr
, &next
, sizeof(next
));
1244 next
= ptr
+ WL3501_BLKSZ
;
1248 wl3501_set_to_wla(this, ptr
, &next
, sizeof(next
));
1249 this->tx_buffer_tail
= ptr
;
1253 printk(KERN_WARNING
"%s: failed!\n", __FUNCTION__
);
1257 static int wl3501_close(struct net_device
*dev
)
1259 struct wl3501_card
*this = netdev_priv(dev
);
1261 unsigned long flags
;
1262 struct pcmcia_device
*link
;
1265 spin_lock_irqsave(&this->lock
, flags
);
1268 /* Stop wl3501_hard_start_xmit() from now on */
1269 netif_stop_queue(dev
);
1270 wl3501_ack_interrupt(this);
1272 /* Mask interrupts from the SUTRO */
1273 wl3501_block_interrupt(this);
1276 printk(KERN_INFO
"%s: WL3501 closed\n", dev
->name
);
1277 spin_unlock_irqrestore(&this->lock
, flags
);
1282 * wl3501_reset - Reset the SUTRO.
1283 * @dev - network device
1285 * It is almost the same as wl3501_open(). In fact, we may just wl3501_close()
1286 * and wl3501_open() again, but I wouldn't like to free_irq() when the driver
1287 * is running. It seems to be dangerous.
1289 static int wl3501_reset(struct net_device
*dev
)
1291 struct wl3501_card
*this = netdev_priv(dev
);
1294 wl3501_block_interrupt(this);
1296 if (wl3501_init_firmware(this)) {
1297 printk(KERN_WARNING
"%s: Can't initialize Firmware!\n",
1299 /* Free IRQ, and mark IRQ as unused */
1300 free_irq(dev
->irq
, dev
);
1305 * Queue has to be started only when the Card is Started
1307 netif_stop_queue(dev
);
1308 this->adhoc_times
= 0;
1309 wl3501_ack_interrupt(this);
1310 wl3501_unblock_interrupt(this);
1311 wl3501_mgmt_scan(this, 100);
1312 dprintk(1, "%s: device reset", dev
->name
);
1318 static void wl3501_tx_timeout(struct net_device
*dev
)
1320 struct wl3501_card
*this = netdev_priv(dev
);
1321 struct net_device_stats
*stats
= &this->stats
;
1322 unsigned long flags
;
1326 spin_lock_irqsave(&this->lock
, flags
);
1327 rc
= wl3501_reset(dev
);
1328 spin_unlock_irqrestore(&this->lock
, flags
);
1330 printk(KERN_ERR
"%s: Error %d resetting card on Tx timeout!\n",
1333 dev
->trans_start
= jiffies
;
1334 netif_wake_queue(dev
);
1340 * 1 - Could not transmit (dev_queue_xmit will queue it)
1341 * and try to sent it later
1343 static int wl3501_hard_start_xmit(struct sk_buff
*skb
, struct net_device
*dev
)
1346 struct wl3501_card
*this = netdev_priv(dev
);
1347 unsigned long flags
;
1349 spin_lock_irqsave(&this->lock
, flags
);
1350 enabled
= wl3501_block_interrupt(this);
1351 dev
->trans_start
= jiffies
;
1352 rc
= wl3501_send_pkt(this, skb
->data
, skb
->len
);
1354 wl3501_unblock_interrupt(this);
1356 ++this->stats
.tx_dropped
;
1357 netif_stop_queue(dev
);
1359 ++this->stats
.tx_packets
;
1360 this->stats
.tx_bytes
+= skb
->len
;
1363 if (this->tx_buffer_cnt
< 2)
1364 netif_stop_queue(dev
);
1366 spin_unlock_irqrestore(&this->lock
, flags
);
1370 static int wl3501_open(struct net_device
*dev
)
1373 struct wl3501_card
*this = netdev_priv(dev
);
1374 unsigned long flags
;
1375 struct pcmcia_device
*link
;
1378 spin_lock_irqsave(&this->lock
, flags
);
1379 if (!pcmcia_dev_present(link
))
1381 netif_device_attach(dev
);
1384 /* Initial WL3501 firmware */
1385 dprintk(1, "%s: Initialize WL3501 firmware...", dev
->name
);
1386 if (wl3501_init_firmware(this))
1388 /* Initial device variables */
1389 this->adhoc_times
= 0;
1390 /* Acknowledge Interrupt, for cleaning last state */
1391 wl3501_ack_interrupt(this);
1393 /* Enable interrupt from card after all */
1394 wl3501_unblock_interrupt(this);
1395 wl3501_mgmt_scan(this, 100);
1397 dprintk(1, "%s: WL3501 opened", dev
->name
);
1398 printk(KERN_INFO
"%s: Card Name: %s\n"
1399 "%s: Firmware Date: %s\n",
1400 dev
->name
, this->card_name
,
1401 dev
->name
, this->firmware_date
);
1403 spin_unlock_irqrestore(&this->lock
, flags
);
1406 printk(KERN_WARNING
"%s: Can't initialize firmware!\n", dev
->name
);
1410 static struct net_device_stats
*wl3501_get_stats(struct net_device
*dev
)
1412 struct wl3501_card
*this = netdev_priv(dev
);
1414 return &this->stats
;
1417 static struct iw_statistics
*wl3501_get_wireless_stats(struct net_device
*dev
)
1419 struct wl3501_card
*this = netdev_priv(dev
);
1420 struct iw_statistics
*wstats
= &this->wstats
;
1421 u32 value
; /* size checked: it is u32 */
1423 memset(wstats
, 0, sizeof(*wstats
));
1424 wstats
->status
= netif_running(dev
);
1425 if (!wl3501_get_mib_value(this, WL3501_MIB_ATTR_WEP_ICV_ERROR_COUNT
,
1426 &value
, sizeof(value
)))
1427 wstats
->discard
.code
+= value
;
1428 if (!wl3501_get_mib_value(this, WL3501_MIB_ATTR_WEP_UNDECRYPTABLE_COUNT
,
1429 &value
, sizeof(value
)))
1430 wstats
->discard
.code
+= value
;
1431 if (!wl3501_get_mib_value(this, WL3501_MIB_ATTR_WEP_EXCLUDED_COUNT
,
1432 &value
, sizeof(value
)))
1433 wstats
->discard
.code
+= value
;
1434 if (!wl3501_get_mib_value(this, WL3501_MIB_ATTR_RETRY_COUNT
,
1435 &value
, sizeof(value
)))
1436 wstats
->discard
.retries
= value
;
1437 if (!wl3501_get_mib_value(this, WL3501_MIB_ATTR_FAILED_COUNT
,
1438 &value
, sizeof(value
)))
1439 wstats
->discard
.misc
+= value
;
1440 if (!wl3501_get_mib_value(this, WL3501_MIB_ATTR_RTS_FAILURE_COUNT
,
1441 &value
, sizeof(value
)))
1442 wstats
->discard
.misc
+= value
;
1443 if (!wl3501_get_mib_value(this, WL3501_MIB_ATTR_ACK_FAILURE_COUNT
,
1444 &value
, sizeof(value
)))
1445 wstats
->discard
.misc
+= value
;
1446 if (!wl3501_get_mib_value(this, WL3501_MIB_ATTR_FRAME_DUPLICATE_COUNT
,
1447 &value
, sizeof(value
)))
1448 wstats
->discard
.misc
+= value
;
1452 static void wl3501_get_drvinfo(struct net_device
*dev
, struct ethtool_drvinfo
*info
)
1454 strlcpy(info
->driver
, wl3501_dev_info
, sizeof(info
->driver
));
1457 static const struct ethtool_ops ops
= {
1458 .get_drvinfo
= wl3501_get_drvinfo
1462 * wl3501_detach - deletes a driver "instance"
1465 * This deletes a driver "instance". The device is de-registered with Card
1466 * Services. If it has been released, all local data structures are freed.
1467 * Otherwise, the structures will be freed when the device is released.
1469 static void wl3501_detach(struct pcmcia_device
*link
)
1471 struct net_device
*dev
= link
->priv
;
1473 /* If the device is currently configured and active, we won't actually
1474 * delete it yet. Instead, it is marked so that when the release()
1475 * function is called, that will trigger a proper detach(). */
1477 while (link
->open
> 0)
1480 netif_device_detach(dev
);
1481 wl3501_release(link
);
1484 free_netdev(link
->priv
);
1489 static int wl3501_get_name(struct net_device
*dev
, struct iw_request_info
*info
,
1490 union iwreq_data
*wrqu
, char *extra
)
1492 strlcpy(wrqu
->name
, "IEEE 802.11-DS", sizeof(wrqu
->name
));
1496 static int wl3501_set_freq(struct net_device
*dev
, struct iw_request_info
*info
,
1497 union iwreq_data
*wrqu
, char *extra
)
1499 struct wl3501_card
*this = netdev_priv(dev
);
1500 int channel
= wrqu
->freq
.m
;
1503 if (iw_valid_channel(this->reg_domain
, channel
)) {
1504 this->chan
= channel
;
1505 rc
= wl3501_reset(dev
);
1510 static int wl3501_get_freq(struct net_device
*dev
, struct iw_request_info
*info
,
1511 union iwreq_data
*wrqu
, char *extra
)
1513 struct wl3501_card
*this = netdev_priv(dev
);
1515 wrqu
->freq
.m
= wl3501_chan2freq
[this->chan
- 1] * 100000;
1520 static int wl3501_set_mode(struct net_device
*dev
, struct iw_request_info
*info
,
1521 union iwreq_data
*wrqu
, char *extra
)
1525 if (wrqu
->mode
== IW_MODE_INFRA
||
1526 wrqu
->mode
== IW_MODE_ADHOC
||
1527 wrqu
->mode
== IW_MODE_AUTO
) {
1528 struct wl3501_card
*this = netdev_priv(dev
);
1530 this->net_type
= wrqu
->mode
;
1531 rc
= wl3501_reset(dev
);
1536 static int wl3501_get_mode(struct net_device
*dev
, struct iw_request_info
*info
,
1537 union iwreq_data
*wrqu
, char *extra
)
1539 struct wl3501_card
*this = netdev_priv(dev
);
1541 wrqu
->mode
= this->net_type
;
1545 static int wl3501_get_sens(struct net_device
*dev
, struct iw_request_info
*info
,
1546 union iwreq_data
*wrqu
, char *extra
)
1548 struct wl3501_card
*this = netdev_priv(dev
);
1550 wrqu
->sens
.value
= this->rssi
;
1551 wrqu
->sens
.disabled
= !wrqu
->sens
.value
;
1552 wrqu
->sens
.fixed
= 1;
1556 static int wl3501_get_range(struct net_device
*dev
,
1557 struct iw_request_info
*info
,
1558 union iwreq_data
*wrqu
, char *extra
)
1560 struct iw_range
*range
= (struct iw_range
*)extra
;
1562 /* Set the length (very important for backward compatibility) */
1563 wrqu
->data
.length
= sizeof(*range
);
1565 /* Set all the info we don't care or don't know about to zero */
1566 memset(range
, 0, sizeof(*range
));
1568 /* Set the Wireless Extension versions */
1569 range
->we_version_compiled
= WIRELESS_EXT
;
1570 range
->we_version_source
= 1;
1571 range
->throughput
= 2 * 1000 * 1000; /* ~2 Mb/s */
1572 /* FIXME: study the code to fill in more fields... */
1576 static int wl3501_set_wap(struct net_device
*dev
, struct iw_request_info
*info
,
1577 union iwreq_data
*wrqu
, char *extra
)
1579 struct wl3501_card
*this = netdev_priv(dev
);
1580 static const u8 bcast
[ETH_ALEN
] = { 255, 255, 255, 255, 255, 255 };
1583 /* FIXME: we support other ARPHRDs...*/
1584 if (wrqu
->ap_addr
.sa_family
!= ARPHRD_ETHER
)
1586 if (!memcmp(bcast
, wrqu
->ap_addr
.sa_data
, ETH_ALEN
)) {
1587 /* FIXME: rescan? */
1589 memcpy(this->bssid
, wrqu
->ap_addr
.sa_data
, ETH_ALEN
);
1590 /* FIXME: rescan? deassoc & scan? */
1596 static int wl3501_get_wap(struct net_device
*dev
, struct iw_request_info
*info
,
1597 union iwreq_data
*wrqu
, char *extra
)
1599 struct wl3501_card
*this = netdev_priv(dev
);
1601 wrqu
->ap_addr
.sa_family
= ARPHRD_ETHER
;
1602 memcpy(wrqu
->ap_addr
.sa_data
, this->bssid
, ETH_ALEN
);
1606 static int wl3501_set_scan(struct net_device
*dev
, struct iw_request_info
*info
,
1607 union iwreq_data
*wrqu
, char *extra
)
1610 * FIXME: trigger scanning with a reset, yes, I'm lazy
1612 return wl3501_reset(dev
);
1615 static int wl3501_get_scan(struct net_device
*dev
, struct iw_request_info
*info
,
1616 union iwreq_data
*wrqu
, char *extra
)
1618 struct wl3501_card
*this = netdev_priv(dev
);
1620 char *current_ev
= extra
;
1621 struct iw_event iwe
;
1623 for (i
= 0; i
< this->bss_cnt
; ++i
) {
1624 iwe
.cmd
= SIOCGIWAP
;
1625 iwe
.u
.ap_addr
.sa_family
= ARPHRD_ETHER
;
1626 memcpy(iwe
.u
.ap_addr
.sa_data
, this->bss_set
[i
].bssid
, ETH_ALEN
);
1627 current_ev
= iwe_stream_add_event(current_ev
,
1628 extra
+ IW_SCAN_MAX_DATA
,
1629 &iwe
, IW_EV_ADDR_LEN
);
1630 iwe
.cmd
= SIOCGIWESSID
;
1631 iwe
.u
.data
.flags
= 1;
1632 iwe
.u
.data
.length
= this->bss_set
[i
].ssid
.el
.len
;
1633 current_ev
= iwe_stream_add_point(current_ev
,
1634 extra
+ IW_SCAN_MAX_DATA
,
1636 this->bss_set
[i
].ssid
.essid
);
1637 iwe
.cmd
= SIOCGIWMODE
;
1638 iwe
.u
.mode
= this->bss_set
[i
].bss_type
;
1639 current_ev
= iwe_stream_add_event(current_ev
,
1640 extra
+ IW_SCAN_MAX_DATA
,
1641 &iwe
, IW_EV_UINT_LEN
);
1642 iwe
.cmd
= SIOCGIWFREQ
;
1643 iwe
.u
.freq
.m
= this->bss_set
[i
].ds_pset
.chan
;
1645 current_ev
= iwe_stream_add_event(current_ev
,
1646 extra
+ IW_SCAN_MAX_DATA
,
1647 &iwe
, IW_EV_FREQ_LEN
);
1648 iwe
.cmd
= SIOCGIWENCODE
;
1649 if (this->bss_set
[i
].cap_info
& WL3501_MGMT_CAPABILITY_PRIVACY
)
1650 iwe
.u
.data
.flags
= IW_ENCODE_ENABLED
| IW_ENCODE_NOKEY
;
1652 iwe
.u
.data
.flags
= IW_ENCODE_DISABLED
;
1653 iwe
.u
.data
.length
= 0;
1654 current_ev
= iwe_stream_add_point(current_ev
,
1655 extra
+ IW_SCAN_MAX_DATA
,
1658 /* Length of data */
1659 wrqu
->data
.length
= (current_ev
- extra
);
1660 wrqu
->data
.flags
= 0; /* FIXME: set properly these flags */
1664 static int wl3501_set_essid(struct net_device
*dev
,
1665 struct iw_request_info
*info
,
1666 union iwreq_data
*wrqu
, char *extra
)
1668 struct wl3501_card
*this = netdev_priv(dev
);
1670 if (wrqu
->data
.flags
) {
1671 iw_set_mgmt_info_element(IW_MGMT_INFO_ELEMENT_SSID
,
1673 extra
, wrqu
->data
.length
);
1674 } else { /* We accept any ESSID */
1675 iw_set_mgmt_info_element(IW_MGMT_INFO_ELEMENT_SSID
,
1676 &this->essid
.el
, "ANY", 3);
1678 return wl3501_reset(dev
);
1681 static int wl3501_get_essid(struct net_device
*dev
,
1682 struct iw_request_info
*info
,
1683 union iwreq_data
*wrqu
, char *extra
)
1685 struct wl3501_card
*this = netdev_priv(dev
);
1686 unsigned long flags
;
1688 spin_lock_irqsave(&this->lock
, flags
);
1689 wrqu
->essid
.flags
= 1;
1690 wrqu
->essid
.length
= this->essid
.el
.len
;
1691 memcpy(extra
, this->essid
.essid
, this->essid
.el
.len
);
1692 spin_unlock_irqrestore(&this->lock
, flags
);
1696 static int wl3501_set_nick(struct net_device
*dev
, struct iw_request_info
*info
,
1697 union iwreq_data
*wrqu
, char *extra
)
1699 struct wl3501_card
*this = netdev_priv(dev
);
1701 if (wrqu
->data
.length
> sizeof(this->nick
))
1703 strlcpy(this->nick
, extra
, wrqu
->data
.length
);
1707 static int wl3501_get_nick(struct net_device
*dev
, struct iw_request_info
*info
,
1708 union iwreq_data
*wrqu
, char *extra
)
1710 struct wl3501_card
*this = netdev_priv(dev
);
1712 strlcpy(extra
, this->nick
, 32);
1713 wrqu
->data
.length
= strlen(extra
);
1717 static int wl3501_get_rate(struct net_device
*dev
, struct iw_request_info
*info
,
1718 union iwreq_data
*wrqu
, char *extra
)
1721 * FIXME: have to see from where to get this info, perhaps this card
1722 * works at 1 Mbit/s too... for now leave at 2 Mbit/s that is the most
1723 * common with the Planet Access Points. -acme
1725 wrqu
->bitrate
.value
= 2000000;
1726 wrqu
->bitrate
.fixed
= 1;
1730 static int wl3501_get_rts_threshold(struct net_device
*dev
,
1731 struct iw_request_info
*info
,
1732 union iwreq_data
*wrqu
, char *extra
)
1734 u16 threshold
; /* size checked: it is u16 */
1735 struct wl3501_card
*this = netdev_priv(dev
);
1736 int rc
= wl3501_get_mib_value(this, WL3501_MIB_ATTR_RTS_THRESHOLD
,
1737 &threshold
, sizeof(threshold
));
1739 wrqu
->rts
.value
= threshold
;
1740 wrqu
->rts
.disabled
= threshold
>= 2347;
1741 wrqu
->rts
.fixed
= 1;
1746 static int wl3501_get_frag_threshold(struct net_device
*dev
,
1747 struct iw_request_info
*info
,
1748 union iwreq_data
*wrqu
, char *extra
)
1750 u16 threshold
; /* size checked: it is u16 */
1751 struct wl3501_card
*this = netdev_priv(dev
);
1752 int rc
= wl3501_get_mib_value(this, WL3501_MIB_ATTR_FRAG_THRESHOLD
,
1753 &threshold
, sizeof(threshold
));
1755 wrqu
->frag
.value
= threshold
;
1756 wrqu
->frag
.disabled
= threshold
>= 2346;
1757 wrqu
->frag
.fixed
= 1;
1762 static int wl3501_get_txpow(struct net_device
*dev
,
1763 struct iw_request_info
*info
,
1764 union iwreq_data
*wrqu
, char *extra
)
1767 struct wl3501_card
*this = netdev_priv(dev
);
1768 int rc
= wl3501_get_mib_value(this,
1769 WL3501_MIB_ATTR_CURRENT_TX_PWR_LEVEL
,
1770 &txpow
, sizeof(txpow
));
1772 wrqu
->txpower
.value
= txpow
;
1773 wrqu
->txpower
.disabled
= 0;
1775 * From the MIB values I think this can be configurable,
1776 * as it lists several tx power levels -acme
1778 wrqu
->txpower
.fixed
= 0;
1779 wrqu
->txpower
.flags
= IW_TXPOW_MWATT
;
1784 static int wl3501_get_retry(struct net_device
*dev
,
1785 struct iw_request_info
*info
,
1786 union iwreq_data
*wrqu
, char *extra
)
1788 u8 retry
; /* size checked: it is u8 */
1789 struct wl3501_card
*this = netdev_priv(dev
);
1790 int rc
= wl3501_get_mib_value(this,
1791 WL3501_MIB_ATTR_LONG_RETRY_LIMIT
,
1792 &retry
, sizeof(retry
));
1795 if (wrqu
->retry
.flags
& IW_RETRY_LONG
) {
1796 wrqu
->retry
.flags
= IW_RETRY_LIMIT
| IW_RETRY_LONG
;
1799 rc
= wl3501_get_mib_value(this, WL3501_MIB_ATTR_SHORT_RETRY_LIMIT
,
1800 &retry
, sizeof(retry
));
1803 wrqu
->retry
.flags
= IW_RETRY_LIMIT
| IW_RETRY_SHORT
;
1805 wrqu
->retry
.value
= retry
;
1806 wrqu
->retry
.disabled
= 0;
1811 static int wl3501_get_encode(struct net_device
*dev
,
1812 struct iw_request_info
*info
,
1813 union iwreq_data
*wrqu
, char *extra
)
1815 u8 implemented
, restricted
, keys
[100], len_keys
, tocopy
;
1816 struct wl3501_card
*this = netdev_priv(dev
);
1817 int rc
= wl3501_get_mib_value(this,
1818 WL3501_MIB_ATTR_PRIV_OPT_IMPLEMENTED
,
1819 &implemented
, sizeof(implemented
));
1823 wrqu
->encoding
.flags
= IW_ENCODE_DISABLED
;
1826 rc
= wl3501_get_mib_value(this, WL3501_MIB_ATTR_EXCLUDE_UNENCRYPTED
,
1827 &restricted
, sizeof(restricted
));
1830 wrqu
->encoding
.flags
= restricted
? IW_ENCODE_RESTRICTED
:
1832 rc
= wl3501_get_mib_value(this, WL3501_MIB_ATTR_WEP_KEY_MAPPINGS_LEN
,
1833 &len_keys
, sizeof(len_keys
));
1836 rc
= wl3501_get_mib_value(this, WL3501_MIB_ATTR_WEP_KEY_MAPPINGS
,
1840 tocopy
= min_t(u8
, len_keys
, wrqu
->encoding
.length
);
1841 tocopy
= min_t(u8
, tocopy
, 100);
1842 wrqu
->encoding
.length
= tocopy
;
1843 memcpy(extra
, keys
, tocopy
);
1848 static int wl3501_get_power(struct net_device
*dev
,
1849 struct iw_request_info
*info
,
1850 union iwreq_data
*wrqu
, char *extra
)
1853 struct wl3501_card
*this = netdev_priv(dev
);
1854 int rc
= wl3501_get_mib_value(this,
1855 WL3501_MIB_ATTR_CURRENT_PWR_STATE
,
1856 &pwr_state
, sizeof(pwr_state
));
1859 wrqu
->power
.disabled
= !pwr_state
;
1860 wrqu
->power
.flags
= IW_POWER_ON
;
1865 static const iw_handler wl3501_handler
[] = {
1866 [SIOCGIWNAME
- SIOCIWFIRST
] = wl3501_get_name
,
1867 [SIOCSIWFREQ
- SIOCIWFIRST
] = wl3501_set_freq
,
1868 [SIOCGIWFREQ
- SIOCIWFIRST
] = wl3501_get_freq
,
1869 [SIOCSIWMODE
- SIOCIWFIRST
] = wl3501_set_mode
,
1870 [SIOCGIWMODE
- SIOCIWFIRST
] = wl3501_get_mode
,
1871 [SIOCGIWSENS
- SIOCIWFIRST
] = wl3501_get_sens
,
1872 [SIOCGIWRANGE
- SIOCIWFIRST
] = wl3501_get_range
,
1873 [SIOCSIWSPY
- SIOCIWFIRST
] = iw_handler_set_spy
,
1874 [SIOCGIWSPY
- SIOCIWFIRST
] = iw_handler_get_spy
,
1875 [SIOCSIWTHRSPY
- SIOCIWFIRST
] = iw_handler_set_thrspy
,
1876 [SIOCGIWTHRSPY
- SIOCIWFIRST
] = iw_handler_get_thrspy
,
1877 [SIOCSIWAP
- SIOCIWFIRST
] = wl3501_set_wap
,
1878 [SIOCGIWAP
- SIOCIWFIRST
] = wl3501_get_wap
,
1879 [SIOCSIWSCAN
- SIOCIWFIRST
] = wl3501_set_scan
,
1880 [SIOCGIWSCAN
- SIOCIWFIRST
] = wl3501_get_scan
,
1881 [SIOCSIWESSID
- SIOCIWFIRST
] = wl3501_set_essid
,
1882 [SIOCGIWESSID
- SIOCIWFIRST
] = wl3501_get_essid
,
1883 [SIOCSIWNICKN
- SIOCIWFIRST
] = wl3501_set_nick
,
1884 [SIOCGIWNICKN
- SIOCIWFIRST
] = wl3501_get_nick
,
1885 [SIOCGIWRATE
- SIOCIWFIRST
] = wl3501_get_rate
,
1886 [SIOCGIWRTS
- SIOCIWFIRST
] = wl3501_get_rts_threshold
,
1887 [SIOCGIWFRAG
- SIOCIWFIRST
] = wl3501_get_frag_threshold
,
1888 [SIOCGIWTXPOW
- SIOCIWFIRST
] = wl3501_get_txpow
,
1889 [SIOCGIWRETRY
- SIOCIWFIRST
] = wl3501_get_retry
,
1890 [SIOCGIWENCODE
- SIOCIWFIRST
] = wl3501_get_encode
,
1891 [SIOCGIWPOWER
- SIOCIWFIRST
] = wl3501_get_power
,
1894 static const struct iw_handler_def wl3501_handler_def
= {
1895 .num_standard
= ARRAY_SIZE(wl3501_handler
),
1896 .standard
= (iw_handler
*)wl3501_handler
,
1897 .get_wireless_stats
= wl3501_get_wireless_stats
,
1901 * wl3501_attach - creates an "instance" of the driver
1903 * Creates an "instance" of the driver, allocating local data structures for
1904 * one device. The device is registered with Card Services.
1906 * The dev_link structure is initialized, but we don't actually configure the
1907 * card at this point -- we wait until we receive a card insertion event.
1909 static int wl3501_probe(struct pcmcia_device
*p_dev
)
1911 struct net_device
*dev
;
1912 struct wl3501_card
*this;
1914 /* The io structure describes IO port mapping */
1915 p_dev
->io
.NumPorts1
= 16;
1916 p_dev
->io
.Attributes1
= IO_DATA_PATH_WIDTH_8
;
1917 p_dev
->io
.IOAddrLines
= 5;
1919 /* Interrupt setup */
1920 p_dev
->irq
.Attributes
= IRQ_TYPE_EXCLUSIVE
| IRQ_HANDLE_PRESENT
;
1921 p_dev
->irq
.IRQInfo1
= IRQ_LEVEL_ID
;
1922 p_dev
->irq
.Handler
= wl3501_interrupt
;
1924 /* General socket configuration */
1925 p_dev
->conf
.Attributes
= CONF_ENABLE_IRQ
;
1926 p_dev
->conf
.IntType
= INT_MEMORY_AND_IO
;
1927 p_dev
->conf
.ConfigIndex
= 1;
1929 dev
= alloc_etherdev(sizeof(struct wl3501_card
));
1932 dev
->open
= wl3501_open
;
1933 dev
->stop
= wl3501_close
;
1934 dev
->hard_start_xmit
= wl3501_hard_start_xmit
;
1935 dev
->tx_timeout
= wl3501_tx_timeout
;
1936 dev
->watchdog_timeo
= 5 * HZ
;
1937 dev
->get_stats
= wl3501_get_stats
;
1938 this = netdev_priv(dev
);
1939 this->wireless_data
.spy_data
= &this->spy_data
;
1940 this->p_dev
= p_dev
;
1941 dev
->wireless_data
= &this->wireless_data
;
1942 dev
->wireless_handlers
= (struct iw_handler_def
*)&wl3501_handler_def
;
1943 SET_ETHTOOL_OPS(dev
, &ops
);
1944 netif_stop_queue(dev
);
1945 p_dev
->priv
= p_dev
->irq
.Instance
= dev
;
1947 return wl3501_config(p_dev
);
1952 #define CS_CHECK(fn, ret) \
1953 do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
1956 * wl3501_config - configure the PCMCIA socket and make eth device available
1959 * wl3501_config() is scheduled to run after a CARD_INSERTION event is
1960 * received, to configure the PCMCIA socket, and to make the ethernet device
1961 * available to the system.
1963 static int wl3501_config(struct pcmcia_device
*link
)
1965 struct net_device
*dev
= link
->priv
;
1966 int i
= 0, j
, last_fn
, last_ret
;
1967 struct wl3501_card
*this;
1968 DECLARE_MAC_BUF(mac
);
1970 /* Try allocating IO ports. This tries a few fixed addresses. If you
1971 * want, you can also read the card's config table to pick addresses --
1972 * see the serial driver for an example. */
1974 for (j
= 0x280; j
< 0x400; j
+= 0x20) {
1975 /* The '^0x300' is so that we probe 0x300-0x3ff first, then
1976 * 0x200-0x2ff, and so on, because this seems safer */
1977 link
->io
.BasePort1
= j
;
1978 link
->io
.BasePort2
= link
->io
.BasePort1
+ 0x10;
1979 i
= pcmcia_request_io(link
, &link
->io
);
1980 if (i
== CS_SUCCESS
)
1983 if (i
!= CS_SUCCESS
) {
1984 cs_error(link
, RequestIO
, i
);
1988 /* Now allocate an interrupt line. Note that this does not actually
1989 * assign a handler to the interrupt. */
1991 CS_CHECK(RequestIRQ
, pcmcia_request_irq(link
, &link
->irq
));
1993 /* This actually configures the PCMCIA socket -- setting up the I/O
1994 * windows and the interrupt mapping. */
1996 CS_CHECK(RequestConfiguration
, pcmcia_request_configuration(link
, &link
->conf
));
1998 dev
->irq
= link
->irq
.AssignedIRQ
;
1999 dev
->base_addr
= link
->io
.BasePort1
;
2000 SET_NETDEV_DEV(dev
, &handle_to_dev(link
));
2001 if (register_netdev(dev
)) {
2002 printk(KERN_NOTICE
"wl3501_cs: register_netdev() failed\n");
2006 this = netdev_priv(dev
);
2008 * At this point, the dev_node_t structure(s) should be initialized and
2009 * arranged in a linked list at link->dev_node.
2011 link
->dev_node
= &this->node
;
2013 this->base_addr
= dev
->base_addr
;
2015 if (!wl3501_get_flash_mac_addr(this)) {
2016 printk(KERN_WARNING
"%s: Cant read MAC addr in flash ROM?\n",
2020 strcpy(this->node
.dev_name
, dev
->name
);
2022 for (i
= 0; i
< 6; i
++)
2023 dev
->dev_addr
[i
] = ((char *)&this->mac_addr
)[i
];
2025 /* print probe information */
2026 printk(KERN_INFO
"%s: wl3501 @ 0x%3.3x, IRQ %d, "
2027 "MAC addr in flash ROM:%s\n",
2028 dev
->name
, this->base_addr
, (int)dev
->irq
,
2029 print_mac(mac
, dev
->dev_addr
));
2031 * Initialize card parameters - added by jss
2033 this->net_type
= IW_MODE_INFRA
;
2035 this->join_sta_bss
= 0;
2036 this->adhoc_times
= 0;
2037 iw_set_mgmt_info_element(IW_MGMT_INFO_ELEMENT_SSID
, &this->essid
.el
,
2039 this->card_name
[0] = '\0';
2040 this->firmware_date
[0] = '\0';
2042 this->chan
= iw_default_channel(this->reg_domain
);
2043 strlcpy(this->nick
, "Planet WL3501", sizeof(this->nick
));
2044 spin_lock_init(&this->lock
);
2045 init_waitqueue_head(&this->wait
);
2046 netif_start_queue(dev
);
2050 cs_error(link
, last_fn
, last_ret
);
2052 wl3501_release(link
);
2057 * wl3501_release - unregister the net, release PCMCIA configuration
2060 * After a card is removed, wl3501_release() will unregister the net device,
2061 * and release the PCMCIA configuration. If the device is still open, this
2062 * will be postponed until it is closed.
2064 static void wl3501_release(struct pcmcia_device
*link
)
2066 struct net_device
*dev
= link
->priv
;
2068 /* Unlink the device chain */
2070 unregister_netdev(dev
);
2072 pcmcia_disable_device(link
);
2075 static int wl3501_suspend(struct pcmcia_device
*link
)
2077 struct net_device
*dev
= link
->priv
;
2079 wl3501_pwr_mgmt(netdev_priv(dev
), WL3501_SUSPEND
);
2081 netif_device_detach(dev
);
2086 static int wl3501_resume(struct pcmcia_device
*link
)
2088 struct net_device
*dev
= link
->priv
;
2090 wl3501_pwr_mgmt(netdev_priv(dev
), WL3501_RESUME
);
2093 netif_device_attach(dev
);
2100 static struct pcmcia_device_id wl3501_ids
[] = {
2101 PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0001),
2104 MODULE_DEVICE_TABLE(pcmcia
, wl3501_ids
);
2106 static struct pcmcia_driver wl3501_driver
= {
2107 .owner
= THIS_MODULE
,
2109 .name
= "wl3501_cs",
2111 .probe
= wl3501_probe
,
2112 .remove
= wl3501_detach
,
2113 .id_table
= wl3501_ids
,
2114 .suspend
= wl3501_suspend
,
2115 .resume
= wl3501_resume
,
2118 static int __init
wl3501_init_module(void)
2120 return pcmcia_register_driver(&wl3501_driver
);
2123 static void __exit
wl3501_exit_module(void)
2125 pcmcia_unregister_driver(&wl3501_driver
);
2128 module_init(wl3501_init_module
);
2129 module_exit(wl3501_exit_module
);
2131 MODULE_AUTHOR("Fox Chen <mhchen@golf.ccl.itri.org.tw>, "
2132 "Arnaldo Carvalho de Melo <acme@conectiva.com.br>,"
2133 "Gustavo Niemeyer <niemeyer@conectiva.com>");
2134 MODULE_DESCRIPTION("Planet wl3501 wireless driver");
2135 MODULE_LICENSE("GPL");