2 * drivers/net/wireless/mwl8k.c
3 * Driver for Marvell TOPDOG 802.11 Wireless cards
5 * Copyright (C) 2008-2009 Marvell Semiconductor Inc.
7 * This file is licensed under the terms of the GNU General Public
8 * License version 2. This program is licensed "as is" without any
9 * warranty of any kind, whether express or implied.
12 #include <linux/init.h>
13 #include <linux/module.h>
14 #include <linux/kernel.h>
15 #include <linux/spinlock.h>
16 #include <linux/list.h>
17 #include <linux/pci.h>
18 #include <linux/delay.h>
19 #include <linux/completion.h>
20 #include <linux/etherdevice.h>
21 #include <net/mac80211.h>
22 #include <linux/moduleparam.h>
23 #include <linux/firmware.h>
24 #include <linux/workqueue.h>
26 #define MWL8K_DESC "Marvell TOPDOG(R) 802.11 Wireless Network Driver"
27 #define MWL8K_NAME KBUILD_MODNAME
28 #define MWL8K_VERSION "0.10"
30 static DEFINE_PCI_DEVICE_TABLE(mwl8k_table) = {
31 { PCI_VDEVICE(MARVELL, 0x2a2b), .driver_data = 8687, },
32 { PCI_VDEVICE(MARVELL, 0x2a30), .driver_data = 8687, },
35 MODULE_DEVICE_TABLE(pci, mwl8k_table);
37 /* Register definitions */
38 #define MWL8K_HIU_GEN_PTR 0x00000c10
39 #define MWL8K_MODE_STA 0x0000005a
40 #define MWL8K_MODE_AP 0x000000a5
41 #define MWL8K_HIU_INT_CODE 0x00000c14
42 #define MWL8K_FWSTA_READY 0xf0f1f2f4
43 #define MWL8K_FWAP_READY 0xf1f2f4a5
44 #define MWL8K_INT_CODE_CMD_FINISHED 0x00000005
45 #define MWL8K_HIU_SCRATCH 0x00000c40
47 /* Host->device communications */
48 #define MWL8K_HIU_H2A_INTERRUPT_EVENTS 0x00000c18
49 #define MWL8K_HIU_H2A_INTERRUPT_STATUS 0x00000c1c
50 #define MWL8K_HIU_H2A_INTERRUPT_MASK 0x00000c20
51 #define MWL8K_HIU_H2A_INTERRUPT_CLEAR_SEL 0x00000c24
52 #define MWL8K_HIU_H2A_INTERRUPT_STATUS_MASK 0x00000c28
53 #define MWL8K_H2A_INT_DUMMY (1 << 20)
54 #define MWL8K_H2A_INT_RESET (1 << 15)
55 #define MWL8K_H2A_INT_DOORBELL (1 << 1)
56 #define MWL8K_H2A_INT_PPA_READY (1 << 0)
58 /* Device->host communications */
59 #define MWL8K_HIU_A2H_INTERRUPT_EVENTS 0x00000c2c
60 #define MWL8K_HIU_A2H_INTERRUPT_STATUS 0x00000c30
61 #define MWL8K_HIU_A2H_INTERRUPT_MASK 0x00000c34
62 #define MWL8K_HIU_A2H_INTERRUPT_CLEAR_SEL 0x00000c38
63 #define MWL8K_HIU_A2H_INTERRUPT_STATUS_MASK 0x00000c3c
64 #define MWL8K_A2H_INT_DUMMY (1 << 20)
65 #define MWL8K_A2H_INT_CHNL_SWITCHED (1 << 11)
66 #define MWL8K_A2H_INT_QUEUE_EMPTY (1 << 10)
67 #define MWL8K_A2H_INT_RADAR_DETECT (1 << 7)
68 #define MWL8K_A2H_INT_RADIO_ON (1 << 6)
69 #define MWL8K_A2H_INT_RADIO_OFF (1 << 5)
70 #define MWL8K_A2H_INT_MAC_EVENT (1 << 3)
71 #define MWL8K_A2H_INT_OPC_DONE (1 << 2)
72 #define MWL8K_A2H_INT_RX_READY (1 << 1)
73 #define MWL8K_A2H_INT_TX_DONE (1 << 0)
75 #define MWL8K_A2H_EVENTS (MWL8K_A2H_INT_DUMMY | \
76 MWL8K_A2H_INT_CHNL_SWITCHED | \
77 MWL8K_A2H_INT_QUEUE_EMPTY | \
78 MWL8K_A2H_INT_RADAR_DETECT | \
79 MWL8K_A2H_INT_RADIO_ON | \
80 MWL8K_A2H_INT_RADIO_OFF | \
81 MWL8K_A2H_INT_MAC_EVENT | \
82 MWL8K_A2H_INT_OPC_DONE | \
83 MWL8K_A2H_INT_RX_READY | \
84 MWL8K_A2H_INT_TX_DONE)
86 /* WME stream classes */
87 #define WME_AC_BE 0 /* best effort */
88 #define WME_AC_BK 1 /* background */
89 #define WME_AC_VI 2 /* video */
90 #define WME_AC_VO 3 /* voice */
92 #define MWL8K_RX_QUEUES 1
93 #define MWL8K_TX_QUEUES 4
95 struct mwl8k_rx_queue {
98 /* hw receives here */
101 /* refill descs here */
104 struct mwl8k_rx_desc *rx_desc_area;
105 dma_addr_t rx_desc_dma;
106 struct sk_buff **rx_skb;
109 struct mwl8k_tx_queue {
110 /* hw transmits here */
113 /* sw appends here */
116 struct ieee80211_tx_queue_stats tx_stats;
117 struct mwl8k_tx_desc *tx_desc_area;
118 dma_addr_t tx_desc_dma;
119 struct sk_buff **tx_skb;
122 /* Pointers to the firmware data and meta information about it. */
123 struct mwl8k_firmware {
125 struct firmware *ucode;
127 /* Boot helper code */
128 struct firmware *helper;
133 struct ieee80211_hw *hw;
135 struct pci_dev *pdev;
137 /* firmware files and meta data */
138 struct mwl8k_firmware fw;
141 /* firmware access */
142 struct mutex fw_mutex;
143 struct task_struct *fw_mutex_owner;
145 struct completion *hostcmd_wait;
147 /* lock held over TX and TX reap */
150 /* TX quiesce completion, protected by fw_mutex and tx_lock */
151 struct completion *tx_wait;
153 struct ieee80211_vif *vif;
155 struct ieee80211_channel *current_channel;
157 /* power management status cookie from firmware */
159 dma_addr_t cookie_dma;
166 * Running count of TX packets in flight, to avoid
167 * iterating over the transmit rings each time.
171 struct mwl8k_rx_queue rxq[MWL8K_RX_QUEUES];
172 struct mwl8k_tx_queue txq[MWL8K_TX_QUEUES];
175 struct ieee80211_supported_band band;
176 struct ieee80211_channel channels[14];
177 struct ieee80211_rate rates[12];
180 bool radio_short_preamble;
183 /* XXX need to convert this to handle multiple interfaces */
185 u8 capture_bssid[ETH_ALEN];
186 struct sk_buff *beacon_skb;
189 * This FJ worker has to be global as it is scheduled from the
190 * RX handler. At this point we don't know which interface it
191 * belongs to until the list of bssids waiting to complete join
194 struct work_struct finalize_join_worker;
196 /* Tasklet to reclaim TX descriptors and buffers after tx */
197 struct tasklet_struct tx_reclaim_task;
200 /* Per interface specific private data */
202 /* backpointer to parent config block */
203 struct mwl8k_priv *priv;
205 /* BSS config of AP or IBSS from mac80211*/
206 struct ieee80211_bss_conf bss_info;
208 /* BSSID of AP or IBSS */
210 u8 mac_addr[ETH_ALEN];
213 * Subset of supported legacy rates.
214 * Intersection of AP and STA supported rates.
216 struct ieee80211_rate legacy_rates[12];
218 /* number of supported legacy rates */
221 /* Index into station database.Returned by update_sta_db call */
224 /* Non AMPDU sequence number assigned by driver */
228 #define MWL8K_VIF(_vif) ((struct mwl8k_vif *)&((_vif)->drv_priv))
230 static const struct ieee80211_channel mwl8k_channels[] = {
231 { .center_freq = 2412, .hw_value = 1, },
232 { .center_freq = 2417, .hw_value = 2, },
233 { .center_freq = 2422, .hw_value = 3, },
234 { .center_freq = 2427, .hw_value = 4, },
235 { .center_freq = 2432, .hw_value = 5, },
236 { .center_freq = 2437, .hw_value = 6, },
237 { .center_freq = 2442, .hw_value = 7, },
238 { .center_freq = 2447, .hw_value = 8, },
239 { .center_freq = 2452, .hw_value = 9, },
240 { .center_freq = 2457, .hw_value = 10, },
241 { .center_freq = 2462, .hw_value = 11, },
244 static const struct ieee80211_rate mwl8k_rates[] = {
245 { .bitrate = 10, .hw_value = 2, },
246 { .bitrate = 20, .hw_value = 4, },
247 { .bitrate = 55, .hw_value = 11, },
248 { .bitrate = 60, .hw_value = 12, },
249 { .bitrate = 90, .hw_value = 18, },
250 { .bitrate = 110, .hw_value = 22, },
251 { .bitrate = 120, .hw_value = 24, },
252 { .bitrate = 180, .hw_value = 36, },
253 { .bitrate = 240, .hw_value = 48, },
254 { .bitrate = 360, .hw_value = 72, },
255 { .bitrate = 480, .hw_value = 96, },
256 { .bitrate = 540, .hw_value = 108, },
259 /* Set or get info from Firmware */
260 #define MWL8K_CMD_SET 0x0001
261 #define MWL8K_CMD_GET 0x0000
263 /* Firmware command codes */
264 #define MWL8K_CMD_CODE_DNLD 0x0001
265 #define MWL8K_CMD_GET_HW_SPEC 0x0003
266 #define MWL8K_CMD_MAC_MULTICAST_ADR 0x0010
267 #define MWL8K_CMD_GET_STAT 0x0014
268 #define MWL8K_CMD_RADIO_CONTROL 0x001c
269 #define MWL8K_CMD_RF_TX_POWER 0x001e
270 #define MWL8K_CMD_SET_PRE_SCAN 0x0107
271 #define MWL8K_CMD_SET_POST_SCAN 0x0108
272 #define MWL8K_CMD_SET_RF_CHANNEL 0x010a
273 #define MWL8K_CMD_SET_AID 0x010d
274 #define MWL8K_CMD_SET_RATE 0x0110
275 #define MWL8K_CMD_SET_FINALIZE_JOIN 0x0111
276 #define MWL8K_CMD_RTS_THRESHOLD 0x0113
277 #define MWL8K_CMD_SET_SLOT 0x0114
278 #define MWL8K_CMD_SET_EDCA_PARAMS 0x0115
279 #define MWL8K_CMD_SET_WMM_MODE 0x0123
280 #define MWL8K_CMD_MIMO_CONFIG 0x0125
281 #define MWL8K_CMD_USE_FIXED_RATE 0x0126
282 #define MWL8K_CMD_ENABLE_SNIFFER 0x0150
283 #define MWL8K_CMD_SET_RATEADAPT_MODE 0x0203
284 #define MWL8K_CMD_UPDATE_STADB 0x1123
286 static const char *mwl8k_cmd_name(u16 cmd, char *buf, int bufsize)
288 #define MWL8K_CMDNAME(x) case MWL8K_CMD_##x: do {\
289 snprintf(buf, bufsize, "%s", #x);\
292 switch (cmd & ~0x8000) {
293 MWL8K_CMDNAME(CODE_DNLD);
294 MWL8K_CMDNAME(GET_HW_SPEC);
295 MWL8K_CMDNAME(MAC_MULTICAST_ADR);
296 MWL8K_CMDNAME(GET_STAT);
297 MWL8K_CMDNAME(RADIO_CONTROL);
298 MWL8K_CMDNAME(RF_TX_POWER);
299 MWL8K_CMDNAME(SET_PRE_SCAN);
300 MWL8K_CMDNAME(SET_POST_SCAN);
301 MWL8K_CMDNAME(SET_RF_CHANNEL);
302 MWL8K_CMDNAME(SET_AID);
303 MWL8K_CMDNAME(SET_RATE);
304 MWL8K_CMDNAME(SET_FINALIZE_JOIN);
305 MWL8K_CMDNAME(RTS_THRESHOLD);
306 MWL8K_CMDNAME(SET_SLOT);
307 MWL8K_CMDNAME(SET_EDCA_PARAMS);
308 MWL8K_CMDNAME(SET_WMM_MODE);
309 MWL8K_CMDNAME(MIMO_CONFIG);
310 MWL8K_CMDNAME(USE_FIXED_RATE);
311 MWL8K_CMDNAME(ENABLE_SNIFFER);
312 MWL8K_CMDNAME(SET_RATEADAPT_MODE);
313 MWL8K_CMDNAME(UPDATE_STADB);
315 snprintf(buf, bufsize, "0x%x", cmd);
322 /* Hardware and firmware reset */
323 static void mwl8k_hw_reset(struct mwl8k_priv *priv)
325 iowrite32(MWL8K_H2A_INT_RESET,
326 priv->regs + MWL8K_HIU_H2A_INTERRUPT_EVENTS);
327 iowrite32(MWL8K_H2A_INT_RESET,
328 priv->regs + MWL8K_HIU_H2A_INTERRUPT_EVENTS);
332 /* Release fw image */
333 static void mwl8k_release_fw(struct firmware **fw)
337 release_firmware(*fw);
341 static void mwl8k_release_firmware(struct mwl8k_priv *priv)
343 mwl8k_release_fw(&priv->fw.ucode);
344 mwl8k_release_fw(&priv->fw.helper);
347 /* Request fw image */
348 static int mwl8k_request_fw(struct mwl8k_priv *priv,
349 const char *fname, struct firmware **fw)
351 /* release current image */
353 mwl8k_release_fw(fw);
355 return request_firmware((const struct firmware **)fw,
356 fname, &priv->pdev->dev);
359 static int mwl8k_request_firmware(struct mwl8k_priv *priv, u32 part_num)
364 priv->part_num = part_num;
366 snprintf(filename, sizeof(filename),
367 "mwl8k/helper_%u.fw", priv->part_num);
369 rc = mwl8k_request_fw(priv, filename, &priv->fw.helper);
371 printk(KERN_ERR "%s: Error requesting helper firmware "
372 "file %s\n", pci_name(priv->pdev), filename);
376 snprintf(filename, sizeof(filename),
377 "mwl8k/fmimage_%u.fw", priv->part_num);
379 rc = mwl8k_request_fw(priv, filename, &priv->fw.ucode);
381 printk(KERN_ERR "%s: Error requesting firmware file %s\n",
382 pci_name(priv->pdev), filename);
383 mwl8k_release_fw(&priv->fw.helper);
390 struct mwl8k_cmd_pkt {
396 } __attribute__((packed));
402 mwl8k_send_fw_load_cmd(struct mwl8k_priv *priv, void *data, int length)
404 void __iomem *regs = priv->regs;
408 dma_addr = pci_map_single(priv->pdev, data, length, PCI_DMA_TODEVICE);
409 if (pci_dma_mapping_error(priv->pdev, dma_addr))
412 iowrite32(dma_addr, regs + MWL8K_HIU_GEN_PTR);
413 iowrite32(0, regs + MWL8K_HIU_INT_CODE);
414 iowrite32(MWL8K_H2A_INT_DOORBELL,
415 regs + MWL8K_HIU_H2A_INTERRUPT_EVENTS);
416 iowrite32(MWL8K_H2A_INT_DUMMY,
417 regs + MWL8K_HIU_H2A_INTERRUPT_EVENTS);
423 int_code = ioread32(regs + MWL8K_HIU_INT_CODE);
424 if (int_code == MWL8K_INT_CODE_CMD_FINISHED) {
425 iowrite32(0, regs + MWL8K_HIU_INT_CODE);
432 pci_unmap_single(priv->pdev, dma_addr, length, PCI_DMA_TODEVICE);
434 return loops ? 0 : -ETIMEDOUT;
437 static int mwl8k_load_fw_image(struct mwl8k_priv *priv,
438 const u8 *data, size_t length)
440 struct mwl8k_cmd_pkt *cmd;
444 cmd = kmalloc(sizeof(*cmd) + 256, GFP_KERNEL);
448 cmd->code = cpu_to_le16(MWL8K_CMD_CODE_DNLD);
454 int block_size = length > 256 ? 256 : length;
456 memcpy(cmd->payload, data + done, block_size);
457 cmd->length = cpu_to_le16(block_size);
459 rc = mwl8k_send_fw_load_cmd(priv, cmd,
460 sizeof(*cmd) + block_size);
465 length -= block_size;
470 rc = mwl8k_send_fw_load_cmd(priv, cmd, sizeof(*cmd));
478 static int mwl8k_feed_fw_image(struct mwl8k_priv *priv,
479 const u8 *data, size_t length)
481 unsigned char *buffer;
482 int may_continue, rc = 0;
483 u32 done, prev_block_size;
485 buffer = kmalloc(1024, GFP_KERNEL);
492 while (may_continue > 0) {
495 block_size = ioread32(priv->regs + MWL8K_HIU_SCRATCH);
496 if (block_size & 1) {
500 done += prev_block_size;
501 length -= prev_block_size;
504 if (block_size > 1024 || block_size > length) {
514 if (block_size == 0) {
521 prev_block_size = block_size;
522 memcpy(buffer, data + done, block_size);
524 rc = mwl8k_send_fw_load_cmd(priv, buffer, block_size);
529 if (!rc && length != 0)
537 static int mwl8k_load_firmware(struct ieee80211_hw *hw)
539 struct mwl8k_priv *priv = hw->priv;
540 struct firmware *fw = priv->fw.ucode;
544 if (!memcmp(fw->data, "\x01\x00\x00\x00", 4)) {
545 struct firmware *helper = priv->fw.helper;
547 if (helper == NULL) {
548 printk(KERN_ERR "%s: helper image needed but none "
549 "given\n", pci_name(priv->pdev));
553 rc = mwl8k_load_fw_image(priv, helper->data, helper->size);
555 printk(KERN_ERR "%s: unable to load firmware "
556 "helper image\n", pci_name(priv->pdev));
561 rc = mwl8k_feed_fw_image(priv, fw->data, fw->size);
563 rc = mwl8k_load_fw_image(priv, fw->data, fw->size);
567 printk(KERN_ERR "%s: unable to load firmware image\n",
568 pci_name(priv->pdev));
572 iowrite32(MWL8K_MODE_STA, priv->regs + MWL8K_HIU_GEN_PTR);
577 if (ioread32(priv->regs + MWL8K_HIU_INT_CODE)
578 == MWL8K_FWSTA_READY)
583 return loops ? 0 : -ETIMEDOUT;
588 * Defines shared between transmission and reception.
590 /* HT control fields for firmware */
595 } __attribute__((packed));
597 /* Firmware Station database operations */
598 #define MWL8K_STA_DB_ADD_ENTRY 0
599 #define MWL8K_STA_DB_MODIFY_ENTRY 1
600 #define MWL8K_STA_DB_DEL_ENTRY 2
601 #define MWL8K_STA_DB_FLUSH 3
603 /* Peer Entry flags - used to define the type of the peer node */
604 #define MWL8K_PEER_TYPE_ACCESSPOINT 2
606 #define MWL8K_IEEE_LEGACY_DATA_RATES 12
607 #define MWL8K_MCS_BITMAP_SIZE 16
609 struct peer_capability_info {
610 /* Peer type - AP vs. STA. */
613 /* Basic 802.11 capabilities from assoc resp. */
616 /* Set if peer supports 802.11n high throughput (HT). */
619 /* Valid if HT is supported. */
621 __u8 extended_ht_caps;
622 struct ewc_ht_info ewc_info;
624 /* Legacy rate table. Intersection of our rates and peer rates. */
625 __u8 legacy_rates[MWL8K_IEEE_LEGACY_DATA_RATES];
627 /* HT rate table. Intersection of our rates and peer rates. */
628 __u8 ht_rates[MWL8K_MCS_BITMAP_SIZE];
631 /* If set, interoperability mode, no proprietary extensions. */
635 __le16 amsdu_enabled;
636 } __attribute__((packed));
638 /* Inline functions to manipulate QoS field in data descriptor. */
639 static inline u16 mwl8k_qos_setbit_eosp(u16 qos)
641 u16 val_mask = 1 << 4;
643 /* End of Service Period Bit 4 */
644 return qos | val_mask;
647 static inline u16 mwl8k_qos_setbit_ack(u16 qos, u8 ack_policy)
651 u16 qos_mask = ~(val_mask << shift);
653 /* Ack Policy Bit 5-6 */
654 return (qos & qos_mask) | ((ack_policy & val_mask) << shift);
657 static inline u16 mwl8k_qos_setbit_amsdu(u16 qos)
659 u16 val_mask = 1 << 7;
661 /* AMSDU present Bit 7 */
662 return qos | val_mask;
665 static inline u16 mwl8k_qos_setbit_qlen(u16 qos, u8 len)
669 u16 qos_mask = ~(val_mask << shift);
671 /* Queue Length Bits 8-15 */
672 return (qos & qos_mask) | ((len & val_mask) << shift);
675 /* DMA header used by firmware and hardware. */
676 struct mwl8k_dma_data {
678 struct ieee80211_hdr wh;
679 } __attribute__((packed));
681 /* Routines to add/remove DMA header from skb. */
682 static inline void mwl8k_remove_dma_header(struct sk_buff *skb)
684 struct mwl8k_dma_data *tr = (struct mwl8k_dma_data *)skb->data;
685 void *dst, *src = &tr->wh;
686 int hdrlen = ieee80211_hdrlen(tr->wh.frame_control);
687 u16 space = sizeof(struct mwl8k_dma_data) - hdrlen;
689 dst = (void *)tr + space;
691 memmove(dst, src, hdrlen);
692 skb_pull(skb, space);
696 static inline void mwl8k_add_dma_header(struct sk_buff *skb)
698 struct ieee80211_hdr *wh;
700 struct mwl8k_dma_data *tr;
702 wh = (struct ieee80211_hdr *)skb->data;
703 hdrlen = ieee80211_hdrlen(wh->frame_control);
707 * Copy up/down the 802.11 header; the firmware requires
708 * we present a 2-byte payload length followed by a
709 * 4-address header (w/o QoS), followed (optionally) by
710 * any WEP/ExtIV header (but only filled in for CCMP).
712 if (hdrlen != sizeof(struct mwl8k_dma_data))
713 skb_push(skb, sizeof(struct mwl8k_dma_data) - hdrlen);
715 tr = (struct mwl8k_dma_data *)skb->data;
717 memmove(&tr->wh, wh, hdrlen);
720 memset(tr->wh.addr4, 0, ETH_ALEN);
723 * Firmware length is the length of the fully formed "802.11
724 * payload". That is, everything except for the 802.11 header.
725 * This includes all crypto material including the MIC.
727 tr->fwlen = cpu_to_le16(pktlen - hdrlen);
734 #define MWL8K_RX_CTRL_OWNED_BY_HOST 0x02
736 struct mwl8k_rx_desc {
740 __le32 pkt_phys_addr;
741 __le32 next_rx_desc_phys_addr;
751 } __attribute__((packed));
753 #define MWL8K_RX_DESCS 256
754 #define MWL8K_RX_MAXSZ 3800
756 static int mwl8k_rxq_init(struct ieee80211_hw *hw, int index)
758 struct mwl8k_priv *priv = hw->priv;
759 struct mwl8k_rx_queue *rxq = priv->rxq + index;
763 rxq->rx_desc_count = 0;
767 size = MWL8K_RX_DESCS * sizeof(struct mwl8k_rx_desc);
770 pci_alloc_consistent(priv->pdev, size, &rxq->rx_desc_dma);
771 if (rxq->rx_desc_area == NULL) {
772 printk(KERN_ERR "%s: failed to alloc RX descriptors\n",
773 wiphy_name(hw->wiphy));
776 memset(rxq->rx_desc_area, 0, size);
778 rxq->rx_skb = kmalloc(MWL8K_RX_DESCS *
779 sizeof(*rxq->rx_skb), GFP_KERNEL);
780 if (rxq->rx_skb == NULL) {
781 printk(KERN_ERR "%s: failed to alloc RX skbuff list\n",
782 wiphy_name(hw->wiphy));
783 pci_free_consistent(priv->pdev, size,
784 rxq->rx_desc_area, rxq->rx_desc_dma);
787 memset(rxq->rx_skb, 0, MWL8K_RX_DESCS * sizeof(*rxq->rx_skb));
789 for (i = 0; i < MWL8K_RX_DESCS; i++) {
790 struct mwl8k_rx_desc *rx_desc;
793 rx_desc = rxq->rx_desc_area + i;
794 nexti = (i + 1) % MWL8K_RX_DESCS;
796 rx_desc->next_rx_desc_phys_addr =
797 cpu_to_le32(rxq->rx_desc_dma
798 + nexti * sizeof(*rx_desc));
799 rx_desc->rx_ctrl = MWL8K_RX_CTRL_OWNED_BY_HOST;
805 static int rxq_refill(struct ieee80211_hw *hw, int index, int limit)
807 struct mwl8k_priv *priv = hw->priv;
808 struct mwl8k_rx_queue *rxq = priv->rxq + index;
812 while (rxq->rx_desc_count < MWL8K_RX_DESCS && limit--) {
816 skb = dev_alloc_skb(MWL8K_RX_MAXSZ);
820 rxq->rx_desc_count++;
823 rxq->rx_tail = (rx + 1) % MWL8K_RX_DESCS;
825 rxq->rx_desc_area[rx].pkt_phys_addr =
826 cpu_to_le32(pci_map_single(priv->pdev, skb->data,
827 MWL8K_RX_MAXSZ, DMA_FROM_DEVICE));
829 rxq->rx_desc_area[rx].pkt_len = cpu_to_le16(MWL8K_RX_MAXSZ);
830 rxq->rx_skb[rx] = skb;
832 rxq->rx_desc_area[rx].rx_ctrl = 0;
840 /* Must be called only when the card's reception is completely halted */
841 static void mwl8k_rxq_deinit(struct ieee80211_hw *hw, int index)
843 struct mwl8k_priv *priv = hw->priv;
844 struct mwl8k_rx_queue *rxq = priv->rxq + index;
847 for (i = 0; i < MWL8K_RX_DESCS; i++) {
848 if (rxq->rx_skb[i] != NULL) {
851 addr = le32_to_cpu(rxq->rx_desc_area[i].pkt_phys_addr);
852 pci_unmap_single(priv->pdev, addr, MWL8K_RX_MAXSZ,
854 kfree_skb(rxq->rx_skb[i]);
855 rxq->rx_skb[i] = NULL;
862 pci_free_consistent(priv->pdev,
863 MWL8K_RX_DESCS * sizeof(struct mwl8k_rx_desc),
864 rxq->rx_desc_area, rxq->rx_desc_dma);
865 rxq->rx_desc_area = NULL;
870 * Scan a list of BSSIDs to process for finalize join.
871 * Allows for extension to process multiple BSSIDs.
874 mwl8k_capture_bssid(struct mwl8k_priv *priv, struct ieee80211_hdr *wh)
876 return priv->capture_beacon &&
877 ieee80211_is_beacon(wh->frame_control) &&
878 !compare_ether_addr(wh->addr3, priv->capture_bssid);
881 static inline void mwl8k_save_beacon(struct ieee80211_hw *hw,
884 struct mwl8k_priv *priv = hw->priv;
886 priv->capture_beacon = false;
887 memset(priv->capture_bssid, 0, ETH_ALEN);
890 * Use GFP_ATOMIC as rxq_process is called from
891 * the primary interrupt handler, memory allocation call
894 priv->beacon_skb = skb_copy(skb, GFP_ATOMIC);
895 if (priv->beacon_skb != NULL)
896 ieee80211_queue_work(hw, &priv->finalize_join_worker);
899 static int rxq_process(struct ieee80211_hw *hw, int index, int limit)
901 struct mwl8k_priv *priv = hw->priv;
902 struct mwl8k_rx_queue *rxq = priv->rxq + index;
906 while (rxq->rx_desc_count && limit--) {
907 struct mwl8k_rx_desc *rx_desc;
909 struct ieee80211_rx_status status;
911 struct ieee80211_hdr *wh;
913 rx_desc = rxq->rx_desc_area + rxq->rx_head;
914 if (!(rx_desc->rx_ctrl & MWL8K_RX_CTRL_OWNED_BY_HOST))
918 skb = rxq->rx_skb[rxq->rx_head];
921 rxq->rx_skb[rxq->rx_head] = NULL;
923 rxq->rx_head = (rxq->rx_head + 1) % MWL8K_RX_DESCS;
924 rxq->rx_desc_count--;
926 addr = le32_to_cpu(rx_desc->pkt_phys_addr);
927 pci_unmap_single(priv->pdev, addr,
928 MWL8K_RX_MAXSZ, PCI_DMA_FROMDEVICE);
930 skb_put(skb, le16_to_cpu(rx_desc->pkt_len));
931 mwl8k_remove_dma_header(skb);
933 wh = (struct ieee80211_hdr *)skb->data;
936 * Check for a pending join operation. Save a
937 * copy of the beacon and schedule a tasklet to
938 * send a FINALIZE_JOIN command to the firmware.
940 if (mwl8k_capture_bssid(priv, wh))
941 mwl8k_save_beacon(hw, skb);
943 memset(&status, 0, sizeof(status));
945 status.signal = -rx_desc->rssi;
946 status.noise = -rx_desc->noise_level;
947 status.qual = rx_desc->link_quality;
951 status.band = IEEE80211_BAND_2GHZ;
952 status.freq = ieee80211_channel_to_frequency(rx_desc->channel);
953 memcpy(IEEE80211_SKB_RXCB(skb), &status, sizeof(status));
954 ieee80211_rx_irqsafe(hw, skb);
964 * Packet transmission.
967 /* Transmit queue assignment. */
969 MWL8K_WME_AC_BK = 0, /* background access */
970 MWL8K_WME_AC_BE = 1, /* best effort access */
971 MWL8K_WME_AC_VI = 2, /* video access */
972 MWL8K_WME_AC_VO = 3, /* voice access */
975 /* Transmit packet ACK policy */
976 #define MWL8K_TXD_ACK_POLICY_NORMAL 0
977 #define MWL8K_TXD_ACK_POLICY_BLOCKACK 3
979 #define GET_TXQ(_ac) (\
980 ((_ac) == WME_AC_VO) ? MWL8K_WME_AC_VO : \
981 ((_ac) == WME_AC_VI) ? MWL8K_WME_AC_VI : \
982 ((_ac) == WME_AC_BK) ? MWL8K_WME_AC_BK : \
985 #define MWL8K_TXD_STATUS_OK 0x00000001
986 #define MWL8K_TXD_STATUS_OK_RETRY 0x00000002
987 #define MWL8K_TXD_STATUS_OK_MORE_RETRY 0x00000004
988 #define MWL8K_TXD_STATUS_MULTICAST_TX 0x00000008
989 #define MWL8K_TXD_STATUS_FW_OWNED 0x80000000
991 struct mwl8k_tx_desc {
996 __le32 pkt_phys_addr;
998 __u8 dest_MAC_addr[ETH_ALEN];
999 __le32 next_tx_desc_phys_addr;
1004 } __attribute__((packed));
1006 #define MWL8K_TX_DESCS 128
1008 static int mwl8k_txq_init(struct ieee80211_hw *hw, int index)
1010 struct mwl8k_priv *priv = hw->priv;
1011 struct mwl8k_tx_queue *txq = priv->txq + index;
1015 memset(&txq->tx_stats, 0, sizeof(struct ieee80211_tx_queue_stats));
1016 txq->tx_stats.limit = MWL8K_TX_DESCS;
1020 size = MWL8K_TX_DESCS * sizeof(struct mwl8k_tx_desc);
1023 pci_alloc_consistent(priv->pdev, size, &txq->tx_desc_dma);
1024 if (txq->tx_desc_area == NULL) {
1025 printk(KERN_ERR "%s: failed to alloc TX descriptors\n",
1026 wiphy_name(hw->wiphy));
1029 memset(txq->tx_desc_area, 0, size);
1031 txq->tx_skb = kmalloc(MWL8K_TX_DESCS * sizeof(*txq->tx_skb),
1033 if (txq->tx_skb == NULL) {
1034 printk(KERN_ERR "%s: failed to alloc TX skbuff list\n",
1035 wiphy_name(hw->wiphy));
1036 pci_free_consistent(priv->pdev, size,
1037 txq->tx_desc_area, txq->tx_desc_dma);
1040 memset(txq->tx_skb, 0, MWL8K_TX_DESCS * sizeof(*txq->tx_skb));
1042 for (i = 0; i < MWL8K_TX_DESCS; i++) {
1043 struct mwl8k_tx_desc *tx_desc;
1046 tx_desc = txq->tx_desc_area + i;
1047 nexti = (i + 1) % MWL8K_TX_DESCS;
1049 tx_desc->status = 0;
1050 tx_desc->next_tx_desc_phys_addr =
1051 cpu_to_le32(txq->tx_desc_dma +
1052 nexti * sizeof(*tx_desc));
1058 static inline void mwl8k_tx_start(struct mwl8k_priv *priv)
1060 iowrite32(MWL8K_H2A_INT_PPA_READY,
1061 priv->regs + MWL8K_HIU_H2A_INTERRUPT_EVENTS);
1062 iowrite32(MWL8K_H2A_INT_DUMMY,
1063 priv->regs + MWL8K_HIU_H2A_INTERRUPT_EVENTS);
1064 ioread32(priv->regs + MWL8K_HIU_INT_CODE);
1067 struct mwl8k_txq_info {
1076 static int mwl8k_scan_tx_ring(struct mwl8k_priv *priv,
1077 struct mwl8k_txq_info *txinfo)
1079 int count, desc, status;
1080 struct mwl8k_tx_queue *txq;
1081 struct mwl8k_tx_desc *tx_desc;
1084 memset(txinfo, 0, MWL8K_TX_QUEUES * sizeof(struct mwl8k_txq_info));
1086 for (count = 0; count < MWL8K_TX_QUEUES; count++) {
1087 txq = priv->txq + count;
1088 txinfo[count].len = txq->tx_stats.len;
1089 txinfo[count].head = txq->tx_head;
1090 txinfo[count].tail = txq->tx_tail;
1091 for (desc = 0; desc < MWL8K_TX_DESCS; desc++) {
1092 tx_desc = txq->tx_desc_area + desc;
1093 status = le32_to_cpu(tx_desc->status);
1095 if (status & MWL8K_TXD_STATUS_FW_OWNED)
1096 txinfo[count].fw_owned++;
1098 txinfo[count].drv_owned++;
1100 if (tx_desc->pkt_len == 0)
1101 txinfo[count].unused++;
1109 * Must be called with priv->fw_mutex held and tx queues stopped.
1111 static int mwl8k_tx_wait_empty(struct ieee80211_hw *hw)
1113 struct mwl8k_priv *priv = hw->priv;
1114 DECLARE_COMPLETION_ONSTACK(tx_wait);
1116 unsigned long timeout;
1120 spin_lock_bh(&priv->tx_lock);
1121 count = priv->pending_tx_pkts;
1123 priv->tx_wait = &tx_wait;
1124 spin_unlock_bh(&priv->tx_lock);
1127 struct mwl8k_txq_info txinfo[MWL8K_TX_QUEUES];
1131 timeout = wait_for_completion_timeout(&tx_wait,
1132 msecs_to_jiffies(5000));
1136 spin_lock_bh(&priv->tx_lock);
1137 priv->tx_wait = NULL;
1138 newcount = priv->pending_tx_pkts;
1139 mwl8k_scan_tx_ring(priv, txinfo);
1140 spin_unlock_bh(&priv->tx_lock);
1142 printk(KERN_ERR "%s(%u) TIMEDOUT:5000ms Pend:%u-->%u\n",
1143 __func__, __LINE__, count, newcount);
1145 for (index = 0; index < MWL8K_TX_QUEUES; index++)
1146 printk(KERN_ERR "TXQ:%u L:%u H:%u T:%u FW:%u "
1152 txinfo[index].fw_owned,
1153 txinfo[index].drv_owned,
1154 txinfo[index].unused);
1162 #define MWL8K_TXD_SUCCESS(status) \
1163 ((status) & (MWL8K_TXD_STATUS_OK | \
1164 MWL8K_TXD_STATUS_OK_RETRY | \
1165 MWL8K_TXD_STATUS_OK_MORE_RETRY))
1167 static void mwl8k_txq_reclaim(struct ieee80211_hw *hw, int index, int force)
1169 struct mwl8k_priv *priv = hw->priv;
1170 struct mwl8k_tx_queue *txq = priv->txq + index;
1173 while (txq->tx_stats.len > 0) {
1175 struct mwl8k_tx_desc *tx_desc;
1178 struct sk_buff *skb;
1179 struct ieee80211_tx_info *info;
1183 tx_desc = txq->tx_desc_area + tx;
1185 status = le32_to_cpu(tx_desc->status);
1187 if (status & MWL8K_TXD_STATUS_FW_OWNED) {
1191 ~cpu_to_le32(MWL8K_TXD_STATUS_FW_OWNED);
1194 txq->tx_head = (tx + 1) % MWL8K_TX_DESCS;
1195 BUG_ON(txq->tx_stats.len == 0);
1196 txq->tx_stats.len--;
1197 priv->pending_tx_pkts--;
1199 addr = le32_to_cpu(tx_desc->pkt_phys_addr);
1200 size = le16_to_cpu(tx_desc->pkt_len);
1201 skb = txq->tx_skb[tx];
1202 txq->tx_skb[tx] = NULL;
1204 BUG_ON(skb == NULL);
1205 pci_unmap_single(priv->pdev, addr, size, PCI_DMA_TODEVICE);
1207 mwl8k_remove_dma_header(skb);
1209 /* Mark descriptor as unused */
1210 tx_desc->pkt_phys_addr = 0;
1211 tx_desc->pkt_len = 0;
1213 info = IEEE80211_SKB_CB(skb);
1214 ieee80211_tx_info_clear_status(info);
1215 if (MWL8K_TXD_SUCCESS(status))
1216 info->flags |= IEEE80211_TX_STAT_ACK;
1218 ieee80211_tx_status_irqsafe(hw, skb);
1223 if (wake && priv->radio_on && !mutex_is_locked(&priv->fw_mutex))
1224 ieee80211_wake_queue(hw, index);
1227 /* must be called only when the card's transmit is completely halted */
1228 static void mwl8k_txq_deinit(struct ieee80211_hw *hw, int index)
1230 struct mwl8k_priv *priv = hw->priv;
1231 struct mwl8k_tx_queue *txq = priv->txq + index;
1233 mwl8k_txq_reclaim(hw, index, 1);
1238 pci_free_consistent(priv->pdev,
1239 MWL8K_TX_DESCS * sizeof(struct mwl8k_tx_desc),
1240 txq->tx_desc_area, txq->tx_desc_dma);
1241 txq->tx_desc_area = NULL;
1245 mwl8k_txq_xmit(struct ieee80211_hw *hw, int index, struct sk_buff *skb)
1247 struct mwl8k_priv *priv = hw->priv;
1248 struct ieee80211_tx_info *tx_info;
1249 struct mwl8k_vif *mwl8k_vif;
1250 struct ieee80211_hdr *wh;
1251 struct mwl8k_tx_queue *txq;
1252 struct mwl8k_tx_desc *tx;
1258 wh = (struct ieee80211_hdr *)skb->data;
1259 if (ieee80211_is_data_qos(wh->frame_control))
1260 qos = le16_to_cpu(*((__le16 *)ieee80211_get_qos_ctl(wh)));
1264 mwl8k_add_dma_header(skb);
1265 wh = &((struct mwl8k_dma_data *)skb->data)->wh;
1267 tx_info = IEEE80211_SKB_CB(skb);
1268 mwl8k_vif = MWL8K_VIF(tx_info->control.vif);
1270 if (tx_info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) {
1271 u16 seqno = mwl8k_vif->seqno;
1273 wh->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
1274 wh->seq_ctrl |= cpu_to_le16(seqno << 4);
1275 mwl8k_vif->seqno = seqno++ % 4096;
1278 /* Setup firmware control bit fields for each frame type. */
1281 if (ieee80211_is_mgmt(wh->frame_control) ||
1282 ieee80211_is_ctl(wh->frame_control)) {
1284 qos = mwl8k_qos_setbit_eosp(qos);
1285 /* Set Queue size to unspecified */
1286 qos = mwl8k_qos_setbit_qlen(qos, 0xff);
1287 } else if (ieee80211_is_data(wh->frame_control)) {
1289 if (is_multicast_ether_addr(wh->addr1))
1290 txstatus |= MWL8K_TXD_STATUS_MULTICAST_TX;
1292 /* Send pkt in an aggregate if AMPDU frame. */
1293 if (tx_info->flags & IEEE80211_TX_CTL_AMPDU)
1294 qos = mwl8k_qos_setbit_ack(qos,
1295 MWL8K_TXD_ACK_POLICY_BLOCKACK);
1297 qos = mwl8k_qos_setbit_ack(qos,
1298 MWL8K_TXD_ACK_POLICY_NORMAL);
1300 if (qos & IEEE80211_QOS_CONTROL_A_MSDU_PRESENT)
1301 qos = mwl8k_qos_setbit_amsdu(qos);
1304 dma = pci_map_single(priv->pdev, skb->data,
1305 skb->len, PCI_DMA_TODEVICE);
1307 if (pci_dma_mapping_error(priv->pdev, dma)) {
1308 printk(KERN_DEBUG "%s: failed to dma map skb, "
1309 "dropping TX frame.\n", wiphy_name(hw->wiphy));
1311 return NETDEV_TX_OK;
1314 spin_lock_bh(&priv->tx_lock);
1316 txq = priv->txq + index;
1318 BUG_ON(txq->tx_skb[txq->tx_tail] != NULL);
1319 txq->tx_skb[txq->tx_tail] = skb;
1321 tx = txq->tx_desc_area + txq->tx_tail;
1322 tx->data_rate = txdatarate;
1323 tx->tx_priority = index;
1324 tx->qos_control = cpu_to_le16(qos);
1325 tx->pkt_phys_addr = cpu_to_le32(dma);
1326 tx->pkt_len = cpu_to_le16(skb->len);
1328 tx->peer_id = mwl8k_vif->peer_id;
1330 tx->status = cpu_to_le32(MWL8K_TXD_STATUS_FW_OWNED | txstatus);
1332 txq->tx_stats.count++;
1333 txq->tx_stats.len++;
1334 priv->pending_tx_pkts++;
1337 if (txq->tx_tail == MWL8K_TX_DESCS)
1340 if (txq->tx_head == txq->tx_tail)
1341 ieee80211_stop_queue(hw, index);
1343 mwl8k_tx_start(priv);
1345 spin_unlock_bh(&priv->tx_lock);
1347 return NETDEV_TX_OK;
1354 * We have the following requirements for issuing firmware commands:
1355 * - Some commands require that the packet transmit path is idle when
1356 * the command is issued. (For simplicity, we'll just quiesce the
1357 * transmit path for every command.)
1358 * - There are certain sequences of commands that need to be issued to
1359 * the hardware sequentially, with no other intervening commands.
1361 * This leads to an implementation of a "firmware lock" as a mutex that
1362 * can be taken recursively, and which is taken by both the low-level
1363 * command submission function (mwl8k_post_cmd) as well as any users of
1364 * that function that require issuing of an atomic sequence of commands,
1365 * and quiesces the transmit path whenever it's taken.
1367 static int mwl8k_fw_lock(struct ieee80211_hw *hw)
1369 struct mwl8k_priv *priv = hw->priv;
1371 if (priv->fw_mutex_owner != current) {
1374 mutex_lock(&priv->fw_mutex);
1375 ieee80211_stop_queues(hw);
1377 rc = mwl8k_tx_wait_empty(hw);
1379 ieee80211_wake_queues(hw);
1380 mutex_unlock(&priv->fw_mutex);
1385 priv->fw_mutex_owner = current;
1388 priv->fw_mutex_depth++;
1393 static void mwl8k_fw_unlock(struct ieee80211_hw *hw)
1395 struct mwl8k_priv *priv = hw->priv;
1397 if (!--priv->fw_mutex_depth) {
1398 ieee80211_wake_queues(hw);
1399 priv->fw_mutex_owner = NULL;
1400 mutex_unlock(&priv->fw_mutex);
1406 * Command processing.
1409 /* Timeout firmware commands after 2000ms */
1410 #define MWL8K_CMD_TIMEOUT_MS 2000
1412 static int mwl8k_post_cmd(struct ieee80211_hw *hw, struct mwl8k_cmd_pkt *cmd)
1414 DECLARE_COMPLETION_ONSTACK(cmd_wait);
1415 struct mwl8k_priv *priv = hw->priv;
1416 void __iomem *regs = priv->regs;
1417 dma_addr_t dma_addr;
1418 unsigned int dma_size;
1420 unsigned long timeout = 0;
1423 cmd->result = 0xffff;
1424 dma_size = le16_to_cpu(cmd->length);
1425 dma_addr = pci_map_single(priv->pdev, cmd, dma_size,
1426 PCI_DMA_BIDIRECTIONAL);
1427 if (pci_dma_mapping_error(priv->pdev, dma_addr))
1430 rc = mwl8k_fw_lock(hw);
1432 pci_unmap_single(priv->pdev, dma_addr, dma_size,
1433 PCI_DMA_BIDIRECTIONAL);
1437 priv->hostcmd_wait = &cmd_wait;
1438 iowrite32(dma_addr, regs + MWL8K_HIU_GEN_PTR);
1439 iowrite32(MWL8K_H2A_INT_DOORBELL,
1440 regs + MWL8K_HIU_H2A_INTERRUPT_EVENTS);
1441 iowrite32(MWL8K_H2A_INT_DUMMY,
1442 regs + MWL8K_HIU_H2A_INTERRUPT_EVENTS);
1444 timeout = wait_for_completion_timeout(&cmd_wait,
1445 msecs_to_jiffies(MWL8K_CMD_TIMEOUT_MS));
1447 priv->hostcmd_wait = NULL;
1449 mwl8k_fw_unlock(hw);
1451 pci_unmap_single(priv->pdev, dma_addr, dma_size,
1452 PCI_DMA_BIDIRECTIONAL);
1455 printk(KERN_ERR "%s: Command %s timeout after %u ms\n",
1456 wiphy_name(hw->wiphy),
1457 mwl8k_cmd_name(cmd->code, buf, sizeof(buf)),
1458 MWL8K_CMD_TIMEOUT_MS);
1461 rc = cmd->result ? -EINVAL : 0;
1463 printk(KERN_ERR "%s: Command %s error 0x%x\n",
1464 wiphy_name(hw->wiphy),
1465 mwl8k_cmd_name(cmd->code, buf, sizeof(buf)),
1466 le16_to_cpu(cmd->result));
1475 struct mwl8k_cmd_get_hw_spec {
1476 struct mwl8k_cmd_pkt header;
1478 __u8 host_interface;
1480 __u8 perm_addr[ETH_ALEN];
1485 __u8 mcs_bitmap[16];
1486 __le32 rx_queue_ptr;
1487 __le32 num_tx_queues;
1488 __le32 tx_queue_ptrs[MWL8K_TX_QUEUES];
1490 __le32 num_tx_desc_per_queue;
1491 __le32 total_rx_desc;
1492 } __attribute__((packed));
1494 static int mwl8k_cmd_get_hw_spec(struct ieee80211_hw *hw)
1496 struct mwl8k_priv *priv = hw->priv;
1497 struct mwl8k_cmd_get_hw_spec *cmd;
1501 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
1505 cmd->header.code = cpu_to_le16(MWL8K_CMD_GET_HW_SPEC);
1506 cmd->header.length = cpu_to_le16(sizeof(*cmd));
1508 memset(cmd->perm_addr, 0xff, sizeof(cmd->perm_addr));
1509 cmd->ps_cookie = cpu_to_le32(priv->cookie_dma);
1510 cmd->rx_queue_ptr = cpu_to_le32(priv->rxq[0].rx_desc_dma);
1511 cmd->num_tx_queues = cpu_to_le32(MWL8K_TX_QUEUES);
1512 for (i = 0; i < MWL8K_TX_QUEUES; i++)
1513 cmd->tx_queue_ptrs[i] = cpu_to_le32(priv->txq[i].tx_desc_dma);
1514 cmd->num_tx_desc_per_queue = cpu_to_le32(MWL8K_TX_DESCS);
1515 cmd->total_rx_desc = cpu_to_le32(MWL8K_RX_DESCS);
1517 rc = mwl8k_post_cmd(hw, &cmd->header);
1520 SET_IEEE80211_PERM_ADDR(hw, cmd->perm_addr);
1521 priv->num_mcaddrs = le16_to_cpu(cmd->num_mcaddrs);
1522 priv->fw_rev = le32_to_cpu(cmd->fw_rev);
1523 priv->hw_rev = cmd->hw_rev;
1531 * CMD_MAC_MULTICAST_ADR.
1533 struct mwl8k_cmd_mac_multicast_adr {
1534 struct mwl8k_cmd_pkt header;
1537 __u8 addr[0][ETH_ALEN];
1540 #define MWL8K_ENABLE_RX_DIRECTED 0x0001
1541 #define MWL8K_ENABLE_RX_MULTICAST 0x0002
1542 #define MWL8K_ENABLE_RX_ALL_MULTICAST 0x0004
1543 #define MWL8K_ENABLE_RX_BROADCAST 0x0008
1545 static struct mwl8k_cmd_pkt *
1546 __mwl8k_cmd_mac_multicast_adr(struct ieee80211_hw *hw, int allmulti,
1547 int mc_count, struct dev_addr_list *mclist)
1549 struct mwl8k_priv *priv = hw->priv;
1550 struct mwl8k_cmd_mac_multicast_adr *cmd;
1553 if (allmulti || mc_count > priv->num_mcaddrs) {
1558 size = sizeof(*cmd) + mc_count * ETH_ALEN;
1560 cmd = kzalloc(size, GFP_ATOMIC);
1564 cmd->header.code = cpu_to_le16(MWL8K_CMD_MAC_MULTICAST_ADR);
1565 cmd->header.length = cpu_to_le16(size);
1566 cmd->action = cpu_to_le16(MWL8K_ENABLE_RX_DIRECTED |
1567 MWL8K_ENABLE_RX_BROADCAST);
1570 cmd->action |= cpu_to_le16(MWL8K_ENABLE_RX_ALL_MULTICAST);
1571 } else if (mc_count) {
1574 cmd->action |= cpu_to_le16(MWL8K_ENABLE_RX_MULTICAST);
1575 cmd->numaddr = cpu_to_le16(mc_count);
1576 for (i = 0; i < mc_count && mclist; i++) {
1577 if (mclist->da_addrlen != ETH_ALEN) {
1581 memcpy(cmd->addr[i], mclist->da_addr, ETH_ALEN);
1582 mclist = mclist->next;
1586 return &cmd->header;
1590 * CMD_802_11_GET_STAT.
1592 struct mwl8k_cmd_802_11_get_stat {
1593 struct mwl8k_cmd_pkt header;
1595 } __attribute__((packed));
1597 #define MWL8K_STAT_ACK_FAILURE 9
1598 #define MWL8K_STAT_RTS_FAILURE 12
1599 #define MWL8K_STAT_FCS_ERROR 24
1600 #define MWL8K_STAT_RTS_SUCCESS 11
1602 static int mwl8k_cmd_802_11_get_stat(struct ieee80211_hw *hw,
1603 struct ieee80211_low_level_stats *stats)
1605 struct mwl8k_cmd_802_11_get_stat *cmd;
1608 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
1612 cmd->header.code = cpu_to_le16(MWL8K_CMD_GET_STAT);
1613 cmd->header.length = cpu_to_le16(sizeof(*cmd));
1615 rc = mwl8k_post_cmd(hw, &cmd->header);
1617 stats->dot11ACKFailureCount =
1618 le32_to_cpu(cmd->stats[MWL8K_STAT_ACK_FAILURE]);
1619 stats->dot11RTSFailureCount =
1620 le32_to_cpu(cmd->stats[MWL8K_STAT_RTS_FAILURE]);
1621 stats->dot11FCSErrorCount =
1622 le32_to_cpu(cmd->stats[MWL8K_STAT_FCS_ERROR]);
1623 stats->dot11RTSSuccessCount =
1624 le32_to_cpu(cmd->stats[MWL8K_STAT_RTS_SUCCESS]);
1632 * CMD_802_11_RADIO_CONTROL.
1634 struct mwl8k_cmd_802_11_radio_control {
1635 struct mwl8k_cmd_pkt header;
1639 } __attribute__((packed));
1642 mwl8k_cmd_802_11_radio_control(struct ieee80211_hw *hw, bool enable, bool force)
1644 struct mwl8k_priv *priv = hw->priv;
1645 struct mwl8k_cmd_802_11_radio_control *cmd;
1648 if (enable == priv->radio_on && !force)
1651 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
1655 cmd->header.code = cpu_to_le16(MWL8K_CMD_RADIO_CONTROL);
1656 cmd->header.length = cpu_to_le16(sizeof(*cmd));
1657 cmd->action = cpu_to_le16(MWL8K_CMD_SET);
1658 cmd->control = cpu_to_le16(priv->radio_short_preamble ? 3 : 1);
1659 cmd->radio_on = cpu_to_le16(enable ? 0x0001 : 0x0000);
1661 rc = mwl8k_post_cmd(hw, &cmd->header);
1665 priv->radio_on = enable;
1670 static int mwl8k_cmd_802_11_radio_disable(struct ieee80211_hw *hw)
1672 return mwl8k_cmd_802_11_radio_control(hw, 0, 0);
1675 static int mwl8k_cmd_802_11_radio_enable(struct ieee80211_hw *hw)
1677 return mwl8k_cmd_802_11_radio_control(hw, 1, 0);
1681 mwl8k_set_radio_preamble(struct ieee80211_hw *hw, bool short_preamble)
1683 struct mwl8k_priv *priv;
1685 if (hw == NULL || hw->priv == NULL)
1689 priv->radio_short_preamble = short_preamble;
1691 return mwl8k_cmd_802_11_radio_control(hw, 1, 1);
1695 * CMD_802_11_RF_TX_POWER.
1697 #define MWL8K_TX_POWER_LEVEL_TOTAL 8
1699 struct mwl8k_cmd_802_11_rf_tx_power {
1700 struct mwl8k_cmd_pkt header;
1702 __le16 support_level;
1703 __le16 current_level;
1705 __le16 power_level_list[MWL8K_TX_POWER_LEVEL_TOTAL];
1706 } __attribute__((packed));
1708 static int mwl8k_cmd_802_11_rf_tx_power(struct ieee80211_hw *hw, int dBm)
1710 struct mwl8k_cmd_802_11_rf_tx_power *cmd;
1713 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
1717 cmd->header.code = cpu_to_le16(MWL8K_CMD_RF_TX_POWER);
1718 cmd->header.length = cpu_to_le16(sizeof(*cmd));
1719 cmd->action = cpu_to_le16(MWL8K_CMD_SET);
1720 cmd->support_level = cpu_to_le16(dBm);
1722 rc = mwl8k_post_cmd(hw, &cmd->header);
1731 struct mwl8k_cmd_set_pre_scan {
1732 struct mwl8k_cmd_pkt header;
1733 } __attribute__((packed));
1735 static int mwl8k_cmd_set_pre_scan(struct ieee80211_hw *hw)
1737 struct mwl8k_cmd_set_pre_scan *cmd;
1740 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
1744 cmd->header.code = cpu_to_le16(MWL8K_CMD_SET_PRE_SCAN);
1745 cmd->header.length = cpu_to_le16(sizeof(*cmd));
1747 rc = mwl8k_post_cmd(hw, &cmd->header);
1754 * CMD_SET_POST_SCAN.
1756 struct mwl8k_cmd_set_post_scan {
1757 struct mwl8k_cmd_pkt header;
1759 __u8 bssid[ETH_ALEN];
1760 } __attribute__((packed));
1763 mwl8k_cmd_set_post_scan(struct ieee80211_hw *hw, __u8 *mac)
1765 struct mwl8k_cmd_set_post_scan *cmd;
1768 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
1772 cmd->header.code = cpu_to_le16(MWL8K_CMD_SET_POST_SCAN);
1773 cmd->header.length = cpu_to_le16(sizeof(*cmd));
1775 memcpy(cmd->bssid, mac, ETH_ALEN);
1777 rc = mwl8k_post_cmd(hw, &cmd->header);
1784 * CMD_SET_RF_CHANNEL.
1786 struct mwl8k_cmd_set_rf_channel {
1787 struct mwl8k_cmd_pkt header;
1789 __u8 current_channel;
1790 __le32 channel_flags;
1791 } __attribute__((packed));
1793 static int mwl8k_cmd_set_rf_channel(struct ieee80211_hw *hw,
1794 struct ieee80211_channel *channel)
1796 struct mwl8k_cmd_set_rf_channel *cmd;
1799 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
1803 cmd->header.code = cpu_to_le16(MWL8K_CMD_SET_RF_CHANNEL);
1804 cmd->header.length = cpu_to_le16(sizeof(*cmd));
1805 cmd->action = cpu_to_le16(MWL8K_CMD_SET);
1806 cmd->current_channel = channel->hw_value;
1807 if (channel->band == IEEE80211_BAND_2GHZ)
1808 cmd->channel_flags = cpu_to_le32(0x00000081);
1810 cmd->channel_flags = cpu_to_le32(0x00000000);
1812 rc = mwl8k_post_cmd(hw, &cmd->header);
1821 struct mwl8k_cmd_set_slot {
1822 struct mwl8k_cmd_pkt header;
1825 } __attribute__((packed));
1827 static int mwl8k_cmd_set_slot(struct ieee80211_hw *hw, bool short_slot_time)
1829 struct mwl8k_cmd_set_slot *cmd;
1832 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
1836 cmd->header.code = cpu_to_le16(MWL8K_CMD_SET_SLOT);
1837 cmd->header.length = cpu_to_le16(sizeof(*cmd));
1838 cmd->action = cpu_to_le16(MWL8K_CMD_SET);
1839 cmd->short_slot = short_slot_time;
1841 rc = mwl8k_post_cmd(hw, &cmd->header);
1850 struct mwl8k_cmd_mimo_config {
1851 struct mwl8k_cmd_pkt header;
1853 __u8 rx_antenna_map;
1854 __u8 tx_antenna_map;
1855 } __attribute__((packed));
1857 static int mwl8k_cmd_mimo_config(struct ieee80211_hw *hw, __u8 rx, __u8 tx)
1859 struct mwl8k_cmd_mimo_config *cmd;
1862 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
1866 cmd->header.code = cpu_to_le16(MWL8K_CMD_MIMO_CONFIG);
1867 cmd->header.length = cpu_to_le16(sizeof(*cmd));
1868 cmd->action = cpu_to_le32((u32)MWL8K_CMD_SET);
1869 cmd->rx_antenna_map = rx;
1870 cmd->tx_antenna_map = tx;
1872 rc = mwl8k_post_cmd(hw, &cmd->header);
1879 * CMD_ENABLE_SNIFFER.
1881 struct mwl8k_cmd_enable_sniffer {
1882 struct mwl8k_cmd_pkt header;
1884 } __attribute__((packed));
1886 static int mwl8k_enable_sniffer(struct ieee80211_hw *hw, bool enable)
1888 struct mwl8k_cmd_enable_sniffer *cmd;
1891 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
1895 cmd->header.code = cpu_to_le16(MWL8K_CMD_ENABLE_SNIFFER);
1896 cmd->header.length = cpu_to_le16(sizeof(*cmd));
1897 cmd->action = cpu_to_le32(!!enable);
1899 rc = mwl8k_post_cmd(hw, &cmd->header);
1906 * CMD_SET_RATEADAPT_MODE.
1908 struct mwl8k_cmd_set_rate_adapt_mode {
1909 struct mwl8k_cmd_pkt header;
1912 } __attribute__((packed));
1914 static int mwl8k_cmd_setrateadaptmode(struct ieee80211_hw *hw, __u16 mode)
1916 struct mwl8k_cmd_set_rate_adapt_mode *cmd;
1919 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
1923 cmd->header.code = cpu_to_le16(MWL8K_CMD_SET_RATEADAPT_MODE);
1924 cmd->header.length = cpu_to_le16(sizeof(*cmd));
1925 cmd->action = cpu_to_le16(MWL8K_CMD_SET);
1926 cmd->mode = cpu_to_le16(mode);
1928 rc = mwl8k_post_cmd(hw, &cmd->header);
1937 struct mwl8k_cmd_set_wmm {
1938 struct mwl8k_cmd_pkt header;
1940 } __attribute__((packed));
1942 static int mwl8k_set_wmm(struct ieee80211_hw *hw, bool enable)
1944 struct mwl8k_priv *priv = hw->priv;
1945 struct mwl8k_cmd_set_wmm *cmd;
1948 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
1952 cmd->header.code = cpu_to_le16(MWL8K_CMD_SET_WMM_MODE);
1953 cmd->header.length = cpu_to_le16(sizeof(*cmd));
1954 cmd->action = cpu_to_le16(!!enable);
1956 rc = mwl8k_post_cmd(hw, &cmd->header);
1960 priv->wmm_enabled = enable;
1966 * CMD_SET_RTS_THRESHOLD.
1968 struct mwl8k_cmd_rts_threshold {
1969 struct mwl8k_cmd_pkt header;
1972 } __attribute__((packed));
1974 static int mwl8k_rts_threshold(struct ieee80211_hw *hw,
1975 u16 action, u16 threshold)
1977 struct mwl8k_cmd_rts_threshold *cmd;
1980 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
1984 cmd->header.code = cpu_to_le16(MWL8K_CMD_RTS_THRESHOLD);
1985 cmd->header.length = cpu_to_le16(sizeof(*cmd));
1986 cmd->action = cpu_to_le16(action);
1987 cmd->threshold = cpu_to_le16(threshold);
1989 rc = mwl8k_post_cmd(hw, &cmd->header);
1996 * CMD_SET_EDCA_PARAMS.
1998 struct mwl8k_cmd_set_edca_params {
1999 struct mwl8k_cmd_pkt header;
2001 /* See MWL8K_SET_EDCA_XXX below */
2004 /* TX opportunity in units of 32 us */
2007 /* Log exponent of max contention period: 0...15*/
2010 /* Log exponent of min contention period: 0...15 */
2013 /* Adaptive interframe spacing in units of 32us */
2016 /* TX queue to configure */
2018 } __attribute__((packed));
2020 #define MWL8K_SET_EDCA_CW 0x01
2021 #define MWL8K_SET_EDCA_TXOP 0x02
2022 #define MWL8K_SET_EDCA_AIFS 0x04
2024 #define MWL8K_SET_EDCA_ALL (MWL8K_SET_EDCA_CW | \
2025 MWL8K_SET_EDCA_TXOP | \
2026 MWL8K_SET_EDCA_AIFS)
2029 mwl8k_set_edca_params(struct ieee80211_hw *hw, __u8 qnum,
2030 __u16 cw_min, __u16 cw_max,
2031 __u8 aifs, __u16 txop)
2033 struct mwl8k_cmd_set_edca_params *cmd;
2036 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
2040 cmd->header.code = cpu_to_le16(MWL8K_CMD_SET_EDCA_PARAMS);
2041 cmd->header.length = cpu_to_le16(sizeof(*cmd));
2042 cmd->action = cpu_to_le16(MWL8K_SET_EDCA_ALL);
2043 cmd->txop = cpu_to_le16(txop);
2044 cmd->log_cw_max = (u8)ilog2(cw_max + 1);
2045 cmd->log_cw_min = (u8)ilog2(cw_min + 1);
2049 rc = mwl8k_post_cmd(hw, &cmd->header);
2056 * CMD_FINALIZE_JOIN.
2059 /* FJ beacon buffer size is compiled into the firmware. */
2060 #define MWL8K_FJ_BEACON_MAXLEN 128
2062 struct mwl8k_cmd_finalize_join {
2063 struct mwl8k_cmd_pkt header;
2064 __le32 sleep_interval; /* Number of beacon periods to sleep */
2065 __u8 beacon_data[MWL8K_FJ_BEACON_MAXLEN];
2066 } __attribute__((packed));
2068 static int mwl8k_finalize_join(struct ieee80211_hw *hw, void *frame,
2069 __u16 framelen, __u16 dtim)
2071 struct mwl8k_cmd_finalize_join *cmd;
2072 struct ieee80211_mgmt *payload = frame;
2080 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
2084 cmd->header.code = cpu_to_le16(MWL8K_CMD_SET_FINALIZE_JOIN);
2085 cmd->header.length = cpu_to_le16(sizeof(*cmd));
2086 cmd->sleep_interval = cpu_to_le32(dtim ? dtim : 1);
2088 hdrlen = ieee80211_hdrlen(payload->frame_control);
2090 payload_len = framelen > hdrlen ? framelen - hdrlen : 0;
2092 /* XXX TBD Might just have to abort and return an error */
2093 if (payload_len > MWL8K_FJ_BEACON_MAXLEN)
2094 printk(KERN_ERR "%s(): WARNING: Incomplete beacon "
2095 "sent to firmware. Sz=%u MAX=%u\n", __func__,
2096 payload_len, MWL8K_FJ_BEACON_MAXLEN);
2098 if (payload_len > MWL8K_FJ_BEACON_MAXLEN)
2099 payload_len = MWL8K_FJ_BEACON_MAXLEN;
2101 if (payload && payload_len)
2102 memcpy(cmd->beacon_data, &payload->u.beacon, payload_len);
2104 rc = mwl8k_post_cmd(hw, &cmd->header);
2112 struct mwl8k_cmd_update_sta_db {
2113 struct mwl8k_cmd_pkt header;
2115 /* See STADB_ACTION_TYPE */
2118 /* Peer MAC address */
2119 __u8 peer_addr[ETH_ALEN];
2123 /* Peer info - valid during add/update. */
2124 struct peer_capability_info peer_info;
2125 } __attribute__((packed));
2127 static int mwl8k_cmd_update_sta_db(struct ieee80211_hw *hw,
2128 struct ieee80211_vif *vif, __u32 action)
2130 struct mwl8k_vif *mv_vif = MWL8K_VIF(vif);
2131 struct ieee80211_bss_conf *info = &mv_vif->bss_info;
2132 struct mwl8k_cmd_update_sta_db *cmd;
2133 struct peer_capability_info *peer_info;
2134 struct ieee80211_rate *bitrates = mv_vif->legacy_rates;
2138 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
2142 cmd->header.code = cpu_to_le16(MWL8K_CMD_UPDATE_STADB);
2143 cmd->header.length = cpu_to_le16(sizeof(*cmd));
2145 cmd->action = cpu_to_le32(action);
2146 peer_info = &cmd->peer_info;
2147 memcpy(cmd->peer_addr, mv_vif->bssid, ETH_ALEN);
2150 case MWL8K_STA_DB_ADD_ENTRY:
2151 case MWL8K_STA_DB_MODIFY_ENTRY:
2152 /* Build peer_info block */
2153 peer_info->peer_type = MWL8K_PEER_TYPE_ACCESSPOINT;
2154 peer_info->basic_caps = cpu_to_le16(info->assoc_capability);
2155 peer_info->interop = 1;
2156 peer_info->amsdu_enabled = 0;
2158 rates = peer_info->legacy_rates;
2159 for (count = 0; count < mv_vif->legacy_nrates; count++)
2160 rates[count] = bitrates[count].hw_value;
2162 rc = mwl8k_post_cmd(hw, &cmd->header);
2164 mv_vif->peer_id = peer_info->station_id;
2168 case MWL8K_STA_DB_DEL_ENTRY:
2169 case MWL8K_STA_DB_FLUSH:
2171 rc = mwl8k_post_cmd(hw, &cmd->header);
2173 mv_vif->peer_id = 0;
2184 #define MWL8K_RATE_INDEX_MAX_ARRAY 14
2186 #define MWL8K_FRAME_PROT_DISABLED 0x00
2187 #define MWL8K_FRAME_PROT_11G 0x07
2188 #define MWL8K_FRAME_PROT_11N_HT_40MHZ_ONLY 0x02
2189 #define MWL8K_FRAME_PROT_11N_HT_ALL 0x06
2191 struct mwl8k_cmd_update_set_aid {
2192 struct mwl8k_cmd_pkt header;
2195 /* AP's MAC address (BSSID) */
2196 __u8 bssid[ETH_ALEN];
2197 __le16 protection_mode;
2198 __u8 supp_rates[MWL8K_RATE_INDEX_MAX_ARRAY];
2199 } __attribute__((packed));
2201 static int mwl8k_cmd_set_aid(struct ieee80211_hw *hw,
2202 struct ieee80211_vif *vif)
2204 struct mwl8k_vif *mv_vif = MWL8K_VIF(vif);
2205 struct ieee80211_bss_conf *info = &mv_vif->bss_info;
2206 struct mwl8k_cmd_update_set_aid *cmd;
2207 struct ieee80211_rate *bitrates = mv_vif->legacy_rates;
2212 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
2216 cmd->header.code = cpu_to_le16(MWL8K_CMD_SET_AID);
2217 cmd->header.length = cpu_to_le16(sizeof(*cmd));
2218 cmd->aid = cpu_to_le16(info->aid);
2220 memcpy(cmd->bssid, mv_vif->bssid, ETH_ALEN);
2222 if (info->use_cts_prot) {
2223 prot_mode = MWL8K_FRAME_PROT_11G;
2225 switch (info->ht_operation_mode &
2226 IEEE80211_HT_OP_MODE_PROTECTION) {
2227 case IEEE80211_HT_OP_MODE_PROTECTION_20MHZ:
2228 prot_mode = MWL8K_FRAME_PROT_11N_HT_40MHZ_ONLY;
2230 case IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED:
2231 prot_mode = MWL8K_FRAME_PROT_11N_HT_ALL;
2234 prot_mode = MWL8K_FRAME_PROT_DISABLED;
2238 cmd->protection_mode = cpu_to_le16(prot_mode);
2240 for (count = 0; count < mv_vif->legacy_nrates; count++)
2241 cmd->supp_rates[count] = bitrates[count].hw_value;
2243 rc = mwl8k_post_cmd(hw, &cmd->header);
2252 struct mwl8k_cmd_update_rateset {
2253 struct mwl8k_cmd_pkt header;
2254 __u8 legacy_rates[MWL8K_RATE_INDEX_MAX_ARRAY];
2256 /* Bitmap for supported MCS codes. */
2257 __u8 mcs_set[MWL8K_IEEE_LEGACY_DATA_RATES];
2258 __u8 reserved[MWL8K_IEEE_LEGACY_DATA_RATES];
2259 } __attribute__((packed));
2261 static int mwl8k_update_rateset(struct ieee80211_hw *hw,
2262 struct ieee80211_vif *vif)
2264 struct mwl8k_vif *mv_vif = MWL8K_VIF(vif);
2265 struct mwl8k_cmd_update_rateset *cmd;
2266 struct ieee80211_rate *bitrates = mv_vif->legacy_rates;
2270 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
2274 cmd->header.code = cpu_to_le16(MWL8K_CMD_SET_RATE);
2275 cmd->header.length = cpu_to_le16(sizeof(*cmd));
2277 for (count = 0; count < mv_vif->legacy_nrates; count++)
2278 cmd->legacy_rates[count] = bitrates[count].hw_value;
2280 rc = mwl8k_post_cmd(hw, &cmd->header);
2287 * CMD_USE_FIXED_RATE.
2289 #define MWL8K_RATE_TABLE_SIZE 8
2290 #define MWL8K_UCAST_RATE 0
2291 #define MWL8K_USE_AUTO_RATE 0x0002
2293 struct mwl8k_rate_entry {
2294 /* Set to 1 if HT rate, 0 if legacy. */
2297 /* Set to 1 to use retry_count field. */
2298 __le32 enable_retry;
2300 /* Specified legacy rate or MCS. */
2303 /* Number of allowed retries. */
2305 } __attribute__((packed));
2307 struct mwl8k_rate_table {
2308 /* 1 to allow specified rate and below */
2309 __le32 allow_rate_drop;
2311 struct mwl8k_rate_entry rate_entry[MWL8K_RATE_TABLE_SIZE];
2312 } __attribute__((packed));
2314 struct mwl8k_cmd_use_fixed_rate {
2315 struct mwl8k_cmd_pkt header;
2317 struct mwl8k_rate_table rate_table;
2319 /* Unicast, Broadcast or Multicast */
2323 } __attribute__((packed));
2325 static int mwl8k_cmd_use_fixed_rate(struct ieee80211_hw *hw,
2326 u32 action, u32 rate_type, struct mwl8k_rate_table *rate_table)
2328 struct mwl8k_cmd_use_fixed_rate *cmd;
2332 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
2336 cmd->header.code = cpu_to_le16(MWL8K_CMD_USE_FIXED_RATE);
2337 cmd->header.length = cpu_to_le16(sizeof(*cmd));
2339 cmd->action = cpu_to_le32(action);
2340 cmd->rate_type = cpu_to_le32(rate_type);
2342 if (rate_table != NULL) {
2344 * Copy over each field manually so that endian
2345 * conversion can be done.
2347 cmd->rate_table.allow_rate_drop =
2348 cpu_to_le32(rate_table->allow_rate_drop);
2349 cmd->rate_table.num_rates =
2350 cpu_to_le32(rate_table->num_rates);
2352 for (count = 0; count < rate_table->num_rates; count++) {
2353 struct mwl8k_rate_entry *dst =
2354 &cmd->rate_table.rate_entry[count];
2355 struct mwl8k_rate_entry *src =
2356 &rate_table->rate_entry[count];
2358 dst->is_ht_rate = cpu_to_le32(src->is_ht_rate);
2359 dst->enable_retry = cpu_to_le32(src->enable_retry);
2360 dst->rate = cpu_to_le32(src->rate);
2361 dst->retry_count = cpu_to_le32(src->retry_count);
2365 rc = mwl8k_post_cmd(hw, &cmd->header);
2373 * Interrupt handling.
2375 static irqreturn_t mwl8k_interrupt(int irq, void *dev_id)
2377 struct ieee80211_hw *hw = dev_id;
2378 struct mwl8k_priv *priv = hw->priv;
2381 status = ioread32(priv->regs + MWL8K_HIU_A2H_INTERRUPT_STATUS);
2382 iowrite32(~status, priv->regs + MWL8K_HIU_A2H_INTERRUPT_STATUS);
2387 if (status & MWL8K_A2H_INT_TX_DONE)
2388 tasklet_schedule(&priv->tx_reclaim_task);
2390 if (status & MWL8K_A2H_INT_RX_READY) {
2391 while (rxq_process(hw, 0, 1))
2392 rxq_refill(hw, 0, 1);
2395 if (status & MWL8K_A2H_INT_OPC_DONE) {
2396 if (priv->hostcmd_wait != NULL)
2397 complete(priv->hostcmd_wait);
2400 if (status & MWL8K_A2H_INT_QUEUE_EMPTY) {
2401 if (!mutex_is_locked(&priv->fw_mutex) &&
2402 priv->radio_on && priv->pending_tx_pkts)
2403 mwl8k_tx_start(priv);
2411 * Core driver operations.
2413 static int mwl8k_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
2415 struct mwl8k_priv *priv = hw->priv;
2416 int index = skb_get_queue_mapping(skb);
2419 if (priv->current_channel == NULL) {
2420 printk(KERN_DEBUG "%s: dropped TX frame since radio "
2421 "disabled\n", wiphy_name(hw->wiphy));
2423 return NETDEV_TX_OK;
2426 rc = mwl8k_txq_xmit(hw, index, skb);
2431 static int mwl8k_start(struct ieee80211_hw *hw)
2433 struct mwl8k_priv *priv = hw->priv;
2436 rc = request_irq(priv->pdev->irq, &mwl8k_interrupt,
2437 IRQF_SHARED, MWL8K_NAME, hw);
2439 printk(KERN_ERR "%s: failed to register IRQ handler\n",
2440 wiphy_name(hw->wiphy));
2444 /* Enable tx reclaim tasklet */
2445 tasklet_enable(&priv->tx_reclaim_task);
2447 /* Enable interrupts */
2448 iowrite32(MWL8K_A2H_EVENTS, priv->regs + MWL8K_HIU_A2H_INTERRUPT_MASK);
2450 rc = mwl8k_fw_lock(hw);
2452 rc = mwl8k_cmd_802_11_radio_enable(hw);
2455 rc = mwl8k_cmd_set_pre_scan(hw);
2458 rc = mwl8k_cmd_set_post_scan(hw,
2459 "\x00\x00\x00\x00\x00\x00");
2462 rc = mwl8k_cmd_setrateadaptmode(hw, 0);
2465 rc = mwl8k_set_wmm(hw, 0);
2468 rc = mwl8k_enable_sniffer(hw, 0);
2470 mwl8k_fw_unlock(hw);
2474 iowrite32(0, priv->regs + MWL8K_HIU_A2H_INTERRUPT_MASK);
2475 free_irq(priv->pdev->irq, hw);
2476 tasklet_disable(&priv->tx_reclaim_task);
2482 static void mwl8k_stop(struct ieee80211_hw *hw)
2484 struct mwl8k_priv *priv = hw->priv;
2487 mwl8k_cmd_802_11_radio_disable(hw);
2489 ieee80211_stop_queues(hw);
2491 /* Disable interrupts */
2492 iowrite32(0, priv->regs + MWL8K_HIU_A2H_INTERRUPT_MASK);
2493 free_irq(priv->pdev->irq, hw);
2495 /* Stop finalize join worker */
2496 cancel_work_sync(&priv->finalize_join_worker);
2497 if (priv->beacon_skb != NULL)
2498 dev_kfree_skb(priv->beacon_skb);
2500 /* Stop tx reclaim tasklet */
2501 tasklet_disable(&priv->tx_reclaim_task);
2503 /* Return all skbs to mac80211 */
2504 for (i = 0; i < MWL8K_TX_QUEUES; i++)
2505 mwl8k_txq_reclaim(hw, i, 1);
2508 static int mwl8k_add_interface(struct ieee80211_hw *hw,
2509 struct ieee80211_if_init_conf *conf)
2511 struct mwl8k_priv *priv = hw->priv;
2512 struct mwl8k_vif *mwl8k_vif;
2515 * We only support one active interface at a time.
2517 if (priv->vif != NULL)
2521 * We only support managed interfaces for now.
2523 if (conf->type != NL80211_IFTYPE_STATION)
2526 /* Clean out driver private area */
2527 mwl8k_vif = MWL8K_VIF(conf->vif);
2528 memset(mwl8k_vif, 0, sizeof(*mwl8k_vif));
2530 /* Save the mac address */
2531 memcpy(mwl8k_vif->mac_addr, conf->mac_addr, ETH_ALEN);
2533 /* Back pointer to parent config block */
2534 mwl8k_vif->priv = priv;
2536 /* Setup initial PHY parameters */
2537 memcpy(mwl8k_vif->legacy_rates,
2538 priv->rates, sizeof(mwl8k_vif->legacy_rates));
2539 mwl8k_vif->legacy_nrates = ARRAY_SIZE(priv->rates);
2541 /* Set Initial sequence number to zero */
2542 mwl8k_vif->seqno = 0;
2544 priv->vif = conf->vif;
2545 priv->current_channel = NULL;
2550 static void mwl8k_remove_interface(struct ieee80211_hw *hw,
2551 struct ieee80211_if_init_conf *conf)
2553 struct mwl8k_priv *priv = hw->priv;
2555 if (priv->vif == NULL)
2561 static int mwl8k_config(struct ieee80211_hw *hw, u32 changed)
2563 struct ieee80211_conf *conf = &hw->conf;
2564 struct mwl8k_priv *priv = hw->priv;
2567 if (conf->flags & IEEE80211_CONF_IDLE) {
2568 mwl8k_cmd_802_11_radio_disable(hw);
2569 priv->current_channel = NULL;
2573 rc = mwl8k_fw_lock(hw);
2577 rc = mwl8k_cmd_802_11_radio_enable(hw);
2581 rc = mwl8k_cmd_set_rf_channel(hw, conf->channel);
2585 priv->current_channel = conf->channel;
2587 if (conf->power_level > 18)
2588 conf->power_level = 18;
2589 rc = mwl8k_cmd_802_11_rf_tx_power(hw, conf->power_level);
2593 if (mwl8k_cmd_mimo_config(hw, 0x7, 0x7))
2597 mwl8k_fw_unlock(hw);
2602 static void mwl8k_bss_info_changed(struct ieee80211_hw *hw,
2603 struct ieee80211_vif *vif,
2604 struct ieee80211_bss_conf *info,
2607 struct mwl8k_priv *priv = hw->priv;
2608 struct mwl8k_vif *mwl8k_vif = MWL8K_VIF(vif);
2611 if (changed & BSS_CHANGED_BSSID)
2612 memcpy(mwl8k_vif->bssid, info->bssid, ETH_ALEN);
2614 if ((changed & BSS_CHANGED_ASSOC) == 0)
2617 priv->capture_beacon = false;
2619 rc = mwl8k_fw_lock(hw);
2624 memcpy(&mwl8k_vif->bss_info, info,
2625 sizeof(struct ieee80211_bss_conf));
2628 rc = mwl8k_update_rateset(hw, vif);
2632 /* Turn on rate adaptation */
2633 rc = mwl8k_cmd_use_fixed_rate(hw, MWL8K_USE_AUTO_RATE,
2634 MWL8K_UCAST_RATE, NULL);
2638 /* Set radio preamble */
2639 rc = mwl8k_set_radio_preamble(hw, info->use_short_preamble);
2644 rc = mwl8k_cmd_set_slot(hw, info->use_short_slot);
2648 /* Update peer rate info */
2649 rc = mwl8k_cmd_update_sta_db(hw, vif,
2650 MWL8K_STA_DB_MODIFY_ENTRY);
2655 rc = mwl8k_cmd_set_aid(hw, vif);
2660 * Finalize the join. Tell rx handler to process
2661 * next beacon from our BSSID.
2663 memcpy(priv->capture_bssid, mwl8k_vif->bssid, ETH_ALEN);
2664 priv->capture_beacon = true;
2666 rc = mwl8k_cmd_update_sta_db(hw, vif, MWL8K_STA_DB_DEL_ENTRY);
2667 memset(&mwl8k_vif->bss_info, 0,
2668 sizeof(struct ieee80211_bss_conf));
2669 memset(mwl8k_vif->bssid, 0, ETH_ALEN);
2673 mwl8k_fw_unlock(hw);
2676 static u64 mwl8k_prepare_multicast(struct ieee80211_hw *hw,
2677 int mc_count, struct dev_addr_list *mclist)
2679 struct mwl8k_cmd_pkt *cmd;
2682 * Synthesize and return a command packet that programs the
2683 * hardware multicast address filter. At this point we don't
2684 * know whether FIF_ALLMULTI is being requested, but if it is,
2685 * we'll end up throwing this packet away and creating a new
2686 * one in mwl8k_configure_filter().
2688 cmd = __mwl8k_cmd_mac_multicast_adr(hw, 0, mc_count, mclist);
2690 return (unsigned long)cmd;
2693 static void mwl8k_configure_filter(struct ieee80211_hw *hw,
2694 unsigned int changed_flags,
2695 unsigned int *total_flags,
2698 struct mwl8k_priv *priv = hw->priv;
2699 struct mwl8k_cmd_pkt *cmd;
2701 /* Clear unsupported feature flags */
2702 *total_flags &= FIF_ALLMULTI | FIF_BCN_PRBRESP_PROMISC;
2704 if (mwl8k_fw_lock(hw))
2707 if (changed_flags & FIF_BCN_PRBRESP_PROMISC) {
2708 if (*total_flags & FIF_BCN_PRBRESP_PROMISC) {
2710 * Disable the BSS filter.
2712 mwl8k_cmd_set_pre_scan(hw);
2717 * Enable the BSS filter.
2719 * If there is an active STA interface, use that
2720 * interface's BSSID, otherwise use a dummy one
2721 * (where the OUI part needs to be nonzero for
2722 * the BSSID to be accepted by POST_SCAN).
2724 bssid = "\x01\x00\x00\x00\x00\x00";
2725 if (priv->vif != NULL)
2726 bssid = MWL8K_VIF(priv->vif)->bssid;
2728 mwl8k_cmd_set_post_scan(hw, bssid);
2732 cmd = (void *)(unsigned long)multicast;
2735 * If FIF_ALLMULTI is being requested, throw away the command
2736 * packet that ->prepare_multicast() built and replace it with
2737 * a command packet that enables reception of all multicast
2740 if (*total_flags & FIF_ALLMULTI) {
2742 cmd = __mwl8k_cmd_mac_multicast_adr(hw, 1, 0, NULL);
2746 mwl8k_post_cmd(hw, cmd);
2750 mwl8k_fw_unlock(hw);
2753 static int mwl8k_set_rts_threshold(struct ieee80211_hw *hw, u32 value)
2755 return mwl8k_rts_threshold(hw, MWL8K_CMD_SET, value);
2758 static int mwl8k_conf_tx(struct ieee80211_hw *hw, u16 queue,
2759 const struct ieee80211_tx_queue_params *params)
2761 struct mwl8k_priv *priv = hw->priv;
2764 rc = mwl8k_fw_lock(hw);
2766 if (!priv->wmm_enabled)
2767 rc = mwl8k_set_wmm(hw, 1);
2770 rc = mwl8k_set_edca_params(hw, queue,
2776 mwl8k_fw_unlock(hw);
2782 static int mwl8k_get_tx_stats(struct ieee80211_hw *hw,
2783 struct ieee80211_tx_queue_stats *stats)
2785 struct mwl8k_priv *priv = hw->priv;
2786 struct mwl8k_tx_queue *txq;
2789 spin_lock_bh(&priv->tx_lock);
2790 for (index = 0; index < MWL8K_TX_QUEUES; index++) {
2791 txq = priv->txq + index;
2792 memcpy(&stats[index], &txq->tx_stats,
2793 sizeof(struct ieee80211_tx_queue_stats));
2795 spin_unlock_bh(&priv->tx_lock);
2800 static int mwl8k_get_stats(struct ieee80211_hw *hw,
2801 struct ieee80211_low_level_stats *stats)
2803 return mwl8k_cmd_802_11_get_stat(hw, stats);
2806 static const struct ieee80211_ops mwl8k_ops = {
2808 .start = mwl8k_start,
2810 .add_interface = mwl8k_add_interface,
2811 .remove_interface = mwl8k_remove_interface,
2812 .config = mwl8k_config,
2813 .bss_info_changed = mwl8k_bss_info_changed,
2814 .prepare_multicast = mwl8k_prepare_multicast,
2815 .configure_filter = mwl8k_configure_filter,
2816 .set_rts_threshold = mwl8k_set_rts_threshold,
2817 .conf_tx = mwl8k_conf_tx,
2818 .get_tx_stats = mwl8k_get_tx_stats,
2819 .get_stats = mwl8k_get_stats,
2822 static void mwl8k_tx_reclaim_handler(unsigned long data)
2825 struct ieee80211_hw *hw = (struct ieee80211_hw *) data;
2826 struct mwl8k_priv *priv = hw->priv;
2828 spin_lock_bh(&priv->tx_lock);
2829 for (i = 0; i < MWL8K_TX_QUEUES; i++)
2830 mwl8k_txq_reclaim(hw, i, 0);
2832 if (priv->tx_wait != NULL && !priv->pending_tx_pkts) {
2833 complete(priv->tx_wait);
2834 priv->tx_wait = NULL;
2836 spin_unlock_bh(&priv->tx_lock);
2839 static void mwl8k_finalize_join_worker(struct work_struct *work)
2841 struct mwl8k_priv *priv =
2842 container_of(work, struct mwl8k_priv, finalize_join_worker);
2843 struct sk_buff *skb = priv->beacon_skb;
2844 u8 dtim = MWL8K_VIF(priv->vif)->bss_info.dtim_period;
2846 mwl8k_finalize_join(priv->hw, skb->data, skb->len, dtim);
2849 priv->beacon_skb = NULL;
2852 static int __devinit mwl8k_probe(struct pci_dev *pdev,
2853 const struct pci_device_id *id)
2855 static int printed_version = 0;
2856 struct ieee80211_hw *hw;
2857 struct mwl8k_priv *priv;
2861 if (!printed_version) {
2862 printk(KERN_INFO "%s version %s\n", MWL8K_DESC, MWL8K_VERSION);
2863 printed_version = 1;
2866 rc = pci_enable_device(pdev);
2868 printk(KERN_ERR "%s: Cannot enable new PCI device\n",
2873 rc = pci_request_regions(pdev, MWL8K_NAME);
2875 printk(KERN_ERR "%s: Cannot obtain PCI resources\n",
2880 pci_set_master(pdev);
2882 hw = ieee80211_alloc_hw(sizeof(*priv), &mwl8k_ops);
2884 printk(KERN_ERR "%s: ieee80211 alloc failed\n", MWL8K_NAME);
2892 priv->wmm_enabled = false;
2893 priv->pending_tx_pkts = 0;
2895 SET_IEEE80211_DEV(hw, &pdev->dev);
2896 pci_set_drvdata(pdev, hw);
2898 priv->regs = pci_iomap(pdev, 1, 0x10000);
2899 if (priv->regs == NULL) {
2900 printk(KERN_ERR "%s: Cannot map device memory\n",
2901 wiphy_name(hw->wiphy));
2905 memcpy(priv->channels, mwl8k_channels, sizeof(mwl8k_channels));
2906 priv->band.band = IEEE80211_BAND_2GHZ;
2907 priv->band.channels = priv->channels;
2908 priv->band.n_channels = ARRAY_SIZE(mwl8k_channels);
2909 priv->band.bitrates = priv->rates;
2910 priv->band.n_bitrates = ARRAY_SIZE(mwl8k_rates);
2911 hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &priv->band;
2913 BUILD_BUG_ON(sizeof(priv->rates) != sizeof(mwl8k_rates));
2914 memcpy(priv->rates, mwl8k_rates, sizeof(mwl8k_rates));
2917 * Extra headroom is the size of the required DMA header
2918 * minus the size of the smallest 802.11 frame (CTS frame).
2920 hw->extra_tx_headroom =
2921 sizeof(struct mwl8k_dma_data) - sizeof(struct ieee80211_cts);
2923 hw->channel_change_time = 10;
2925 hw->queues = MWL8K_TX_QUEUES;
2927 hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION);
2929 /* Set rssi and noise values to dBm */
2930 hw->flags |= IEEE80211_HW_SIGNAL_DBM | IEEE80211_HW_NOISE_DBM;
2931 hw->vif_data_size = sizeof(struct mwl8k_vif);
2934 /* Set default radio state and preamble */
2936 priv->radio_short_preamble = 0;
2938 /* Finalize join worker */
2939 INIT_WORK(&priv->finalize_join_worker, mwl8k_finalize_join_worker);
2941 /* TX reclaim tasklet */
2942 tasklet_init(&priv->tx_reclaim_task,
2943 mwl8k_tx_reclaim_handler, (unsigned long)hw);
2944 tasklet_disable(&priv->tx_reclaim_task);
2946 /* Power management cookie */
2947 priv->cookie = pci_alloc_consistent(priv->pdev, 4, &priv->cookie_dma);
2948 if (priv->cookie == NULL)
2951 rc = mwl8k_rxq_init(hw, 0);
2954 rxq_refill(hw, 0, INT_MAX);
2956 mutex_init(&priv->fw_mutex);
2957 priv->fw_mutex_owner = NULL;
2958 priv->fw_mutex_depth = 0;
2959 priv->hostcmd_wait = NULL;
2961 spin_lock_init(&priv->tx_lock);
2963 priv->tx_wait = NULL;
2965 for (i = 0; i < MWL8K_TX_QUEUES; i++) {
2966 rc = mwl8k_txq_init(hw, i);
2968 goto err_free_queues;
2971 iowrite32(0, priv->regs + MWL8K_HIU_A2H_INTERRUPT_STATUS);
2972 iowrite32(0, priv->regs + MWL8K_HIU_A2H_INTERRUPT_MASK);
2973 iowrite32(0, priv->regs + MWL8K_HIU_A2H_INTERRUPT_CLEAR_SEL);
2974 iowrite32(0xffffffff, priv->regs + MWL8K_HIU_A2H_INTERRUPT_STATUS_MASK);
2976 rc = request_irq(priv->pdev->irq, &mwl8k_interrupt,
2977 IRQF_SHARED, MWL8K_NAME, hw);
2979 printk(KERN_ERR "%s: failed to register IRQ handler\n",
2980 wiphy_name(hw->wiphy));
2981 goto err_free_queues;
2984 /* Reset firmware and hardware */
2985 mwl8k_hw_reset(priv);
2987 /* Ask userland hotplug daemon for the device firmware */
2988 rc = mwl8k_request_firmware(priv, (u32)id->driver_data);
2990 printk(KERN_ERR "%s: Firmware files not found\n",
2991 wiphy_name(hw->wiphy));
2995 /* Load firmware into hardware */
2996 rc = mwl8k_load_firmware(hw);
2998 printk(KERN_ERR "%s: Cannot start firmware\n",
2999 wiphy_name(hw->wiphy));
3000 goto err_stop_firmware;
3003 /* Reclaim memory once firmware is successfully loaded */
3004 mwl8k_release_firmware(priv);
3007 * Temporarily enable interrupts. Initial firmware host
3008 * commands use interrupts and avoids polling. Disable
3009 * interrupts when done.
3011 iowrite32(MWL8K_A2H_EVENTS, priv->regs + MWL8K_HIU_A2H_INTERRUPT_MASK);
3013 /* Get config data, mac addrs etc */
3014 rc = mwl8k_cmd_get_hw_spec(hw);
3016 printk(KERN_ERR "%s: Cannot initialise firmware\n",
3017 wiphy_name(hw->wiphy));
3018 goto err_stop_firmware;
3021 /* Turn radio off */
3022 rc = mwl8k_cmd_802_11_radio_disable(hw);
3024 printk(KERN_ERR "%s: Cannot disable\n", wiphy_name(hw->wiphy));
3025 goto err_stop_firmware;
3028 /* Disable interrupts */
3029 iowrite32(0, priv->regs + MWL8K_HIU_A2H_INTERRUPT_MASK);
3030 free_irq(priv->pdev->irq, hw);
3032 rc = ieee80211_register_hw(hw);
3034 printk(KERN_ERR "%s: Cannot register device\n",
3035 wiphy_name(hw->wiphy));
3036 goto err_stop_firmware;
3039 printk(KERN_INFO "%s: 88w%u v%d, %pM, firmware version %u.%u.%u.%u\n",
3040 wiphy_name(hw->wiphy), priv->part_num, priv->hw_rev,
3041 hw->wiphy->perm_addr,
3042 (priv->fw_rev >> 24) & 0xff, (priv->fw_rev >> 16) & 0xff,
3043 (priv->fw_rev >> 8) & 0xff, priv->fw_rev & 0xff);
3048 mwl8k_hw_reset(priv);
3049 mwl8k_release_firmware(priv);
3052 iowrite32(0, priv->regs + MWL8K_HIU_A2H_INTERRUPT_MASK);
3053 free_irq(priv->pdev->irq, hw);
3056 for (i = 0; i < MWL8K_TX_QUEUES; i++)
3057 mwl8k_txq_deinit(hw, i);
3058 mwl8k_rxq_deinit(hw, 0);
3061 if (priv->cookie != NULL)
3062 pci_free_consistent(priv->pdev, 4,
3063 priv->cookie, priv->cookie_dma);
3065 if (priv->regs != NULL)
3066 pci_iounmap(pdev, priv->regs);
3068 pci_set_drvdata(pdev, NULL);
3069 ieee80211_free_hw(hw);
3072 pci_release_regions(pdev);
3073 pci_disable_device(pdev);
3078 static void __devexit mwl8k_shutdown(struct pci_dev *pdev)
3080 printk(KERN_ERR "===>%s(%u)\n", __func__, __LINE__);
3083 static void __devexit mwl8k_remove(struct pci_dev *pdev)
3085 struct ieee80211_hw *hw = pci_get_drvdata(pdev);
3086 struct mwl8k_priv *priv;
3093 ieee80211_stop_queues(hw);
3095 ieee80211_unregister_hw(hw);
3097 /* Remove tx reclaim tasklet */
3098 tasklet_kill(&priv->tx_reclaim_task);
3101 mwl8k_hw_reset(priv);
3103 /* Return all skbs to mac80211 */
3104 for (i = 0; i < MWL8K_TX_QUEUES; i++)
3105 mwl8k_txq_reclaim(hw, i, 1);
3107 for (i = 0; i < MWL8K_TX_QUEUES; i++)
3108 mwl8k_txq_deinit(hw, i);
3110 mwl8k_rxq_deinit(hw, 0);
3112 pci_free_consistent(priv->pdev, 4, priv->cookie, priv->cookie_dma);
3114 pci_iounmap(pdev, priv->regs);
3115 pci_set_drvdata(pdev, NULL);
3116 ieee80211_free_hw(hw);
3117 pci_release_regions(pdev);
3118 pci_disable_device(pdev);
3121 static struct pci_driver mwl8k_driver = {
3123 .id_table = mwl8k_table,
3124 .probe = mwl8k_probe,
3125 .remove = __devexit_p(mwl8k_remove),
3126 .shutdown = __devexit_p(mwl8k_shutdown),
3129 static int __init mwl8k_init(void)
3131 return pci_register_driver(&mwl8k_driver);
3134 static void __exit mwl8k_exit(void)
3136 pci_unregister_driver(&mwl8k_driver);
3139 module_init(mwl8k_init);
3140 module_exit(mwl8k_exit);
3142 MODULE_DESCRIPTION(MWL8K_DESC);
3143 MODULE_VERSION(MWL8K_VERSION);
3144 MODULE_AUTHOR("Lennert Buytenhek <buytenh@marvell.com>");
3145 MODULE_LICENSE("GPL");