2 * drivers/net/wireless/mwl8k.c
3 * Driver for Marvell TOPDOG 802.11 Wireless cards
5 * Copyright (C) 2008, 2009, 2010 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 <linux/slab.h>
23 #include <net/mac80211.h>
24 #include <linux/moduleparam.h>
25 #include <linux/firmware.h>
26 #include <linux/workqueue.h>
28 #define MWL8K_DESC "Marvell TOPDOG(R) 802.11 Wireless Network Driver"
29 #define MWL8K_NAME KBUILD_MODNAME
30 #define MWL8K_VERSION "0.12"
32 /* Module parameters */
33 static unsigned ap_mode_default
;
34 module_param(ap_mode_default
, bool, 0);
35 MODULE_PARM_DESC(ap_mode_default
,
36 "Set to 1 to make ap mode the default instead of sta mode");
38 /* Register definitions */
39 #define MWL8K_HIU_GEN_PTR 0x00000c10
40 #define MWL8K_MODE_STA 0x0000005a
41 #define MWL8K_MODE_AP 0x000000a5
42 #define MWL8K_HIU_INT_CODE 0x00000c14
43 #define MWL8K_FWSTA_READY 0xf0f1f2f4
44 #define MWL8K_FWAP_READY 0xf1f2f4a5
45 #define MWL8K_INT_CODE_CMD_FINISHED 0x00000005
46 #define MWL8K_HIU_SCRATCH 0x00000c40
48 /* Host->device communications */
49 #define MWL8K_HIU_H2A_INTERRUPT_EVENTS 0x00000c18
50 #define MWL8K_HIU_H2A_INTERRUPT_STATUS 0x00000c1c
51 #define MWL8K_HIU_H2A_INTERRUPT_MASK 0x00000c20
52 #define MWL8K_HIU_H2A_INTERRUPT_CLEAR_SEL 0x00000c24
53 #define MWL8K_HIU_H2A_INTERRUPT_STATUS_MASK 0x00000c28
54 #define MWL8K_H2A_INT_DUMMY (1 << 20)
55 #define MWL8K_H2A_INT_RESET (1 << 15)
56 #define MWL8K_H2A_INT_DOORBELL (1 << 1)
57 #define MWL8K_H2A_INT_PPA_READY (1 << 0)
59 /* Device->host communications */
60 #define MWL8K_HIU_A2H_INTERRUPT_EVENTS 0x00000c2c
61 #define MWL8K_HIU_A2H_INTERRUPT_STATUS 0x00000c30
62 #define MWL8K_HIU_A2H_INTERRUPT_MASK 0x00000c34
63 #define MWL8K_HIU_A2H_INTERRUPT_CLEAR_SEL 0x00000c38
64 #define MWL8K_HIU_A2H_INTERRUPT_STATUS_MASK 0x00000c3c
65 #define MWL8K_A2H_INT_DUMMY (1 << 20)
66 #define MWL8K_A2H_INT_CHNL_SWITCHED (1 << 11)
67 #define MWL8K_A2H_INT_QUEUE_EMPTY (1 << 10)
68 #define MWL8K_A2H_INT_RADAR_DETECT (1 << 7)
69 #define MWL8K_A2H_INT_RADIO_ON (1 << 6)
70 #define MWL8K_A2H_INT_RADIO_OFF (1 << 5)
71 #define MWL8K_A2H_INT_MAC_EVENT (1 << 3)
72 #define MWL8K_A2H_INT_OPC_DONE (1 << 2)
73 #define MWL8K_A2H_INT_RX_READY (1 << 1)
74 #define MWL8K_A2H_INT_TX_DONE (1 << 0)
76 #define MWL8K_A2H_EVENTS (MWL8K_A2H_INT_DUMMY | \
77 MWL8K_A2H_INT_CHNL_SWITCHED | \
78 MWL8K_A2H_INT_QUEUE_EMPTY | \
79 MWL8K_A2H_INT_RADAR_DETECT | \
80 MWL8K_A2H_INT_RADIO_ON | \
81 MWL8K_A2H_INT_RADIO_OFF | \
82 MWL8K_A2H_INT_MAC_EVENT | \
83 MWL8K_A2H_INT_OPC_DONE | \
84 MWL8K_A2H_INT_RX_READY | \
85 MWL8K_A2H_INT_TX_DONE)
87 #define MWL8K_RX_QUEUES 1
88 #define MWL8K_TX_QUEUES 4
92 void (*rxd_init
)(void *rxd
, dma_addr_t next_dma_addr
);
93 void (*rxd_refill
)(void *rxd
, dma_addr_t addr
, int len
);
94 int (*rxd_process
)(void *rxd
, struct ieee80211_rx_status
*status
,
95 __le16
*qos
, s8
*noise
);
98 struct mwl8k_device_info
{
103 struct rxd_ops
*ap_rxd_ops
;
107 struct mwl8k_rx_queue
{
110 /* hw receives here */
113 /* refill descs here */
120 DEFINE_DMA_UNMAP_ADDR(dma
);
124 struct mwl8k_tx_queue
{
125 /* hw transmits here */
128 /* sw appends here */
132 struct mwl8k_tx_desc
*txd
;
134 struct sk_buff
**skb
;
138 struct ieee80211_hw
*hw
;
139 struct pci_dev
*pdev
;
142 struct mwl8k_device_info
*device_info
;
148 const struct firmware
*fw_helper
;
149 const struct firmware
*fw_ucode
;
151 /* hardware/firmware parameters */
153 struct rxd_ops
*rxd_ops
;
154 struct ieee80211_supported_band band_24
;
155 struct ieee80211_channel channels_24
[14];
156 struct ieee80211_rate rates_24
[14];
157 struct ieee80211_supported_band band_50
;
158 struct ieee80211_channel channels_50
[4];
159 struct ieee80211_rate rates_50
[9];
160 u32 ap_macids_supported
;
161 u32 sta_macids_supported
;
163 /* firmware access */
164 struct mutex fw_mutex
;
165 struct task_struct
*fw_mutex_owner
;
167 struct completion
*hostcmd_wait
;
169 /* lock held over TX and TX reap */
172 /* TX quiesce completion, protected by fw_mutex and tx_lock */
173 struct completion
*tx_wait
;
175 /* List of interfaces. */
177 struct list_head vif_list
;
179 /* power management status cookie from firmware */
181 dma_addr_t cookie_dma
;
188 * Running count of TX packets in flight, to avoid
189 * iterating over the transmit rings each time.
193 struct mwl8k_rx_queue rxq
[MWL8K_RX_QUEUES
];
194 struct mwl8k_tx_queue txq
[MWL8K_TX_QUEUES
];
197 bool radio_short_preamble
;
198 bool sniffer_enabled
;
201 /* XXX need to convert this to handle multiple interfaces */
203 u8 capture_bssid
[ETH_ALEN
];
204 struct sk_buff
*beacon_skb
;
207 * This FJ worker has to be global as it is scheduled from the
208 * RX handler. At this point we don't know which interface it
209 * belongs to until the list of bssids waiting to complete join
212 struct work_struct finalize_join_worker
;
214 /* Tasklet to perform TX reclaim. */
215 struct tasklet_struct poll_tx_task
;
217 /* Tasklet to perform RX. */
218 struct tasklet_struct poll_rx_task
;
220 /* Most recently reported noise in dBm */
224 * preserve the queue configurations so they can be restored if/when
225 * the firmware image is swapped.
227 struct ieee80211_tx_queue_params wmm_params
[MWL8K_TX_QUEUES
];
229 /* async firmware loading state */
233 struct completion firmware_loading_complete
;
236 #define MAX_WEP_KEY_LEN 13
237 #define NUM_WEP_KEYS 4
239 /* Per interface specific private data */
241 struct list_head list
;
242 struct ieee80211_vif
*vif
;
244 /* Firmware macid for this vif. */
247 /* Non AMPDU sequence number assigned by driver. */
253 u8 key
[sizeof(struct ieee80211_key_conf
) + MAX_WEP_KEY_LEN
];
254 } wep_key_conf
[NUM_WEP_KEYS
];
259 /* A flag to indicate is HW crypto is enabled for this bssid */
260 bool is_hw_crypto_enabled
;
262 #define MWL8K_VIF(_vif) ((struct mwl8k_vif *)&((_vif)->drv_priv))
263 #define IEEE80211_KEY_CONF(_u8) ((struct ieee80211_key_conf *)(_u8))
266 /* Index into station database. Returned by UPDATE_STADB. */
269 #define MWL8K_STA(_sta) ((struct mwl8k_sta *)&((_sta)->drv_priv))
271 static const struct ieee80211_channel mwl8k_channels_24
[] = {
272 { .center_freq
= 2412, .hw_value
= 1, },
273 { .center_freq
= 2417, .hw_value
= 2, },
274 { .center_freq
= 2422, .hw_value
= 3, },
275 { .center_freq
= 2427, .hw_value
= 4, },
276 { .center_freq
= 2432, .hw_value
= 5, },
277 { .center_freq
= 2437, .hw_value
= 6, },
278 { .center_freq
= 2442, .hw_value
= 7, },
279 { .center_freq
= 2447, .hw_value
= 8, },
280 { .center_freq
= 2452, .hw_value
= 9, },
281 { .center_freq
= 2457, .hw_value
= 10, },
282 { .center_freq
= 2462, .hw_value
= 11, },
283 { .center_freq
= 2467, .hw_value
= 12, },
284 { .center_freq
= 2472, .hw_value
= 13, },
285 { .center_freq
= 2484, .hw_value
= 14, },
288 static const struct ieee80211_rate mwl8k_rates_24
[] = {
289 { .bitrate
= 10, .hw_value
= 2, },
290 { .bitrate
= 20, .hw_value
= 4, },
291 { .bitrate
= 55, .hw_value
= 11, },
292 { .bitrate
= 110, .hw_value
= 22, },
293 { .bitrate
= 220, .hw_value
= 44, },
294 { .bitrate
= 60, .hw_value
= 12, },
295 { .bitrate
= 90, .hw_value
= 18, },
296 { .bitrate
= 120, .hw_value
= 24, },
297 { .bitrate
= 180, .hw_value
= 36, },
298 { .bitrate
= 240, .hw_value
= 48, },
299 { .bitrate
= 360, .hw_value
= 72, },
300 { .bitrate
= 480, .hw_value
= 96, },
301 { .bitrate
= 540, .hw_value
= 108, },
302 { .bitrate
= 720, .hw_value
= 144, },
305 static const struct ieee80211_channel mwl8k_channels_50
[] = {
306 { .center_freq
= 5180, .hw_value
= 36, },
307 { .center_freq
= 5200, .hw_value
= 40, },
308 { .center_freq
= 5220, .hw_value
= 44, },
309 { .center_freq
= 5240, .hw_value
= 48, },
312 static const struct ieee80211_rate mwl8k_rates_50
[] = {
313 { .bitrate
= 60, .hw_value
= 12, },
314 { .bitrate
= 90, .hw_value
= 18, },
315 { .bitrate
= 120, .hw_value
= 24, },
316 { .bitrate
= 180, .hw_value
= 36, },
317 { .bitrate
= 240, .hw_value
= 48, },
318 { .bitrate
= 360, .hw_value
= 72, },
319 { .bitrate
= 480, .hw_value
= 96, },
320 { .bitrate
= 540, .hw_value
= 108, },
321 { .bitrate
= 720, .hw_value
= 144, },
324 /* Set or get info from Firmware */
325 #define MWL8K_CMD_GET 0x0000
326 #define MWL8K_CMD_SET 0x0001
327 #define MWL8K_CMD_SET_LIST 0x0002
329 /* Firmware command codes */
330 #define MWL8K_CMD_CODE_DNLD 0x0001
331 #define MWL8K_CMD_GET_HW_SPEC 0x0003
332 #define MWL8K_CMD_SET_HW_SPEC 0x0004
333 #define MWL8K_CMD_MAC_MULTICAST_ADR 0x0010
334 #define MWL8K_CMD_GET_STAT 0x0014
335 #define MWL8K_CMD_RADIO_CONTROL 0x001c
336 #define MWL8K_CMD_RF_TX_POWER 0x001e
337 #define MWL8K_CMD_TX_POWER 0x001f
338 #define MWL8K_CMD_RF_ANTENNA 0x0020
339 #define MWL8K_CMD_SET_BEACON 0x0100 /* per-vif */
340 #define MWL8K_CMD_SET_PRE_SCAN 0x0107
341 #define MWL8K_CMD_SET_POST_SCAN 0x0108
342 #define MWL8K_CMD_SET_RF_CHANNEL 0x010a
343 #define MWL8K_CMD_SET_AID 0x010d
344 #define MWL8K_CMD_SET_RATE 0x0110
345 #define MWL8K_CMD_SET_FINALIZE_JOIN 0x0111
346 #define MWL8K_CMD_RTS_THRESHOLD 0x0113
347 #define MWL8K_CMD_SET_SLOT 0x0114
348 #define MWL8K_CMD_SET_EDCA_PARAMS 0x0115
349 #define MWL8K_CMD_SET_WMM_MODE 0x0123
350 #define MWL8K_CMD_MIMO_CONFIG 0x0125
351 #define MWL8K_CMD_USE_FIXED_RATE 0x0126
352 #define MWL8K_CMD_ENABLE_SNIFFER 0x0150
353 #define MWL8K_CMD_SET_MAC_ADDR 0x0202 /* per-vif */
354 #define MWL8K_CMD_SET_RATEADAPT_MODE 0x0203
355 #define MWL8K_CMD_BSS_START 0x1100 /* per-vif */
356 #define MWL8K_CMD_SET_NEW_STN 0x1111 /* per-vif */
357 #define MWL8K_CMD_UPDATE_ENCRYPTION 0x1122 /* per-vif */
358 #define MWL8K_CMD_UPDATE_STADB 0x1123
360 static const char *mwl8k_cmd_name(__le16 cmd
, char *buf
, int bufsize
)
362 u16 command
= le16_to_cpu(cmd
);
364 #define MWL8K_CMDNAME(x) case MWL8K_CMD_##x: do {\
365 snprintf(buf, bufsize, "%s", #x);\
368 switch (command
& ~0x8000) {
369 MWL8K_CMDNAME(CODE_DNLD
);
370 MWL8K_CMDNAME(GET_HW_SPEC
);
371 MWL8K_CMDNAME(SET_HW_SPEC
);
372 MWL8K_CMDNAME(MAC_MULTICAST_ADR
);
373 MWL8K_CMDNAME(GET_STAT
);
374 MWL8K_CMDNAME(RADIO_CONTROL
);
375 MWL8K_CMDNAME(RF_TX_POWER
);
376 MWL8K_CMDNAME(TX_POWER
);
377 MWL8K_CMDNAME(RF_ANTENNA
);
378 MWL8K_CMDNAME(SET_BEACON
);
379 MWL8K_CMDNAME(SET_PRE_SCAN
);
380 MWL8K_CMDNAME(SET_POST_SCAN
);
381 MWL8K_CMDNAME(SET_RF_CHANNEL
);
382 MWL8K_CMDNAME(SET_AID
);
383 MWL8K_CMDNAME(SET_RATE
);
384 MWL8K_CMDNAME(SET_FINALIZE_JOIN
);
385 MWL8K_CMDNAME(RTS_THRESHOLD
);
386 MWL8K_CMDNAME(SET_SLOT
);
387 MWL8K_CMDNAME(SET_EDCA_PARAMS
);
388 MWL8K_CMDNAME(SET_WMM_MODE
);
389 MWL8K_CMDNAME(MIMO_CONFIG
);
390 MWL8K_CMDNAME(USE_FIXED_RATE
);
391 MWL8K_CMDNAME(ENABLE_SNIFFER
);
392 MWL8K_CMDNAME(SET_MAC_ADDR
);
393 MWL8K_CMDNAME(SET_RATEADAPT_MODE
);
394 MWL8K_CMDNAME(BSS_START
);
395 MWL8K_CMDNAME(SET_NEW_STN
);
396 MWL8K_CMDNAME(UPDATE_ENCRYPTION
);
397 MWL8K_CMDNAME(UPDATE_STADB
);
399 snprintf(buf
, bufsize
, "0x%x", cmd
);
406 /* Hardware and firmware reset */
407 static void mwl8k_hw_reset(struct mwl8k_priv
*priv
)
409 iowrite32(MWL8K_H2A_INT_RESET
,
410 priv
->regs
+ MWL8K_HIU_H2A_INTERRUPT_EVENTS
);
411 iowrite32(MWL8K_H2A_INT_RESET
,
412 priv
->regs
+ MWL8K_HIU_H2A_INTERRUPT_EVENTS
);
416 /* Release fw image */
417 static void mwl8k_release_fw(const struct firmware
**fw
)
421 release_firmware(*fw
);
425 static void mwl8k_release_firmware(struct mwl8k_priv
*priv
)
427 mwl8k_release_fw(&priv
->fw_ucode
);
428 mwl8k_release_fw(&priv
->fw_helper
);
431 /* states for asynchronous f/w loading */
432 static void mwl8k_fw_state_machine(const struct firmware
*fw
, void *context
);
435 FW_STATE_LOADING_PREF
,
436 FW_STATE_LOADING_ALT
,
440 /* Request fw image */
441 static int mwl8k_request_fw(struct mwl8k_priv
*priv
,
442 const char *fname
, const struct firmware
**fw
,
445 /* release current image */
447 mwl8k_release_fw(fw
);
450 return request_firmware_nowait(THIS_MODULE
, 1, fname
,
451 &priv
->pdev
->dev
, GFP_KERNEL
,
452 priv
, mwl8k_fw_state_machine
);
454 return request_firmware(fw
, fname
, &priv
->pdev
->dev
);
457 static int mwl8k_request_firmware(struct mwl8k_priv
*priv
, char *fw_image
,
460 struct mwl8k_device_info
*di
= priv
->device_info
;
463 if (di
->helper_image
!= NULL
) {
465 rc
= mwl8k_request_fw(priv
, di
->helper_image
,
466 &priv
->fw_helper
, true);
468 rc
= mwl8k_request_fw(priv
, di
->helper_image
,
469 &priv
->fw_helper
, false);
471 printk(KERN_ERR
"%s: Error requesting helper fw %s\n",
472 pci_name(priv
->pdev
), di
->helper_image
);
480 * if we get here, no helper image is needed. Skip the
481 * FW_STATE_INIT state.
483 priv
->fw_state
= FW_STATE_LOADING_PREF
;
484 rc
= mwl8k_request_fw(priv
, fw_image
,
488 rc
= mwl8k_request_fw(priv
, fw_image
,
489 &priv
->fw_ucode
, false);
491 printk(KERN_ERR
"%s: Error requesting firmware file %s\n",
492 pci_name(priv
->pdev
), fw_image
);
493 mwl8k_release_fw(&priv
->fw_helper
);
500 struct mwl8k_cmd_pkt
{
513 mwl8k_send_fw_load_cmd(struct mwl8k_priv
*priv
, void *data
, int length
)
515 void __iomem
*regs
= priv
->regs
;
519 dma_addr
= pci_map_single(priv
->pdev
, data
, length
, PCI_DMA_TODEVICE
);
520 if (pci_dma_mapping_error(priv
->pdev
, dma_addr
))
523 iowrite32(dma_addr
, regs
+ MWL8K_HIU_GEN_PTR
);
524 iowrite32(0, regs
+ MWL8K_HIU_INT_CODE
);
525 iowrite32(MWL8K_H2A_INT_DOORBELL
,
526 regs
+ MWL8K_HIU_H2A_INTERRUPT_EVENTS
);
527 iowrite32(MWL8K_H2A_INT_DUMMY
,
528 regs
+ MWL8K_HIU_H2A_INTERRUPT_EVENTS
);
534 int_code
= ioread32(regs
+ MWL8K_HIU_INT_CODE
);
535 if (int_code
== MWL8K_INT_CODE_CMD_FINISHED
) {
536 iowrite32(0, regs
+ MWL8K_HIU_INT_CODE
);
544 pci_unmap_single(priv
->pdev
, dma_addr
, length
, PCI_DMA_TODEVICE
);
546 return loops
? 0 : -ETIMEDOUT
;
549 static int mwl8k_load_fw_image(struct mwl8k_priv
*priv
,
550 const u8
*data
, size_t length
)
552 struct mwl8k_cmd_pkt
*cmd
;
556 cmd
= kmalloc(sizeof(*cmd
) + 256, GFP_KERNEL
);
560 cmd
->code
= cpu_to_le16(MWL8K_CMD_CODE_DNLD
);
567 int block_size
= length
> 256 ? 256 : length
;
569 memcpy(cmd
->payload
, data
+ done
, block_size
);
570 cmd
->length
= cpu_to_le16(block_size
);
572 rc
= mwl8k_send_fw_load_cmd(priv
, cmd
,
573 sizeof(*cmd
) + block_size
);
578 length
-= block_size
;
583 rc
= mwl8k_send_fw_load_cmd(priv
, cmd
, sizeof(*cmd
));
591 static int mwl8k_feed_fw_image(struct mwl8k_priv
*priv
,
592 const u8
*data
, size_t length
)
594 unsigned char *buffer
;
595 int may_continue
, rc
= 0;
596 u32 done
, prev_block_size
;
598 buffer
= kmalloc(1024, GFP_KERNEL
);
605 while (may_continue
> 0) {
608 block_size
= ioread32(priv
->regs
+ MWL8K_HIU_SCRATCH
);
609 if (block_size
& 1) {
613 done
+= prev_block_size
;
614 length
-= prev_block_size
;
617 if (block_size
> 1024 || block_size
> length
) {
627 if (block_size
== 0) {
634 prev_block_size
= block_size
;
635 memcpy(buffer
, data
+ done
, block_size
);
637 rc
= mwl8k_send_fw_load_cmd(priv
, buffer
, block_size
);
642 if (!rc
&& length
!= 0)
650 static int mwl8k_load_firmware(struct ieee80211_hw
*hw
)
652 struct mwl8k_priv
*priv
= hw
->priv
;
653 const struct firmware
*fw
= priv
->fw_ucode
;
657 if (!memcmp(fw
->data
, "\x01\x00\x00\x00", 4)) {
658 const struct firmware
*helper
= priv
->fw_helper
;
660 if (helper
== NULL
) {
661 printk(KERN_ERR
"%s: helper image needed but none "
662 "given\n", pci_name(priv
->pdev
));
666 rc
= mwl8k_load_fw_image(priv
, helper
->data
, helper
->size
);
668 printk(KERN_ERR
"%s: unable to load firmware "
669 "helper image\n", pci_name(priv
->pdev
));
674 rc
= mwl8k_feed_fw_image(priv
, fw
->data
, fw
->size
);
676 rc
= mwl8k_load_fw_image(priv
, fw
->data
, fw
->size
);
680 printk(KERN_ERR
"%s: unable to load firmware image\n",
681 pci_name(priv
->pdev
));
685 iowrite32(MWL8K_MODE_STA
, priv
->regs
+ MWL8K_HIU_GEN_PTR
);
691 ready_code
= ioread32(priv
->regs
+ MWL8K_HIU_INT_CODE
);
692 if (ready_code
== MWL8K_FWAP_READY
) {
695 } else if (ready_code
== MWL8K_FWSTA_READY
) {
704 return loops
? 0 : -ETIMEDOUT
;
708 /* DMA header used by firmware and hardware. */
709 struct mwl8k_dma_data
{
711 struct ieee80211_hdr wh
;
715 /* Routines to add/remove DMA header from skb. */
716 static inline void mwl8k_remove_dma_header(struct sk_buff
*skb
, __le16 qos
)
718 struct mwl8k_dma_data
*tr
;
721 tr
= (struct mwl8k_dma_data
*)skb
->data
;
722 hdrlen
= ieee80211_hdrlen(tr
->wh
.frame_control
);
724 if (hdrlen
!= sizeof(tr
->wh
)) {
725 if (ieee80211_is_data_qos(tr
->wh
.frame_control
)) {
726 memmove(tr
->data
- hdrlen
, &tr
->wh
, hdrlen
- 2);
727 *((__le16
*)(tr
->data
- 2)) = qos
;
729 memmove(tr
->data
- hdrlen
, &tr
->wh
, hdrlen
);
733 if (hdrlen
!= sizeof(*tr
))
734 skb_pull(skb
, sizeof(*tr
) - hdrlen
);
738 mwl8k_add_dma_header(struct sk_buff
*skb
, int tail_pad
)
740 struct ieee80211_hdr
*wh
;
743 struct mwl8k_dma_data
*tr
;
746 * Add a firmware DMA header; the firmware requires that we
747 * present a 2-byte payload length followed by a 4-address
748 * header (without QoS field), followed (optionally) by any
749 * WEP/ExtIV header (but only filled in for CCMP).
751 wh
= (struct ieee80211_hdr
*)skb
->data
;
753 hdrlen
= ieee80211_hdrlen(wh
->frame_control
);
754 reqd_hdrlen
= sizeof(*tr
);
756 if (hdrlen
!= reqd_hdrlen
)
757 skb_push(skb
, reqd_hdrlen
- hdrlen
);
759 if (ieee80211_is_data_qos(wh
->frame_control
))
760 hdrlen
-= IEEE80211_QOS_CTL_LEN
;
762 tr
= (struct mwl8k_dma_data
*)skb
->data
;
764 memmove(&tr
->wh
, wh
, hdrlen
);
765 if (hdrlen
!= sizeof(tr
->wh
))
766 memset(((void *)&tr
->wh
) + hdrlen
, 0, sizeof(tr
->wh
) - hdrlen
);
769 * Firmware length is the length of the fully formed "802.11
770 * payload". That is, everything except for the 802.11 header.
771 * This includes all crypto material including the MIC.
773 tr
->fwlen
= cpu_to_le16(skb
->len
- sizeof(*tr
) + tail_pad
);
776 static void mwl8k_encapsulate_tx_frame(struct sk_buff
*skb
)
778 struct ieee80211_hdr
*wh
;
779 struct ieee80211_tx_info
*tx_info
;
780 struct ieee80211_key_conf
*key_conf
;
783 wh
= (struct ieee80211_hdr
*)skb
->data
;
785 tx_info
= IEEE80211_SKB_CB(skb
);
788 if (ieee80211_is_data(wh
->frame_control
))
789 key_conf
= tx_info
->control
.hw_key
;
792 * Make sure the packet header is in the DMA header format (4-address
793 * without QoS), the necessary crypto padding between the header and the
794 * payload has already been provided by mac80211, but it doesn't add tail
795 * padding when HW crypto is enabled.
797 * We have the following trailer padding requirements:
798 * - WEP: 4 trailer bytes (ICV)
799 * - TKIP: 12 trailer bytes (8 MIC + 4 ICV)
800 * - CCMP: 8 trailer bytes (MIC)
803 if (key_conf
!= NULL
) {
804 switch (key_conf
->cipher
) {
805 case WLAN_CIPHER_SUITE_WEP40
:
806 case WLAN_CIPHER_SUITE_WEP104
:
809 case WLAN_CIPHER_SUITE_TKIP
:
812 case WLAN_CIPHER_SUITE_CCMP
:
817 mwl8k_add_dma_header(skb
, data_pad
);
821 * Packet reception for 88w8366 AP firmware.
823 struct mwl8k_rxd_8366_ap
{
827 __le32 pkt_phys_addr
;
828 __le32 next_rxd_phys_addr
;
832 __le32 hw_noise_floor_info
;
841 #define MWL8K_8366_AP_RATE_INFO_MCS_FORMAT 0x80
842 #define MWL8K_8366_AP_RATE_INFO_40MHZ 0x40
843 #define MWL8K_8366_AP_RATE_INFO_RATEID(x) ((x) & 0x3f)
845 #define MWL8K_8366_AP_RX_CTRL_OWNED_BY_HOST 0x80
847 /* 8366 AP rx_status bits */
848 #define MWL8K_8366_AP_RXSTAT_DECRYPT_ERR_MASK 0x80
849 #define MWL8K_8366_AP_RXSTAT_GENERAL_DECRYPT_ERR 0xFF
850 #define MWL8K_8366_AP_RXSTAT_TKIP_DECRYPT_MIC_ERR 0x02
851 #define MWL8K_8366_AP_RXSTAT_WEP_DECRYPT_ICV_ERR 0x04
852 #define MWL8K_8366_AP_RXSTAT_TKIP_DECRYPT_ICV_ERR 0x08
854 static void mwl8k_rxd_8366_ap_init(void *_rxd
, dma_addr_t next_dma_addr
)
856 struct mwl8k_rxd_8366_ap
*rxd
= _rxd
;
858 rxd
->next_rxd_phys_addr
= cpu_to_le32(next_dma_addr
);
859 rxd
->rx_ctrl
= MWL8K_8366_AP_RX_CTRL_OWNED_BY_HOST
;
862 static void mwl8k_rxd_8366_ap_refill(void *_rxd
, dma_addr_t addr
, int len
)
864 struct mwl8k_rxd_8366_ap
*rxd
= _rxd
;
866 rxd
->pkt_len
= cpu_to_le16(len
);
867 rxd
->pkt_phys_addr
= cpu_to_le32(addr
);
873 mwl8k_rxd_8366_ap_process(void *_rxd
, struct ieee80211_rx_status
*status
,
874 __le16
*qos
, s8
*noise
)
876 struct mwl8k_rxd_8366_ap
*rxd
= _rxd
;
878 if (!(rxd
->rx_ctrl
& MWL8K_8366_AP_RX_CTRL_OWNED_BY_HOST
))
882 memset(status
, 0, sizeof(*status
));
884 status
->signal
= -rxd
->rssi
;
885 *noise
= -rxd
->noise_floor
;
887 if (rxd
->rate
& MWL8K_8366_AP_RATE_INFO_MCS_FORMAT
) {
888 status
->flag
|= RX_FLAG_HT
;
889 if (rxd
->rate
& MWL8K_8366_AP_RATE_INFO_40MHZ
)
890 status
->flag
|= RX_FLAG_40MHZ
;
891 status
->rate_idx
= MWL8K_8366_AP_RATE_INFO_RATEID(rxd
->rate
);
895 for (i
= 0; i
< ARRAY_SIZE(mwl8k_rates_24
); i
++) {
896 if (mwl8k_rates_24
[i
].hw_value
== rxd
->rate
) {
897 status
->rate_idx
= i
;
903 if (rxd
->channel
> 14) {
904 status
->band
= IEEE80211_BAND_5GHZ
;
905 if (!(status
->flag
& RX_FLAG_HT
))
906 status
->rate_idx
-= 5;
908 status
->band
= IEEE80211_BAND_2GHZ
;
910 status
->freq
= ieee80211_channel_to_frequency(rxd
->channel
,
913 *qos
= rxd
->qos_control
;
915 if ((rxd
->rx_status
!= MWL8K_8366_AP_RXSTAT_GENERAL_DECRYPT_ERR
) &&
916 (rxd
->rx_status
& MWL8K_8366_AP_RXSTAT_DECRYPT_ERR_MASK
) &&
917 (rxd
->rx_status
& MWL8K_8366_AP_RXSTAT_TKIP_DECRYPT_MIC_ERR
))
918 status
->flag
|= RX_FLAG_MMIC_ERROR
;
920 return le16_to_cpu(rxd
->pkt_len
);
923 static struct rxd_ops rxd_8366_ap_ops
= {
924 .rxd_size
= sizeof(struct mwl8k_rxd_8366_ap
),
925 .rxd_init
= mwl8k_rxd_8366_ap_init
,
926 .rxd_refill
= mwl8k_rxd_8366_ap_refill
,
927 .rxd_process
= mwl8k_rxd_8366_ap_process
,
931 * Packet reception for STA firmware.
933 struct mwl8k_rxd_sta
{
937 __le32 pkt_phys_addr
;
938 __le32 next_rxd_phys_addr
;
950 #define MWL8K_STA_RATE_INFO_SHORTPRE 0x8000
951 #define MWL8K_STA_RATE_INFO_ANTSELECT(x) (((x) >> 11) & 0x3)
952 #define MWL8K_STA_RATE_INFO_RATEID(x) (((x) >> 3) & 0x3f)
953 #define MWL8K_STA_RATE_INFO_40MHZ 0x0004
954 #define MWL8K_STA_RATE_INFO_SHORTGI 0x0002
955 #define MWL8K_STA_RATE_INFO_MCS_FORMAT 0x0001
957 #define MWL8K_STA_RX_CTRL_OWNED_BY_HOST 0x02
958 #define MWL8K_STA_RX_CTRL_DECRYPT_ERROR 0x04
960 #define MWL8K_STA_RX_CTRL_DEC_ERR_TYPE 0x08
961 /* Key is uploaded only in failure case */
962 #define MWL8K_STA_RX_CTRL_KEY_INDEX 0x30
964 static void mwl8k_rxd_sta_init(void *_rxd
, dma_addr_t next_dma_addr
)
966 struct mwl8k_rxd_sta
*rxd
= _rxd
;
968 rxd
->next_rxd_phys_addr
= cpu_to_le32(next_dma_addr
);
969 rxd
->rx_ctrl
= MWL8K_STA_RX_CTRL_OWNED_BY_HOST
;
972 static void mwl8k_rxd_sta_refill(void *_rxd
, dma_addr_t addr
, int len
)
974 struct mwl8k_rxd_sta
*rxd
= _rxd
;
976 rxd
->pkt_len
= cpu_to_le16(len
);
977 rxd
->pkt_phys_addr
= cpu_to_le32(addr
);
983 mwl8k_rxd_sta_process(void *_rxd
, struct ieee80211_rx_status
*status
,
984 __le16
*qos
, s8
*noise
)
986 struct mwl8k_rxd_sta
*rxd
= _rxd
;
989 if (!(rxd
->rx_ctrl
& MWL8K_STA_RX_CTRL_OWNED_BY_HOST
))
993 rate_info
= le16_to_cpu(rxd
->rate_info
);
995 memset(status
, 0, sizeof(*status
));
997 status
->signal
= -rxd
->rssi
;
998 *noise
= -rxd
->noise_level
;
999 status
->antenna
= MWL8K_STA_RATE_INFO_ANTSELECT(rate_info
);
1000 status
->rate_idx
= MWL8K_STA_RATE_INFO_RATEID(rate_info
);
1002 if (rate_info
& MWL8K_STA_RATE_INFO_SHORTPRE
)
1003 status
->flag
|= RX_FLAG_SHORTPRE
;
1004 if (rate_info
& MWL8K_STA_RATE_INFO_40MHZ
)
1005 status
->flag
|= RX_FLAG_40MHZ
;
1006 if (rate_info
& MWL8K_STA_RATE_INFO_SHORTGI
)
1007 status
->flag
|= RX_FLAG_SHORT_GI
;
1008 if (rate_info
& MWL8K_STA_RATE_INFO_MCS_FORMAT
)
1009 status
->flag
|= RX_FLAG_HT
;
1011 if (rxd
->channel
> 14) {
1012 status
->band
= IEEE80211_BAND_5GHZ
;
1013 if (!(status
->flag
& RX_FLAG_HT
))
1014 status
->rate_idx
-= 5;
1016 status
->band
= IEEE80211_BAND_2GHZ
;
1018 status
->freq
= ieee80211_channel_to_frequency(rxd
->channel
,
1021 *qos
= rxd
->qos_control
;
1022 if ((rxd
->rx_ctrl
& MWL8K_STA_RX_CTRL_DECRYPT_ERROR
) &&
1023 (rxd
->rx_ctrl
& MWL8K_STA_RX_CTRL_DEC_ERR_TYPE
))
1024 status
->flag
|= RX_FLAG_MMIC_ERROR
;
1026 return le16_to_cpu(rxd
->pkt_len
);
1029 static struct rxd_ops rxd_sta_ops
= {
1030 .rxd_size
= sizeof(struct mwl8k_rxd_sta
),
1031 .rxd_init
= mwl8k_rxd_sta_init
,
1032 .rxd_refill
= mwl8k_rxd_sta_refill
,
1033 .rxd_process
= mwl8k_rxd_sta_process
,
1037 #define MWL8K_RX_DESCS 256
1038 #define MWL8K_RX_MAXSZ 3800
1040 static int mwl8k_rxq_init(struct ieee80211_hw
*hw
, int index
)
1042 struct mwl8k_priv
*priv
= hw
->priv
;
1043 struct mwl8k_rx_queue
*rxq
= priv
->rxq
+ index
;
1051 size
= MWL8K_RX_DESCS
* priv
->rxd_ops
->rxd_size
;
1053 rxq
->rxd
= pci_alloc_consistent(priv
->pdev
, size
, &rxq
->rxd_dma
);
1054 if (rxq
->rxd
== NULL
) {
1055 wiphy_err(hw
->wiphy
, "failed to alloc RX descriptors\n");
1058 memset(rxq
->rxd
, 0, size
);
1060 rxq
->buf
= kcalloc(MWL8K_RX_DESCS
, sizeof(*rxq
->buf
), GFP_KERNEL
);
1061 if (rxq
->buf
== NULL
) {
1062 wiphy_err(hw
->wiphy
, "failed to alloc RX skbuff list\n");
1063 pci_free_consistent(priv
->pdev
, size
, rxq
->rxd
, rxq
->rxd_dma
);
1067 for (i
= 0; i
< MWL8K_RX_DESCS
; i
++) {
1071 dma_addr_t next_dma_addr
;
1073 desc_size
= priv
->rxd_ops
->rxd_size
;
1074 rxd
= rxq
->rxd
+ (i
* priv
->rxd_ops
->rxd_size
);
1077 if (nexti
== MWL8K_RX_DESCS
)
1079 next_dma_addr
= rxq
->rxd_dma
+ (nexti
* desc_size
);
1081 priv
->rxd_ops
->rxd_init(rxd
, next_dma_addr
);
1087 static int rxq_refill(struct ieee80211_hw
*hw
, int index
, int limit
)
1089 struct mwl8k_priv
*priv
= hw
->priv
;
1090 struct mwl8k_rx_queue
*rxq
= priv
->rxq
+ index
;
1094 while (rxq
->rxd_count
< MWL8K_RX_DESCS
&& limit
--) {
1095 struct sk_buff
*skb
;
1100 skb
= dev_alloc_skb(MWL8K_RX_MAXSZ
);
1104 addr
= pci_map_single(priv
->pdev
, skb
->data
,
1105 MWL8K_RX_MAXSZ
, DMA_FROM_DEVICE
);
1109 if (rxq
->tail
== MWL8K_RX_DESCS
)
1111 rxq
->buf
[rx
].skb
= skb
;
1112 dma_unmap_addr_set(&rxq
->buf
[rx
], dma
, addr
);
1114 rxd
= rxq
->rxd
+ (rx
* priv
->rxd_ops
->rxd_size
);
1115 priv
->rxd_ops
->rxd_refill(rxd
, addr
, MWL8K_RX_MAXSZ
);
1123 /* Must be called only when the card's reception is completely halted */
1124 static void mwl8k_rxq_deinit(struct ieee80211_hw
*hw
, int index
)
1126 struct mwl8k_priv
*priv
= hw
->priv
;
1127 struct mwl8k_rx_queue
*rxq
= priv
->rxq
+ index
;
1130 for (i
= 0; i
< MWL8K_RX_DESCS
; i
++) {
1131 if (rxq
->buf
[i
].skb
!= NULL
) {
1132 pci_unmap_single(priv
->pdev
,
1133 dma_unmap_addr(&rxq
->buf
[i
], dma
),
1134 MWL8K_RX_MAXSZ
, PCI_DMA_FROMDEVICE
);
1135 dma_unmap_addr_set(&rxq
->buf
[i
], dma
, 0);
1137 kfree_skb(rxq
->buf
[i
].skb
);
1138 rxq
->buf
[i
].skb
= NULL
;
1145 pci_free_consistent(priv
->pdev
,
1146 MWL8K_RX_DESCS
* priv
->rxd_ops
->rxd_size
,
1147 rxq
->rxd
, rxq
->rxd_dma
);
1153 * Scan a list of BSSIDs to process for finalize join.
1154 * Allows for extension to process multiple BSSIDs.
1157 mwl8k_capture_bssid(struct mwl8k_priv
*priv
, struct ieee80211_hdr
*wh
)
1159 return priv
->capture_beacon
&&
1160 ieee80211_is_beacon(wh
->frame_control
) &&
1161 !compare_ether_addr(wh
->addr3
, priv
->capture_bssid
);
1164 static inline void mwl8k_save_beacon(struct ieee80211_hw
*hw
,
1165 struct sk_buff
*skb
)
1167 struct mwl8k_priv
*priv
= hw
->priv
;
1169 priv
->capture_beacon
= false;
1170 memset(priv
->capture_bssid
, 0, ETH_ALEN
);
1173 * Use GFP_ATOMIC as rxq_process is called from
1174 * the primary interrupt handler, memory allocation call
1177 priv
->beacon_skb
= skb_copy(skb
, GFP_ATOMIC
);
1178 if (priv
->beacon_skb
!= NULL
)
1179 ieee80211_queue_work(hw
, &priv
->finalize_join_worker
);
1182 static inline struct mwl8k_vif
*mwl8k_find_vif_bss(struct list_head
*vif_list
,
1185 struct mwl8k_vif
*mwl8k_vif
;
1187 list_for_each_entry(mwl8k_vif
,
1189 if (memcmp(bssid
, mwl8k_vif
->bssid
,
1197 static int rxq_process(struct ieee80211_hw
*hw
, int index
, int limit
)
1199 struct mwl8k_priv
*priv
= hw
->priv
;
1200 struct mwl8k_vif
*mwl8k_vif
= NULL
;
1201 struct mwl8k_rx_queue
*rxq
= priv
->rxq
+ index
;
1205 while (rxq
->rxd_count
&& limit
--) {
1206 struct sk_buff
*skb
;
1209 struct ieee80211_rx_status status
;
1210 struct ieee80211_hdr
*wh
;
1213 skb
= rxq
->buf
[rxq
->head
].skb
;
1217 rxd
= rxq
->rxd
+ (rxq
->head
* priv
->rxd_ops
->rxd_size
);
1219 pkt_len
= priv
->rxd_ops
->rxd_process(rxd
, &status
, &qos
,
1224 rxq
->buf
[rxq
->head
].skb
= NULL
;
1226 pci_unmap_single(priv
->pdev
,
1227 dma_unmap_addr(&rxq
->buf
[rxq
->head
], dma
),
1228 MWL8K_RX_MAXSZ
, PCI_DMA_FROMDEVICE
);
1229 dma_unmap_addr_set(&rxq
->buf
[rxq
->head
], dma
, 0);
1232 if (rxq
->head
== MWL8K_RX_DESCS
)
1237 wh
= &((struct mwl8k_dma_data
*)skb
->data
)->wh
;
1240 * Check for a pending join operation. Save a
1241 * copy of the beacon and schedule a tasklet to
1242 * send a FINALIZE_JOIN command to the firmware.
1244 if (mwl8k_capture_bssid(priv
, (void *)skb
->data
))
1245 mwl8k_save_beacon(hw
, skb
);
1247 if (ieee80211_has_protected(wh
->frame_control
)) {
1249 /* Check if hw crypto has been enabled for
1250 * this bss. If yes, set the status flags
1253 mwl8k_vif
= mwl8k_find_vif_bss(&priv
->vif_list
,
1256 if (mwl8k_vif
!= NULL
&&
1257 mwl8k_vif
->is_hw_crypto_enabled
== true) {
1259 * When MMIC ERROR is encountered
1260 * by the firmware, payload is
1261 * dropped and only 32 bytes of
1262 * mwl8k Firmware header is sent
1265 * We need to add four bytes of
1266 * key information. In it
1267 * MAC80211 expects keyidx set to
1268 * 0 for triggering Counter
1269 * Measure of MMIC failure.
1271 if (status
.flag
& RX_FLAG_MMIC_ERROR
) {
1272 struct mwl8k_dma_data
*tr
;
1273 tr
= (struct mwl8k_dma_data
*)skb
->data
;
1274 memset((void *)&(tr
->data
), 0, 4);
1278 if (!ieee80211_is_auth(wh
->frame_control
))
1279 status
.flag
|= RX_FLAG_IV_STRIPPED
|
1281 RX_FLAG_MMIC_STRIPPED
;
1285 skb_put(skb
, pkt_len
);
1286 mwl8k_remove_dma_header(skb
, qos
);
1287 memcpy(IEEE80211_SKB_RXCB(skb
), &status
, sizeof(status
));
1288 ieee80211_rx_irqsafe(hw
, skb
);
1298 * Packet transmission.
1301 #define MWL8K_TXD_STATUS_OK 0x00000001
1302 #define MWL8K_TXD_STATUS_OK_RETRY 0x00000002
1303 #define MWL8K_TXD_STATUS_OK_MORE_RETRY 0x00000004
1304 #define MWL8K_TXD_STATUS_MULTICAST_TX 0x00000008
1305 #define MWL8K_TXD_STATUS_FW_OWNED 0x80000000
1307 #define MWL8K_QOS_QLEN_UNSPEC 0xff00
1308 #define MWL8K_QOS_ACK_POLICY_MASK 0x0060
1309 #define MWL8K_QOS_ACK_POLICY_NORMAL 0x0000
1310 #define MWL8K_QOS_ACK_POLICY_BLOCKACK 0x0060
1311 #define MWL8K_QOS_EOSP 0x0010
1313 struct mwl8k_tx_desc
{
1318 __le32 pkt_phys_addr
;
1320 __u8 dest_MAC_addr
[ETH_ALEN
];
1321 __le32 next_txd_phys_addr
;
1328 #define MWL8K_TX_DESCS 128
1330 static int mwl8k_txq_init(struct ieee80211_hw
*hw
, int index
)
1332 struct mwl8k_priv
*priv
= hw
->priv
;
1333 struct mwl8k_tx_queue
*txq
= priv
->txq
+ index
;
1341 size
= MWL8K_TX_DESCS
* sizeof(struct mwl8k_tx_desc
);
1343 txq
->txd
= pci_alloc_consistent(priv
->pdev
, size
, &txq
->txd_dma
);
1344 if (txq
->txd
== NULL
) {
1345 wiphy_err(hw
->wiphy
, "failed to alloc TX descriptors\n");
1348 memset(txq
->txd
, 0, size
);
1350 txq
->skb
= kcalloc(MWL8K_TX_DESCS
, sizeof(*txq
->skb
), GFP_KERNEL
);
1351 if (txq
->skb
== NULL
) {
1352 wiphy_err(hw
->wiphy
, "failed to alloc TX skbuff list\n");
1353 pci_free_consistent(priv
->pdev
, size
, txq
->txd
, txq
->txd_dma
);
1357 for (i
= 0; i
< MWL8K_TX_DESCS
; i
++) {
1358 struct mwl8k_tx_desc
*tx_desc
;
1361 tx_desc
= txq
->txd
+ i
;
1362 nexti
= (i
+ 1) % MWL8K_TX_DESCS
;
1364 tx_desc
->status
= 0;
1365 tx_desc
->next_txd_phys_addr
=
1366 cpu_to_le32(txq
->txd_dma
+ nexti
* sizeof(*tx_desc
));
1372 static inline void mwl8k_tx_start(struct mwl8k_priv
*priv
)
1374 iowrite32(MWL8K_H2A_INT_PPA_READY
,
1375 priv
->regs
+ MWL8K_HIU_H2A_INTERRUPT_EVENTS
);
1376 iowrite32(MWL8K_H2A_INT_DUMMY
,
1377 priv
->regs
+ MWL8K_HIU_H2A_INTERRUPT_EVENTS
);
1378 ioread32(priv
->regs
+ MWL8K_HIU_INT_CODE
);
1381 static void mwl8k_dump_tx_rings(struct ieee80211_hw
*hw
)
1383 struct mwl8k_priv
*priv
= hw
->priv
;
1386 for (i
= 0; i
< MWL8K_TX_QUEUES
; i
++) {
1387 struct mwl8k_tx_queue
*txq
= priv
->txq
+ i
;
1393 for (desc
= 0; desc
< MWL8K_TX_DESCS
; desc
++) {
1394 struct mwl8k_tx_desc
*tx_desc
= txq
->txd
+ desc
;
1397 status
= le32_to_cpu(tx_desc
->status
);
1398 if (status
& MWL8K_TXD_STATUS_FW_OWNED
)
1403 if (tx_desc
->pkt_len
== 0)
1407 wiphy_err(hw
->wiphy
,
1408 "txq[%d] len=%d head=%d tail=%d "
1409 "fw_owned=%d drv_owned=%d unused=%d\n",
1411 txq
->len
, txq
->head
, txq
->tail
,
1412 fw_owned
, drv_owned
, unused
);
1417 * Must be called with priv->fw_mutex held and tx queues stopped.
1419 #define MWL8K_TX_WAIT_TIMEOUT_MS 5000
1421 static int mwl8k_tx_wait_empty(struct ieee80211_hw
*hw
)
1423 struct mwl8k_priv
*priv
= hw
->priv
;
1424 DECLARE_COMPLETION_ONSTACK(tx_wait
);
1431 * The TX queues are stopped at this point, so this test
1432 * doesn't need to take ->tx_lock.
1434 if (!priv
->pending_tx_pkts
)
1440 spin_lock_bh(&priv
->tx_lock
);
1441 priv
->tx_wait
= &tx_wait
;
1444 unsigned long timeout
;
1446 oldcount
= priv
->pending_tx_pkts
;
1448 spin_unlock_bh(&priv
->tx_lock
);
1449 timeout
= wait_for_completion_timeout(&tx_wait
,
1450 msecs_to_jiffies(MWL8K_TX_WAIT_TIMEOUT_MS
));
1451 spin_lock_bh(&priv
->tx_lock
);
1454 WARN_ON(priv
->pending_tx_pkts
);
1456 wiphy_notice(hw
->wiphy
, "tx rings drained\n");
1461 if (priv
->pending_tx_pkts
< oldcount
) {
1462 wiphy_notice(hw
->wiphy
,
1463 "waiting for tx rings to drain (%d -> %d pkts)\n",
1464 oldcount
, priv
->pending_tx_pkts
);
1469 priv
->tx_wait
= NULL
;
1471 wiphy_err(hw
->wiphy
, "tx rings stuck for %d ms\n",
1472 MWL8K_TX_WAIT_TIMEOUT_MS
);
1473 mwl8k_dump_tx_rings(hw
);
1477 spin_unlock_bh(&priv
->tx_lock
);
1482 #define MWL8K_TXD_SUCCESS(status) \
1483 ((status) & (MWL8K_TXD_STATUS_OK | \
1484 MWL8K_TXD_STATUS_OK_RETRY | \
1485 MWL8K_TXD_STATUS_OK_MORE_RETRY))
1488 mwl8k_txq_reclaim(struct ieee80211_hw
*hw
, int index
, int limit
, int force
)
1490 struct mwl8k_priv
*priv
= hw
->priv
;
1491 struct mwl8k_tx_queue
*txq
= priv
->txq
+ index
;
1495 while (txq
->len
> 0 && limit
--) {
1497 struct mwl8k_tx_desc
*tx_desc
;
1500 struct sk_buff
*skb
;
1501 struct ieee80211_tx_info
*info
;
1505 tx_desc
= txq
->txd
+ tx
;
1507 status
= le32_to_cpu(tx_desc
->status
);
1509 if (status
& MWL8K_TXD_STATUS_FW_OWNED
) {
1513 ~cpu_to_le32(MWL8K_TXD_STATUS_FW_OWNED
);
1516 txq
->head
= (tx
+ 1) % MWL8K_TX_DESCS
;
1517 BUG_ON(txq
->len
== 0);
1519 priv
->pending_tx_pkts
--;
1521 addr
= le32_to_cpu(tx_desc
->pkt_phys_addr
);
1522 size
= le16_to_cpu(tx_desc
->pkt_len
);
1524 txq
->skb
[tx
] = NULL
;
1526 BUG_ON(skb
== NULL
);
1527 pci_unmap_single(priv
->pdev
, addr
, size
, PCI_DMA_TODEVICE
);
1529 mwl8k_remove_dma_header(skb
, tx_desc
->qos_control
);
1531 /* Mark descriptor as unused */
1532 tx_desc
->pkt_phys_addr
= 0;
1533 tx_desc
->pkt_len
= 0;
1535 info
= IEEE80211_SKB_CB(skb
);
1536 ieee80211_tx_info_clear_status(info
);
1538 /* Rate control is happening in the firmware.
1539 * Ensure no tx rate is being reported.
1541 info
->status
.rates
[0].idx
= -1;
1542 info
->status
.rates
[0].count
= 1;
1544 if (MWL8K_TXD_SUCCESS(status
))
1545 info
->flags
|= IEEE80211_TX_STAT_ACK
;
1547 ieee80211_tx_status_irqsafe(hw
, skb
);
1552 if (processed
&& priv
->radio_on
&& !mutex_is_locked(&priv
->fw_mutex
))
1553 ieee80211_wake_queue(hw
, index
);
1558 /* must be called only when the card's transmit is completely halted */
1559 static void mwl8k_txq_deinit(struct ieee80211_hw
*hw
, int index
)
1561 struct mwl8k_priv
*priv
= hw
->priv
;
1562 struct mwl8k_tx_queue
*txq
= priv
->txq
+ index
;
1564 mwl8k_txq_reclaim(hw
, index
, INT_MAX
, 1);
1569 pci_free_consistent(priv
->pdev
,
1570 MWL8K_TX_DESCS
* sizeof(struct mwl8k_tx_desc
),
1571 txq
->txd
, txq
->txd_dma
);
1576 mwl8k_txq_xmit(struct ieee80211_hw
*hw
, int index
, struct sk_buff
*skb
)
1578 struct mwl8k_priv
*priv
= hw
->priv
;
1579 struct ieee80211_tx_info
*tx_info
;
1580 struct mwl8k_vif
*mwl8k_vif
;
1581 struct ieee80211_hdr
*wh
;
1582 struct mwl8k_tx_queue
*txq
;
1583 struct mwl8k_tx_desc
*tx
;
1589 wh
= (struct ieee80211_hdr
*)skb
->data
;
1590 if (ieee80211_is_data_qos(wh
->frame_control
))
1591 qos
= le16_to_cpu(*((__le16
*)ieee80211_get_qos_ctl(wh
)));
1596 mwl8k_encapsulate_tx_frame(skb
);
1598 mwl8k_add_dma_header(skb
, 0);
1600 wh
= &((struct mwl8k_dma_data
*)skb
->data
)->wh
;
1602 tx_info
= IEEE80211_SKB_CB(skb
);
1603 mwl8k_vif
= MWL8K_VIF(tx_info
->control
.vif
);
1605 if (tx_info
->flags
& IEEE80211_TX_CTL_ASSIGN_SEQ
) {
1606 wh
->seq_ctrl
&= cpu_to_le16(IEEE80211_SCTL_FRAG
);
1607 wh
->seq_ctrl
|= cpu_to_le16(mwl8k_vif
->seqno
);
1608 mwl8k_vif
->seqno
+= 0x10;
1611 /* Setup firmware control bit fields for each frame type. */
1614 if (ieee80211_is_mgmt(wh
->frame_control
) ||
1615 ieee80211_is_ctl(wh
->frame_control
)) {
1617 qos
|= MWL8K_QOS_QLEN_UNSPEC
| MWL8K_QOS_EOSP
;
1618 } else if (ieee80211_is_data(wh
->frame_control
)) {
1620 if (is_multicast_ether_addr(wh
->addr1
))
1621 txstatus
|= MWL8K_TXD_STATUS_MULTICAST_TX
;
1623 qos
&= ~MWL8K_QOS_ACK_POLICY_MASK
;
1624 if (tx_info
->flags
& IEEE80211_TX_CTL_AMPDU
)
1625 qos
|= MWL8K_QOS_ACK_POLICY_BLOCKACK
;
1627 qos
|= MWL8K_QOS_ACK_POLICY_NORMAL
;
1630 dma
= pci_map_single(priv
->pdev
, skb
->data
,
1631 skb
->len
, PCI_DMA_TODEVICE
);
1633 if (pci_dma_mapping_error(priv
->pdev
, dma
)) {
1634 wiphy_debug(hw
->wiphy
,
1635 "failed to dma map skb, dropping TX frame.\n");
1640 spin_lock_bh(&priv
->tx_lock
);
1642 txq
= priv
->txq
+ index
;
1644 BUG_ON(txq
->skb
[txq
->tail
] != NULL
);
1645 txq
->skb
[txq
->tail
] = skb
;
1647 tx
= txq
->txd
+ txq
->tail
;
1648 tx
->data_rate
= txdatarate
;
1649 tx
->tx_priority
= index
;
1650 tx
->qos_control
= cpu_to_le16(qos
);
1651 tx
->pkt_phys_addr
= cpu_to_le32(dma
);
1652 tx
->pkt_len
= cpu_to_le16(skb
->len
);
1654 if (!priv
->ap_fw
&& tx_info
->control
.sta
!= NULL
)
1655 tx
->peer_id
= MWL8K_STA(tx_info
->control
.sta
)->peer_id
;
1659 tx
->status
= cpu_to_le32(MWL8K_TXD_STATUS_FW_OWNED
| txstatus
);
1662 priv
->pending_tx_pkts
++;
1665 if (txq
->tail
== MWL8K_TX_DESCS
)
1668 if (txq
->head
== txq
->tail
)
1669 ieee80211_stop_queue(hw
, index
);
1671 mwl8k_tx_start(priv
);
1673 spin_unlock_bh(&priv
->tx_lock
);
1680 * We have the following requirements for issuing firmware commands:
1681 * - Some commands require that the packet transmit path is idle when
1682 * the command is issued. (For simplicity, we'll just quiesce the
1683 * transmit path for every command.)
1684 * - There are certain sequences of commands that need to be issued to
1685 * the hardware sequentially, with no other intervening commands.
1687 * This leads to an implementation of a "firmware lock" as a mutex that
1688 * can be taken recursively, and which is taken by both the low-level
1689 * command submission function (mwl8k_post_cmd) as well as any users of
1690 * that function that require issuing of an atomic sequence of commands,
1691 * and quiesces the transmit path whenever it's taken.
1693 static int mwl8k_fw_lock(struct ieee80211_hw
*hw
)
1695 struct mwl8k_priv
*priv
= hw
->priv
;
1697 if (priv
->fw_mutex_owner
!= current
) {
1700 mutex_lock(&priv
->fw_mutex
);
1701 ieee80211_stop_queues(hw
);
1703 rc
= mwl8k_tx_wait_empty(hw
);
1705 ieee80211_wake_queues(hw
);
1706 mutex_unlock(&priv
->fw_mutex
);
1711 priv
->fw_mutex_owner
= current
;
1714 priv
->fw_mutex_depth
++;
1719 static void mwl8k_fw_unlock(struct ieee80211_hw
*hw
)
1721 struct mwl8k_priv
*priv
= hw
->priv
;
1723 if (!--priv
->fw_mutex_depth
) {
1724 ieee80211_wake_queues(hw
);
1725 priv
->fw_mutex_owner
= NULL
;
1726 mutex_unlock(&priv
->fw_mutex
);
1732 * Command processing.
1735 /* Timeout firmware commands after 10s */
1736 #define MWL8K_CMD_TIMEOUT_MS 10000
1738 static int mwl8k_post_cmd(struct ieee80211_hw
*hw
, struct mwl8k_cmd_pkt
*cmd
)
1740 DECLARE_COMPLETION_ONSTACK(cmd_wait
);
1741 struct mwl8k_priv
*priv
= hw
->priv
;
1742 void __iomem
*regs
= priv
->regs
;
1743 dma_addr_t dma_addr
;
1744 unsigned int dma_size
;
1746 unsigned long timeout
= 0;
1749 cmd
->result
= (__force __le16
) 0xffff;
1750 dma_size
= le16_to_cpu(cmd
->length
);
1751 dma_addr
= pci_map_single(priv
->pdev
, cmd
, dma_size
,
1752 PCI_DMA_BIDIRECTIONAL
);
1753 if (pci_dma_mapping_error(priv
->pdev
, dma_addr
))
1756 rc
= mwl8k_fw_lock(hw
);
1758 pci_unmap_single(priv
->pdev
, dma_addr
, dma_size
,
1759 PCI_DMA_BIDIRECTIONAL
);
1763 priv
->hostcmd_wait
= &cmd_wait
;
1764 iowrite32(dma_addr
, regs
+ MWL8K_HIU_GEN_PTR
);
1765 iowrite32(MWL8K_H2A_INT_DOORBELL
,
1766 regs
+ MWL8K_HIU_H2A_INTERRUPT_EVENTS
);
1767 iowrite32(MWL8K_H2A_INT_DUMMY
,
1768 regs
+ MWL8K_HIU_H2A_INTERRUPT_EVENTS
);
1770 timeout
= wait_for_completion_timeout(&cmd_wait
,
1771 msecs_to_jiffies(MWL8K_CMD_TIMEOUT_MS
));
1773 priv
->hostcmd_wait
= NULL
;
1775 mwl8k_fw_unlock(hw
);
1777 pci_unmap_single(priv
->pdev
, dma_addr
, dma_size
,
1778 PCI_DMA_BIDIRECTIONAL
);
1781 wiphy_err(hw
->wiphy
, "Command %s timeout after %u ms\n",
1782 mwl8k_cmd_name(cmd
->code
, buf
, sizeof(buf
)),
1783 MWL8K_CMD_TIMEOUT_MS
);
1788 ms
= MWL8K_CMD_TIMEOUT_MS
- jiffies_to_msecs(timeout
);
1790 rc
= cmd
->result
? -EINVAL
: 0;
1792 wiphy_err(hw
->wiphy
, "Command %s error 0x%x\n",
1793 mwl8k_cmd_name(cmd
->code
, buf
, sizeof(buf
)),
1794 le16_to_cpu(cmd
->result
));
1796 wiphy_notice(hw
->wiphy
, "Command %s took %d ms\n",
1797 mwl8k_cmd_name(cmd
->code
,
1805 static int mwl8k_post_pervif_cmd(struct ieee80211_hw
*hw
,
1806 struct ieee80211_vif
*vif
,
1807 struct mwl8k_cmd_pkt
*cmd
)
1810 cmd
->macid
= MWL8K_VIF(vif
)->macid
;
1811 return mwl8k_post_cmd(hw
, cmd
);
1815 * Setup code shared between STA and AP firmware images.
1817 static void mwl8k_setup_2ghz_band(struct ieee80211_hw
*hw
)
1819 struct mwl8k_priv
*priv
= hw
->priv
;
1821 BUILD_BUG_ON(sizeof(priv
->channels_24
) != sizeof(mwl8k_channels_24
));
1822 memcpy(priv
->channels_24
, mwl8k_channels_24
, sizeof(mwl8k_channels_24
));
1824 BUILD_BUG_ON(sizeof(priv
->rates_24
) != sizeof(mwl8k_rates_24
));
1825 memcpy(priv
->rates_24
, mwl8k_rates_24
, sizeof(mwl8k_rates_24
));
1827 priv
->band_24
.band
= IEEE80211_BAND_2GHZ
;
1828 priv
->band_24
.channels
= priv
->channels_24
;
1829 priv
->band_24
.n_channels
= ARRAY_SIZE(mwl8k_channels_24
);
1830 priv
->band_24
.bitrates
= priv
->rates_24
;
1831 priv
->band_24
.n_bitrates
= ARRAY_SIZE(mwl8k_rates_24
);
1833 hw
->wiphy
->bands
[IEEE80211_BAND_2GHZ
] = &priv
->band_24
;
1836 static void mwl8k_setup_5ghz_band(struct ieee80211_hw
*hw
)
1838 struct mwl8k_priv
*priv
= hw
->priv
;
1840 BUILD_BUG_ON(sizeof(priv
->channels_50
) != sizeof(mwl8k_channels_50
));
1841 memcpy(priv
->channels_50
, mwl8k_channels_50
, sizeof(mwl8k_channels_50
));
1843 BUILD_BUG_ON(sizeof(priv
->rates_50
) != sizeof(mwl8k_rates_50
));
1844 memcpy(priv
->rates_50
, mwl8k_rates_50
, sizeof(mwl8k_rates_50
));
1846 priv
->band_50
.band
= IEEE80211_BAND_5GHZ
;
1847 priv
->band_50
.channels
= priv
->channels_50
;
1848 priv
->band_50
.n_channels
= ARRAY_SIZE(mwl8k_channels_50
);
1849 priv
->band_50
.bitrates
= priv
->rates_50
;
1850 priv
->band_50
.n_bitrates
= ARRAY_SIZE(mwl8k_rates_50
);
1852 hw
->wiphy
->bands
[IEEE80211_BAND_5GHZ
] = &priv
->band_50
;
1856 * CMD_GET_HW_SPEC (STA version).
1858 struct mwl8k_cmd_get_hw_spec_sta
{
1859 struct mwl8k_cmd_pkt header
;
1861 __u8 host_interface
;
1863 __u8 perm_addr
[ETH_ALEN
];
1868 __u8 mcs_bitmap
[16];
1869 __le32 rx_queue_ptr
;
1870 __le32 num_tx_queues
;
1871 __le32 tx_queue_ptrs
[MWL8K_TX_QUEUES
];
1873 __le32 num_tx_desc_per_queue
;
1877 #define MWL8K_CAP_MAX_AMSDU 0x20000000
1878 #define MWL8K_CAP_GREENFIELD 0x08000000
1879 #define MWL8K_CAP_AMPDU 0x04000000
1880 #define MWL8K_CAP_RX_STBC 0x01000000
1881 #define MWL8K_CAP_TX_STBC 0x00800000
1882 #define MWL8K_CAP_SHORTGI_40MHZ 0x00400000
1883 #define MWL8K_CAP_SHORTGI_20MHZ 0x00200000
1884 #define MWL8K_CAP_RX_ANTENNA_MASK 0x000e0000
1885 #define MWL8K_CAP_TX_ANTENNA_MASK 0x0001c000
1886 #define MWL8K_CAP_DELAY_BA 0x00003000
1887 #define MWL8K_CAP_MIMO 0x00000200
1888 #define MWL8K_CAP_40MHZ 0x00000100
1889 #define MWL8K_CAP_BAND_MASK 0x00000007
1890 #define MWL8K_CAP_5GHZ 0x00000004
1891 #define MWL8K_CAP_2GHZ4 0x00000001
1894 mwl8k_set_ht_caps(struct ieee80211_hw
*hw
,
1895 struct ieee80211_supported_band
*band
, u32 cap
)
1900 band
->ht_cap
.ht_supported
= 1;
1902 if (cap
& MWL8K_CAP_MAX_AMSDU
)
1903 band
->ht_cap
.cap
|= IEEE80211_HT_CAP_MAX_AMSDU
;
1904 if (cap
& MWL8K_CAP_GREENFIELD
)
1905 band
->ht_cap
.cap
|= IEEE80211_HT_CAP_GRN_FLD
;
1906 if (cap
& MWL8K_CAP_AMPDU
) {
1907 hw
->flags
|= IEEE80211_HW_AMPDU_AGGREGATION
;
1908 band
->ht_cap
.ampdu_factor
= IEEE80211_HT_MAX_AMPDU_64K
;
1909 band
->ht_cap
.ampdu_density
= IEEE80211_HT_MPDU_DENSITY_NONE
;
1911 if (cap
& MWL8K_CAP_RX_STBC
)
1912 band
->ht_cap
.cap
|= IEEE80211_HT_CAP_RX_STBC
;
1913 if (cap
& MWL8K_CAP_TX_STBC
)
1914 band
->ht_cap
.cap
|= IEEE80211_HT_CAP_TX_STBC
;
1915 if (cap
& MWL8K_CAP_SHORTGI_40MHZ
)
1916 band
->ht_cap
.cap
|= IEEE80211_HT_CAP_SGI_40
;
1917 if (cap
& MWL8K_CAP_SHORTGI_20MHZ
)
1918 band
->ht_cap
.cap
|= IEEE80211_HT_CAP_SGI_20
;
1919 if (cap
& MWL8K_CAP_DELAY_BA
)
1920 band
->ht_cap
.cap
|= IEEE80211_HT_CAP_DELAY_BA
;
1921 if (cap
& MWL8K_CAP_40MHZ
)
1922 band
->ht_cap
.cap
|= IEEE80211_HT_CAP_SUP_WIDTH_20_40
;
1924 rx_streams
= hweight32(cap
& MWL8K_CAP_RX_ANTENNA_MASK
);
1925 tx_streams
= hweight32(cap
& MWL8K_CAP_TX_ANTENNA_MASK
);
1927 band
->ht_cap
.mcs
.rx_mask
[0] = 0xff;
1928 if (rx_streams
>= 2)
1929 band
->ht_cap
.mcs
.rx_mask
[1] = 0xff;
1930 if (rx_streams
>= 3)
1931 band
->ht_cap
.mcs
.rx_mask
[2] = 0xff;
1932 band
->ht_cap
.mcs
.rx_mask
[4] = 0x01;
1933 band
->ht_cap
.mcs
.tx_params
= IEEE80211_HT_MCS_TX_DEFINED
;
1935 if (rx_streams
!= tx_streams
) {
1936 band
->ht_cap
.mcs
.tx_params
|= IEEE80211_HT_MCS_TX_RX_DIFF
;
1937 band
->ht_cap
.mcs
.tx_params
|= (tx_streams
- 1) <<
1938 IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT
;
1943 mwl8k_set_caps(struct ieee80211_hw
*hw
, u32 caps
)
1945 struct mwl8k_priv
*priv
= hw
->priv
;
1947 if ((caps
& MWL8K_CAP_2GHZ4
) || !(caps
& MWL8K_CAP_BAND_MASK
)) {
1948 mwl8k_setup_2ghz_band(hw
);
1949 if (caps
& MWL8K_CAP_MIMO
)
1950 mwl8k_set_ht_caps(hw
, &priv
->band_24
, caps
);
1953 if (caps
& MWL8K_CAP_5GHZ
) {
1954 mwl8k_setup_5ghz_band(hw
);
1955 if (caps
& MWL8K_CAP_MIMO
)
1956 mwl8k_set_ht_caps(hw
, &priv
->band_50
, caps
);
1960 static int mwl8k_cmd_get_hw_spec_sta(struct ieee80211_hw
*hw
)
1962 struct mwl8k_priv
*priv
= hw
->priv
;
1963 struct mwl8k_cmd_get_hw_spec_sta
*cmd
;
1967 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
1971 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_GET_HW_SPEC
);
1972 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
1974 memset(cmd
->perm_addr
, 0xff, sizeof(cmd
->perm_addr
));
1975 cmd
->ps_cookie
= cpu_to_le32(priv
->cookie_dma
);
1976 cmd
->rx_queue_ptr
= cpu_to_le32(priv
->rxq
[0].rxd_dma
);
1977 cmd
->num_tx_queues
= cpu_to_le32(MWL8K_TX_QUEUES
);
1978 for (i
= 0; i
< MWL8K_TX_QUEUES
; i
++)
1979 cmd
->tx_queue_ptrs
[i
] = cpu_to_le32(priv
->txq
[i
].txd_dma
);
1980 cmd
->num_tx_desc_per_queue
= cpu_to_le32(MWL8K_TX_DESCS
);
1981 cmd
->total_rxd
= cpu_to_le32(MWL8K_RX_DESCS
);
1983 rc
= mwl8k_post_cmd(hw
, &cmd
->header
);
1986 SET_IEEE80211_PERM_ADDR(hw
, cmd
->perm_addr
);
1987 priv
->num_mcaddrs
= le16_to_cpu(cmd
->num_mcaddrs
);
1988 priv
->fw_rev
= le32_to_cpu(cmd
->fw_rev
);
1989 priv
->hw_rev
= cmd
->hw_rev
;
1990 mwl8k_set_caps(hw
, le32_to_cpu(cmd
->caps
));
1991 priv
->ap_macids_supported
= 0x00000000;
1992 priv
->sta_macids_supported
= 0x00000001;
2000 * CMD_GET_HW_SPEC (AP version).
2002 struct mwl8k_cmd_get_hw_spec_ap
{
2003 struct mwl8k_cmd_pkt header
;
2005 __u8 host_interface
;
2008 __u8 perm_addr
[ETH_ALEN
];
2019 __le32 fw_api_version
;
2022 static int mwl8k_cmd_get_hw_spec_ap(struct ieee80211_hw
*hw
)
2024 struct mwl8k_priv
*priv
= hw
->priv
;
2025 struct mwl8k_cmd_get_hw_spec_ap
*cmd
;
2029 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
2033 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_GET_HW_SPEC
);
2034 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
2036 memset(cmd
->perm_addr
, 0xff, sizeof(cmd
->perm_addr
));
2037 cmd
->ps_cookie
= cpu_to_le32(priv
->cookie_dma
);
2039 rc
= mwl8k_post_cmd(hw
, &cmd
->header
);
2044 api_version
= le32_to_cpu(cmd
->fw_api_version
);
2045 if (priv
->device_info
->fw_api_ap
!= api_version
) {
2046 printk(KERN_ERR
"%s: Unsupported fw API version for %s."
2047 " Expected %d got %d.\n", MWL8K_NAME
,
2048 priv
->device_info
->part_name
,
2049 priv
->device_info
->fw_api_ap
,
2054 SET_IEEE80211_PERM_ADDR(hw
, cmd
->perm_addr
);
2055 priv
->num_mcaddrs
= le16_to_cpu(cmd
->num_mcaddrs
);
2056 priv
->fw_rev
= le32_to_cpu(cmd
->fw_rev
);
2057 priv
->hw_rev
= cmd
->hw_rev
;
2058 mwl8k_setup_2ghz_band(hw
);
2059 priv
->ap_macids_supported
= 0x000000ff;
2060 priv
->sta_macids_supported
= 0x00000000;
2062 off
= le32_to_cpu(cmd
->wcbbase0
) & 0xffff;
2063 iowrite32(priv
->txq
[0].txd_dma
, priv
->sram
+ off
);
2065 off
= le32_to_cpu(cmd
->rxwrptr
) & 0xffff;
2066 iowrite32(priv
->rxq
[0].rxd_dma
, priv
->sram
+ off
);
2068 off
= le32_to_cpu(cmd
->rxrdptr
) & 0xffff;
2069 iowrite32(priv
->rxq
[0].rxd_dma
, priv
->sram
+ off
);
2071 off
= le32_to_cpu(cmd
->wcbbase1
) & 0xffff;
2072 iowrite32(priv
->txq
[1].txd_dma
, priv
->sram
+ off
);
2074 off
= le32_to_cpu(cmd
->wcbbase2
) & 0xffff;
2075 iowrite32(priv
->txq
[2].txd_dma
, priv
->sram
+ off
);
2077 off
= le32_to_cpu(cmd
->wcbbase3
) & 0xffff;
2078 iowrite32(priv
->txq
[3].txd_dma
, priv
->sram
+ off
);
2089 struct mwl8k_cmd_set_hw_spec
{
2090 struct mwl8k_cmd_pkt header
;
2092 __u8 host_interface
;
2094 __u8 perm_addr
[ETH_ALEN
];
2099 __le32 rx_queue_ptr
;
2100 __le32 num_tx_queues
;
2101 __le32 tx_queue_ptrs
[MWL8K_TX_QUEUES
];
2103 __le32 num_tx_desc_per_queue
;
2107 #define MWL8K_SET_HW_SPEC_FLAG_HOST_DECR_MGMT 0x00000080
2108 #define MWL8K_SET_HW_SPEC_FLAG_HOSTFORM_PROBERESP 0x00000020
2109 #define MWL8K_SET_HW_SPEC_FLAG_HOSTFORM_BEACON 0x00000010
2111 static int mwl8k_cmd_set_hw_spec(struct ieee80211_hw
*hw
)
2113 struct mwl8k_priv
*priv
= hw
->priv
;
2114 struct mwl8k_cmd_set_hw_spec
*cmd
;
2118 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
2122 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_SET_HW_SPEC
);
2123 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
2125 cmd
->ps_cookie
= cpu_to_le32(priv
->cookie_dma
);
2126 cmd
->rx_queue_ptr
= cpu_to_le32(priv
->rxq
[0].rxd_dma
);
2127 cmd
->num_tx_queues
= cpu_to_le32(MWL8K_TX_QUEUES
);
2130 * Mac80211 stack has Q0 as highest priority and Q3 as lowest in
2131 * that order. Firmware has Q3 as highest priority and Q0 as lowest
2132 * in that order. Map Q3 of mac80211 to Q0 of firmware so that the
2133 * priority is interpreted the right way in firmware.
2135 for (i
= 0; i
< MWL8K_TX_QUEUES
; i
++) {
2136 int j
= MWL8K_TX_QUEUES
- 1 - i
;
2137 cmd
->tx_queue_ptrs
[i
] = cpu_to_le32(priv
->txq
[j
].txd_dma
);
2140 cmd
->flags
= cpu_to_le32(MWL8K_SET_HW_SPEC_FLAG_HOST_DECR_MGMT
|
2141 MWL8K_SET_HW_SPEC_FLAG_HOSTFORM_PROBERESP
|
2142 MWL8K_SET_HW_SPEC_FLAG_HOSTFORM_BEACON
);
2143 cmd
->num_tx_desc_per_queue
= cpu_to_le32(MWL8K_TX_DESCS
);
2144 cmd
->total_rxd
= cpu_to_le32(MWL8K_RX_DESCS
);
2146 rc
= mwl8k_post_cmd(hw
, &cmd
->header
);
2153 * CMD_MAC_MULTICAST_ADR.
2155 struct mwl8k_cmd_mac_multicast_adr
{
2156 struct mwl8k_cmd_pkt header
;
2159 __u8 addr
[0][ETH_ALEN
];
2162 #define MWL8K_ENABLE_RX_DIRECTED 0x0001
2163 #define MWL8K_ENABLE_RX_MULTICAST 0x0002
2164 #define MWL8K_ENABLE_RX_ALL_MULTICAST 0x0004
2165 #define MWL8K_ENABLE_RX_BROADCAST 0x0008
2167 static struct mwl8k_cmd_pkt
*
2168 __mwl8k_cmd_mac_multicast_adr(struct ieee80211_hw
*hw
, int allmulti
,
2169 struct netdev_hw_addr_list
*mc_list
)
2171 struct mwl8k_priv
*priv
= hw
->priv
;
2172 struct mwl8k_cmd_mac_multicast_adr
*cmd
;
2177 mc_count
= netdev_hw_addr_list_count(mc_list
);
2179 if (allmulti
|| mc_count
> priv
->num_mcaddrs
) {
2184 size
= sizeof(*cmd
) + mc_count
* ETH_ALEN
;
2186 cmd
= kzalloc(size
, GFP_ATOMIC
);
2190 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_MAC_MULTICAST_ADR
);
2191 cmd
->header
.length
= cpu_to_le16(size
);
2192 cmd
->action
= cpu_to_le16(MWL8K_ENABLE_RX_DIRECTED
|
2193 MWL8K_ENABLE_RX_BROADCAST
);
2196 cmd
->action
|= cpu_to_le16(MWL8K_ENABLE_RX_ALL_MULTICAST
);
2197 } else if (mc_count
) {
2198 struct netdev_hw_addr
*ha
;
2201 cmd
->action
|= cpu_to_le16(MWL8K_ENABLE_RX_MULTICAST
);
2202 cmd
->numaddr
= cpu_to_le16(mc_count
);
2203 netdev_hw_addr_list_for_each(ha
, mc_list
) {
2204 memcpy(cmd
->addr
[i
], ha
->addr
, ETH_ALEN
);
2208 return &cmd
->header
;
2214 struct mwl8k_cmd_get_stat
{
2215 struct mwl8k_cmd_pkt header
;
2219 #define MWL8K_STAT_ACK_FAILURE 9
2220 #define MWL8K_STAT_RTS_FAILURE 12
2221 #define MWL8K_STAT_FCS_ERROR 24
2222 #define MWL8K_STAT_RTS_SUCCESS 11
2224 static int mwl8k_cmd_get_stat(struct ieee80211_hw
*hw
,
2225 struct ieee80211_low_level_stats
*stats
)
2227 struct mwl8k_cmd_get_stat
*cmd
;
2230 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
2234 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_GET_STAT
);
2235 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
2237 rc
= mwl8k_post_cmd(hw
, &cmd
->header
);
2239 stats
->dot11ACKFailureCount
=
2240 le32_to_cpu(cmd
->stats
[MWL8K_STAT_ACK_FAILURE
]);
2241 stats
->dot11RTSFailureCount
=
2242 le32_to_cpu(cmd
->stats
[MWL8K_STAT_RTS_FAILURE
]);
2243 stats
->dot11FCSErrorCount
=
2244 le32_to_cpu(cmd
->stats
[MWL8K_STAT_FCS_ERROR
]);
2245 stats
->dot11RTSSuccessCount
=
2246 le32_to_cpu(cmd
->stats
[MWL8K_STAT_RTS_SUCCESS
]);
2254 * CMD_RADIO_CONTROL.
2256 struct mwl8k_cmd_radio_control
{
2257 struct mwl8k_cmd_pkt header
;
2264 mwl8k_cmd_radio_control(struct ieee80211_hw
*hw
, bool enable
, bool force
)
2266 struct mwl8k_priv
*priv
= hw
->priv
;
2267 struct mwl8k_cmd_radio_control
*cmd
;
2270 if (enable
== priv
->radio_on
&& !force
)
2273 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
2277 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_RADIO_CONTROL
);
2278 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
2279 cmd
->action
= cpu_to_le16(MWL8K_CMD_SET
);
2280 cmd
->control
= cpu_to_le16(priv
->radio_short_preamble
? 3 : 1);
2281 cmd
->radio_on
= cpu_to_le16(enable
? 0x0001 : 0x0000);
2283 rc
= mwl8k_post_cmd(hw
, &cmd
->header
);
2287 priv
->radio_on
= enable
;
2292 static int mwl8k_cmd_radio_disable(struct ieee80211_hw
*hw
)
2294 return mwl8k_cmd_radio_control(hw
, 0, 0);
2297 static int mwl8k_cmd_radio_enable(struct ieee80211_hw
*hw
)
2299 return mwl8k_cmd_radio_control(hw
, 1, 0);
2303 mwl8k_set_radio_preamble(struct ieee80211_hw
*hw
, bool short_preamble
)
2305 struct mwl8k_priv
*priv
= hw
->priv
;
2307 priv
->radio_short_preamble
= short_preamble
;
2309 return mwl8k_cmd_radio_control(hw
, 1, 1);
2315 #define MWL8K_RF_TX_POWER_LEVEL_TOTAL 8
2317 struct mwl8k_cmd_rf_tx_power
{
2318 struct mwl8k_cmd_pkt header
;
2320 __le16 support_level
;
2321 __le16 current_level
;
2323 __le16 power_level_list
[MWL8K_RF_TX_POWER_LEVEL_TOTAL
];
2326 static int mwl8k_cmd_rf_tx_power(struct ieee80211_hw
*hw
, int dBm
)
2328 struct mwl8k_cmd_rf_tx_power
*cmd
;
2331 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
2335 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_RF_TX_POWER
);
2336 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
2337 cmd
->action
= cpu_to_le16(MWL8K_CMD_SET
);
2338 cmd
->support_level
= cpu_to_le16(dBm
);
2340 rc
= mwl8k_post_cmd(hw
, &cmd
->header
);
2349 #define MWL8K_TX_POWER_LEVEL_TOTAL 12
2351 struct mwl8k_cmd_tx_power
{
2352 struct mwl8k_cmd_pkt header
;
2358 __le16 power_level_list
[MWL8K_TX_POWER_LEVEL_TOTAL
];
2359 } __attribute__((packed
));
2361 static int mwl8k_cmd_tx_power(struct ieee80211_hw
*hw
,
2362 struct ieee80211_conf
*conf
,
2365 struct ieee80211_channel
*channel
= conf
->channel
;
2366 struct mwl8k_cmd_tx_power
*cmd
;
2370 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
2374 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_TX_POWER
);
2375 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
2376 cmd
->action
= cpu_to_le16(MWL8K_CMD_SET_LIST
);
2378 if (channel
->band
== IEEE80211_BAND_2GHZ
)
2379 cmd
->band
= cpu_to_le16(0x1);
2380 else if (channel
->band
== IEEE80211_BAND_5GHZ
)
2381 cmd
->band
= cpu_to_le16(0x4);
2383 cmd
->channel
= channel
->hw_value
;
2385 if (conf
->channel_type
== NL80211_CHAN_NO_HT
||
2386 conf
->channel_type
== NL80211_CHAN_HT20
) {
2387 cmd
->bw
= cpu_to_le16(0x2);
2389 cmd
->bw
= cpu_to_le16(0x4);
2390 if (conf
->channel_type
== NL80211_CHAN_HT40MINUS
)
2391 cmd
->sub_ch
= cpu_to_le16(0x3);
2392 else if (conf
->channel_type
== NL80211_CHAN_HT40PLUS
)
2393 cmd
->sub_ch
= cpu_to_le16(0x1);
2396 for (i
= 0; i
< MWL8K_TX_POWER_LEVEL_TOTAL
; i
++)
2397 cmd
->power_level_list
[i
] = cpu_to_le16(pwr
);
2399 rc
= mwl8k_post_cmd(hw
, &cmd
->header
);
2408 struct mwl8k_cmd_rf_antenna
{
2409 struct mwl8k_cmd_pkt header
;
2414 #define MWL8K_RF_ANTENNA_RX 1
2415 #define MWL8K_RF_ANTENNA_TX 2
2418 mwl8k_cmd_rf_antenna(struct ieee80211_hw
*hw
, int antenna
, int mask
)
2420 struct mwl8k_cmd_rf_antenna
*cmd
;
2423 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
2427 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_RF_ANTENNA
);
2428 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
2429 cmd
->antenna
= cpu_to_le16(antenna
);
2430 cmd
->mode
= cpu_to_le16(mask
);
2432 rc
= mwl8k_post_cmd(hw
, &cmd
->header
);
2441 struct mwl8k_cmd_set_beacon
{
2442 struct mwl8k_cmd_pkt header
;
2447 static int mwl8k_cmd_set_beacon(struct ieee80211_hw
*hw
,
2448 struct ieee80211_vif
*vif
, u8
*beacon
, int len
)
2450 struct mwl8k_cmd_set_beacon
*cmd
;
2453 cmd
= kzalloc(sizeof(*cmd
) + len
, GFP_KERNEL
);
2457 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_SET_BEACON
);
2458 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
) + len
);
2459 cmd
->beacon_len
= cpu_to_le16(len
);
2460 memcpy(cmd
->beacon
, beacon
, len
);
2462 rc
= mwl8k_post_pervif_cmd(hw
, vif
, &cmd
->header
);
2471 struct mwl8k_cmd_set_pre_scan
{
2472 struct mwl8k_cmd_pkt header
;
2475 static int mwl8k_cmd_set_pre_scan(struct ieee80211_hw
*hw
)
2477 struct mwl8k_cmd_set_pre_scan
*cmd
;
2480 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
2484 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_SET_PRE_SCAN
);
2485 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
2487 rc
= mwl8k_post_cmd(hw
, &cmd
->header
);
2494 * CMD_SET_POST_SCAN.
2496 struct mwl8k_cmd_set_post_scan
{
2497 struct mwl8k_cmd_pkt header
;
2499 __u8 bssid
[ETH_ALEN
];
2503 mwl8k_cmd_set_post_scan(struct ieee80211_hw
*hw
, const __u8
*mac
)
2505 struct mwl8k_cmd_set_post_scan
*cmd
;
2508 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
2512 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_SET_POST_SCAN
);
2513 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
2515 memcpy(cmd
->bssid
, mac
, ETH_ALEN
);
2517 rc
= mwl8k_post_cmd(hw
, &cmd
->header
);
2524 * CMD_SET_RF_CHANNEL.
2526 struct mwl8k_cmd_set_rf_channel
{
2527 struct mwl8k_cmd_pkt header
;
2529 __u8 current_channel
;
2530 __le32 channel_flags
;
2533 static int mwl8k_cmd_set_rf_channel(struct ieee80211_hw
*hw
,
2534 struct ieee80211_conf
*conf
)
2536 struct ieee80211_channel
*channel
= conf
->channel
;
2537 struct mwl8k_cmd_set_rf_channel
*cmd
;
2540 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
2544 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_SET_RF_CHANNEL
);
2545 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
2546 cmd
->action
= cpu_to_le16(MWL8K_CMD_SET
);
2547 cmd
->current_channel
= channel
->hw_value
;
2549 if (channel
->band
== IEEE80211_BAND_2GHZ
)
2550 cmd
->channel_flags
|= cpu_to_le32(0x00000001);
2551 else if (channel
->band
== IEEE80211_BAND_5GHZ
)
2552 cmd
->channel_flags
|= cpu_to_le32(0x00000004);
2554 if (conf
->channel_type
== NL80211_CHAN_NO_HT
||
2555 conf
->channel_type
== NL80211_CHAN_HT20
)
2556 cmd
->channel_flags
|= cpu_to_le32(0x00000080);
2557 else if (conf
->channel_type
== NL80211_CHAN_HT40MINUS
)
2558 cmd
->channel_flags
|= cpu_to_le32(0x000001900);
2559 else if (conf
->channel_type
== NL80211_CHAN_HT40PLUS
)
2560 cmd
->channel_flags
|= cpu_to_le32(0x000000900);
2562 rc
= mwl8k_post_cmd(hw
, &cmd
->header
);
2571 #define MWL8K_FRAME_PROT_DISABLED 0x00
2572 #define MWL8K_FRAME_PROT_11G 0x07
2573 #define MWL8K_FRAME_PROT_11N_HT_40MHZ_ONLY 0x02
2574 #define MWL8K_FRAME_PROT_11N_HT_ALL 0x06
2576 struct mwl8k_cmd_update_set_aid
{
2577 struct mwl8k_cmd_pkt header
;
2580 /* AP's MAC address (BSSID) */
2581 __u8 bssid
[ETH_ALEN
];
2582 __le16 protection_mode
;
2583 __u8 supp_rates
[14];
2586 static void legacy_rate_mask_to_array(u8
*rates
, u32 mask
)
2592 * Clear nonstandard rates 4 and 13.
2596 for (i
= 0, j
= 0; i
< 14; i
++) {
2597 if (mask
& (1 << i
))
2598 rates
[j
++] = mwl8k_rates_24
[i
].hw_value
;
2603 mwl8k_cmd_set_aid(struct ieee80211_hw
*hw
,
2604 struct ieee80211_vif
*vif
, u32 legacy_rate_mask
)
2606 struct mwl8k_cmd_update_set_aid
*cmd
;
2610 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
2614 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_SET_AID
);
2615 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
2616 cmd
->aid
= cpu_to_le16(vif
->bss_conf
.aid
);
2617 memcpy(cmd
->bssid
, vif
->bss_conf
.bssid
, ETH_ALEN
);
2619 if (vif
->bss_conf
.use_cts_prot
) {
2620 prot_mode
= MWL8K_FRAME_PROT_11G
;
2622 switch (vif
->bss_conf
.ht_operation_mode
&
2623 IEEE80211_HT_OP_MODE_PROTECTION
) {
2624 case IEEE80211_HT_OP_MODE_PROTECTION_20MHZ
:
2625 prot_mode
= MWL8K_FRAME_PROT_11N_HT_40MHZ_ONLY
;
2627 case IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED
:
2628 prot_mode
= MWL8K_FRAME_PROT_11N_HT_ALL
;
2631 prot_mode
= MWL8K_FRAME_PROT_DISABLED
;
2635 cmd
->protection_mode
= cpu_to_le16(prot_mode
);
2637 legacy_rate_mask_to_array(cmd
->supp_rates
, legacy_rate_mask
);
2639 rc
= mwl8k_post_cmd(hw
, &cmd
->header
);
2648 struct mwl8k_cmd_set_rate
{
2649 struct mwl8k_cmd_pkt header
;
2650 __u8 legacy_rates
[14];
2652 /* Bitmap for supported MCS codes. */
2658 mwl8k_cmd_set_rate(struct ieee80211_hw
*hw
, struct ieee80211_vif
*vif
,
2659 u32 legacy_rate_mask
, u8
*mcs_rates
)
2661 struct mwl8k_cmd_set_rate
*cmd
;
2664 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
2668 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_SET_RATE
);
2669 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
2670 legacy_rate_mask_to_array(cmd
->legacy_rates
, legacy_rate_mask
);
2671 memcpy(cmd
->mcs_set
, mcs_rates
, 16);
2673 rc
= mwl8k_post_cmd(hw
, &cmd
->header
);
2680 * CMD_FINALIZE_JOIN.
2682 #define MWL8K_FJ_BEACON_MAXLEN 128
2684 struct mwl8k_cmd_finalize_join
{
2685 struct mwl8k_cmd_pkt header
;
2686 __le32 sleep_interval
; /* Number of beacon periods to sleep */
2687 __u8 beacon_data
[MWL8K_FJ_BEACON_MAXLEN
];
2690 static int mwl8k_cmd_finalize_join(struct ieee80211_hw
*hw
, void *frame
,
2691 int framelen
, int dtim
)
2693 struct mwl8k_cmd_finalize_join
*cmd
;
2694 struct ieee80211_mgmt
*payload
= frame
;
2698 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
2702 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_SET_FINALIZE_JOIN
);
2703 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
2704 cmd
->sleep_interval
= cpu_to_le32(dtim
? dtim
: 1);
2706 payload_len
= framelen
- ieee80211_hdrlen(payload
->frame_control
);
2707 if (payload_len
< 0)
2709 else if (payload_len
> MWL8K_FJ_BEACON_MAXLEN
)
2710 payload_len
= MWL8K_FJ_BEACON_MAXLEN
;
2712 memcpy(cmd
->beacon_data
, &payload
->u
.beacon
, payload_len
);
2714 rc
= mwl8k_post_cmd(hw
, &cmd
->header
);
2721 * CMD_SET_RTS_THRESHOLD.
2723 struct mwl8k_cmd_set_rts_threshold
{
2724 struct mwl8k_cmd_pkt header
;
2730 mwl8k_cmd_set_rts_threshold(struct ieee80211_hw
*hw
, int rts_thresh
)
2732 struct mwl8k_cmd_set_rts_threshold
*cmd
;
2735 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
2739 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_RTS_THRESHOLD
);
2740 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
2741 cmd
->action
= cpu_to_le16(MWL8K_CMD_SET
);
2742 cmd
->threshold
= cpu_to_le16(rts_thresh
);
2744 rc
= mwl8k_post_cmd(hw
, &cmd
->header
);
2753 struct mwl8k_cmd_set_slot
{
2754 struct mwl8k_cmd_pkt header
;
2759 static int mwl8k_cmd_set_slot(struct ieee80211_hw
*hw
, bool short_slot_time
)
2761 struct mwl8k_cmd_set_slot
*cmd
;
2764 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
2768 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_SET_SLOT
);
2769 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
2770 cmd
->action
= cpu_to_le16(MWL8K_CMD_SET
);
2771 cmd
->short_slot
= short_slot_time
;
2773 rc
= mwl8k_post_cmd(hw
, &cmd
->header
);
2780 * CMD_SET_EDCA_PARAMS.
2782 struct mwl8k_cmd_set_edca_params
{
2783 struct mwl8k_cmd_pkt header
;
2785 /* See MWL8K_SET_EDCA_XXX below */
2788 /* TX opportunity in units of 32 us */
2793 /* Log exponent of max contention period: 0...15 */
2796 /* Log exponent of min contention period: 0...15 */
2799 /* Adaptive interframe spacing in units of 32us */
2802 /* TX queue to configure */
2806 /* Log exponent of max contention period: 0...15 */
2809 /* Log exponent of min contention period: 0...15 */
2812 /* Adaptive interframe spacing in units of 32us */
2815 /* TX queue to configure */
2821 #define MWL8K_SET_EDCA_CW 0x01
2822 #define MWL8K_SET_EDCA_TXOP 0x02
2823 #define MWL8K_SET_EDCA_AIFS 0x04
2825 #define MWL8K_SET_EDCA_ALL (MWL8K_SET_EDCA_CW | \
2826 MWL8K_SET_EDCA_TXOP | \
2827 MWL8K_SET_EDCA_AIFS)
2830 mwl8k_cmd_set_edca_params(struct ieee80211_hw
*hw
, __u8 qnum
,
2831 __u16 cw_min
, __u16 cw_max
,
2832 __u8 aifs
, __u16 txop
)
2834 struct mwl8k_priv
*priv
= hw
->priv
;
2835 struct mwl8k_cmd_set_edca_params
*cmd
;
2838 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
2842 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_SET_EDCA_PARAMS
);
2843 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
2844 cmd
->action
= cpu_to_le16(MWL8K_SET_EDCA_ALL
);
2845 cmd
->txop
= cpu_to_le16(txop
);
2847 cmd
->ap
.log_cw_max
= cpu_to_le32(ilog2(cw_max
+ 1));
2848 cmd
->ap
.log_cw_min
= cpu_to_le32(ilog2(cw_min
+ 1));
2849 cmd
->ap
.aifs
= aifs
;
2852 cmd
->sta
.log_cw_max
= (u8
)ilog2(cw_max
+ 1);
2853 cmd
->sta
.log_cw_min
= (u8
)ilog2(cw_min
+ 1);
2854 cmd
->sta
.aifs
= aifs
;
2855 cmd
->sta
.txq
= qnum
;
2858 rc
= mwl8k_post_cmd(hw
, &cmd
->header
);
2867 struct mwl8k_cmd_set_wmm_mode
{
2868 struct mwl8k_cmd_pkt header
;
2872 static int mwl8k_cmd_set_wmm_mode(struct ieee80211_hw
*hw
, bool enable
)
2874 struct mwl8k_priv
*priv
= hw
->priv
;
2875 struct mwl8k_cmd_set_wmm_mode
*cmd
;
2878 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
2882 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_SET_WMM_MODE
);
2883 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
2884 cmd
->action
= cpu_to_le16(!!enable
);
2886 rc
= mwl8k_post_cmd(hw
, &cmd
->header
);
2890 priv
->wmm_enabled
= enable
;
2898 struct mwl8k_cmd_mimo_config
{
2899 struct mwl8k_cmd_pkt header
;
2901 __u8 rx_antenna_map
;
2902 __u8 tx_antenna_map
;
2905 static int mwl8k_cmd_mimo_config(struct ieee80211_hw
*hw
, __u8 rx
, __u8 tx
)
2907 struct mwl8k_cmd_mimo_config
*cmd
;
2910 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
2914 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_MIMO_CONFIG
);
2915 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
2916 cmd
->action
= cpu_to_le32((u32
)MWL8K_CMD_SET
);
2917 cmd
->rx_antenna_map
= rx
;
2918 cmd
->tx_antenna_map
= tx
;
2920 rc
= mwl8k_post_cmd(hw
, &cmd
->header
);
2927 * CMD_USE_FIXED_RATE (STA version).
2929 struct mwl8k_cmd_use_fixed_rate_sta
{
2930 struct mwl8k_cmd_pkt header
;
2932 __le32 allow_rate_drop
;
2936 __le32 enable_retry
;
2945 #define MWL8K_USE_AUTO_RATE 0x0002
2946 #define MWL8K_UCAST_RATE 0
2948 static int mwl8k_cmd_use_fixed_rate_sta(struct ieee80211_hw
*hw
)
2950 struct mwl8k_cmd_use_fixed_rate_sta
*cmd
;
2953 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
2957 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_USE_FIXED_RATE
);
2958 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
2959 cmd
->action
= cpu_to_le32(MWL8K_USE_AUTO_RATE
);
2960 cmd
->rate_type
= cpu_to_le32(MWL8K_UCAST_RATE
);
2962 rc
= mwl8k_post_cmd(hw
, &cmd
->header
);
2969 * CMD_USE_FIXED_RATE (AP version).
2971 struct mwl8k_cmd_use_fixed_rate_ap
{
2972 struct mwl8k_cmd_pkt header
;
2974 __le32 allow_rate_drop
;
2976 struct mwl8k_rate_entry_ap
{
2978 __le32 enable_retry
;
2983 u8 multicast_rate_type
;
2988 mwl8k_cmd_use_fixed_rate_ap(struct ieee80211_hw
*hw
, int mcast
, int mgmt
)
2990 struct mwl8k_cmd_use_fixed_rate_ap
*cmd
;
2993 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
2997 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_USE_FIXED_RATE
);
2998 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
2999 cmd
->action
= cpu_to_le32(MWL8K_USE_AUTO_RATE
);
3000 cmd
->multicast_rate
= mcast
;
3001 cmd
->management_rate
= mgmt
;
3003 rc
= mwl8k_post_cmd(hw
, &cmd
->header
);
3010 * CMD_ENABLE_SNIFFER.
3012 struct mwl8k_cmd_enable_sniffer
{
3013 struct mwl8k_cmd_pkt header
;
3017 static int mwl8k_cmd_enable_sniffer(struct ieee80211_hw
*hw
, bool enable
)
3019 struct mwl8k_cmd_enable_sniffer
*cmd
;
3022 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
3026 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_ENABLE_SNIFFER
);
3027 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
3028 cmd
->action
= cpu_to_le32(!!enable
);
3030 rc
= mwl8k_post_cmd(hw
, &cmd
->header
);
3039 struct mwl8k_cmd_set_mac_addr
{
3040 struct mwl8k_cmd_pkt header
;
3044 __u8 mac_addr
[ETH_ALEN
];
3046 __u8 mac_addr
[ETH_ALEN
];
3050 #define MWL8K_MAC_TYPE_PRIMARY_CLIENT 0
3051 #define MWL8K_MAC_TYPE_SECONDARY_CLIENT 1
3052 #define MWL8K_MAC_TYPE_PRIMARY_AP 2
3053 #define MWL8K_MAC_TYPE_SECONDARY_AP 3
3055 static int mwl8k_cmd_set_mac_addr(struct ieee80211_hw
*hw
,
3056 struct ieee80211_vif
*vif
, u8
*mac
)
3058 struct mwl8k_priv
*priv
= hw
->priv
;
3059 struct mwl8k_vif
*mwl8k_vif
= MWL8K_VIF(vif
);
3060 struct mwl8k_cmd_set_mac_addr
*cmd
;
3064 mac_type
= MWL8K_MAC_TYPE_PRIMARY_AP
;
3065 if (vif
!= NULL
&& vif
->type
== NL80211_IFTYPE_STATION
) {
3066 if (mwl8k_vif
->macid
+ 1 == ffs(priv
->sta_macids_supported
))
3067 mac_type
= MWL8K_MAC_TYPE_PRIMARY_CLIENT
;
3069 mac_type
= MWL8K_MAC_TYPE_SECONDARY_CLIENT
;
3070 } else if (vif
!= NULL
&& vif
->type
== NL80211_IFTYPE_AP
) {
3071 if (mwl8k_vif
->macid
+ 1 == ffs(priv
->ap_macids_supported
))
3072 mac_type
= MWL8K_MAC_TYPE_PRIMARY_AP
;
3074 mac_type
= MWL8K_MAC_TYPE_SECONDARY_AP
;
3077 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
3081 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_SET_MAC_ADDR
);
3082 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
3084 cmd
->mbss
.mac_type
= cpu_to_le16(mac_type
);
3085 memcpy(cmd
->mbss
.mac_addr
, mac
, ETH_ALEN
);
3087 memcpy(cmd
->mac_addr
, mac
, ETH_ALEN
);
3090 rc
= mwl8k_post_pervif_cmd(hw
, vif
, &cmd
->header
);
3097 * CMD_SET_RATEADAPT_MODE.
3099 struct mwl8k_cmd_set_rate_adapt_mode
{
3100 struct mwl8k_cmd_pkt header
;
3105 static int mwl8k_cmd_set_rateadapt_mode(struct ieee80211_hw
*hw
, __u16 mode
)
3107 struct mwl8k_cmd_set_rate_adapt_mode
*cmd
;
3110 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
3114 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_SET_RATEADAPT_MODE
);
3115 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
3116 cmd
->action
= cpu_to_le16(MWL8K_CMD_SET
);
3117 cmd
->mode
= cpu_to_le16(mode
);
3119 rc
= mwl8k_post_cmd(hw
, &cmd
->header
);
3128 struct mwl8k_cmd_bss_start
{
3129 struct mwl8k_cmd_pkt header
;
3133 static int mwl8k_cmd_bss_start(struct ieee80211_hw
*hw
,
3134 struct ieee80211_vif
*vif
, int enable
)
3136 struct mwl8k_cmd_bss_start
*cmd
;
3139 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
3143 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_BSS_START
);
3144 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
3145 cmd
->enable
= cpu_to_le32(enable
);
3147 rc
= mwl8k_post_pervif_cmd(hw
, vif
, &cmd
->header
);
3156 struct mwl8k_cmd_set_new_stn
{
3157 struct mwl8k_cmd_pkt header
;
3163 __le32 legacy_rates
;
3166 __le16 ht_capabilities_info
;
3167 __u8 mac_ht_param_info
;
3169 __u8 control_channel
;
3178 #define MWL8K_STA_ACTION_ADD 0
3179 #define MWL8K_STA_ACTION_REMOVE 2
3181 static int mwl8k_cmd_set_new_stn_add(struct ieee80211_hw
*hw
,
3182 struct ieee80211_vif
*vif
,
3183 struct ieee80211_sta
*sta
)
3185 struct mwl8k_cmd_set_new_stn
*cmd
;
3189 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
3193 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_SET_NEW_STN
);
3194 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
3195 cmd
->aid
= cpu_to_le16(sta
->aid
);
3196 memcpy(cmd
->mac_addr
, sta
->addr
, ETH_ALEN
);
3197 cmd
->stn_id
= cpu_to_le16(sta
->aid
);
3198 cmd
->action
= cpu_to_le16(MWL8K_STA_ACTION_ADD
);
3199 if (hw
->conf
.channel
->band
== IEEE80211_BAND_2GHZ
)
3200 rates
= sta
->supp_rates
[IEEE80211_BAND_2GHZ
];
3202 rates
= sta
->supp_rates
[IEEE80211_BAND_5GHZ
] << 5;
3203 cmd
->legacy_rates
= cpu_to_le32(rates
);
3204 if (sta
->ht_cap
.ht_supported
) {
3205 cmd
->ht_rates
[0] = sta
->ht_cap
.mcs
.rx_mask
[0];
3206 cmd
->ht_rates
[1] = sta
->ht_cap
.mcs
.rx_mask
[1];
3207 cmd
->ht_rates
[2] = sta
->ht_cap
.mcs
.rx_mask
[2];
3208 cmd
->ht_rates
[3] = sta
->ht_cap
.mcs
.rx_mask
[3];
3209 cmd
->ht_capabilities_info
= cpu_to_le16(sta
->ht_cap
.cap
);
3210 cmd
->mac_ht_param_info
= (sta
->ht_cap
.ampdu_factor
& 3) |
3211 ((sta
->ht_cap
.ampdu_density
& 7) << 2);
3212 cmd
->is_qos_sta
= 1;
3215 rc
= mwl8k_post_pervif_cmd(hw
, vif
, &cmd
->header
);
3221 static int mwl8k_cmd_set_new_stn_add_self(struct ieee80211_hw
*hw
,
3222 struct ieee80211_vif
*vif
)
3224 struct mwl8k_cmd_set_new_stn
*cmd
;
3227 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
3231 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_SET_NEW_STN
);
3232 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
3233 memcpy(cmd
->mac_addr
, vif
->addr
, ETH_ALEN
);
3235 rc
= mwl8k_post_pervif_cmd(hw
, vif
, &cmd
->header
);
3241 static int mwl8k_cmd_set_new_stn_del(struct ieee80211_hw
*hw
,
3242 struct ieee80211_vif
*vif
, u8
*addr
)
3244 struct mwl8k_cmd_set_new_stn
*cmd
;
3247 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
3251 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_SET_NEW_STN
);
3252 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
3253 memcpy(cmd
->mac_addr
, addr
, ETH_ALEN
);
3254 cmd
->action
= cpu_to_le16(MWL8K_STA_ACTION_REMOVE
);
3256 rc
= mwl8k_post_pervif_cmd(hw
, vif
, &cmd
->header
);
3263 * CMD_UPDATE_ENCRYPTION.
3266 #define MAX_ENCR_KEY_LENGTH 16
3267 #define MIC_KEY_LENGTH 8
3269 struct mwl8k_cmd_update_encryption
{
3270 struct mwl8k_cmd_pkt header
;
3277 } __attribute__((packed
));
3279 struct mwl8k_cmd_set_key
{
3280 struct mwl8k_cmd_pkt header
;
3289 __u8 key_material
[MAX_ENCR_KEY_LENGTH
];
3290 __u8 tkip_tx_mic_key
[MIC_KEY_LENGTH
];
3291 __u8 tkip_rx_mic_key
[MIC_KEY_LENGTH
];
3292 __le16 tkip_rsc_low
;
3293 __le32 tkip_rsc_high
;
3294 __le16 tkip_tsc_low
;
3295 __le32 tkip_tsc_high
;
3297 } __attribute__((packed
));
3302 MWL8K_ENCR_REMOVE_KEY
,
3303 MWL8K_ENCR_SET_GROUP_KEY
,
3306 #define MWL8K_UPDATE_ENCRYPTION_TYPE_WEP 0
3307 #define MWL8K_UPDATE_ENCRYPTION_TYPE_DISABLE 1
3308 #define MWL8K_UPDATE_ENCRYPTION_TYPE_TKIP 4
3309 #define MWL8K_UPDATE_ENCRYPTION_TYPE_MIXED 7
3310 #define MWL8K_UPDATE_ENCRYPTION_TYPE_AES 8
3318 #define MWL8K_KEY_FLAG_TXGROUPKEY 0x00000004
3319 #define MWL8K_KEY_FLAG_PAIRWISE 0x00000008
3320 #define MWL8K_KEY_FLAG_TSC_VALID 0x00000040
3321 #define MWL8K_KEY_FLAG_WEP_TXKEY 0x01000000
3322 #define MWL8K_KEY_FLAG_MICKEY_VALID 0x02000000
3324 static int mwl8k_cmd_update_encryption_enable(struct ieee80211_hw
*hw
,
3325 struct ieee80211_vif
*vif
,
3329 struct mwl8k_cmd_update_encryption
*cmd
;
3332 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
3336 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_UPDATE_ENCRYPTION
);
3337 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
3338 cmd
->action
= cpu_to_le32(MWL8K_ENCR_ENABLE
);
3339 memcpy(cmd
->mac_addr
, addr
, ETH_ALEN
);
3340 cmd
->encr_type
= encr_type
;
3342 rc
= mwl8k_post_pervif_cmd(hw
, vif
, &cmd
->header
);
3348 static int mwl8k_encryption_set_cmd_info(struct mwl8k_cmd_set_key
*cmd
,
3350 struct ieee80211_key_conf
*key
)
3352 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_UPDATE_ENCRYPTION
);
3353 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
3354 cmd
->length
= cpu_to_le16(sizeof(*cmd
) -
3355 offsetof(struct mwl8k_cmd_set_key
, length
));
3356 cmd
->key_id
= cpu_to_le32(key
->keyidx
);
3357 cmd
->key_len
= cpu_to_le16(key
->keylen
);
3358 memcpy(cmd
->mac_addr
, addr
, ETH_ALEN
);
3360 switch (key
->cipher
) {
3361 case WLAN_CIPHER_SUITE_WEP40
:
3362 case WLAN_CIPHER_SUITE_WEP104
:
3363 cmd
->key_type_id
= cpu_to_le16(MWL8K_ALG_WEP
);
3364 if (key
->keyidx
== 0)
3365 cmd
->key_info
= cpu_to_le32(MWL8K_KEY_FLAG_WEP_TXKEY
);
3368 case WLAN_CIPHER_SUITE_TKIP
:
3369 cmd
->key_type_id
= cpu_to_le16(MWL8K_ALG_TKIP
);
3370 cmd
->key_info
= (key
->flags
& IEEE80211_KEY_FLAG_PAIRWISE
)
3371 ? cpu_to_le32(MWL8K_KEY_FLAG_PAIRWISE
)
3372 : cpu_to_le32(MWL8K_KEY_FLAG_TXGROUPKEY
);
3373 cmd
->key_info
|= cpu_to_le32(MWL8K_KEY_FLAG_MICKEY_VALID
3374 | MWL8K_KEY_FLAG_TSC_VALID
);
3376 case WLAN_CIPHER_SUITE_CCMP
:
3377 cmd
->key_type_id
= cpu_to_le16(MWL8K_ALG_CCMP
);
3378 cmd
->key_info
= (key
->flags
& IEEE80211_KEY_FLAG_PAIRWISE
)
3379 ? cpu_to_le32(MWL8K_KEY_FLAG_PAIRWISE
)
3380 : cpu_to_le32(MWL8K_KEY_FLAG_TXGROUPKEY
);
3389 static int mwl8k_cmd_encryption_set_key(struct ieee80211_hw
*hw
,
3390 struct ieee80211_vif
*vif
,
3392 struct ieee80211_key_conf
*key
)
3394 struct mwl8k_cmd_set_key
*cmd
;
3399 struct mwl8k_vif
*mwl8k_vif
= MWL8K_VIF(vif
);
3401 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
3405 rc
= mwl8k_encryption_set_cmd_info(cmd
, addr
, key
);
3411 if (key
->flags
& IEEE80211_KEY_FLAG_PAIRWISE
)
3412 action
= MWL8K_ENCR_SET_KEY
;
3414 action
= MWL8K_ENCR_SET_GROUP_KEY
;
3416 switch (key
->cipher
) {
3417 case WLAN_CIPHER_SUITE_WEP40
:
3418 case WLAN_CIPHER_SUITE_WEP104
:
3419 if (!mwl8k_vif
->wep_key_conf
[idx
].enabled
) {
3420 memcpy(mwl8k_vif
->wep_key_conf
[idx
].key
, key
,
3421 sizeof(*key
) + key
->keylen
);
3422 mwl8k_vif
->wep_key_conf
[idx
].enabled
= 1;
3426 action
= MWL8K_ENCR_SET_KEY
;
3428 case WLAN_CIPHER_SUITE_TKIP
:
3429 keymlen
= MAX_ENCR_KEY_LENGTH
+ 2 * MIC_KEY_LENGTH
;
3431 case WLAN_CIPHER_SUITE_CCMP
:
3432 keymlen
= key
->keylen
;
3439 memcpy(cmd
->key_material
, key
->key
, keymlen
);
3440 cmd
->action
= cpu_to_le32(action
);
3442 rc
= mwl8k_post_pervif_cmd(hw
, vif
, &cmd
->header
);
3449 static int mwl8k_cmd_encryption_remove_key(struct ieee80211_hw
*hw
,
3450 struct ieee80211_vif
*vif
,
3452 struct ieee80211_key_conf
*key
)
3454 struct mwl8k_cmd_set_key
*cmd
;
3456 struct mwl8k_vif
*mwl8k_vif
= MWL8K_VIF(vif
);
3458 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
3462 rc
= mwl8k_encryption_set_cmd_info(cmd
, addr
, key
);
3466 if (key
->cipher
== WLAN_CIPHER_SUITE_WEP40
||
3467 WLAN_CIPHER_SUITE_WEP104
)
3468 mwl8k_vif
->wep_key_conf
[key
->keyidx
].enabled
= 0;
3470 cmd
->action
= cpu_to_le32(MWL8K_ENCR_REMOVE_KEY
);
3472 rc
= mwl8k_post_pervif_cmd(hw
, vif
, &cmd
->header
);
3479 static int mwl8k_set_key(struct ieee80211_hw
*hw
,
3480 enum set_key_cmd cmd_param
,
3481 struct ieee80211_vif
*vif
,
3482 struct ieee80211_sta
*sta
,
3483 struct ieee80211_key_conf
*key
)
3488 struct mwl8k_vif
*mwl8k_vif
= MWL8K_VIF(vif
);
3490 if (vif
->type
== NL80211_IFTYPE_STATION
)
3494 addr
= hw
->wiphy
->perm_addr
;
3498 if (cmd_param
== SET_KEY
) {
3499 key
->flags
|= IEEE80211_KEY_FLAG_GENERATE_IV
;
3500 rc
= mwl8k_cmd_encryption_set_key(hw
, vif
, addr
, key
);
3504 if ((key
->cipher
== WLAN_CIPHER_SUITE_WEP40
)
3505 || (key
->cipher
== WLAN_CIPHER_SUITE_WEP104
))
3506 encr_type
= MWL8K_UPDATE_ENCRYPTION_TYPE_WEP
;
3508 encr_type
= MWL8K_UPDATE_ENCRYPTION_TYPE_MIXED
;
3510 rc
= mwl8k_cmd_update_encryption_enable(hw
, vif
, addr
,
3515 mwl8k_vif
->is_hw_crypto_enabled
= true;
3518 rc
= mwl8k_cmd_encryption_remove_key(hw
, vif
, addr
, key
);
3523 mwl8k_vif
->is_hw_crypto_enabled
= false;
3533 struct ewc_ht_info
{
3539 struct peer_capability_info
{
3540 /* Peer type - AP vs. STA. */
3543 /* Basic 802.11 capabilities from assoc resp. */
3546 /* Set if peer supports 802.11n high throughput (HT). */
3549 /* Valid if HT is supported. */
3551 __u8 extended_ht_caps
;
3552 struct ewc_ht_info ewc_info
;
3554 /* Legacy rate table. Intersection of our rates and peer rates. */
3555 __u8 legacy_rates
[12];
3557 /* HT rate table. Intersection of our rates and peer rates. */
3561 /* If set, interoperability mode, no proprietary extensions. */
3565 __le16 amsdu_enabled
;
3568 struct mwl8k_cmd_update_stadb
{
3569 struct mwl8k_cmd_pkt header
;
3571 /* See STADB_ACTION_TYPE */
3574 /* Peer MAC address */
3575 __u8 peer_addr
[ETH_ALEN
];
3579 /* Peer info - valid during add/update. */
3580 struct peer_capability_info peer_info
;
3583 #define MWL8K_STA_DB_MODIFY_ENTRY 1
3584 #define MWL8K_STA_DB_DEL_ENTRY 2
3586 /* Peer Entry flags - used to define the type of the peer node */
3587 #define MWL8K_PEER_TYPE_ACCESSPOINT 2
3589 static int mwl8k_cmd_update_stadb_add(struct ieee80211_hw
*hw
,
3590 struct ieee80211_vif
*vif
,
3591 struct ieee80211_sta
*sta
)
3593 struct mwl8k_cmd_update_stadb
*cmd
;
3594 struct peer_capability_info
*p
;
3598 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
3602 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_UPDATE_STADB
);
3603 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
3604 cmd
->action
= cpu_to_le32(MWL8K_STA_DB_MODIFY_ENTRY
);
3605 memcpy(cmd
->peer_addr
, sta
->addr
, ETH_ALEN
);
3607 p
= &cmd
->peer_info
;
3608 p
->peer_type
= MWL8K_PEER_TYPE_ACCESSPOINT
;
3609 p
->basic_caps
= cpu_to_le16(vif
->bss_conf
.assoc_capability
);
3610 p
->ht_support
= sta
->ht_cap
.ht_supported
;
3611 p
->ht_caps
= cpu_to_le16(sta
->ht_cap
.cap
);
3612 p
->extended_ht_caps
= (sta
->ht_cap
.ampdu_factor
& 3) |
3613 ((sta
->ht_cap
.ampdu_density
& 7) << 2);
3614 if (hw
->conf
.channel
->band
== IEEE80211_BAND_2GHZ
)
3615 rates
= sta
->supp_rates
[IEEE80211_BAND_2GHZ
];
3617 rates
= sta
->supp_rates
[IEEE80211_BAND_5GHZ
] << 5;
3618 legacy_rate_mask_to_array(p
->legacy_rates
, rates
);
3619 memcpy(p
->ht_rates
, sta
->ht_cap
.mcs
.rx_mask
, 16);
3621 p
->amsdu_enabled
= 0;
3623 rc
= mwl8k_post_cmd(hw
, &cmd
->header
);
3626 return rc
? rc
: p
->station_id
;
3629 static int mwl8k_cmd_update_stadb_del(struct ieee80211_hw
*hw
,
3630 struct ieee80211_vif
*vif
, u8
*addr
)
3632 struct mwl8k_cmd_update_stadb
*cmd
;
3635 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
3639 cmd
->header
.code
= cpu_to_le16(MWL8K_CMD_UPDATE_STADB
);
3640 cmd
->header
.length
= cpu_to_le16(sizeof(*cmd
));
3641 cmd
->action
= cpu_to_le32(MWL8K_STA_DB_DEL_ENTRY
);
3642 memcpy(cmd
->peer_addr
, addr
, ETH_ALEN
);
3644 rc
= mwl8k_post_cmd(hw
, &cmd
->header
);
3652 * Interrupt handling.
3654 static irqreturn_t
mwl8k_interrupt(int irq
, void *dev_id
)
3656 struct ieee80211_hw
*hw
= dev_id
;
3657 struct mwl8k_priv
*priv
= hw
->priv
;
3660 status
= ioread32(priv
->regs
+ MWL8K_HIU_A2H_INTERRUPT_STATUS
);
3664 if (status
& MWL8K_A2H_INT_TX_DONE
) {
3665 status
&= ~MWL8K_A2H_INT_TX_DONE
;
3666 tasklet_schedule(&priv
->poll_tx_task
);
3669 if (status
& MWL8K_A2H_INT_RX_READY
) {
3670 status
&= ~MWL8K_A2H_INT_RX_READY
;
3671 tasklet_schedule(&priv
->poll_rx_task
);
3675 iowrite32(~status
, priv
->regs
+ MWL8K_HIU_A2H_INTERRUPT_STATUS
);
3677 if (status
& MWL8K_A2H_INT_OPC_DONE
) {
3678 if (priv
->hostcmd_wait
!= NULL
)
3679 complete(priv
->hostcmd_wait
);
3682 if (status
& MWL8K_A2H_INT_QUEUE_EMPTY
) {
3683 if (!mutex_is_locked(&priv
->fw_mutex
) &&
3684 priv
->radio_on
&& priv
->pending_tx_pkts
)
3685 mwl8k_tx_start(priv
);
3691 static void mwl8k_tx_poll(unsigned long data
)
3693 struct ieee80211_hw
*hw
= (struct ieee80211_hw
*)data
;
3694 struct mwl8k_priv
*priv
= hw
->priv
;
3700 spin_lock_bh(&priv
->tx_lock
);
3702 for (i
= 0; i
< MWL8K_TX_QUEUES
; i
++)
3703 limit
-= mwl8k_txq_reclaim(hw
, i
, limit
, 0);
3705 if (!priv
->pending_tx_pkts
&& priv
->tx_wait
!= NULL
) {
3706 complete(priv
->tx_wait
);
3707 priv
->tx_wait
= NULL
;
3710 spin_unlock_bh(&priv
->tx_lock
);
3713 writel(~MWL8K_A2H_INT_TX_DONE
,
3714 priv
->regs
+ MWL8K_HIU_A2H_INTERRUPT_STATUS
);
3716 tasklet_schedule(&priv
->poll_tx_task
);
3720 static void mwl8k_rx_poll(unsigned long data
)
3722 struct ieee80211_hw
*hw
= (struct ieee80211_hw
*)data
;
3723 struct mwl8k_priv
*priv
= hw
->priv
;
3727 limit
-= rxq_process(hw
, 0, limit
);
3728 limit
-= rxq_refill(hw
, 0, limit
);
3731 writel(~MWL8K_A2H_INT_RX_READY
,
3732 priv
->regs
+ MWL8K_HIU_A2H_INTERRUPT_STATUS
);
3734 tasklet_schedule(&priv
->poll_rx_task
);
3740 * Core driver operations.
3742 static void mwl8k_tx(struct ieee80211_hw
*hw
, struct sk_buff
*skb
)
3744 struct mwl8k_priv
*priv
= hw
->priv
;
3745 int index
= skb_get_queue_mapping(skb
);
3747 if (!priv
->radio_on
) {
3748 wiphy_debug(hw
->wiphy
,
3749 "dropped TX frame since radio disabled\n");
3754 mwl8k_txq_xmit(hw
, index
, skb
);
3757 static int mwl8k_start(struct ieee80211_hw
*hw
)
3759 struct mwl8k_priv
*priv
= hw
->priv
;
3762 rc
= request_irq(priv
->pdev
->irq
, mwl8k_interrupt
,
3763 IRQF_SHARED
, MWL8K_NAME
, hw
);
3766 wiphy_err(hw
->wiphy
, "failed to register IRQ handler\n");
3769 priv
->irq
= priv
->pdev
->irq
;
3771 /* Enable TX reclaim and RX tasklets. */
3772 tasklet_enable(&priv
->poll_tx_task
);
3773 tasklet_enable(&priv
->poll_rx_task
);
3775 /* Enable interrupts */
3776 iowrite32(MWL8K_A2H_EVENTS
, priv
->regs
+ MWL8K_HIU_A2H_INTERRUPT_MASK
);
3778 rc
= mwl8k_fw_lock(hw
);
3780 rc
= mwl8k_cmd_radio_enable(hw
);
3784 rc
= mwl8k_cmd_enable_sniffer(hw
, 0);
3787 rc
= mwl8k_cmd_set_pre_scan(hw
);
3790 rc
= mwl8k_cmd_set_post_scan(hw
,
3791 "\x00\x00\x00\x00\x00\x00");
3795 rc
= mwl8k_cmd_set_rateadapt_mode(hw
, 0);
3798 rc
= mwl8k_cmd_set_wmm_mode(hw
, 0);
3800 mwl8k_fw_unlock(hw
);
3804 iowrite32(0, priv
->regs
+ MWL8K_HIU_A2H_INTERRUPT_MASK
);
3805 free_irq(priv
->pdev
->irq
, hw
);
3807 tasklet_disable(&priv
->poll_tx_task
);
3808 tasklet_disable(&priv
->poll_rx_task
);
3814 static void mwl8k_stop(struct ieee80211_hw
*hw
)
3816 struct mwl8k_priv
*priv
= hw
->priv
;
3819 mwl8k_cmd_radio_disable(hw
);
3821 ieee80211_stop_queues(hw
);
3823 /* Disable interrupts */
3824 iowrite32(0, priv
->regs
+ MWL8K_HIU_A2H_INTERRUPT_MASK
);
3825 if (priv
->irq
!= -1) {
3826 free_irq(priv
->pdev
->irq
, hw
);
3830 /* Stop finalize join worker */
3831 cancel_work_sync(&priv
->finalize_join_worker
);
3832 if (priv
->beacon_skb
!= NULL
)
3833 dev_kfree_skb(priv
->beacon_skb
);
3835 /* Stop TX reclaim and RX tasklets. */
3836 tasklet_disable(&priv
->poll_tx_task
);
3837 tasklet_disable(&priv
->poll_rx_task
);
3839 /* Return all skbs to mac80211 */
3840 for (i
= 0; i
< MWL8K_TX_QUEUES
; i
++)
3841 mwl8k_txq_reclaim(hw
, i
, INT_MAX
, 1);
3844 static int mwl8k_reload_firmware(struct ieee80211_hw
*hw
, char *fw_image
);
3846 static int mwl8k_add_interface(struct ieee80211_hw
*hw
,
3847 struct ieee80211_vif
*vif
)
3849 struct mwl8k_priv
*priv
= hw
->priv
;
3850 struct mwl8k_vif
*mwl8k_vif
;
3851 u32 macids_supported
;
3853 struct mwl8k_device_info
*di
;
3856 * Reject interface creation if sniffer mode is active, as
3857 * STA operation is mutually exclusive with hardware sniffer
3858 * mode. (Sniffer mode is only used on STA firmware.)
3860 if (priv
->sniffer_enabled
) {
3861 wiphy_info(hw
->wiphy
,
3862 "unable to create STA interface because sniffer mode is enabled\n");
3866 di
= priv
->device_info
;
3867 switch (vif
->type
) {
3868 case NL80211_IFTYPE_AP
:
3869 if (!priv
->ap_fw
&& di
->fw_image_ap
) {
3870 /* we must load the ap fw to meet this request */
3871 if (!list_empty(&priv
->vif_list
))
3873 rc
= mwl8k_reload_firmware(hw
, di
->fw_image_ap
);
3877 macids_supported
= priv
->ap_macids_supported
;
3879 case NL80211_IFTYPE_STATION
:
3880 if (priv
->ap_fw
&& di
->fw_image_sta
) {
3881 /* we must load the sta fw to meet this request */
3882 if (!list_empty(&priv
->vif_list
))
3884 rc
= mwl8k_reload_firmware(hw
, di
->fw_image_sta
);
3888 macids_supported
= priv
->sta_macids_supported
;
3894 macid
= ffs(macids_supported
& ~priv
->macids_used
);
3898 /* Setup driver private area. */
3899 mwl8k_vif
= MWL8K_VIF(vif
);
3900 memset(mwl8k_vif
, 0, sizeof(*mwl8k_vif
));
3901 mwl8k_vif
->vif
= vif
;
3902 mwl8k_vif
->macid
= macid
;
3903 mwl8k_vif
->seqno
= 0;
3904 memcpy(mwl8k_vif
->bssid
, vif
->addr
, ETH_ALEN
);
3905 mwl8k_vif
->is_hw_crypto_enabled
= false;
3907 /* Set the mac address. */
3908 mwl8k_cmd_set_mac_addr(hw
, vif
, vif
->addr
);
3911 mwl8k_cmd_set_new_stn_add_self(hw
, vif
);
3913 priv
->macids_used
|= 1 << mwl8k_vif
->macid
;
3914 list_add_tail(&mwl8k_vif
->list
, &priv
->vif_list
);
3919 static void mwl8k_remove_interface(struct ieee80211_hw
*hw
,
3920 struct ieee80211_vif
*vif
)
3922 struct mwl8k_priv
*priv
= hw
->priv
;
3923 struct mwl8k_vif
*mwl8k_vif
= MWL8K_VIF(vif
);
3926 mwl8k_cmd_set_new_stn_del(hw
, vif
, vif
->addr
);
3928 mwl8k_cmd_set_mac_addr(hw
, vif
, "\x00\x00\x00\x00\x00\x00");
3930 priv
->macids_used
&= ~(1 << mwl8k_vif
->macid
);
3931 list_del(&mwl8k_vif
->list
);
3934 static int mwl8k_config(struct ieee80211_hw
*hw
, u32 changed
)
3936 struct ieee80211_conf
*conf
= &hw
->conf
;
3937 struct mwl8k_priv
*priv
= hw
->priv
;
3940 if (conf
->flags
& IEEE80211_CONF_IDLE
) {
3941 mwl8k_cmd_radio_disable(hw
);
3945 rc
= mwl8k_fw_lock(hw
);
3949 rc
= mwl8k_cmd_radio_enable(hw
);
3953 rc
= mwl8k_cmd_set_rf_channel(hw
, conf
);
3957 if (conf
->power_level
> 18)
3958 conf
->power_level
= 18;
3961 rc
= mwl8k_cmd_tx_power(hw
, conf
, conf
->power_level
);
3965 rc
= mwl8k_cmd_rf_antenna(hw
, MWL8K_RF_ANTENNA_RX
, 0x3);
3967 wiphy_warn(hw
->wiphy
, "failed to set # of RX antennas");
3968 rc
= mwl8k_cmd_rf_antenna(hw
, MWL8K_RF_ANTENNA_TX
, 0x7);
3970 wiphy_warn(hw
->wiphy
, "failed to set # of TX antennas");
3973 rc
= mwl8k_cmd_rf_tx_power(hw
, conf
->power_level
);
3976 rc
= mwl8k_cmd_mimo_config(hw
, 0x7, 0x7);
3980 mwl8k_fw_unlock(hw
);
3986 mwl8k_bss_info_changed_sta(struct ieee80211_hw
*hw
, struct ieee80211_vif
*vif
,
3987 struct ieee80211_bss_conf
*info
, u32 changed
)
3989 struct mwl8k_priv
*priv
= hw
->priv
;
3990 u32 ap_legacy_rates
;
3991 u8 ap_mcs_rates
[16];
3994 if (mwl8k_fw_lock(hw
))
3998 * No need to capture a beacon if we're no longer associated.
4000 if ((changed
& BSS_CHANGED_ASSOC
) && !vif
->bss_conf
.assoc
)
4001 priv
->capture_beacon
= false;
4004 * Get the AP's legacy and MCS rates.
4006 if (vif
->bss_conf
.assoc
) {
4007 struct ieee80211_sta
*ap
;
4011 ap
= ieee80211_find_sta(vif
, vif
->bss_conf
.bssid
);
4017 if (hw
->conf
.channel
->band
== IEEE80211_BAND_2GHZ
) {
4018 ap_legacy_rates
= ap
->supp_rates
[IEEE80211_BAND_2GHZ
];
4021 ap
->supp_rates
[IEEE80211_BAND_5GHZ
] << 5;
4023 memcpy(ap_mcs_rates
, ap
->ht_cap
.mcs
.rx_mask
, 16);
4028 if ((changed
& BSS_CHANGED_ASSOC
) && vif
->bss_conf
.assoc
) {
4029 rc
= mwl8k_cmd_set_rate(hw
, vif
, ap_legacy_rates
, ap_mcs_rates
);
4033 rc
= mwl8k_cmd_use_fixed_rate_sta(hw
);
4038 if (changed
& BSS_CHANGED_ERP_PREAMBLE
) {
4039 rc
= mwl8k_set_radio_preamble(hw
,
4040 vif
->bss_conf
.use_short_preamble
);
4045 if (changed
& BSS_CHANGED_ERP_SLOT
) {
4046 rc
= mwl8k_cmd_set_slot(hw
, vif
->bss_conf
.use_short_slot
);
4051 if (vif
->bss_conf
.assoc
&&
4052 (changed
& (BSS_CHANGED_ASSOC
| BSS_CHANGED_ERP_CTS_PROT
|
4054 rc
= mwl8k_cmd_set_aid(hw
, vif
, ap_legacy_rates
);
4059 if (vif
->bss_conf
.assoc
&&
4060 (changed
& (BSS_CHANGED_ASSOC
| BSS_CHANGED_BEACON_INT
))) {
4062 * Finalize the join. Tell rx handler to process
4063 * next beacon from our BSSID.
4065 memcpy(priv
->capture_bssid
, vif
->bss_conf
.bssid
, ETH_ALEN
);
4066 priv
->capture_beacon
= true;
4070 mwl8k_fw_unlock(hw
);
4074 mwl8k_bss_info_changed_ap(struct ieee80211_hw
*hw
, struct ieee80211_vif
*vif
,
4075 struct ieee80211_bss_conf
*info
, u32 changed
)
4079 if (mwl8k_fw_lock(hw
))
4082 if (changed
& BSS_CHANGED_ERP_PREAMBLE
) {
4083 rc
= mwl8k_set_radio_preamble(hw
,
4084 vif
->bss_conf
.use_short_preamble
);
4089 if (changed
& BSS_CHANGED_BASIC_RATES
) {
4094 * Use lowest supported basic rate for multicasts
4095 * and management frames (such as probe responses --
4096 * beacons will always go out at 1 Mb/s).
4098 idx
= ffs(vif
->bss_conf
.basic_rates
);
4102 if (hw
->conf
.channel
->band
== IEEE80211_BAND_2GHZ
)
4103 rate
= mwl8k_rates_24
[idx
].hw_value
;
4105 rate
= mwl8k_rates_50
[idx
].hw_value
;
4107 mwl8k_cmd_use_fixed_rate_ap(hw
, rate
, rate
);
4110 if (changed
& (BSS_CHANGED_BEACON_INT
| BSS_CHANGED_BEACON
)) {
4111 struct sk_buff
*skb
;
4113 skb
= ieee80211_beacon_get(hw
, vif
);
4115 mwl8k_cmd_set_beacon(hw
, vif
, skb
->data
, skb
->len
);
4120 if (changed
& BSS_CHANGED_BEACON_ENABLED
)
4121 mwl8k_cmd_bss_start(hw
, vif
, info
->enable_beacon
);
4124 mwl8k_fw_unlock(hw
);
4128 mwl8k_bss_info_changed(struct ieee80211_hw
*hw
, struct ieee80211_vif
*vif
,
4129 struct ieee80211_bss_conf
*info
, u32 changed
)
4131 struct mwl8k_priv
*priv
= hw
->priv
;
4134 mwl8k_bss_info_changed_sta(hw
, vif
, info
, changed
);
4136 mwl8k_bss_info_changed_ap(hw
, vif
, info
, changed
);
4139 static u64
mwl8k_prepare_multicast(struct ieee80211_hw
*hw
,
4140 struct netdev_hw_addr_list
*mc_list
)
4142 struct mwl8k_cmd_pkt
*cmd
;
4145 * Synthesize and return a command packet that programs the
4146 * hardware multicast address filter. At this point we don't
4147 * know whether FIF_ALLMULTI is being requested, but if it is,
4148 * we'll end up throwing this packet away and creating a new
4149 * one in mwl8k_configure_filter().
4151 cmd
= __mwl8k_cmd_mac_multicast_adr(hw
, 0, mc_list
);
4153 return (unsigned long)cmd
;
4157 mwl8k_configure_filter_sniffer(struct ieee80211_hw
*hw
,
4158 unsigned int changed_flags
,
4159 unsigned int *total_flags
)
4161 struct mwl8k_priv
*priv
= hw
->priv
;
4164 * Hardware sniffer mode is mutually exclusive with STA
4165 * operation, so refuse to enable sniffer mode if a STA
4166 * interface is active.
4168 if (!list_empty(&priv
->vif_list
)) {
4169 if (net_ratelimit())
4170 wiphy_info(hw
->wiphy
,
4171 "not enabling sniffer mode because STA interface is active\n");
4175 if (!priv
->sniffer_enabled
) {
4176 if (mwl8k_cmd_enable_sniffer(hw
, 1))
4178 priv
->sniffer_enabled
= true;
4181 *total_flags
&= FIF_PROMISC_IN_BSS
| FIF_ALLMULTI
|
4182 FIF_BCN_PRBRESP_PROMISC
| FIF_CONTROL
|
4188 static struct mwl8k_vif
*mwl8k_first_vif(struct mwl8k_priv
*priv
)
4190 if (!list_empty(&priv
->vif_list
))
4191 return list_entry(priv
->vif_list
.next
, struct mwl8k_vif
, list
);
4196 static void mwl8k_configure_filter(struct ieee80211_hw
*hw
,
4197 unsigned int changed_flags
,
4198 unsigned int *total_flags
,
4201 struct mwl8k_priv
*priv
= hw
->priv
;
4202 struct mwl8k_cmd_pkt
*cmd
= (void *)(unsigned long)multicast
;
4205 * AP firmware doesn't allow fine-grained control over
4206 * the receive filter.
4209 *total_flags
&= FIF_ALLMULTI
| FIF_BCN_PRBRESP_PROMISC
;
4215 * Enable hardware sniffer mode if FIF_CONTROL or
4216 * FIF_OTHER_BSS is requested.
4218 if (*total_flags
& (FIF_CONTROL
| FIF_OTHER_BSS
) &&
4219 mwl8k_configure_filter_sniffer(hw
, changed_flags
, total_flags
)) {
4224 /* Clear unsupported feature flags */
4225 *total_flags
&= FIF_ALLMULTI
| FIF_BCN_PRBRESP_PROMISC
;
4227 if (mwl8k_fw_lock(hw
)) {
4232 if (priv
->sniffer_enabled
) {
4233 mwl8k_cmd_enable_sniffer(hw
, 0);
4234 priv
->sniffer_enabled
= false;
4237 if (changed_flags
& FIF_BCN_PRBRESP_PROMISC
) {
4238 if (*total_flags
& FIF_BCN_PRBRESP_PROMISC
) {
4240 * Disable the BSS filter.
4242 mwl8k_cmd_set_pre_scan(hw
);
4244 struct mwl8k_vif
*mwl8k_vif
;
4248 * Enable the BSS filter.
4250 * If there is an active STA interface, use that
4251 * interface's BSSID, otherwise use a dummy one
4252 * (where the OUI part needs to be nonzero for
4253 * the BSSID to be accepted by POST_SCAN).
4255 mwl8k_vif
= mwl8k_first_vif(priv
);
4256 if (mwl8k_vif
!= NULL
)
4257 bssid
= mwl8k_vif
->vif
->bss_conf
.bssid
;
4259 bssid
= "\x01\x00\x00\x00\x00\x00";
4261 mwl8k_cmd_set_post_scan(hw
, bssid
);
4266 * If FIF_ALLMULTI is being requested, throw away the command
4267 * packet that ->prepare_multicast() built and replace it with
4268 * a command packet that enables reception of all multicast
4271 if (*total_flags
& FIF_ALLMULTI
) {
4273 cmd
= __mwl8k_cmd_mac_multicast_adr(hw
, 1, NULL
);
4277 mwl8k_post_cmd(hw
, cmd
);
4281 mwl8k_fw_unlock(hw
);
4284 static int mwl8k_set_rts_threshold(struct ieee80211_hw
*hw
, u32 value
)
4286 return mwl8k_cmd_set_rts_threshold(hw
, value
);
4289 static int mwl8k_sta_remove(struct ieee80211_hw
*hw
,
4290 struct ieee80211_vif
*vif
,
4291 struct ieee80211_sta
*sta
)
4293 struct mwl8k_priv
*priv
= hw
->priv
;
4296 return mwl8k_cmd_set_new_stn_del(hw
, vif
, sta
->addr
);
4298 return mwl8k_cmd_update_stadb_del(hw
, vif
, sta
->addr
);
4301 static int mwl8k_sta_add(struct ieee80211_hw
*hw
,
4302 struct ieee80211_vif
*vif
,
4303 struct ieee80211_sta
*sta
)
4305 struct mwl8k_priv
*priv
= hw
->priv
;
4308 struct mwl8k_vif
*mwl8k_vif
= MWL8K_VIF(vif
);
4309 struct ieee80211_key_conf
*key
;
4312 ret
= mwl8k_cmd_update_stadb_add(hw
, vif
, sta
);
4314 MWL8K_STA(sta
)->peer_id
= ret
;
4319 ret
= mwl8k_cmd_set_new_stn_add(hw
, vif
, sta
);
4322 for (i
= 0; i
< NUM_WEP_KEYS
; i
++) {
4323 key
= IEEE80211_KEY_CONF(mwl8k_vif
->wep_key_conf
[i
].key
);
4324 if (mwl8k_vif
->wep_key_conf
[i
].enabled
)
4325 mwl8k_set_key(hw
, SET_KEY
, vif
, sta
, key
);
4330 static int mwl8k_conf_tx(struct ieee80211_hw
*hw
, u16 queue
,
4331 const struct ieee80211_tx_queue_params
*params
)
4333 struct mwl8k_priv
*priv
= hw
->priv
;
4336 rc
= mwl8k_fw_lock(hw
);
4338 BUG_ON(queue
> MWL8K_TX_QUEUES
- 1);
4339 memcpy(&priv
->wmm_params
[queue
], params
, sizeof(*params
));
4341 if (!priv
->wmm_enabled
)
4342 rc
= mwl8k_cmd_set_wmm_mode(hw
, 1);
4345 int q
= MWL8K_TX_QUEUES
- 1 - queue
;
4346 rc
= mwl8k_cmd_set_edca_params(hw
, q
,
4353 mwl8k_fw_unlock(hw
);
4359 static int mwl8k_get_stats(struct ieee80211_hw
*hw
,
4360 struct ieee80211_low_level_stats
*stats
)
4362 return mwl8k_cmd_get_stat(hw
, stats
);
4365 static int mwl8k_get_survey(struct ieee80211_hw
*hw
, int idx
,
4366 struct survey_info
*survey
)
4368 struct mwl8k_priv
*priv
= hw
->priv
;
4369 struct ieee80211_conf
*conf
= &hw
->conf
;
4374 survey
->channel
= conf
->channel
;
4375 survey
->filled
= SURVEY_INFO_NOISE_DBM
;
4376 survey
->noise
= priv
->noise
;
4382 mwl8k_ampdu_action(struct ieee80211_hw
*hw
, struct ieee80211_vif
*vif
,
4383 enum ieee80211_ampdu_mlme_action action
,
4384 struct ieee80211_sta
*sta
, u16 tid
, u16
*ssn
,
4388 case IEEE80211_AMPDU_RX_START
:
4389 case IEEE80211_AMPDU_RX_STOP
:
4390 if (!(hw
->flags
& IEEE80211_HW_AMPDU_AGGREGATION
))
4398 static const struct ieee80211_ops mwl8k_ops
= {
4400 .start
= mwl8k_start
,
4402 .add_interface
= mwl8k_add_interface
,
4403 .remove_interface
= mwl8k_remove_interface
,
4404 .config
= mwl8k_config
,
4405 .bss_info_changed
= mwl8k_bss_info_changed
,
4406 .prepare_multicast
= mwl8k_prepare_multicast
,
4407 .configure_filter
= mwl8k_configure_filter
,
4408 .set_key
= mwl8k_set_key
,
4409 .set_rts_threshold
= mwl8k_set_rts_threshold
,
4410 .sta_add
= mwl8k_sta_add
,
4411 .sta_remove
= mwl8k_sta_remove
,
4412 .conf_tx
= mwl8k_conf_tx
,
4413 .get_stats
= mwl8k_get_stats
,
4414 .get_survey
= mwl8k_get_survey
,
4415 .ampdu_action
= mwl8k_ampdu_action
,
4418 static void mwl8k_finalize_join_worker(struct work_struct
*work
)
4420 struct mwl8k_priv
*priv
=
4421 container_of(work
, struct mwl8k_priv
, finalize_join_worker
);
4422 struct sk_buff
*skb
= priv
->beacon_skb
;
4423 struct ieee80211_mgmt
*mgmt
= (void *)skb
->data
;
4424 int len
= skb
->len
- offsetof(struct ieee80211_mgmt
, u
.beacon
.variable
);
4425 const u8
*tim
= cfg80211_find_ie(WLAN_EID_TIM
,
4426 mgmt
->u
.beacon
.variable
, len
);
4427 int dtim_period
= 1;
4429 if (tim
&& tim
[1] >= 2)
4430 dtim_period
= tim
[3];
4432 mwl8k_cmd_finalize_join(priv
->hw
, skb
->data
, skb
->len
, dtim_period
);
4435 priv
->beacon_skb
= NULL
;
4444 #define MWL8K_8366_AP_FW_API 1
4445 #define _MWL8K_8366_AP_FW(api) "mwl8k/fmimage_8366_ap-" #api ".fw"
4446 #define MWL8K_8366_AP_FW(api) _MWL8K_8366_AP_FW(api)
4448 static struct mwl8k_device_info mwl8k_info_tbl
[] __devinitdata
= {
4450 .part_name
= "88w8363",
4451 .helper_image
= "mwl8k/helper_8363.fw",
4452 .fw_image_sta
= "mwl8k/fmimage_8363.fw",
4455 .part_name
= "88w8687",
4456 .helper_image
= "mwl8k/helper_8687.fw",
4457 .fw_image_sta
= "mwl8k/fmimage_8687.fw",
4460 .part_name
= "88w8366",
4461 .helper_image
= "mwl8k/helper_8366.fw",
4462 .fw_image_sta
= "mwl8k/fmimage_8366.fw",
4463 .fw_image_ap
= MWL8K_8366_AP_FW(MWL8K_8366_AP_FW_API
),
4464 .fw_api_ap
= MWL8K_8366_AP_FW_API
,
4465 .ap_rxd_ops
= &rxd_8366_ap_ops
,
4469 MODULE_FIRMWARE("mwl8k/helper_8363.fw");
4470 MODULE_FIRMWARE("mwl8k/fmimage_8363.fw");
4471 MODULE_FIRMWARE("mwl8k/helper_8687.fw");
4472 MODULE_FIRMWARE("mwl8k/fmimage_8687.fw");
4473 MODULE_FIRMWARE("mwl8k/helper_8366.fw");
4474 MODULE_FIRMWARE("mwl8k/fmimage_8366.fw");
4475 MODULE_FIRMWARE(MWL8K_8366_AP_FW(MWL8K_8366_AP_FW_API
));
4477 static DEFINE_PCI_DEVICE_TABLE(mwl8k_pci_id_table
) = {
4478 { PCI_VDEVICE(MARVELL
, 0x2a0a), .driver_data
= MWL8363
, },
4479 { PCI_VDEVICE(MARVELL
, 0x2a0c), .driver_data
= MWL8363
, },
4480 { PCI_VDEVICE(MARVELL
, 0x2a24), .driver_data
= MWL8363
, },
4481 { PCI_VDEVICE(MARVELL
, 0x2a2b), .driver_data
= MWL8687
, },
4482 { PCI_VDEVICE(MARVELL
, 0x2a30), .driver_data
= MWL8687
, },
4483 { PCI_VDEVICE(MARVELL
, 0x2a40), .driver_data
= MWL8366
, },
4484 { PCI_VDEVICE(MARVELL
, 0x2a43), .driver_data
= MWL8366
, },
4487 MODULE_DEVICE_TABLE(pci
, mwl8k_pci_id_table
);
4489 static int mwl8k_request_alt_fw(struct mwl8k_priv
*priv
)
4492 printk(KERN_ERR
"%s: Error requesting preferred fw %s.\n"
4493 "Trying alternative firmware %s\n", pci_name(priv
->pdev
),
4494 priv
->fw_pref
, priv
->fw_alt
);
4495 rc
= mwl8k_request_fw(priv
, priv
->fw_alt
, &priv
->fw_ucode
, true);
4497 printk(KERN_ERR
"%s: Error requesting alt fw %s\n",
4498 pci_name(priv
->pdev
), priv
->fw_alt
);
4504 static int mwl8k_firmware_load_success(struct mwl8k_priv
*priv
);
4505 static void mwl8k_fw_state_machine(const struct firmware
*fw
, void *context
)
4507 struct mwl8k_priv
*priv
= context
;
4508 struct mwl8k_device_info
*di
= priv
->device_info
;
4511 switch (priv
->fw_state
) {
4514 printk(KERN_ERR
"%s: Error requesting helper fw %s\n",
4515 pci_name(priv
->pdev
), di
->helper_image
);
4518 priv
->fw_helper
= fw
;
4519 rc
= mwl8k_request_fw(priv
, priv
->fw_pref
, &priv
->fw_ucode
,
4521 if (rc
&& priv
->fw_alt
) {
4522 rc
= mwl8k_request_alt_fw(priv
);
4525 priv
->fw_state
= FW_STATE_LOADING_ALT
;
4529 priv
->fw_state
= FW_STATE_LOADING_PREF
;
4532 case FW_STATE_LOADING_PREF
:
4535 rc
= mwl8k_request_alt_fw(priv
);
4538 priv
->fw_state
= FW_STATE_LOADING_ALT
;
4542 priv
->fw_ucode
= fw
;
4543 rc
= mwl8k_firmware_load_success(priv
);
4547 complete(&priv
->firmware_loading_complete
);
4551 case FW_STATE_LOADING_ALT
:
4553 printk(KERN_ERR
"%s: Error requesting alt fw %s\n",
4554 pci_name(priv
->pdev
), di
->helper_image
);
4557 priv
->fw_ucode
= fw
;
4558 rc
= mwl8k_firmware_load_success(priv
);
4562 complete(&priv
->firmware_loading_complete
);
4566 printk(KERN_ERR
"%s: Unexpected firmware loading state: %d\n",
4567 MWL8K_NAME
, priv
->fw_state
);
4574 priv
->fw_state
= FW_STATE_ERROR
;
4575 complete(&priv
->firmware_loading_complete
);
4576 device_release_driver(&priv
->pdev
->dev
);
4577 mwl8k_release_firmware(priv
);
4580 static int mwl8k_init_firmware(struct ieee80211_hw
*hw
, char *fw_image
,
4583 struct mwl8k_priv
*priv
= hw
->priv
;
4586 /* Reset firmware and hardware */
4587 mwl8k_hw_reset(priv
);
4589 /* Ask userland hotplug daemon for the device firmware */
4590 rc
= mwl8k_request_firmware(priv
, fw_image
, nowait
);
4592 wiphy_err(hw
->wiphy
, "Firmware files not found\n");
4599 /* Load firmware into hardware */
4600 rc
= mwl8k_load_firmware(hw
);
4602 wiphy_err(hw
->wiphy
, "Cannot start firmware\n");
4604 /* Reclaim memory once firmware is successfully loaded */
4605 mwl8k_release_firmware(priv
);
4610 /* initialize hw after successfully loading a firmware image */
4611 static int mwl8k_probe_hw(struct ieee80211_hw
*hw
)
4613 struct mwl8k_priv
*priv
= hw
->priv
;
4618 priv
->rxd_ops
= priv
->device_info
->ap_rxd_ops
;
4619 if (priv
->rxd_ops
== NULL
) {
4620 wiphy_err(hw
->wiphy
,
4621 "Driver does not have AP firmware image support for this hardware\n");
4622 goto err_stop_firmware
;
4625 priv
->rxd_ops
= &rxd_sta_ops
;
4628 priv
->sniffer_enabled
= false;
4629 priv
->wmm_enabled
= false;
4630 priv
->pending_tx_pkts
= 0;
4632 rc
= mwl8k_rxq_init(hw
, 0);
4634 goto err_stop_firmware
;
4635 rxq_refill(hw
, 0, INT_MAX
);
4637 for (i
= 0; i
< MWL8K_TX_QUEUES
; i
++) {
4638 rc
= mwl8k_txq_init(hw
, i
);
4640 goto err_free_queues
;
4643 iowrite32(0, priv
->regs
+ MWL8K_HIU_A2H_INTERRUPT_STATUS
);
4644 iowrite32(0, priv
->regs
+ MWL8K_HIU_A2H_INTERRUPT_MASK
);
4645 iowrite32(MWL8K_A2H_INT_TX_DONE
| MWL8K_A2H_INT_RX_READY
,
4646 priv
->regs
+ MWL8K_HIU_A2H_INTERRUPT_CLEAR_SEL
);
4647 iowrite32(0xffffffff, priv
->regs
+ MWL8K_HIU_A2H_INTERRUPT_STATUS_MASK
);
4649 rc
= request_irq(priv
->pdev
->irq
, mwl8k_interrupt
,
4650 IRQF_SHARED
, MWL8K_NAME
, hw
);
4652 wiphy_err(hw
->wiphy
, "failed to register IRQ handler\n");
4653 goto err_free_queues
;
4657 * Temporarily enable interrupts. Initial firmware host
4658 * commands use interrupts and avoid polling. Disable
4659 * interrupts when done.
4661 iowrite32(MWL8K_A2H_EVENTS
, priv
->regs
+ MWL8K_HIU_A2H_INTERRUPT_MASK
);
4663 /* Get config data, mac addrs etc */
4665 rc
= mwl8k_cmd_get_hw_spec_ap(hw
);
4667 rc
= mwl8k_cmd_set_hw_spec(hw
);
4669 rc
= mwl8k_cmd_get_hw_spec_sta(hw
);
4672 wiphy_err(hw
->wiphy
, "Cannot initialise firmware\n");
4676 /* Turn radio off */
4677 rc
= mwl8k_cmd_radio_disable(hw
);
4679 wiphy_err(hw
->wiphy
, "Cannot disable\n");
4683 /* Clear MAC address */
4684 rc
= mwl8k_cmd_set_mac_addr(hw
, NULL
, "\x00\x00\x00\x00\x00\x00");
4686 wiphy_err(hw
->wiphy
, "Cannot clear MAC address\n");
4690 /* Disable interrupts */
4691 iowrite32(0, priv
->regs
+ MWL8K_HIU_A2H_INTERRUPT_MASK
);
4692 free_irq(priv
->pdev
->irq
, hw
);
4694 wiphy_info(hw
->wiphy
, "%s v%d, %pm, %s firmware %u.%u.%u.%u\n",
4695 priv
->device_info
->part_name
,
4696 priv
->hw_rev
, hw
->wiphy
->perm_addr
,
4697 priv
->ap_fw
? "AP" : "STA",
4698 (priv
->fw_rev
>> 24) & 0xff, (priv
->fw_rev
>> 16) & 0xff,
4699 (priv
->fw_rev
>> 8) & 0xff, priv
->fw_rev
& 0xff);
4704 iowrite32(0, priv
->regs
+ MWL8K_HIU_A2H_INTERRUPT_MASK
);
4705 free_irq(priv
->pdev
->irq
, hw
);
4708 for (i
= 0; i
< MWL8K_TX_QUEUES
; i
++)
4709 mwl8k_txq_deinit(hw
, i
);
4710 mwl8k_rxq_deinit(hw
, 0);
4713 mwl8k_hw_reset(priv
);
4719 * invoke mwl8k_reload_firmware to change the firmware image after the device
4720 * has already been registered
4722 static int mwl8k_reload_firmware(struct ieee80211_hw
*hw
, char *fw_image
)
4725 struct mwl8k_priv
*priv
= hw
->priv
;
4728 mwl8k_rxq_deinit(hw
, 0);
4730 for (i
= 0; i
< MWL8K_TX_QUEUES
; i
++)
4731 mwl8k_txq_deinit(hw
, i
);
4733 rc
= mwl8k_init_firmware(hw
, fw_image
, false);
4737 rc
= mwl8k_probe_hw(hw
);
4741 rc
= mwl8k_start(hw
);
4745 rc
= mwl8k_config(hw
, ~0);
4749 for (i
= 0; i
< MWL8K_TX_QUEUES
; i
++) {
4750 rc
= mwl8k_conf_tx(hw
, i
, &priv
->wmm_params
[i
]);
4758 printk(KERN_WARNING
"mwl8k: Failed to reload firmware image.\n");
4762 static int mwl8k_firmware_load_success(struct mwl8k_priv
*priv
)
4764 struct ieee80211_hw
*hw
= priv
->hw
;
4767 rc
= mwl8k_load_firmware(hw
);
4768 mwl8k_release_firmware(priv
);
4770 wiphy_err(hw
->wiphy
, "Cannot start firmware\n");
4775 * Extra headroom is the size of the required DMA header
4776 * minus the size of the smallest 802.11 frame (CTS frame).
4778 hw
->extra_tx_headroom
=
4779 sizeof(struct mwl8k_dma_data
) - sizeof(struct ieee80211_cts
);
4781 hw
->channel_change_time
= 10;
4783 hw
->queues
= MWL8K_TX_QUEUES
;
4785 /* Set rssi values to dBm */
4786 hw
->flags
|= IEEE80211_HW_SIGNAL_DBM
| IEEE80211_HW_HAS_RATE_CONTROL
;
4787 hw
->vif_data_size
= sizeof(struct mwl8k_vif
);
4788 hw
->sta_data_size
= sizeof(struct mwl8k_sta
);
4790 priv
->macids_used
= 0;
4791 INIT_LIST_HEAD(&priv
->vif_list
);
4793 /* Set default radio state and preamble */
4795 priv
->radio_short_preamble
= 0;
4797 /* Finalize join worker */
4798 INIT_WORK(&priv
->finalize_join_worker
, mwl8k_finalize_join_worker
);
4800 /* TX reclaim and RX tasklets. */
4801 tasklet_init(&priv
->poll_tx_task
, mwl8k_tx_poll
, (unsigned long)hw
);
4802 tasklet_disable(&priv
->poll_tx_task
);
4803 tasklet_init(&priv
->poll_rx_task
, mwl8k_rx_poll
, (unsigned long)hw
);
4804 tasklet_disable(&priv
->poll_rx_task
);
4806 /* Power management cookie */
4807 priv
->cookie
= pci_alloc_consistent(priv
->pdev
, 4, &priv
->cookie_dma
);
4808 if (priv
->cookie
== NULL
)
4811 mutex_init(&priv
->fw_mutex
);
4812 priv
->fw_mutex_owner
= NULL
;
4813 priv
->fw_mutex_depth
= 0;
4814 priv
->hostcmd_wait
= NULL
;
4816 spin_lock_init(&priv
->tx_lock
);
4818 priv
->tx_wait
= NULL
;
4820 rc
= mwl8k_probe_hw(hw
);
4822 goto err_free_cookie
;
4824 hw
->wiphy
->interface_modes
= 0;
4825 if (priv
->ap_macids_supported
|| priv
->device_info
->fw_image_ap
)
4826 hw
->wiphy
->interface_modes
|= BIT(NL80211_IFTYPE_AP
);
4827 if (priv
->sta_macids_supported
|| priv
->device_info
->fw_image_sta
)
4828 hw
->wiphy
->interface_modes
|= BIT(NL80211_IFTYPE_STATION
);
4830 rc
= ieee80211_register_hw(hw
);
4832 wiphy_err(hw
->wiphy
, "Cannot register device\n");
4833 goto err_unprobe_hw
;
4839 for (i
= 0; i
< MWL8K_TX_QUEUES
; i
++)
4840 mwl8k_txq_deinit(hw
, i
);
4841 mwl8k_rxq_deinit(hw
, 0);
4844 if (priv
->cookie
!= NULL
)
4845 pci_free_consistent(priv
->pdev
, 4,
4846 priv
->cookie
, priv
->cookie_dma
);
4850 static int __devinit
mwl8k_probe(struct pci_dev
*pdev
,
4851 const struct pci_device_id
*id
)
4853 static int printed_version
;
4854 struct ieee80211_hw
*hw
;
4855 struct mwl8k_priv
*priv
;
4856 struct mwl8k_device_info
*di
;
4859 if (!printed_version
) {
4860 printk(KERN_INFO
"%s version %s\n", MWL8K_DESC
, MWL8K_VERSION
);
4861 printed_version
= 1;
4865 rc
= pci_enable_device(pdev
);
4867 printk(KERN_ERR
"%s: Cannot enable new PCI device\n",
4872 rc
= pci_request_regions(pdev
, MWL8K_NAME
);
4874 printk(KERN_ERR
"%s: Cannot obtain PCI resources\n",
4876 goto err_disable_device
;
4879 pci_set_master(pdev
);
4882 hw
= ieee80211_alloc_hw(sizeof(*priv
), &mwl8k_ops
);
4884 printk(KERN_ERR
"%s: ieee80211 alloc failed\n", MWL8K_NAME
);
4889 SET_IEEE80211_DEV(hw
, &pdev
->dev
);
4890 pci_set_drvdata(pdev
, hw
);
4895 priv
->device_info
= &mwl8k_info_tbl
[id
->driver_data
];
4898 priv
->sram
= pci_iomap(pdev
, 0, 0x10000);
4899 if (priv
->sram
== NULL
) {
4900 wiphy_err(hw
->wiphy
, "Cannot map device SRAM\n");
4905 * If BAR0 is a 32 bit BAR, the register BAR will be BAR1.
4906 * If BAR0 is a 64 bit BAR, the register BAR will be BAR2.
4908 priv
->regs
= pci_iomap(pdev
, 1, 0x10000);
4909 if (priv
->regs
== NULL
) {
4910 priv
->regs
= pci_iomap(pdev
, 2, 0x10000);
4911 if (priv
->regs
== NULL
) {
4912 wiphy_err(hw
->wiphy
, "Cannot map device registers\n");
4918 * Choose the initial fw image depending on user input. If a second
4919 * image is available, make it the alternative image that will be
4920 * loaded if the first one fails.
4922 init_completion(&priv
->firmware_loading_complete
);
4923 di
= priv
->device_info
;
4924 if (ap_mode_default
&& di
->fw_image_ap
) {
4925 priv
->fw_pref
= di
->fw_image_ap
;
4926 priv
->fw_alt
= di
->fw_image_sta
;
4927 } else if (!ap_mode_default
&& di
->fw_image_sta
) {
4928 priv
->fw_pref
= di
->fw_image_sta
;
4929 priv
->fw_alt
= di
->fw_image_ap
;
4930 } else if (ap_mode_default
&& !di
->fw_image_ap
&& di
->fw_image_sta
) {
4931 printk(KERN_WARNING
"AP fw is unavailable. Using STA fw.");
4932 priv
->fw_pref
= di
->fw_image_sta
;
4933 } else if (!ap_mode_default
&& !di
->fw_image_sta
&& di
->fw_image_ap
) {
4934 printk(KERN_WARNING
"STA fw is unavailable. Using AP fw.");
4935 priv
->fw_pref
= di
->fw_image_ap
;
4937 rc
= mwl8k_init_firmware(hw
, priv
->fw_pref
, true);
4939 goto err_stop_firmware
;
4943 mwl8k_hw_reset(priv
);
4946 if (priv
->regs
!= NULL
)
4947 pci_iounmap(pdev
, priv
->regs
);
4949 if (priv
->sram
!= NULL
)
4950 pci_iounmap(pdev
, priv
->sram
);
4952 pci_set_drvdata(pdev
, NULL
);
4953 ieee80211_free_hw(hw
);
4956 pci_release_regions(pdev
);
4959 pci_disable_device(pdev
);
4964 static void __devexit
mwl8k_shutdown(struct pci_dev
*pdev
)
4966 printk(KERN_ERR
"===>%s(%u)\n", __func__
, __LINE__
);
4969 static void __devexit
mwl8k_remove(struct pci_dev
*pdev
)
4971 struct ieee80211_hw
*hw
= pci_get_drvdata(pdev
);
4972 struct mwl8k_priv
*priv
;
4979 wait_for_completion(&priv
->firmware_loading_complete
);
4981 if (priv
->fw_state
== FW_STATE_ERROR
) {
4982 mwl8k_hw_reset(priv
);
4986 ieee80211_stop_queues(hw
);
4988 ieee80211_unregister_hw(hw
);
4990 /* Remove TX reclaim and RX tasklets. */
4991 tasklet_kill(&priv
->poll_tx_task
);
4992 tasklet_kill(&priv
->poll_rx_task
);
4995 mwl8k_hw_reset(priv
);
4997 /* Return all skbs to mac80211 */
4998 for (i
= 0; i
< MWL8K_TX_QUEUES
; i
++)
4999 mwl8k_txq_reclaim(hw
, i
, INT_MAX
, 1);
5001 for (i
= 0; i
< MWL8K_TX_QUEUES
; i
++)
5002 mwl8k_txq_deinit(hw
, i
);
5004 mwl8k_rxq_deinit(hw
, 0);
5006 pci_free_consistent(priv
->pdev
, 4, priv
->cookie
, priv
->cookie_dma
);
5009 pci_iounmap(pdev
, priv
->regs
);
5010 pci_iounmap(pdev
, priv
->sram
);
5011 pci_set_drvdata(pdev
, NULL
);
5012 ieee80211_free_hw(hw
);
5013 pci_release_regions(pdev
);
5014 pci_disable_device(pdev
);
5017 static struct pci_driver mwl8k_driver
= {
5019 .id_table
= mwl8k_pci_id_table
,
5020 .probe
= mwl8k_probe
,
5021 .remove
= __devexit_p(mwl8k_remove
),
5022 .shutdown
= __devexit_p(mwl8k_shutdown
),
5025 static int __init
mwl8k_init(void)
5027 return pci_register_driver(&mwl8k_driver
);
5030 static void __exit
mwl8k_exit(void)
5032 pci_unregister_driver(&mwl8k_driver
);
5035 module_init(mwl8k_init
);
5036 module_exit(mwl8k_exit
);
5038 MODULE_DESCRIPTION(MWL8K_DESC
);
5039 MODULE_VERSION(MWL8K_VERSION
);
5040 MODULE_AUTHOR("Lennert Buytenhek <buytenh@marvell.com>");
5041 MODULE_LICENSE("GPL");