3 * Copyright (C) 2002 Intersil Americas Inc.
4 * Copyright (C) 2003 Herbert Valerio Riedel <hvr@gnu.org>
5 * Copyright (C) 2003 Luis R. Rodriguez <mcgrof@ruslug.rutgers.edu>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include <linux/version.h>
23 #include <linux/module.h>
25 #include <linux/netdevice.h>
26 #include <linux/pci.h>
27 #include <linux/etherdevice.h>
28 #include <linux/delay.h>
29 #include <linux/if_arp.h>
33 #include "prismcompat.h"
35 #include "isl_ioctl.h"
36 #include "islpci_dev.h"
37 #include "islpci_mgt.h"
38 #include "islpci_eth.h"
41 #define ISL3877_IMAGE_FILE "isl3877"
42 #define ISL3886_IMAGE_FILE "isl3886"
43 #define ISL3890_IMAGE_FILE "isl3890"
45 static int prism54_bring_down(islpci_private *);
46 static int islpci_alloc_memory(islpci_private *);
48 /* Temporary dummy MAC address to use until firmware is loaded.
49 * The idea there is that some tools (such as nameif) may query
50 * the MAC address before the netdev is 'open'. By using a valid
51 * OUI prefix, they can process the netdev properly.
52 * Of course, this is not the final/real MAC address. It doesn't
53 * matter, as you are suppose to be able to change it anytime via
54 * ndev->set_mac_address. Jean II */
55 /* Set dummy address to 00:00:00:00:00:00 so tools have a chance
56 to find out that this is no real mac address - jg */
57 const unsigned char dummy_mac[6] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
60 isl_upload_firmware(islpci_private *priv)
63 void __iomem *device_base = priv->device_base;
65 /* clear the RAMBoot and the Reset bit */
66 reg = readl(device_base + ISL38XX_CTRL_STAT_REG);
67 reg &= ~ISL38XX_CTRL_STAT_RESET;
68 reg &= ~ISL38XX_CTRL_STAT_RAMBOOT;
69 writel(reg, device_base + ISL38XX_CTRL_STAT_REG);
71 udelay(ISL38XX_WRITEIO_DELAY);
73 /* set the Reset bit without reading the register ! */
74 reg |= ISL38XX_CTRL_STAT_RESET;
75 writel(reg, device_base + ISL38XX_CTRL_STAT_REG);
77 udelay(ISL38XX_WRITEIO_DELAY);
79 /* clear the Reset bit */
80 reg &= ~ISL38XX_CTRL_STAT_RESET;
81 writel(reg, device_base + ISL38XX_CTRL_STAT_REG);
84 /* wait a while for the device to reboot */
88 const struct firmware *fw_entry = NULL;
92 rc = request_firmware(&fw_entry, priv->firmware, PRISM_FW_PDEV);
95 "%s: request_firmware() failed for '%s'\n",
96 "prism54", priv->firmware);
99 /* prepare the Direct Memory Base register */
100 reg = ISL38XX_DEV_FIRMWARE_ADDRES;
102 fw_ptr = (u32 *) fw_entry->data;
103 fw_len = fw_entry->size;
107 "%s: firmware '%s' size is not multiple of 32bit, aborting!\n",
108 "prism54", priv->firmware);
109 release_firmware(fw_entry);
110 return -EILSEQ; /* Illegal byte sequence */;
116 ISL38XX_MEMORY_WINDOW_SIZE) ?
117 ISL38XX_MEMORY_WINDOW_SIZE : fw_len;
118 u32 __iomem *dev_fw_ptr = device_base + ISL38XX_DIRECT_MEM_WIN;
120 /* set the cards base address for writting the data */
121 isl38xx_w32_flush(device_base, reg,
122 ISL38XX_DIR_MEM_BASE_REG);
123 wmb(); /* be paranoid */
125 /* increment the write address for next iteration */
129 /* write the data to the Direct Memory Window 32bit-wise */
130 /* memcpy_toio() doesn't guarantee 32bit writes :-| */
131 while (_fw_len > 0) {
132 /* use non-swapping writel() */
133 __raw_writel(*fw_ptr, dev_fw_ptr);
134 fw_ptr++, dev_fw_ptr++;
138 /* flush PCI posting */
139 (void) readl(device_base + ISL38XX_PCI_POSTING_FLUSH);
140 wmb(); /* be paranoid again */
142 BUG_ON(_fw_len != 0);
147 /* Firmware version is at offset 40 (also for "newmac") */
148 printk(KERN_DEBUG "%s: firmware version: %.8s\n",
149 priv->ndev->name, fw_entry->data + 40);
151 release_firmware(fw_entry);
154 /* now reset the device
155 * clear the Reset & ClkRun bit, set the RAMBoot bit */
156 reg = readl(device_base + ISL38XX_CTRL_STAT_REG);
157 reg &= ~ISL38XX_CTRL_STAT_CLKRUN;
158 reg &= ~ISL38XX_CTRL_STAT_RESET;
159 reg |= ISL38XX_CTRL_STAT_RAMBOOT;
160 isl38xx_w32_flush(device_base, reg, ISL38XX_CTRL_STAT_REG);
162 udelay(ISL38XX_WRITEIO_DELAY);
164 /* set the reset bit latches the host override and RAMBoot bits
165 * into the device for operation when the reset bit is reset */
166 reg |= ISL38XX_CTRL_STAT_RESET;
167 writel(reg, device_base + ISL38XX_CTRL_STAT_REG);
168 /* don't do flush PCI posting here! */
170 udelay(ISL38XX_WRITEIO_DELAY);
172 /* clear the reset bit should start the whole circus */
173 reg &= ~ISL38XX_CTRL_STAT_RESET;
174 writel(reg, device_base + ISL38XX_CTRL_STAT_REG);
175 /* don't do flush PCI posting here! */
177 udelay(ISL38XX_WRITEIO_DELAY);
182 /******************************************************************************
183 Device Interrupt Handler
184 ******************************************************************************/
187 islpci_interrupt(int irq, void *config, struct pt_regs *regs)
190 islpci_private *priv = config;
191 struct net_device *ndev = priv->ndev;
192 void __iomem *device = priv->device_base;
193 int powerstate = ISL38XX_PSM_POWERSAVE_STATE;
195 /* lock the interrupt handler */
196 spin_lock(&priv->slock);
198 /* received an interrupt request on a shared IRQ line
199 * first check whether the device is in sleep mode */
200 reg = readl(device + ISL38XX_CTRL_STAT_REG);
201 if (reg & ISL38XX_CTRL_STAT_SLEEPMODE)
202 /* device is in sleep mode, IRQ was generated by someone else */
204 #if VERBOSE > SHOW_ERROR_MESSAGES
205 DEBUG(SHOW_TRACING, "Assuming someone else called the IRQ\n");
207 spin_unlock(&priv->slock);
212 /* check whether there is any source of interrupt on the device */
213 reg = readl(device + ISL38XX_INT_IDENT_REG);
215 /* also check the contents of the Interrupt Enable Register, because this
216 * will filter out interrupt sources from other devices on the same irq ! */
217 reg &= readl(device + ISL38XX_INT_EN_REG);
218 reg &= ISL38XX_INT_SOURCES;
221 if (islpci_get_state(priv) != PRV_STATE_SLEEP)
222 powerstate = ISL38XX_PSM_ACTIVE_STATE;
224 /* reset the request bits in the Identification register */
225 isl38xx_w32_flush(device, reg, ISL38XX_INT_ACK_REG);
227 #if VERBOSE > SHOW_ERROR_MESSAGES
228 DEBUG(SHOW_FUNCTION_CALLS,
229 "IRQ: Identification register 0x%p 0x%x \n", device, reg);
232 /* check for each bit in the register separately */
233 if (reg & ISL38XX_INT_IDENT_UPDATE) {
234 #if VERBOSE > SHOW_ERROR_MESSAGES
235 /* Queue has been updated */
236 DEBUG(SHOW_TRACING, "IRQ: Update flag \n");
238 DEBUG(SHOW_QUEUE_INDEXES,
239 "CB drv Qs: [%i][%i][%i][%i][%i][%i]\n",
240 le32_to_cpu(priv->control_block->
241 driver_curr_frag[0]),
242 le32_to_cpu(priv->control_block->
243 driver_curr_frag[1]),
244 le32_to_cpu(priv->control_block->
245 driver_curr_frag[2]),
246 le32_to_cpu(priv->control_block->
247 driver_curr_frag[3]),
248 le32_to_cpu(priv->control_block->
249 driver_curr_frag[4]),
250 le32_to_cpu(priv->control_block->
254 DEBUG(SHOW_QUEUE_INDEXES,
255 "CB dev Qs: [%i][%i][%i][%i][%i][%i]\n",
256 le32_to_cpu(priv->control_block->
257 device_curr_frag[0]),
258 le32_to_cpu(priv->control_block->
259 device_curr_frag[1]),
260 le32_to_cpu(priv->control_block->
261 device_curr_frag[2]),
262 le32_to_cpu(priv->control_block->
263 device_curr_frag[3]),
264 le32_to_cpu(priv->control_block->
265 device_curr_frag[4]),
266 le32_to_cpu(priv->control_block->
271 /* cleanup the data low transmit queue */
272 islpci_eth_cleanup_transmit(priv, priv->control_block);
274 /* device is in active state, update the
275 * powerstate flag if necessary */
276 powerstate = ISL38XX_PSM_ACTIVE_STATE;
278 /* check all three queues in priority order
279 * call the PIMFOR receive function until the
281 if (isl38xx_in_queue(priv->control_block,
282 ISL38XX_CB_RX_MGMTQ) != 0) {
283 #if VERBOSE > SHOW_ERROR_MESSAGES
285 "Received frame in Management Queue\n");
287 islpci_mgt_receive(ndev);
289 islpci_mgt_cleanup_transmit(ndev);
291 /* Refill slots in receive queue */
292 islpci_mgmt_rx_fill(ndev);
294 /* no need to trigger the device, next
295 islpci_mgt_transaction does it */
298 while (isl38xx_in_queue(priv->control_block,
299 ISL38XX_CB_RX_DATA_LQ) != 0) {
300 #if VERBOSE > SHOW_ERROR_MESSAGES
302 "Received frame in Data Low Queue \n");
304 islpci_eth_receive(priv);
307 /* check whether the data transmit queues were full */
308 if (priv->data_low_tx_full) {
309 /* check whether the transmit is not full anymore */
310 if (ISL38XX_CB_TX_QSIZE -
311 isl38xx_in_queue(priv->control_block,
312 ISL38XX_CB_TX_DATA_LQ) >=
313 ISL38XX_MIN_QTHRESHOLD) {
314 /* nope, the driver is ready for more network frames */
315 netif_wake_queue(priv->ndev);
317 /* reset the full flag */
318 priv->data_low_tx_full = 0;
323 if (reg & ISL38XX_INT_IDENT_INIT) {
324 /* Device has been initialized */
325 #if VERBOSE > SHOW_ERROR_MESSAGES
327 "IRQ: Init flag, device initialized \n");
329 wake_up(&priv->reset_done);
332 if (reg & ISL38XX_INT_IDENT_SLEEP) {
333 /* Device intends to move to powersave state */
334 #if VERBOSE > SHOW_ERROR_MESSAGES
335 DEBUG(SHOW_TRACING, "IRQ: Sleep flag \n");
337 isl38xx_handle_sleep_request(priv->control_block,
342 if (reg & ISL38XX_INT_IDENT_WAKEUP) {
343 /* Device has been woken up to active state */
344 #if VERBOSE > SHOW_ERROR_MESSAGES
345 DEBUG(SHOW_TRACING, "IRQ: Wakeup flag \n");
348 isl38xx_handle_wakeup(priv->control_block,
349 &powerstate, priv->device_base);
352 #if VERBOSE > SHOW_ERROR_MESSAGES
353 DEBUG(SHOW_TRACING, "Assuming someone else called the IRQ\n");
355 spin_unlock(&priv->slock);
360 if (islpci_get_state(priv) == PRV_STATE_SLEEP
361 && powerstate == ISL38XX_PSM_ACTIVE_STATE)
362 islpci_set_state(priv, PRV_STATE_READY);
364 /* !sleep -> sleep */
365 if (islpci_get_state(priv) != PRV_STATE_SLEEP
366 && powerstate == ISL38XX_PSM_POWERSAVE_STATE)
367 islpci_set_state(priv, PRV_STATE_SLEEP);
369 /* unlock the interrupt handler */
370 spin_unlock(&priv->slock);
375 /******************************************************************************
376 Network Interface Control & Statistical functions
377 ******************************************************************************/
379 islpci_open(struct net_device *ndev)
382 islpci_private *priv = netdev_priv(ndev);
384 /* reset data structures, upload firmware and reset device */
385 rc = islpci_reset(priv,1);
387 prism54_bring_down(priv);
388 return rc; /* Returns informative message */
391 netif_start_queue(ndev);
392 /* netif_mark_up( ndev ); */
398 islpci_close(struct net_device *ndev)
400 islpci_private *priv = netdev_priv(ndev);
402 printk(KERN_DEBUG "%s: islpci_close ()\n", ndev->name);
404 netif_stop_queue(ndev);
406 return prism54_bring_down(priv);
410 prism54_bring_down(islpci_private *priv)
412 void __iomem *device_base = priv->device_base;
414 /* we are going to shutdown the device */
415 islpci_set_state(priv, PRV_STATE_PREBOOT);
417 /* disable all device interrupts in case they weren't */
418 isl38xx_disable_interrupts(priv->device_base);
420 /* For safety reasons, we may want to ensure that no DMA transfer is
421 * currently in progress by emptying the TX and RX queues. */
423 /* wait until interrupts have finished executing on other CPUs */
424 synchronize_irq(priv->pdev->irq);
426 reg = readl(device_base + ISL38XX_CTRL_STAT_REG);
427 reg &= ~(ISL38XX_CTRL_STAT_RESET | ISL38XX_CTRL_STAT_RAMBOOT);
428 writel(reg, device_base + ISL38XX_CTRL_STAT_REG);
430 udelay(ISL38XX_WRITEIO_DELAY);
432 reg |= ISL38XX_CTRL_STAT_RESET;
433 writel(reg, device_base + ISL38XX_CTRL_STAT_REG);
435 udelay(ISL38XX_WRITEIO_DELAY);
437 /* clear the Reset bit */
438 reg &= ~ISL38XX_CTRL_STAT_RESET;
439 writel(reg, device_base + ISL38XX_CTRL_STAT_REG);
442 /* wait a while for the device to reset */
443 set_current_state(TASK_UNINTERRUPTIBLE);
444 schedule_timeout(50*HZ/1000);
450 islpci_upload_fw(islpci_private *priv)
452 islpci_state_t old_state;
455 old_state = islpci_set_state(priv, PRV_STATE_BOOT);
457 printk(KERN_DEBUG "%s: uploading firmware...\n", priv->ndev->name);
459 rc = isl_upload_firmware(priv);
461 /* error uploading the firmware */
462 printk(KERN_ERR "%s: could not upload firmware ('%s')\n",
463 priv->ndev->name, priv->firmware);
465 islpci_set_state(priv, old_state);
469 printk(KERN_DEBUG "%s: firmware upload complete\n",
472 islpci_set_state(priv, PRV_STATE_POSTBOOT);
478 islpci_reset_if(islpci_private *priv)
485 prepare_to_wait(&priv->reset_done, &wait, TASK_UNINTERRUPTIBLE);
487 /* now the last step is to reset the interface */
488 isl38xx_interface_reset(priv->device_base, priv->device_host_address);
489 islpci_set_state(priv, PRV_STATE_PREINIT);
491 for(count = 0; count < 2 && result; count++) {
492 /* The software reset acknowledge needs about 220 msec here.
493 * Be conservative and wait for up to one second. */
495 set_current_state(TASK_UNINTERRUPTIBLE);
496 remaining = schedule_timeout(HZ);
503 /* If we're here it's because our IRQ hasn't yet gone through.
504 * Retry a bit more...
506 printk(KERN_ERR "%s: no 'reset complete' IRQ seen - retrying\n",
510 finish_wait(&priv->reset_done, &wait);
513 printk(KERN_ERR "%s: interface reset failure\n", priv->ndev->name);
517 islpci_set_state(priv, PRV_STATE_INIT);
519 /* Now that the device is 100% up, let's allow
520 * for the other interrupts --
521 * NOTE: this is not *yet* true since we've only allowed the
522 * INIT interrupt on the IRQ line. We can perhaps poll
523 * the IRQ line until we know for sure the reset went through */
524 isl38xx_enable_common_interrupts(priv->device_base);
526 down_write(&priv->mib_sem);
527 result = mgt_commit(priv);
529 printk(KERN_ERR "%s: interface reset failure\n", priv->ndev->name);
530 up_write(&priv->mib_sem);
533 up_write(&priv->mib_sem);
535 islpci_set_state(priv, PRV_STATE_READY);
537 printk(KERN_DEBUG "%s: interface reset complete\n", priv->ndev->name);
542 islpci_reset(islpci_private *priv, int reload_firmware)
544 isl38xx_control_block *cb = /* volatile not needed */
545 (isl38xx_control_block *) priv->control_block;
550 islpci_set_state(priv, PRV_STATE_PREBOOT);
552 islpci_set_state(priv, PRV_STATE_POSTBOOT);
554 printk(KERN_DEBUG "%s: resetting device...\n", priv->ndev->name);
556 /* disable all device interrupts in case they weren't */
557 isl38xx_disable_interrupts(priv->device_base);
559 /* flush all management queues */
560 priv->index_mgmt_tx = 0;
561 priv->index_mgmt_rx = 0;
563 /* clear the indexes in the frame pointer */
564 for (counter = 0; counter < ISL38XX_CB_QCOUNT; counter++) {
565 cb->driver_curr_frag[counter] = cpu_to_le32(0);
566 cb->device_curr_frag[counter] = cpu_to_le32(0);
569 /* reset the mgmt receive queue */
570 for (counter = 0; counter < ISL38XX_CB_MGMT_QSIZE; counter++) {
571 isl38xx_fragment *frag = &cb->rx_data_mgmt[counter];
572 frag->size = cpu_to_le16(MGMT_FRAME_SIZE);
574 frag->address = cpu_to_le32(priv->mgmt_rx[counter].pci_addr);
577 for (counter = 0; counter < ISL38XX_CB_RX_QSIZE; counter++) {
578 cb->rx_data_low[counter].address =
579 cpu_to_le32((u32) priv->pci_map_rx_address[counter]);
582 /* since the receive queues are filled with empty fragments, now we can
583 * set the corresponding indexes in the Control Block */
584 priv->control_block->driver_curr_frag[ISL38XX_CB_RX_DATA_LQ] =
585 cpu_to_le32(ISL38XX_CB_RX_QSIZE);
586 priv->control_block->driver_curr_frag[ISL38XX_CB_RX_MGMTQ] =
587 cpu_to_le32(ISL38XX_CB_MGMT_QSIZE);
589 /* reset the remaining real index registers and full flags */
590 priv->free_data_rx = 0;
591 priv->free_data_tx = 0;
592 priv->data_low_tx_full = 0;
594 if (reload_firmware) { /* Should we load the firmware ? */
595 /* now that the data structures are cleaned up, upload
596 * firmware and reset interface */
597 rc = islpci_upload_fw(priv);
599 printk(KERN_ERR "%s: islpci_reset: failure\n",
605 /* finally reset interface */
606 rc = islpci_reset_if(priv);
608 printk(KERN_ERR "prism54: Your card/socket may be faulty, or IRQ line too busy :(\n");
612 struct net_device_stats *
613 islpci_statistics(struct net_device *ndev)
615 islpci_private *priv = netdev_priv(ndev);
617 #if VERBOSE > SHOW_ERROR_MESSAGES
618 DEBUG(SHOW_FUNCTION_CALLS, "islpci_statistics\n");
621 return &priv->statistics;
624 /******************************************************************************
625 Network device configuration functions
626 ******************************************************************************/
628 islpci_alloc_memory(islpci_private *priv)
632 #if VERBOSE > SHOW_ERROR_MESSAGES
633 printk(KERN_DEBUG "islpci_alloc_memory\n");
636 /* remap the PCI device base address to accessable */
637 if (!(priv->device_base =
638 ioremap(pci_resource_start(priv->pdev, 0),
639 ISL38XX_PCI_MEM_SIZE))) {
640 /* error in remapping the PCI device memory address range */
641 printk(KERN_ERR "PCI memory remapping failed \n");
645 /* memory layout for consistent DMA region:
647 * Area 1: Control Block for the device interface
648 * Area 2: Power Save Mode Buffer for temporary frame storage. Be aware that
649 * the number of supported stations in the AP determines the minimal
650 * size of the buffer !
653 /* perform the allocation */
654 priv->driver_mem_address = pci_alloc_consistent(priv->pdev,
657 device_host_address);
659 if (!priv->driver_mem_address) {
660 /* error allocating the block of PCI memory */
661 printk(KERN_ERR "%s: could not allocate DMA memory, aborting!",
666 /* assign the Control Block to the first address of the allocated area */
667 priv->control_block =
668 (isl38xx_control_block *) priv->driver_mem_address;
670 /* set the Power Save Buffer pointer directly behind the CB */
671 priv->device_psm_buffer =
672 priv->device_host_address + CONTROL_BLOCK_SIZE;
674 /* make sure all buffer pointers are initialized */
675 for (counter = 0; counter < ISL38XX_CB_QCOUNT; counter++) {
676 priv->control_block->driver_curr_frag[counter] = cpu_to_le32(0);
677 priv->control_block->device_curr_frag[counter] = cpu_to_le32(0);
680 priv->index_mgmt_rx = 0;
681 memset(priv->mgmt_rx, 0, sizeof(priv->mgmt_rx));
682 memset(priv->mgmt_tx, 0, sizeof(priv->mgmt_tx));
684 /* allocate rx queue for management frames */
685 if (islpci_mgmt_rx_fill(priv->ndev) < 0)
688 /* now get the data rx skb's */
689 memset(priv->data_low_rx, 0, sizeof (priv->data_low_rx));
690 memset(priv->pci_map_rx_address, 0, sizeof (priv->pci_map_rx_address));
692 for (counter = 0; counter < ISL38XX_CB_RX_QSIZE; counter++) {
695 /* allocate an sk_buff for received data frames storage
696 * each frame on receive size consists of 1 fragment
697 * include any required allignment operations */
698 if (!(skb = dev_alloc_skb(MAX_FRAGMENT_SIZE_RX + 2))) {
699 /* error allocating an sk_buff structure elements */
700 printk(KERN_ERR "Error allocating skb.\n");
704 skb_reserve(skb, (4 - (long) skb->data) & 0x03);
705 /* add the new allocated sk_buff to the buffer array */
706 priv->data_low_rx[counter] = skb;
708 /* map the allocated skb data area to pci */
709 priv->pci_map_rx_address[counter] =
710 pci_map_single(priv->pdev, (void *) skb->data,
711 MAX_FRAGMENT_SIZE_RX + 2,
713 if (!priv->pci_map_rx_address[counter]) {
714 /* error mapping the buffer to device
715 accessable memory address */
716 printk(KERN_ERR "failed to map skb DMA'able\n");
721 prism54_acl_init(&priv->acl);
722 prism54_wpa_ie_init(priv);
728 islpci_free_memory(priv);
733 islpci_free_memory(islpci_private *priv)
737 if (priv->device_base)
738 iounmap(priv->device_base);
739 priv->device_base = NULL;
741 /* free consistent DMA area... */
742 if (priv->driver_mem_address)
743 pci_free_consistent(priv->pdev, HOST_MEM_BLOCK,
744 priv->driver_mem_address,
745 priv->device_host_address);
747 /* clear some dangling pointers */
748 priv->driver_mem_address = NULL;
749 priv->device_host_address = 0;
750 priv->device_psm_buffer = 0;
751 priv->control_block = NULL;
753 /* clean up mgmt rx buffers */
754 for (counter = 0; counter < ISL38XX_CB_MGMT_QSIZE; counter++) {
755 struct islpci_membuf *buf = &priv->mgmt_rx[counter];
757 pci_unmap_single(priv->pdev, buf->pci_addr,
758 buf->size, PCI_DMA_FROMDEVICE);
766 /* clean up data rx buffers */
767 for (counter = 0; counter < ISL38XX_CB_RX_QSIZE; counter++) {
768 if (priv->pci_map_rx_address[counter])
769 pci_unmap_single(priv->pdev,
770 priv->pci_map_rx_address[counter],
771 MAX_FRAGMENT_SIZE_RX + 2,
773 priv->pci_map_rx_address[counter] = 0;
775 if (priv->data_low_rx[counter])
776 dev_kfree_skb(priv->data_low_rx[counter]);
777 priv->data_low_rx[counter] = NULL;
780 /* Free the acces control list and the WPA list */
781 prism54_acl_clean(&priv->acl);
782 prism54_wpa_ie_clean(priv);
790 islpci_set_multicast_list(struct net_device *dev)
792 /* put device into promisc mode and let network layer handle it */
797 islpci_setup(struct pci_dev *pdev)
799 islpci_private *priv;
800 struct net_device *ndev = alloc_etherdev(sizeof (islpci_private));
805 SET_MODULE_OWNER(ndev);
806 pci_set_drvdata(pdev, ndev);
807 #if defined(SET_NETDEV_DEV)
808 SET_NETDEV_DEV(ndev, &pdev->dev);
811 /* setup the structure members */
812 ndev->base_addr = pci_resource_start(pdev, 0);
813 ndev->irq = pdev->irq;
815 /* initialize the function pointers */
816 ndev->open = &islpci_open;
817 ndev->stop = &islpci_close;
818 ndev->get_stats = &islpci_statistics;
819 ndev->get_wireless_stats = &prism54_get_wireless_stats;
820 ndev->do_ioctl = &prism54_ioctl;
821 ndev->wireless_handlers =
822 (struct iw_handler_def *) &prism54_handler_def;
824 ndev->hard_start_xmit = &islpci_eth_transmit;
825 /* ndev->set_multicast_list = &islpci_set_multicast_list; */
826 ndev->addr_len = ETH_ALEN;
827 ndev->set_mac_address = &prism54_set_mac_address;
828 /* Get a non-zero dummy MAC address for nameif. Jean II */
829 memcpy(ndev->dev_addr, dummy_mac, 6);
831 #ifdef HAVE_TX_TIMEOUT
832 ndev->watchdog_timeo = ISLPCI_TX_TIMEOUT;
833 ndev->tx_timeout = &islpci_eth_tx_timeout;
836 /* allocate a private device structure to the network device */
837 priv = netdev_priv(ndev);
840 priv->monitor_type = ARPHRD_IEEE80211;
841 priv->ndev->type = (priv->iw_mode == IW_MODE_MONITOR) ?
842 priv->monitor_type : ARPHRD_ETHER;
844 #if WIRELESS_EXT > 16
845 /* Add pointers to enable iwspy support. */
846 priv->wireless_data.spy_data = &priv->spy_data;
847 ndev->wireless_data = &priv->wireless_data;
848 #endif /* WIRELESS_EXT > 16 */
850 /* save the start and end address of the PCI memory area */
851 ndev->mem_start = (unsigned long) priv->device_base;
852 ndev->mem_end = ndev->mem_start + ISL38XX_PCI_MEM_SIZE;
854 #if VERBOSE > SHOW_ERROR_MESSAGES
855 DEBUG(SHOW_TRACING, "PCI Memory remapped to 0x%p\n", priv->device_base);
858 init_waitqueue_head(&priv->reset_done);
860 /* init the queue read locks, process wait counter */
861 sema_init(&priv->mgmt_sem, 1);
862 priv->mgmt_received = NULL;
863 init_waitqueue_head(&priv->mgmt_wqueue);
864 sema_init(&priv->stats_sem, 1);
865 spin_lock_init(&priv->slock);
867 /* init state machine with off#1 state */
868 priv->state = PRV_STATE_OFF;
871 /* initialize workqueue's */
872 INIT_WORK(&priv->stats_work,
873 (void (*)(void *)) prism54_update_stats, priv);
874 priv->stats_timestamp = 0;
876 INIT_WORK(&priv->reset_task, islpci_do_reset_and_wake, priv);
877 priv->reset_task_pending = 0;
879 /* allocate various memory areas */
880 if (islpci_alloc_memory(priv))
883 /* select the firmware file depending on the device id */
884 switch (pdev->device) {
886 strcpy(priv->firmware, ISL3877_IMAGE_FILE);
890 strcpy(priv->firmware, ISL3886_IMAGE_FILE);
894 strcpy(priv->firmware, ISL3890_IMAGE_FILE);
898 if (register_netdev(ndev)) {
899 DEBUG(SHOW_ERROR_MESSAGES,
900 "ERROR: register_netdev() failed \n");
901 goto do_islpci_free_memory;
906 do_islpci_free_memory:
907 islpci_free_memory(priv);
909 pci_set_drvdata(pdev, NULL);
916 islpci_set_state(islpci_private *priv, islpci_state_t new_state)
918 islpci_state_t old_state;
921 old_state = priv->state;
923 /* this means either a race condition or some serious error in
929 priv->state = new_state;
932 case PRV_STATE_PREBOOT:
933 /* there are actually many off-states, enumerated by
935 if (old_state == PRV_STATE_OFF)
938 /* only if hw_unavailable is zero now it means we either
939 * were in off#1 state, or came here from
941 if (!priv->state_off)
942 priv->state = new_state;
946 printk(KERN_DEBUG "%s: state transition %d -> %d (off#%d)\n",
947 priv->ndev->name, old_state, new_state, priv->state_off);
951 BUG_ON(priv->state_off < 0);
952 BUG_ON(priv->state_off && (priv->state != PRV_STATE_OFF));
953 BUG_ON(!priv->state_off && (priv->state == PRV_STATE_OFF));