2 * drivers/net/wireless/mwl8k.c
3 * Driver for Marvell TOPDOG 802.11 Wireless cards
5 * Copyright (C) 2008-2009 Marvell Semiconductor Inc.
7 * This file is licensed under the terms of the GNU General Public
8 * License version 2. This program is licensed "as is" without any
9 * warranty of any kind, whether express or implied.
12 #include <linux/init.h>
13 #include <linux/module.h>
14 #include <linux/kernel.h>
15 #include <linux/sched.h>
16 #include <linux/spinlock.h>
17 #include <linux/list.h>
18 #include <linux/pci.h>
19 #include <linux/delay.h>
20 #include <linux/completion.h>
21 #include <linux/etherdevice.h>
22 #include <net/mac80211.h>
23 #include <linux/moduleparam.h>
24 #include <linux/firmware.h>
25 #include <linux/workqueue.h>
27 #define MWL8K_DESC "Marvell TOPDOG(R) 802.11 Wireless Network Driver"
28 #define MWL8K_NAME KBUILD_MODNAME
29 #define MWL8K_VERSION "0.11"
31 /* Register definitions */
32 #define MWL8K_HIU_GEN_PTR 0x00000c10
33 #define MWL8K_MODE_STA 0x0000005a
34 #define MWL8K_MODE_AP 0x000000a5
35 #define MWL8K_HIU_INT_CODE 0x00000c14
36 #define MWL8K_FWSTA_READY 0xf0f1f2f4
37 #define MWL8K_FWAP_READY 0xf1f2f4a5
38 #define MWL8K_INT_CODE_CMD_FINISHED 0x00000005
39 #define MWL8K_HIU_SCRATCH 0x00000c40
41 /* Host->device communications */
42 #define MWL8K_HIU_H2A_INTERRUPT_EVENTS 0x00000c18
43 #define MWL8K_HIU_H2A_INTERRUPT_STATUS 0x00000c1c
44 #define MWL8K_HIU_H2A_INTERRUPT_MASK 0x00000c20
45 #define MWL8K_HIU_H2A_INTERRUPT_CLEAR_SEL 0x00000c24
46 #define MWL8K_HIU_H2A_INTERRUPT_STATUS_MASK 0x00000c28
47 #define MWL8K_H2A_INT_DUMMY (1 << 20)
48 #define MWL8K_H2A_INT_RESET (1 << 15)
49 #define MWL8K_H2A_INT_DOORBELL (1 << 1)
50 #define MWL8K_H2A_INT_PPA_READY (1 << 0)
52 /* Device->host communications */
53 #define MWL8K_HIU_A2H_INTERRUPT_EVENTS 0x00000c2c
54 #define MWL8K_HIU_A2H_INTERRUPT_STATUS 0x00000c30
55 #define MWL8K_HIU_A2H_INTERRUPT_MASK 0x00000c34
56 #define MWL8K_HIU_A2H_INTERRUPT_CLEAR_SEL 0x00000c38
57 #define MWL8K_HIU_A2H_INTERRUPT_STATUS_MASK 0x00000c3c
58 #define MWL8K_A2H_INT_DUMMY (1 << 20)
59 #define MWL8K_A2H_INT_CHNL_SWITCHED (1 << 11)
60 #define MWL8K_A2H_INT_QUEUE_EMPTY (1 << 10)
61 #define MWL8K_A2H_INT_RADAR_DETECT (1 << 7)
62 #define MWL8K_A2H_INT_RADIO_ON (1 << 6)
63 #define MWL8K_A2H_INT_RADIO_OFF (1 << 5)
64 #define MWL8K_A2H_INT_MAC_EVENT (1 << 3)
65 #define MWL8K_A2H_INT_OPC_DONE (1 << 2)
66 #define MWL8K_A2H_INT_RX_READY (1 << 1)
67 #define MWL8K_A2H_INT_TX_DONE (1 << 0)
69 #define MWL8K_A2H_EVENTS (MWL8K_A2H_INT_DUMMY | \
70 MWL8K_A2H_INT_CHNL_SWITCHED | \
71 MWL8K_A2H_INT_QUEUE_EMPTY | \
72 MWL8K_A2H_INT_RADAR_DETECT | \
73 MWL8K_A2H_INT_RADIO_ON | \
74 MWL8K_A2H_INT_RADIO_OFF | \
75 MWL8K_A2H_INT_MAC_EVENT | \
76 MWL8K_A2H_INT_OPC_DONE | \
77 MWL8K_A2H_INT_RX_READY | \
78 MWL8K_A2H_INT_TX_DONE)
80 #define MWL8K_RX_QUEUES 1
81 #define MWL8K_TX_QUEUES 4
85 void (*rxd_init
)(void *rxd
, dma_addr_t next_dma_addr
);
86 void (*rxd_refill
)(void *rxd
, dma_addr_t addr
, int len
);
87 int (*rxd_process
)(void *rxd
, struct ieee80211_rx_status
*status
,
91 struct mwl8k_device_info
{
95 struct rxd_ops
*ap_rxd_ops
;
98 struct mwl8k_rx_queue
{
101 /* hw receives here */
104 /* refill descs here */
111 DECLARE_PCI_UNMAP_ADDR(dma
)
115 struct mwl8k_tx_queue
{
116 /* hw transmits here */
119 /* sw appends here */
122 struct ieee80211_tx_queue_stats stats
;
123 struct mwl8k_tx_desc
*txd
;
125 struct sk_buff
**skb
;
129 struct ieee80211_hw
*hw
;
130 struct pci_dev
*pdev
;
132 struct mwl8k_device_info
*device_info
;
138 struct firmware
*fw_helper
;
139 struct firmware
*fw_ucode
;
141 /* hardware/firmware parameters */
143 struct rxd_ops
*rxd_ops
;
145 /* firmware access */
146 struct mutex fw_mutex
;
147 struct task_struct
*fw_mutex_owner
;
149 struct completion
*hostcmd_wait
;
151 /* lock held over TX and TX reap */
154 /* TX quiesce completion, protected by fw_mutex and tx_lock */
155 struct completion
*tx_wait
;
157 struct ieee80211_vif
*vif
;
159 struct ieee80211_channel
*current_channel
;
161 /* power management status cookie from firmware */
163 dma_addr_t cookie_dma
;
170 * Running count of TX packets in flight, to avoid
171 * iterating over the transmit rings each time.
175 struct mwl8k_rx_queue rxq
[MWL8K_RX_QUEUES
];
176 struct mwl8k_tx_queue txq
[MWL8K_TX_QUEUES
];
179 struct ieee80211_supported_band band
;
180 struct ieee80211_channel channels
[14];
181 struct ieee80211_rate rates
[14];
184 bool radio_short_preamble
;
185 bool sniffer_enabled
;
188 struct work_struct sta_notify_worker
;
189 spinlock_t sta_notify_list_lock
;
190 struct list_head sta_notify_list
;
192 /* XXX need to convert this to handle multiple interfaces */
194 u8 capture_bssid
[ETH_ALEN
];
195 struct sk_buff
*beacon_skb
;
198 * This FJ worker has to be global as it is scheduled from the
199 * RX handler. At this point we don't know which interface it
200 * belongs to until the list of bssids waiting to complete join
203 struct work_struct finalize_join_worker
;
205 /* Tasklet to reclaim TX descriptors and buffers after tx */
206 struct tasklet_struct tx_reclaim_task
;
209 /* Per interface specific private data */
211 /* Local MAC address. */
212 u8 mac_addr
[ETH_ALEN
];
214 /* Index into station database. Returned by UPDATE_STADB. */
217 /* Non AMPDU sequence number assigned by driver */
221 #define MWL8K_VIF(_vif) ((struct mwl8k_vif *)&((_vif)->drv_priv))
223 static const struct ieee80211_channel mwl8k_channels
[] = {
224 { .center_freq
= 2412, .hw_value
= 1, },
225 { .center_freq
= 2417, .hw_value
= 2, },
226 { .center_freq
= 2422, .hw_value
= 3, },
227 { .center_freq
= 2427, .hw_value
= 4, },
228 { .center_freq
= 2432, .hw_value
= 5, },
229 { .center_freq
= 2437, .hw_value
= 6, },
230 { .center_freq
= 2442, .hw_value
= 7, },
231 { .center_freq
= 2447, .hw_value
= 8, },
232 { .center_freq
= 2452, .hw_value
= 9, },
233 { .center_freq
= 2457, .hw_value
= 10, },
234 { .center_freq
= 2462, .hw_value
= 11, },
235 { .center_freq
= 2467, .hw_value
= 12, },
236 { .center_freq
= 2472, .hw_value
= 13, },
237 { .center_freq
= 2484, .hw_value
= 14, },
240 static const struct ieee80211_rate mwl8k_rates
[] = {
241 { .bitrate
= 10, .hw_value
= 2, },
242 { .bitrate
= 20, .hw_value
= 4, },
243 { .bitrate
= 55, .hw_value
= 11, },
244 { .bitrate
= 110, .hw_value
= 22, },
245 { .bitrate
= 220, .hw_value
= 44, },
246 { .bitrate
= 60, .hw_value
= 12, },
247 { .bitrate
= 90, .hw_value
= 18, },
248 { .bitrate
= 120, .hw_value
= 24, },
249 { .bitrate
= 180, .hw_value
= 36, },
250 { .bitrate
= 240, .hw_value
= 48, },
251 { .bitrate
= 360, .hw_value
= 72, },
252 { .bitrate
= 480, .hw_value
= 96, },
253 { .bitrate
= 540, .hw_value
= 108, },
254 { .bitrate
= 720, .hw_value
= 144, },
257 static const u8 mwl8k_rateids
[12] = {
258 2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108,
261 /* Set or get info from Firmware */
262 #define MWL8K_CMD_SET 0x0001
263 #define MWL8K_CMD_GET 0x0000
265 /* Firmware command codes */
266 #define MWL8K_CMD_CODE_DNLD 0x0001
267 #define MWL8K_CMD_GET_HW_SPEC 0x0003
268 #define MWL8K_CMD_SET_HW_SPEC 0x0004
269 #define MWL8K_CMD_MAC_MULTICAST_ADR 0x0010
270 #define MWL8K_CMD_GET_STAT 0x0014
271 #define MWL8K_CMD_RADIO_CONTROL 0x001c
272 #define MWL8K_CMD_RF_TX_POWER 0x001e
273 #define MWL8K_CMD_RF_ANTENNA 0x0020
274 #define MWL8K_CMD_SET_PRE_SCAN 0x0107
275 #define MWL8K_CMD_SET_POST_SCAN 0x0108
276 #define MWL8K_CMD_SET_RF_CHANNEL 0x010a
277 #define MWL8K_CMD_SET_AID 0x010d
278 #define MWL8K_CMD_SET_RATE 0x0110
279 #define MWL8K_CMD_SET_FINALIZE_JOIN 0x0111
280 #define MWL8K_CMD_RTS_THRESHOLD 0x0113
281 #define MWL8K_CMD_SET_SLOT 0x0114
282 #define MWL8K_CMD_SET_EDCA_PARAMS 0x0115
283 #define MWL8K_CMD_SET_WMM_MODE 0x0123
284 #define MWL8K_CMD_MIMO_CONFIG 0x0125
285 #define MWL8K_CMD_USE_FIXED_RATE 0x0126
286 #define MWL8K_CMD_ENABLE_SNIFFER 0x0150
287 #define MWL8K_CMD_SET_MAC_ADDR 0x0202
288 #define MWL8K_CMD_SET_RATEADAPT_MODE 0x0203
289 #define MWL8K_CMD_UPDATE_STADB 0x1123
291 static const char *mwl8k_cmd_name(u16 cmd
, char *buf
, int bufsize
)
293 #define MWL8K_CMDNAME(x) case MWL8K_CMD_##x: do {\
294 snprintf(buf, bufsize, "%s", #x);\
297 switch (cmd
& ~0x8000) {
298 MWL8K_CMDNAME(CODE_DNLD
);
299 MWL8K_CMDNAME(GET_HW_SPEC
);
300 MWL8K_CMDNAME(SET_HW_SPEC
);
301 MWL8K_CMDNAME(MAC_MULTICAST_ADR
);
302 MWL8K_CMDNAME(GET_STAT
);
303 MWL8K_CMDNAME(RADIO_CONTROL
);
304 MWL8K_CMDNAME(RF_TX_POWER
);
305 MWL8K_CMDNAME(RF_ANTENNA
);
306 MWL8K_CMDNAME(SET_PRE_SCAN
);
307 MWL8K_CMDNAME(SET_POST_SCAN
);
308 MWL8K_CMDNAME(SET_RF_CHANNEL
);
309 MWL8K_CMDNAME(SET_AID
);
310 MWL8K_CMDNAME(SET_RATE
);
311 MWL8K_CMDNAME(SET_FINALIZE_JOIN
);
312 MWL8K_CMDNAME(RTS_THRESHOLD
);
313 MWL8K_CMDNAME(SET_SLOT
);
314 MWL8K_CMDNAME(SET_EDCA_PARAMS
);
315 MWL8K_CMDNAME(SET_WMM_MODE
);
316 MWL8K_CMDNAME(MIMO_CONFIG
);
317 MWL8K_CMDNAME(USE_FIXED_RATE
);
318 MWL8K_CMDNAME(ENABLE_SNIFFER
);
319 MWL8K_CMDNAME(SET_MAC_ADDR
);
320 MWL8K_CMDNAME(SET_RATEADAPT_MODE
);
321 MWL8K_CMDNAME(UPDATE_STADB
);
323 snprintf(buf
, bufsize
, "0x%x", cmd
);
330 /* Hardware and firmware reset */
331 static void mwl8k_hw_reset(struct mwl8k_priv
*priv
)
333 iowrite32(MWL8K_H2A_INT_RESET
,
334 priv
->regs
+ MWL8K_HIU_H2A_INTERRUPT_EVENTS
);
335 iowrite32(MWL8K_H2A_INT_RESET
,
336 priv
->regs
+ MWL8K_HIU_H2A_INTERRUPT_EVENTS
);
340 /* Release fw image */
341 static void mwl8k_release_fw(struct firmware
**fw
)
345 release_firmware(*fw
);
349 static void mwl8k_release_firmware(struct mwl8k_priv
*priv
)
351 mwl8k_release_fw(&priv
->fw_ucode
);
352 mwl8k_release_fw(&priv
->fw_helper
);
355 /* Request fw image */
356 static int mwl8k_request_fw(struct mwl8k_priv
*priv
,
357 const char *fname
, struct firmware
**fw
)
359 /* release current image */
361 mwl8k_release_fw(fw
);
363 return request_firmware((const struct firmware
**)fw
,
364 fname
, &priv
->pdev
->dev
);
367 static int mwl8k_request_firmware(struct mwl8k_priv
*priv
)
369 struct mwl8k_device_info
*di
= priv
->device_info
;
372 if (di
->helper_image
!= NULL
) {
373 rc
= mwl8k_request_fw(priv
, di
->helper_image
, &priv
->fw_helper
);
375 printk(KERN_ERR
"%s: Error requesting helper "
376 "firmware file %s\n", pci_name(priv
->pdev
),
382 rc
= mwl8k_request_fw(priv
, di
->fw_image
, &priv
->fw_ucode
);
384 printk(KERN_ERR
"%s: Error requesting firmware file %s\n",
385 pci_name(priv
->pdev
), di
->fw_image
);
386 mwl8k_release_fw(&priv
->fw_helper
);
393 MODULE_FIRMWARE("mwl8k/helper_8687.fw");
394 MODULE_FIRMWARE("mwl8k/fmimage_8687.fw");
396 struct mwl8k_cmd_pkt
{
402 } __attribute__((packed
));
408 mwl8k_send_fw_load_cmd(struct mwl8k_priv
*priv
, void *data
, int length
)
410 void __iomem
*regs
= priv
->regs
;
414 dma_addr
= pci_map_single(priv
->pdev
, data
, length
, PCI_DMA_TODEVICE
);
415 if (pci_dma_mapping_error(priv
->pdev
, dma_addr
))
418 iowrite32(dma_addr
, regs
+ MWL8K_HIU_GEN_PTR
);
419 iowrite32(0, regs
+ MWL8K_HIU_INT_CODE
);
420 iowrite32(MWL8K_H2A_INT_DOORBELL
,
421 regs
+ MWL8K_HIU_H2A_INTERRUPT_EVENTS
);
422 iowrite32(MWL8K_H2A_INT_DUMMY
,
423 regs
+ MWL8K_HIU_H2A_INTERRUPT_EVENTS
);
429 int_code
= ioread32(regs
+ MWL8K_HIU_INT_CODE
);
430 if (int_code
== MWL8K_INT_CODE_CMD_FINISHED
) {
431 iowrite32(0, regs
+ MWL8K_HIU_INT_CODE
);
439 pci_unmap_single(priv
->pdev
, dma_addr
, length
, PCI_DMA_TODEVICE
);
441 return loops
? 0 : -ETIMEDOUT
;
444 static int mwl8k_load_fw_image(struct mwl8k_priv
*priv
,
445 const u8
*data
, size_t length
)
447 struct mwl8k_cmd_pkt
*cmd
;
451 cmd
= kmalloc(sizeof(*cmd
) + 256, GFP_KERNEL
);
455 cmd
->code
= cpu_to_le16(MWL8K_CMD_CODE_DNLD
);
461 int block_size
= length
> 256 ? 256 : length
;
463 memcpy(cmd
->payload
, data
+ done
, block_size
);
464 cmd
->length
= cpu_to_le16(block_size
);
466 rc
= mwl8k_send_fw_load_cmd(priv
, cmd
,
467 sizeof(*cmd
) + block_size
);
472 length
-= block_size
;
477 rc
= mwl8k_send_fw_load_cmd(priv
, cmd
, sizeof(*cmd
));
485 static int mwl8k_feed_fw_image(struct mwl8k_priv
*priv
,
486 const u8
*data
, size_t length
)
488 unsigned char *buffer
;
489 int may_continue
, rc
= 0;
490 u32 done
, prev_block_size
;
492 buffer
= kmalloc(1024, GFP_KERNEL
);
499 while (may_continue
> 0) {
502 block_size
= ioread32(priv
->regs
+ MWL8K_HIU_SCRATCH
);
503 if (block_size
& 1) {
507 done
+= prev_block_size
;
508 length
-= prev_block_size
;
511 if (block_size
> 1024 || block_size
> length
) {
521 if (block_size
== 0) {
528 prev_block_size
= block_size
;
529 memcpy(buffer
, data
+ done
, block_size
);
531 rc
= mwl8k_send_fw_load_cmd(priv
, buffer
, block_size
);
536 if (!rc
&& length
!= 0)
544 static int mwl8k_load_firmware(struct ieee80211_hw
*hw
)
546 struct mwl8k_priv
*priv
= hw
->priv
;
547 struct firmware
*fw
= priv
->fw_ucode
;
551 if (!memcmp(fw
->data
, "\x01\x00\x00\x00", 4)) {
552 struct firmware
*helper
= priv
->fw_helper
;
554 if (helper
== NULL
) {
555 printk(KERN_ERR
"%s: helper image needed but none "
556 "given\n", pci_name(priv
->pdev
));
560 rc
= mwl8k_load_fw_image(priv
, helper
->data
, helper
->size
);
562 printk(KERN_ERR
"%s: unable to load firmware "
563 "helper image\n", pci_name(priv
->pdev
));
568 rc
= mwl8k_feed_fw_image(priv
, fw
->data
, fw
->size
);
570 rc
= mwl8k_load_fw_image(priv
, fw
->data
, fw
->size
);
574 printk(KERN_ERR
"%s: unable to load firmware image\n",
575 pci_name(priv
->pdev
));
579 iowrite32(MWL8K_MODE_STA
, priv
->regs
+ MWL8K_HIU_GEN_PTR
);
585 ready_code
= ioread32(priv
->regs
+ MWL8K_HIU_INT_CODE
);
586 if (ready_code
== MWL8K_FWAP_READY
) {
589 } else if (ready_code
== MWL8K_FWSTA_READY
) {
598 return loops
? 0 : -ETIMEDOUT
;
602 /* DMA header used by firmware and hardware. */
603 struct mwl8k_dma_data
{
605 struct ieee80211_hdr wh
;
607 } __attribute__((packed
));
609 /* Routines to add/remove DMA header from skb. */
610 static inline void mwl8k_remove_dma_header(struct sk_buff
*skb
, __le16 qos
)
612 struct mwl8k_dma_data
*tr
;
615 tr
= (struct mwl8k_dma_data
*)skb
->data
;
616 hdrlen
= ieee80211_hdrlen(tr
->wh
.frame_control
);
618 if (hdrlen
!= sizeof(tr
->wh
)) {
619 if (ieee80211_is_data_qos(tr
->wh
.frame_control
)) {
620 memmove(tr
->data
- hdrlen
, &tr
->wh
, hdrlen
- 2);
621 *((__le16
*)(tr
->data
- 2)) = qos
;
623 memmove(tr
->data
- hdrlen
, &tr
->wh
, hdrlen
);
627 if (hdrlen
!= sizeof(*tr
))
628 skb_pull(skb
, sizeof(*tr
) - hdrlen
);
631 static inline void mwl8k_add_dma_header(struct sk_buff
*skb
)
633 struct ieee80211_hdr
*wh
;
635 struct mwl8k_dma_data
*tr
;
638 * Add a firmware DMA header; the firmware requires that we
639 * present a 2-byte payload length followed by a 4-address
640 * header (without QoS field), followed (optionally) by any
641 * WEP/ExtIV header (but only filled in for CCMP).
643 wh
= (struct ieee80211_hdr
*)skb
->data
;
645 hdrlen
= ieee80211_hdrlen(wh
->frame_control
);
646 if (hdrlen
!= sizeof(*tr
))
647 skb_push(skb
, sizeof(*tr
) - hdrlen
);
649 if (ieee80211_is_data_qos(wh
->frame_control
))
652 tr
= (struct mwl8k_dma_data
*)skb
->data
;
654 memmove(&tr
->wh
, wh
, hdrlen
);
655 if (hdrlen
!= sizeof(tr
->wh
))
656 memset(((void *)&tr
->wh
) + hdrlen
, 0, sizeof(tr
->wh
) - hdrlen
);
659 * Firmware length is the length of the fully formed "802.11
660 * payload". That is, everything except for the 802.11 header.
661 * This includes all crypto material including the MIC.
663 tr
->fwlen
= cpu_to_le16(skb
->len
- sizeof(*tr
));
668 * Packet reception for 88w8366 AP firmware.
670 struct mwl8k_rxd_8366_ap
{
674 __le32 pkt_phys_addr
;
675 __le32 next_rxd_phys_addr
;
679 __le32 hw_noise_floor_info
;
686 } __attribute__((packed
));
688 #define MWL8K_8366_AP_RATE_INFO_MCS_FORMAT 0x80
689 #define MWL8K_8366_AP_RATE_INFO_40MHZ 0x40
690 #define MWL8K_8366_AP_RATE_INFO_RATEID(x) ((x) & 0x3f)
692 #define MWL8K_8366_AP_RX_CTRL_OWNED_BY_HOST 0x80
694 static void mwl8k_rxd_8366_ap_init(void *_rxd
, dma_addr_t next_dma_addr
)
696 struct mwl8k_rxd_8366_ap
*rxd
= _rxd
;
698 rxd
->next_rxd_phys_addr
= cpu_to_le32(next_dma_addr
);
699 rxd
->rx_ctrl
= MWL8K_8366_AP_RX_CTRL_OWNED_BY_HOST
;
702 static void mwl8k_rxd_8366_ap_refill(void *_rxd
, dma_addr_t addr
, int len
)
704 struct mwl8k_rxd_8366_ap
*rxd
= _rxd
;
706 rxd
->pkt_len
= cpu_to_le16(len
);
707 rxd
->pkt_phys_addr
= cpu_to_le32(addr
);
713 mwl8k_rxd_8366_ap_process(void *_rxd
, struct ieee80211_rx_status
*status
,
716 struct mwl8k_rxd_8366_ap
*rxd
= _rxd
;
718 if (!(rxd
->rx_ctrl
& MWL8K_8366_AP_RX_CTRL_OWNED_BY_HOST
))
722 memset(status
, 0, sizeof(*status
));
724 status
->signal
= -rxd
->rssi
;
725 status
->noise
= -rxd
->noise_floor
;
727 if (rxd
->rate
& MWL8K_8366_AP_RATE_INFO_MCS_FORMAT
) {
728 status
->flag
|= RX_FLAG_HT
;
729 if (rxd
->rate
& MWL8K_8366_AP_RATE_INFO_40MHZ
)
730 status
->flag
|= RX_FLAG_40MHZ
;
731 status
->rate_idx
= MWL8K_8366_AP_RATE_INFO_RATEID(rxd
->rate
);
735 for (i
= 0; i
< ARRAY_SIZE(mwl8k_rates
); i
++) {
736 if (mwl8k_rates
[i
].hw_value
== rxd
->rate
) {
737 status
->rate_idx
= i
;
743 status
->band
= IEEE80211_BAND_2GHZ
;
744 status
->freq
= ieee80211_channel_to_frequency(rxd
->channel
);
746 *qos
= rxd
->qos_control
;
748 return le16_to_cpu(rxd
->pkt_len
);
751 static struct rxd_ops rxd_8366_ap_ops
= {
752 .rxd_size
= sizeof(struct mwl8k_rxd_8366_ap
),
753 .rxd_init
= mwl8k_rxd_8366_ap_init
,
754 .rxd_refill
= mwl8k_rxd_8366_ap_refill
,
755 .rxd_process
= mwl8k_rxd_8366_ap_process
,
759 * Packet reception for STA firmware.
761 struct mwl8k_rxd_sta
{
765 __le32 pkt_phys_addr
;
766 __le32 next_rxd_phys_addr
;
776 } __attribute__((packed
));
778 #define MWL8K_STA_RATE_INFO_SHORTPRE 0x8000
779 #define MWL8K_STA_RATE_INFO_ANTSELECT(x) (((x) >> 11) & 0x3)
780 #define MWL8K_STA_RATE_INFO_RATEID(x) (((x) >> 3) & 0x3f)
781 #define MWL8K_STA_RATE_INFO_40MHZ 0x0004
782 #define MWL8K_STA_RATE_INFO_SHORTGI 0x0002
783 #define MWL8K_STA_RATE_INFO_MCS_FORMAT 0x0001
785 #define MWL8K_STA_RX_CTRL_OWNED_BY_HOST 0x02
787 static void mwl8k_rxd_sta_init(void *_rxd
, dma_addr_t next_dma_addr
)
789 struct mwl8k_rxd_sta
*rxd
= _rxd
;
791 rxd
->next_rxd_phys_addr
= cpu_to_le32(next_dma_addr
);
792 rxd
->rx_ctrl
= MWL8K_STA_RX_CTRL_OWNED_BY_HOST
;
795 static void mwl8k_rxd_sta_refill(void *_rxd
, dma_addr_t addr
, int len
)
797 struct mwl8k_rxd_sta
*rxd
= _rxd
;
799 rxd
->pkt_len
= cpu_to_le16(len
);
800 rxd
->pkt_phys_addr
= cpu_to_le32(addr
);
806 mwl8k_rxd_sta_process(void *_rxd
, struct ieee80211_rx_status
*status
,
809 struct mwl8k_rxd_sta
*rxd
= _rxd
;
812 if (!(rxd
->rx_ctrl
& MWL8K_STA_RX_CTRL_OWNED_BY_HOST
))
816 rate_info
= le16_to_cpu(rxd
->rate_info
);
818 memset(status
, 0, sizeof(*status
));
820 status
->signal
= -rxd
->rssi
;
821 status
->noise
= -rxd
->noise_level
;
822 status
->antenna
= MWL8K_STA_RATE_INFO_ANTSELECT(rate_info
);
823 status
->rate_idx
= MWL8K_STA_RATE_INFO_RATEID(rate_info
);
825 if (rate_info
& MWL8K_STA_RATE_INFO_SHORTPRE
)
826 status
->flag
|= RX_FLAG_SHORTPRE
;
827 if (rate_info
& MWL8K_STA_RATE_INFO_40MHZ
)
828 status
->flag
|= RX_FLAG_40MHZ
;
829 if (rate_info
& MWL8K_STA_RATE_INFO_SHORTGI
)
830 status
->flag
|= RX_FLAG_SHORT_GI
;
831 if (rate_info
& MWL8K_STA_RATE_INFO_MCS_FORMAT
)
832 status
->flag
|= RX_FLAG_HT
;
834 status
->band
= IEEE80211_BAND_2GHZ
;
835 status
->freq
= ieee80211_channel_to_frequency(rxd
->channel
);
837 *qos
= rxd
->qos_control
;
839 return le16_to_cpu(rxd
->pkt_len
);
842 static struct rxd_ops rxd_sta_ops
= {
843 .rxd_size
= sizeof(struct mwl8k_rxd_sta
),
844 .rxd_init
= mwl8k_rxd_sta_init
,
845 .rxd_refill
= mwl8k_rxd_sta_refill
,
846 .rxd_process
= mwl8k_rxd_sta_process
,
850 #define MWL8K_RX_DESCS 256
851 #define MWL8K_RX_MAXSZ 3800
853 static int mwl8k_rxq_init(struct ieee80211_hw
*hw
, int index
)
855 struct mwl8k_priv
*priv
= hw
->priv
;
856 struct mwl8k_rx_queue
*rxq
= priv
->rxq
+ index
;
864 size
= MWL8K_RX_DESCS
* priv
->rxd_ops
->rxd_size
;
866 rxq
->rxd
= pci_alloc_consistent(priv
->pdev
, size
, &rxq
->rxd_dma
);
867 if (rxq
->rxd
== NULL
) {
868 printk(KERN_ERR
"%s: failed to alloc RX descriptors\n",
869 wiphy_name(hw
->wiphy
));
872 memset(rxq
->rxd
, 0, size
);
874 rxq
->buf
= kmalloc(MWL8K_RX_DESCS
* sizeof(*rxq
->buf
), GFP_KERNEL
);
875 if (rxq
->buf
== NULL
) {
876 printk(KERN_ERR
"%s: failed to alloc RX skbuff list\n",
877 wiphy_name(hw
->wiphy
));
878 pci_free_consistent(priv
->pdev
, size
, rxq
->rxd
, rxq
->rxd_dma
);
881 memset(rxq
->buf
, 0, MWL8K_RX_DESCS
* sizeof(*rxq
->buf
));
883 for (i
= 0; i
< MWL8K_RX_DESCS
; i
++) {
887 dma_addr_t next_dma_addr
;
889 desc_size
= priv
->rxd_ops
->rxd_size
;
890 rxd
= rxq
->rxd
+ (i
* priv
->rxd_ops
->rxd_size
);
893 if (nexti
== MWL8K_RX_DESCS
)
895 next_dma_addr
= rxq
->rxd_dma
+ (nexti
* desc_size
);
897 priv
->rxd_ops
->rxd_init(rxd
, next_dma_addr
);
903 static int rxq_refill(struct ieee80211_hw
*hw
, int index
, int limit
)
905 struct mwl8k_priv
*priv
= hw
->priv
;
906 struct mwl8k_rx_queue
*rxq
= priv
->rxq
+ index
;
910 while (rxq
->rxd_count
< MWL8K_RX_DESCS
&& limit
--) {
916 skb
= dev_alloc_skb(MWL8K_RX_MAXSZ
);
920 addr
= pci_map_single(priv
->pdev
, skb
->data
,
921 MWL8K_RX_MAXSZ
, DMA_FROM_DEVICE
);
925 if (rxq
->tail
== MWL8K_RX_DESCS
)
927 rxq
->buf
[rx
].skb
= skb
;
928 pci_unmap_addr_set(&rxq
->buf
[rx
], dma
, addr
);
930 rxd
= rxq
->rxd
+ (rx
* priv
->rxd_ops
->rxd_size
);
931 priv
->rxd_ops
->rxd_refill(rxd
, addr
, MWL8K_RX_MAXSZ
);
939 /* Must be called only when the card's reception is completely halted */
940 static void mwl8k_rxq_deinit(struct ieee80211_hw
*hw
, int index
)
942 struct mwl8k_priv
*priv
= hw
->priv
;
943 struct mwl8k_rx_queue
*rxq
= priv
->rxq
+ index
;
946 for (i
= 0; i
< MWL8K_RX_DESCS
; i
++) {
947 if (rxq
->buf
[i
].skb
!= NULL
) {
948 pci_unmap_single(priv
->pdev
,
949 pci_unmap_addr(&rxq
->buf
[i
], dma
),
950 MWL8K_RX_MAXSZ
, PCI_DMA_FROMDEVICE
);
951 pci_unmap_addr_set(&rxq
->buf
[i
], dma
, 0);
953 kfree_skb(rxq
->buf
[i
].skb
);
954 rxq
->buf
[i
].skb
= NULL
;
961 pci_free_consistent(priv
->pdev
,
962 MWL8K_RX_DESCS
* priv
->rxd_ops
->rxd_size
,
963 rxq
->rxd
, rxq
->rxd_dma
);
969 * Scan a list of BSSIDs to process for finalize join.
970 * Allows for extension to process multiple BSSIDs.
973 mwl8k_capture_bssid(struct mwl8k_priv
*priv
, struct ieee80211_hdr
*wh
)
975 return priv
->capture_beacon
&&
976 ieee80211_is_beacon(wh
->frame_control
) &&
977 !compare_ether_addr(wh
->addr3
, priv
->capture_bssid
);
980 static inline void mwl8k_save_beacon(struct ieee80211_hw
*hw
,
983 struct mwl8k_priv
*priv
= hw
->priv
;
985 priv
->capture_beacon
= false;
986 memset(priv
->capture_bssid
, 0, ETH_ALEN
);
989 * Use GFP_ATOMIC as rxq_process is called from
990 * the primary interrupt handler, memory allocation call
993 priv
->beacon_skb
= skb_copy(skb
, GFP_ATOMIC
);
994 if (priv
->beacon_skb
!= NULL
)
995 ieee80211_queue_work(hw
, &priv
->finalize_join_worker
);
998 static int rxq_process(struct ieee80211_hw
*hw
, int index
, int limit
)
1000 struct mwl8k_priv
*priv
= hw
->priv
;
1001 struct mwl8k_rx_queue
*rxq
= priv
->rxq
+ index
;
1005 while (rxq
->rxd_count
&& limit
--) {
1006 struct sk_buff
*skb
;
1009 struct ieee80211_rx_status status
;
1012 skb
= rxq
->buf
[rxq
->head
].skb
;
1016 rxd
= rxq
->rxd
+ (rxq
->head
* priv
->rxd_ops
->rxd_size
);
1018 pkt_len
= priv
->rxd_ops
->rxd_process(rxd
, &status
, &qos
);
1022 rxq
->buf
[rxq
->head
].skb
= NULL
;
1024 pci_unmap_single(priv
->pdev
,
1025 pci_unmap_addr(&rxq
->buf
[rxq
->head
], dma
),
1026 MWL8K_RX_MAXSZ
, PCI_DMA_FROMDEVICE
);
1027 pci_unmap_addr_set(&rxq
->buf
[rxq
->head
], dma
, 0);
1030 if (rxq
->head
== MWL8K_RX_DESCS
)
1035 skb_put(skb
, pkt_len
);
1036 mwl8k_remove_dma_header(skb
, qos
);
1039 * Check for a pending join operation. Save a
1040 * copy of the beacon and schedule a tasklet to
1041 * send a FINALIZE_JOIN command to the firmware.
1043 if (mwl8k_capture_bssid(priv
, (void *)skb
->data
))
1044 mwl8k_save_beacon(hw
, skb
);
1046 memcpy(IEEE80211_SKB_RXCB(skb
), &status
, sizeof(status
));
1047 ieee80211_rx_irqsafe(hw
, skb
);
1057 * Packet transmission.
1060 #define MWL8K_TXD_STATUS_OK 0x00000001
1061 #define MWL8K_TXD_STATUS_OK_RETRY 0x00000002
1062 #define MWL8K_TXD_STATUS_OK_MORE_RETRY 0x00000004
1063 #define MWL8K_TXD_STATUS_MULTICAST_TX 0x00000008
1064 #define MWL8K_TXD_STATUS_FW_OWNED 0x80000000
1066 #define MWL8K_QOS_QLEN_UNSPEC 0xff00
1067 #define MWL8K_QOS_ACK_POLICY_MASK 0x0060
1068 #define MWL8K_QOS_ACK_POLICY_NORMAL 0x0000
1069 #define MWL8K_QOS_ACK_POLICY_BLOCKACK 0x0060
1070 #define MWL8K_QOS_EOSP 0x0010
1072 struct mwl8k_tx_desc
{
1077 __le32 pkt_phys_addr
;
1079 __u8 dest_MAC_addr
[ETH_ALEN
];
1080 __le32 next_txd_phys_addr
;
1085 } __attribute__((packed
));
1087 #define MWL8K_TX_DESCS 128
1089 static int mwl8k_txq_init(struct ieee80211_hw
*hw
, int index
)
1091 struct mwl8k_priv
*priv
= hw
->priv
;
1092 struct mwl8k_tx_queue
*txq
= priv
->txq
+ index
;
1096 memset(&txq
->stats
, 0, sizeof(struct ieee80211_tx_queue_stats
));
1097 txq
->stats
.limit
= MWL8K_TX_DESCS
;
1101 size
= MWL8K_TX_DESCS
* sizeof(struct mwl8k_tx_desc
);
1103 txq
->txd
= pci_alloc_consistent(priv
->pdev
, size
, &txq
->txd_dma
);
1104 if (txq
->txd
== NULL
) {
1105 printk(KERN_ERR
"%s: failed to alloc TX descriptors\n",
1106 wiphy_name(hw
->wiphy
));
1109 memset(txq
->txd
, 0, size
);
1111 txq
->skb
= kmalloc(MWL8K_TX_DESCS
* sizeof(*txq
->skb
), GFP_KERNEL
);
1112 if (txq
->skb
== NULL
) {
1113 printk(KERN_ERR
"%s: failed to alloc TX skbuff list\n",
1114 wiphy_name(hw
->wiphy
));
1115 pci_free_consistent(priv
->pdev
, size
, txq
->txd
, txq
->txd_dma
);
1118 memset(txq
->skb
, 0, MWL8K_TX_DESCS
* sizeof(*txq
->skb
));
1120 for (i
= 0; i
< MWL8K_TX_DESCS
; i
++) {
1121 struct mwl8k_tx_desc
*tx_desc
;
1124 tx_desc
= txq
->txd
+ i
;
1125 nexti
= (i
+ 1) % MWL8K_TX_DESCS
;
1127 tx_desc
->status
= 0;
1128 tx_desc
->next_txd_phys_addr
=
1129 cpu_to_le32(txq
->txd_dma
+ nexti
* sizeof(*tx_desc
));
1135 static inline void mwl8k_tx_start(struct mwl8k_priv
*priv
)
1137 iowrite32(MWL8K_H2A_INT_PPA_READY
,
1138 priv
->regs
+ MWL8K_HIU_H2A_INTERRUPT_EVENTS
);
1139 iowrite32(MWL8K_H2A_INT_DUMMY
,
1140 priv
->regs
+ MWL8K_HIU_H2A_INTERRUPT_EVENTS
);
1141 ioread32(priv
->regs
+ MWL8K_HIU_INT_CODE
);
1144 static void mwl8k_dump_tx_rings(struct ieee80211_hw
*hw
)
1146 struct mwl8k_priv
*priv
= hw
->priv
;
1149 for (i
= 0; i
< MWL8K_TX_QUEUES
; i
++) {
1150 struct mwl8k_tx_queue
*txq
= priv
->txq
+ i
;
1156 for (desc
= 0; desc
< MWL8K_TX_DESCS
; desc
++) {
1157 struct mwl8k_tx_desc
*tx_desc
= txq
->txd
+ desc
;
1160 status
= le32_to_cpu(tx_desc
->status
);
1161 if (status
& MWL8K_TXD_STATUS_FW_OWNED
)
1166 if (tx_desc
->pkt_len
== 0)
1170 printk(KERN_ERR
"%s: txq[%d] len=%d head=%d tail=%d "
1171 "fw_owned=%d drv_owned=%d unused=%d\n",
1172 wiphy_name(hw
->wiphy
), i
,
1173 txq
->stats
.len
, txq
->head
, txq
->tail
,
1174 fw_owned
, drv_owned
, unused
);
1179 * Must be called with priv->fw_mutex held and tx queues stopped.
1181 #define MWL8K_TX_WAIT_TIMEOUT_MS 1000
1183 static int mwl8k_tx_wait_empty(struct ieee80211_hw
*hw
)
1185 struct mwl8k_priv
*priv
= hw
->priv
;
1186 DECLARE_COMPLETION_ONSTACK(tx_wait
);
1193 * The TX queues are stopped at this point, so this test
1194 * doesn't need to take ->tx_lock.
1196 if (!priv
->pending_tx_pkts
)
1202 spin_lock_bh(&priv
->tx_lock
);
1203 priv
->tx_wait
= &tx_wait
;
1206 unsigned long timeout
;
1208 oldcount
= priv
->pending_tx_pkts
;
1210 spin_unlock_bh(&priv
->tx_lock
);
1211 timeout
= wait_for_completion_timeout(&tx_wait
,
1212 msecs_to_jiffies(MWL8K_TX_WAIT_TIMEOUT_MS
));
1213 spin_lock_bh(&priv
->tx_lock
);
1216 WARN_ON(priv
->pending_tx_pkts
);
1218 printk(KERN_NOTICE
"%s: tx rings drained\n",
1219 wiphy_name(hw
->wiphy
));
1224 if (priv
->pending_tx_pkts
< oldcount
) {
1225 printk(KERN_NOTICE
"%s: waiting for tx rings "
1226 "to drain (%d -> %d pkts)\n",
1227 wiphy_name(hw
->wiphy
), oldcount
,
1228 priv
->pending_tx_pkts
);
1233 priv
->tx_wait
= NULL
;
1235 printk(KERN_ERR
"%s: tx rings stuck for %d ms\n",
1236 wiphy_name(hw
->wiphy
), MWL8K_TX_WAIT_TIMEOUT_MS
);
1237 mwl8k_dump_tx_rings(hw
);
1241 spin_unlock_bh(&priv
->tx_lock
);
1246 #define MWL8K_TXD_SUCCESS(status) \
1247 ((status) & (MWL8K_TXD_STATUS_OK | \
1248 MWL8K_TXD_STATUS_OK_RETRY | \
1249 MWL8K_TXD_STATUS_OK_MORE_RETRY))
1251 static void mwl8k_txq_reclaim(struct ieee80211_hw
*hw
, int index
, int force
)
1253 struct mwl8k_priv
*priv
= hw
->priv
;
1254 struct mwl8k_tx_queue
*txq
= priv
->txq
+ index
;
1257 while (txq
->stats
.len
> 0) {
1259 struct mwl8k_tx_desc
*tx_desc
;
1262 struct sk_buff
*skb
;
1263 struct ieee80211_tx_info
*info
;
1267 tx_desc
= txq
->txd
+ tx
;
1269 status
= le32_to_cpu(tx_desc
->status
);
1271 if (status
& MWL8K_TXD_STATUS_FW_OWNED
) {
1275 ~cpu_to_le32(MWL8K_TXD_STATUS_FW_OWNED
);
1278 txq
->head
= (tx
+ 1) % MWL8K_TX_DESCS
;
1279 BUG_ON(txq
->stats
.len
== 0);
1281 priv
->pending_tx_pkts
--;
1283 addr
= le32_to_cpu(tx_desc
->pkt_phys_addr
);
1284 size
= le16_to_cpu(tx_desc
->pkt_len
);
1286 txq
->skb
[tx
] = NULL
;
1288 BUG_ON(skb
== NULL
);
1289 pci_unmap_single(priv
->pdev
, addr
, size
, PCI_DMA_TODEVICE
);
1291 mwl8k_remove_dma_header(skb
, tx_desc
->qos_control
);
1293 /* Mark descriptor as unused */
1294 tx_desc
->pkt_phys_addr
= 0;
1295 tx_desc
->pkt_len
= 0;
1297 info
= IEEE80211_SKB_CB(skb
);
1298 ieee80211_tx_info_clear_status(info
);
1299 if (MWL8K_TXD_SUCCESS(status
))
1300 info
->flags
|= IEEE80211_TX_STAT_ACK
;
1302 ieee80211_tx_status_irqsafe(hw
, skb
);
1307 if (wake
&& priv
->radio_on
&& !mutex_is_locked(&priv
->fw_mutex
))
1308 ieee80211_wake_queue(hw
, index
);
1311 /* must be called only when the card's transmit is completely halted */
1312 static void mwl8k_txq_deinit(struct ieee80211_hw
*hw
, int index
)
1314 struct mwl8k_priv
*priv
= hw
->priv
;
1315 struct mwl8k_tx_queue
*txq
= priv
->txq
+ index
;
1317 mwl8k_txq_reclaim(hw
, index
, 1);
1322 pci_free_consistent(priv
->pdev
,
1323 MWL8K_TX_DESCS
* sizeof(struct mwl8k_tx_desc
),
1324 txq
->txd
, txq
->txd_dma
);
1329 mwl8k_txq_xmit(struct ieee80211_hw
*hw
, int index
, struct sk_buff
*skb
)
1331 struct mwl8k_priv
*priv
= hw
->priv
;
1332 struct ieee80211_tx_info
*tx_info
;
1333 struct mwl8k_vif
*mwl8k_vif
;
1334 struct ieee80211_hdr
*wh
;
1335 struct mwl8k_tx_queue
*txq
;
1336 struct mwl8k_tx_desc
*tx
;
1342 wh
= (struct ieee80211_hdr
*)skb
->data
;
1343 if (ieee80211_is_data_qos(wh
->frame_control
))
1344 qos
= le16_to_cpu(*((__le16
*)ieee80211_get_qos_ctl(wh
)));
1348 mwl8k_add_dma_header(skb
);
1349 wh
= &((struct mwl8k_dma_data
*)skb
->data
)->wh
;
1351 tx_info
= IEEE80211_SKB_CB(skb
);
1352 mwl8k_vif
= MWL8K_VIF(tx_info
->control
.vif
);
1354 if (tx_info
->flags
& IEEE80211_TX_CTL_ASSIGN_SEQ
) {
1355 u16 seqno
= mwl8k_vif
->seqno
;
1357 wh
->seq_ctrl
&= cpu_to_le16(IEEE80211_SCTL_FRAG
);
1358 wh
->seq_ctrl
|= cpu_to_le16(seqno
<< 4);
1359 mwl8k_vif
->seqno
= seqno
++ % 4096;
1362 /* Setup firmware control bit fields for each frame type. */
1365 if (ieee80211_is_mgmt(wh
->frame_control
) ||
1366 ieee80211_is_ctl(wh
->frame_control
)) {
1368 qos
|= MWL8K_QOS_QLEN_UNSPEC
| MWL8K_QOS_EOSP
;
1369 } else if (ieee80211_is_data(wh
->frame_control
)) {
1371 if (is_multicast_ether_addr(wh
->addr1
))
1372 txstatus
|= MWL8K_TXD_STATUS_MULTICAST_TX
;
1374 qos
&= ~MWL8K_QOS_ACK_POLICY_MASK
;
1375 if (tx_info
->flags
& IEEE80211_TX_CTL_AMPDU
)
1376 qos
|= MWL8K_QOS_ACK_POLICY_BLOCKACK
;
1378 qos
|= MWL8K_QOS_ACK_POLICY_NORMAL
;
1381 dma
= pci_map_single(priv
->pdev
, skb
->data
,
1382 skb
->len
, PCI_DMA_TODEVICE
);
1384 if (pci_dma_mapping_error(priv
->pdev
, dma
)) {
1385 printk(KERN_DEBUG
"%s: failed to dma map skb, "
1386 "dropping TX frame.\n", wiphy_name(hw
->wiphy
));
1388 return NETDEV_TX_OK
;
1391 spin_lock_bh(&priv
->tx_lock
);
1393 txq
= priv
->txq
+ index
;
1395 BUG_ON(txq
->skb
[txq
->tail
] != NULL
);
1396 txq
->skb
[txq
->tail
] = skb
;
1398 tx
= txq
->txd
+ txq
->tail
;
1399 tx
->data_rate
= txdatarate
;
1400 tx
->tx_priority
= index
;
1401 tx
->qos_control
= cpu_to_le16(qos
);
1402 tx
->pkt_phys_addr
= cpu_to_le32(dma
);
1403 tx
->pkt_len
= cpu_to_le16(skb
->len
);
1405 tx
->peer_id
= mwl8k_vif
->peer_id
;
1407 tx
->status
= cpu_to_le32(MWL8K_TXD_STATUS_FW_OWNED
| txstatus
);
1411 priv
->pending_tx_pkts
++;
1414 if (txq
->tail
== MWL8K_TX_DESCS
)
1417 if (txq
->head
== txq
->tail
)
1418 ieee80211_stop_queue(hw
, index
);
1420 mwl8k_tx_start(priv
);
1422 spin_unlock_bh(&priv
->tx_lock
);
1424 return NETDEV_TX_OK
;
1431 * We have the following requirements for issuing firmware commands:
1432 * - Some commands require that the packet transmit path is idle when
1433 * the command is issued. (For simplicity, we'll just quiesce the
1434 * transmit path for every command.)
1435 * - There are certain sequences of commands that need to be issued to
1436 * the hardware sequentially, with no other intervening commands.
1438 * This leads to an implementation of a "firmware lock" as a mutex that
1439 * can be taken recursively, and which is taken by both the low-level
1440 * command submission function (mwl8k_post_cmd) as well as any users of
1441 * that function that require issuing of an atomic sequence of commands,
1442 * and quiesces the transmit path whenever it's taken.
1444 static int mwl8k_fw_lock(struct ieee80211_hw
*hw
)
1446 struct mwl8k_priv
*priv
= hw
->priv
;
1448 if (priv
->fw_mutex_owner
!= current
) {
1451 mutex_lock(&priv
->fw_mutex
);
1452 ieee80211_stop_queues(hw
);
1454 rc
= mwl8k_tx_wait_empty(hw
);
1456 ieee80211_wake_queues(hw
);
1457 mutex_unlock(&priv
->fw_mutex
);
1462 priv
->fw_mutex_owner
= current
;
1465 priv
->fw_mutex_depth
++;
1470 static void mwl8k_fw_unlock(struct ieee80211_hw
*hw
)
1472 struct mwl8k_priv
*priv
= hw
->priv
;
1474 if (!--priv
->fw_mutex_depth
) {
1475 ieee80211_wake_queues(hw
);
1476 priv
->fw_mutex_owner
= NULL
;
1477 mutex_unlock(&priv
->fw_mutex
);
1483 * Command processing.
1486 /* Timeout firmware commands after 10s */
1487 #define MWL8K_CMD_TIMEOUT_MS 10000
1489 static int mwl8k_post_cmd(struct ieee80211_hw
*hw
, struct mwl8k_cmd_pkt
*cmd
)
1491 DECLARE_COMPLETION_ONSTACK(cmd_wait
);
1492 struct mwl8k_priv
*priv
= hw
->priv
;
1493 void __iomem
*regs
= priv
->regs
;
1494 dma_addr_t dma_addr
;
1495 unsigned int dma_size
;
1497 unsigned long timeout
= 0;
1500 cmd
->result
= 0xffff;
1501 dma_size
= le16_to_cpu(cmd
->length
);
1502 dma_addr
= pci_map_single(priv
->pdev
, cmd
, dma_size
,
1503 PCI_DMA_BIDIRECTIONAL
);
1504 if (pci_dma_mapping_error(priv
->pdev
, dma_addr
))
1507 rc
= mwl8k_fw_lock(hw
);
1509 pci_unmap_single(priv
->pdev
, dma_addr
, dma_size
,
1510 PCI_DMA_BIDIRECTIONAL
);
1514 priv
->hostcmd_wait
= &cmd_wait
;
1515 iowrite32(dma_addr
, regs
+ MWL8K_HIU_GEN_PTR
);
1516 iowrite32(MWL8K_H2A_INT_DOORBELL
,
1517 regs
+ MWL8K_HIU_H2A_INTERRUPT_EVENTS
);
1518 iowrite32(MWL8K_H2A_INT_DUMMY
,
1519 regs
+ MWL8K_HIU_H2A_INTERRUPT_EVENTS
);
1521 timeout
= wait_for_completion_timeout(&cmd_wait
,
1522 msecs_to_jiffies(MWL8K_CMD_TIMEOUT_MS
));
1524 priv
->hostcmd_wait
= NULL
;
1526 mwl8k_fw_unlock(hw
);
1528 pci_unmap_single(priv
->pdev
, dma_addr
, dma_size
,
1529 PCI_DMA_BIDIRECTIONAL
);
1532 printk(KERN_ERR
"%s: Command %s timeout after %u ms\n",
1533 wiphy_name(hw
->wiphy
),
1534 mwl8k_cmd_name(cmd
->code
, buf
, sizeof(buf
)),
1535 MWL8K_CMD_TIMEOUT_MS
);
1540 ms
= MWL8K_CMD_TIMEOUT_MS
- jiffies_to_msecs(timeout
);
1542 rc
= cmd
->result
? -EINVAL
: 0;
1544 printk(KERN_ERR
"%s: Command %s error 0x%x\n",
1545 wiphy_name(hw
->wiphy
),
1546 mwl8k_cmd_name(cmd
->code
, buf
, sizeof(buf
)),
1547 le16_to_cpu(cmd
->result
));
1549 printk(KERN_NOTICE
"%s: Command %s took %d ms\n",
1550 wiphy_name(hw
->wiphy
),
1551 mwl8k_cmd_name(cmd
->code
, buf
, sizeof(buf
)),
1559 * CMD_GET_HW_SPEC (STA version).
1561 struct mwl8k_cmd_get_hw_spec_sta
{
1562 struct mwl8k_cmd_pkt header
;
1564 __u8 host_interface
;
1566 __u8 perm_addr
[ETH_ALEN
];
1571 __u8 mcs_bitmap
[16];
1572 __le32 rx_queue_ptr
;
1573 __le32 num_tx_queues
;
1574 __le32 tx_queue_ptrs
[MWL8K_TX_QUEUES
];
1576 __le32 num_tx_desc_per_queue
;
1578 } __attribute__((packed
));
1580 static int mwl8k_cmd_get_hw_spec_sta(struct ieee80211_hw
*hw
)
1582 struct mwl8k_priv
*priv
= hw
->priv
;
1583 struct mwl8k_cmd_get_hw_spec_sta
*cmd
;
1587 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
1591 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_GET_HW_SPEC
);
1592 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
1594 memset(cmd
->perm_addr
, 0xff, sizeof(cmd
->perm_addr
));
1595 cmd
->ps_cookie
= cpu_to_le32(priv
->cookie_dma
);
1596 cmd
->rx_queue_ptr
= cpu_to_le32(priv
->rxq
[0].rxd_dma
);
1597 cmd
->num_tx_queues
= cpu_to_le32(MWL8K_TX_QUEUES
);
1598 for (i
= 0; i
< MWL8K_TX_QUEUES
; i
++)
1599 cmd
->tx_queue_ptrs
[i
] = cpu_to_le32(priv
->txq
[i
].txd_dma
);
1600 cmd
->num_tx_desc_per_queue
= cpu_to_le32(MWL8K_TX_DESCS
);
1601 cmd
->total_rxd
= cpu_to_le32(MWL8K_RX_DESCS
);
1603 rc
= mwl8k_post_cmd(hw
, &cmd
->header
);
1606 SET_IEEE80211_PERM_ADDR(hw
, cmd
->perm_addr
);
1607 priv
->num_mcaddrs
= le16_to_cpu(cmd
->num_mcaddrs
);
1608 priv
->fw_rev
= le32_to_cpu(cmd
->fw_rev
);
1609 priv
->hw_rev
= cmd
->hw_rev
;
1617 * CMD_GET_HW_SPEC (AP version).
1619 struct mwl8k_cmd_get_hw_spec_ap
{
1620 struct mwl8k_cmd_pkt header
;
1622 __u8 host_interface
;
1625 __u8 perm_addr
[ETH_ALEN
];
1636 } __attribute__((packed
));
1638 static int mwl8k_cmd_get_hw_spec_ap(struct ieee80211_hw
*hw
)
1640 struct mwl8k_priv
*priv
= hw
->priv
;
1641 struct mwl8k_cmd_get_hw_spec_ap
*cmd
;
1644 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
1648 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_GET_HW_SPEC
);
1649 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
1651 memset(cmd
->perm_addr
, 0xff, sizeof(cmd
->perm_addr
));
1652 cmd
->ps_cookie
= cpu_to_le32(priv
->cookie_dma
);
1654 rc
= mwl8k_post_cmd(hw
, &cmd
->header
);
1659 SET_IEEE80211_PERM_ADDR(hw
, cmd
->perm_addr
);
1660 priv
->num_mcaddrs
= le16_to_cpu(cmd
->num_mcaddrs
);
1661 priv
->fw_rev
= le32_to_cpu(cmd
->fw_rev
);
1662 priv
->hw_rev
= cmd
->hw_rev
;
1664 off
= le32_to_cpu(cmd
->wcbbase0
) & 0xffff;
1665 iowrite32(cpu_to_le32(priv
->txq
[0].txd_dma
), priv
->sram
+ off
);
1667 off
= le32_to_cpu(cmd
->rxwrptr
) & 0xffff;
1668 iowrite32(cpu_to_le32(priv
->rxq
[0].rxd_dma
), priv
->sram
+ off
);
1670 off
= le32_to_cpu(cmd
->rxrdptr
) & 0xffff;
1671 iowrite32(cpu_to_le32(priv
->rxq
[0].rxd_dma
), priv
->sram
+ off
);
1673 off
= le32_to_cpu(cmd
->wcbbase1
) & 0xffff;
1674 iowrite32(cpu_to_le32(priv
->txq
[1].txd_dma
), priv
->sram
+ off
);
1676 off
= le32_to_cpu(cmd
->wcbbase2
) & 0xffff;
1677 iowrite32(cpu_to_le32(priv
->txq
[2].txd_dma
), priv
->sram
+ off
);
1679 off
= le32_to_cpu(cmd
->wcbbase3
) & 0xffff;
1680 iowrite32(cpu_to_le32(priv
->txq
[3].txd_dma
), priv
->sram
+ off
);
1690 struct mwl8k_cmd_set_hw_spec
{
1691 struct mwl8k_cmd_pkt header
;
1693 __u8 host_interface
;
1695 __u8 perm_addr
[ETH_ALEN
];
1700 __le32 rx_queue_ptr
;
1701 __le32 num_tx_queues
;
1702 __le32 tx_queue_ptrs
[MWL8K_TX_QUEUES
];
1704 __le32 num_tx_desc_per_queue
;
1706 } __attribute__((packed
));
1708 #define MWL8K_SET_HW_SPEC_FLAG_HOST_DECR_MGMT 0x00000080
1710 static int mwl8k_cmd_set_hw_spec(struct ieee80211_hw
*hw
)
1712 struct mwl8k_priv
*priv
= hw
->priv
;
1713 struct mwl8k_cmd_set_hw_spec
*cmd
;
1717 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
1721 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_SET_HW_SPEC
);
1722 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
1724 cmd
->ps_cookie
= cpu_to_le32(priv
->cookie_dma
);
1725 cmd
->rx_queue_ptr
= cpu_to_le32(priv
->rxq
[0].rxd_dma
);
1726 cmd
->num_tx_queues
= cpu_to_le32(MWL8K_TX_QUEUES
);
1727 for (i
= 0; i
< MWL8K_TX_QUEUES
; i
++)
1728 cmd
->tx_queue_ptrs
[i
] = cpu_to_le32(priv
->txq
[i
].txd_dma
);
1729 cmd
->flags
= cpu_to_le32(MWL8K_SET_HW_SPEC_FLAG_HOST_DECR_MGMT
);
1730 cmd
->num_tx_desc_per_queue
= cpu_to_le32(MWL8K_TX_DESCS
);
1731 cmd
->total_rxd
= cpu_to_le32(MWL8K_RX_DESCS
);
1733 rc
= mwl8k_post_cmd(hw
, &cmd
->header
);
1740 * CMD_MAC_MULTICAST_ADR.
1742 struct mwl8k_cmd_mac_multicast_adr
{
1743 struct mwl8k_cmd_pkt header
;
1746 __u8 addr
[0][ETH_ALEN
];
1749 #define MWL8K_ENABLE_RX_DIRECTED 0x0001
1750 #define MWL8K_ENABLE_RX_MULTICAST 0x0002
1751 #define MWL8K_ENABLE_RX_ALL_MULTICAST 0x0004
1752 #define MWL8K_ENABLE_RX_BROADCAST 0x0008
1754 static struct mwl8k_cmd_pkt
*
1755 __mwl8k_cmd_mac_multicast_adr(struct ieee80211_hw
*hw
, int allmulti
,
1756 int mc_count
, struct dev_addr_list
*mclist
)
1758 struct mwl8k_priv
*priv
= hw
->priv
;
1759 struct mwl8k_cmd_mac_multicast_adr
*cmd
;
1762 if (allmulti
|| mc_count
> priv
->num_mcaddrs
) {
1767 size
= sizeof(*cmd
) + mc_count
* ETH_ALEN
;
1769 cmd
= kzalloc(size
, GFP_ATOMIC
);
1773 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_MAC_MULTICAST_ADR
);
1774 cmd
->header
.length
= cpu_to_le16(size
);
1775 cmd
->action
= cpu_to_le16(MWL8K_ENABLE_RX_DIRECTED
|
1776 MWL8K_ENABLE_RX_BROADCAST
);
1779 cmd
->action
|= cpu_to_le16(MWL8K_ENABLE_RX_ALL_MULTICAST
);
1780 } else if (mc_count
) {
1783 cmd
->action
|= cpu_to_le16(MWL8K_ENABLE_RX_MULTICAST
);
1784 cmd
->numaddr
= cpu_to_le16(mc_count
);
1785 for (i
= 0; i
< mc_count
&& mclist
; i
++) {
1786 if (mclist
->da_addrlen
!= ETH_ALEN
) {
1790 memcpy(cmd
->addr
[i
], mclist
->da_addr
, ETH_ALEN
);
1791 mclist
= mclist
->next
;
1795 return &cmd
->header
;
1801 struct mwl8k_cmd_get_stat
{
1802 struct mwl8k_cmd_pkt header
;
1804 } __attribute__((packed
));
1806 #define MWL8K_STAT_ACK_FAILURE 9
1807 #define MWL8K_STAT_RTS_FAILURE 12
1808 #define MWL8K_STAT_FCS_ERROR 24
1809 #define MWL8K_STAT_RTS_SUCCESS 11
1811 static int mwl8k_cmd_get_stat(struct ieee80211_hw
*hw
,
1812 struct ieee80211_low_level_stats
*stats
)
1814 struct mwl8k_cmd_get_stat
*cmd
;
1817 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
1821 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_GET_STAT
);
1822 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
1824 rc
= mwl8k_post_cmd(hw
, &cmd
->header
);
1826 stats
->dot11ACKFailureCount
=
1827 le32_to_cpu(cmd
->stats
[MWL8K_STAT_ACK_FAILURE
]);
1828 stats
->dot11RTSFailureCount
=
1829 le32_to_cpu(cmd
->stats
[MWL8K_STAT_RTS_FAILURE
]);
1830 stats
->dot11FCSErrorCount
=
1831 le32_to_cpu(cmd
->stats
[MWL8K_STAT_FCS_ERROR
]);
1832 stats
->dot11RTSSuccessCount
=
1833 le32_to_cpu(cmd
->stats
[MWL8K_STAT_RTS_SUCCESS
]);
1841 * CMD_RADIO_CONTROL.
1843 struct mwl8k_cmd_radio_control
{
1844 struct mwl8k_cmd_pkt header
;
1848 } __attribute__((packed
));
1851 mwl8k_cmd_radio_control(struct ieee80211_hw
*hw
, bool enable
, bool force
)
1853 struct mwl8k_priv
*priv
= hw
->priv
;
1854 struct mwl8k_cmd_radio_control
*cmd
;
1857 if (enable
== priv
->radio_on
&& !force
)
1860 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
1864 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_RADIO_CONTROL
);
1865 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
1866 cmd
->action
= cpu_to_le16(MWL8K_CMD_SET
);
1867 cmd
->control
= cpu_to_le16(priv
->radio_short_preamble
? 3 : 1);
1868 cmd
->radio_on
= cpu_to_le16(enable
? 0x0001 : 0x0000);
1870 rc
= mwl8k_post_cmd(hw
, &cmd
->header
);
1874 priv
->radio_on
= enable
;
1879 static int mwl8k_cmd_radio_disable(struct ieee80211_hw
*hw
)
1881 return mwl8k_cmd_radio_control(hw
, 0, 0);
1884 static int mwl8k_cmd_radio_enable(struct ieee80211_hw
*hw
)
1886 return mwl8k_cmd_radio_control(hw
, 1, 0);
1890 mwl8k_set_radio_preamble(struct ieee80211_hw
*hw
, bool short_preamble
)
1892 struct mwl8k_priv
*priv
= hw
->priv
;
1894 priv
->radio_short_preamble
= short_preamble
;
1896 return mwl8k_cmd_radio_control(hw
, 1, 1);
1902 #define MWL8K_TX_POWER_LEVEL_TOTAL 8
1904 struct mwl8k_cmd_rf_tx_power
{
1905 struct mwl8k_cmd_pkt header
;
1907 __le16 support_level
;
1908 __le16 current_level
;
1910 __le16 power_level_list
[MWL8K_TX_POWER_LEVEL_TOTAL
];
1911 } __attribute__((packed
));
1913 static int mwl8k_cmd_rf_tx_power(struct ieee80211_hw
*hw
, int dBm
)
1915 struct mwl8k_cmd_rf_tx_power
*cmd
;
1918 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
1922 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_RF_TX_POWER
);
1923 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
1924 cmd
->action
= cpu_to_le16(MWL8K_CMD_SET
);
1925 cmd
->support_level
= cpu_to_le16(dBm
);
1927 rc
= mwl8k_post_cmd(hw
, &cmd
->header
);
1936 struct mwl8k_cmd_rf_antenna
{
1937 struct mwl8k_cmd_pkt header
;
1940 } __attribute__((packed
));
1942 #define MWL8K_RF_ANTENNA_RX 1
1943 #define MWL8K_RF_ANTENNA_TX 2
1946 mwl8k_cmd_rf_antenna(struct ieee80211_hw
*hw
, int antenna
, int mask
)
1948 struct mwl8k_cmd_rf_antenna
*cmd
;
1951 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
1955 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_RF_ANTENNA
);
1956 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
1957 cmd
->antenna
= cpu_to_le16(antenna
);
1958 cmd
->mode
= cpu_to_le16(mask
);
1960 rc
= mwl8k_post_cmd(hw
, &cmd
->header
);
1969 struct mwl8k_cmd_set_pre_scan
{
1970 struct mwl8k_cmd_pkt header
;
1971 } __attribute__((packed
));
1973 static int mwl8k_cmd_set_pre_scan(struct ieee80211_hw
*hw
)
1975 struct mwl8k_cmd_set_pre_scan
*cmd
;
1978 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
1982 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_SET_PRE_SCAN
);
1983 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
1985 rc
= mwl8k_post_cmd(hw
, &cmd
->header
);
1992 * CMD_SET_POST_SCAN.
1994 struct mwl8k_cmd_set_post_scan
{
1995 struct mwl8k_cmd_pkt header
;
1997 __u8 bssid
[ETH_ALEN
];
1998 } __attribute__((packed
));
2001 mwl8k_cmd_set_post_scan(struct ieee80211_hw
*hw
, const __u8
*mac
)
2003 struct mwl8k_cmd_set_post_scan
*cmd
;
2006 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
2010 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_SET_POST_SCAN
);
2011 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
2013 memcpy(cmd
->bssid
, mac
, ETH_ALEN
);
2015 rc
= mwl8k_post_cmd(hw
, &cmd
->header
);
2022 * CMD_SET_RF_CHANNEL.
2024 struct mwl8k_cmd_set_rf_channel
{
2025 struct mwl8k_cmd_pkt header
;
2027 __u8 current_channel
;
2028 __le32 channel_flags
;
2029 } __attribute__((packed
));
2031 static int mwl8k_cmd_set_rf_channel(struct ieee80211_hw
*hw
,
2032 struct ieee80211_channel
*channel
)
2034 struct mwl8k_cmd_set_rf_channel
*cmd
;
2037 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
2041 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_SET_RF_CHANNEL
);
2042 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
2043 cmd
->action
= cpu_to_le16(MWL8K_CMD_SET
);
2044 cmd
->current_channel
= channel
->hw_value
;
2045 if (channel
->band
== IEEE80211_BAND_2GHZ
)
2046 cmd
->channel_flags
= cpu_to_le32(0x00000081);
2048 cmd
->channel_flags
= cpu_to_le32(0x00000000);
2050 rc
= mwl8k_post_cmd(hw
, &cmd
->header
);
2059 #define MWL8K_FRAME_PROT_DISABLED 0x00
2060 #define MWL8K_FRAME_PROT_11G 0x07
2061 #define MWL8K_FRAME_PROT_11N_HT_40MHZ_ONLY 0x02
2062 #define MWL8K_FRAME_PROT_11N_HT_ALL 0x06
2064 struct mwl8k_cmd_update_set_aid
{
2065 struct mwl8k_cmd_pkt header
;
2068 /* AP's MAC address (BSSID) */
2069 __u8 bssid
[ETH_ALEN
];
2070 __le16 protection_mode
;
2071 __u8 supp_rates
[14];
2072 } __attribute__((packed
));
2075 mwl8k_cmd_set_aid(struct ieee80211_hw
*hw
, struct ieee80211_vif
*vif
)
2077 struct mwl8k_cmd_update_set_aid
*cmd
;
2081 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
2085 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_SET_AID
);
2086 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
2087 cmd
->aid
= cpu_to_le16(vif
->bss_conf
.aid
);
2089 memcpy(cmd
->bssid
, vif
->bss_conf
.bssid
, ETH_ALEN
);
2091 if (vif
->bss_conf
.use_cts_prot
) {
2092 prot_mode
= MWL8K_FRAME_PROT_11G
;
2094 switch (vif
->bss_conf
.ht_operation_mode
&
2095 IEEE80211_HT_OP_MODE_PROTECTION
) {
2096 case IEEE80211_HT_OP_MODE_PROTECTION_20MHZ
:
2097 prot_mode
= MWL8K_FRAME_PROT_11N_HT_40MHZ_ONLY
;
2099 case IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED
:
2100 prot_mode
= MWL8K_FRAME_PROT_11N_HT_ALL
;
2103 prot_mode
= MWL8K_FRAME_PROT_DISABLED
;
2107 cmd
->protection_mode
= cpu_to_le16(prot_mode
);
2109 memcpy(cmd
->supp_rates
, mwl8k_rateids
, sizeof(mwl8k_rateids
));
2111 rc
= mwl8k_post_cmd(hw
, &cmd
->header
);
2120 struct mwl8k_cmd_set_rate
{
2121 struct mwl8k_cmd_pkt header
;
2122 __u8 legacy_rates
[14];
2124 /* Bitmap for supported MCS codes. */
2127 } __attribute__((packed
));
2130 mwl8k_cmd_set_rate(struct ieee80211_hw
*hw
, struct ieee80211_vif
*vif
)
2132 struct mwl8k_cmd_set_rate
*cmd
;
2135 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
2139 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_SET_RATE
);
2140 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
2141 memcpy(cmd
->legacy_rates
, mwl8k_rateids
, sizeof(mwl8k_rateids
));
2143 rc
= mwl8k_post_cmd(hw
, &cmd
->header
);
2150 * CMD_FINALIZE_JOIN.
2152 #define MWL8K_FJ_BEACON_MAXLEN 128
2154 struct mwl8k_cmd_finalize_join
{
2155 struct mwl8k_cmd_pkt header
;
2156 __le32 sleep_interval
; /* Number of beacon periods to sleep */
2157 __u8 beacon_data
[MWL8K_FJ_BEACON_MAXLEN
];
2158 } __attribute__((packed
));
2160 static int mwl8k_cmd_finalize_join(struct ieee80211_hw
*hw
, void *frame
,
2161 int framelen
, int dtim
)
2163 struct mwl8k_cmd_finalize_join
*cmd
;
2164 struct ieee80211_mgmt
*payload
= frame
;
2168 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
2172 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_SET_FINALIZE_JOIN
);
2173 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
2174 cmd
->sleep_interval
= cpu_to_le32(dtim
? dtim
: 1);
2176 payload_len
= framelen
- ieee80211_hdrlen(payload
->frame_control
);
2177 if (payload_len
< 0)
2179 else if (payload_len
> MWL8K_FJ_BEACON_MAXLEN
)
2180 payload_len
= MWL8K_FJ_BEACON_MAXLEN
;
2182 memcpy(cmd
->beacon_data
, &payload
->u
.beacon
, payload_len
);
2184 rc
= mwl8k_post_cmd(hw
, &cmd
->header
);
2191 * CMD_SET_RTS_THRESHOLD.
2193 struct mwl8k_cmd_set_rts_threshold
{
2194 struct mwl8k_cmd_pkt header
;
2197 } __attribute__((packed
));
2199 static int mwl8k_cmd_set_rts_threshold(struct ieee80211_hw
*hw
,
2200 u16 action
, u16 threshold
)
2202 struct mwl8k_cmd_set_rts_threshold
*cmd
;
2205 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
2209 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_RTS_THRESHOLD
);
2210 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
2211 cmd
->action
= cpu_to_le16(action
);
2212 cmd
->threshold
= cpu_to_le16(threshold
);
2214 rc
= mwl8k_post_cmd(hw
, &cmd
->header
);
2223 struct mwl8k_cmd_set_slot
{
2224 struct mwl8k_cmd_pkt header
;
2227 } __attribute__((packed
));
2229 static int mwl8k_cmd_set_slot(struct ieee80211_hw
*hw
, bool short_slot_time
)
2231 struct mwl8k_cmd_set_slot
*cmd
;
2234 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
2238 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_SET_SLOT
);
2239 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
2240 cmd
->action
= cpu_to_le16(MWL8K_CMD_SET
);
2241 cmd
->short_slot
= short_slot_time
;
2243 rc
= mwl8k_post_cmd(hw
, &cmd
->header
);
2250 * CMD_SET_EDCA_PARAMS.
2252 struct mwl8k_cmd_set_edca_params
{
2253 struct mwl8k_cmd_pkt header
;
2255 /* See MWL8K_SET_EDCA_XXX below */
2258 /* TX opportunity in units of 32 us */
2263 /* Log exponent of max contention period: 0...15 */
2266 /* Log exponent of min contention period: 0...15 */
2269 /* Adaptive interframe spacing in units of 32us */
2272 /* TX queue to configure */
2276 /* Log exponent of max contention period: 0...15 */
2279 /* Log exponent of min contention period: 0...15 */
2282 /* Adaptive interframe spacing in units of 32us */
2285 /* TX queue to configure */
2289 } __attribute__((packed
));
2291 #define MWL8K_SET_EDCA_CW 0x01
2292 #define MWL8K_SET_EDCA_TXOP 0x02
2293 #define MWL8K_SET_EDCA_AIFS 0x04
2295 #define MWL8K_SET_EDCA_ALL (MWL8K_SET_EDCA_CW | \
2296 MWL8K_SET_EDCA_TXOP | \
2297 MWL8K_SET_EDCA_AIFS)
2300 mwl8k_cmd_set_edca_params(struct ieee80211_hw
*hw
, __u8 qnum
,
2301 __u16 cw_min
, __u16 cw_max
,
2302 __u8 aifs
, __u16 txop
)
2304 struct mwl8k_priv
*priv
= hw
->priv
;
2305 struct mwl8k_cmd_set_edca_params
*cmd
;
2308 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
2313 * Queues 0 (BE) and 1 (BK) are swapped in hardware for
2316 qnum
^= !(qnum
>> 1);
2318 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_SET_EDCA_PARAMS
);
2319 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
2320 cmd
->action
= cpu_to_le16(MWL8K_SET_EDCA_ALL
);
2321 cmd
->txop
= cpu_to_le16(txop
);
2323 cmd
->ap
.log_cw_max
= cpu_to_le32(ilog2(cw_max
+ 1));
2324 cmd
->ap
.log_cw_min
= cpu_to_le32(ilog2(cw_min
+ 1));
2325 cmd
->ap
.aifs
= aifs
;
2328 cmd
->sta
.log_cw_max
= (u8
)ilog2(cw_max
+ 1);
2329 cmd
->sta
.log_cw_min
= (u8
)ilog2(cw_min
+ 1);
2330 cmd
->sta
.aifs
= aifs
;
2331 cmd
->sta
.txq
= qnum
;
2334 rc
= mwl8k_post_cmd(hw
, &cmd
->header
);
2343 struct mwl8k_cmd_set_wmm_mode
{
2344 struct mwl8k_cmd_pkt header
;
2346 } __attribute__((packed
));
2348 static int mwl8k_cmd_set_wmm_mode(struct ieee80211_hw
*hw
, bool enable
)
2350 struct mwl8k_priv
*priv
= hw
->priv
;
2351 struct mwl8k_cmd_set_wmm_mode
*cmd
;
2354 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
2358 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_SET_WMM_MODE
);
2359 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
2360 cmd
->action
= cpu_to_le16(!!enable
);
2362 rc
= mwl8k_post_cmd(hw
, &cmd
->header
);
2366 priv
->wmm_enabled
= enable
;
2374 struct mwl8k_cmd_mimo_config
{
2375 struct mwl8k_cmd_pkt header
;
2377 __u8 rx_antenna_map
;
2378 __u8 tx_antenna_map
;
2379 } __attribute__((packed
));
2381 static int mwl8k_cmd_mimo_config(struct ieee80211_hw
*hw
, __u8 rx
, __u8 tx
)
2383 struct mwl8k_cmd_mimo_config
*cmd
;
2386 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
2390 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_MIMO_CONFIG
);
2391 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
2392 cmd
->action
= cpu_to_le32((u32
)MWL8K_CMD_SET
);
2393 cmd
->rx_antenna_map
= rx
;
2394 cmd
->tx_antenna_map
= tx
;
2396 rc
= mwl8k_post_cmd(hw
, &cmd
->header
);
2403 * CMD_USE_FIXED_RATE.
2405 #define MWL8K_RATE_TABLE_SIZE 8
2406 #define MWL8K_UCAST_RATE 0
2407 #define MWL8K_USE_AUTO_RATE 0x0002
2409 struct mwl8k_rate_entry
{
2410 /* Set to 1 if HT rate, 0 if legacy. */
2413 /* Set to 1 to use retry_count field. */
2414 __le32 enable_retry
;
2416 /* Specified legacy rate or MCS. */
2419 /* Number of allowed retries. */
2421 } __attribute__((packed
));
2423 struct mwl8k_rate_table
{
2424 /* 1 to allow specified rate and below */
2425 __le32 allow_rate_drop
;
2427 struct mwl8k_rate_entry rate_entry
[MWL8K_RATE_TABLE_SIZE
];
2428 } __attribute__((packed
));
2430 struct mwl8k_cmd_use_fixed_rate
{
2431 struct mwl8k_cmd_pkt header
;
2433 struct mwl8k_rate_table rate_table
;
2435 /* Unicast, Broadcast or Multicast */
2439 } __attribute__((packed
));
2441 static int mwl8k_cmd_use_fixed_rate(struct ieee80211_hw
*hw
,
2442 u32 action
, u32 rate_type
, struct mwl8k_rate_table
*rate_table
)
2444 struct mwl8k_cmd_use_fixed_rate
*cmd
;
2448 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
2452 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_USE_FIXED_RATE
);
2453 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
2455 cmd
->action
= cpu_to_le32(action
);
2456 cmd
->rate_type
= cpu_to_le32(rate_type
);
2458 if (rate_table
!= NULL
) {
2460 * Copy over each field manually so that endian
2461 * conversion can be done.
2463 cmd
->rate_table
.allow_rate_drop
=
2464 cpu_to_le32(rate_table
->allow_rate_drop
);
2465 cmd
->rate_table
.num_rates
=
2466 cpu_to_le32(rate_table
->num_rates
);
2468 for (count
= 0; count
< rate_table
->num_rates
; count
++) {
2469 struct mwl8k_rate_entry
*dst
=
2470 &cmd
->rate_table
.rate_entry
[count
];
2471 struct mwl8k_rate_entry
*src
=
2472 &rate_table
->rate_entry
[count
];
2474 dst
->is_ht_rate
= cpu_to_le32(src
->is_ht_rate
);
2475 dst
->enable_retry
= cpu_to_le32(src
->enable_retry
);
2476 dst
->rate
= cpu_to_le32(src
->rate
);
2477 dst
->retry_count
= cpu_to_le32(src
->retry_count
);
2481 rc
= mwl8k_post_cmd(hw
, &cmd
->header
);
2488 * CMD_ENABLE_SNIFFER.
2490 struct mwl8k_cmd_enable_sniffer
{
2491 struct mwl8k_cmd_pkt header
;
2493 } __attribute__((packed
));
2495 static int mwl8k_cmd_enable_sniffer(struct ieee80211_hw
*hw
, bool enable
)
2497 struct mwl8k_cmd_enable_sniffer
*cmd
;
2500 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
2504 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_ENABLE_SNIFFER
);
2505 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
2506 cmd
->action
= cpu_to_le32(!!enable
);
2508 rc
= mwl8k_post_cmd(hw
, &cmd
->header
);
2517 struct mwl8k_cmd_set_mac_addr
{
2518 struct mwl8k_cmd_pkt header
;
2522 __u8 mac_addr
[ETH_ALEN
];
2524 __u8 mac_addr
[ETH_ALEN
];
2526 } __attribute__((packed
));
2528 static int mwl8k_cmd_set_mac_addr(struct ieee80211_hw
*hw
, u8
*mac
)
2530 struct mwl8k_priv
*priv
= hw
->priv
;
2531 struct mwl8k_cmd_set_mac_addr
*cmd
;
2534 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
2538 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_SET_MAC_ADDR
);
2539 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
2541 cmd
->mbss
.mac_type
= 0;
2542 memcpy(cmd
->mbss
.mac_addr
, mac
, ETH_ALEN
);
2544 memcpy(cmd
->mac_addr
, mac
, ETH_ALEN
);
2547 rc
= mwl8k_post_cmd(hw
, &cmd
->header
);
2554 * CMD_SET_RATEADAPT_MODE.
2556 struct mwl8k_cmd_set_rate_adapt_mode
{
2557 struct mwl8k_cmd_pkt header
;
2560 } __attribute__((packed
));
2562 static int mwl8k_cmd_set_rateadapt_mode(struct ieee80211_hw
*hw
, __u16 mode
)
2564 struct mwl8k_cmd_set_rate_adapt_mode
*cmd
;
2567 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
2571 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_SET_RATEADAPT_MODE
);
2572 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
2573 cmd
->action
= cpu_to_le16(MWL8K_CMD_SET
);
2574 cmd
->mode
= cpu_to_le16(mode
);
2576 rc
= mwl8k_post_cmd(hw
, &cmd
->header
);
2585 #define MWL8K_STA_DB_ADD_ENTRY 0
2586 #define MWL8K_STA_DB_MODIFY_ENTRY 1
2587 #define MWL8K_STA_DB_DEL_ENTRY 2
2588 #define MWL8K_STA_DB_FLUSH 3
2590 /* Peer Entry flags - used to define the type of the peer node */
2591 #define MWL8K_PEER_TYPE_ACCESSPOINT 2
2593 struct ewc_ht_info
{
2597 } __attribute__((packed
));
2599 struct peer_capability_info
{
2600 /* Peer type - AP vs. STA. */
2603 /* Basic 802.11 capabilities from assoc resp. */
2606 /* Set if peer supports 802.11n high throughput (HT). */
2609 /* Valid if HT is supported. */
2611 __u8 extended_ht_caps
;
2612 struct ewc_ht_info ewc_info
;
2614 /* Legacy rate table. Intersection of our rates and peer rates. */
2615 __u8 legacy_rates
[12];
2617 /* HT rate table. Intersection of our rates and peer rates. */
2621 /* If set, interoperability mode, no proprietary extensions. */
2625 __le16 amsdu_enabled
;
2626 } __attribute__((packed
));
2628 struct mwl8k_cmd_update_stadb
{
2629 struct mwl8k_cmd_pkt header
;
2631 /* See STADB_ACTION_TYPE */
2634 /* Peer MAC address */
2635 __u8 peer_addr
[ETH_ALEN
];
2639 /* Peer info - valid during add/update. */
2640 struct peer_capability_info peer_info
;
2641 } __attribute__((packed
));
2643 static int mwl8k_cmd_update_stadb(struct ieee80211_hw
*hw
,
2644 struct ieee80211_vif
*vif
, __u32 action
, u8
*addr
)
2646 struct mwl8k_vif
*mv_vif
= MWL8K_VIF(vif
);
2647 struct mwl8k_cmd_update_stadb
*cmd
;
2648 struct peer_capability_info
*peer_info
;
2651 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
2655 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_UPDATE_STADB
);
2656 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
2658 cmd
->action
= cpu_to_le32(action
);
2659 peer_info
= &cmd
->peer_info
;
2660 memcpy(cmd
->peer_addr
, addr
, ETH_ALEN
);
2663 case MWL8K_STA_DB_ADD_ENTRY
:
2664 case MWL8K_STA_DB_MODIFY_ENTRY
:
2665 /* Build peer_info block */
2666 peer_info
->peer_type
= MWL8K_PEER_TYPE_ACCESSPOINT
;
2667 peer_info
->basic_caps
=
2668 cpu_to_le16(vif
->bss_conf
.assoc_capability
);
2669 memcpy(peer_info
->legacy_rates
, mwl8k_rateids
,
2670 sizeof(mwl8k_rateids
));
2671 peer_info
->interop
= 1;
2672 peer_info
->amsdu_enabled
= 0;
2674 rc
= mwl8k_post_cmd(hw
, &cmd
->header
);
2676 mv_vif
->peer_id
= peer_info
->station_id
;
2680 case MWL8K_STA_DB_DEL_ENTRY
:
2681 case MWL8K_STA_DB_FLUSH
:
2683 rc
= mwl8k_post_cmd(hw
, &cmd
->header
);
2685 mv_vif
->peer_id
= 0;
2695 * Interrupt handling.
2697 static irqreturn_t
mwl8k_interrupt(int irq
, void *dev_id
)
2699 struct ieee80211_hw
*hw
= dev_id
;
2700 struct mwl8k_priv
*priv
= hw
->priv
;
2703 status
= ioread32(priv
->regs
+ MWL8K_HIU_A2H_INTERRUPT_STATUS
);
2704 iowrite32(~status
, priv
->regs
+ MWL8K_HIU_A2H_INTERRUPT_STATUS
);
2709 if (status
& MWL8K_A2H_INT_TX_DONE
)
2710 tasklet_schedule(&priv
->tx_reclaim_task
);
2712 if (status
& MWL8K_A2H_INT_RX_READY
) {
2713 while (rxq_process(hw
, 0, 1))
2714 rxq_refill(hw
, 0, 1);
2717 if (status
& MWL8K_A2H_INT_OPC_DONE
) {
2718 if (priv
->hostcmd_wait
!= NULL
)
2719 complete(priv
->hostcmd_wait
);
2722 if (status
& MWL8K_A2H_INT_QUEUE_EMPTY
) {
2723 if (!mutex_is_locked(&priv
->fw_mutex
) &&
2724 priv
->radio_on
&& priv
->pending_tx_pkts
)
2725 mwl8k_tx_start(priv
);
2733 * Core driver operations.
2735 static int mwl8k_tx(struct ieee80211_hw
*hw
, struct sk_buff
*skb
)
2737 struct mwl8k_priv
*priv
= hw
->priv
;
2738 int index
= skb_get_queue_mapping(skb
);
2741 if (priv
->current_channel
== NULL
) {
2742 printk(KERN_DEBUG
"%s: dropped TX frame since radio "
2743 "disabled\n", wiphy_name(hw
->wiphy
));
2745 return NETDEV_TX_OK
;
2748 rc
= mwl8k_txq_xmit(hw
, index
, skb
);
2753 static int mwl8k_start(struct ieee80211_hw
*hw
)
2755 struct mwl8k_priv
*priv
= hw
->priv
;
2758 rc
= request_irq(priv
->pdev
->irq
, mwl8k_interrupt
,
2759 IRQF_SHARED
, MWL8K_NAME
, hw
);
2761 printk(KERN_ERR
"%s: failed to register IRQ handler\n",
2762 wiphy_name(hw
->wiphy
));
2766 /* Enable tx reclaim tasklet */
2767 tasklet_enable(&priv
->tx_reclaim_task
);
2769 /* Enable interrupts */
2770 iowrite32(MWL8K_A2H_EVENTS
, priv
->regs
+ MWL8K_HIU_A2H_INTERRUPT_MASK
);
2772 rc
= mwl8k_fw_lock(hw
);
2774 rc
= mwl8k_cmd_radio_enable(hw
);
2778 rc
= mwl8k_cmd_enable_sniffer(hw
, 0);
2781 rc
= mwl8k_cmd_set_pre_scan(hw
);
2784 rc
= mwl8k_cmd_set_post_scan(hw
,
2785 "\x00\x00\x00\x00\x00\x00");
2789 rc
= mwl8k_cmd_set_rateadapt_mode(hw
, 0);
2792 rc
= mwl8k_cmd_set_wmm_mode(hw
, 0);
2794 mwl8k_fw_unlock(hw
);
2798 iowrite32(0, priv
->regs
+ MWL8K_HIU_A2H_INTERRUPT_MASK
);
2799 free_irq(priv
->pdev
->irq
, hw
);
2800 tasklet_disable(&priv
->tx_reclaim_task
);
2806 static void mwl8k_stop(struct ieee80211_hw
*hw
)
2808 struct mwl8k_priv
*priv
= hw
->priv
;
2811 mwl8k_cmd_radio_disable(hw
);
2813 ieee80211_stop_queues(hw
);
2815 /* Disable interrupts */
2816 iowrite32(0, priv
->regs
+ MWL8K_HIU_A2H_INTERRUPT_MASK
);
2817 free_irq(priv
->pdev
->irq
, hw
);
2819 /* Stop finalize join worker */
2820 cancel_work_sync(&priv
->finalize_join_worker
);
2821 if (priv
->beacon_skb
!= NULL
)
2822 dev_kfree_skb(priv
->beacon_skb
);
2824 /* Stop tx reclaim tasklet */
2825 tasklet_disable(&priv
->tx_reclaim_task
);
2827 /* Return all skbs to mac80211 */
2828 for (i
= 0; i
< MWL8K_TX_QUEUES
; i
++)
2829 mwl8k_txq_reclaim(hw
, i
, 1);
2832 static int mwl8k_add_interface(struct ieee80211_hw
*hw
,
2833 struct ieee80211_vif
*vif
)
2835 struct mwl8k_priv
*priv
= hw
->priv
;
2836 struct mwl8k_vif
*mwl8k_vif
;
2839 * We only support one active interface at a time.
2841 if (priv
->vif
!= NULL
)
2845 * We only support managed interfaces for now.
2847 if (vif
->type
!= NL80211_IFTYPE_STATION
)
2851 * Reject interface creation if sniffer mode is active, as
2852 * STA operation is mutually exclusive with hardware sniffer
2855 if (priv
->sniffer_enabled
) {
2856 printk(KERN_INFO
"%s: unable to create STA "
2857 "interface due to sniffer mode being enabled\n",
2858 wiphy_name(hw
->wiphy
));
2862 /* Clean out driver private area */
2863 mwl8k_vif
= MWL8K_VIF(vif
);
2864 memset(mwl8k_vif
, 0, sizeof(*mwl8k_vif
));
2866 /* Set and save the mac address */
2867 mwl8k_cmd_set_mac_addr(hw
, vif
->addr
);
2868 memcpy(mwl8k_vif
->mac_addr
, vif
->addr
, ETH_ALEN
);
2870 /* Set Initial sequence number to zero */
2871 mwl8k_vif
->seqno
= 0;
2874 priv
->current_channel
= NULL
;
2879 static void mwl8k_remove_interface(struct ieee80211_hw
*hw
,
2880 struct ieee80211_vif
*vif
)
2882 struct mwl8k_priv
*priv
= hw
->priv
;
2884 if (priv
->vif
== NULL
)
2887 mwl8k_cmd_set_mac_addr(hw
, "\x00\x00\x00\x00\x00\x00");
2892 static int mwl8k_config(struct ieee80211_hw
*hw
, u32 changed
)
2894 struct ieee80211_conf
*conf
= &hw
->conf
;
2895 struct mwl8k_priv
*priv
= hw
->priv
;
2898 if (conf
->flags
& IEEE80211_CONF_IDLE
) {
2899 mwl8k_cmd_radio_disable(hw
);
2900 priv
->current_channel
= NULL
;
2904 rc
= mwl8k_fw_lock(hw
);
2908 rc
= mwl8k_cmd_radio_enable(hw
);
2912 rc
= mwl8k_cmd_set_rf_channel(hw
, conf
->channel
);
2916 priv
->current_channel
= conf
->channel
;
2918 if (conf
->power_level
> 18)
2919 conf
->power_level
= 18;
2920 rc
= mwl8k_cmd_rf_tx_power(hw
, conf
->power_level
);
2925 rc
= mwl8k_cmd_rf_antenna(hw
, MWL8K_RF_ANTENNA_RX
, 0x7);
2927 rc
= mwl8k_cmd_rf_antenna(hw
, MWL8K_RF_ANTENNA_TX
, 0x7);
2929 rc
= mwl8k_cmd_mimo_config(hw
, 0x7, 0x7);
2933 mwl8k_fw_unlock(hw
);
2938 static void mwl8k_bss_info_changed(struct ieee80211_hw
*hw
,
2939 struct ieee80211_vif
*vif
,
2940 struct ieee80211_bss_conf
*info
,
2943 struct mwl8k_priv
*priv
= hw
->priv
;
2946 if ((changed
& BSS_CHANGED_ASSOC
) == 0)
2949 priv
->capture_beacon
= false;
2951 rc
= mwl8k_fw_lock(hw
);
2955 if (vif
->bss_conf
.assoc
) {
2957 rc
= mwl8k_cmd_set_rate(hw
, vif
);
2961 /* Turn on rate adaptation */
2962 rc
= mwl8k_cmd_use_fixed_rate(hw
, MWL8K_USE_AUTO_RATE
,
2963 MWL8K_UCAST_RATE
, NULL
);
2967 /* Set radio preamble */
2968 rc
= mwl8k_set_radio_preamble(hw
,
2969 vif
->bss_conf
.use_short_preamble
);
2974 rc
= mwl8k_cmd_set_slot(hw
, vif
->bss_conf
.use_short_slot
);
2979 rc
= mwl8k_cmd_set_aid(hw
, vif
);
2984 * Finalize the join. Tell rx handler to process
2985 * next beacon from our BSSID.
2987 memcpy(priv
->capture_bssid
, vif
->bss_conf
.bssid
, ETH_ALEN
);
2988 priv
->capture_beacon
= true;
2992 mwl8k_fw_unlock(hw
);
2995 static u64
mwl8k_prepare_multicast(struct ieee80211_hw
*hw
,
2996 int mc_count
, struct dev_addr_list
*mclist
)
2998 struct mwl8k_cmd_pkt
*cmd
;
3001 * Synthesize and return a command packet that programs the
3002 * hardware multicast address filter. At this point we don't
3003 * know whether FIF_ALLMULTI is being requested, but if it is,
3004 * we'll end up throwing this packet away and creating a new
3005 * one in mwl8k_configure_filter().
3007 cmd
= __mwl8k_cmd_mac_multicast_adr(hw
, 0, mc_count
, mclist
);
3009 return (unsigned long)cmd
;
3013 mwl8k_configure_filter_sniffer(struct ieee80211_hw
*hw
,
3014 unsigned int changed_flags
,
3015 unsigned int *total_flags
)
3017 struct mwl8k_priv
*priv
= hw
->priv
;
3020 * Hardware sniffer mode is mutually exclusive with STA
3021 * operation, so refuse to enable sniffer mode if a STA
3022 * interface is active.
3024 if (priv
->vif
!= NULL
) {
3025 if (net_ratelimit())
3026 printk(KERN_INFO
"%s: not enabling sniffer "
3027 "mode because STA interface is active\n",
3028 wiphy_name(hw
->wiphy
));
3032 if (!priv
->sniffer_enabled
) {
3033 if (mwl8k_cmd_enable_sniffer(hw
, 1))
3035 priv
->sniffer_enabled
= true;
3038 *total_flags
&= FIF_PROMISC_IN_BSS
| FIF_ALLMULTI
|
3039 FIF_BCN_PRBRESP_PROMISC
| FIF_CONTROL
|
3045 static void mwl8k_configure_filter(struct ieee80211_hw
*hw
,
3046 unsigned int changed_flags
,
3047 unsigned int *total_flags
,
3050 struct mwl8k_priv
*priv
= hw
->priv
;
3051 struct mwl8k_cmd_pkt
*cmd
= (void *)(unsigned long)multicast
;
3054 * AP firmware doesn't allow fine-grained control over
3055 * the receive filter.
3058 *total_flags
&= FIF_ALLMULTI
| FIF_BCN_PRBRESP_PROMISC
;
3064 * Enable hardware sniffer mode if FIF_CONTROL or
3065 * FIF_OTHER_BSS is requested.
3067 if (*total_flags
& (FIF_CONTROL
| FIF_OTHER_BSS
) &&
3068 mwl8k_configure_filter_sniffer(hw
, changed_flags
, total_flags
)) {
3073 /* Clear unsupported feature flags */
3074 *total_flags
&= FIF_ALLMULTI
| FIF_BCN_PRBRESP_PROMISC
;
3076 if (mwl8k_fw_lock(hw
))
3079 if (priv
->sniffer_enabled
) {
3080 mwl8k_cmd_enable_sniffer(hw
, 0);
3081 priv
->sniffer_enabled
= false;
3084 if (changed_flags
& FIF_BCN_PRBRESP_PROMISC
) {
3085 if (*total_flags
& FIF_BCN_PRBRESP_PROMISC
) {
3087 * Disable the BSS filter.
3089 mwl8k_cmd_set_pre_scan(hw
);
3094 * Enable the BSS filter.
3096 * If there is an active STA interface, use that
3097 * interface's BSSID, otherwise use a dummy one
3098 * (where the OUI part needs to be nonzero for
3099 * the BSSID to be accepted by POST_SCAN).
3101 bssid
= "\x01\x00\x00\x00\x00\x00";
3102 if (priv
->vif
!= NULL
)
3103 bssid
= priv
->vif
->bss_conf
.bssid
;
3105 mwl8k_cmd_set_post_scan(hw
, bssid
);
3110 * If FIF_ALLMULTI is being requested, throw away the command
3111 * packet that ->prepare_multicast() built and replace it with
3112 * a command packet that enables reception of all multicast
3115 if (*total_flags
& FIF_ALLMULTI
) {
3117 cmd
= __mwl8k_cmd_mac_multicast_adr(hw
, 1, 0, NULL
);
3121 mwl8k_post_cmd(hw
, cmd
);
3125 mwl8k_fw_unlock(hw
);
3128 static int mwl8k_set_rts_threshold(struct ieee80211_hw
*hw
, u32 value
)
3130 return mwl8k_cmd_set_rts_threshold(hw
, MWL8K_CMD_SET
, value
);
3133 struct mwl8k_sta_notify_item
3135 struct list_head list
;
3136 struct ieee80211_vif
*vif
;
3137 enum sta_notify_cmd cmd
;
3141 static void mwl8k_sta_notify_worker(struct work_struct
*work
)
3143 struct mwl8k_priv
*priv
=
3144 container_of(work
, struct mwl8k_priv
, sta_notify_worker
);
3146 spin_lock_bh(&priv
->sta_notify_list_lock
);
3147 while (!list_empty(&priv
->sta_notify_list
)) {
3148 struct mwl8k_sta_notify_item
*s
;
3151 s
= list_entry(priv
->sta_notify_list
.next
,
3152 struct mwl8k_sta_notify_item
, list
);
3155 spin_unlock_bh(&priv
->sta_notify_list_lock
);
3157 if (s
->cmd
== STA_NOTIFY_ADD
)
3158 action
= MWL8K_STA_DB_MODIFY_ENTRY
;
3160 action
= MWL8K_STA_DB_DEL_ENTRY
;
3161 mwl8k_cmd_update_stadb(priv
->hw
, s
->vif
, action
, s
->addr
);
3165 spin_lock_bh(&priv
->sta_notify_list_lock
);
3167 spin_unlock_bh(&priv
->sta_notify_list_lock
);
3171 mwl8k_sta_notify(struct ieee80211_hw
*hw
, struct ieee80211_vif
*vif
,
3172 enum sta_notify_cmd cmd
, struct ieee80211_sta
*sta
)
3174 struct mwl8k_priv
*priv
= hw
->priv
;
3175 struct mwl8k_sta_notify_item
*s
;
3177 if (cmd
!= STA_NOTIFY_ADD
&& cmd
!= STA_NOTIFY_REMOVE
)
3180 s
= kmalloc(sizeof(*s
), GFP_ATOMIC
);
3184 memcpy(s
->addr
, sta
->addr
, ETH_ALEN
);
3186 spin_lock(&priv
->sta_notify_list_lock
);
3187 list_add_tail(&s
->list
, &priv
->sta_notify_list
);
3188 spin_unlock(&priv
->sta_notify_list_lock
);
3190 ieee80211_queue_work(hw
, &priv
->sta_notify_worker
);
3194 static int mwl8k_conf_tx(struct ieee80211_hw
*hw
, u16 queue
,
3195 const struct ieee80211_tx_queue_params
*params
)
3197 struct mwl8k_priv
*priv
= hw
->priv
;
3200 rc
= mwl8k_fw_lock(hw
);
3202 if (!priv
->wmm_enabled
)
3203 rc
= mwl8k_cmd_set_wmm_mode(hw
, 1);
3206 rc
= mwl8k_cmd_set_edca_params(hw
, queue
,
3212 mwl8k_fw_unlock(hw
);
3218 static int mwl8k_get_tx_stats(struct ieee80211_hw
*hw
,
3219 struct ieee80211_tx_queue_stats
*stats
)
3221 struct mwl8k_priv
*priv
= hw
->priv
;
3222 struct mwl8k_tx_queue
*txq
;
3225 spin_lock_bh(&priv
->tx_lock
);
3226 for (index
= 0; index
< MWL8K_TX_QUEUES
; index
++) {
3227 txq
= priv
->txq
+ index
;
3228 memcpy(&stats
[index
], &txq
->stats
,
3229 sizeof(struct ieee80211_tx_queue_stats
));
3231 spin_unlock_bh(&priv
->tx_lock
);
3236 static int mwl8k_get_stats(struct ieee80211_hw
*hw
,
3237 struct ieee80211_low_level_stats
*stats
)
3239 return mwl8k_cmd_get_stat(hw
, stats
);
3242 static const struct ieee80211_ops mwl8k_ops
= {
3244 .start
= mwl8k_start
,
3246 .add_interface
= mwl8k_add_interface
,
3247 .remove_interface
= mwl8k_remove_interface
,
3248 .config
= mwl8k_config
,
3249 .bss_info_changed
= mwl8k_bss_info_changed
,
3250 .prepare_multicast
= mwl8k_prepare_multicast
,
3251 .configure_filter
= mwl8k_configure_filter
,
3252 .set_rts_threshold
= mwl8k_set_rts_threshold
,
3253 .sta_notify
= mwl8k_sta_notify
,
3254 .conf_tx
= mwl8k_conf_tx
,
3255 .get_tx_stats
= mwl8k_get_tx_stats
,
3256 .get_stats
= mwl8k_get_stats
,
3259 static void mwl8k_tx_reclaim_handler(unsigned long data
)
3262 struct ieee80211_hw
*hw
= (struct ieee80211_hw
*) data
;
3263 struct mwl8k_priv
*priv
= hw
->priv
;
3265 spin_lock_bh(&priv
->tx_lock
);
3266 for (i
= 0; i
< MWL8K_TX_QUEUES
; i
++)
3267 mwl8k_txq_reclaim(hw
, i
, 0);
3269 if (priv
->tx_wait
!= NULL
&& !priv
->pending_tx_pkts
) {
3270 complete(priv
->tx_wait
);
3271 priv
->tx_wait
= NULL
;
3273 spin_unlock_bh(&priv
->tx_lock
);
3276 static void mwl8k_finalize_join_worker(struct work_struct
*work
)
3278 struct mwl8k_priv
*priv
=
3279 container_of(work
, struct mwl8k_priv
, finalize_join_worker
);
3280 struct sk_buff
*skb
= priv
->beacon_skb
;
3282 mwl8k_cmd_finalize_join(priv
->hw
, skb
->data
, skb
->len
,
3283 priv
->vif
->bss_conf
.dtim_period
);
3286 priv
->beacon_skb
= NULL
;
3294 static struct mwl8k_device_info mwl8k_info_tbl
[] __devinitdata
= {
3296 .part_name
= "88w8687",
3297 .helper_image
= "mwl8k/helper_8687.fw",
3298 .fw_image
= "mwl8k/fmimage_8687.fw",
3301 .part_name
= "88w8366",
3302 .helper_image
= "mwl8k/helper_8366.fw",
3303 .fw_image
= "mwl8k/fmimage_8366.fw",
3304 .ap_rxd_ops
= &rxd_8366_ap_ops
,
3308 static DEFINE_PCI_DEVICE_TABLE(mwl8k_pci_id_table
) = {
3309 { PCI_VDEVICE(MARVELL
, 0x2a2b), .driver_data
= MWL8687
, },
3310 { PCI_VDEVICE(MARVELL
, 0x2a30), .driver_data
= MWL8687
, },
3311 { PCI_VDEVICE(MARVELL
, 0x2a40), .driver_data
= MWL8366
, },
3314 MODULE_DEVICE_TABLE(pci
, mwl8k_pci_id_table
);
3316 static int __devinit
mwl8k_probe(struct pci_dev
*pdev
,
3317 const struct pci_device_id
*id
)
3319 static int printed_version
= 0;
3320 struct ieee80211_hw
*hw
;
3321 struct mwl8k_priv
*priv
;
3325 if (!printed_version
) {
3326 printk(KERN_INFO
"%s version %s\n", MWL8K_DESC
, MWL8K_VERSION
);
3327 printed_version
= 1;
3331 rc
= pci_enable_device(pdev
);
3333 printk(KERN_ERR
"%s: Cannot enable new PCI device\n",
3338 rc
= pci_request_regions(pdev
, MWL8K_NAME
);
3340 printk(KERN_ERR
"%s: Cannot obtain PCI resources\n",
3342 goto err_disable_device
;
3345 pci_set_master(pdev
);
3348 hw
= ieee80211_alloc_hw(sizeof(*priv
), &mwl8k_ops
);
3350 printk(KERN_ERR
"%s: ieee80211 alloc failed\n", MWL8K_NAME
);
3355 SET_IEEE80211_DEV(hw
, &pdev
->dev
);
3356 pci_set_drvdata(pdev
, hw
);
3361 priv
->device_info
= &mwl8k_info_tbl
[id
->driver_data
];
3364 priv
->sram
= pci_iomap(pdev
, 0, 0x10000);
3365 if (priv
->sram
== NULL
) {
3366 printk(KERN_ERR
"%s: Cannot map device SRAM\n",
3367 wiphy_name(hw
->wiphy
));
3372 * If BAR0 is a 32 bit BAR, the register BAR will be BAR1.
3373 * If BAR0 is a 64 bit BAR, the register BAR will be BAR2.
3375 priv
->regs
= pci_iomap(pdev
, 1, 0x10000);
3376 if (priv
->regs
== NULL
) {
3377 priv
->regs
= pci_iomap(pdev
, 2, 0x10000);
3378 if (priv
->regs
== NULL
) {
3379 printk(KERN_ERR
"%s: Cannot map device registers\n",
3380 wiphy_name(hw
->wiphy
));
3386 /* Reset firmware and hardware */
3387 mwl8k_hw_reset(priv
);
3389 /* Ask userland hotplug daemon for the device firmware */
3390 rc
= mwl8k_request_firmware(priv
);
3392 printk(KERN_ERR
"%s: Firmware files not found\n",
3393 wiphy_name(hw
->wiphy
));
3394 goto err_stop_firmware
;
3397 /* Load firmware into hardware */
3398 rc
= mwl8k_load_firmware(hw
);
3400 printk(KERN_ERR
"%s: Cannot start firmware\n",
3401 wiphy_name(hw
->wiphy
));
3402 goto err_stop_firmware
;
3405 /* Reclaim memory once firmware is successfully loaded */
3406 mwl8k_release_firmware(priv
);
3410 priv
->rxd_ops
= priv
->device_info
->ap_rxd_ops
;
3411 if (priv
->rxd_ops
== NULL
) {
3412 printk(KERN_ERR
"%s: Driver does not have AP "
3413 "firmware image support for this hardware\n",
3414 wiphy_name(hw
->wiphy
));
3415 goto err_stop_firmware
;
3418 priv
->rxd_ops
= &rxd_sta_ops
;
3421 priv
->sniffer_enabled
= false;
3422 priv
->wmm_enabled
= false;
3423 priv
->pending_tx_pkts
= 0;
3426 memcpy(priv
->channels
, mwl8k_channels
, sizeof(mwl8k_channels
));
3427 priv
->band
.band
= IEEE80211_BAND_2GHZ
;
3428 priv
->band
.channels
= priv
->channels
;
3429 priv
->band
.n_channels
= ARRAY_SIZE(mwl8k_channels
);
3430 priv
->band
.bitrates
= priv
->rates
;
3431 priv
->band
.n_bitrates
= ARRAY_SIZE(mwl8k_rates
);
3432 hw
->wiphy
->bands
[IEEE80211_BAND_2GHZ
] = &priv
->band
;
3434 BUILD_BUG_ON(sizeof(priv
->rates
) != sizeof(mwl8k_rates
));
3435 memcpy(priv
->rates
, mwl8k_rates
, sizeof(mwl8k_rates
));
3438 * Extra headroom is the size of the required DMA header
3439 * minus the size of the smallest 802.11 frame (CTS frame).
3441 hw
->extra_tx_headroom
=
3442 sizeof(struct mwl8k_dma_data
) - sizeof(struct ieee80211_cts
);
3444 hw
->channel_change_time
= 10;
3446 hw
->queues
= MWL8K_TX_QUEUES
;
3448 /* Set rssi and noise values to dBm */
3449 hw
->flags
|= IEEE80211_HW_SIGNAL_DBM
| IEEE80211_HW_NOISE_DBM
;
3450 hw
->vif_data_size
= sizeof(struct mwl8k_vif
);
3453 /* Set default radio state and preamble */
3455 priv
->radio_short_preamble
= 0;
3457 /* Station database handling */
3458 INIT_WORK(&priv
->sta_notify_worker
, mwl8k_sta_notify_worker
);
3459 spin_lock_init(&priv
->sta_notify_list_lock
);
3460 INIT_LIST_HEAD(&priv
->sta_notify_list
);
3462 /* Finalize join worker */
3463 INIT_WORK(&priv
->finalize_join_worker
, mwl8k_finalize_join_worker
);
3465 /* TX reclaim tasklet */
3466 tasklet_init(&priv
->tx_reclaim_task
,
3467 mwl8k_tx_reclaim_handler
, (unsigned long)hw
);
3468 tasklet_disable(&priv
->tx_reclaim_task
);
3470 /* Power management cookie */
3471 priv
->cookie
= pci_alloc_consistent(priv
->pdev
, 4, &priv
->cookie_dma
);
3472 if (priv
->cookie
== NULL
)
3473 goto err_stop_firmware
;
3475 rc
= mwl8k_rxq_init(hw
, 0);
3477 goto err_free_cookie
;
3478 rxq_refill(hw
, 0, INT_MAX
);
3480 mutex_init(&priv
->fw_mutex
);
3481 priv
->fw_mutex_owner
= NULL
;
3482 priv
->fw_mutex_depth
= 0;
3483 priv
->hostcmd_wait
= NULL
;
3485 spin_lock_init(&priv
->tx_lock
);
3487 priv
->tx_wait
= NULL
;
3489 for (i
= 0; i
< MWL8K_TX_QUEUES
; i
++) {
3490 rc
= mwl8k_txq_init(hw
, i
);
3492 goto err_free_queues
;
3495 iowrite32(0, priv
->regs
+ MWL8K_HIU_A2H_INTERRUPT_STATUS
);
3496 iowrite32(0, priv
->regs
+ MWL8K_HIU_A2H_INTERRUPT_MASK
);
3497 iowrite32(0, priv
->regs
+ MWL8K_HIU_A2H_INTERRUPT_CLEAR_SEL
);
3498 iowrite32(0xffffffff, priv
->regs
+ MWL8K_HIU_A2H_INTERRUPT_STATUS_MASK
);
3500 rc
= request_irq(priv
->pdev
->irq
, mwl8k_interrupt
,
3501 IRQF_SHARED
, MWL8K_NAME
, hw
);
3503 printk(KERN_ERR
"%s: failed to register IRQ handler\n",
3504 wiphy_name(hw
->wiphy
));
3505 goto err_free_queues
;
3509 * Temporarily enable interrupts. Initial firmware host
3510 * commands use interrupts and avoids polling. Disable
3511 * interrupts when done.
3513 iowrite32(MWL8K_A2H_EVENTS
, priv
->regs
+ MWL8K_HIU_A2H_INTERRUPT_MASK
);
3515 /* Get config data, mac addrs etc */
3517 rc
= mwl8k_cmd_get_hw_spec_ap(hw
);
3519 rc
= mwl8k_cmd_set_hw_spec(hw
);
3521 rc
= mwl8k_cmd_get_hw_spec_sta(hw
);
3523 hw
->wiphy
->interface_modes
= BIT(NL80211_IFTYPE_STATION
);
3526 printk(KERN_ERR
"%s: Cannot initialise firmware\n",
3527 wiphy_name(hw
->wiphy
));
3531 /* Turn radio off */
3532 rc
= mwl8k_cmd_radio_disable(hw
);
3534 printk(KERN_ERR
"%s: Cannot disable\n", wiphy_name(hw
->wiphy
));
3538 /* Clear MAC address */
3539 rc
= mwl8k_cmd_set_mac_addr(hw
, "\x00\x00\x00\x00\x00\x00");
3541 printk(KERN_ERR
"%s: Cannot clear MAC address\n",
3542 wiphy_name(hw
->wiphy
));
3546 /* Disable interrupts */
3547 iowrite32(0, priv
->regs
+ MWL8K_HIU_A2H_INTERRUPT_MASK
);
3548 free_irq(priv
->pdev
->irq
, hw
);
3550 rc
= ieee80211_register_hw(hw
);
3552 printk(KERN_ERR
"%s: Cannot register device\n",
3553 wiphy_name(hw
->wiphy
));
3554 goto err_free_queues
;
3557 printk(KERN_INFO
"%s: %s v%d, %pM, %s firmware %u.%u.%u.%u\n",
3558 wiphy_name(hw
->wiphy
), priv
->device_info
->part_name
,
3559 priv
->hw_rev
, hw
->wiphy
->perm_addr
,
3560 priv
->ap_fw
? "AP" : "STA",
3561 (priv
->fw_rev
>> 24) & 0xff, (priv
->fw_rev
>> 16) & 0xff,
3562 (priv
->fw_rev
>> 8) & 0xff, priv
->fw_rev
& 0xff);
3567 iowrite32(0, priv
->regs
+ MWL8K_HIU_A2H_INTERRUPT_MASK
);
3568 free_irq(priv
->pdev
->irq
, hw
);
3571 for (i
= 0; i
< MWL8K_TX_QUEUES
; i
++)
3572 mwl8k_txq_deinit(hw
, i
);
3573 mwl8k_rxq_deinit(hw
, 0);
3576 if (priv
->cookie
!= NULL
)
3577 pci_free_consistent(priv
->pdev
, 4,
3578 priv
->cookie
, priv
->cookie_dma
);
3581 mwl8k_hw_reset(priv
);
3582 mwl8k_release_firmware(priv
);
3585 if (priv
->regs
!= NULL
)
3586 pci_iounmap(pdev
, priv
->regs
);
3588 if (priv
->sram
!= NULL
)
3589 pci_iounmap(pdev
, priv
->sram
);
3591 pci_set_drvdata(pdev
, NULL
);
3592 ieee80211_free_hw(hw
);
3595 pci_release_regions(pdev
);
3598 pci_disable_device(pdev
);
3603 static void __devexit
mwl8k_shutdown(struct pci_dev
*pdev
)
3605 printk(KERN_ERR
"===>%s(%u)\n", __func__
, __LINE__
);
3608 static void __devexit
mwl8k_remove(struct pci_dev
*pdev
)
3610 struct ieee80211_hw
*hw
= pci_get_drvdata(pdev
);
3611 struct mwl8k_priv
*priv
;
3618 ieee80211_stop_queues(hw
);
3620 ieee80211_unregister_hw(hw
);
3622 /* Remove tx reclaim tasklet */
3623 tasklet_kill(&priv
->tx_reclaim_task
);
3626 mwl8k_hw_reset(priv
);
3628 /* Return all skbs to mac80211 */
3629 for (i
= 0; i
< MWL8K_TX_QUEUES
; i
++)
3630 mwl8k_txq_reclaim(hw
, i
, 1);
3632 for (i
= 0; i
< MWL8K_TX_QUEUES
; i
++)
3633 mwl8k_txq_deinit(hw
, i
);
3635 mwl8k_rxq_deinit(hw
, 0);
3637 pci_free_consistent(priv
->pdev
, 4, priv
->cookie
, priv
->cookie_dma
);
3639 pci_iounmap(pdev
, priv
->regs
);
3640 pci_iounmap(pdev
, priv
->sram
);
3641 pci_set_drvdata(pdev
, NULL
);
3642 ieee80211_free_hw(hw
);
3643 pci_release_regions(pdev
);
3644 pci_disable_device(pdev
);
3647 static struct pci_driver mwl8k_driver
= {
3649 .id_table
= mwl8k_pci_id_table
,
3650 .probe
= mwl8k_probe
,
3651 .remove
= __devexit_p(mwl8k_remove
),
3652 .shutdown
= __devexit_p(mwl8k_shutdown
),
3655 static int __init
mwl8k_init(void)
3657 return pci_register_driver(&mwl8k_driver
);
3660 static void __exit
mwl8k_exit(void)
3662 pci_unregister_driver(&mwl8k_driver
);
3665 module_init(mwl8k_init
);
3666 module_exit(mwl8k_exit
);
3668 MODULE_DESCRIPTION(MWL8K_DESC
);
3669 MODULE_VERSION(MWL8K_VERSION
);
3670 MODULE_AUTHOR("Lennert Buytenhek <buytenh@marvell.com>");
3671 MODULE_LICENSE("GPL");