2 * Copyright (C) 2002 Intersil Americas Inc.
3 * Copyright (C) 2003 Herbert Valerio Riedel <hvr@gnu.org>
4 * Copyright (C) 2003 Luis R. Rodriguez <mcgrof@ruslug.rutgers.edu>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include <linux/module.h>
23 #include <linux/netdevice.h>
24 #include <linux/pci.h>
25 #include <linux/etherdevice.h>
26 #include <linux/delay.h>
27 #include <linux/if_arp.h>
31 #include "prismcompat.h"
33 #include "isl_ioctl.h"
34 #include "islpci_dev.h"
35 #include "islpci_mgt.h"
36 #include "islpci_eth.h"
39 #define ISL3877_IMAGE_FILE "isl3877"
40 #define ISL3886_IMAGE_FILE "isl3886"
41 #define ISL3890_IMAGE_FILE "isl3890"
43 static int prism54_bring_down(islpci_private
*);
44 static int islpci_alloc_memory(islpci_private
*);
45 static struct net_device_stats
*islpci_statistics(struct net_device
*);
47 /* Temporary dummy MAC address to use until firmware is loaded.
48 * The idea there is that some tools (such as nameif) may query
49 * the MAC address before the netdev is 'open'. By using a valid
50 * OUI prefix, they can process the netdev properly.
51 * Of course, this is not the final/real MAC address. It doesn't
52 * matter, as you are suppose to be able to change it anytime via
53 * ndev->set_mac_address. Jean II */
54 static const unsigned char dummy_mac
[6] = { 0x00, 0x30, 0xB4, 0x00, 0x00, 0x00 };
57 isl_upload_firmware(islpci_private
*priv
)
60 void __iomem
*device_base
= priv
->device_base
;
62 /* clear the RAMBoot and the Reset bit */
63 reg
= readl(device_base
+ ISL38XX_CTRL_STAT_REG
);
64 reg
&= ~ISL38XX_CTRL_STAT_RESET
;
65 reg
&= ~ISL38XX_CTRL_STAT_RAMBOOT
;
66 writel(reg
, device_base
+ ISL38XX_CTRL_STAT_REG
);
68 udelay(ISL38XX_WRITEIO_DELAY
);
70 /* set the Reset bit without reading the register ! */
71 reg
|= ISL38XX_CTRL_STAT_RESET
;
72 writel(reg
, device_base
+ ISL38XX_CTRL_STAT_REG
);
74 udelay(ISL38XX_WRITEIO_DELAY
);
76 /* clear the Reset bit */
77 reg
&= ~ISL38XX_CTRL_STAT_RESET
;
78 writel(reg
, device_base
+ ISL38XX_CTRL_STAT_REG
);
81 /* wait a while for the device to reboot */
85 const struct firmware
*fw_entry
= NULL
;
89 rc
= request_firmware(&fw_entry
, priv
->firmware
, PRISM_FW_PDEV
);
92 "%s: request_firmware() failed for '%s'\n",
93 "prism54", priv
->firmware
);
96 /* prepare the Direct Memory Base register */
97 reg
= ISL38XX_DEV_FIRMWARE_ADDRES
;
99 fw_ptr
= (u32
*) fw_entry
->data
;
100 fw_len
= fw_entry
->size
;
104 "%s: firmware '%s' size is not multiple of 32bit, aborting!\n",
105 "prism54", priv
->firmware
);
106 release_firmware(fw_entry
);
107 return -EILSEQ
; /* Illegal byte sequence */;
113 ISL38XX_MEMORY_WINDOW_SIZE
) ?
114 ISL38XX_MEMORY_WINDOW_SIZE
: fw_len
;
115 u32 __iomem
*dev_fw_ptr
= device_base
+ ISL38XX_DIRECT_MEM_WIN
;
117 /* set the cards base address for writting the data */
118 isl38xx_w32_flush(device_base
, reg
,
119 ISL38XX_DIR_MEM_BASE_REG
);
120 wmb(); /* be paranoid */
122 /* increment the write address for next iteration */
126 /* write the data to the Direct Memory Window 32bit-wise */
127 /* memcpy_toio() doesn't guarantee 32bit writes :-| */
128 while (_fw_len
> 0) {
129 /* use non-swapping writel() */
130 __raw_writel(*fw_ptr
, dev_fw_ptr
);
131 fw_ptr
++, dev_fw_ptr
++;
135 /* flush PCI posting */
136 (void) readl(device_base
+ ISL38XX_PCI_POSTING_FLUSH
);
137 wmb(); /* be paranoid again */
139 BUG_ON(_fw_len
!= 0);
144 /* Firmware version is at offset 40 (also for "newmac") */
145 printk(KERN_DEBUG
"%s: firmware version: %.8s\n",
146 priv
->ndev
->name
, fw_entry
->data
+ 40);
148 release_firmware(fw_entry
);
151 /* now reset the device
152 * clear the Reset & ClkRun bit, set the RAMBoot bit */
153 reg
= readl(device_base
+ ISL38XX_CTRL_STAT_REG
);
154 reg
&= ~ISL38XX_CTRL_STAT_CLKRUN
;
155 reg
&= ~ISL38XX_CTRL_STAT_RESET
;
156 reg
|= ISL38XX_CTRL_STAT_RAMBOOT
;
157 isl38xx_w32_flush(device_base
, reg
, ISL38XX_CTRL_STAT_REG
);
159 udelay(ISL38XX_WRITEIO_DELAY
);
161 /* set the reset bit latches the host override and RAMBoot bits
162 * into the device for operation when the reset bit is reset */
163 reg
|= ISL38XX_CTRL_STAT_RESET
;
164 writel(reg
, device_base
+ ISL38XX_CTRL_STAT_REG
);
165 /* don't do flush PCI posting here! */
167 udelay(ISL38XX_WRITEIO_DELAY
);
169 /* clear the reset bit should start the whole circus */
170 reg
&= ~ISL38XX_CTRL_STAT_RESET
;
171 writel(reg
, device_base
+ ISL38XX_CTRL_STAT_REG
);
172 /* don't do flush PCI posting here! */
174 udelay(ISL38XX_WRITEIO_DELAY
);
179 /******************************************************************************
180 Device Interrupt Handler
181 ******************************************************************************/
184 islpci_interrupt(int irq
, void *config
)
187 islpci_private
*priv
= config
;
188 struct net_device
*ndev
= priv
->ndev
;
189 void __iomem
*device
= priv
->device_base
;
190 int powerstate
= ISL38XX_PSM_POWERSAVE_STATE
;
192 /* lock the interrupt handler */
193 spin_lock(&priv
->slock
);
195 /* received an interrupt request on a shared IRQ line
196 * first check whether the device is in sleep mode */
197 reg
= readl(device
+ ISL38XX_CTRL_STAT_REG
);
198 if (reg
& ISL38XX_CTRL_STAT_SLEEPMODE
)
199 /* device is in sleep mode, IRQ was generated by someone else */
201 #if VERBOSE > SHOW_ERROR_MESSAGES
202 DEBUG(SHOW_TRACING
, "Assuming someone else called the IRQ\n");
204 spin_unlock(&priv
->slock
);
209 /* check whether there is any source of interrupt on the device */
210 reg
= readl(device
+ ISL38XX_INT_IDENT_REG
);
212 /* also check the contents of the Interrupt Enable Register, because this
213 * will filter out interrupt sources from other devices on the same irq ! */
214 reg
&= readl(device
+ ISL38XX_INT_EN_REG
);
215 reg
&= ISL38XX_INT_SOURCES
;
218 if (islpci_get_state(priv
) != PRV_STATE_SLEEP
)
219 powerstate
= ISL38XX_PSM_ACTIVE_STATE
;
221 /* reset the request bits in the Identification register */
222 isl38xx_w32_flush(device
, reg
, ISL38XX_INT_ACK_REG
);
224 #if VERBOSE > SHOW_ERROR_MESSAGES
225 DEBUG(SHOW_FUNCTION_CALLS
,
226 "IRQ: Identification register 0x%p 0x%x \n", device
, reg
);
229 /* check for each bit in the register separately */
230 if (reg
& ISL38XX_INT_IDENT_UPDATE
) {
231 #if VERBOSE > SHOW_ERROR_MESSAGES
232 /* Queue has been updated */
233 DEBUG(SHOW_TRACING
, "IRQ: Update flag \n");
235 DEBUG(SHOW_QUEUE_INDEXES
,
236 "CB drv Qs: [%i][%i][%i][%i][%i][%i]\n",
237 le32_to_cpu(priv
->control_block
->
238 driver_curr_frag
[0]),
239 le32_to_cpu(priv
->control_block
->
240 driver_curr_frag
[1]),
241 le32_to_cpu(priv
->control_block
->
242 driver_curr_frag
[2]),
243 le32_to_cpu(priv
->control_block
->
244 driver_curr_frag
[3]),
245 le32_to_cpu(priv
->control_block
->
246 driver_curr_frag
[4]),
247 le32_to_cpu(priv
->control_block
->
251 DEBUG(SHOW_QUEUE_INDEXES
,
252 "CB dev Qs: [%i][%i][%i][%i][%i][%i]\n",
253 le32_to_cpu(priv
->control_block
->
254 device_curr_frag
[0]),
255 le32_to_cpu(priv
->control_block
->
256 device_curr_frag
[1]),
257 le32_to_cpu(priv
->control_block
->
258 device_curr_frag
[2]),
259 le32_to_cpu(priv
->control_block
->
260 device_curr_frag
[3]),
261 le32_to_cpu(priv
->control_block
->
262 device_curr_frag
[4]),
263 le32_to_cpu(priv
->control_block
->
268 /* cleanup the data low transmit queue */
269 islpci_eth_cleanup_transmit(priv
, priv
->control_block
);
271 /* device is in active state, update the
272 * powerstate flag if necessary */
273 powerstate
= ISL38XX_PSM_ACTIVE_STATE
;
275 /* check all three queues in priority order
276 * call the PIMFOR receive function until the
278 if (isl38xx_in_queue(priv
->control_block
,
279 ISL38XX_CB_RX_MGMTQ
) != 0) {
280 #if VERBOSE > SHOW_ERROR_MESSAGES
282 "Received frame in Management Queue\n");
284 islpci_mgt_receive(ndev
);
286 islpci_mgt_cleanup_transmit(ndev
);
288 /* Refill slots in receive queue */
289 islpci_mgmt_rx_fill(ndev
);
291 /* no need to trigger the device, next
292 islpci_mgt_transaction does it */
295 while (isl38xx_in_queue(priv
->control_block
,
296 ISL38XX_CB_RX_DATA_LQ
) != 0) {
297 #if VERBOSE > SHOW_ERROR_MESSAGES
299 "Received frame in Data Low Queue \n");
301 islpci_eth_receive(priv
);
304 /* check whether the data transmit queues were full */
305 if (priv
->data_low_tx_full
) {
306 /* check whether the transmit is not full anymore */
307 if (ISL38XX_CB_TX_QSIZE
-
308 isl38xx_in_queue(priv
->control_block
,
309 ISL38XX_CB_TX_DATA_LQ
) >=
310 ISL38XX_MIN_QTHRESHOLD
) {
311 /* nope, the driver is ready for more network frames */
312 netif_wake_queue(priv
->ndev
);
314 /* reset the full flag */
315 priv
->data_low_tx_full
= 0;
320 if (reg
& ISL38XX_INT_IDENT_INIT
) {
321 /* Device has been initialized */
322 #if VERBOSE > SHOW_ERROR_MESSAGES
324 "IRQ: Init flag, device initialized \n");
326 wake_up(&priv
->reset_done
);
329 if (reg
& ISL38XX_INT_IDENT_SLEEP
) {
330 /* Device intends to move to powersave state */
331 #if VERBOSE > SHOW_ERROR_MESSAGES
332 DEBUG(SHOW_TRACING
, "IRQ: Sleep flag \n");
334 isl38xx_handle_sleep_request(priv
->control_block
,
339 if (reg
& ISL38XX_INT_IDENT_WAKEUP
) {
340 /* Device has been woken up to active state */
341 #if VERBOSE > SHOW_ERROR_MESSAGES
342 DEBUG(SHOW_TRACING
, "IRQ: Wakeup flag \n");
345 isl38xx_handle_wakeup(priv
->control_block
,
346 &powerstate
, priv
->device_base
);
349 #if VERBOSE > SHOW_ERROR_MESSAGES
350 DEBUG(SHOW_TRACING
, "Assuming someone else called the IRQ\n");
352 spin_unlock(&priv
->slock
);
357 if (islpci_get_state(priv
) == PRV_STATE_SLEEP
358 && powerstate
== ISL38XX_PSM_ACTIVE_STATE
)
359 islpci_set_state(priv
, PRV_STATE_READY
);
361 /* !sleep -> sleep */
362 if (islpci_get_state(priv
) != PRV_STATE_SLEEP
363 && powerstate
== ISL38XX_PSM_POWERSAVE_STATE
)
364 islpci_set_state(priv
, PRV_STATE_SLEEP
);
366 /* unlock the interrupt handler */
367 spin_unlock(&priv
->slock
);
372 /******************************************************************************
373 Network Interface Control & Statistical functions
374 ******************************************************************************/
376 islpci_open(struct net_device
*ndev
)
379 islpci_private
*priv
= netdev_priv(ndev
);
381 /* reset data structures, upload firmware and reset device */
382 rc
= islpci_reset(priv
,1);
384 prism54_bring_down(priv
);
385 return rc
; /* Returns informative message */
388 netif_start_queue(ndev
);
389 /* netif_mark_up( ndev ); */
395 islpci_close(struct net_device
*ndev
)
397 islpci_private
*priv
= netdev_priv(ndev
);
399 printk(KERN_DEBUG
"%s: islpci_close ()\n", ndev
->name
);
401 netif_stop_queue(ndev
);
403 return prism54_bring_down(priv
);
407 prism54_bring_down(islpci_private
*priv
)
409 void __iomem
*device_base
= priv
->device_base
;
411 /* we are going to shutdown the device */
412 islpci_set_state(priv
, PRV_STATE_PREBOOT
);
414 /* disable all device interrupts in case they weren't */
415 isl38xx_disable_interrupts(priv
->device_base
);
417 /* For safety reasons, we may want to ensure that no DMA transfer is
418 * currently in progress by emptying the TX and RX queues. */
420 /* wait until interrupts have finished executing on other CPUs */
421 synchronize_irq(priv
->pdev
->irq
);
423 reg
= readl(device_base
+ ISL38XX_CTRL_STAT_REG
);
424 reg
&= ~(ISL38XX_CTRL_STAT_RESET
| ISL38XX_CTRL_STAT_RAMBOOT
);
425 writel(reg
, device_base
+ ISL38XX_CTRL_STAT_REG
);
427 udelay(ISL38XX_WRITEIO_DELAY
);
429 reg
|= ISL38XX_CTRL_STAT_RESET
;
430 writel(reg
, device_base
+ ISL38XX_CTRL_STAT_REG
);
432 udelay(ISL38XX_WRITEIO_DELAY
);
434 /* clear the Reset bit */
435 reg
&= ~ISL38XX_CTRL_STAT_RESET
;
436 writel(reg
, device_base
+ ISL38XX_CTRL_STAT_REG
);
439 /* wait a while for the device to reset */
440 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
446 islpci_upload_fw(islpci_private
*priv
)
448 islpci_state_t old_state
;
451 old_state
= islpci_set_state(priv
, PRV_STATE_BOOT
);
453 printk(KERN_DEBUG
"%s: uploading firmware...\n", priv
->ndev
->name
);
455 rc
= isl_upload_firmware(priv
);
457 /* error uploading the firmware */
458 printk(KERN_ERR
"%s: could not upload firmware ('%s')\n",
459 priv
->ndev
->name
, priv
->firmware
);
461 islpci_set_state(priv
, old_state
);
465 printk(KERN_DEBUG
"%s: firmware upload complete\n",
468 islpci_set_state(priv
, PRV_STATE_POSTBOOT
);
474 islpci_reset_if(islpci_private
*priv
)
481 prepare_to_wait(&priv
->reset_done
, &wait
, TASK_UNINTERRUPTIBLE
);
483 /* now the last step is to reset the interface */
484 isl38xx_interface_reset(priv
->device_base
, priv
->device_host_address
);
485 islpci_set_state(priv
, PRV_STATE_PREINIT
);
487 for(count
= 0; count
< 2 && result
; count
++) {
488 /* The software reset acknowledge needs about 220 msec here.
489 * Be conservative and wait for up to one second. */
491 remaining
= schedule_timeout_uninterruptible(HZ
);
498 /* If we're here it's because our IRQ hasn't yet gone through.
499 * Retry a bit more...
501 printk(KERN_ERR
"%s: no 'reset complete' IRQ seen - retrying\n",
505 finish_wait(&priv
->reset_done
, &wait
);
508 printk(KERN_ERR
"%s: interface reset failure\n", priv
->ndev
->name
);
512 islpci_set_state(priv
, PRV_STATE_INIT
);
514 /* Now that the device is 100% up, let's allow
515 * for the other interrupts --
516 * NOTE: this is not *yet* true since we've only allowed the
517 * INIT interrupt on the IRQ line. We can perhaps poll
518 * the IRQ line until we know for sure the reset went through */
519 isl38xx_enable_common_interrupts(priv
->device_base
);
521 down_write(&priv
->mib_sem
);
522 result
= mgt_commit(priv
);
524 printk(KERN_ERR
"%s: interface reset failure\n", priv
->ndev
->name
);
525 up_write(&priv
->mib_sem
);
528 up_write(&priv
->mib_sem
);
530 islpci_set_state(priv
, PRV_STATE_READY
);
532 printk(KERN_DEBUG
"%s: interface reset complete\n", priv
->ndev
->name
);
537 islpci_reset(islpci_private
*priv
, int reload_firmware
)
539 isl38xx_control_block
*cb
= /* volatile not needed */
540 (isl38xx_control_block
*) priv
->control_block
;
545 islpci_set_state(priv
, PRV_STATE_PREBOOT
);
547 islpci_set_state(priv
, PRV_STATE_POSTBOOT
);
549 printk(KERN_DEBUG
"%s: resetting device...\n", priv
->ndev
->name
);
551 /* disable all device interrupts in case they weren't */
552 isl38xx_disable_interrupts(priv
->device_base
);
554 /* flush all management queues */
555 priv
->index_mgmt_tx
= 0;
556 priv
->index_mgmt_rx
= 0;
558 /* clear the indexes in the frame pointer */
559 for (counter
= 0; counter
< ISL38XX_CB_QCOUNT
; counter
++) {
560 cb
->driver_curr_frag
[counter
] = cpu_to_le32(0);
561 cb
->device_curr_frag
[counter
] = cpu_to_le32(0);
564 /* reset the mgmt receive queue */
565 for (counter
= 0; counter
< ISL38XX_CB_MGMT_QSIZE
; counter
++) {
566 isl38xx_fragment
*frag
= &cb
->rx_data_mgmt
[counter
];
567 frag
->size
= cpu_to_le16(MGMT_FRAME_SIZE
);
569 frag
->address
= cpu_to_le32(priv
->mgmt_rx
[counter
].pci_addr
);
572 for (counter
= 0; counter
< ISL38XX_CB_RX_QSIZE
; counter
++) {
573 cb
->rx_data_low
[counter
].address
=
574 cpu_to_le32((u32
) priv
->pci_map_rx_address
[counter
]);
577 /* since the receive queues are filled with empty fragments, now we can
578 * set the corresponding indexes in the Control Block */
579 priv
->control_block
->driver_curr_frag
[ISL38XX_CB_RX_DATA_LQ
] =
580 cpu_to_le32(ISL38XX_CB_RX_QSIZE
);
581 priv
->control_block
->driver_curr_frag
[ISL38XX_CB_RX_MGMTQ
] =
582 cpu_to_le32(ISL38XX_CB_MGMT_QSIZE
);
584 /* reset the remaining real index registers and full flags */
585 priv
->free_data_rx
= 0;
586 priv
->free_data_tx
= 0;
587 priv
->data_low_tx_full
= 0;
589 if (reload_firmware
) { /* Should we load the firmware ? */
590 /* now that the data structures are cleaned up, upload
591 * firmware and reset interface */
592 rc
= islpci_upload_fw(priv
);
594 printk(KERN_ERR
"%s: islpci_reset: failure\n",
600 /* finally reset interface */
601 rc
= islpci_reset_if(priv
);
603 printk(KERN_ERR
"prism54: Your card/socket may be faulty, or IRQ line too busy :(\n");
607 static struct net_device_stats
*
608 islpci_statistics(struct net_device
*ndev
)
610 islpci_private
*priv
= netdev_priv(ndev
);
612 #if VERBOSE > SHOW_ERROR_MESSAGES
613 DEBUG(SHOW_FUNCTION_CALLS
, "islpci_statistics\n");
616 return &priv
->statistics
;
619 /******************************************************************************
620 Network device configuration functions
621 ******************************************************************************/
623 islpci_alloc_memory(islpci_private
*priv
)
627 #if VERBOSE > SHOW_ERROR_MESSAGES
628 printk(KERN_DEBUG
"islpci_alloc_memory\n");
631 /* remap the PCI device base address to accessable */
632 if (!(priv
->device_base
=
633 ioremap(pci_resource_start(priv
->pdev
, 0),
634 ISL38XX_PCI_MEM_SIZE
))) {
635 /* error in remapping the PCI device memory address range */
636 printk(KERN_ERR
"PCI memory remapping failed \n");
640 /* memory layout for consistent DMA region:
642 * Area 1: Control Block for the device interface
643 * Area 2: Power Save Mode Buffer for temporary frame storage. Be aware that
644 * the number of supported stations in the AP determines the minimal
645 * size of the buffer !
648 /* perform the allocation */
649 priv
->driver_mem_address
= pci_alloc_consistent(priv
->pdev
,
652 device_host_address
);
654 if (!priv
->driver_mem_address
) {
655 /* error allocating the block of PCI memory */
656 printk(KERN_ERR
"%s: could not allocate DMA memory, aborting!",
661 /* assign the Control Block to the first address of the allocated area */
662 priv
->control_block
=
663 (isl38xx_control_block
*) priv
->driver_mem_address
;
665 /* set the Power Save Buffer pointer directly behind the CB */
666 priv
->device_psm_buffer
=
667 priv
->device_host_address
+ CONTROL_BLOCK_SIZE
;
669 /* make sure all buffer pointers are initialized */
670 for (counter
= 0; counter
< ISL38XX_CB_QCOUNT
; counter
++) {
671 priv
->control_block
->driver_curr_frag
[counter
] = cpu_to_le32(0);
672 priv
->control_block
->device_curr_frag
[counter
] = cpu_to_le32(0);
675 priv
->index_mgmt_rx
= 0;
676 memset(priv
->mgmt_rx
, 0, sizeof(priv
->mgmt_rx
));
677 memset(priv
->mgmt_tx
, 0, sizeof(priv
->mgmt_tx
));
679 /* allocate rx queue for management frames */
680 if (islpci_mgmt_rx_fill(priv
->ndev
) < 0)
683 /* now get the data rx skb's */
684 memset(priv
->data_low_rx
, 0, sizeof (priv
->data_low_rx
));
685 memset(priv
->pci_map_rx_address
, 0, sizeof (priv
->pci_map_rx_address
));
687 for (counter
= 0; counter
< ISL38XX_CB_RX_QSIZE
; counter
++) {
690 /* allocate an sk_buff for received data frames storage
691 * each frame on receive size consists of 1 fragment
692 * include any required allignment operations */
693 if (!(skb
= dev_alloc_skb(MAX_FRAGMENT_SIZE_RX
+ 2))) {
694 /* error allocating an sk_buff structure elements */
695 printk(KERN_ERR
"Error allocating skb.\n");
699 skb_reserve(skb
, (4 - (long) skb
->data
) & 0x03);
700 /* add the new allocated sk_buff to the buffer array */
701 priv
->data_low_rx
[counter
] = skb
;
703 /* map the allocated skb data area to pci */
704 priv
->pci_map_rx_address
[counter
] =
705 pci_map_single(priv
->pdev
, (void *) skb
->data
,
706 MAX_FRAGMENT_SIZE_RX
+ 2,
708 if (!priv
->pci_map_rx_address
[counter
]) {
709 /* error mapping the buffer to device
710 accessable memory address */
711 printk(KERN_ERR
"failed to map skb DMA'able\n");
716 prism54_acl_init(&priv
->acl
);
717 prism54_wpa_bss_ie_init(priv
);
723 islpci_free_memory(priv
);
728 islpci_free_memory(islpci_private
*priv
)
732 if (priv
->device_base
)
733 iounmap(priv
->device_base
);
734 priv
->device_base
= NULL
;
736 /* free consistent DMA area... */
737 if (priv
->driver_mem_address
)
738 pci_free_consistent(priv
->pdev
, HOST_MEM_BLOCK
,
739 priv
->driver_mem_address
,
740 priv
->device_host_address
);
742 /* clear some dangling pointers */
743 priv
->driver_mem_address
= NULL
;
744 priv
->device_host_address
= 0;
745 priv
->device_psm_buffer
= 0;
746 priv
->control_block
= NULL
;
748 /* clean up mgmt rx buffers */
749 for (counter
= 0; counter
< ISL38XX_CB_MGMT_QSIZE
; counter
++) {
750 struct islpci_membuf
*buf
= &priv
->mgmt_rx
[counter
];
752 pci_unmap_single(priv
->pdev
, buf
->pci_addr
,
753 buf
->size
, PCI_DMA_FROMDEVICE
);
760 /* clean up data rx buffers */
761 for (counter
= 0; counter
< ISL38XX_CB_RX_QSIZE
; counter
++) {
762 if (priv
->pci_map_rx_address
[counter
])
763 pci_unmap_single(priv
->pdev
,
764 priv
->pci_map_rx_address
[counter
],
765 MAX_FRAGMENT_SIZE_RX
+ 2,
767 priv
->pci_map_rx_address
[counter
] = 0;
769 if (priv
->data_low_rx
[counter
])
770 dev_kfree_skb(priv
->data_low_rx
[counter
]);
771 priv
->data_low_rx
[counter
] = NULL
;
774 /* Free the acces control list and the WPA list */
775 prism54_acl_clean(&priv
->acl
);
776 prism54_wpa_bss_ie_clean(priv
);
784 islpci_set_multicast_list(struct net_device
*dev
)
786 /* put device into promisc mode and let network layer handle it */
791 islpci_setup(struct pci_dev
*pdev
)
793 islpci_private
*priv
;
794 struct net_device
*ndev
= alloc_etherdev(sizeof (islpci_private
));
799 SET_MODULE_OWNER(ndev
);
800 pci_set_drvdata(pdev
, ndev
);
801 #if defined(SET_NETDEV_DEV)
802 SET_NETDEV_DEV(ndev
, &pdev
->dev
);
805 /* setup the structure members */
806 ndev
->base_addr
= pci_resource_start(pdev
, 0);
807 ndev
->irq
= pdev
->irq
;
809 /* initialize the function pointers */
810 ndev
->open
= &islpci_open
;
811 ndev
->stop
= &islpci_close
;
812 ndev
->get_stats
= &islpci_statistics
;
813 ndev
->do_ioctl
= &prism54_ioctl
;
814 ndev
->wireless_handlers
=
815 (struct iw_handler_def
*) &prism54_handler_def
;
817 ndev
->hard_start_xmit
= &islpci_eth_transmit
;
818 /* ndev->set_multicast_list = &islpci_set_multicast_list; */
819 ndev
->addr_len
= ETH_ALEN
;
820 ndev
->set_mac_address
= &prism54_set_mac_address
;
821 /* Get a non-zero dummy MAC address for nameif. Jean II */
822 memcpy(ndev
->dev_addr
, dummy_mac
, 6);
824 #ifdef HAVE_TX_TIMEOUT
825 ndev
->watchdog_timeo
= ISLPCI_TX_TIMEOUT
;
826 ndev
->tx_timeout
= &islpci_eth_tx_timeout
;
829 /* allocate a private device structure to the network device */
830 priv
= netdev_priv(ndev
);
833 priv
->monitor_type
= ARPHRD_IEEE80211
;
834 priv
->ndev
->type
= (priv
->iw_mode
== IW_MODE_MONITOR
) ?
835 priv
->monitor_type
: ARPHRD_ETHER
;
837 /* Add pointers to enable iwspy support. */
838 priv
->wireless_data
.spy_data
= &priv
->spy_data
;
839 ndev
->wireless_data
= &priv
->wireless_data
;
841 /* save the start and end address of the PCI memory area */
842 ndev
->mem_start
= (unsigned long) priv
->device_base
;
843 ndev
->mem_end
= ndev
->mem_start
+ ISL38XX_PCI_MEM_SIZE
;
845 #if VERBOSE > SHOW_ERROR_MESSAGES
846 DEBUG(SHOW_TRACING
, "PCI Memory remapped to 0x%p\n", priv
->device_base
);
849 init_waitqueue_head(&priv
->reset_done
);
851 /* init the queue read locks, process wait counter */
852 sema_init(&priv
->mgmt_sem
, 1);
853 priv
->mgmt_received
= NULL
;
854 init_waitqueue_head(&priv
->mgmt_wqueue
);
855 sema_init(&priv
->stats_sem
, 1);
856 spin_lock_init(&priv
->slock
);
858 /* init state machine with off#1 state */
859 priv
->state
= PRV_STATE_OFF
;
862 /* initialize workqueue's */
863 INIT_WORK(&priv
->stats_work
,
864 (void (*)(void *)) prism54_update_stats
, priv
);
865 priv
->stats_timestamp
= 0;
867 INIT_WORK(&priv
->reset_task
, islpci_do_reset_and_wake
, priv
);
868 priv
->reset_task_pending
= 0;
870 /* allocate various memory areas */
871 if (islpci_alloc_memory(priv
))
874 /* select the firmware file depending on the device id */
875 switch (pdev
->device
) {
877 strcpy(priv
->firmware
, ISL3877_IMAGE_FILE
);
881 strcpy(priv
->firmware
, ISL3886_IMAGE_FILE
);
885 strcpy(priv
->firmware
, ISL3890_IMAGE_FILE
);
889 if (register_netdev(ndev
)) {
890 DEBUG(SHOW_ERROR_MESSAGES
,
891 "ERROR: register_netdev() failed \n");
892 goto do_islpci_free_memory
;
897 do_islpci_free_memory
:
898 islpci_free_memory(priv
);
900 pci_set_drvdata(pdev
, NULL
);
907 islpci_set_state(islpci_private
*priv
, islpci_state_t new_state
)
909 islpci_state_t old_state
;
912 old_state
= priv
->state
;
914 /* this means either a race condition or some serious error in
920 priv
->state
= new_state
;
923 case PRV_STATE_PREBOOT
:
924 /* there are actually many off-states, enumerated by
926 if (old_state
== PRV_STATE_OFF
)
929 /* only if hw_unavailable is zero now it means we either
930 * were in off#1 state, or came here from
932 if (!priv
->state_off
)
933 priv
->state
= new_state
;
937 printk(KERN_DEBUG
"%s: state transition %d -> %d (off#%d)\n",
938 priv
->ndev
->name
, old_state
, new_state
, priv
->state_off
);
942 BUG_ON(priv
->state_off
< 0);
943 BUG_ON(priv
->state_off
&& (priv
->state
!= PRV_STATE_OFF
));
944 BUG_ON(!priv
->state_off
&& (priv
->state
== PRV_STATE_OFF
));