6 * Reorganisation and extension of the driver.
7 * Original copyright follows (also see the end of this file).
8 * See wavelan.p.h for details.
12 * AT&T GIS (nee NCR) WaveLAN card:
13 * An Ethernet-like radio transceiver
14 * controlled by an Intel 82586 coprocessor.
17 #include "wavelan.p.h" /* Private header */
19 /************************* MISC SUBROUTINES **************************/
21 * Subroutines which won't fit in one of the following category
22 * (WaveLAN modem or i82586)
25 /*------------------------------------------------------------------*/
27 * Wrapper for disabling interrupts and locking the driver.
28 * (note : inline, so optimised away)
30 static inline void wv_splhi(net_local
* lp
,
31 unsigned long * pflags
)
33 spin_lock_irqsave(&lp
->spinlock
, *pflags
);
34 /* Note : above does the cli(); itself */
37 /*------------------------------------------------------------------*/
39 * Wrapper for re-enabling interrupts and un-locking the driver.
41 static inline void wv_splx(net_local
* lp
,
42 unsigned long * pflags
)
44 spin_unlock_irqrestore(&lp
->spinlock
, *pflags
);
47 /*------------------------------------------------------------------*/
49 * Translate irq number to PSA irq parameter
51 static u8
wv_irq_to_psa(int irq
)
53 if (irq
< 0 || irq
>= NELS(irqvals
))
59 /*------------------------------------------------------------------*/
61 * Translate PSA irq parameter to irq number
63 static int __init
wv_psa_to_irq(u8 irqval
)
67 for (irq
= 0; irq
< NELS(irqvals
); irq
++)
68 if (irqvals
[irq
] == irqval
)
75 /*------------------------------------------------------------------*/
77 * Sanity routine to verify the sizes of the various WaveLAN interface
80 static char *wv_struct_check(void)
82 #define SC(t,s,n) if (sizeof(t) != s) return(n);
84 SC(psa_t
, PSA_SIZE
, "psa_t");
85 SC(mmw_t
, MMW_SIZE
, "mmw_t");
86 SC(mmr_t
, MMR_SIZE
, "mmr_t");
87 SC(ha_t
, HA_SIZE
, "ha_t");
91 return ((char *) NULL
);
92 } /* wv_struct_check */
93 #endif /* STRUCT_CHECK */
95 /********************* HOST ADAPTER SUBROUTINES *********************/
97 * Useful subroutines to manage the WaveLAN ISA interface
99 * One major difference with the PCMCIA hardware (except the port mapping)
100 * is that we have to keep the state of the Host Control Register
101 * because of the interrupt enable & bus size flags.
104 /*------------------------------------------------------------------*/
106 * Read from card's Host Adaptor Status Register.
108 static inline u16
hasr_read(unsigned long ioaddr
)
110 return (inw(HASR(ioaddr
)));
113 /*------------------------------------------------------------------*/
115 * Write to card's Host Adapter Command Register.
117 static inline void hacr_write(unsigned long ioaddr
, u16 hacr
)
119 outw(hacr
, HACR(ioaddr
));
122 /*------------------------------------------------------------------*/
124 * Write to card's Host Adapter Command Register. Include a delay for
125 * those times when it is needed.
127 static inline void hacr_write_slow(unsigned long ioaddr
, u16 hacr
)
129 hacr_write(ioaddr
, hacr
);
130 /* delay might only be needed sometimes */
132 } /* hacr_write_slow */
134 /*------------------------------------------------------------------*/
136 * Set the channel attention bit.
138 static inline void set_chan_attn(unsigned long ioaddr
, u16 hacr
)
140 hacr_write(ioaddr
, hacr
| HACR_CA
);
141 } /* set_chan_attn */
143 /*------------------------------------------------------------------*/
145 * Reset, and then set host adaptor into default mode.
147 static inline void wv_hacr_reset(unsigned long ioaddr
)
149 hacr_write_slow(ioaddr
, HACR_RESET
);
150 hacr_write(ioaddr
, HACR_DEFAULT
);
151 } /* wv_hacr_reset */
153 /*------------------------------------------------------------------*/
155 * Set the I/O transfer over the ISA bus to 8-bit mode
157 static inline void wv_16_off(unsigned long ioaddr
, u16 hacr
)
159 hacr
&= ~HACR_16BITS
;
160 hacr_write(ioaddr
, hacr
);
163 /*------------------------------------------------------------------*/
165 * Set the I/O transfer over the ISA bus to 8-bit mode
167 static inline void wv_16_on(unsigned long ioaddr
, u16 hacr
)
170 hacr_write(ioaddr
, hacr
);
173 /*------------------------------------------------------------------*/
175 * Disable interrupts on the WaveLAN hardware.
176 * (called by wv_82586_stop())
178 static inline void wv_ints_off(device
* dev
)
180 net_local
*lp
= (net_local
*) dev
->priv
;
181 unsigned long ioaddr
= dev
->base_addr
;
183 lp
->hacr
&= ~HACR_INTRON
;
184 hacr_write(ioaddr
, lp
->hacr
);
187 /*------------------------------------------------------------------*/
189 * Enable interrupts on the WaveLAN hardware.
190 * (called by wv_hw_reset())
192 static inline void wv_ints_on(device
* dev
)
194 net_local
*lp
= (net_local
*) dev
->priv
;
195 unsigned long ioaddr
= dev
->base_addr
;
197 lp
->hacr
|= HACR_INTRON
;
198 hacr_write(ioaddr
, lp
->hacr
);
201 /******************* MODEM MANAGEMENT SUBROUTINES *******************/
203 * Useful subroutines to manage the modem of the WaveLAN
206 /*------------------------------------------------------------------*/
208 * Read the Parameter Storage Area from the WaveLAN card's memory
211 * Read bytes from the PSA.
213 static void psa_read(unsigned long ioaddr
, u16 hacr
, int o
, /* offset in PSA */
214 u8
* b
, /* buffer to fill */
217 wv_16_off(ioaddr
, hacr
);
220 outw(o
, PIOR2(ioaddr
));
222 *b
++ = inb(PIOP2(ioaddr
));
225 wv_16_on(ioaddr
, hacr
);
228 /*------------------------------------------------------------------*/
230 * Write the Parameter Storage Area to the WaveLAN card's memory.
232 static void psa_write(unsigned long ioaddr
, u16 hacr
, int o
, /* Offset in PSA */
233 u8
* b
, /* Buffer in memory */
235 { /* Length of buffer */
238 wv_16_off(ioaddr
, hacr
);
241 outw(o
, PIOR2(ioaddr
));
244 outb(*b
, PIOP2(ioaddr
));
247 /* Wait for the memory to finish its write cycle */
249 while ((count
++ < 100) &&
250 (hasr_read(ioaddr
) & HASR_PSA_BUSY
)) mdelay(1);
253 wv_16_on(ioaddr
, hacr
);
257 /*------------------------------------------------------------------*/
259 * Calculate the PSA CRC
260 * Thanks to Valster, Nico <NVALSTER@wcnd.nl.lucent.com> for the code
261 * NOTE: By specifying a length including the CRC position the
262 * returned value should be zero. (i.e. a correct checksum in the PSA)
264 * The Windows drivers don't use the CRC, but the AP and the PtP tool
267 static inline u16
psa_crc(u8
* psa
, /* The PSA */
269 { /* Number of short for CRC */
270 int byte_cnt
; /* Loop on the PSA */
271 u16 crc_bytes
= 0; /* Data in the PSA */
272 int bit_cnt
; /* Loop on the bits of the short */
274 for (byte_cnt
= 0; byte_cnt
< size
; byte_cnt
++) {
275 crc_bytes
^= psa
[byte_cnt
]; /* Its an xor */
277 for (bit_cnt
= 1; bit_cnt
< 9; bit_cnt
++) {
278 if (crc_bytes
& 0x0001)
279 crc_bytes
= (crc_bytes
>> 1) ^ 0xA001;
287 #endif /* SET_PSA_CRC */
289 /*------------------------------------------------------------------*/
291 * update the checksum field in the Wavelan's PSA
293 static void update_psa_checksum(device
* dev
, unsigned long ioaddr
, u16 hacr
)
299 /* read the parameter storage area */
300 psa_read(ioaddr
, hacr
, 0, (unsigned char *) &psa
, sizeof(psa
));
302 /* update the checksum */
303 crc
= psa_crc((unsigned char *) &psa
,
304 sizeof(psa
) - sizeof(psa
.psa_crc
[0]) -
305 sizeof(psa
.psa_crc
[1])
306 - sizeof(psa
.psa_crc_status
));
308 psa
.psa_crc
[0] = crc
& 0xFF;
309 psa
.psa_crc
[1] = (crc
& 0xFF00) >> 8;
312 psa_write(ioaddr
, hacr
, (char *) &psa
.psa_crc
- (char *) &psa
,
313 (unsigned char *) &psa
.psa_crc
, 2);
315 #ifdef DEBUG_IOCTL_INFO
316 printk(KERN_DEBUG
"%s: update_psa_checksum(): crc = 0x%02x%02x\n",
317 dev
->name
, psa
.psa_crc
[0], psa
.psa_crc
[1]);
319 /* Check again (luxury !) */
320 crc
= psa_crc((unsigned char *) &psa
,
321 sizeof(psa
) - sizeof(psa
.psa_crc_status
));
325 "%s: update_psa_checksum(): CRC does not agree with PSA data (even after recalculating)\n",
327 #endif /* DEBUG_IOCTL_INFO */
328 #endif /* SET_PSA_CRC */
329 } /* update_psa_checksum */
331 /*------------------------------------------------------------------*/
333 * Write 1 byte to the MMC.
335 static inline void mmc_out(unsigned long ioaddr
, u16 o
, u8 d
)
337 /* Wait for MMC to go idle */
338 while (inw(HASR(ioaddr
)) & HASR_MMC_BUSY
);
340 outw((u16
) (((u16
) d
<< 8) | (o
<< 1) | 1), MMCR(ioaddr
));
343 /*------------------------------------------------------------------*/
345 * Routine to write bytes to the Modem Management Controller.
346 * We start at the end because it is the way it should be!
348 static inline void mmc_write(unsigned long ioaddr
, u8 o
, u8
* b
, int n
)
354 mmc_out(ioaddr
, --o
, *(--b
));
357 /*------------------------------------------------------------------*/
359 * Read a byte from the MMC.
360 * Optimised version for 1 byte, avoid using memory.
362 static inline u8
mmc_in(unsigned long ioaddr
, u16 o
)
364 while (inw(HASR(ioaddr
)) & HASR_MMC_BUSY
);
365 outw(o
<< 1, MMCR(ioaddr
));
367 while (inw(HASR(ioaddr
)) & HASR_MMC_BUSY
);
368 return (u8
) (inw(MMCR(ioaddr
)) >> 8);
371 /*------------------------------------------------------------------*/
373 * Routine to read bytes from the Modem Management Controller.
374 * The implementation is complicated by a lack of address lines,
375 * which prevents decoding of the low-order bit.
376 * (code has just been moved in the above function)
377 * We start at the end because it is the way it should be!
379 static inline void mmc_read(unsigned long ioaddr
, u8 o
, u8
* b
, int n
)
385 *(--b
) = mmc_in(ioaddr
, --o
);
388 /*------------------------------------------------------------------*/
390 * Get the type of encryption available.
392 static inline int mmc_encr(unsigned long ioaddr
)
393 { /* I/O port of the card */
396 temp
= mmc_in(ioaddr
, mmroff(0, mmr_des_avail
));
397 if ((temp
!= MMR_DES_AVAIL_DES
) && (temp
!= MMR_DES_AVAIL_AES
))
403 /*------------------------------------------------------------------*/
405 * Wait for the frequency EEPROM to complete a command.
406 * I hope this one will be optimally inlined.
408 static inline void fee_wait(unsigned long ioaddr
, /* I/O port of the card */
409 int delay
, /* Base delay to wait for */
411 { /* Number of time to wait */
412 int count
= 0; /* Wait only a limited time */
414 while ((count
++ < number
) &&
415 (mmc_in(ioaddr
, mmroff(0, mmr_fee_status
)) &
416 MMR_FEE_STATUS_BUSY
)) udelay(delay
);
419 /*------------------------------------------------------------------*/
421 * Read bytes from the Frequency EEPROM (frequency select cards).
423 static void fee_read(unsigned long ioaddr
, /* I/O port of the card */
424 u16 o
, /* destination offset */
425 u16
* b
, /* data buffer */
427 { /* number of registers */
428 b
+= n
; /* Position at the end of the area */
430 /* Write the address */
431 mmc_out(ioaddr
, mmwoff(0, mmw_fee_addr
), o
+ n
- 1);
433 /* Loop on all buffer */
435 /* Write the read command */
436 mmc_out(ioaddr
, mmwoff(0, mmw_fee_ctrl
),
439 /* Wait until EEPROM is ready (should be quick). */
440 fee_wait(ioaddr
, 10, 100);
442 /* Read the value. */
443 *--b
= ((mmc_in(ioaddr
, mmroff(0, mmr_fee_data_h
)) << 8) |
444 mmc_in(ioaddr
, mmroff(0, mmr_fee_data_l
)));
448 #ifdef WIRELESS_EXT /* if the wireless extension exists in the kernel */
450 /*------------------------------------------------------------------*/
452 * Write bytes from the Frequency EEPROM (frequency select cards).
453 * This is a bit complicated, because the frequency EEPROM has to
454 * be unprotected and the write enabled.
457 static void fee_write(unsigned long ioaddr
, /* I/O port of the card */
458 u16 o
, /* destination offset */
459 u16
* b
, /* data buffer */
461 { /* number of registers */
462 b
+= n
; /* Position at the end of the area. */
464 #ifdef EEPROM_IS_PROTECTED /* disabled */
465 #ifdef DOESNT_SEEM_TO_WORK /* disabled */
466 /* Ask to read the protected register */
467 mmc_out(ioaddr
, mmwoff(0, mmw_fee_ctrl
), MMW_FEE_CTRL_PRREAD
);
469 fee_wait(ioaddr
, 10, 100);
471 /* Read the protected register. */
472 printk("Protected 2: %02X-%02X\n",
473 mmc_in(ioaddr
, mmroff(0, mmr_fee_data_h
)),
474 mmc_in(ioaddr
, mmroff(0, mmr_fee_data_l
)));
475 #endif /* DOESNT_SEEM_TO_WORK */
477 /* Enable protected register. */
478 mmc_out(ioaddr
, mmwoff(0, mmw_fee_addr
), MMW_FEE_ADDR_EN
);
479 mmc_out(ioaddr
, mmwoff(0, mmw_fee_ctrl
), MMW_FEE_CTRL_PREN
);
481 fee_wait(ioaddr
, 10, 100);
483 /* Unprotect area. */
484 mmc_out(ioaddr
, mmwoff(0, mmw_fee_addr
), o
+ n
);
485 mmc_out(ioaddr
, mmwoff(0, mmw_fee_ctrl
), MMW_FEE_CTRL_PRWRITE
);
486 #ifdef DOESNT_SEEM_TO_WORK /* disabled */
488 mmc_out(ioaddr
, mmwoff(0, mmw_fee_ctrl
), MMW_FEE_CTRL_PRCLEAR
);
489 #endif /* DOESNT_SEEM_TO_WORK */
491 fee_wait(ioaddr
, 10, 100);
492 #endif /* EEPROM_IS_PROTECTED */
495 mmc_out(ioaddr
, mmwoff(0, mmw_fee_addr
), MMW_FEE_ADDR_EN
);
496 mmc_out(ioaddr
, mmwoff(0, mmw_fee_ctrl
), MMW_FEE_CTRL_WREN
);
498 fee_wait(ioaddr
, 10, 100);
500 /* Write the EEPROM address. */
501 mmc_out(ioaddr
, mmwoff(0, mmw_fee_addr
), o
+ n
- 1);
503 /* Loop on all buffer */
505 /* Write the value. */
506 mmc_out(ioaddr
, mmwoff(0, mmw_fee_data_h
), (*--b
) >> 8);
507 mmc_out(ioaddr
, mmwoff(0, mmw_fee_data_l
), *b
& 0xFF);
509 /* Write the write command. */
510 mmc_out(ioaddr
, mmwoff(0, mmw_fee_ctrl
),
513 /* WaveLAN documentation says to wait at least 10 ms for EEBUSY = 0 */
515 fee_wait(ioaddr
, 10, 100);
519 mmc_out(ioaddr
, mmwoff(0, mmw_fee_addr
), MMW_FEE_ADDR_DS
);
520 mmc_out(ioaddr
, mmwoff(0, mmw_fee_ctrl
), MMW_FEE_CTRL_WDS
);
522 fee_wait(ioaddr
, 10, 100);
524 #ifdef EEPROM_IS_PROTECTED /* disabled */
525 /* Reprotect EEPROM. */
526 mmc_out(ioaddr
, mmwoff(0, mmw_fee_addr
), 0x00);
527 mmc_out(ioaddr
, mmwoff(0, mmw_fee_ctrl
), MMW_FEE_CTRL_PRWRITE
);
529 fee_wait(ioaddr
, 10, 100);
530 #endif /* EEPROM_IS_PROTECTED */
532 #endif /* WIRELESS_EXT */
534 /************************ I82586 SUBROUTINES *************************/
536 * Useful subroutines to manage the Ethernet controller
539 /*------------------------------------------------------------------*/
541 * Read bytes from the on-board RAM.
542 * Why does inlining this function make it fail?
544 static /*inline */ void obram_read(unsigned long ioaddr
,
545 u16 o
, u8
* b
, int n
)
547 outw(o
, PIOR1(ioaddr
));
548 insw(PIOP1(ioaddr
), (unsigned short *) b
, (n
+ 1) >> 1);
551 /*------------------------------------------------------------------*/
553 * Write bytes to the on-board RAM.
555 static inline void obram_write(unsigned long ioaddr
, u16 o
, u8
* b
, int n
)
557 outw(o
, PIOR1(ioaddr
));
558 outsw(PIOP1(ioaddr
), (unsigned short *) b
, (n
+ 1) >> 1);
561 /*------------------------------------------------------------------*/
563 * Acknowledge the reading of the status issued by the i82586.
565 static void wv_ack(device
* dev
)
567 net_local
*lp
= (net_local
*) dev
->priv
;
568 unsigned long ioaddr
= dev
->base_addr
;
572 obram_read(ioaddr
, scboff(OFFSET_SCB
, scb_status
),
573 (unsigned char *) &scb_cs
, sizeof(scb_cs
));
574 scb_cs
&= SCB_ST_INT
;
579 obram_write(ioaddr
, scboff(OFFSET_SCB
, scb_command
),
580 (unsigned char *) &scb_cs
, sizeof(scb_cs
));
582 set_chan_attn(ioaddr
, lp
->hacr
);
584 for (i
= 1000; i
> 0; i
--) {
585 obram_read(ioaddr
, scboff(OFFSET_SCB
, scb_command
),
586 (unsigned char *) &scb_cs
, sizeof(scb_cs
));
594 #ifdef DEBUG_CONFIG_ERROR
597 "%s: wv_ack(): board not accepting command.\n",
602 /*------------------------------------------------------------------*/
604 * Set channel attention bit and busy wait until command has
605 * completed, then acknowledge completion of the command.
607 static inline int wv_synchronous_cmd(device
* dev
, const char *str
)
609 net_local
*lp
= (net_local
*) dev
->priv
;
610 unsigned long ioaddr
= dev
->base_addr
;
615 scb_cmd
= SCB_CMD_CUC
& SCB_CMD_CUC_GO
;
616 obram_write(ioaddr
, scboff(OFFSET_SCB
, scb_command
),
617 (unsigned char *) &scb_cmd
, sizeof(scb_cmd
));
619 set_chan_attn(ioaddr
, lp
->hacr
);
621 for (i
= 1000; i
> 0; i
--) {
622 obram_read(ioaddr
, OFFSET_CU
, (unsigned char *) &cb
,
624 if (cb
.ac_status
& AC_SFLD_C
)
631 if (i
<= 0 || !(cb
.ac_status
& AC_SFLD_OK
)) {
632 #ifdef DEBUG_CONFIG_ERROR
633 printk(KERN_INFO
"%s: %s failed; status = 0x%x\n",
634 dev
->name
, str
, cb
.ac_status
);
636 #ifdef DEBUG_I82586_SHOW
648 /*------------------------------------------------------------------*/
650 * Configuration commands completion interrupt.
651 * Check if done, and if OK.
654 wv_config_complete(device
* dev
, unsigned long ioaddr
, net_local
* lp
)
656 unsigned short mcs_addr
;
657 unsigned short status
;
660 #ifdef DEBUG_INTERRUPT_TRACE
661 printk(KERN_DEBUG
"%s: ->wv_config_complete()\n", dev
->name
);
664 mcs_addr
= lp
->tx_first_in_use
+ sizeof(ac_tx_t
) + sizeof(ac_nop_t
)
665 + sizeof(tbd_t
) + sizeof(ac_cfg_t
) + sizeof(ac_ias_t
);
667 /* Read the status of the last command (set mc list). */
668 obram_read(ioaddr
, acoff(mcs_addr
, ac_status
),
669 (unsigned char *) &status
, sizeof(status
));
671 /* If not completed -> exit */
672 if ((status
& AC_SFLD_C
) == 0)
673 ret
= 0; /* Not ready to be scrapped */
675 #ifdef DEBUG_CONFIG_ERROR
676 unsigned short cfg_addr
;
677 unsigned short ias_addr
;
679 /* Check mc_config command */
680 if ((status
& AC_SFLD_OK
) != AC_SFLD_OK
)
682 "%s: wv_config_complete(): set_multicast_address failed; status = 0x%x\n",
685 /* check ia-config command */
686 ias_addr
= mcs_addr
- sizeof(ac_ias_t
);
687 obram_read(ioaddr
, acoff(ias_addr
, ac_status
),
688 (unsigned char *) &status
, sizeof(status
));
689 if ((status
& AC_SFLD_OK
) != AC_SFLD_OK
)
691 "%s: wv_config_complete(): set_MAC_address failed; status = 0x%x\n",
694 /* Check config command. */
695 cfg_addr
= ias_addr
- sizeof(ac_cfg_t
);
696 obram_read(ioaddr
, acoff(cfg_addr
, ac_status
),
697 (unsigned char *) &status
, sizeof(status
));
698 if ((status
& AC_SFLD_OK
) != AC_SFLD_OK
)
700 "%s: wv_config_complete(): configure failed; status = 0x%x\n",
702 #endif /* DEBUG_CONFIG_ERROR */
704 ret
= 1; /* Ready to be scrapped */
707 #ifdef DEBUG_INTERRUPT_TRACE
708 printk(KERN_DEBUG
"%s: <-wv_config_complete() - %d\n", dev
->name
,
714 /*------------------------------------------------------------------*/
716 * Command completion interrupt.
717 * Reclaim as many freed tx buffers as we can.
718 * (called in wavelan_interrupt()).
719 * Note : the spinlock is already grabbed for us.
721 static int wv_complete(device
* dev
, unsigned long ioaddr
, net_local
* lp
)
725 #ifdef DEBUG_INTERRUPT_TRACE
726 printk(KERN_DEBUG
"%s: ->wv_complete()\n", dev
->name
);
729 /* Loop on all the transmit buffers */
730 while (lp
->tx_first_in_use
!= I82586NULL
) {
731 unsigned short tx_status
;
733 /* Read the first transmit buffer */
734 obram_read(ioaddr
, acoff(lp
->tx_first_in_use
, ac_status
),
735 (unsigned char *) &tx_status
,
738 /* If not completed -> exit */
739 if ((tx_status
& AC_SFLD_C
) == 0)
742 /* Hack for reconfiguration */
743 if (tx_status
== 0xFFFF)
744 if (!wv_config_complete(dev
, ioaddr
, lp
))
745 break; /* Not completed */
747 /* We now remove this buffer */
752 if (lp->tx_n_in_use > 0)
753 printk("%c", "0123456789abcdefghijk"[lp->tx_n_in_use]);
756 /* Was it the last one? */
757 if (lp
->tx_n_in_use
<= 0)
758 lp
->tx_first_in_use
= I82586NULL
;
760 /* Next one in the chain */
761 lp
->tx_first_in_use
+= TXBLOCKZ
;
762 if (lp
->tx_first_in_use
>=
764 NTXBLOCKS
* TXBLOCKZ
) lp
->tx_first_in_use
-=
765 NTXBLOCKS
* TXBLOCKZ
;
768 /* Hack for reconfiguration */
769 if (tx_status
== 0xFFFF)
772 /* Now, check status of the finished command */
773 if (tx_status
& AC_SFLD_OK
) {
776 lp
->stats
.tx_packets
++;
777 ncollisions
= tx_status
& AC_SFLD_MAXCOL
;
778 lp
->stats
.collisions
+= ncollisions
;
782 "%s: wv_complete(): tx completed after %d collisions.\n",
783 dev
->name
, ncollisions
);
786 lp
->stats
.tx_errors
++;
787 if (tx_status
& AC_SFLD_S10
) {
788 lp
->stats
.tx_carrier_errors
++;
791 "%s: wv_complete(): tx error: no CS.\n",
795 if (tx_status
& AC_SFLD_S9
) {
796 lp
->stats
.tx_carrier_errors
++;
799 "%s: wv_complete(): tx error: lost CTS.\n",
803 if (tx_status
& AC_SFLD_S8
) {
804 lp
->stats
.tx_fifo_errors
++;
807 "%s: wv_complete(): tx error: slow DMA.\n",
811 if (tx_status
& AC_SFLD_S6
) {
812 lp
->stats
.tx_heartbeat_errors
++;
815 "%s: wv_complete(): tx error: heart beat.\n",
819 if (tx_status
& AC_SFLD_S5
) {
820 lp
->stats
.tx_aborted_errors
++;
823 "%s: wv_complete(): tx error: too many collisions.\n",
831 "%s: wv_complete(): tx completed, tx_status 0x%04x\n",
832 dev
->name
, tx_status
);
836 #ifdef DEBUG_INTERRUPT_INFO
838 printk(KERN_DEBUG
"%s: wv_complete(): reaped %d\n",
843 * Inform upper layers.
845 if (lp
->tx_n_in_use
< NTXBLOCKS
- 1) {
846 netif_wake_queue(dev
);
848 #ifdef DEBUG_INTERRUPT_TRACE
849 printk(KERN_DEBUG
"%s: <-wv_complete()\n", dev
->name
);
854 /*------------------------------------------------------------------*/
856 * Reconfigure the i82586, or at least ask for it.
857 * Because wv_82586_config uses a transmission buffer, we must do it
858 * when we are sure that there is one left, so we do it now
859 * or in wavelan_packet_xmit() (I can't find any better place,
860 * wavelan_interrupt is not an option), so you may experience
863 static inline void wv_82586_reconfig(device
* dev
)
865 net_local
*lp
= (net_local
*) dev
->priv
;
868 /* Arm the flag, will be cleard in wv_82586_config() */
869 lp
->reconfig_82586
= 1;
871 /* Check if we can do it now ! */
872 if((netif_running(dev
)) && !(netif_queue_stopped(dev
))) {
873 wv_splhi(lp
, &flags
);
875 wv_82586_config(dev
);
879 #ifdef DEBUG_CONFIG_INFO
881 "%s: wv_82586_reconfig(): delayed (state = %lX)\n",
882 dev
->name
, dev
->state
);
887 /********************* DEBUG & INFO SUBROUTINES *********************/
889 * This routine is used in the code to show information for debugging.
890 * Most of the time, it dumps the contents of hardware structures.
893 #ifdef DEBUG_PSA_SHOW
894 /*------------------------------------------------------------------*/
896 * Print the formatted contents of the Parameter Storage Area.
898 static void wv_psa_show(psa_t
* p
)
900 printk(KERN_DEBUG
"##### WaveLAN PSA contents: #####\n");
901 printk(KERN_DEBUG
"psa_io_base_addr_1: 0x%02X %02X %02X %02X\n",
902 p
->psa_io_base_addr_1
,
903 p
->psa_io_base_addr_2
,
904 p
->psa_io_base_addr_3
, p
->psa_io_base_addr_4
);
905 printk(KERN_DEBUG
"psa_rem_boot_addr_1: 0x%02X %02X %02X\n",
906 p
->psa_rem_boot_addr_1
,
907 p
->psa_rem_boot_addr_2
, p
->psa_rem_boot_addr_3
);
908 printk(KERN_DEBUG
"psa_holi_params: 0x%02x, ", p
->psa_holi_params
);
909 printk("psa_int_req_no: %d\n", p
->psa_int_req_no
);
910 #ifdef DEBUG_SHOW_UNUSED
912 "psa_unused0[]: %02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
913 p
->psa_unused0
[0], p
->psa_unused0
[1], p
->psa_unused0
[2],
914 p
->psa_unused0
[3], p
->psa_unused0
[4], p
->psa_unused0
[5],
916 #endif /* DEBUG_SHOW_UNUSED */
918 "psa_univ_mac_addr[]: %02x:%02x:%02x:%02x:%02x:%02x\n",
919 p
->psa_univ_mac_addr
[0], p
->psa_univ_mac_addr
[1],
920 p
->psa_univ_mac_addr
[2], p
->psa_univ_mac_addr
[3],
921 p
->psa_univ_mac_addr
[4], p
->psa_univ_mac_addr
[5]);
923 "psa_local_mac_addr[]: %02x:%02x:%02x:%02x:%02x:%02x\n",
924 p
->psa_local_mac_addr
[0], p
->psa_local_mac_addr
[1],
925 p
->psa_local_mac_addr
[2], p
->psa_local_mac_addr
[3],
926 p
->psa_local_mac_addr
[4], p
->psa_local_mac_addr
[5]);
927 printk(KERN_DEBUG
"psa_univ_local_sel: %d, ",
928 p
->psa_univ_local_sel
);
929 printk("psa_comp_number: %d, ", p
->psa_comp_number
);
930 printk("psa_thr_pre_set: 0x%02x\n", p
->psa_thr_pre_set
);
931 printk(KERN_DEBUG
"psa_feature_select/decay_prm: 0x%02x, ",
932 p
->psa_feature_select
);
933 printk("psa_subband/decay_update_prm: %d\n", p
->psa_subband
);
934 printk(KERN_DEBUG
"psa_quality_thr: 0x%02x, ", p
->psa_quality_thr
);
935 printk("psa_mod_delay: 0x%02x\n", p
->psa_mod_delay
);
936 printk(KERN_DEBUG
"psa_nwid: 0x%02x%02x, ", p
->psa_nwid
[0],
938 printk("psa_nwid_select: %d\n", p
->psa_nwid_select
);
939 printk(KERN_DEBUG
"psa_encryption_select: %d, ",
940 p
->psa_encryption_select
);
942 ("psa_encryption_key[]: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
943 p
->psa_encryption_key
[0], p
->psa_encryption_key
[1],
944 p
->psa_encryption_key
[2], p
->psa_encryption_key
[3],
945 p
->psa_encryption_key
[4], p
->psa_encryption_key
[5],
946 p
->psa_encryption_key
[6], p
->psa_encryption_key
[7]);
947 printk(KERN_DEBUG
"psa_databus_width: %d\n", p
->psa_databus_width
);
948 printk(KERN_DEBUG
"psa_call_code/auto_squelch: 0x%02x, ",
949 p
->psa_call_code
[0]);
951 ("psa_call_code[]: %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
952 p
->psa_call_code
[0], p
->psa_call_code
[1], p
->psa_call_code
[2],
953 p
->psa_call_code
[3], p
->psa_call_code
[4], p
->psa_call_code
[5],
954 p
->psa_call_code
[6], p
->psa_call_code
[7]);
955 #ifdef DEBUG_SHOW_UNUSED
956 printk(KERN_DEBUG
"psa_reserved[]: %02X:%02X:%02X:%02X\n",
958 p
->psa_reserved
[1], p
->psa_reserved
[2], p
->psa_reserved
[3]);
959 #endif /* DEBUG_SHOW_UNUSED */
960 printk(KERN_DEBUG
"psa_conf_status: %d, ", p
->psa_conf_status
);
961 printk("psa_crc: 0x%02x%02x, ", p
->psa_crc
[0], p
->psa_crc
[1]);
962 printk("psa_crc_status: 0x%02x\n", p
->psa_crc_status
);
964 #endif /* DEBUG_PSA_SHOW */
966 #ifdef DEBUG_MMC_SHOW
967 /*------------------------------------------------------------------*/
969 * Print the formatted status of the Modem Management Controller.
970 * This function needs to be completed.
972 static void wv_mmc_show(device
* dev
)
974 unsigned long ioaddr
= dev
->base_addr
;
975 net_local
*lp
= (net_local
*) dev
->priv
;
979 if (hasr_read(ioaddr
) & HASR_NO_CLK
) {
981 "%s: wv_mmc_show: modem not connected\n",
987 mmc_out(ioaddr
, mmwoff(0, mmw_freeze
), 1);
988 mmc_read(ioaddr
, 0, (u8
*) & m
, sizeof(m
));
989 mmc_out(ioaddr
, mmwoff(0, mmw_freeze
), 0);
991 #ifdef WIRELESS_EXT /* if wireless extension exists in the kernel */
992 /* Don't forget to update statistics */
993 lp
->wstats
.discard
.nwid
+=
994 (m
.mmr_wrong_nwid_h
<< 8) | m
.mmr_wrong_nwid_l
;
995 #endif /* WIRELESS_EXT */
997 printk(KERN_DEBUG
"##### WaveLAN modem status registers: #####\n");
998 #ifdef DEBUG_SHOW_UNUSED
1000 "mmc_unused0[]: %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
1001 m
.mmr_unused0
[0], m
.mmr_unused0
[1], m
.mmr_unused0
[2],
1002 m
.mmr_unused0
[3], m
.mmr_unused0
[4], m
.mmr_unused0
[5],
1003 m
.mmr_unused0
[6], m
.mmr_unused0
[7]);
1004 #endif /* DEBUG_SHOW_UNUSED */
1005 printk(KERN_DEBUG
"Encryption algorithm: %02X - Status: %02X\n",
1006 m
.mmr_des_avail
, m
.mmr_des_status
);
1007 #ifdef DEBUG_SHOW_UNUSED
1008 printk(KERN_DEBUG
"mmc_unused1[]: %02X:%02X:%02X:%02X:%02X\n",
1011 m
.mmr_unused1
[2], m
.mmr_unused1
[3], m
.mmr_unused1
[4]);
1012 #endif /* DEBUG_SHOW_UNUSED */
1013 printk(KERN_DEBUG
"dce_status: 0x%x [%s%s%s%s]\n",
1016 mmr_dce_status
& MMR_DCE_STATUS_RX_BUSY
) ?
1017 "energy detected," : "",
1019 mmr_dce_status
& MMR_DCE_STATUS_LOOPT_IND
) ?
1020 "loop test indicated," : "",
1022 mmr_dce_status
& MMR_DCE_STATUS_TX_BUSY
) ?
1023 "transmitter on," : "",
1025 mmr_dce_status
& MMR_DCE_STATUS_JBR_EXPIRED
) ?
1026 "jabber timer expired," : "");
1027 printk(KERN_DEBUG
"Dsp ID: %02X\n", m
.mmr_dsp_id
);
1028 #ifdef DEBUG_SHOW_UNUSED
1029 printk(KERN_DEBUG
"mmc_unused2[]: %02X:%02X\n",
1030 m
.mmr_unused2
[0], m
.mmr_unused2
[1]);
1031 #endif /* DEBUG_SHOW_UNUSED */
1032 printk(KERN_DEBUG
"# correct_nwid: %d, # wrong_nwid: %d\n",
1033 (m
.mmr_correct_nwid_h
<< 8) | m
.mmr_correct_nwid_l
,
1034 (m
.mmr_wrong_nwid_h
<< 8) | m
.mmr_wrong_nwid_l
);
1035 printk(KERN_DEBUG
"thr_pre_set: 0x%x [current signal %s]\n",
1036 m
.mmr_thr_pre_set
& MMR_THR_PRE_SET
,
1038 mmr_thr_pre_set
& MMR_THR_PRE_SET_CUR
) ? "above" :
1040 printk(KERN_DEBUG
"signal_lvl: %d [%s], ",
1041 m
.mmr_signal_lvl
& MMR_SIGNAL_LVL
,
1043 mmr_signal_lvl
& MMR_SIGNAL_LVL_VALID
) ? "new msg" :
1045 printk("silence_lvl: %d [%s], ",
1046 m
.mmr_silence_lvl
& MMR_SILENCE_LVL
,
1048 mmr_silence_lvl
& MMR_SILENCE_LVL_VALID
) ? "update done" :
1050 printk("sgnl_qual: 0x%x [%s]\n", m
.mmr_sgnl_qual
& MMR_SGNL_QUAL
,
1052 mmr_sgnl_qual
& MMR_SGNL_QUAL_ANT
) ? "Antenna 1" :
1054 #ifdef DEBUG_SHOW_UNUSED
1055 printk(KERN_DEBUG
"netw_id_l: %x\n", m
.mmr_netw_id_l
);
1056 #endif /* DEBUG_SHOW_UNUSED */
1058 #endif /* DEBUG_MMC_SHOW */
1060 #ifdef DEBUG_I82586_SHOW
1061 /*------------------------------------------------------------------*/
1063 * Print the last block of the i82586 memory.
1065 static void wv_scb_show(unsigned long ioaddr
)
1069 obram_read(ioaddr
, OFFSET_SCB
, (unsigned char *) &scb
,
1072 printk(KERN_DEBUG
"##### WaveLAN system control block: #####\n");
1074 printk(KERN_DEBUG
"status: ");
1075 printk("stat 0x%x[%s%s%s%s] ",
1077 scb_status
& (SCB_ST_CX
| SCB_ST_FR
| SCB_ST_CNA
|
1080 scb_status
& SCB_ST_CX
) ? "command completion interrupt," :
1081 "", (scb
.scb_status
& SCB_ST_FR
) ? "frame received," : "",
1083 scb_status
& SCB_ST_CNA
) ? "command unit not active," : "",
1085 scb_status
& SCB_ST_RNR
) ? "receiving unit not ready," :
1087 printk("cus 0x%x[%s%s%s] ", (scb
.scb_status
& SCB_ST_CUS
) >> 8,
1088 ((scb
.scb_status
& SCB_ST_CUS
) ==
1089 SCB_ST_CUS_IDLE
) ? "idle" : "",
1090 ((scb
.scb_status
& SCB_ST_CUS
) ==
1091 SCB_ST_CUS_SUSP
) ? "suspended" : "",
1092 ((scb
.scb_status
& SCB_ST_CUS
) ==
1093 SCB_ST_CUS_ACTV
) ? "active" : "");
1094 printk("rus 0x%x[%s%s%s%s]\n", (scb
.scb_status
& SCB_ST_RUS
) >> 4,
1095 ((scb
.scb_status
& SCB_ST_RUS
) ==
1096 SCB_ST_RUS_IDLE
) ? "idle" : "",
1097 ((scb
.scb_status
& SCB_ST_RUS
) ==
1098 SCB_ST_RUS_SUSP
) ? "suspended" : "",
1099 ((scb
.scb_status
& SCB_ST_RUS
) ==
1100 SCB_ST_RUS_NRES
) ? "no resources" : "",
1101 ((scb
.scb_status
& SCB_ST_RUS
) ==
1102 SCB_ST_RUS_RDY
) ? "ready" : "");
1104 printk(KERN_DEBUG
"command: ");
1105 printk("ack 0x%x[%s%s%s%s] ",
1107 scb_command
& (SCB_CMD_ACK_CX
| SCB_CMD_ACK_FR
|
1108 SCB_CMD_ACK_CNA
| SCB_CMD_ACK_RNR
)) >> 12,
1110 scb_command
& SCB_CMD_ACK_CX
) ? "ack cmd completion," : "",
1112 scb_command
& SCB_CMD_ACK_FR
) ? "ack frame received," : "",
1114 scb_command
& SCB_CMD_ACK_CNA
) ? "ack CU not active," : "",
1116 scb_command
& SCB_CMD_ACK_RNR
) ? "ack RU not ready," : "");
1117 printk("cuc 0x%x[%s%s%s%s%s] ",
1118 (scb
.scb_command
& SCB_CMD_CUC
) >> 8,
1119 ((scb
.scb_command
& SCB_CMD_CUC
) ==
1120 SCB_CMD_CUC_NOP
) ? "nop" : "",
1121 ((scb
.scb_command
& SCB_CMD_CUC
) ==
1122 SCB_CMD_CUC_GO
) ? "start cbl_offset" : "",
1123 ((scb
.scb_command
& SCB_CMD_CUC
) ==
1124 SCB_CMD_CUC_RES
) ? "resume execution" : "",
1125 ((scb
.scb_command
& SCB_CMD_CUC
) ==
1126 SCB_CMD_CUC_SUS
) ? "suspend execution" : "",
1127 ((scb
.scb_command
& SCB_CMD_CUC
) ==
1128 SCB_CMD_CUC_ABT
) ? "abort execution" : "");
1129 printk("ruc 0x%x[%s%s%s%s%s]\n",
1130 (scb
.scb_command
& SCB_CMD_RUC
) >> 4,
1131 ((scb
.scb_command
& SCB_CMD_RUC
) ==
1132 SCB_CMD_RUC_NOP
) ? "nop" : "",
1133 ((scb
.scb_command
& SCB_CMD_RUC
) ==
1134 SCB_CMD_RUC_GO
) ? "start rfa_offset" : "",
1135 ((scb
.scb_command
& SCB_CMD_RUC
) ==
1136 SCB_CMD_RUC_RES
) ? "resume reception" : "",
1137 ((scb
.scb_command
& SCB_CMD_RUC
) ==
1138 SCB_CMD_RUC_SUS
) ? "suspend reception" : "",
1139 ((scb
.scb_command
& SCB_CMD_RUC
) ==
1140 SCB_CMD_RUC_ABT
) ? "abort reception" : "");
1142 printk(KERN_DEBUG
"cbl_offset 0x%x ", scb
.scb_cbl_offset
);
1143 printk("rfa_offset 0x%x\n", scb
.scb_rfa_offset
);
1145 printk(KERN_DEBUG
"crcerrs %d ", scb
.scb_crcerrs
);
1146 printk("alnerrs %d ", scb
.scb_alnerrs
);
1147 printk("rscerrs %d ", scb
.scb_rscerrs
);
1148 printk("ovrnerrs %d\n", scb
.scb_ovrnerrs
);
1151 /*------------------------------------------------------------------*/
1153 * Print the formatted status of the i82586's receive unit.
1155 static void wv_ru_show(device
* dev
)
1157 /* net_local *lp = (net_local *) dev->priv; */
1160 "##### WaveLAN i82586 receiver unit status: #####\n");
1161 printk(KERN_DEBUG
"ru:");
1163 * Not implemented yet
1168 /*------------------------------------------------------------------*/
1170 * Display info about one control block of the i82586 memory.
1172 static void wv_cu_show_one(device
* dev
, net_local
* lp
, int i
, u16 p
)
1174 unsigned long ioaddr
;
1177 ioaddr
= dev
->base_addr
;
1179 printk("%d: 0x%x:", i
, p
);
1181 obram_read(ioaddr
, p
, (unsigned char *) &actx
, sizeof(actx
));
1182 printk(" status=0x%x,", actx
.tx_h
.ac_status
);
1183 printk(" command=0x%x,", actx
.tx_h
.ac_command
);
1189 obram_read(ioaddr, actx.tx_tbd_offset, (unsigned char *)&tbd, sizeof(tbd));
1190 printk(" tbd_status=0x%x,", tbd.tbd_status);
1197 /*------------------------------------------------------------------*/
1199 * Print status of the command unit of the i82586.
1201 static void wv_cu_show(device
* dev
)
1203 net_local
*lp
= (net_local
*) dev
->priv
;
1208 "##### WaveLAN i82586 command unit status: #####\n");
1211 for (i
= 0, p
= lp
->tx_first_in_use
; i
< NTXBLOCKS
; i
++) {
1212 wv_cu_show_one(dev
, lp
, i
, p
);
1215 if (p
>= OFFSET_CU
+ NTXBLOCKS
* TXBLOCKZ
)
1216 p
-= NTXBLOCKS
* TXBLOCKZ
;
1220 #endif /* DEBUG_I82586_SHOW */
1222 #ifdef DEBUG_DEVICE_SHOW
1223 /*------------------------------------------------------------------*/
1225 * Print the formatted status of the WaveLAN PCMCIA device driver.
1227 static void wv_dev_show(device
* dev
)
1229 printk(KERN_DEBUG
"dev:");
1230 printk(" state=%lX,", dev
->state
);
1231 printk(" trans_start=%ld,", dev
->trans_start
);
1232 printk(" flags=0x%x,", dev
->flags
);
1236 /*------------------------------------------------------------------*/
1238 * Print the formatted status of the WaveLAN PCMCIA device driver's
1239 * private information.
1241 static void wv_local_show(device
* dev
)
1245 lp
= (net_local
*) dev
->priv
;
1247 printk(KERN_DEBUG
"local:");
1248 printk(" tx_n_in_use=%d,", lp
->tx_n_in_use
);
1249 printk(" hacr=0x%x,", lp
->hacr
);
1250 printk(" rx_head=0x%x,", lp
->rx_head
);
1251 printk(" rx_last=0x%x,", lp
->rx_last
);
1252 printk(" tx_first_free=0x%x,", lp
->tx_first_free
);
1253 printk(" tx_first_in_use=0x%x,", lp
->tx_first_in_use
);
1255 } /* wv_local_show */
1256 #endif /* DEBUG_DEVICE_SHOW */
1258 #if defined(DEBUG_RX_INFO) || defined(DEBUG_TX_INFO)
1259 /*------------------------------------------------------------------*/
1261 * Dump packet header (and content if necessary) on the screen
1263 static inline void wv_packet_info(u8
* p
, /* Packet to dump */
1264 int length
, /* Length of the packet */
1265 char *msg1
, /* Name of the device */
1267 { /* Name of the function */
1272 "%s: %s(): dest %02X:%02X:%02X:%02X:%02X:%02X, length %d\n",
1273 msg1
, msg2
, p
[0], p
[1], p
[2], p
[3], p
[4], p
[5], length
);
1275 "%s: %s(): src %02X:%02X:%02X:%02X:%02X:%02X, type 0x%02X%02X\n",
1276 msg1
, msg2
, p
[6], p
[7], p
[8], p
[9], p
[10], p
[11], p
[12],
1279 #ifdef DEBUG_PACKET_DUMP
1281 printk(KERN_DEBUG
"data=\"");
1283 if ((maxi
= length
) > DEBUG_PACKET_DUMP
)
1284 maxi
= DEBUG_PACKET_DUMP
;
1285 for (i
= 14; i
< maxi
; i
++)
1286 if (p
[i
] >= ' ' && p
[i
] <= '~')
1287 printk(" %c", p
[i
]);
1289 printk("%02X", p
[i
]);
1293 printk(KERN_DEBUG
"\n");
1294 #endif /* DEBUG_PACKET_DUMP */
1296 #endif /* defined(DEBUG_RX_INFO) || defined(DEBUG_TX_INFO) */
1298 /*------------------------------------------------------------------*/
1300 * This is the information which is displayed by the driver at startup.
1301 * There are lots of flags for configuring it to your liking.
1303 static inline void wv_init_info(device
* dev
)
1305 short ioaddr
= dev
->base_addr
;
1306 net_local
*lp
= (net_local
*) dev
->priv
;
1310 /* Read the parameter storage area */
1311 psa_read(ioaddr
, lp
->hacr
, 0, (unsigned char *) &psa
, sizeof(psa
));
1313 #ifdef DEBUG_PSA_SHOW
1316 #ifdef DEBUG_MMC_SHOW
1319 #ifdef DEBUG_I82586_SHOW
1323 #ifdef DEBUG_BASIC_SHOW
1324 /* Now, let's go for the basic stuff. */
1325 printk(KERN_NOTICE
"%s: WaveLAN at %#x,", dev
->name
, ioaddr
);
1326 for (i
= 0; i
< WAVELAN_ADDR_SIZE
; i
++)
1327 printk("%s%02X", (i
== 0) ? " " : ":", dev
->dev_addr
[i
]);
1328 printk(", IRQ %d", dev
->irq
);
1330 /* Print current network ID. */
1331 if (psa
.psa_nwid_select
)
1332 printk(", nwid 0x%02X-%02X", psa
.psa_nwid
[0],
1335 printk(", nwid off");
1338 if (!(mmc_in(ioaddr
, mmroff(0, mmr_fee_status
)) &
1339 (MMR_FEE_STATUS_DWLD
| MMR_FEE_STATUS_BUSY
))) {
1340 unsigned short freq
;
1342 /* Ask the EEPROM to read the frequency from the first area. */
1343 fee_read(ioaddr
, 0x00, &freq
, 1);
1345 /* Print frequency */
1346 printk(", 2.00, %ld", (freq
>> 6) + 2400L);
1353 switch (psa
.psa_comp_number
) {
1354 case PSA_COMP_PC_AT_915
:
1355 case PSA_COMP_PC_AT_2400
:
1358 case PSA_COMP_PC_MC_915
:
1359 case PSA_COMP_PC_MC_2400
:
1362 case PSA_COMP_PCMCIA_915
:
1369 switch (psa
.psa_subband
) {
1370 case PSA_SUBBAND_915
:
1373 case PSA_SUBBAND_2425
:
1376 case PSA_SUBBAND_2460
:
1379 case PSA_SUBBAND_2484
:
1382 case PSA_SUBBAND_2430_5
:
1391 #endif /* DEBUG_BASIC_SHOW */
1393 #ifdef DEBUG_VERSION_SHOW
1394 /* Print version information */
1395 printk(KERN_NOTICE
"%s", version
);
1397 } /* wv_init_info */
1399 /********************* IOCTL, STATS & RECONFIG *********************/
1401 * We found here routines that are called by Linux on different
1402 * occasions after the configuration and not for transmitting data
1403 * These may be called when the user use ifconfig, /proc/net/dev
1404 * or wireless extensions
1407 /*------------------------------------------------------------------*/
1409 * Get the current Ethernet statistics. This may be called with the
1410 * card open or closed.
1411 * Used when the user read /proc/net/dev
1413 static en_stats
*wavelan_get_stats(device
* dev
)
1415 #ifdef DEBUG_IOCTL_TRACE
1416 printk(KERN_DEBUG
"%s: <>wavelan_get_stats()\n", dev
->name
);
1419 return (&((net_local
*) dev
->priv
)->stats
);
1422 /*------------------------------------------------------------------*/
1424 * Set or clear the multicast filter for this adaptor.
1425 * num_addrs == -1 Promiscuous mode, receive all packets
1426 * num_addrs == 0 Normal mode, clear multicast list
1427 * num_addrs > 0 Multicast mode, receive normal and MC packets,
1428 * and do best-effort filtering.
1430 static void wavelan_set_multicast_list(device
* dev
)
1432 net_local
*lp
= (net_local
*) dev
->priv
;
1434 #ifdef DEBUG_IOCTL_TRACE
1435 printk(KERN_DEBUG
"%s: ->wavelan_set_multicast_list()\n",
1439 #ifdef DEBUG_IOCTL_INFO
1441 "%s: wavelan_set_multicast_list(): setting Rx mode %02X to %d addresses.\n",
1442 dev
->name
, dev
->flags
, dev
->mc_count
);
1445 /* Are we asking for promiscuous mode,
1446 * or all multicast addresses (we don't have that!)
1447 * or too many multicast addresses for the hardware filter? */
1448 if ((dev
->flags
& IFF_PROMISC
) ||
1449 (dev
->flags
& IFF_ALLMULTI
) ||
1450 (dev
->mc_count
> I82586_MAX_MULTICAST_ADDRESSES
)) {
1452 * Enable promiscuous mode: receive all packets.
1454 if (!lp
->promiscuous
) {
1455 lp
->promiscuous
= 1;
1458 wv_82586_reconfig(dev
);
1460 /* Tell the kernel that we are doing a really bad job. */
1461 dev
->flags
|= IFF_PROMISC
;
1464 /* Are there multicast addresses to send? */
1465 if (dev
->mc_list
!= (struct dev_mc_list
*) NULL
) {
1467 * Disable promiscuous mode, but receive all packets
1470 #ifdef MULTICAST_AVOID
1471 if (lp
->promiscuous
|| (dev
->mc_count
!= lp
->mc_count
))
1474 lp
->promiscuous
= 0;
1475 lp
->mc_count
= dev
->mc_count
;
1477 wv_82586_reconfig(dev
);
1481 * Switch to normal mode: disable promiscuous mode and
1482 * clear the multicast list.
1484 if (lp
->promiscuous
|| lp
->mc_count
== 0) {
1485 lp
->promiscuous
= 0;
1488 wv_82586_reconfig(dev
);
1491 #ifdef DEBUG_IOCTL_TRACE
1492 printk(KERN_DEBUG
"%s: <-wavelan_set_multicast_list()\n",
1497 /*------------------------------------------------------------------*/
1499 * This function doesn't exist.
1500 * (Note : it was a nice way to test the reconfigure stuff...)
1502 #ifdef SET_MAC_ADDRESS
1503 static int wavelan_set_mac_address(device
* dev
, void *addr
)
1505 struct sockaddr
*mac
= addr
;
1507 /* Copy the address. */
1508 memcpy(dev
->dev_addr
, mac
->sa_data
, WAVELAN_ADDR_SIZE
);
1510 /* Reconfigure the beast. */
1511 wv_82586_reconfig(dev
);
1515 #endif /* SET_MAC_ADDRESS */
1517 #ifdef WIRELESS_EXT /* if wireless extensions exist in the kernel */
1519 /*------------------------------------------------------------------*/
1521 * Frequency setting (for hardware capable of it)
1522 * It's a bit complicated and you don't really want to look into it.
1523 * (called in wavelan_ioctl)
1525 static inline int wv_set_frequency(unsigned long ioaddr
, /* I/O port of the card */
1526 iw_freq
* frequency
)
1528 const int BAND_NUM
= 10; /* Number of bands */
1529 long freq
= 0L; /* offset to 2.4 GHz in .5 MHz */
1530 #ifdef DEBUG_IOCTL_INFO
1534 /* Setting by frequency */
1535 /* Theoretically, you may set any frequency between
1536 * the two limits with a 0.5 MHz precision. In practice,
1537 * I don't want you to have trouble with local regulations.
1539 if ((frequency
->e
== 1) &&
1540 (frequency
->m
>= (int) 2.412e8
)
1541 && (frequency
->m
<= (int) 2.487e8
)) {
1542 freq
= ((frequency
->m
/ 10000) - 24000L) / 5;
1545 /* Setting by channel (same as wfreqsel) */
1546 /* Warning: each channel is 22 MHz wide, so some of the channels
1547 * will interfere. */
1548 if ((frequency
->e
== 0) &&
1549 (frequency
->m
>= 0) && (frequency
->m
< BAND_NUM
)) {
1550 /* Get frequency offset. */
1551 freq
= channel_bands
[frequency
->m
] >> 1;
1554 /* Verify that the frequency is allowed. */
1556 u16 table
[10]; /* Authorized frequency table */
1558 /* Read the frequency table. */
1559 fee_read(ioaddr
, 0x71, table
, 10);
1561 #ifdef DEBUG_IOCTL_INFO
1562 printk(KERN_DEBUG
"Frequency table: ");
1563 for (i
= 0; i
< 10; i
++) {
1564 printk(" %04X", table
[i
]);
1569 /* Look in the table to see whether the frequency is allowed. */
1570 if (!(table
[9 - ((freq
- 24) / 16)] &
1571 (1 << ((freq
- 24) % 16)))) return -EINVAL
; /* not allowed */
1575 /* if we get a usable frequency */
1577 unsigned short area
[16];
1578 unsigned short dac
[2];
1579 unsigned short area_verify
[16];
1580 unsigned short dac_verify
[2];
1581 /* Corresponding gain (in the power adjust value table)
1582 * See AT&T WaveLAN Data Manual, REF 407-024689/E, page 3-8
1583 * and WCIN062D.DOC, page 6.2.9. */
1584 unsigned short power_limit
[] = { 40, 80, 120, 160, 0 };
1585 int power_band
= 0; /* Selected band */
1586 unsigned short power_adjust
; /* Correct value */
1588 /* Search for the gain. */
1590 while ((freq
> power_limit
[power_band
]) &&
1591 (power_limit
[++power_band
] != 0));
1593 /* Read the first area. */
1594 fee_read(ioaddr
, 0x00, area
, 16);
1597 fee_read(ioaddr
, 0x60, dac
, 2);
1599 /* Read the new power adjust value. */
1600 fee_read(ioaddr
, 0x6B - (power_band
>> 1), &power_adjust
,
1602 if (power_band
& 0x1)
1605 power_adjust
&= 0xFF;
1607 #ifdef DEBUG_IOCTL_INFO
1608 printk(KERN_DEBUG
"WaveLAN EEPROM Area 1: ");
1609 for (i
= 0; i
< 16; i
++) {
1610 printk(" %04X", area
[i
]);
1614 printk(KERN_DEBUG
"WaveLAN EEPROM DAC: %04X %04X\n",
1618 /* Frequency offset (for info only) */
1619 area
[0] = ((freq
<< 5) & 0xFFE0) | (area
[0] & 0x1F);
1621 /* Receiver Principle main divider coefficient */
1622 area
[3] = (freq
>> 1) + 2400L - 352L;
1623 area
[2] = ((freq
& 0x1) << 4) | (area
[2] & 0xFFEF);
1625 /* Transmitter Main divider coefficient */
1626 area
[13] = (freq
>> 1) + 2400L;
1627 area
[12] = ((freq
& 0x1) << 4) | (area
[2] & 0xFFEF);
1629 /* Other parts of the area are flags, bit streams or unused. */
1631 /* Set the value in the DAC. */
1632 dac
[1] = ((power_adjust
>> 1) & 0x7F) | (dac
[1] & 0xFF80);
1633 dac
[0] = ((power_adjust
& 0x1) << 4) | (dac
[0] & 0xFFEF);
1635 /* Write the first area. */
1636 fee_write(ioaddr
, 0x00, area
, 16);
1638 /* Write the DAC. */
1639 fee_write(ioaddr
, 0x60, dac
, 2);
1641 /* We now should verify here that the writing of the EEPROM went OK. */
1643 /* Reread the first area. */
1644 fee_read(ioaddr
, 0x00, area_verify
, 16);
1646 /* Reread the DAC. */
1647 fee_read(ioaddr
, 0x60, dac_verify
, 2);
1650 if (memcmp(area
, area_verify
, 16 * 2) ||
1651 memcmp(dac
, dac_verify
, 2 * 2)) {
1652 #ifdef DEBUG_IOCTL_ERROR
1654 "WaveLAN: wv_set_frequency: unable to write new frequency to EEPROM(?).\n");
1659 /* We must download the frequency parameters to the
1660 * synthesizers (from the EEPROM - area 1)
1661 * Note: as the EEPROM is automatically decremented, we set the end
1663 mmc_out(ioaddr
, mmwoff(0, mmw_fee_addr
), 0x0F);
1664 mmc_out(ioaddr
, mmwoff(0, mmw_fee_ctrl
),
1665 MMW_FEE_CTRL_READ
| MMW_FEE_CTRL_DWLD
);
1667 /* Wait until the download is finished. */
1668 fee_wait(ioaddr
, 100, 100);
1670 /* We must now download the power adjust value (gain) to
1671 * the synthesizers (from the EEPROM - area 7 - DAC). */
1672 mmc_out(ioaddr
, mmwoff(0, mmw_fee_addr
), 0x61);
1673 mmc_out(ioaddr
, mmwoff(0, mmw_fee_ctrl
),
1674 MMW_FEE_CTRL_READ
| MMW_FEE_CTRL_DWLD
);
1676 /* Wait for the download to finish. */
1677 fee_wait(ioaddr
, 100, 100);
1679 #ifdef DEBUG_IOCTL_INFO
1680 /* Verification of what we have done */
1682 printk(KERN_DEBUG
"WaveLAN EEPROM Area 1: ");
1683 for (i
= 0; i
< 16; i
++) {
1684 printk(" %04X", area_verify
[i
]);
1688 printk(KERN_DEBUG
"WaveLAN EEPROM DAC: %04X %04X\n",
1689 dac_verify
[0], dac_verify
[1]);
1694 return -EINVAL
; /* Bah, never get there... */
1697 /*------------------------------------------------------------------*/
1699 * Give the list of available frequencies.
1701 static inline int wv_frequency_list(unsigned long ioaddr
, /* I/O port of the card */
1702 iw_freq
* list
, /* List of frequencies to fill */
1704 { /* Maximum number of frequencies */
1705 u16 table
[10]; /* Authorized frequency table */
1706 long freq
= 0L; /* offset to 2.4 GHz in .5 MHz + 12 MHz */
1707 int i
; /* index in the table */
1708 int c
= 0; /* Channel number */
1710 /* Read the frequency table. */
1711 fee_read(ioaddr
, 0x71 /* frequency table */ , table
, 10);
1713 /* Check all frequencies. */
1715 for (freq
= 0; freq
< 150; freq
++)
1716 /* Look in the table if the frequency is allowed */
1717 if (table
[9 - (freq
/ 16)] & (1 << (freq
% 16))) {
1718 /* Compute approximate channel number */
1719 while ((((channel_bands
[c
] >> 1) - 24) < freq
) &&
1720 (c
< NELS(channel_bands
)))
1722 list
[i
].i
= c
; /* Set the list index */
1724 /* put in the list */
1725 list
[i
].m
= (((freq
+ 24) * 5) + 24000L) * 10000;
1737 /*------------------------------------------------------------------*/
1739 * Gather wireless spy statistics: for each packet, compare the source
1740 * address with our list, and if they match, get the statistics.
1741 * Sorry, but this function really needs the wireless extensions.
1743 static inline void wl_spy_gather(device
* dev
, u8
* mac
, /* MAC address */
1745 { /* Statistics to gather */
1746 net_local
*lp
= (net_local
*) dev
->priv
;
1749 /* Check all addresses. */
1750 for (i
= 0; i
< lp
->spy_number
; i
++)
1752 if (!memcmp(mac
, lp
->spy_address
[i
], WAVELAN_ADDR_SIZE
)) {
1753 /* Update statistics */
1754 lp
->spy_stat
[i
].qual
= stats
[2] & MMR_SGNL_QUAL
;
1755 lp
->spy_stat
[i
].level
= stats
[0] & MMR_SIGNAL_LVL
;
1756 lp
->spy_stat
[i
].noise
= stats
[1] & MMR_SILENCE_LVL
;
1757 lp
->spy_stat
[i
].updated
= 0x7;
1760 #endif /* WIRELESS_SPY */
1763 /*------------------------------------------------------------------*/
1765 * This function calculates a histogram of the signal level.
1766 * As the noise is quite constant, it's like doing it on the SNR.
1767 * We have defined a set of interval (lp->his_range), and each time
1768 * the level goes in that interval, we increment the count (lp->his_sum).
1769 * With this histogram you may detect if one WaveLAN is really weak,
1770 * or you may also calculate the mean and standard deviation of the level.
1772 static inline void wl_his_gather(device
* dev
, u8
* stats
)
1773 { /* Statistics to gather */
1774 net_local
*lp
= (net_local
*) dev
->priv
;
1775 u8 level
= stats
[0] & MMR_SIGNAL_LVL
;
1778 /* Find the correct interval. */
1780 while ((i
< (lp
->his_number
- 1))
1781 && (level
>= lp
->his_range
[i
++]));
1783 /* Increment interval counter. */
1786 #endif /* HISTOGRAM */
1788 /*------------------------------------------------------------------*/
1790 * Perform ioctl for configuration and information.
1791 * It is here that the wireless extensions are treated (iwconfig).
1793 static int wavelan_ioctl(struct net_device
*dev
, /* device on which the ioctl is applied */
1794 struct ifreq
*rq
, /* data passed */
1796 { /* ioctl number */
1797 unsigned long ioaddr
= dev
->base_addr
;
1798 net_local
*lp
= (net_local
*) dev
->priv
; /* lp is not unused */
1799 struct iwreq
*wrq
= (struct iwreq
*) rq
;
1802 unsigned long flags
;
1806 #ifdef DEBUG_IOCTL_TRACE
1807 printk(KERN_DEBUG
"%s: ->wavelan_ioctl(cmd=0x%X)\n", dev
->name
,
1811 /* Disable interrupts and save flags. */
1812 wv_splhi(lp
, &flags
);
1814 /* Look what is the request */
1816 /* --------------- WIRELESS EXTENSIONS --------------- */
1819 strcpy(wrq
->u
.name
, "WaveLAN");
1823 /* Set NWID in WaveLAN. */
1824 if (!wrq
->u
.nwid
.disabled
) {
1825 /* Set NWID in psa */
1827 (wrq
->u
.nwid
.value
& 0xFF00) >> 8;
1828 psa
.psa_nwid
[1] = wrq
->u
.nwid
.value
& 0xFF;
1829 psa
.psa_nwid_select
= 0x01;
1830 psa_write(ioaddr
, lp
->hacr
,
1831 (char *) psa
.psa_nwid
- (char *) &psa
,
1832 (unsigned char *) psa
.psa_nwid
, 3);
1834 /* Set NWID in mmc. */
1835 m
.w
.mmw_netw_id_l
= psa
.psa_nwid
[1];
1836 m
.w
.mmw_netw_id_h
= psa
.psa_nwid
[0];
1838 (char *) &m
.w
.mmw_netw_id_l
-
1840 (unsigned char *) &m
.w
.mmw_netw_id_l
, 2);
1841 mmc_out(ioaddr
, mmwoff(0, mmw_loopt_sel
), 0x00);
1843 /* Disable NWID in the psa. */
1844 psa
.psa_nwid_select
= 0x00;
1845 psa_write(ioaddr
, lp
->hacr
,
1846 (char *) &psa
.psa_nwid_select
-
1848 (unsigned char *) &psa
.psa_nwid_select
,
1851 /* Disable NWID in the mmc (no filtering). */
1852 mmc_out(ioaddr
, mmwoff(0, mmw_loopt_sel
),
1853 MMW_LOOPT_SEL_DIS_NWID
);
1855 /* update the Wavelan checksum */
1856 update_psa_checksum(dev
, ioaddr
, lp
->hacr
);
1860 /* Read the NWID. */
1861 psa_read(ioaddr
, lp
->hacr
,
1862 (char *) psa
.psa_nwid
- (char *) &psa
,
1863 (unsigned char *) psa
.psa_nwid
, 3);
1865 (psa
.psa_nwid
[0] << 8) + psa
.psa_nwid
[1];
1866 wrq
->u
.nwid
.disabled
= !(psa
.psa_nwid_select
);
1867 wrq
->u
.nwid
.fixed
= 1; /* Superfluous */
1871 /* Attempt to recognise 2.00 cards (2.4 GHz frequency selectable). */
1872 if (!(mmc_in(ioaddr
, mmroff(0, mmr_fee_status
)) &
1873 (MMR_FEE_STATUS_DWLD
| MMR_FEE_STATUS_BUSY
)))
1874 ret
= wv_set_frequency(ioaddr
, &(wrq
->u
.freq
));
1880 /* Attempt to recognise 2.00 cards (2.4 GHz frequency selectable).
1881 * Does it work for everybody, especially old cards? */
1882 if (!(mmc_in(ioaddr
, mmroff(0, mmr_fee_status
)) &
1883 (MMR_FEE_STATUS_DWLD
| MMR_FEE_STATUS_BUSY
))) {
1884 unsigned short freq
;
1886 /* Ask the EEPROM to read the frequency from the first area. */
1887 fee_read(ioaddr
, 0x00, &freq
, 1);
1888 wrq
->u
.freq
.m
= ((freq
>> 5) * 5 + 24000L) * 10000;
1891 psa_read(ioaddr
, lp
->hacr
,
1892 (char *) &psa
.psa_subband
- (char *) &psa
,
1893 (unsigned char *) &psa
.psa_subband
, 1);
1895 if (psa
.psa_subband
<= 4) {
1897 fixed_bands
[psa
.psa_subband
];
1898 wrq
->u
.freq
.e
= (psa
.psa_subband
!= 0);
1905 /* Set the level threshold. */
1906 /* We should complain loudly if wrq->u.sens.fixed = 0, because we
1907 * can't set auto mode... */
1908 psa
.psa_thr_pre_set
= wrq
->u
.sens
.value
& 0x3F;
1909 psa_write(ioaddr
, lp
->hacr
,
1910 (char *) &psa
.psa_thr_pre_set
- (char *) &psa
,
1911 (unsigned char *) &psa
.psa_thr_pre_set
, 1);
1912 /* update the Wavelan checksum */
1913 update_psa_checksum(dev
, ioaddr
, lp
->hacr
);
1914 mmc_out(ioaddr
, mmwoff(0, mmw_thr_pre_set
),
1915 psa
.psa_thr_pre_set
);
1919 /* Read the level threshold. */
1920 psa_read(ioaddr
, lp
->hacr
,
1921 (char *) &psa
.psa_thr_pre_set
- (char *) &psa
,
1922 (unsigned char *) &psa
.psa_thr_pre_set
, 1);
1923 wrq
->u
.sens
.value
= psa
.psa_thr_pre_set
& 0x3F;
1924 wrq
->u
.sens
.fixed
= 1;
1928 /* Set encryption key */
1929 if (!mmc_encr(ioaddr
)) {
1934 /* Basic checking... */
1935 if (wrq
->u
.encoding
.pointer
!= (caddr_t
) 0) {
1936 /* Check the size of the key */
1937 if (wrq
->u
.encoding
.length
!= 8) {
1942 /* Copy the key in the driver */
1943 wv_splx(lp
, &flags
);
1944 err
= copy_from_user(psa
.psa_encryption_key
,
1945 wrq
->u
.encoding
.pointer
,
1946 wrq
->u
.encoding
.length
);
1947 wv_splhi(lp
, &flags
);
1953 psa
.psa_encryption_select
= 1;
1954 psa_write(ioaddr
, lp
->hacr
,
1955 (char *) &psa
.psa_encryption_select
-
1957 (unsigned char *) &psa
.
1958 psa_encryption_select
, 8 + 1);
1960 mmc_out(ioaddr
, mmwoff(0, mmw_encr_enable
),
1961 MMW_ENCR_ENABLE_EN
| MMW_ENCR_ENABLE_MODE
);
1962 mmc_write(ioaddr
, mmwoff(0, mmw_encr_key
),
1963 (unsigned char *) &psa
.
1964 psa_encryption_key
, 8);
1967 if (wrq
->u
.encoding
.flags
& IW_ENCODE_DISABLED
) { /* disable encryption */
1968 psa
.psa_encryption_select
= 0;
1969 psa_write(ioaddr
, lp
->hacr
,
1970 (char *) &psa
.psa_encryption_select
-
1972 (unsigned char *) &psa
.
1973 psa_encryption_select
, 1);
1975 mmc_out(ioaddr
, mmwoff(0, mmw_encr_enable
), 0);
1977 /* update the Wavelan checksum */
1978 update_psa_checksum(dev
, ioaddr
, lp
->hacr
);
1982 /* Read the encryption key */
1983 if (!mmc_encr(ioaddr
)) {
1988 /* only super-user can see encryption key */
1989 if (!capable(CAP_NET_ADMIN
)) {
1994 /* Basic checking... */
1995 if (wrq
->u
.encoding
.pointer
!= (caddr_t
) 0) {
1996 /* Verify the user buffer */
1998 verify_area(VERIFY_WRITE
,
1999 wrq
->u
.encoding
.pointer
, 8);
2003 psa_read(ioaddr
, lp
->hacr
,
2004 (char *) &psa
.psa_encryption_select
-
2006 (unsigned char *) &psa
.
2007 psa_encryption_select
, 1 + 8);
2009 /* encryption is enabled ? */
2010 if (psa
.psa_encryption_select
)
2011 wrq
->u
.encoding
.flags
= IW_ENCODE_ENABLED
;
2013 wrq
->u
.encoding
.flags
= IW_ENCODE_DISABLED
;
2014 wrq
->u
.encoding
.flags
|= mmc_encr(ioaddr
);
2016 /* Copy the key to the user buffer */
2017 wrq
->u
.encoding
.length
= 8;
2018 wv_splx(lp
, &flags
);
2019 if (copy_to_user(wrq
->u
.encoding
.pointer
,
2020 psa
.psa_encryption_key
, 8))
2022 wv_splhi(lp
, &flags
);
2027 /* basic checking */
2028 if (wrq
->u
.data
.pointer
!= (caddr_t
) 0) {
2029 struct iw_range range
;
2031 /* Set the length (useless: it's constant). */
2032 wrq
->u
.data
.length
= sizeof(struct iw_range
);
2034 /* Set information in the range struct. */
2035 range
.throughput
= 1.6 * 1000 * 1000; /* don't argue on this ! */
2036 range
.min_nwid
= 0x0000;
2037 range
.max_nwid
= 0xFFFF;
2039 /* Attempt to recognise 2.00 cards (2.4 GHz frequency selectable). */
2040 if (!(mmc_in(ioaddr
, mmroff(0, mmr_fee_status
)) &
2041 (MMR_FEE_STATUS_DWLD
| MMR_FEE_STATUS_BUSY
))) {
2042 range
.num_channels
= 10;
2043 range
.num_frequency
=
2044 wv_frequency_list(ioaddr
, range
.freq
,
2045 IW_MAX_FREQUENCIES
);
2047 range
.num_channels
= range
.num_frequency
=
2050 range
.sensitivity
= 0x3F;
2051 range
.max_qual
.qual
= MMR_SGNL_QUAL
;
2052 range
.max_qual
.level
= MMR_SIGNAL_LVL
;
2053 range
.max_qual
.noise
= MMR_SILENCE_LVL
;
2055 range
.num_bitrates
= 1;
2056 range
.bitrate
[0] = 2000000; /* 2 Mb/s */
2058 /* Encryption supported ? */
2059 if (mmc_encr(ioaddr
)) {
2060 range
.encoding_size
[0] = 8; /* DES = 64 bits key */
2061 range
.num_encoding_sizes
= 1;
2062 range
.max_encoding_tokens
= 1; /* Only one key possible */
2064 range
.num_encoding_sizes
= 0;
2065 range
.max_encoding_tokens
= 0;
2068 /* Copy structure to the user buffer. */
2069 wv_splx(lp
, &flags
);
2070 if (copy_to_user(wrq
->u
.data
.pointer
,
2072 sizeof(struct iw_range
)))
2074 wv_splhi(lp
, &flags
);
2079 /* Basic checking */
2080 if (wrq
->u
.data
.pointer
!= (caddr_t
) 0) {
2081 struct iw_priv_args priv
[] = {
2087 IW_PRIV_TYPE_BYTE
| IW_PRIV_SIZE_FIXED
| 1,
2092 IW_PRIV_TYPE_BYTE
| IW_PRIV_SIZE_FIXED
| 1,
2095 IW_PRIV_TYPE_BYTE
| 16,
2100 IW_PRIV_TYPE_INT
| 16,
2104 /* Set the number of available ioctls. */
2105 wrq
->u
.data
.length
= 4;
2107 /* Copy structure to the user buffer. */
2108 wv_splx(lp
, &flags
);
2109 if (copy_to_user(wrq
->u
.data
.pointer
,
2113 wv_splhi(lp
, &flags
);
2119 /* Set the spy list */
2121 /* Check the number of addresses. */
2122 if (wrq
->u
.data
.length
> IW_MAX_SPY
) {
2126 lp
->spy_number
= wrq
->u
.data
.length
;
2128 /* Are there are addresses to copy? */
2129 if (lp
->spy_number
> 0) {
2130 struct sockaddr address
[IW_MAX_SPY
];
2133 /* Copy addresses to the driver. */
2134 wv_splx(lp
, &flags
);
2135 err
= copy_from_user(address
,
2136 wrq
->u
.data
.pointer
,
2137 sizeof(struct sockaddr
)
2139 wv_splhi(lp
, &flags
);
2145 /* Copy addresses to the lp structure. */
2146 for (i
= 0; i
< lp
->spy_number
; i
++) {
2147 memcpy(lp
->spy_address
[i
],
2152 /* Reset structure. */
2153 memset(lp
->spy_stat
, 0x00,
2154 sizeof(iw_qual
) * IW_MAX_SPY
);
2156 #ifdef DEBUG_IOCTL_INFO
2158 "SetSpy: set of new addresses is: \n");
2159 for (i
= 0; i
< wrq
->u
.data
.length
; i
++)
2161 "%02X:%02X:%02X:%02X:%02X:%02X \n",
2162 lp
->spy_address
[i
][0],
2163 lp
->spy_address
[i
][1],
2164 lp
->spy_address
[i
][2],
2165 lp
->spy_address
[i
][3],
2166 lp
->spy_address
[i
][4],
2167 lp
->spy_address
[i
][5]);
2168 #endif /* DEBUG_IOCTL_INFO */
2174 /* Get the spy list and spy stats. */
2176 /* Set the number of addresses */
2177 wrq
->u
.data
.length
= lp
->spy_number
;
2179 /* Does the user want to have the addresses back? */
2180 if ((lp
->spy_number
> 0)
2181 && (wrq
->u
.data
.pointer
!= (caddr_t
) 0)) {
2182 struct sockaddr address
[IW_MAX_SPY
];
2185 /* Copy addresses from the lp structure. */
2186 for (i
= 0; i
< lp
->spy_number
; i
++) {
2187 memcpy(address
[i
].sa_data
,
2190 address
[i
].sa_family
= AF_UNIX
;
2193 /* Copy addresses to the user buffer. */
2194 wv_splx(lp
, &flags
);
2195 err
= copy_to_user(wrq
->u
.data
.pointer
,
2197 sizeof(struct sockaddr
)
2200 /* Copy stats to the user buffer (just after). */
2201 err
|= copy_to_user(wrq
->u
.data
.pointer
2202 + (sizeof(struct sockaddr
)
2205 sizeof(iw_qual
) * lp
->spy_number
);
2206 wv_splhi(lp
, &flags
);
2212 /* Reset updated flags. */
2213 for (i
= 0; i
< lp
->spy_number
; i
++)
2214 lp
->spy_stat
[i
].updated
= 0x0;
2216 /* if(pointer != NULL) */
2218 #endif /* WIRELESS_SPY */
2220 /* ------------------ PRIVATE IOCTL ------------------ */
2223 if (!capable(CAP_NET_ADMIN
)) {
2227 psa
.psa_quality_thr
= *(wrq
->u
.name
) & 0x0F;
2228 psa_write(ioaddr
, lp
->hacr
,
2229 (char *) &psa
.psa_quality_thr
- (char *) &psa
,
2230 (unsigned char *) &psa
.psa_quality_thr
, 1);
2231 /* update the Wavelan checksum */
2232 update_psa_checksum(dev
, ioaddr
, lp
->hacr
);
2233 mmc_out(ioaddr
, mmwoff(0, mmw_quality_thr
),
2234 psa
.psa_quality_thr
);
2238 psa_read(ioaddr
, lp
->hacr
,
2239 (char *) &psa
.psa_quality_thr
- (char *) &psa
,
2240 (unsigned char *) &psa
.psa_quality_thr
, 1);
2241 *(wrq
->u
.name
) = psa
.psa_quality_thr
& 0x0F;
2246 /* Verify that the user is root. */
2247 if (!capable(CAP_NET_ADMIN
)) {
2252 /* Check the number of intervals. */
2253 if (wrq
->u
.data
.length
> 16) {
2257 lp
->his_number
= wrq
->u
.data
.length
;
2259 /* Are there addresses to copy? */
2260 if (lp
->his_number
> 0) {
2261 /* Copy interval ranges to the driver */
2262 wv_splx(lp
, &flags
);
2263 err
= copy_from_user(lp
->his_range
,
2264 wrq
->u
.data
.pointer
,
2265 sizeof(char) * lp
->his_number
);
2266 wv_splhi(lp
, &flags
);
2272 /* Reset structure. */
2273 memset(lp
->his_sum
, 0x00, sizeof(long) * 16);
2278 /* Set the number of intervals. */
2279 wrq
->u
.data
.length
= lp
->his_number
;
2281 /* Give back the distribution statistics */
2282 if ((lp
->his_number
> 0)
2283 && (wrq
->u
.data
.pointer
!= (caddr_t
) 0)) {
2284 /* Copy data to the user buffer. */
2285 wv_splx(lp
, &flags
);
2286 if (copy_to_user(wrq
->u
.data
.pointer
,
2288 sizeof(long) * lp
->his_number
);
2290 wv_splhi(lp
, &flags
);
2292 } /* if(pointer != NULL) */
2294 #endif /* HISTOGRAM */
2296 /* ------------------- OTHER IOCTL ------------------- */
2300 } /* switch (cmd) */
2302 /* Enable interrupts and restore flags. */
2303 wv_splx(lp
, &flags
);
2305 #ifdef DEBUG_IOCTL_TRACE
2306 printk(KERN_DEBUG
"%s: <-wavelan_ioctl()\n", dev
->name
);
2311 /*------------------------------------------------------------------*/
2313 * Get wireless statistics.
2314 * Called by /proc/net/wireless
2316 static iw_stats
*wavelan_get_wireless_stats(device
* dev
)
2318 unsigned long ioaddr
= dev
->base_addr
;
2319 net_local
*lp
= (net_local
*) dev
->priv
;
2322 unsigned long flags
;
2324 #ifdef DEBUG_IOCTL_TRACE
2325 printk(KERN_DEBUG
"%s: ->wavelan_get_wireless_stats()\n",
2330 if (lp
== (net_local
*) NULL
)
2331 return (iw_stats
*) NULL
;
2333 /* Disable interrupts and save flags. */
2334 wv_splhi(lp
, &flags
);
2336 wstats
= &lp
->wstats
;
2338 /* Get data from the mmc. */
2339 mmc_out(ioaddr
, mmwoff(0, mmw_freeze
), 1);
2341 mmc_read(ioaddr
, mmroff(0, mmr_dce_status
), &m
.mmr_dce_status
, 1);
2342 mmc_read(ioaddr
, mmroff(0, mmr_wrong_nwid_l
), &m
.mmr_wrong_nwid_l
,
2344 mmc_read(ioaddr
, mmroff(0, mmr_thr_pre_set
), &m
.mmr_thr_pre_set
,
2347 mmc_out(ioaddr
, mmwoff(0, mmw_freeze
), 0);
2349 /* Copy data to wireless stuff. */
2350 wstats
->status
= m
.mmr_dce_status
& MMR_DCE_STATUS
;
2351 wstats
->qual
.qual
= m
.mmr_sgnl_qual
& MMR_SGNL_QUAL
;
2352 wstats
->qual
.level
= m
.mmr_signal_lvl
& MMR_SIGNAL_LVL
;
2353 wstats
->qual
.noise
= m
.mmr_silence_lvl
& MMR_SILENCE_LVL
;
2354 wstats
->qual
.updated
= (((m
. mmr_signal_lvl
& MMR_SIGNAL_LVL_VALID
) >> 7)
2355 | ((m
.mmr_signal_lvl
& MMR_SIGNAL_LVL_VALID
) >> 6)
2356 | ((m
.mmr_silence_lvl
& MMR_SILENCE_LVL_VALID
) >> 5));
2357 wstats
->discard
.nwid
+= (m
.mmr_wrong_nwid_h
<< 8) | m
.mmr_wrong_nwid_l
;
2358 wstats
->discard
.code
= 0L;
2359 wstats
->discard
.misc
= 0L;
2361 /* Enable interrupts and restore flags. */
2362 wv_splx(lp
, &flags
);
2364 #ifdef DEBUG_IOCTL_TRACE
2365 printk(KERN_DEBUG
"%s: <-wavelan_get_wireless_stats()\n",
2370 #endif /* WIRELESS_EXT */
2372 /************************* PACKET RECEPTION *************************/
2374 * This part deals with receiving the packets.
2375 * The interrupt handler gets an interrupt when a packet has been
2376 * successfully received and calls this part.
2379 /*------------------------------------------------------------------*/
2381 * This routine does the actual copying of data (including the Ethernet
2382 * header structure) from the WaveLAN card to an sk_buff chain that
2383 * will be passed up to the network interface layer. NOTE: we
2384 * currently don't handle trailer protocols (neither does the rest of
2385 * the network interface), so if that is needed, it will (at least in
2386 * part) be added here. The contents of the receive ring buffer are
2387 * copied to a message chain that is then passed to the kernel.
2389 * Note: if any errors occur, the packet is "dropped on the floor".
2390 * (called by wv_packet_rcv())
2393 wv_packet_read(device
* dev
, u16 buf_off
, int sksize
)
2395 net_local
*lp
= (net_local
*) dev
->priv
;
2396 unsigned long ioaddr
= dev
->base_addr
;
2397 struct sk_buff
*skb
;
2399 #ifdef DEBUG_RX_TRACE
2400 printk(KERN_DEBUG
"%s: ->wv_packet_read(0x%X, %d)\n",
2401 dev
->name
, buf_off
, sksize
);
2404 /* Allocate buffer for the data */
2405 if ((skb
= dev_alloc_skb(sksize
)) == (struct sk_buff
*) NULL
) {
2406 #ifdef DEBUG_RX_ERROR
2408 "%s: wv_packet_read(): could not alloc_skb(%d, GFP_ATOMIC).\n",
2411 lp
->stats
.rx_dropped
++;
2417 /* Copy the packet to the buffer. */
2418 obram_read(ioaddr
, buf_off
, skb_put(skb
, sksize
), sksize
);
2419 skb
->protocol
= eth_type_trans(skb
, dev
);
2421 #ifdef DEBUG_RX_INFO
2422 wv_packet_info(skb
->mac
.raw
, sksize
, dev
->name
, "wv_packet_read");
2423 #endif /* DEBUG_RX_INFO */
2425 /* Statistics-gathering and associated stuff.
2426 * It seem a bit messy with all the define, but it's really simple... */
2427 #if defined(WIRELESS_SPY) || defined(HISTOGRAM)
2430 (lp
->spy_number
> 0) ||
2431 #endif /* WIRELESS_SPY */
2433 (lp
->his_number
> 0) ||
2434 #endif /* HISTOGRAM */
2436 u8 stats
[3]; /* signal level, noise level, signal quality */
2438 /* Read signal level, silence level and signal quality bytes. */
2439 /* Note: in the PCMCIA hardware, these are part of the frame. It seems
2440 * that for the ISA hardware, it's nowhere to be found in the frame,
2441 * so I'm obliged to do this (it has a side effect on /proc/net/wireless).
2444 mmc_out(ioaddr
, mmwoff(0, mmw_freeze
), 1);
2445 mmc_read(ioaddr
, mmroff(0, mmr_signal_lvl
), stats
, 3);
2446 mmc_out(ioaddr
, mmwoff(0, mmw_freeze
), 0);
2448 #ifdef DEBUG_RX_INFO
2450 "%s: wv_packet_read(): Signal level %d/63, Silence level %d/63, signal quality %d/16\n",
2451 dev
->name
, stats
[0] & 0x3F, stats
[1] & 0x3F,
2457 wl_spy_gather(dev
, skb
->mac
.raw
+ WAVELAN_ADDR_SIZE
,
2459 #endif /* WIRELESS_SPY */
2461 wl_his_gather(dev
, stats
);
2462 #endif /* HISTOGRAM */
2464 #endif /* defined(WIRELESS_SPY) || defined(HISTOGRAM) */
2467 * Hand the packet to the network module.
2471 /* Keep statistics up to date */
2472 lp
->stats
.rx_packets
++;
2473 lp
->stats
.rx_bytes
+= skb
->len
;
2475 #ifdef DEBUG_RX_TRACE
2476 printk(KERN_DEBUG
"%s: <-wv_packet_read()\n", dev
->name
);
2480 /*------------------------------------------------------------------*/
2482 * Transfer as many packets as we can
2483 * from the device RAM.
2484 * (called in wavelan_interrupt()).
2485 * Note : the spinlock is already grabbed for us.
2487 static inline void wv_receive(device
* dev
)
2489 unsigned long ioaddr
= dev
->base_addr
;
2490 net_local
*lp
= (net_local
*) dev
->priv
;
2495 #ifdef DEBUG_RX_TRACE
2496 printk(KERN_DEBUG
"%s: ->wv_receive()\n", dev
->name
);
2499 /* Loop on each received packet. */
2501 obram_read(ioaddr
, lp
->rx_head
, (unsigned char *) &fd
,
2504 /* Note about the status :
2505 * It start up to be 0 (the value we set). Then, when the RU
2506 * grab the buffer to prepare for reception, it sets the
2507 * FD_STATUS_B flag. When the RU has finished receiving the
2508 * frame, it clears FD_STATUS_B, set FD_STATUS_C to indicate
2509 * completion and set the other flags to indicate the eventual
2510 * errors. FD_STATUS_OK indicates that the reception was OK.
2513 /* If the current frame is not complete, we have reached the end. */
2514 if ((fd
.fd_status
& FD_STATUS_C
) != FD_STATUS_C
)
2515 break; /* This is how we exit the loop. */
2519 /* Check whether frame was correctly received. */
2520 if ((fd
.fd_status
& FD_STATUS_OK
) == FD_STATUS_OK
) {
2521 /* Does the frame contain a pointer to the data? Let's check. */
2522 if (fd
.fd_rbd_offset
!= I82586NULL
) {
2523 /* Read the receive buffer descriptor */
2524 obram_read(ioaddr
, fd
.fd_rbd_offset
,
2525 (unsigned char *) &rbd
,
2528 #ifdef DEBUG_RX_ERROR
2529 if ((rbd
.rbd_status
& RBD_STATUS_EOF
) !=
2530 RBD_STATUS_EOF
) printk(KERN_INFO
2531 "%s: wv_receive(): missing EOF flag.\n",
2534 if ((rbd
.rbd_status
& RBD_STATUS_F
) !=
2535 RBD_STATUS_F
) printk(KERN_INFO
2536 "%s: wv_receive(): missing F flag.\n",
2538 #endif /* DEBUG_RX_ERROR */
2540 /* Read the packet and transmit to Linux */
2541 wv_packet_read(dev
, rbd
.rbd_bufl
,
2546 #ifdef DEBUG_RX_ERROR
2547 else /* if frame has no data */
2549 "%s: wv_receive(): frame has no data.\n",
2552 } else { /* If reception was no successful */
2554 lp
->stats
.rx_errors
++;
2556 #ifdef DEBUG_RX_INFO
2558 "%s: wv_receive(): frame not received successfully (%X).\n",
2559 dev
->name
, fd
.fd_status
);
2562 #ifdef DEBUG_RX_ERROR
2563 if ((fd
.fd_status
& FD_STATUS_S6
) != 0)
2565 "%s: wv_receive(): no EOF flag.\n",
2569 if ((fd
.fd_status
& FD_STATUS_S7
) != 0) {
2570 lp
->stats
.rx_length_errors
++;
2571 #ifdef DEBUG_RX_FAIL
2573 "%s: wv_receive(): frame too short.\n",
2578 if ((fd
.fd_status
& FD_STATUS_S8
) != 0) {
2579 lp
->stats
.rx_over_errors
++;
2580 #ifdef DEBUG_RX_FAIL
2582 "%s: wv_receive(): rx DMA overrun.\n",
2587 if ((fd
.fd_status
& FD_STATUS_S9
) != 0) {
2588 lp
->stats
.rx_fifo_errors
++;
2589 #ifdef DEBUG_RX_FAIL
2591 "%s: wv_receive(): ran out of resources.\n",
2596 if ((fd
.fd_status
& FD_STATUS_S10
) != 0) {
2597 lp
->stats
.rx_frame_errors
++;
2598 #ifdef DEBUG_RX_FAIL
2600 "%s: wv_receive(): alignment error.\n",
2605 if ((fd
.fd_status
& FD_STATUS_S11
) != 0) {
2606 lp
->stats
.rx_crc_errors
++;
2607 #ifdef DEBUG_RX_FAIL
2609 "%s: wv_receive(): CRC error.\n",
2616 obram_write(ioaddr
, fdoff(lp
->rx_head
, fd_status
),
2617 (unsigned char *) &fd
.fd_status
,
2618 sizeof(fd
.fd_status
));
2620 fd
.fd_command
= FD_COMMAND_EL
;
2621 obram_write(ioaddr
, fdoff(lp
->rx_head
, fd_command
),
2622 (unsigned char *) &fd
.fd_command
,
2623 sizeof(fd
.fd_command
));
2626 obram_write(ioaddr
, fdoff(lp
->rx_last
, fd_command
),
2627 (unsigned char *) &fd
.fd_command
,
2628 sizeof(fd
.fd_command
));
2630 lp
->rx_last
= lp
->rx_head
;
2631 lp
->rx_head
= fd
.fd_link_offset
;
2632 } /* for(;;) -> loop on all frames */
2634 #ifdef DEBUG_RX_INFO
2636 printk(KERN_DEBUG
"%s: wv_receive(): reaped %d\n",
2637 dev
->name
, nreaped
);
2639 #ifdef DEBUG_RX_TRACE
2640 printk(KERN_DEBUG
"%s: <-wv_receive()\n", dev
->name
);
2644 /*********************** PACKET TRANSMISSION ***********************/
2646 * This part deals with sending packets through the WaveLAN.
2650 /*------------------------------------------------------------------*/
2652 * This routine fills in the appropriate registers and memory
2653 * locations on the WaveLAN card and starts the card off on
2657 * Each block contains a transmit command, a NOP command,
2658 * a transmit block descriptor and a buffer.
2659 * The CU read the transmit block which point to the tbd,
2660 * read the tbd and the content of the buffer.
2661 * When it has finish with it, it goes to the next command
2662 * which in our case is the NOP. The NOP points on itself,
2663 * so the CU stop here.
2664 * When we add the next block, we modify the previous nop
2665 * to make it point on the new tx command.
2666 * Simple, isn't it ?
2668 * (called in wavelan_packet_xmit())
2670 static inline int wv_packet_write(device
* dev
, void *buf
, short length
)
2672 net_local
*lp
= (net_local
*) dev
->priv
;
2673 unsigned long ioaddr
= dev
->base_addr
;
2674 unsigned short txblock
;
2675 unsigned short txpred
;
2676 unsigned short tx_addr
;
2677 unsigned short nop_addr
;
2678 unsigned short tbd_addr
;
2679 unsigned short buf_addr
;
2684 unsigned long flags
;
2686 #ifdef DEBUG_TX_TRACE
2687 printk(KERN_DEBUG
"%s: ->wv_packet_write(%d)\n", dev
->name
,
2691 /* Do we need some padding? */
2692 if (clen
< ETH_ZLEN
)
2695 wv_splhi(lp
, &flags
);
2697 /* Check nothing bad has happened */
2698 if (lp
->tx_n_in_use
== (NTXBLOCKS
- 1)) {
2699 #ifdef DEBUG_TX_ERROR
2700 printk(KERN_INFO
"%s: wv_packet_write(): Tx queue full.\n",
2703 wv_splx(lp
, &flags
);
2707 /* Calculate addresses of next block and previous block. */
2708 txblock
= lp
->tx_first_free
;
2709 txpred
= txblock
- TXBLOCKZ
;
2710 if (txpred
< OFFSET_CU
)
2711 txpred
+= NTXBLOCKS
* TXBLOCKZ
;
2712 lp
->tx_first_free
+= TXBLOCKZ
;
2713 if (lp
->tx_first_free
>= OFFSET_CU
+ NTXBLOCKS
* TXBLOCKZ
)
2714 lp
->tx_first_free
-= NTXBLOCKS
* TXBLOCKZ
;
2718 /* Calculate addresses of the different parts of the block. */
2720 nop_addr
= tx_addr
+ sizeof(tx
);
2721 tbd_addr
= nop_addr
+ sizeof(nop
);
2722 buf_addr
= tbd_addr
+ sizeof(tbd
);
2727 tx
.tx_h
.ac_status
= 0;
2728 obram_write(ioaddr
, toff(ac_tx_t
, tx_addr
, tx_h
.ac_status
),
2729 (unsigned char *) &tx
.tx_h
.ac_status
,
2730 sizeof(tx
.tx_h
.ac_status
));
2735 nop
.nop_h
.ac_status
= 0;
2736 obram_write(ioaddr
, toff(ac_nop_t
, nop_addr
, nop_h
.ac_status
),
2737 (unsigned char *) &nop
.nop_h
.ac_status
,
2738 sizeof(nop
.nop_h
.ac_status
));
2739 nop
.nop_h
.ac_link
= nop_addr
;
2740 obram_write(ioaddr
, toff(ac_nop_t
, nop_addr
, nop_h
.ac_link
),
2741 (unsigned char *) &nop
.nop_h
.ac_link
,
2742 sizeof(nop
.nop_h
.ac_link
));
2745 * Transmit buffer descriptor
2747 tbd
.tbd_status
= TBD_STATUS_EOF
| (TBD_STATUS_ACNT
& clen
);
2748 tbd
.tbd_next_bd_offset
= I82586NULL
;
2749 tbd
.tbd_bufl
= buf_addr
;
2751 obram_write(ioaddr
, tbd_addr
, (unsigned char *) &tbd
, sizeof(tbd
));
2756 obram_write(ioaddr
, buf_addr
, buf
, length
);
2759 * Overwrite the predecessor NOP link
2760 * so that it points to this txblock.
2762 nop_addr
= txpred
+ sizeof(tx
);
2763 nop
.nop_h
.ac_status
= 0;
2764 obram_write(ioaddr
, toff(ac_nop_t
, nop_addr
, nop_h
.ac_status
),
2765 (unsigned char *) &nop
.nop_h
.ac_status
,
2766 sizeof(nop
.nop_h
.ac_status
));
2767 nop
.nop_h
.ac_link
= txblock
;
2768 obram_write(ioaddr
, toff(ac_nop_t
, nop_addr
, nop_h
.ac_link
),
2769 (unsigned char *) &nop
.nop_h
.ac_link
,
2770 sizeof(nop
.nop_h
.ac_link
));
2772 /* Keep stats up to date. */
2773 lp
->stats
.tx_bytes
+= length
;
2775 if (lp
->tx_first_in_use
== I82586NULL
)
2776 lp
->tx_first_in_use
= txblock
;
2778 if (lp
->tx_n_in_use
< NTXBLOCKS
- 1)
2779 netif_wake_queue(dev
);
2781 wv_splx(lp
, &flags
);
2783 #ifdef DEBUG_TX_INFO
2784 wv_packet_info((u8
*) buf
, length
, dev
->name
,
2786 #endif /* DEBUG_TX_INFO */
2788 #ifdef DEBUG_TX_TRACE
2789 printk(KERN_DEBUG
"%s: <-wv_packet_write()\n", dev
->name
);
2795 /*------------------------------------------------------------------*/
2797 * This routine is called when we want to send a packet (NET3 callback)
2798 * In this routine, we check if the harware is ready to accept
2799 * the packet. We also prevent reentrance. Then we call the function
2800 * to send the packet.
2802 static int wavelan_packet_xmit(struct sk_buff
*skb
, device
* dev
)
2804 net_local
*lp
= (net_local
*) dev
->priv
;
2805 unsigned long flags
;
2807 #ifdef DEBUG_TX_TRACE
2808 printk(KERN_DEBUG
"%s: ->wavelan_packet_xmit(0x%X)\n", dev
->name
,
2813 * Block a timer-based transmit from overlapping.
2814 * In other words, prevent reentering this routine.
2816 netif_stop_queue(dev
);
2818 /* If somebody has asked to reconfigure the controller,
2821 if (lp
->reconfig_82586
) {
2822 wv_splhi(lp
, &flags
);
2823 wv_82586_config(dev
);
2824 wv_splx(lp
, &flags
);
2825 /* Check that we can continue */
2826 if (lp
->tx_n_in_use
== (NTXBLOCKS
- 1))
2829 #ifdef DEBUG_TX_ERROR
2831 printk(KERN_INFO
"skb has next\n");
2834 /* Write packet on the card */
2835 if(wv_packet_write(dev
, skb
->data
, skb
->len
))
2836 return 1; /* We failed */
2840 #ifdef DEBUG_TX_TRACE
2841 printk(KERN_DEBUG
"%s: <-wavelan_packet_xmit()\n", dev
->name
);
2846 /*********************** HARDWARE CONFIGURATION ***********************/
2848 * This part does the real job of starting and configuring the hardware.
2851 /*--------------------------------------------------------------------*/
2853 * Routine to initialize the Modem Management Controller.
2854 * (called by wv_hw_reset())
2856 static inline int wv_mmc_init(device
* dev
)
2858 unsigned long ioaddr
= dev
->base_addr
;
2859 net_local
*lp
= (net_local
*) dev
->priv
;
2864 #ifdef DEBUG_CONFIG_TRACE
2865 printk(KERN_DEBUG
"%s: ->wv_mmc_init()\n", dev
->name
);
2868 /* Read the parameter storage area. */
2869 psa_read(ioaddr
, lp
->hacr
, 0, (unsigned char *) &psa
, sizeof(psa
));
2871 #ifdef USE_PSA_CONFIG
2872 configured
= psa
.psa_conf_status
& 1;
2877 /* Is the PSA is not configured */
2879 /* User will be able to configure NWID later (with iwconfig). */
2880 psa
.psa_nwid
[0] = 0;
2881 psa
.psa_nwid
[1] = 0;
2883 /* no NWID checking since NWID is not set */
2884 psa
.psa_nwid_select
= 0;
2886 /* Disable encryption */
2887 psa
.psa_encryption_select
= 0;
2889 /* Set to standard values:
2892 * 0x04 for PCMCIA and 2.00 card (AT&T 407-024689/E document)
2894 if (psa
.psa_comp_number
& 1)
2895 psa
.psa_thr_pre_set
= 0x01;
2897 psa
.psa_thr_pre_set
= 0x04;
2898 psa
.psa_quality_thr
= 0x03;
2900 /* It is configured */
2901 psa
.psa_conf_status
|= 1;
2903 #ifdef USE_PSA_CONFIG
2904 /* Write the psa. */
2905 psa_write(ioaddr
, lp
->hacr
,
2906 (char *) psa
.psa_nwid
- (char *) &psa
,
2907 (unsigned char *) psa
.psa_nwid
, 4);
2908 psa_write(ioaddr
, lp
->hacr
,
2909 (char *) &psa
.psa_thr_pre_set
- (char *) &psa
,
2910 (unsigned char *) &psa
.psa_thr_pre_set
, 1);
2911 psa_write(ioaddr
, lp
->hacr
,
2912 (char *) &psa
.psa_quality_thr
- (char *) &psa
,
2913 (unsigned char *) &psa
.psa_quality_thr
, 1);
2914 psa_write(ioaddr
, lp
->hacr
,
2915 (char *) &psa
.psa_conf_status
- (char *) &psa
,
2916 (unsigned char *) &psa
.psa_conf_status
, 1);
2917 /* update the Wavelan checksum */
2918 update_psa_checksum(dev
, ioaddr
, lp
->hacr
);
2922 /* Zero the mmc structure. */
2923 memset(&m
, 0x00, sizeof(m
));
2925 /* Copy PSA info to the mmc. */
2926 m
.mmw_netw_id_l
= psa
.psa_nwid
[1];
2927 m
.mmw_netw_id_h
= psa
.psa_nwid
[0];
2929 if (psa
.psa_nwid_select
& 1)
2930 m
.mmw_loopt_sel
= 0x00;
2932 m
.mmw_loopt_sel
= MMW_LOOPT_SEL_DIS_NWID
;
2934 memcpy(&m
.mmw_encr_key
, &psa
.psa_encryption_key
,
2935 sizeof(m
.mmw_encr_key
));
2937 if (psa
.psa_encryption_select
)
2939 MMW_ENCR_ENABLE_EN
| MMW_ENCR_ENABLE_MODE
;
2941 m
.mmw_encr_enable
= 0;
2943 m
.mmw_thr_pre_set
= psa
.psa_thr_pre_set
& 0x3F;
2944 m
.mmw_quality_thr
= psa
.psa_quality_thr
& 0x0F;
2947 * Set default modem control parameters.
2948 * See NCR document 407-0024326 Rev. A.
2950 m
.mmw_jabber_enable
= 0x01;
2952 m
.mmw_anten_sel
= MMW_ANTEN_SEL_ALG_EN
;
2954 m
.mmw_mod_delay
= 0x04;
2955 m
.mmw_jam_time
= 0x38;
2957 m
.mmw_des_io_invert
= 0;
2958 m
.mmw_decay_prm
= 0;
2959 m
.mmw_decay_updat_prm
= 0;
2961 /* Write all info to MMC. */
2962 mmc_write(ioaddr
, 0, (u8
*) & m
, sizeof(m
));
2964 /* The following code starts the modem of the 2.00 frequency
2965 * selectable cards at power on. It's not strictly needed for the
2967 * The original patch was by Joe Finney for the PCMCIA driver, but
2968 * I've cleaned it up a bit and added documentation.
2969 * Thanks to Loeke Brederveld from Lucent for the info.
2972 /* Attempt to recognise 2.00 cards (2.4 GHz frequency selectable)
2973 * Does it work for everybody, especially old cards? */
2974 /* Note: WFREQSEL verifies that it is able to read a sensible
2975 * frequency from EEPROM (address 0x00) and that MMR_FEE_STATUS_ID
2976 * is 0xA (Xilinx version) or 0xB (Ariadne version).
2977 * My test is more crude but does work. */
2978 if (!(mmc_in(ioaddr
, mmroff(0, mmr_fee_status
)) &
2979 (MMR_FEE_STATUS_DWLD
| MMR_FEE_STATUS_BUSY
))) {
2980 /* We must download the frequency parameters to the
2981 * synthesizers (from the EEPROM - area 1)
2982 * Note: as the EEPROM is automatically decremented, we set the end
2984 m
.mmw_fee_addr
= 0x0F;
2985 m
.mmw_fee_ctrl
= MMW_FEE_CTRL_READ
| MMW_FEE_CTRL_DWLD
;
2986 mmc_write(ioaddr
, (char *) &m
.mmw_fee_ctrl
- (char *) &m
,
2987 (unsigned char *) &m
.mmw_fee_ctrl
, 2);
2989 /* Wait until the download is finished. */
2990 fee_wait(ioaddr
, 100, 100);
2992 #ifdef DEBUG_CONFIG_INFO
2993 /* The frequency was in the last word downloaded. */
2994 mmc_read(ioaddr
, (char *) &m
.mmw_fee_data_l
- (char *) &m
,
2995 (unsigned char *) &m
.mmw_fee_data_l
, 2);
2997 /* Print some info for the user. */
2999 "%s: WaveLAN 2.00 recognised (frequency select). Current frequency = %ld\n",
3002 mmw_fee_data_h
<< 4) | (m
.mmw_fee_data_l
>> 4)) *
3006 /* We must now download the power adjust value (gain) to
3007 * the synthesizers (from the EEPROM - area 7 - DAC). */
3008 m
.mmw_fee_addr
= 0x61;
3009 m
.mmw_fee_ctrl
= MMW_FEE_CTRL_READ
| MMW_FEE_CTRL_DWLD
;
3010 mmc_write(ioaddr
, (char *) &m
.mmw_fee_ctrl
- (char *) &m
,
3011 (unsigned char *) &m
.mmw_fee_ctrl
, 2);
3013 /* Wait until the download is finished. */
3016 #ifdef DEBUG_CONFIG_TRACE
3017 printk(KERN_DEBUG
"%s: <-wv_mmc_init()\n", dev
->name
);
3022 /*------------------------------------------------------------------*/
3024 * Construct the fd and rbd structures.
3025 * Start the receive unit.
3026 * (called by wv_hw_reset())
3028 static inline int wv_ru_start(device
* dev
)
3030 net_local
*lp
= (net_local
*) dev
->priv
;
3031 unsigned long ioaddr
= dev
->base_addr
;
3039 #ifdef DEBUG_CONFIG_TRACE
3040 printk(KERN_DEBUG
"%s: ->wv_ru_start()\n", dev
->name
);
3043 obram_read(ioaddr
, scboff(OFFSET_SCB
, scb_status
),
3044 (unsigned char *) &scb_cs
, sizeof(scb_cs
));
3045 if ((scb_cs
& SCB_ST_RUS
) == SCB_ST_RUS_RDY
)
3048 lp
->rx_head
= OFFSET_RU
;
3050 for (i
= 0, rx
= lp
->rx_head
; i
< NRXBLOCKS
; i
++, rx
= rx_next
) {
3052 (i
== NRXBLOCKS
- 1) ? lp
->rx_head
: rx
+ RXBLOCKZ
;
3055 fd
.fd_command
= (i
== NRXBLOCKS
- 1) ? FD_COMMAND_EL
: 0;
3056 fd
.fd_link_offset
= rx_next
;
3057 fd
.fd_rbd_offset
= rx
+ sizeof(fd
);
3058 obram_write(ioaddr
, rx
, (unsigned char *) &fd
, sizeof(fd
));
3061 rbd
.rbd_next_rbd_offset
= I82586NULL
;
3062 rbd
.rbd_bufl
= rx
+ sizeof(fd
) + sizeof(rbd
);
3064 rbd
.rbd_el_size
= RBD_EL
| (RBD_SIZE
& MAXDATAZ
);
3065 obram_write(ioaddr
, rx
+ sizeof(fd
),
3066 (unsigned char *) &rbd
, sizeof(rbd
));
3071 obram_write(ioaddr
, scboff(OFFSET_SCB
, scb_rfa_offset
),
3072 (unsigned char *) &lp
->rx_head
, sizeof(lp
->rx_head
));
3074 scb_cs
= SCB_CMD_RUC_GO
;
3075 obram_write(ioaddr
, scboff(OFFSET_SCB
, scb_command
),
3076 (unsigned char *) &scb_cs
, sizeof(scb_cs
));
3078 set_chan_attn(ioaddr
, lp
->hacr
);
3080 for (i
= 1000; i
> 0; i
--) {
3081 obram_read(ioaddr
, scboff(OFFSET_SCB
, scb_command
),
3082 (unsigned char *) &scb_cs
, sizeof(scb_cs
));
3090 #ifdef DEBUG_CONFIG_ERROR
3092 "%s: wavelan_ru_start(): board not accepting command.\n",
3097 #ifdef DEBUG_CONFIG_TRACE
3098 printk(KERN_DEBUG
"%s: <-wv_ru_start()\n", dev
->name
);
3103 /*------------------------------------------------------------------*/
3105 * Initialise the transmit blocks.
3106 * Start the command unit executing the NOP
3107 * self-loop of the first transmit block.
3109 * Here we create the list of send buffers used to transmit packets
3110 * between the PC and the command unit. For each buffer, we create a
3111 * buffer descriptor (pointing on the buffer), a transmit command
3112 * (pointing to the buffer descriptor) and a NOP command.
3113 * The transmit command is linked to the NOP, and the NOP to itself.
3114 * When we will have finished executing the transmit command, we will
3115 * then loop on the NOP. By releasing the NOP link to a new command,
3116 * we may send another buffer.
3118 * (called by wv_hw_reset())
3120 static inline int wv_cu_start(device
* dev
)
3122 net_local
*lp
= (net_local
*) dev
->priv
;
3123 unsigned long ioaddr
= dev
->base_addr
;
3129 #ifdef DEBUG_CONFIG_TRACE
3130 printk(KERN_DEBUG
"%s: ->wv_cu_start()\n", dev
->name
);
3133 lp
->tx_first_free
= OFFSET_CU
;
3134 lp
->tx_first_in_use
= I82586NULL
;
3136 for (i
= 0, txblock
= OFFSET_CU
;
3137 i
< NTXBLOCKS
; i
++, txblock
+= TXBLOCKZ
) {
3141 unsigned short tx_addr
;
3142 unsigned short nop_addr
;
3143 unsigned short tbd_addr
;
3144 unsigned short buf_addr
;
3147 nop_addr
= tx_addr
+ sizeof(tx
);
3148 tbd_addr
= nop_addr
+ sizeof(nop
);
3149 buf_addr
= tbd_addr
+ sizeof(tbd
);
3151 tx
.tx_h
.ac_status
= 0;
3152 tx
.tx_h
.ac_command
= acmd_transmit
| AC_CFLD_I
;
3153 tx
.tx_h
.ac_link
= nop_addr
;
3154 tx
.tx_tbd_offset
= tbd_addr
;
3155 obram_write(ioaddr
, tx_addr
, (unsigned char *) &tx
,
3158 nop
.nop_h
.ac_status
= 0;
3159 nop
.nop_h
.ac_command
= acmd_nop
;
3160 nop
.nop_h
.ac_link
= nop_addr
;
3161 obram_write(ioaddr
, nop_addr
, (unsigned char *) &nop
,
3164 tbd
.tbd_status
= TBD_STATUS_EOF
;
3165 tbd
.tbd_next_bd_offset
= I82586NULL
;
3166 tbd
.tbd_bufl
= buf_addr
;
3168 obram_write(ioaddr
, tbd_addr
, (unsigned char *) &tbd
,
3173 OFFSET_CU
+ (NTXBLOCKS
- 1) * TXBLOCKZ
+ sizeof(ac_tx_t
);
3174 obram_write(ioaddr
, scboff(OFFSET_SCB
, scb_cbl_offset
),
3175 (unsigned char *) &first_nop
, sizeof(first_nop
));
3177 scb_cs
= SCB_CMD_CUC_GO
;
3178 obram_write(ioaddr
, scboff(OFFSET_SCB
, scb_command
),
3179 (unsigned char *) &scb_cs
, sizeof(scb_cs
));
3181 set_chan_attn(ioaddr
, lp
->hacr
);
3183 for (i
= 1000; i
> 0; i
--) {
3184 obram_read(ioaddr
, scboff(OFFSET_SCB
, scb_command
),
3185 (unsigned char *) &scb_cs
, sizeof(scb_cs
));
3193 #ifdef DEBUG_CONFIG_ERROR
3195 "%s: wavelan_cu_start(): board not accepting command.\n",
3201 lp
->tx_n_in_use
= 0;
3202 netif_start_queue(dev
);
3203 #ifdef DEBUG_CONFIG_TRACE
3204 printk(KERN_DEBUG
"%s: <-wv_cu_start()\n", dev
->name
);
3209 /*------------------------------------------------------------------*/
3211 * This routine does a standard configuration of the WaveLAN
3212 * controller (i82586).
3214 * It initialises the scp, iscp and scb structure
3215 * The first two are just pointers to the next.
3216 * The last one is used for basic configuration and for basic
3217 * communication (interrupt status).
3219 * (called by wv_hw_reset())
3221 static inline int wv_82586_start(device
* dev
)
3223 net_local
*lp
= (net_local
*) dev
->priv
;
3224 unsigned long ioaddr
= dev
->base_addr
;
3225 scp_t scp
; /* system configuration pointer */
3226 iscp_t iscp
; /* intermediate scp */
3227 scb_t scb
; /* system control block */
3228 ach_t cb
; /* Action command header */
3232 #ifdef DEBUG_CONFIG_TRACE
3233 printk(KERN_DEBUG
"%s: ->wv_82586_start()\n", dev
->name
);
3237 * Clear the onboard RAM.
3239 memset(&zeroes
[0], 0x00, sizeof(zeroes
));
3240 for (i
= 0; i
< I82586_MEMZ
; i
+= sizeof(zeroes
))
3241 obram_write(ioaddr
, i
, &zeroes
[0], sizeof(zeroes
));
3244 * Construct the command unit structures:
3245 * scp, iscp, scb, cb.
3247 memset(&scp
, 0x00, sizeof(scp
));
3248 scp
.scp_sysbus
= SCP_SY_16BBUS
;
3249 scp
.scp_iscpl
= OFFSET_ISCP
;
3250 obram_write(ioaddr
, OFFSET_SCP
, (unsigned char *) &scp
,
3253 memset(&iscp
, 0x00, sizeof(iscp
));
3255 iscp
.iscp_offset
= OFFSET_SCB
;
3256 obram_write(ioaddr
, OFFSET_ISCP
, (unsigned char *) &iscp
,
3259 /* Our first command is to reset the i82586. */
3260 memset(&scb
, 0x00, sizeof(scb
));
3261 scb
.scb_command
= SCB_CMD_RESET
;
3262 scb
.scb_cbl_offset
= OFFSET_CU
;
3263 scb
.scb_rfa_offset
= OFFSET_RU
;
3264 obram_write(ioaddr
, OFFSET_SCB
, (unsigned char *) &scb
,
3267 set_chan_attn(ioaddr
, lp
->hacr
);
3269 /* Wait for command to finish. */
3270 for (i
= 1000; i
> 0; i
--) {
3271 obram_read(ioaddr
, OFFSET_ISCP
, (unsigned char *) &iscp
,
3274 if (iscp
.iscp_busy
== (unsigned short) 0)
3281 #ifdef DEBUG_CONFIG_ERROR
3283 "%s: wv_82586_start(): iscp_busy timeout.\n",
3289 /* Check command completion. */
3290 for (i
= 15; i
> 0; i
--) {
3291 obram_read(ioaddr
, OFFSET_SCB
, (unsigned char *) &scb
,
3294 if (scb
.scb_status
== (SCB_ST_CX
| SCB_ST_CNA
))
3301 #ifdef DEBUG_CONFIG_ERROR
3303 "%s: wv_82586_start(): status: expected 0x%02x, got 0x%02x.\n",
3304 dev
->name
, SCB_ST_CX
| SCB_ST_CNA
, scb
.scb_status
);
3311 /* Set the action command header. */
3312 memset(&cb
, 0x00, sizeof(cb
));
3313 cb
.ac_command
= AC_CFLD_EL
| (AC_CFLD_CMD
& acmd_diagnose
);
3314 cb
.ac_link
= OFFSET_CU
;
3315 obram_write(ioaddr
, OFFSET_CU
, (unsigned char *) &cb
, sizeof(cb
));
3317 if (wv_synchronous_cmd(dev
, "diag()") == -1)
3320 obram_read(ioaddr
, OFFSET_CU
, (unsigned char *) &cb
, sizeof(cb
));
3321 if (cb
.ac_status
& AC_SFLD_FAIL
) {
3322 #ifdef DEBUG_CONFIG_ERROR
3324 "%s: wv_82586_start(): i82586 Self Test failed.\n",
3329 #ifdef DEBUG_I82586_SHOW
3330 wv_scb_show(ioaddr
);
3333 #ifdef DEBUG_CONFIG_TRACE
3334 printk(KERN_DEBUG
"%s: <-wv_82586_start()\n", dev
->name
);
3339 /*------------------------------------------------------------------*/
3341 * This routine does a standard configuration of the WaveLAN
3342 * controller (i82586).
3344 * This routine is a violent hack. We use the first free transmit block
3345 * to make our configuration. In the buffer area, we create the three
3346 * configuration commands (linked). We make the previous NOP point to
3347 * the beginning of the buffer instead of the tx command. After, we go
3348 * as usual to the NOP command.
3349 * Note that only the last command (mc_set) will generate an interrupt.
3351 * (called by wv_hw_reset(), wv_82586_reconfig(), wavelan_packet_xmit())
3353 static void wv_82586_config(device
* dev
)
3355 net_local
*lp
= (net_local
*) dev
->priv
;
3356 unsigned long ioaddr
= dev
->base_addr
;
3357 unsigned short txblock
;
3358 unsigned short txpred
;
3359 unsigned short tx_addr
;
3360 unsigned short nop_addr
;
3361 unsigned short tbd_addr
;
3362 unsigned short cfg_addr
;
3363 unsigned short ias_addr
;
3364 unsigned short mcs_addr
;
3367 ac_cfg_t cfg
; /* Configure action */
3368 ac_ias_t ias
; /* IA-setup action */
3369 ac_mcs_t mcs
; /* Multicast setup */
3370 struct dev_mc_list
*dmi
;
3372 #ifdef DEBUG_CONFIG_TRACE
3373 printk(KERN_DEBUG
"%s: ->wv_82586_config()\n", dev
->name
);
3376 /* Check nothing bad has happened */
3377 if (lp
->tx_n_in_use
== (NTXBLOCKS
- 1)) {
3378 #ifdef DEBUG_CONFIG_ERROR
3379 printk(KERN_INFO
"%s: wv_82586_config(): Tx queue full.\n",
3385 /* Calculate addresses of next block and previous block. */
3386 txblock
= lp
->tx_first_free
;
3387 txpred
= txblock
- TXBLOCKZ
;
3388 if (txpred
< OFFSET_CU
)
3389 txpred
+= NTXBLOCKS
* TXBLOCKZ
;
3390 lp
->tx_first_free
+= TXBLOCKZ
;
3391 if (lp
->tx_first_free
>= OFFSET_CU
+ NTXBLOCKS
* TXBLOCKZ
)
3392 lp
->tx_first_free
-= NTXBLOCKS
* TXBLOCKZ
;
3396 /* Calculate addresses of the different parts of the block. */
3398 nop_addr
= tx_addr
+ sizeof(tx
);
3399 tbd_addr
= nop_addr
+ sizeof(nop
);
3400 cfg_addr
= tbd_addr
+ sizeof(tbd_t
); /* beginning of the buffer */
3401 ias_addr
= cfg_addr
+ sizeof(cfg
);
3402 mcs_addr
= ias_addr
+ sizeof(ias
);
3407 tx
.tx_h
.ac_status
= 0xFFFF; /* Fake completion value */
3408 obram_write(ioaddr
, toff(ac_tx_t
, tx_addr
, tx_h
.ac_status
),
3409 (unsigned char *) &tx
.tx_h
.ac_status
,
3410 sizeof(tx
.tx_h
.ac_status
));
3415 nop
.nop_h
.ac_status
= 0;
3416 obram_write(ioaddr
, toff(ac_nop_t
, nop_addr
, nop_h
.ac_status
),
3417 (unsigned char *) &nop
.nop_h
.ac_status
,
3418 sizeof(nop
.nop_h
.ac_status
));
3419 nop
.nop_h
.ac_link
= nop_addr
;
3420 obram_write(ioaddr
, toff(ac_nop_t
, nop_addr
, nop_h
.ac_link
),
3421 (unsigned char *) &nop
.nop_h
.ac_link
,
3422 sizeof(nop
.nop_h
.ac_link
));
3424 /* Create a configure action. */
3425 memset(&cfg
, 0x00, sizeof(cfg
));
3428 * For Linux we invert AC_CFG_ALOC() so as to conform
3429 * to the way that net packets reach us from above.
3430 * (See also ac_tx_t.)
3432 * Updated from Wavelan Manual WCIN085B
3435 AC_CFG_BYTE_CNT(sizeof(ac_cfg_t
) - sizeof(ach_t
));
3436 cfg
.cfg_fifolim
= AC_CFG_FIFOLIM(4);
3437 cfg
.cfg_byte8
= AC_CFG_SAV_BF(1) | AC_CFG_SRDY(0);
3438 cfg
.cfg_byte9
= AC_CFG_ELPBCK(0) |
3440 AC_CFG_PRELEN(AC_CFG_PLEN_2
) |
3441 AC_CFG_ALOC(1) | AC_CFG_ADDRLEN(WAVELAN_ADDR_SIZE
);
3442 cfg
.cfg_byte10
= AC_CFG_BOFMET(1) |
3443 AC_CFG_ACR(6) | AC_CFG_LINPRIO(0);
3445 cfg
.cfg_slotl
= 0x0C;
3446 cfg
.cfg_byte13
= AC_CFG_RETRYNUM(15) | AC_CFG_SLTTMHI(0);
3447 cfg
.cfg_byte14
= AC_CFG_FLGPAD(0) |
3453 AC_CFG_BCDIS(0) | AC_CFG_PRM(lp
->promiscuous
);
3454 cfg
.cfg_byte15
= AC_CFG_ICDS(0) |
3455 AC_CFG_CDTF(0) | AC_CFG_ICSS(0) | AC_CFG_CSTF(0);
3457 cfg.cfg_min_frm_len = AC_CFG_MNFRM(64);
3459 cfg
.cfg_min_frm_len
= AC_CFG_MNFRM(8);
3461 cfg
.cfg_h
.ac_command
= (AC_CFLD_CMD
& acmd_configure
);
3462 cfg
.cfg_h
.ac_link
= ias_addr
;
3463 obram_write(ioaddr
, cfg_addr
, (unsigned char *) &cfg
, sizeof(cfg
));
3465 /* Set up the MAC address */
3466 memset(&ias
, 0x00, sizeof(ias
));
3467 ias
.ias_h
.ac_command
= (AC_CFLD_CMD
& acmd_ia_setup
);
3468 ias
.ias_h
.ac_link
= mcs_addr
;
3469 memcpy(&ias
.ias_addr
[0], (unsigned char *) &dev
->dev_addr
[0],
3470 sizeof(ias
.ias_addr
));
3471 obram_write(ioaddr
, ias_addr
, (unsigned char *) &ias
, sizeof(ias
));
3473 /* Initialize adapter's Ethernet multicast addresses */
3474 memset(&mcs
, 0x00, sizeof(mcs
));
3475 mcs
.mcs_h
.ac_command
= AC_CFLD_I
| (AC_CFLD_CMD
& acmd_mc_setup
);
3476 mcs
.mcs_h
.ac_link
= nop_addr
;
3477 mcs
.mcs_cnt
= WAVELAN_ADDR_SIZE
* lp
->mc_count
;
3478 obram_write(ioaddr
, mcs_addr
, (unsigned char *) &mcs
, sizeof(mcs
));
3480 /* Any address to set? */
3482 for (dmi
= dev
->mc_list
; dmi
; dmi
= dmi
->next
)
3483 outsw(PIOP1(ioaddr
), (u16
*) dmi
->dmi_addr
,
3484 WAVELAN_ADDR_SIZE
>> 1);
3486 #ifdef DEBUG_CONFIG_INFO
3488 "%s: wv_82586_config(): set %d multicast addresses:\n",
3489 dev
->name
, lp
->mc_count
);
3490 for (dmi
= dev
->mc_list
; dmi
; dmi
= dmi
->next
)
3492 " %02x:%02x:%02x:%02x:%02x:%02x\n",
3493 dmi
->dmi_addr
[0], dmi
->dmi_addr
[1],
3494 dmi
->dmi_addr
[2], dmi
->dmi_addr
[3],
3495 dmi
->dmi_addr
[4], dmi
->dmi_addr
[5]);
3500 * Overwrite the predecessor NOP link
3501 * so that it points to the configure action.
3503 nop_addr
= txpred
+ sizeof(tx
);
3504 nop
.nop_h
.ac_status
= 0;
3505 obram_write(ioaddr
, toff(ac_nop_t
, nop_addr
, nop_h
.ac_status
),
3506 (unsigned char *) &nop
.nop_h
.ac_status
,
3507 sizeof(nop
.nop_h
.ac_status
));
3508 nop
.nop_h
.ac_link
= cfg_addr
;
3509 obram_write(ioaddr
, toff(ac_nop_t
, nop_addr
, nop_h
.ac_link
),
3510 (unsigned char *) &nop
.nop_h
.ac_link
,
3511 sizeof(nop
.nop_h
.ac_link
));
3513 /* Job done, clear the flag */
3514 lp
->reconfig_82586
= 0;
3516 if (lp
->tx_first_in_use
== I82586NULL
)
3517 lp
->tx_first_in_use
= txblock
;
3519 if (lp
->tx_n_in_use
== (NTXBLOCKS
- 1))
3520 netif_stop_queue(dev
);
3522 #ifdef DEBUG_CONFIG_TRACE
3523 printk(KERN_DEBUG
"%s: <-wv_82586_config()\n", dev
->name
);
3527 /*------------------------------------------------------------------*/
3529 * This routine, called by wavelan_close(), gracefully stops the
3530 * WaveLAN controller (i82586).
3531 * (called by wavelan_close())
3533 static inline void wv_82586_stop(device
* dev
)
3535 net_local
*lp
= (net_local
*) dev
->priv
;
3536 unsigned long ioaddr
= dev
->base_addr
;
3539 #ifdef DEBUG_CONFIG_TRACE
3540 printk(KERN_DEBUG
"%s: ->wv_82586_stop()\n", dev
->name
);
3543 /* Suspend both command unit and receive unit. */
3545 (SCB_CMD_CUC
& SCB_CMD_CUC_SUS
) | (SCB_CMD_RUC
&
3547 obram_write(ioaddr
, scboff(OFFSET_SCB
, scb_command
),
3548 (unsigned char *) &scb_cmd
, sizeof(scb_cmd
));
3549 set_chan_attn(ioaddr
, lp
->hacr
);
3551 /* No more interrupts */
3554 #ifdef DEBUG_CONFIG_TRACE
3555 printk(KERN_DEBUG
"%s: <-wv_82586_stop()\n", dev
->name
);
3559 /*------------------------------------------------------------------*/
3561 * Totally reset the WaveLAN and restart it.
3562 * Performs the following actions:
3563 * 1. A power reset (reset DMA)
3564 * 2. Initialize the radio modem (using wv_mmc_init)
3565 * 3. Reset & Configure LAN controller (using wv_82586_start)
3566 * 4. Start the LAN controller's command unit
3567 * 5. Start the LAN controller's receive unit
3568 * (called by wavelan_interrupt(), wavelan_watchdog() & wavelan_open())
3570 static int wv_hw_reset(device
* dev
)
3572 net_local
*lp
= (net_local
*) dev
->priv
;
3573 unsigned long ioaddr
= dev
->base_addr
;
3575 #ifdef DEBUG_CONFIG_TRACE
3576 printk(KERN_DEBUG
"%s: ->wv_hw_reset(dev=0x%x)\n", dev
->name
,
3577 (unsigned int) dev
);
3580 /* Increase the number of resets done. */
3583 wv_hacr_reset(ioaddr
);
3584 lp
->hacr
= HACR_DEFAULT
;
3586 if ((wv_mmc_init(dev
) < 0) || (wv_82586_start(dev
) < 0))
3589 /* Enable the card to send interrupts. */
3592 /* Start card functions */
3593 if (wv_cu_start(dev
) < 0)
3596 /* Setup the controller and parameters */
3597 wv_82586_config(dev
);
3599 /* Finish configuration with the receive unit */
3600 if (wv_ru_start(dev
) < 0)
3603 #ifdef DEBUG_CONFIG_TRACE
3604 printk(KERN_DEBUG
"%s: <-wv_hw_reset()\n", dev
->name
);
3609 /*------------------------------------------------------------------*/
3611 * Check if there is a WaveLAN at the specific base address.
3612 * As a side effect, this reads the MAC address.
3613 * (called in wavelan_probe() and init_module())
3615 static int wv_check_ioaddr(unsigned long ioaddr
, u8
* mac
)
3617 int i
; /* Loop counter */
3619 /* Check if the base address if available. */
3620 if (check_region(ioaddr
, sizeof(ha_t
)))
3621 return -EADDRINUSE
; /* ioaddr already used */
3623 /* Reset host interface */
3624 wv_hacr_reset(ioaddr
);
3626 /* Read the MAC address from the parameter storage area. */
3627 psa_read(ioaddr
, HACR_DEFAULT
, psaoff(0, psa_univ_mac_addr
),
3631 * Check the first three octets of the address for the manufacturer's code.
3632 * Note: if this can't find your WaveLAN card, you've got a
3633 * non-NCR/AT&T/Lucent ISA card. See wavelan.p.h for detail on
3634 * how to configure your card.
3636 for (i
= 0; i
< (sizeof(MAC_ADDRESSES
) / sizeof(char) / 3); i
++)
3637 if ((mac
[0] == MAC_ADDRESSES
[i
][0]) &&
3638 (mac
[1] == MAC_ADDRESSES
[i
][1]) &&
3639 (mac
[2] == MAC_ADDRESSES
[i
][2]))
3642 #ifdef DEBUG_CONFIG_INFO
3644 "WaveLAN (0x%3X): your MAC address might be %02X:%02X:%02X.\n",
3645 ioaddr
, mac
[0], mac
[1], mac
[2]);
3650 /************************ INTERRUPT HANDLING ************************/
3653 * This function is the interrupt handler for the WaveLAN card. This
3654 * routine will be called whenever:
3656 static void wavelan_interrupt(int irq
, void *dev_id
, struct pt_regs
*regs
)
3659 unsigned long ioaddr
;
3667 #ifdef DEBUG_INTERRUPT_TRACE
3668 printk(KERN_DEBUG
"%s: ->wavelan_interrupt()\n", dev
->name
);
3671 lp
= (net_local
*) dev
->priv
;
3672 ioaddr
= dev
->base_addr
;
3674 #ifdef DEBUG_INTERRUPT_INFO
3675 /* Check state of our spinlock */
3676 if(spin_is_locked(&lp
->spinlock
))
3678 "%s: wavelan_interrupt(): spinlock is already locked !!!\n",
3682 /* Prevent reentrancy. We need to do that because we may have
3683 * multiple interrupt handler running concurrently.
3684 * It is safe because wv_splhi() disables interrupts before acquiring
3686 spin_lock(&lp
->spinlock
);
3688 /* Check modem interupt */
3689 if ((hasr
= hasr_read(ioaddr
)) & HASR_MMC_INTR
) {
3693 * Interrupt from the modem management controller.
3694 * This will clear it -- ignored for now.
3696 mmc_read(ioaddr
, mmroff(0, mmr_dce_status
), &dce_status
,
3697 sizeof(dce_status
));
3698 #ifdef DEBUG_INTERRUPT_ERROR
3700 "%s: wavelan_interrupt(): unexpected mmc interrupt: status 0x%04x.\n",
3701 dev
->name
, dce_status
);
3705 /* Check if not controller interrupt */
3706 if ((hasr
& HASR_82586_INTR
) == 0) {
3707 #ifdef DEBUG_INTERRUPT_ERROR
3709 "%s: wavelan_interrupt(): interrupt not coming from i82586\n",
3712 spin_unlock (&lp
->spinlock
);
3716 /* Read interrupt data. */
3717 obram_read(ioaddr
, scboff(OFFSET_SCB
, scb_status
),
3718 (unsigned char *) &status
, sizeof(status
));
3721 * Acknowledge the interrupt(s).
3723 ack_cmd
= status
& SCB_ST_INT
;
3724 obram_write(ioaddr
, scboff(OFFSET_SCB
, scb_command
),
3725 (unsigned char *) &ack_cmd
, sizeof(ack_cmd
));
3726 set_chan_attn(ioaddr
, lp
->hacr
);
3728 #ifdef DEBUG_INTERRUPT_INFO
3729 printk(KERN_DEBUG
"%s: wavelan_interrupt(): status 0x%04x.\n",
3733 /* Command completed. */
3734 if ((status
& SCB_ST_CX
) == SCB_ST_CX
) {
3735 #ifdef DEBUG_INTERRUPT_INFO
3737 "%s: wavelan_interrupt(): command completed.\n",
3740 wv_complete(dev
, ioaddr
, lp
);
3743 /* Frame received. */
3744 if ((status
& SCB_ST_FR
) == SCB_ST_FR
) {
3745 #ifdef DEBUG_INTERRUPT_INFO
3747 "%s: wavelan_interrupt(): received packet.\n",
3753 /* Check the state of the command unit. */
3754 if (((status
& SCB_ST_CNA
) == SCB_ST_CNA
) ||
3755 (((status
& SCB_ST_CUS
) != SCB_ST_CUS_ACTV
) &&
3756 (netif_running(dev
)))) {
3757 #ifdef DEBUG_INTERRUPT_ERROR
3759 "%s: wavelan_interrupt(): CU inactive -- restarting\n",
3765 /* Check the state of the command unit. */
3766 if (((status
& SCB_ST_RNR
) == SCB_ST_RNR
) ||
3767 (((status
& SCB_ST_RUS
) != SCB_ST_RUS_RDY
) &&
3768 (netif_running(dev
)))) {
3769 #ifdef DEBUG_INTERRUPT_ERROR
3771 "%s: wavelan_interrupt(): RU not ready -- restarting\n",
3777 /* Release spinlock */
3778 spin_unlock (&lp
->spinlock
);
3780 #ifdef DEBUG_INTERRUPT_TRACE
3781 printk(KERN_DEBUG
"%s: <-wavelan_interrupt()\n", dev
->name
);
3785 /*------------------------------------------------------------------*/
3787 * Watchdog: when we start a transmission, a timer is set for us in the
3788 * kernel. If the transmission completes, this timer is disabled. If
3789 * the timer expires, we are called and we try to unlock the hardware.
3791 static void wavelan_watchdog(device
* dev
)
3793 net_local
* lp
= (net_local
*)dev
->priv
;
3794 u_long ioaddr
= dev
->base_addr
;
3795 unsigned long flags
;
3796 unsigned int nreaped
;
3798 #ifdef DEBUG_INTERRUPT_TRACE
3799 printk(KERN_DEBUG
"%s: ->wavelan_watchdog()\n", dev
->name
);
3802 #ifdef DEBUG_INTERRUPT_ERROR
3803 printk(KERN_INFO
"%s: wavelan_watchdog: watchdog timer expired\n",
3807 /* Check that we came here for something */
3808 if (lp
->tx_n_in_use
<= 0) {
3812 wv_splhi(lp
, &flags
);
3814 /* Try to see if some buffers are not free (in case we missed
3816 nreaped
= wv_complete(dev
, ioaddr
, lp
);
3818 #ifdef DEBUG_INTERRUPT_INFO
3820 "%s: wavelan_watchdog(): %d reaped, %d remain.\n",
3821 dev
->name
, nreaped
, lp
->tx_n_in_use
);
3824 #ifdef DEBUG_PSA_SHOW
3827 psa_read(dev
, 0, (unsigned char *) &psa
, sizeof(psa
));
3831 #ifdef DEBUG_MMC_SHOW
3834 #ifdef DEBUG_I82586_SHOW
3838 /* If no buffer has been freed */
3840 #ifdef DEBUG_INTERRUPT_ERROR
3842 "%s: wavelan_watchdog(): cleanup failed, trying reset\n",
3848 /* At this point, we should have some free Tx buffer ;-) */
3849 if (lp
->tx_n_in_use
< NTXBLOCKS
- 1)
3850 netif_wake_queue(dev
);
3852 wv_splx(lp
, &flags
);
3854 #ifdef DEBUG_INTERRUPT_TRACE
3855 printk(KERN_DEBUG
"%s: <-wavelan_watchdog()\n", dev
->name
);
3859 /********************* CONFIGURATION CALLBACKS *********************/
3861 * Here are the functions called by the Linux networking code (NET3)
3862 * for initialization, configuration and deinstallations of the
3863 * WaveLAN ISA hardware.
3866 /*------------------------------------------------------------------*/
3868 * Configure and start up the WaveLAN PCMCIA adaptor.
3869 * Called by NET3 when it "opens" the device.
3871 static int wavelan_open(device
* dev
)
3873 net_local
* lp
= (net_local
*)dev
->priv
;
3874 unsigned long flags
;
3876 #ifdef DEBUG_CALLBACK_TRACE
3877 printk(KERN_DEBUG
"%s: ->wavelan_open(dev=0x%x)\n", dev
->name
,
3878 (unsigned int) dev
);
3882 if (dev
->irq
== 0) {
3883 #ifdef DEBUG_CONFIG_ERROR
3884 printk(KERN_WARNING
"%s: wavelan_open(): no IRQ\n",
3890 if (request_irq(dev
->irq
, &wavelan_interrupt
, 0, "WaveLAN", dev
) != 0)
3892 #ifdef DEBUG_CONFIG_ERROR
3893 printk(KERN_WARNING
"%s: wavelan_open(): invalid IRQ\n",
3899 wv_splhi(lp
, &flags
);
3901 if (wv_hw_reset(dev
) != -1) {
3902 netif_start_queue(dev
);
3904 free_irq(dev
->irq
, dev
);
3905 #ifdef DEBUG_CONFIG_ERROR
3907 "%s: wavelan_open(): impossible to start the card\n",
3910 wv_splx(lp
, &flags
);
3913 wv_splx(lp
, &flags
);
3917 #ifdef DEBUG_CALLBACK_TRACE
3918 printk(KERN_DEBUG
"%s: <-wavelan_open()\n", dev
->name
);
3923 /*------------------------------------------------------------------*/
3925 * Shut down the WaveLAN ISA card.
3926 * Called by NET3 when it "closes" the device.
3928 static int wavelan_close(device
* dev
)
3930 net_local
*lp
= (net_local
*) dev
->priv
;
3931 unsigned long flags
;
3933 #ifdef DEBUG_CALLBACK_TRACE
3934 printk(KERN_DEBUG
"%s: ->wavelan_close(dev=0x%x)\n", dev
->name
,
3935 (unsigned int) dev
);
3938 netif_stop_queue(dev
);
3941 * Flush the Tx and disable Rx.
3943 wv_splhi(lp
, &flags
);
3945 wv_splx(lp
, &flags
);
3947 free_irq(dev
->irq
, dev
);
3951 #ifdef DEBUG_CALLBACK_TRACE
3952 printk(KERN_DEBUG
"%s: <-wavelan_close()\n", dev
->name
);
3957 /*------------------------------------------------------------------*/
3959 * Probe an I/O address, and if the WaveLAN is there configure the
3961 * (called by wavelan_probe() and via init_module()).
3963 static int __init
wavelan_config(device
* dev
)
3965 unsigned long ioaddr
= dev
->base_addr
;
3970 #ifdef DEBUG_CALLBACK_TRACE
3971 printk(KERN_DEBUG
"%s: ->wavelan_config(dev=0x%x, ioaddr=0x%lx)\n",
3972 dev
->name
, (unsigned int) dev
, ioaddr
);
3975 /* Check IRQ argument on command line. */
3976 if (dev
->irq
!= 0) {
3977 irq_mask
= wv_irq_to_psa(dev
->irq
);
3979 if (irq_mask
== 0) {
3980 #ifdef DEBUG_CONFIG_ERROR
3982 "%s: wavelan_config(): invalid IRQ %d ignored.\n",
3983 dev
->name
, dev
->irq
);
3987 #ifdef DEBUG_CONFIG_INFO
3989 "%s: wavelan_config(): changing IRQ to %d\n",
3990 dev
->name
, dev
->irq
);
3992 psa_write(ioaddr
, HACR_DEFAULT
,
3993 psaoff(0, psa_int_req_no
), &irq_mask
, 1);
3994 /* update the Wavelan checksum */
3995 update_psa_checksum(dev
, ioaddr
, HACR_DEFAULT
);
3996 wv_hacr_reset(ioaddr
);
4000 psa_read(ioaddr
, HACR_DEFAULT
, psaoff(0, psa_int_req_no
),
4002 if ((irq
= wv_psa_to_irq(irq_mask
)) == -1) {
4003 #ifdef DEBUG_CONFIG_ERROR
4005 "%s: wavelan_config(): could not wavelan_map_irq(%d).\n",
4006 dev
->name
, irq_mask
);
4013 request_region(ioaddr
, sizeof(ha_t
), "wavelan");
4015 dev
->mem_start
= 0x0000;
4016 dev
->mem_end
= 0x0000;
4019 /* Initialize device structures */
4020 dev
->priv
= kmalloc(sizeof(net_local
), GFP_KERNEL
);
4021 if (dev
->priv
== NULL
)
4023 memset(dev
->priv
, 0x00, sizeof(net_local
));
4024 lp
= (net_local
*) dev
->priv
;
4026 /* Back link to the device structure. */
4028 /* Add the device at the beginning of the linked list. */
4029 lp
->next
= wavelan_list
;
4032 lp
->hacr
= HACR_DEFAULT
;
4034 /* Multicast stuff */
4035 lp
->promiscuous
= 0;
4039 spin_lock_init(&lp
->spinlock
);
4042 * Fill in the fields of the device structure
4043 * with generic Ethernet values.
4047 dev
->open
= wavelan_open
;
4048 dev
->stop
= wavelan_close
;
4049 dev
->hard_start_xmit
= wavelan_packet_xmit
;
4050 dev
->get_stats
= wavelan_get_stats
;
4051 dev
->set_multicast_list
= &wavelan_set_multicast_list
;
4052 dev
->tx_timeout
= &wavelan_watchdog
;
4053 dev
->watchdog_timeo
= WATCHDOG_JIFFIES
;
4054 #ifdef SET_MAC_ADDRESS
4055 dev
->set_mac_address
= &wavelan_set_mac_address
;
4056 #endif /* SET_MAC_ADDRESS */
4058 #ifdef WIRELESS_EXT /* if wireless extension exists in the kernel */
4059 dev
->do_ioctl
= wavelan_ioctl
;
4060 dev
->get_wireless_stats
= wavelan_get_wireless_stats
;
4063 dev
->mtu
= WAVELAN_MTU
;
4065 /* Display nice information. */
4068 #ifdef DEBUG_CALLBACK_TRACE
4069 printk(KERN_DEBUG
"%s: <-wavelan_config()\n", dev
->name
);
4074 /*------------------------------------------------------------------*/
4076 * Check for a network adaptor of this type. Return '0' iff one
4077 * exists. There seem to be different interpretations of
4078 * the initial value of dev->base_addr.
4079 * We follow the example in drivers/net/ne.c.
4080 * (called in "Space.c")
4082 int __init
wavelan_probe(device
* dev
)
4085 mac_addr mac
; /* MAC address (check existence of WaveLAN) */
4089 #ifdef DEBUG_CALLBACK_TRACE
4091 "%s: ->wavelan_probe(dev=0x%x (base_addr=0x%x))\n",
4092 dev
->name
, (unsigned int) dev
,
4093 (unsigned int) dev
->base_addr
);
4097 if (wv_struct_check() != (char *) NULL
) {
4099 "%s: wavelan_probe(): structure/compiler botch: \"%s\"\n",
4100 dev
->name
, wv_struct_check());
4103 #endif /* STRUCT_CHECK */
4105 /* Check the value of the command line parameter for base address. */
4106 base_addr
= dev
->base_addr
;
4108 /* Don't probe at all. */
4109 if (base_addr
< 0) {
4110 #ifdef DEBUG_CONFIG_ERROR
4112 "%s: wavelan_probe(): invalid base address\n",
4118 /* Check a single specified location. */
4119 if (base_addr
> 0x100) {
4120 /* Check if there is something at this base address */
4121 if ((r
= wv_check_ioaddr(base_addr
, mac
)) == 0) {
4122 memcpy(dev
->dev_addr
, mac
, 6); /* Copy MAC address. */
4123 r
= wavelan_config(dev
);
4125 #ifdef DEBUG_CONFIG_INFO
4128 "%s: wavelan_probe(): no device at specified base address (0x%X) or address already in use\n",
4129 dev
->name
, base_addr
);
4132 #ifdef DEBUG_CALLBACK_TRACE
4133 printk(KERN_DEBUG
"%s: <-wavelan_probe()\n", dev
->name
);
4138 /* Scan all possible addresses of the WaveLAN hardware. */
4139 for (i
= 0; i
< NELS(iobase
); i
++) {
4140 /* Check whether there is something at this base address. */
4141 if (wv_check_ioaddr(iobase
[i
], mac
) == 0) {
4142 dev
->base_addr
= iobase
[i
]; /* Copy base address. */
4143 memcpy(dev
->dev_addr
, mac
, 6); /* Copy MAC address. */
4144 if (wavelan_config(dev
) == 0) {
4145 #ifdef DEBUG_CALLBACK_TRACE
4147 "%s: <-wavelan_probe()\n",
4155 /* We may have touched base_addr. Another driver may not like it. */
4156 dev
->base_addr
= base_addr
;
4158 #ifdef DEBUG_CONFIG_INFO
4159 printk(KERN_DEBUG
"%s: wavelan_probe(): no device found\n",
4166 /****************************** MODULE ******************************/
4168 * Module entry point: insertion and removal
4172 /*------------------------------------------------------------------*/
4174 * Insertion of the module
4175 * I'm now quite proud of the multi-device support.
4177 int init_module(void)
4179 mac_addr mac
; /* MAC address (check WaveLAN existence) */
4180 int ret
= -EIO
; /* Return error if no cards found */
4183 #ifdef DEBUG_MODULE_TRACE
4184 printk(KERN_DEBUG
"-> init_module()\n");
4187 /* If probing is asked */
4189 #ifdef DEBUG_CONFIG_ERROR
4191 "WaveLAN init_module(): doing device probing (bad !)\n");
4193 "Specify base addresses while loading module to correct the problem\n");
4196 /* Copy the basic set of address to be probed. */
4197 for (i
= 0; i
< NELS(iobase
); i
++)
4202 /* Loop on all possible base addresses. */
4204 while ((io
[++i
] != 0) && (i
< NELS(io
))) {
4205 /* Check if there is something at this base address. */
4206 if (wv_check_ioaddr(io
[i
], mac
) == 0) {
4209 /* Create device and set basic arguments. */
4211 kmalloc(sizeof(struct net_device
), GFP_KERNEL
);
4216 memset(dev
, 0x00, sizeof(struct net_device
));
4217 memcpy(dev
->name
, name
[i
], IFNAMSIZ
); /* Copy name */
4218 dev
->base_addr
= io
[i
];
4220 dev
->init
= &wavelan_config
;
4221 memcpy(dev
->dev_addr
, mac
, 6); /* Copy MAC address. */
4223 /* Try to create the device. */
4224 if (register_netdev(dev
) != 0) {
4225 /* Deallocate everything. */
4226 /* Note: if dev->priv is mallocated, there is no way to fail. */
4229 /* If at least one device OK, we do not fail */
4232 } /* if there is something at the address */
4233 } /* Loop on all addresses. */
4235 #ifdef DEBUG_CONFIG_ERROR
4236 if (wavelan_list
== (net_local
*) NULL
)
4238 "WaveLAN init_module(): no device found\n");
4241 #ifdef DEBUG_MODULE_TRACE
4242 printk(KERN_DEBUG
"<- init_module()\n");
4247 /*------------------------------------------------------------------*/
4249 * Removal of the module
4251 void cleanup_module(void)
4253 #ifdef DEBUG_MODULE_TRACE
4254 printk(KERN_DEBUG
"-> cleanup_module()\n");
4257 /* Loop on all devices and release them. */
4258 while (wavelan_list
!= (net_local
*) NULL
) {
4259 device
*dev
= wavelan_list
->dev
;
4261 #ifdef DEBUG_CONFIG_INFO
4263 "%s: cleanup_module(): removing device at 0x%x\n",
4264 dev
->name
, (unsigned int) dev
);
4267 /* Release the ioport region. */
4268 release_region(dev
->base_addr
, sizeof(ha_t
));
4270 /* Definitely remove the device. */
4271 unregister_netdev(dev
);
4273 /* Unlink the device. */
4274 wavelan_list
= wavelan_list
->next
;
4281 #ifdef DEBUG_MODULE_TRACE
4282 printk(KERN_DEBUG
"<- cleanup_module()\n");
4288 * This software may only be used and distributed
4289 * according to the terms of the GNU Public License.
4291 * This software was developed as a component of the
4292 * Linux operating system.
4293 * It is based on other device drivers and information
4294 * either written or supplied by:
4295 * Ajay Bakre (bakre@paul.rutgers.edu),
4296 * Donald Becker (becker@cesdis.gsfc.nasa.gov),
4297 * Loeke Brederveld (Loeke.Brederveld@Utrecht.NCR.com),
4298 * Anders Klemets (klemets@it.kth.se),
4299 * Vladimir V. Kolpakov (w@stier.koenig.ru),
4300 * Marc Meertens (Marc.Meertens@Utrecht.NCR.com),
4301 * Pauline Middelink (middelin@polyware.iaf.nl),
4302 * Robert Morris (rtm@das.harvard.edu),
4303 * Jean Tourrilhes (jt@hplb.hpl.hp.com),
4304 * Girish Welling (welling@paul.rutgers.edu),
4306 * Thanks go also to:
4307 * James Ashton (jaa101@syseng.anu.edu.au),
4308 * Alan Cox (alan@redhat.com),
4309 * Allan Creighton (allanc@cs.usyd.edu.au),
4310 * Matthew Geier (matthew@cs.usyd.edu.au),
4311 * Remo di Giovanni (remo@cs.usyd.edu.au),
4312 * Eckhard Grah (grah@wrcs1.urz.uni-wuppertal.de),
4313 * Vipul Gupta (vgupta@cs.binghamton.edu),
4314 * Mark Hagan (mhagan@wtcpost.daytonoh.NCR.COM),
4315 * Tim Nicholson (tim@cs.usyd.edu.au),
4316 * Ian Parkin (ian@cs.usyd.edu.au),
4317 * John Rosenberg (johnr@cs.usyd.edu.au),
4318 * George Rossi (george@phm.gov.au),
4319 * Arthur Scott (arthur@cs.usyd.edu.au),
4321 * for their assistance and advice.
4323 * Please send bug reports, updates, comments to:
4325 * Bruce Janson Email: bruce@cs.usyd.edu.au
4326 * Basser Department of Computer Science Phone: +61-2-9351-3423
4327 * University of Sydney, N.S.W., 2006, AUSTRALIA Fax: +61-2-9351-3838