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 * Translate irq number to PSA irq parameter
29 static u8 wv_irq_to_psa(int irq)
31 if (irq < 0 || irq >= ARRAY_SIZE(irqvals))
37 /*------------------------------------------------------------------*/
39 * Translate PSA irq parameter to irq number
41 static int __init wv_psa_to_irq(u8 irqval)
45 for (irq = 0; irq < ARRAY_SIZE(irqvals); irq++)
46 if (irqvals[irq] == irqval)
52 /********************* HOST ADAPTER SUBROUTINES *********************/
54 * Useful subroutines to manage the WaveLAN ISA interface
56 * One major difference with the PCMCIA hardware (except the port mapping)
57 * is that we have to keep the state of the Host Control Register
58 * because of the interrupt enable & bus size flags.
61 /*------------------------------------------------------------------*/
63 * Read from card's Host Adaptor Status Register.
65 static inline u16 hasr_read(unsigned long ioaddr)
67 return (inw(HASR(ioaddr)));
70 /*------------------------------------------------------------------*/
72 * Write to card's Host Adapter Command Register.
74 static inline void hacr_write(unsigned long ioaddr, u16 hacr)
76 outw(hacr, HACR(ioaddr));
79 /*------------------------------------------------------------------*/
81 * Write to card's Host Adapter Command Register. Include a delay for
82 * those times when it is needed.
84 static void hacr_write_slow(unsigned long ioaddr, u16 hacr)
86 hacr_write(ioaddr, hacr);
87 /* delay might only be needed sometimes */
89 } /* hacr_write_slow */
91 /*------------------------------------------------------------------*/
93 * Set the channel attention bit.
95 static inline void set_chan_attn(unsigned long ioaddr, u16 hacr)
97 hacr_write(ioaddr, hacr | HACR_CA);
100 /*------------------------------------------------------------------*/
102 * Reset, and then set host adaptor into default mode.
104 static inline void wv_hacr_reset(unsigned long ioaddr)
106 hacr_write_slow(ioaddr, HACR_RESET);
107 hacr_write(ioaddr, HACR_DEFAULT);
108 } /* wv_hacr_reset */
110 /*------------------------------------------------------------------*/
112 * Set the I/O transfer over the ISA bus to 8-bit mode
114 static inline void wv_16_off(unsigned long ioaddr, u16 hacr)
116 hacr &= ~HACR_16BITS;
117 hacr_write(ioaddr, hacr);
120 /*------------------------------------------------------------------*/
122 * Set the I/O transfer over the ISA bus to 8-bit mode
124 static inline void wv_16_on(unsigned long ioaddr, u16 hacr)
127 hacr_write(ioaddr, hacr);
130 /*------------------------------------------------------------------*/
132 * Disable interrupts on the WaveLAN hardware.
133 * (called by wv_82586_stop())
135 static inline void wv_ints_off(struct net_device * dev)
137 net_local *lp = (net_local *) dev->priv;
138 unsigned long ioaddr = dev->base_addr;
140 lp->hacr &= ~HACR_INTRON;
141 hacr_write(ioaddr, lp->hacr);
144 /*------------------------------------------------------------------*/
146 * Enable interrupts on the WaveLAN hardware.
147 * (called by wv_hw_reset())
149 static inline void wv_ints_on(struct net_device * dev)
151 net_local *lp = (net_local *) dev->priv;
152 unsigned long ioaddr = dev->base_addr;
154 lp->hacr |= HACR_INTRON;
155 hacr_write(ioaddr, lp->hacr);
158 /******************* MODEM MANAGEMENT SUBROUTINES *******************/
160 * Useful subroutines to manage the modem of the WaveLAN
163 /*------------------------------------------------------------------*/
165 * Read the Parameter Storage Area from the WaveLAN card's memory
168 * Read bytes from the PSA.
170 static void psa_read(unsigned long ioaddr, u16 hacr, int o, /* offset in PSA */
171 u8 * b, /* buffer to fill */
174 wv_16_off(ioaddr, hacr);
177 outw(o, PIOR2(ioaddr));
179 *b++ = inb(PIOP2(ioaddr));
182 wv_16_on(ioaddr, hacr);
185 /*------------------------------------------------------------------*/
187 * Write the Parameter Storage Area to the WaveLAN card's memory.
189 static void psa_write(unsigned long ioaddr, u16 hacr, int o, /* Offset in PSA */
190 u8 * b, /* Buffer in memory */
192 { /* Length of buffer */
195 wv_16_off(ioaddr, hacr);
198 outw(o, PIOR2(ioaddr));
201 outb(*b, PIOP2(ioaddr));
204 /* Wait for the memory to finish its write cycle */
206 while ((count++ < 100) &&
207 (hasr_read(ioaddr) & HASR_PSA_BUSY)) mdelay(1);
210 wv_16_on(ioaddr, hacr);
214 /*------------------------------------------------------------------*/
216 * Calculate the PSA CRC
217 * Thanks to Valster, Nico <NVALSTER@wcnd.nl.lucent.com> for the code
218 * NOTE: By specifying a length including the CRC position the
219 * returned value should be zero. (i.e. a correct checksum in the PSA)
221 * The Windows drivers don't use the CRC, but the AP and the PtP tool
224 static u16 psa_crc(u8 * psa, /* The PSA */
226 { /* Number of short for CRC */
227 int byte_cnt; /* Loop on the PSA */
228 u16 crc_bytes = 0; /* Data in the PSA */
229 int bit_cnt; /* Loop on the bits of the short */
231 for (byte_cnt = 0; byte_cnt < size; byte_cnt++) {
232 crc_bytes ^= psa[byte_cnt]; /* Its an xor */
234 for (bit_cnt = 1; bit_cnt < 9; bit_cnt++) {
235 if (crc_bytes & 0x0001)
236 crc_bytes = (crc_bytes >> 1) ^ 0xA001;
244 #endif /* SET_PSA_CRC */
246 /*------------------------------------------------------------------*/
248 * update the checksum field in the Wavelan's PSA
250 static void update_psa_checksum(struct net_device * dev, unsigned long ioaddr, u16 hacr)
256 /* read the parameter storage area */
257 psa_read(ioaddr, hacr, 0, (unsigned char *) &psa, sizeof(psa));
259 /* update the checksum */
260 crc = psa_crc((unsigned char *) &psa,
261 sizeof(psa) - sizeof(psa.psa_crc[0]) -
262 sizeof(psa.psa_crc[1])
263 - sizeof(psa.psa_crc_status));
265 psa.psa_crc[0] = crc & 0xFF;
266 psa.psa_crc[1] = (crc & 0xFF00) >> 8;
269 psa_write(ioaddr, hacr, (char *) &psa.psa_crc - (char *) &psa,
270 (unsigned char *) &psa.psa_crc, 2);
272 #ifdef DEBUG_IOCTL_INFO
273 printk(KERN_DEBUG "%s: update_psa_checksum(): crc = 0x%02x%02x\n",
274 dev->name, psa.psa_crc[0], psa.psa_crc[1]);
276 /* Check again (luxury !) */
277 crc = psa_crc((unsigned char *) &psa,
278 sizeof(psa) - sizeof(psa.psa_crc_status));
282 "%s: update_psa_checksum(): CRC does not agree with PSA data (even after recalculating)\n",
284 #endif /* DEBUG_IOCTL_INFO */
285 #endif /* SET_PSA_CRC */
286 } /* update_psa_checksum */
288 /*------------------------------------------------------------------*/
290 * Write 1 byte to the MMC.
292 static void mmc_out(unsigned long ioaddr, u16 o, u8 d)
296 /* Wait for MMC to go idle */
297 while ((count++ < 100) && (inw(HASR(ioaddr)) & HASR_MMC_BUSY))
300 outw((u16) (((u16) d << 8) | (o << 1) | 1), MMCR(ioaddr));
303 /*------------------------------------------------------------------*/
305 * Routine to write bytes to the Modem Management Controller.
306 * We start at the end because it is the way it should be!
308 static void mmc_write(unsigned long ioaddr, u8 o, u8 * b, int n)
314 mmc_out(ioaddr, --o, *(--b));
317 /*------------------------------------------------------------------*/
319 * Read a byte from the MMC.
320 * Optimised version for 1 byte, avoid using memory.
322 static u8 mmc_in(unsigned long ioaddr, u16 o)
326 while ((count++ < 100) && (inw(HASR(ioaddr)) & HASR_MMC_BUSY))
328 outw(o << 1, MMCR(ioaddr));
330 while ((count++ < 100) && (inw(HASR(ioaddr)) & HASR_MMC_BUSY))
332 return (u8) (inw(MMCR(ioaddr)) >> 8);
335 /*------------------------------------------------------------------*/
337 * Routine to read bytes from the Modem Management Controller.
338 * The implementation is complicated by a lack of address lines,
339 * which prevents decoding of the low-order bit.
340 * (code has just been moved in the above function)
341 * We start at the end because it is the way it should be!
343 static inline void mmc_read(unsigned long ioaddr, u8 o, u8 * b, int n)
349 *(--b) = mmc_in(ioaddr, --o);
352 /*------------------------------------------------------------------*/
354 * Get the type of encryption available.
356 static inline int mmc_encr(unsigned long ioaddr)
357 { /* I/O port of the card */
360 temp = mmc_in(ioaddr, mmroff(0, mmr_des_avail));
361 if ((temp != MMR_DES_AVAIL_DES) && (temp != MMR_DES_AVAIL_AES))
367 /*------------------------------------------------------------------*/
369 * Wait for the frequency EEPROM to complete a command.
370 * I hope this one will be optimally inlined.
372 static inline void fee_wait(unsigned long ioaddr, /* I/O port of the card */
373 int delay, /* Base delay to wait for */
375 { /* Number of time to wait */
376 int count = 0; /* Wait only a limited time */
378 while ((count++ < number) &&
379 (mmc_in(ioaddr, mmroff(0, mmr_fee_status)) &
380 MMR_FEE_STATUS_BUSY)) udelay(delay);
383 /*------------------------------------------------------------------*/
385 * Read bytes from the Frequency EEPROM (frequency select cards).
387 static void fee_read(unsigned long ioaddr, /* I/O port of the card */
388 u16 o, /* destination offset */
389 u16 * b, /* data buffer */
391 { /* number of registers */
392 b += n; /* Position at the end of the area */
394 /* Write the address */
395 mmc_out(ioaddr, mmwoff(0, mmw_fee_addr), o + n - 1);
397 /* Loop on all buffer */
399 /* Write the read command */
400 mmc_out(ioaddr, mmwoff(0, mmw_fee_ctrl),
403 /* Wait until EEPROM is ready (should be quick). */
404 fee_wait(ioaddr, 10, 100);
406 /* Read the value. */
407 *--b = ((mmc_in(ioaddr, mmroff(0, mmr_fee_data_h)) << 8) |
408 mmc_in(ioaddr, mmroff(0, mmr_fee_data_l)));
413 /*------------------------------------------------------------------*/
415 * Write bytes from the Frequency EEPROM (frequency select cards).
416 * This is a bit complicated, because the frequency EEPROM has to
417 * be unprotected and the write enabled.
420 static void fee_write(unsigned long ioaddr, /* I/O port of the card */
421 u16 o, /* destination offset */
422 u16 * b, /* data buffer */
424 { /* number of registers */
425 b += n; /* Position at the end of the area. */
427 #ifdef EEPROM_IS_PROTECTED /* disabled */
428 #ifdef DOESNT_SEEM_TO_WORK /* disabled */
429 /* Ask to read the protected register */
430 mmc_out(ioaddr, mmwoff(0, mmw_fee_ctrl), MMW_FEE_CTRL_PRREAD);
432 fee_wait(ioaddr, 10, 100);
434 /* Read the protected register. */
435 printk("Protected 2: %02X-%02X\n",
436 mmc_in(ioaddr, mmroff(0, mmr_fee_data_h)),
437 mmc_in(ioaddr, mmroff(0, mmr_fee_data_l)));
438 #endif /* DOESNT_SEEM_TO_WORK */
440 /* Enable protected register. */
441 mmc_out(ioaddr, mmwoff(0, mmw_fee_addr), MMW_FEE_ADDR_EN);
442 mmc_out(ioaddr, mmwoff(0, mmw_fee_ctrl), MMW_FEE_CTRL_PREN);
444 fee_wait(ioaddr, 10, 100);
446 /* Unprotect area. */
447 mmc_out(ioaddr, mmwoff(0, mmw_fee_addr), o + n);
448 mmc_out(ioaddr, mmwoff(0, mmw_fee_ctrl), MMW_FEE_CTRL_PRWRITE);
449 #ifdef DOESNT_SEEM_TO_WORK /* disabled */
451 mmc_out(ioaddr, mmwoff(0, mmw_fee_ctrl), MMW_FEE_CTRL_PRCLEAR);
452 #endif /* DOESNT_SEEM_TO_WORK */
454 fee_wait(ioaddr, 10, 100);
455 #endif /* EEPROM_IS_PROTECTED */
458 mmc_out(ioaddr, mmwoff(0, mmw_fee_addr), MMW_FEE_ADDR_EN);
459 mmc_out(ioaddr, mmwoff(0, mmw_fee_ctrl), MMW_FEE_CTRL_WREN);
461 fee_wait(ioaddr, 10, 100);
463 /* Write the EEPROM address. */
464 mmc_out(ioaddr, mmwoff(0, mmw_fee_addr), o + n - 1);
466 /* Loop on all buffer */
468 /* Write the value. */
469 mmc_out(ioaddr, mmwoff(0, mmw_fee_data_h), (*--b) >> 8);
470 mmc_out(ioaddr, mmwoff(0, mmw_fee_data_l), *b & 0xFF);
472 /* Write the write command. */
473 mmc_out(ioaddr, mmwoff(0, mmw_fee_ctrl),
476 /* WaveLAN documentation says to wait at least 10 ms for EEBUSY = 0 */
478 fee_wait(ioaddr, 10, 100);
482 mmc_out(ioaddr, mmwoff(0, mmw_fee_addr), MMW_FEE_ADDR_DS);
483 mmc_out(ioaddr, mmwoff(0, mmw_fee_ctrl), MMW_FEE_CTRL_WDS);
485 fee_wait(ioaddr, 10, 100);
487 #ifdef EEPROM_IS_PROTECTED /* disabled */
488 /* Reprotect EEPROM. */
489 mmc_out(ioaddr, mmwoff(0, mmw_fee_addr), 0x00);
490 mmc_out(ioaddr, mmwoff(0, mmw_fee_ctrl), MMW_FEE_CTRL_PRWRITE);
492 fee_wait(ioaddr, 10, 100);
493 #endif /* EEPROM_IS_PROTECTED */
496 /************************ I82586 SUBROUTINES *************************/
498 * Useful subroutines to manage the Ethernet controller
501 /*------------------------------------------------------------------*/
503 * Read bytes from the on-board RAM.
504 * Why does inlining this function make it fail?
506 static /*inline */ void obram_read(unsigned long ioaddr,
507 u16 o, u8 * b, int n)
509 outw(o, PIOR1(ioaddr));
510 insw(PIOP1(ioaddr), (unsigned short *) b, (n + 1) >> 1);
513 /*------------------------------------------------------------------*/
515 * Write bytes to the on-board RAM.
517 static inline void obram_write(unsigned long ioaddr, u16 o, u8 * b, int n)
519 outw(o, PIOR1(ioaddr));
520 outsw(PIOP1(ioaddr), (unsigned short *) b, (n + 1) >> 1);
523 /*------------------------------------------------------------------*/
525 * Acknowledge the reading of the status issued by the i82586.
527 static void wv_ack(struct net_device * dev)
529 net_local *lp = (net_local *) dev->priv;
530 unsigned long ioaddr = dev->base_addr;
534 obram_read(ioaddr, scboff(OFFSET_SCB, scb_status),
535 (unsigned char *) &scb_cs, sizeof(scb_cs));
536 scb_cs &= SCB_ST_INT;
541 obram_write(ioaddr, scboff(OFFSET_SCB, scb_command),
542 (unsigned char *) &scb_cs, sizeof(scb_cs));
544 set_chan_attn(ioaddr, lp->hacr);
546 for (i = 1000; i > 0; i--) {
547 obram_read(ioaddr, scboff(OFFSET_SCB, scb_command),
548 (unsigned char *) &scb_cs, sizeof(scb_cs));
556 #ifdef DEBUG_CONFIG_ERROR
559 "%s: wv_ack(): board not accepting command.\n",
564 /*------------------------------------------------------------------*/
566 * Set channel attention bit and busy wait until command has
567 * completed, then acknowledge completion of the command.
569 static int wv_synchronous_cmd(struct net_device * dev, const char *str)
571 net_local *lp = (net_local *) dev->priv;
572 unsigned long ioaddr = dev->base_addr;
577 scb_cmd = SCB_CMD_CUC & SCB_CMD_CUC_GO;
578 obram_write(ioaddr, scboff(OFFSET_SCB, scb_command),
579 (unsigned char *) &scb_cmd, sizeof(scb_cmd));
581 set_chan_attn(ioaddr, lp->hacr);
583 for (i = 1000; i > 0; i--) {
584 obram_read(ioaddr, OFFSET_CU, (unsigned char *) &cb,
586 if (cb.ac_status & AC_SFLD_C)
593 if (i <= 0 || !(cb.ac_status & AC_SFLD_OK)) {
594 #ifdef DEBUG_CONFIG_ERROR
595 printk(KERN_INFO "%s: %s failed; status = 0x%x\n",
596 dev->name, str, cb.ac_status);
598 #ifdef DEBUG_I82586_SHOW
610 /*------------------------------------------------------------------*/
612 * Configuration commands completion interrupt.
613 * Check if done, and if OK.
616 wv_config_complete(struct net_device * dev, unsigned long ioaddr, net_local * lp)
618 unsigned short mcs_addr;
619 unsigned short status;
622 #ifdef DEBUG_INTERRUPT_TRACE
623 printk(KERN_DEBUG "%s: ->wv_config_complete()\n", dev->name);
626 mcs_addr = lp->tx_first_in_use + sizeof(ac_tx_t) + sizeof(ac_nop_t)
627 + sizeof(tbd_t) + sizeof(ac_cfg_t) + sizeof(ac_ias_t);
629 /* Read the status of the last command (set mc list). */
630 obram_read(ioaddr, acoff(mcs_addr, ac_status),
631 (unsigned char *) &status, sizeof(status));
633 /* If not completed -> exit */
634 if ((status & AC_SFLD_C) == 0)
635 ret = 0; /* Not ready to be scrapped */
637 #ifdef DEBUG_CONFIG_ERROR
638 unsigned short cfg_addr;
639 unsigned short ias_addr;
641 /* Check mc_config command */
642 if ((status & AC_SFLD_OK) != AC_SFLD_OK)
644 "%s: wv_config_complete(): set_multicast_address failed; status = 0x%x\n",
647 /* check ia-config command */
648 ias_addr = mcs_addr - sizeof(ac_ias_t);
649 obram_read(ioaddr, acoff(ias_addr, ac_status),
650 (unsigned char *) &status, sizeof(status));
651 if ((status & AC_SFLD_OK) != AC_SFLD_OK)
653 "%s: wv_config_complete(): set_MAC_address failed; status = 0x%x\n",
656 /* Check config command. */
657 cfg_addr = ias_addr - sizeof(ac_cfg_t);
658 obram_read(ioaddr, acoff(cfg_addr, ac_status),
659 (unsigned char *) &status, sizeof(status));
660 if ((status & AC_SFLD_OK) != AC_SFLD_OK)
662 "%s: wv_config_complete(): configure failed; status = 0x%x\n",
664 #endif /* DEBUG_CONFIG_ERROR */
666 ret = 1; /* Ready to be scrapped */
669 #ifdef DEBUG_INTERRUPT_TRACE
670 printk(KERN_DEBUG "%s: <-wv_config_complete() - %d\n", dev->name,
676 /*------------------------------------------------------------------*/
678 * Command completion interrupt.
679 * Reclaim as many freed tx buffers as we can.
680 * (called in wavelan_interrupt()).
681 * Note : the spinlock is already grabbed for us.
683 static int wv_complete(struct net_device * dev, unsigned long ioaddr, net_local * lp)
687 #ifdef DEBUG_INTERRUPT_TRACE
688 printk(KERN_DEBUG "%s: ->wv_complete()\n", dev->name);
691 /* Loop on all the transmit buffers */
692 while (lp->tx_first_in_use != I82586NULL) {
693 unsigned short tx_status;
695 /* Read the first transmit buffer */
696 obram_read(ioaddr, acoff(lp->tx_first_in_use, ac_status),
697 (unsigned char *) &tx_status,
700 /* If not completed -> exit */
701 if ((tx_status & AC_SFLD_C) == 0)
704 /* Hack for reconfiguration */
705 if (tx_status == 0xFFFF)
706 if (!wv_config_complete(dev, ioaddr, lp))
707 break; /* Not completed */
709 /* We now remove this buffer */
714 if (lp->tx_n_in_use > 0)
715 printk("%c", "0123456789abcdefghijk"[lp->tx_n_in_use]);
718 /* Was it the last one? */
719 if (lp->tx_n_in_use <= 0)
720 lp->tx_first_in_use = I82586NULL;
722 /* Next one in the chain */
723 lp->tx_first_in_use += TXBLOCKZ;
724 if (lp->tx_first_in_use >=
726 NTXBLOCKS * TXBLOCKZ) lp->tx_first_in_use -=
727 NTXBLOCKS * TXBLOCKZ;
730 /* Hack for reconfiguration */
731 if (tx_status == 0xFFFF)
734 /* Now, check status of the finished command */
735 if (tx_status & AC_SFLD_OK) {
738 lp->stats.tx_packets++;
739 ncollisions = tx_status & AC_SFLD_MAXCOL;
740 lp->stats.collisions += ncollisions;
744 "%s: wv_complete(): tx completed after %d collisions.\n",
745 dev->name, ncollisions);
748 lp->stats.tx_errors++;
749 if (tx_status & AC_SFLD_S10) {
750 lp->stats.tx_carrier_errors++;
753 "%s: wv_complete(): tx error: no CS.\n",
757 if (tx_status & AC_SFLD_S9) {
758 lp->stats.tx_carrier_errors++;
761 "%s: wv_complete(): tx error: lost CTS.\n",
765 if (tx_status & AC_SFLD_S8) {
766 lp->stats.tx_fifo_errors++;
769 "%s: wv_complete(): tx error: slow DMA.\n",
773 if (tx_status & AC_SFLD_S6) {
774 lp->stats.tx_heartbeat_errors++;
777 "%s: wv_complete(): tx error: heart beat.\n",
781 if (tx_status & AC_SFLD_S5) {
782 lp->stats.tx_aborted_errors++;
785 "%s: wv_complete(): tx error: too many collisions.\n",
793 "%s: wv_complete(): tx completed, tx_status 0x%04x\n",
794 dev->name, tx_status);
798 #ifdef DEBUG_INTERRUPT_INFO
800 printk(KERN_DEBUG "%s: wv_complete(): reaped %d\n",
805 * Inform upper layers.
807 if (lp->tx_n_in_use < NTXBLOCKS - 1) {
808 netif_wake_queue(dev);
810 #ifdef DEBUG_INTERRUPT_TRACE
811 printk(KERN_DEBUG "%s: <-wv_complete()\n", dev->name);
816 /*------------------------------------------------------------------*/
818 * Reconfigure the i82586, or at least ask for it.
819 * Because wv_82586_config uses a transmission buffer, we must do it
820 * when we are sure that there is one left, so we do it now
821 * or in wavelan_packet_xmit() (I can't find any better place,
822 * wavelan_interrupt is not an option), so you may experience
825 static void wv_82586_reconfig(struct net_device * dev)
827 net_local *lp = (net_local *) dev->priv;
830 /* Arm the flag, will be cleard in wv_82586_config() */
831 lp->reconfig_82586 = 1;
833 /* Check if we can do it now ! */
834 if((netif_running(dev)) && !(netif_queue_stopped(dev))) {
835 spin_lock_irqsave(&lp->spinlock, flags);
837 wv_82586_config(dev);
838 spin_unlock_irqrestore(&lp->spinlock, flags);
841 #ifdef DEBUG_CONFIG_INFO
843 "%s: wv_82586_reconfig(): delayed (state = %lX)\n",
844 dev->name, dev->state);
849 /********************* DEBUG & INFO SUBROUTINES *********************/
851 * This routine is used in the code to show information for debugging.
852 * Most of the time, it dumps the contents of hardware structures.
855 #ifdef DEBUG_PSA_SHOW
856 /*------------------------------------------------------------------*/
858 * Print the formatted contents of the Parameter Storage Area.
860 static void wv_psa_show(psa_t * p)
862 printk(KERN_DEBUG "##### WaveLAN PSA contents: #####\n");
863 printk(KERN_DEBUG "psa_io_base_addr_1: 0x%02X %02X %02X %02X\n",
864 p->psa_io_base_addr_1,
865 p->psa_io_base_addr_2,
866 p->psa_io_base_addr_3, p->psa_io_base_addr_4);
867 printk(KERN_DEBUG "psa_rem_boot_addr_1: 0x%02X %02X %02X\n",
868 p->psa_rem_boot_addr_1,
869 p->psa_rem_boot_addr_2, p->psa_rem_boot_addr_3);
870 printk(KERN_DEBUG "psa_holi_params: 0x%02x, ", p->psa_holi_params);
871 printk("psa_int_req_no: %d\n", p->psa_int_req_no);
872 #ifdef DEBUG_SHOW_UNUSED
873 printk(KERN_DEBUG "psa_unused0[]: %pM\n", p->psa_unused0);
874 #endif /* DEBUG_SHOW_UNUSED */
875 printk(KERN_DEBUG "psa_univ_mac_addr[]: %pM\n", p->psa_univ_mac_addr);
876 printk(KERN_DEBUG "psa_local_mac_addr[]: %pM\n", p->psa_local_mac_addr);
877 printk(KERN_DEBUG "psa_univ_local_sel: %d, ",
878 p->psa_univ_local_sel);
879 printk("psa_comp_number: %d, ", p->psa_comp_number);
880 printk("psa_thr_pre_set: 0x%02x\n", p->psa_thr_pre_set);
881 printk(KERN_DEBUG "psa_feature_select/decay_prm: 0x%02x, ",
882 p->psa_feature_select);
883 printk("psa_subband/decay_update_prm: %d\n", p->psa_subband);
884 printk(KERN_DEBUG "psa_quality_thr: 0x%02x, ", p->psa_quality_thr);
885 printk("psa_mod_delay: 0x%02x\n", p->psa_mod_delay);
886 printk(KERN_DEBUG "psa_nwid: 0x%02x%02x, ", p->psa_nwid[0],
888 printk("psa_nwid_select: %d\n", p->psa_nwid_select);
889 printk(KERN_DEBUG "psa_encryption_select: %d, ",
890 p->psa_encryption_select);
892 ("psa_encryption_key[]: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
893 p->psa_encryption_key[0], p->psa_encryption_key[1],
894 p->psa_encryption_key[2], p->psa_encryption_key[3],
895 p->psa_encryption_key[4], p->psa_encryption_key[5],
896 p->psa_encryption_key[6], p->psa_encryption_key[7]);
897 printk(KERN_DEBUG "psa_databus_width: %d\n", p->psa_databus_width);
898 printk(KERN_DEBUG "psa_call_code/auto_squelch: 0x%02x, ",
899 p->psa_call_code[0]);
901 ("psa_call_code[]: %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
902 p->psa_call_code[0], p->psa_call_code[1], p->psa_call_code[2],
903 p->psa_call_code[3], p->psa_call_code[4], p->psa_call_code[5],
904 p->psa_call_code[6], p->psa_call_code[7]);
905 #ifdef DEBUG_SHOW_UNUSED
906 printk(KERN_DEBUG "psa_reserved[]: %02X:%02X\n",
909 #endif /* DEBUG_SHOW_UNUSED */
910 printk(KERN_DEBUG "psa_conf_status: %d, ", p->psa_conf_status);
911 printk("psa_crc: 0x%02x%02x, ", p->psa_crc[0], p->psa_crc[1]);
912 printk("psa_crc_status: 0x%02x\n", p->psa_crc_status);
914 #endif /* DEBUG_PSA_SHOW */
916 #ifdef DEBUG_MMC_SHOW
917 /*------------------------------------------------------------------*/
919 * Print the formatted status of the Modem Management Controller.
920 * This function needs to be completed.
922 static void wv_mmc_show(struct net_device * dev)
924 unsigned long ioaddr = dev->base_addr;
925 net_local *lp = (net_local *) dev->priv;
929 if (hasr_read(ioaddr) & HASR_NO_CLK) {
931 "%s: wv_mmc_show: modem not connected\n",
937 mmc_out(ioaddr, mmwoff(0, mmw_freeze), 1);
938 mmc_read(ioaddr, 0, (u8 *) & m, sizeof(m));
939 mmc_out(ioaddr, mmwoff(0, mmw_freeze), 0);
941 /* Don't forget to update statistics */
942 lp->wstats.discard.nwid +=
943 (m.mmr_wrong_nwid_h << 8) | m.mmr_wrong_nwid_l;
945 printk(KERN_DEBUG "##### WaveLAN modem status registers: #####\n");
946 #ifdef DEBUG_SHOW_UNUSED
948 "mmc_unused0[]: %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
949 m.mmr_unused0[0], m.mmr_unused0[1], m.mmr_unused0[2],
950 m.mmr_unused0[3], m.mmr_unused0[4], m.mmr_unused0[5],
951 m.mmr_unused0[6], m.mmr_unused0[7]);
952 #endif /* DEBUG_SHOW_UNUSED */
953 printk(KERN_DEBUG "Encryption algorithm: %02X - Status: %02X\n",
954 m.mmr_des_avail, m.mmr_des_status);
955 #ifdef DEBUG_SHOW_UNUSED
956 printk(KERN_DEBUG "mmc_unused1[]: %02X:%02X:%02X:%02X:%02X\n",
959 m.mmr_unused1[2], m.mmr_unused1[3], m.mmr_unused1[4]);
960 #endif /* DEBUG_SHOW_UNUSED */
961 printk(KERN_DEBUG "dce_status: 0x%x [%s%s%s%s]\n",
964 mmr_dce_status & MMR_DCE_STATUS_RX_BUSY) ?
965 "energy detected," : "",
967 mmr_dce_status & MMR_DCE_STATUS_LOOPT_IND) ?
968 "loop test indicated," : "",
970 mmr_dce_status & MMR_DCE_STATUS_TX_BUSY) ?
971 "transmitter on," : "",
973 mmr_dce_status & MMR_DCE_STATUS_JBR_EXPIRED) ?
974 "jabber timer expired," : "");
975 printk(KERN_DEBUG "Dsp ID: %02X\n", m.mmr_dsp_id);
976 #ifdef DEBUG_SHOW_UNUSED
977 printk(KERN_DEBUG "mmc_unused2[]: %02X:%02X\n",
978 m.mmr_unused2[0], m.mmr_unused2[1]);
979 #endif /* DEBUG_SHOW_UNUSED */
980 printk(KERN_DEBUG "# correct_nwid: %d, # wrong_nwid: %d\n",
981 (m.mmr_correct_nwid_h << 8) | m.mmr_correct_nwid_l,
982 (m.mmr_wrong_nwid_h << 8) | m.mmr_wrong_nwid_l);
983 printk(KERN_DEBUG "thr_pre_set: 0x%x [current signal %s]\n",
984 m.mmr_thr_pre_set & MMR_THR_PRE_SET,
986 mmr_thr_pre_set & MMR_THR_PRE_SET_CUR) ? "above" :
988 printk(KERN_DEBUG "signal_lvl: %d [%s], ",
989 m.mmr_signal_lvl & MMR_SIGNAL_LVL,
991 mmr_signal_lvl & MMR_SIGNAL_LVL_VALID) ? "new msg" :
993 printk("silence_lvl: %d [%s], ",
994 m.mmr_silence_lvl & MMR_SILENCE_LVL,
996 mmr_silence_lvl & MMR_SILENCE_LVL_VALID) ? "update done" :
998 printk("sgnl_qual: 0x%x [%s]\n", m.mmr_sgnl_qual & MMR_SGNL_QUAL,
1000 mmr_sgnl_qual & MMR_SGNL_QUAL_ANT) ? "Antenna 1" :
1002 #ifdef DEBUG_SHOW_UNUSED
1003 printk(KERN_DEBUG "netw_id_l: %x\n", m.mmr_netw_id_l);
1004 #endif /* DEBUG_SHOW_UNUSED */
1006 #endif /* DEBUG_MMC_SHOW */
1008 #ifdef DEBUG_I82586_SHOW
1009 /*------------------------------------------------------------------*/
1011 * Print the last block of the i82586 memory.
1013 static void wv_scb_show(unsigned long ioaddr)
1017 obram_read(ioaddr, OFFSET_SCB, (unsigned char *) &scb,
1020 printk(KERN_DEBUG "##### WaveLAN system control block: #####\n");
1022 printk(KERN_DEBUG "status: ");
1023 printk("stat 0x%x[%s%s%s%s] ",
1025 scb_status & (SCB_ST_CX | SCB_ST_FR | SCB_ST_CNA |
1028 scb_status & SCB_ST_CX) ? "command completion interrupt," :
1029 "", (scb.scb_status & SCB_ST_FR) ? "frame received," : "",
1031 scb_status & SCB_ST_CNA) ? "command unit not active," : "",
1033 scb_status & SCB_ST_RNR) ? "receiving unit not ready," :
1035 printk("cus 0x%x[%s%s%s] ", (scb.scb_status & SCB_ST_CUS) >> 8,
1036 ((scb.scb_status & SCB_ST_CUS) ==
1037 SCB_ST_CUS_IDLE) ? "idle" : "",
1038 ((scb.scb_status & SCB_ST_CUS) ==
1039 SCB_ST_CUS_SUSP) ? "suspended" : "",
1040 ((scb.scb_status & SCB_ST_CUS) ==
1041 SCB_ST_CUS_ACTV) ? "active" : "");
1042 printk("rus 0x%x[%s%s%s%s]\n", (scb.scb_status & SCB_ST_RUS) >> 4,
1043 ((scb.scb_status & SCB_ST_RUS) ==
1044 SCB_ST_RUS_IDLE) ? "idle" : "",
1045 ((scb.scb_status & SCB_ST_RUS) ==
1046 SCB_ST_RUS_SUSP) ? "suspended" : "",
1047 ((scb.scb_status & SCB_ST_RUS) ==
1048 SCB_ST_RUS_NRES) ? "no resources" : "",
1049 ((scb.scb_status & SCB_ST_RUS) ==
1050 SCB_ST_RUS_RDY) ? "ready" : "");
1052 printk(KERN_DEBUG "command: ");
1053 printk("ack 0x%x[%s%s%s%s] ",
1055 scb_command & (SCB_CMD_ACK_CX | SCB_CMD_ACK_FR |
1056 SCB_CMD_ACK_CNA | SCB_CMD_ACK_RNR)) >> 12,
1058 scb_command & SCB_CMD_ACK_CX) ? "ack cmd completion," : "",
1060 scb_command & SCB_CMD_ACK_FR) ? "ack frame received," : "",
1062 scb_command & SCB_CMD_ACK_CNA) ? "ack CU not active," : "",
1064 scb_command & SCB_CMD_ACK_RNR) ? "ack RU not ready," : "");
1065 printk("cuc 0x%x[%s%s%s%s%s] ",
1066 (scb.scb_command & SCB_CMD_CUC) >> 8,
1067 ((scb.scb_command & SCB_CMD_CUC) ==
1068 SCB_CMD_CUC_NOP) ? "nop" : "",
1069 ((scb.scb_command & SCB_CMD_CUC) ==
1070 SCB_CMD_CUC_GO) ? "start cbl_offset" : "",
1071 ((scb.scb_command & SCB_CMD_CUC) ==
1072 SCB_CMD_CUC_RES) ? "resume execution" : "",
1073 ((scb.scb_command & SCB_CMD_CUC) ==
1074 SCB_CMD_CUC_SUS) ? "suspend execution" : "",
1075 ((scb.scb_command & SCB_CMD_CUC) ==
1076 SCB_CMD_CUC_ABT) ? "abort execution" : "");
1077 printk("ruc 0x%x[%s%s%s%s%s]\n",
1078 (scb.scb_command & SCB_CMD_RUC) >> 4,
1079 ((scb.scb_command & SCB_CMD_RUC) ==
1080 SCB_CMD_RUC_NOP) ? "nop" : "",
1081 ((scb.scb_command & SCB_CMD_RUC) ==
1082 SCB_CMD_RUC_GO) ? "start rfa_offset" : "",
1083 ((scb.scb_command & SCB_CMD_RUC) ==
1084 SCB_CMD_RUC_RES) ? "resume reception" : "",
1085 ((scb.scb_command & SCB_CMD_RUC) ==
1086 SCB_CMD_RUC_SUS) ? "suspend reception" : "",
1087 ((scb.scb_command & SCB_CMD_RUC) ==
1088 SCB_CMD_RUC_ABT) ? "abort reception" : "");
1090 printk(KERN_DEBUG "cbl_offset 0x%x ", scb.scb_cbl_offset);
1091 printk("rfa_offset 0x%x\n", scb.scb_rfa_offset);
1093 printk(KERN_DEBUG "crcerrs %d ", scb.scb_crcerrs);
1094 printk("alnerrs %d ", scb.scb_alnerrs);
1095 printk("rscerrs %d ", scb.scb_rscerrs);
1096 printk("ovrnerrs %d\n", scb.scb_ovrnerrs);
1099 /*------------------------------------------------------------------*/
1101 * Print the formatted status of the i82586's receive unit.
1103 static void wv_ru_show(struct net_device * dev)
1105 /* net_local *lp = (net_local *) dev->priv; */
1108 "##### WaveLAN i82586 receiver unit status: #####\n");
1109 printk(KERN_DEBUG "ru:");
1111 * Not implemented yet
1116 /*------------------------------------------------------------------*/
1118 * Display info about one control block of the i82586 memory.
1120 static void wv_cu_show_one(struct net_device * dev, net_local * lp, int i, u16 p)
1122 unsigned long ioaddr;
1125 ioaddr = dev->base_addr;
1127 printk("%d: 0x%x:", i, p);
1129 obram_read(ioaddr, p, (unsigned char *) &actx, sizeof(actx));
1130 printk(" status=0x%x,", actx.tx_h.ac_status);
1131 printk(" command=0x%x,", actx.tx_h.ac_command);
1137 obram_read(ioaddr, actx.tx_tbd_offset, (unsigned char *)&tbd, sizeof(tbd));
1138 printk(" tbd_status=0x%x,", tbd.tbd_status);
1145 /*------------------------------------------------------------------*/
1147 * Print status of the command unit of the i82586.
1149 static void wv_cu_show(struct net_device * dev)
1151 net_local *lp = (net_local *) dev->priv;
1156 "##### WaveLAN i82586 command unit status: #####\n");
1159 for (i = 0, p = lp->tx_first_in_use; i < NTXBLOCKS; i++) {
1160 wv_cu_show_one(dev, lp, i, p);
1163 if (p >= OFFSET_CU + NTXBLOCKS * TXBLOCKZ)
1164 p -= NTXBLOCKS * TXBLOCKZ;
1168 #endif /* DEBUG_I82586_SHOW */
1170 #ifdef DEBUG_DEVICE_SHOW
1171 /*------------------------------------------------------------------*/
1173 * Print the formatted status of the WaveLAN PCMCIA device driver.
1175 static void wv_dev_show(struct net_device * dev)
1177 printk(KERN_DEBUG "dev:");
1178 printk(" state=%lX,", dev->state);
1179 printk(" trans_start=%ld,", dev->trans_start);
1180 printk(" flags=0x%x,", dev->flags);
1184 /*------------------------------------------------------------------*/
1186 * Print the formatted status of the WaveLAN PCMCIA device driver's
1187 * private information.
1189 static void wv_local_show(struct net_device * dev)
1193 lp = (net_local *) dev->priv;
1195 printk(KERN_DEBUG "local:");
1196 printk(" tx_n_in_use=%d,", lp->tx_n_in_use);
1197 printk(" hacr=0x%x,", lp->hacr);
1198 printk(" rx_head=0x%x,", lp->rx_head);
1199 printk(" rx_last=0x%x,", lp->rx_last);
1200 printk(" tx_first_free=0x%x,", lp->tx_first_free);
1201 printk(" tx_first_in_use=0x%x,", lp->tx_first_in_use);
1203 } /* wv_local_show */
1204 #endif /* DEBUG_DEVICE_SHOW */
1206 #if defined(DEBUG_RX_INFO) || defined(DEBUG_TX_INFO)
1207 /*------------------------------------------------------------------*/
1209 * Dump packet header (and content if necessary) on the screen
1211 static inline void wv_packet_info(u8 * p, /* Packet to dump */
1212 int length, /* Length of the packet */
1213 char *msg1, /* Name of the device */
1215 { /* Name of the function */
1220 "%s: %s(): dest %pM, length %d\n",
1221 msg1, msg2, p, length);
1223 "%s: %s(): src %pM, type 0x%02X%02X\n",
1224 msg1, msg2, &p[6], p[12], p[13]);
1226 #ifdef DEBUG_PACKET_DUMP
1228 printk(KERN_DEBUG "data=\"");
1230 if ((maxi = length) > DEBUG_PACKET_DUMP)
1231 maxi = DEBUG_PACKET_DUMP;
1232 for (i = 14; i < maxi; i++)
1233 if (p[i] >= ' ' && p[i] <= '~')
1234 printk(" %c", p[i]);
1236 printk("%02X", p[i]);
1240 printk(KERN_DEBUG "\n");
1241 #endif /* DEBUG_PACKET_DUMP */
1243 #endif /* defined(DEBUG_RX_INFO) || defined(DEBUG_TX_INFO) */
1245 /*------------------------------------------------------------------*/
1247 * This is the information which is displayed by the driver at startup.
1248 * There are lots of flags for configuring it to your liking.
1250 static void wv_init_info(struct net_device * dev)
1252 short ioaddr = dev->base_addr;
1253 net_local *lp = (net_local *) dev->priv;
1256 /* Read the parameter storage area */
1257 psa_read(ioaddr, lp->hacr, 0, (unsigned char *) &psa, sizeof(psa));
1259 #ifdef DEBUG_PSA_SHOW
1262 #ifdef DEBUG_MMC_SHOW
1265 #ifdef DEBUG_I82586_SHOW
1269 #ifdef DEBUG_BASIC_SHOW
1270 /* Now, let's go for the basic stuff. */
1271 printk(KERN_NOTICE "%s: WaveLAN at %#x, %pM, IRQ %d",
1272 dev->name, ioaddr, dev->dev_addr, dev->irq);
1274 /* Print current network ID. */
1275 if (psa.psa_nwid_select)
1276 printk(", nwid 0x%02X-%02X", psa.psa_nwid[0],
1279 printk(", nwid off");
1282 if (!(mmc_in(ioaddr, mmroff(0, mmr_fee_status)) &
1283 (MMR_FEE_STATUS_DWLD | MMR_FEE_STATUS_BUSY))) {
1284 unsigned short freq;
1286 /* Ask the EEPROM to read the frequency from the first area. */
1287 fee_read(ioaddr, 0x00, &freq, 1);
1289 /* Print frequency */
1290 printk(", 2.00, %ld", (freq >> 6) + 2400L);
1297 switch (psa.psa_comp_number) {
1298 case PSA_COMP_PC_AT_915:
1299 case PSA_COMP_PC_AT_2400:
1302 case PSA_COMP_PC_MC_915:
1303 case PSA_COMP_PC_MC_2400:
1306 case PSA_COMP_PCMCIA_915:
1313 switch (psa.psa_subband) {
1314 case PSA_SUBBAND_915:
1317 case PSA_SUBBAND_2425:
1320 case PSA_SUBBAND_2460:
1323 case PSA_SUBBAND_2484:
1326 case PSA_SUBBAND_2430_5:
1335 #endif /* DEBUG_BASIC_SHOW */
1337 #ifdef DEBUG_VERSION_SHOW
1338 /* Print version information */
1339 printk(KERN_NOTICE "%s", version);
1341 } /* wv_init_info */
1343 /********************* IOCTL, STATS & RECONFIG *********************/
1345 * We found here routines that are called by Linux on different
1346 * occasions after the configuration and not for transmitting data
1347 * These may be called when the user use ifconfig, /proc/net/dev
1348 * or wireless extensions
1351 /*------------------------------------------------------------------*/
1353 * Get the current Ethernet statistics. This may be called with the
1354 * card open or closed.
1355 * Used when the user read /proc/net/dev
1357 static en_stats *wavelan_get_stats(struct net_device * dev)
1359 #ifdef DEBUG_IOCTL_TRACE
1360 printk(KERN_DEBUG "%s: <>wavelan_get_stats()\n", dev->name);
1363 return (&((net_local *) dev->priv)->stats);
1366 /*------------------------------------------------------------------*/
1368 * Set or clear the multicast filter for this adaptor.
1369 * num_addrs == -1 Promiscuous mode, receive all packets
1370 * num_addrs == 0 Normal mode, clear multicast list
1371 * num_addrs > 0 Multicast mode, receive normal and MC packets,
1372 * and do best-effort filtering.
1374 static void wavelan_set_multicast_list(struct net_device * dev)
1376 net_local *lp = (net_local *) dev->priv;
1378 #ifdef DEBUG_IOCTL_TRACE
1379 printk(KERN_DEBUG "%s: ->wavelan_set_multicast_list()\n",
1383 #ifdef DEBUG_IOCTL_INFO
1385 "%s: wavelan_set_multicast_list(): setting Rx mode %02X to %d addresses.\n",
1386 dev->name, dev->flags, dev->mc_count);
1389 /* Are we asking for promiscuous mode,
1390 * or all multicast addresses (we don't have that!)
1391 * or too many multicast addresses for the hardware filter? */
1392 if ((dev->flags & IFF_PROMISC) ||
1393 (dev->flags & IFF_ALLMULTI) ||
1394 (dev->mc_count > I82586_MAX_MULTICAST_ADDRESSES)) {
1396 * Enable promiscuous mode: receive all packets.
1398 if (!lp->promiscuous) {
1399 lp->promiscuous = 1;
1402 wv_82586_reconfig(dev);
1405 /* Are there multicast addresses to send? */
1406 if (dev->mc_list != (struct dev_mc_list *) NULL) {
1408 * Disable promiscuous mode, but receive all packets
1411 #ifdef MULTICAST_AVOID
1412 if (lp->promiscuous || (dev->mc_count != lp->mc_count))
1415 lp->promiscuous = 0;
1416 lp->mc_count = dev->mc_count;
1418 wv_82586_reconfig(dev);
1422 * Switch to normal mode: disable promiscuous mode and
1423 * clear the multicast list.
1425 if (lp->promiscuous || lp->mc_count == 0) {
1426 lp->promiscuous = 0;
1429 wv_82586_reconfig(dev);
1432 #ifdef DEBUG_IOCTL_TRACE
1433 printk(KERN_DEBUG "%s: <-wavelan_set_multicast_list()\n",
1438 /*------------------------------------------------------------------*/
1440 * This function doesn't exist.
1441 * (Note : it was a nice way to test the reconfigure stuff...)
1443 #ifdef SET_MAC_ADDRESS
1444 static int wavelan_set_mac_address(struct net_device * dev, void *addr)
1446 struct sockaddr *mac = addr;
1448 /* Copy the address. */
1449 memcpy(dev->dev_addr, mac->sa_data, WAVELAN_ADDR_SIZE);
1451 /* Reconfigure the beast. */
1452 wv_82586_reconfig(dev);
1456 #endif /* SET_MAC_ADDRESS */
1459 /*------------------------------------------------------------------*/
1461 * Frequency setting (for hardware capable of it)
1462 * It's a bit complicated and you don't really want to look into it.
1463 * (called in wavelan_ioctl)
1465 static int wv_set_frequency(unsigned long ioaddr, /* I/O port of the card */
1466 iw_freq * frequency)
1468 const int BAND_NUM = 10; /* Number of bands */
1469 long freq = 0L; /* offset to 2.4 GHz in .5 MHz */
1470 #ifdef DEBUG_IOCTL_INFO
1474 /* Setting by frequency */
1475 /* Theoretically, you may set any frequency between
1476 * the two limits with a 0.5 MHz precision. In practice,
1477 * I don't want you to have trouble with local regulations.
1479 if ((frequency->e == 1) &&
1480 (frequency->m >= (int) 2.412e8)
1481 && (frequency->m <= (int) 2.487e8)) {
1482 freq = ((frequency->m / 10000) - 24000L) / 5;
1485 /* Setting by channel (same as wfreqsel) */
1486 /* Warning: each channel is 22 MHz wide, so some of the channels
1487 * will interfere. */
1488 if ((frequency->e == 0) && (frequency->m < BAND_NUM)) {
1489 /* Get frequency offset. */
1490 freq = channel_bands[frequency->m] >> 1;
1493 /* Verify that the frequency is allowed. */
1495 u16 table[10]; /* Authorized frequency table */
1497 /* Read the frequency table. */
1498 fee_read(ioaddr, 0x71, table, 10);
1500 #ifdef DEBUG_IOCTL_INFO
1501 printk(KERN_DEBUG "Frequency table: ");
1502 for (i = 0; i < 10; i++) {
1503 printk(" %04X", table[i]);
1508 /* Look in the table to see whether the frequency is allowed. */
1509 if (!(table[9 - ((freq - 24) / 16)] &
1510 (1 << ((freq - 24) % 16)))) return -EINVAL; /* not allowed */
1514 /* if we get a usable frequency */
1516 unsigned short area[16];
1517 unsigned short dac[2];
1518 unsigned short area_verify[16];
1519 unsigned short dac_verify[2];
1520 /* Corresponding gain (in the power adjust value table)
1521 * See AT&T WaveLAN Data Manual, REF 407-024689/E, page 3-8
1522 * and WCIN062D.DOC, page 6.2.9. */
1523 unsigned short power_limit[] = { 40, 80, 120, 160, 0 };
1524 int power_band = 0; /* Selected band */
1525 unsigned short power_adjust; /* Correct value */
1527 /* Search for the gain. */
1529 while ((freq > power_limit[power_band]) &&
1530 (power_limit[++power_band] != 0));
1532 /* Read the first area. */
1533 fee_read(ioaddr, 0x00, area, 16);
1536 fee_read(ioaddr, 0x60, dac, 2);
1538 /* Read the new power adjust value. */
1539 fee_read(ioaddr, 0x6B - (power_band >> 1), &power_adjust,
1541 if (power_band & 0x1)
1544 power_adjust &= 0xFF;
1546 #ifdef DEBUG_IOCTL_INFO
1547 printk(KERN_DEBUG "WaveLAN EEPROM Area 1: ");
1548 for (i = 0; i < 16; i++) {
1549 printk(" %04X", area[i]);
1553 printk(KERN_DEBUG "WaveLAN EEPROM DAC: %04X %04X\n",
1557 /* Frequency offset (for info only) */
1558 area[0] = ((freq << 5) & 0xFFE0) | (area[0] & 0x1F);
1560 /* Receiver Principle main divider coefficient */
1561 area[3] = (freq >> 1) + 2400L - 352L;
1562 area[2] = ((freq & 0x1) << 4) | (area[2] & 0xFFEF);
1564 /* Transmitter Main divider coefficient */
1565 area[13] = (freq >> 1) + 2400L;
1566 area[12] = ((freq & 0x1) << 4) | (area[2] & 0xFFEF);
1568 /* Other parts of the area are flags, bit streams or unused. */
1570 /* Set the value in the DAC. */
1571 dac[1] = ((power_adjust >> 1) & 0x7F) | (dac[1] & 0xFF80);
1572 dac[0] = ((power_adjust & 0x1) << 4) | (dac[0] & 0xFFEF);
1574 /* Write the first area. */
1575 fee_write(ioaddr, 0x00, area, 16);
1577 /* Write the DAC. */
1578 fee_write(ioaddr, 0x60, dac, 2);
1580 /* We now should verify here that the writing of the EEPROM went OK. */
1582 /* Reread the first area. */
1583 fee_read(ioaddr, 0x00, area_verify, 16);
1585 /* Reread the DAC. */
1586 fee_read(ioaddr, 0x60, dac_verify, 2);
1589 if (memcmp(area, area_verify, 16 * 2) ||
1590 memcmp(dac, dac_verify, 2 * 2)) {
1591 #ifdef DEBUG_IOCTL_ERROR
1593 "WaveLAN: wv_set_frequency: unable to write new frequency to EEPROM(?).\n");
1598 /* We must download the frequency parameters to the
1599 * synthesizers (from the EEPROM - area 1)
1600 * Note: as the EEPROM is automatically decremented, we set the end
1602 mmc_out(ioaddr, mmwoff(0, mmw_fee_addr), 0x0F);
1603 mmc_out(ioaddr, mmwoff(0, mmw_fee_ctrl),
1604 MMW_FEE_CTRL_READ | MMW_FEE_CTRL_DWLD);
1606 /* Wait until the download is finished. */
1607 fee_wait(ioaddr, 100, 100);
1609 /* We must now download the power adjust value (gain) to
1610 * the synthesizers (from the EEPROM - area 7 - DAC). */
1611 mmc_out(ioaddr, mmwoff(0, mmw_fee_addr), 0x61);
1612 mmc_out(ioaddr, mmwoff(0, mmw_fee_ctrl),
1613 MMW_FEE_CTRL_READ | MMW_FEE_CTRL_DWLD);
1615 /* Wait for the download to finish. */
1616 fee_wait(ioaddr, 100, 100);
1618 #ifdef DEBUG_IOCTL_INFO
1619 /* Verification of what we have done */
1621 printk(KERN_DEBUG "WaveLAN EEPROM Area 1: ");
1622 for (i = 0; i < 16; i++) {
1623 printk(" %04X", area_verify[i]);
1627 printk(KERN_DEBUG "WaveLAN EEPROM DAC: %04X %04X\n",
1628 dac_verify[0], dac_verify[1]);
1633 return -EINVAL; /* Bah, never get there... */
1636 /*------------------------------------------------------------------*/
1638 * Give the list of available frequencies.
1640 static int wv_frequency_list(unsigned long ioaddr, /* I/O port of the card */
1641 iw_freq * list, /* List of frequencies to fill */
1643 { /* Maximum number of frequencies */
1644 u16 table[10]; /* Authorized frequency table */
1645 long freq = 0L; /* offset to 2.4 GHz in .5 MHz + 12 MHz */
1646 int i; /* index in the table */
1647 int c = 0; /* Channel number */
1649 /* Read the frequency table. */
1650 fee_read(ioaddr, 0x71 /* frequency table */ , table, 10);
1652 /* Check all frequencies. */
1654 for (freq = 0; freq < 150; freq++)
1655 /* Look in the table if the frequency is allowed */
1656 if (table[9 - (freq / 16)] & (1 << (freq % 16))) {
1657 /* Compute approximate channel number */
1658 while ((c < ARRAY_SIZE(channel_bands)) &&
1659 (((channel_bands[c] >> 1) - 24) < freq))
1661 list[i].i = c; /* Set the list index */
1663 /* put in the list */
1664 list[i].m = (((freq + 24) * 5) + 24000L) * 10000;
1675 #ifdef IW_WIRELESS_SPY
1676 /*------------------------------------------------------------------*/
1678 * Gather wireless spy statistics: for each packet, compare the source
1679 * address with our list, and if they match, get the statistics.
1680 * Sorry, but this function really needs the wireless extensions.
1682 static inline void wl_spy_gather(struct net_device * dev,
1683 u8 * mac, /* MAC address */
1684 u8 * stats) /* Statistics to gather */
1686 struct iw_quality wstats;
1688 wstats.qual = stats[2] & MMR_SGNL_QUAL;
1689 wstats.level = stats[0] & MMR_SIGNAL_LVL;
1690 wstats.noise = stats[1] & MMR_SILENCE_LVL;
1691 wstats.updated = 0x7;
1693 /* Update spy records */
1694 wireless_spy_update(dev, mac, &wstats);
1696 #endif /* IW_WIRELESS_SPY */
1699 /*------------------------------------------------------------------*/
1701 * This function calculates a histogram of the signal level.
1702 * As the noise is quite constant, it's like doing it on the SNR.
1703 * We have defined a set of interval (lp->his_range), and each time
1704 * the level goes in that interval, we increment the count (lp->his_sum).
1705 * With this histogram you may detect if one WaveLAN is really weak,
1706 * or you may also calculate the mean and standard deviation of the level.
1708 static inline void wl_his_gather(struct net_device * dev, u8 * stats)
1709 { /* Statistics to gather */
1710 net_local *lp = (net_local *) dev->priv;
1711 u8 level = stats[0] & MMR_SIGNAL_LVL;
1714 /* Find the correct interval. */
1716 while ((i < (lp->his_number - 1))
1717 && (level >= lp->his_range[i++]));
1719 /* Increment interval counter. */
1722 #endif /* HISTOGRAM */
1724 /*------------------------------------------------------------------*/
1726 * Wireless Handler : get protocol name
1728 static int wavelan_get_name(struct net_device *dev,
1729 struct iw_request_info *info,
1730 union iwreq_data *wrqu,
1733 strcpy(wrqu->name, "WaveLAN");
1737 /*------------------------------------------------------------------*/
1739 * Wireless Handler : set NWID
1741 static int wavelan_set_nwid(struct net_device *dev,
1742 struct iw_request_info *info,
1743 union iwreq_data *wrqu,
1746 unsigned long ioaddr = dev->base_addr;
1747 net_local *lp = (net_local *) dev->priv; /* lp is not unused */
1750 unsigned long flags;
1753 /* Disable interrupts and save flags. */
1754 spin_lock_irqsave(&lp->spinlock, flags);
1756 /* Set NWID in WaveLAN. */
1757 if (!wrqu->nwid.disabled) {
1758 /* Set NWID in psa */
1759 psa.psa_nwid[0] = (wrqu->nwid.value & 0xFF00) >> 8;
1760 psa.psa_nwid[1] = wrqu->nwid.value & 0xFF;
1761 psa.psa_nwid_select = 0x01;
1762 psa_write(ioaddr, lp->hacr,
1763 (char *) psa.psa_nwid - (char *) &psa,
1764 (unsigned char *) psa.psa_nwid, 3);
1766 /* Set NWID in mmc. */
1767 m.w.mmw_netw_id_l = psa.psa_nwid[1];
1768 m.w.mmw_netw_id_h = psa.psa_nwid[0];
1770 (char *) &m.w.mmw_netw_id_l -
1772 (unsigned char *) &m.w.mmw_netw_id_l, 2);
1773 mmc_out(ioaddr, mmwoff(0, mmw_loopt_sel), 0x00);
1775 /* Disable NWID in the psa. */
1776 psa.psa_nwid_select = 0x00;
1777 psa_write(ioaddr, lp->hacr,
1778 (char *) &psa.psa_nwid_select -
1780 (unsigned char *) &psa.psa_nwid_select,
1783 /* Disable NWID in the mmc (no filtering). */
1784 mmc_out(ioaddr, mmwoff(0, mmw_loopt_sel),
1785 MMW_LOOPT_SEL_DIS_NWID);
1787 /* update the Wavelan checksum */
1788 update_psa_checksum(dev, ioaddr, lp->hacr);
1790 /* Enable interrupts and restore flags. */
1791 spin_unlock_irqrestore(&lp->spinlock, flags);
1796 /*------------------------------------------------------------------*/
1798 * Wireless Handler : get NWID
1800 static int wavelan_get_nwid(struct net_device *dev,
1801 struct iw_request_info *info,
1802 union iwreq_data *wrqu,
1805 unsigned long ioaddr = dev->base_addr;
1806 net_local *lp = (net_local *) dev->priv; /* lp is not unused */
1808 unsigned long flags;
1811 /* Disable interrupts and save flags. */
1812 spin_lock_irqsave(&lp->spinlock, flags);
1814 /* Read the NWID. */
1815 psa_read(ioaddr, lp->hacr,
1816 (char *) psa.psa_nwid - (char *) &psa,
1817 (unsigned char *) psa.psa_nwid, 3);
1818 wrqu->nwid.value = (psa.psa_nwid[0] << 8) + psa.psa_nwid[1];
1819 wrqu->nwid.disabled = !(psa.psa_nwid_select);
1820 wrqu->nwid.fixed = 1; /* Superfluous */
1822 /* Enable interrupts and restore flags. */
1823 spin_unlock_irqrestore(&lp->spinlock, flags);
1828 /*------------------------------------------------------------------*/
1830 * Wireless Handler : set frequency
1832 static int wavelan_set_freq(struct net_device *dev,
1833 struct iw_request_info *info,
1834 union iwreq_data *wrqu,
1837 unsigned long ioaddr = dev->base_addr;
1838 net_local *lp = (net_local *) dev->priv; /* lp is not unused */
1839 unsigned long flags;
1842 /* Disable interrupts and save flags. */
1843 spin_lock_irqsave(&lp->spinlock, flags);
1845 /* Attempt to recognise 2.00 cards (2.4 GHz frequency selectable). */
1846 if (!(mmc_in(ioaddr, mmroff(0, mmr_fee_status)) &
1847 (MMR_FEE_STATUS_DWLD | MMR_FEE_STATUS_BUSY)))
1848 ret = wv_set_frequency(ioaddr, &(wrqu->freq));
1852 /* Enable interrupts and restore flags. */
1853 spin_unlock_irqrestore(&lp->spinlock, flags);
1858 /*------------------------------------------------------------------*/
1860 * Wireless Handler : get frequency
1862 static int wavelan_get_freq(struct net_device *dev,
1863 struct iw_request_info *info,
1864 union iwreq_data *wrqu,
1867 unsigned long ioaddr = dev->base_addr;
1868 net_local *lp = (net_local *) dev->priv; /* lp is not unused */
1870 unsigned long flags;
1873 /* Disable interrupts and save flags. */
1874 spin_lock_irqsave(&lp->spinlock, flags);
1876 /* Attempt to recognise 2.00 cards (2.4 GHz frequency selectable).
1877 * Does it work for everybody, especially old cards? */
1878 if (!(mmc_in(ioaddr, mmroff(0, mmr_fee_status)) &
1879 (MMR_FEE_STATUS_DWLD | MMR_FEE_STATUS_BUSY))) {
1880 unsigned short freq;
1882 /* Ask the EEPROM to read the frequency from the first area. */
1883 fee_read(ioaddr, 0x00, &freq, 1);
1884 wrqu->freq.m = ((freq >> 5) * 5 + 24000L) * 10000;
1887 psa_read(ioaddr, lp->hacr,
1888 (char *) &psa.psa_subband - (char *) &psa,
1889 (unsigned char *) &psa.psa_subband, 1);
1891 if (psa.psa_subband <= 4) {
1892 wrqu->freq.m = fixed_bands[psa.psa_subband];
1893 wrqu->freq.e = (psa.psa_subband != 0);
1898 /* Enable interrupts and restore flags. */
1899 spin_unlock_irqrestore(&lp->spinlock, flags);
1904 /*------------------------------------------------------------------*/
1906 * Wireless Handler : set level threshold
1908 static int wavelan_set_sens(struct net_device *dev,
1909 struct iw_request_info *info,
1910 union iwreq_data *wrqu,
1913 unsigned long ioaddr = dev->base_addr;
1914 net_local *lp = (net_local *) dev->priv; /* lp is not unused */
1916 unsigned long flags;
1919 /* Disable interrupts and save flags. */
1920 spin_lock_irqsave(&lp->spinlock, flags);
1922 /* Set the level threshold. */
1923 /* We should complain loudly if wrqu->sens.fixed = 0, because we
1924 * can't set auto mode... */
1925 psa.psa_thr_pre_set = wrqu->sens.value & 0x3F;
1926 psa_write(ioaddr, lp->hacr,
1927 (char *) &psa.psa_thr_pre_set - (char *) &psa,
1928 (unsigned char *) &psa.psa_thr_pre_set, 1);
1929 /* update the Wavelan checksum */
1930 update_psa_checksum(dev, ioaddr, lp->hacr);
1931 mmc_out(ioaddr, mmwoff(0, mmw_thr_pre_set),
1932 psa.psa_thr_pre_set);
1934 /* Enable interrupts and restore flags. */
1935 spin_unlock_irqrestore(&lp->spinlock, flags);
1940 /*------------------------------------------------------------------*/
1942 * Wireless Handler : get level threshold
1944 static int wavelan_get_sens(struct net_device *dev,
1945 struct iw_request_info *info,
1946 union iwreq_data *wrqu,
1949 unsigned long ioaddr = dev->base_addr;
1950 net_local *lp = (net_local *) dev->priv; /* lp is not unused */
1952 unsigned long flags;
1955 /* Disable interrupts and save flags. */
1956 spin_lock_irqsave(&lp->spinlock, flags);
1958 /* Read the level threshold. */
1959 psa_read(ioaddr, lp->hacr,
1960 (char *) &psa.psa_thr_pre_set - (char *) &psa,
1961 (unsigned char *) &psa.psa_thr_pre_set, 1);
1962 wrqu->sens.value = psa.psa_thr_pre_set & 0x3F;
1963 wrqu->sens.fixed = 1;
1965 /* Enable interrupts and restore flags. */
1966 spin_unlock_irqrestore(&lp->spinlock, flags);
1971 /*------------------------------------------------------------------*/
1973 * Wireless Handler : set encryption key
1975 static int wavelan_set_encode(struct net_device *dev,
1976 struct iw_request_info *info,
1977 union iwreq_data *wrqu,
1980 unsigned long ioaddr = dev->base_addr;
1981 net_local *lp = (net_local *) dev->priv; /* lp is not unused */
1982 unsigned long flags;
1986 /* Disable interrupts and save flags. */
1987 spin_lock_irqsave(&lp->spinlock, flags);
1989 /* Check if capable of encryption */
1990 if (!mmc_encr(ioaddr)) {
1994 /* Check the size of the key */
1995 if((wrqu->encoding.length != 8) && (wrqu->encoding.length != 0)) {
2000 /* Basic checking... */
2001 if (wrqu->encoding.length == 8) {
2002 /* Copy the key in the driver */
2003 memcpy(psa.psa_encryption_key, extra,
2004 wrqu->encoding.length);
2005 psa.psa_encryption_select = 1;
2007 psa_write(ioaddr, lp->hacr,
2008 (char *) &psa.psa_encryption_select -
2010 (unsigned char *) &psa.
2011 psa_encryption_select, 8 + 1);
2013 mmc_out(ioaddr, mmwoff(0, mmw_encr_enable),
2014 MMW_ENCR_ENABLE_EN | MMW_ENCR_ENABLE_MODE);
2015 mmc_write(ioaddr, mmwoff(0, mmw_encr_key),
2016 (unsigned char *) &psa.
2017 psa_encryption_key, 8);
2020 /* disable encryption */
2021 if (wrqu->encoding.flags & IW_ENCODE_DISABLED) {
2022 psa.psa_encryption_select = 0;
2023 psa_write(ioaddr, lp->hacr,
2024 (char *) &psa.psa_encryption_select -
2026 (unsigned char *) &psa.
2027 psa_encryption_select, 1);
2029 mmc_out(ioaddr, mmwoff(0, mmw_encr_enable), 0);
2031 /* update the Wavelan checksum */
2032 update_psa_checksum(dev, ioaddr, lp->hacr);
2035 /* Enable interrupts and restore flags. */
2036 spin_unlock_irqrestore(&lp->spinlock, flags);
2041 /*------------------------------------------------------------------*/
2043 * Wireless Handler : get encryption key
2045 static int wavelan_get_encode(struct net_device *dev,
2046 struct iw_request_info *info,
2047 union iwreq_data *wrqu,
2050 unsigned long ioaddr = dev->base_addr;
2051 net_local *lp = (net_local *) dev->priv; /* lp is not unused */
2053 unsigned long flags;
2056 /* Disable interrupts and save flags. */
2057 spin_lock_irqsave(&lp->spinlock, flags);
2059 /* Check if encryption is available */
2060 if (!mmc_encr(ioaddr)) {
2063 /* Read the encryption key */
2064 psa_read(ioaddr, lp->hacr,
2065 (char *) &psa.psa_encryption_select -
2067 (unsigned char *) &psa.
2068 psa_encryption_select, 1 + 8);
2070 /* encryption is enabled ? */
2071 if (psa.psa_encryption_select)
2072 wrqu->encoding.flags = IW_ENCODE_ENABLED;
2074 wrqu->encoding.flags = IW_ENCODE_DISABLED;
2075 wrqu->encoding.flags |= mmc_encr(ioaddr);
2077 /* Copy the key to the user buffer */
2078 wrqu->encoding.length = 8;
2079 memcpy(extra, psa.psa_encryption_key, wrqu->encoding.length);
2082 /* Enable interrupts and restore flags. */
2083 spin_unlock_irqrestore(&lp->spinlock, flags);
2088 /*------------------------------------------------------------------*/
2090 * Wireless Handler : get range info
2092 static int wavelan_get_range(struct net_device *dev,
2093 struct iw_request_info *info,
2094 union iwreq_data *wrqu,
2097 unsigned long ioaddr = dev->base_addr;
2098 net_local *lp = (net_local *) dev->priv; /* lp is not unused */
2099 struct iw_range *range = (struct iw_range *) extra;
2100 unsigned long flags;
2103 /* Set the length (very important for backward compatibility) */
2104 wrqu->data.length = sizeof(struct iw_range);
2106 /* Set all the info we don't care or don't know about to zero */
2107 memset(range, 0, sizeof(struct iw_range));
2109 /* Set the Wireless Extension versions */
2110 range->we_version_compiled = WIRELESS_EXT;
2111 range->we_version_source = 9;
2113 /* Set information in the range struct. */
2114 range->throughput = 1.6 * 1000 * 1000; /* don't argue on this ! */
2115 range->min_nwid = 0x0000;
2116 range->max_nwid = 0xFFFF;
2118 range->sensitivity = 0x3F;
2119 range->max_qual.qual = MMR_SGNL_QUAL;
2120 range->max_qual.level = MMR_SIGNAL_LVL;
2121 range->max_qual.noise = MMR_SILENCE_LVL;
2122 range->avg_qual.qual = MMR_SGNL_QUAL; /* Always max */
2123 /* Need to get better values for those two */
2124 range->avg_qual.level = 30;
2125 range->avg_qual.noise = 8;
2127 range->num_bitrates = 1;
2128 range->bitrate[0] = 2000000; /* 2 Mb/s */
2130 /* Event capability (kernel + driver) */
2131 range->event_capa[0] = (IW_EVENT_CAPA_MASK(0x8B02) |
2132 IW_EVENT_CAPA_MASK(0x8B04));
2133 range->event_capa[1] = IW_EVENT_CAPA_K_1;
2135 /* Disable interrupts and save flags. */
2136 spin_lock_irqsave(&lp->spinlock, flags);
2138 /* Attempt to recognise 2.00 cards (2.4 GHz frequency selectable). */
2139 if (!(mmc_in(ioaddr, mmroff(0, mmr_fee_status)) &
2140 (MMR_FEE_STATUS_DWLD | MMR_FEE_STATUS_BUSY))) {
2141 range->num_channels = 10;
2142 range->num_frequency = wv_frequency_list(ioaddr, range->freq,
2143 IW_MAX_FREQUENCIES);
2145 range->num_channels = range->num_frequency = 0;
2147 /* Encryption supported ? */
2148 if (mmc_encr(ioaddr)) {
2149 range->encoding_size[0] = 8; /* DES = 64 bits key */
2150 range->num_encoding_sizes = 1;
2151 range->max_encoding_tokens = 1; /* Only one key possible */
2153 range->num_encoding_sizes = 0;
2154 range->max_encoding_tokens = 0;
2157 /* Enable interrupts and restore flags. */
2158 spin_unlock_irqrestore(&lp->spinlock, flags);
2163 /*------------------------------------------------------------------*/
2165 * Wireless Private Handler : set quality threshold
2167 static int wavelan_set_qthr(struct net_device *dev,
2168 struct iw_request_info *info,
2169 union iwreq_data *wrqu,
2172 unsigned long ioaddr = dev->base_addr;
2173 net_local *lp = (net_local *) dev->priv; /* lp is not unused */
2175 unsigned long flags;
2177 /* Disable interrupts and save flags. */
2178 spin_lock_irqsave(&lp->spinlock, flags);
2180 psa.psa_quality_thr = *(extra) & 0x0F;
2181 psa_write(ioaddr, lp->hacr,
2182 (char *) &psa.psa_quality_thr - (char *) &psa,
2183 (unsigned char *) &psa.psa_quality_thr, 1);
2184 /* update the Wavelan checksum */
2185 update_psa_checksum(dev, ioaddr, lp->hacr);
2186 mmc_out(ioaddr, mmwoff(0, mmw_quality_thr),
2187 psa.psa_quality_thr);
2189 /* Enable interrupts and restore flags. */
2190 spin_unlock_irqrestore(&lp->spinlock, flags);
2195 /*------------------------------------------------------------------*/
2197 * Wireless Private Handler : get quality threshold
2199 static int wavelan_get_qthr(struct net_device *dev,
2200 struct iw_request_info *info,
2201 union iwreq_data *wrqu,
2204 unsigned long ioaddr = dev->base_addr;
2205 net_local *lp = (net_local *) dev->priv; /* lp is not unused */
2207 unsigned long flags;
2209 /* Disable interrupts and save flags. */
2210 spin_lock_irqsave(&lp->spinlock, flags);
2212 psa_read(ioaddr, lp->hacr,
2213 (char *) &psa.psa_quality_thr - (char *) &psa,
2214 (unsigned char *) &psa.psa_quality_thr, 1);
2215 *(extra) = psa.psa_quality_thr & 0x0F;
2217 /* Enable interrupts and restore flags. */
2218 spin_unlock_irqrestore(&lp->spinlock, flags);
2224 /*------------------------------------------------------------------*/
2226 * Wireless Private Handler : set histogram
2228 static int wavelan_set_histo(struct net_device *dev,
2229 struct iw_request_info *info,
2230 union iwreq_data *wrqu,
2233 net_local *lp = (net_local *) dev->priv; /* lp is not unused */
2235 /* Check the number of intervals. */
2236 if (wrqu->data.length > 16) {
2240 /* Disable histo while we copy the addresses.
2241 * As we don't disable interrupts, we need to do this */
2244 /* Are there ranges to copy? */
2245 if (wrqu->data.length > 0) {
2246 /* Copy interval ranges to the driver */
2247 memcpy(lp->his_range, extra, wrqu->data.length);
2251 printk(KERN_DEBUG "Histo :");
2252 for(i = 0; i < wrqu->data.length; i++)
2253 printk(" %d", lp->his_range[i]);
2257 /* Reset result structure. */
2258 memset(lp->his_sum, 0x00, sizeof(long) * 16);
2261 /* Now we can set the number of ranges */
2262 lp->his_number = wrqu->data.length;
2267 /*------------------------------------------------------------------*/
2269 * Wireless Private Handler : get histogram
2271 static int wavelan_get_histo(struct net_device *dev,
2272 struct iw_request_info *info,
2273 union iwreq_data *wrqu,
2276 net_local *lp = (net_local *) dev->priv; /* lp is not unused */
2278 /* Set the number of intervals. */
2279 wrqu->data.length = lp->his_number;
2281 /* Give back the distribution statistics */
2282 if(lp->his_number > 0)
2283 memcpy(extra, lp->his_sum, sizeof(long) * lp->his_number);
2287 #endif /* HISTOGRAM */
2289 /*------------------------------------------------------------------*/
2291 * Structures to export the Wireless Handlers
2294 static const iw_handler wavelan_handler[] =
2296 NULL, /* SIOCSIWNAME */
2297 wavelan_get_name, /* SIOCGIWNAME */
2298 wavelan_set_nwid, /* SIOCSIWNWID */
2299 wavelan_get_nwid, /* SIOCGIWNWID */
2300 wavelan_set_freq, /* SIOCSIWFREQ */
2301 wavelan_get_freq, /* SIOCGIWFREQ */
2302 NULL, /* SIOCSIWMODE */
2303 NULL, /* SIOCGIWMODE */
2304 wavelan_set_sens, /* SIOCSIWSENS */
2305 wavelan_get_sens, /* SIOCGIWSENS */
2306 NULL, /* SIOCSIWRANGE */
2307 wavelan_get_range, /* SIOCGIWRANGE */
2308 NULL, /* SIOCSIWPRIV */
2309 NULL, /* SIOCGIWPRIV */
2310 NULL, /* SIOCSIWSTATS */
2311 NULL, /* SIOCGIWSTATS */
2312 iw_handler_set_spy, /* SIOCSIWSPY */
2313 iw_handler_get_spy, /* SIOCGIWSPY */
2314 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
2315 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
2316 NULL, /* SIOCSIWAP */
2317 NULL, /* SIOCGIWAP */
2318 NULL, /* -- hole -- */
2319 NULL, /* SIOCGIWAPLIST */
2320 NULL, /* -- hole -- */
2321 NULL, /* -- hole -- */
2322 NULL, /* SIOCSIWESSID */
2323 NULL, /* SIOCGIWESSID */
2324 NULL, /* SIOCSIWNICKN */
2325 NULL, /* SIOCGIWNICKN */
2326 NULL, /* -- hole -- */
2327 NULL, /* -- hole -- */
2328 NULL, /* SIOCSIWRATE */
2329 NULL, /* SIOCGIWRATE */
2330 NULL, /* SIOCSIWRTS */
2331 NULL, /* SIOCGIWRTS */
2332 NULL, /* SIOCSIWFRAG */
2333 NULL, /* SIOCGIWFRAG */
2334 NULL, /* SIOCSIWTXPOW */
2335 NULL, /* SIOCGIWTXPOW */
2336 NULL, /* SIOCSIWRETRY */
2337 NULL, /* SIOCGIWRETRY */
2338 /* Bummer ! Why those are only at the end ??? */
2339 wavelan_set_encode, /* SIOCSIWENCODE */
2340 wavelan_get_encode, /* SIOCGIWENCODE */
2343 static const iw_handler wavelan_private_handler[] =
2345 wavelan_set_qthr, /* SIOCIWFIRSTPRIV */
2346 wavelan_get_qthr, /* SIOCIWFIRSTPRIV + 1 */
2348 wavelan_set_histo, /* SIOCIWFIRSTPRIV + 2 */
2349 wavelan_get_histo, /* SIOCIWFIRSTPRIV + 3 */
2350 #endif /* HISTOGRAM */
2353 static const struct iw_priv_args wavelan_private_args[] = {
2354 /*{ cmd, set_args, get_args, name } */
2355 { SIOCSIPQTHR, IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1, 0, "setqualthr" },
2356 { SIOCGIPQTHR, 0, IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1, "getqualthr" },
2357 { SIOCSIPHISTO, IW_PRIV_TYPE_BYTE | 16, 0, "sethisto" },
2358 { SIOCGIPHISTO, 0, IW_PRIV_TYPE_INT | 16, "gethisto" },
2361 static const struct iw_handler_def wavelan_handler_def =
2363 .num_standard = ARRAY_SIZE(wavelan_handler),
2364 .num_private = ARRAY_SIZE(wavelan_private_handler),
2365 .num_private_args = ARRAY_SIZE(wavelan_private_args),
2366 .standard = wavelan_handler,
2367 .private = wavelan_private_handler,
2368 .private_args = wavelan_private_args,
2369 .get_wireless_stats = wavelan_get_wireless_stats,
2372 /*------------------------------------------------------------------*/
2374 * Get wireless statistics.
2375 * Called by /proc/net/wireless
2377 static iw_stats *wavelan_get_wireless_stats(struct net_device * dev)
2379 unsigned long ioaddr = dev->base_addr;
2380 net_local *lp = (net_local *) dev->priv;
2383 unsigned long flags;
2385 #ifdef DEBUG_IOCTL_TRACE
2386 printk(KERN_DEBUG "%s: ->wavelan_get_wireless_stats()\n",
2391 if (lp == (net_local *) NULL)
2392 return (iw_stats *) NULL;
2394 /* Disable interrupts and save flags. */
2395 spin_lock_irqsave(&lp->spinlock, flags);
2397 wstats = &lp->wstats;
2399 /* Get data from the mmc. */
2400 mmc_out(ioaddr, mmwoff(0, mmw_freeze), 1);
2402 mmc_read(ioaddr, mmroff(0, mmr_dce_status), &m.mmr_dce_status, 1);
2403 mmc_read(ioaddr, mmroff(0, mmr_wrong_nwid_l), &m.mmr_wrong_nwid_l,
2405 mmc_read(ioaddr, mmroff(0, mmr_thr_pre_set), &m.mmr_thr_pre_set,
2408 mmc_out(ioaddr, mmwoff(0, mmw_freeze), 0);
2410 /* Copy data to wireless stuff. */
2411 wstats->status = m.mmr_dce_status & MMR_DCE_STATUS;
2412 wstats->qual.qual = m.mmr_sgnl_qual & MMR_SGNL_QUAL;
2413 wstats->qual.level = m.mmr_signal_lvl & MMR_SIGNAL_LVL;
2414 wstats->qual.noise = m.mmr_silence_lvl & MMR_SILENCE_LVL;
2415 wstats->qual.updated = (((m. mmr_signal_lvl & MMR_SIGNAL_LVL_VALID) >> 7)
2416 | ((m.mmr_signal_lvl & MMR_SIGNAL_LVL_VALID) >> 6)
2417 | ((m.mmr_silence_lvl & MMR_SILENCE_LVL_VALID) >> 5));
2418 wstats->discard.nwid += (m.mmr_wrong_nwid_h << 8) | m.mmr_wrong_nwid_l;
2419 wstats->discard.code = 0L;
2420 wstats->discard.misc = 0L;
2422 /* Enable interrupts and restore flags. */
2423 spin_unlock_irqrestore(&lp->spinlock, flags);
2425 #ifdef DEBUG_IOCTL_TRACE
2426 printk(KERN_DEBUG "%s: <-wavelan_get_wireless_stats()\n",
2432 /************************* PACKET RECEPTION *************************/
2434 * This part deals with receiving the packets.
2435 * The interrupt handler gets an interrupt when a packet has been
2436 * successfully received and calls this part.
2439 /*------------------------------------------------------------------*/
2441 * This routine does the actual copying of data (including the Ethernet
2442 * header structure) from the WaveLAN card to an sk_buff chain that
2443 * will be passed up to the network interface layer. NOTE: we
2444 * currently don't handle trailer protocols (neither does the rest of
2445 * the network interface), so if that is needed, it will (at least in
2446 * part) be added here. The contents of the receive ring buffer are
2447 * copied to a message chain that is then passed to the kernel.
2449 * Note: if any errors occur, the packet is "dropped on the floor".
2450 * (called by wv_packet_rcv())
2453 wv_packet_read(struct net_device * dev, u16 buf_off, int sksize)
2455 net_local *lp = (net_local *) dev->priv;
2456 unsigned long ioaddr = dev->base_addr;
2457 struct sk_buff *skb;
2459 #ifdef DEBUG_RX_TRACE
2460 printk(KERN_DEBUG "%s: ->wv_packet_read(0x%X, %d)\n",
2461 dev->name, buf_off, sksize);
2464 /* Allocate buffer for the data */
2465 if ((skb = dev_alloc_skb(sksize)) == (struct sk_buff *) NULL) {
2466 #ifdef DEBUG_RX_ERROR
2468 "%s: wv_packet_read(): could not alloc_skb(%d, GFP_ATOMIC).\n",
2471 lp->stats.rx_dropped++;
2475 /* Copy the packet to the buffer. */
2476 obram_read(ioaddr, buf_off, skb_put(skb, sksize), sksize);
2477 skb->protocol = eth_type_trans(skb, dev);
2479 #ifdef DEBUG_RX_INFO
2480 wv_packet_info(skb_mac_header(skb), sksize, dev->name,
2482 #endif /* DEBUG_RX_INFO */
2484 /* Statistics-gathering and associated stuff.
2485 * It seem a bit messy with all the define, but it's really
2488 #ifdef IW_WIRELESS_SPY /* defined in iw_handler.h */
2489 (lp->spy_data.spy_number > 0) ||
2490 #endif /* IW_WIRELESS_SPY */
2492 (lp->his_number > 0) ||
2493 #endif /* HISTOGRAM */
2495 u8 stats[3]; /* signal level, noise level, signal quality */
2497 /* Read signal level, silence level and signal quality bytes */
2498 /* Note: in the PCMCIA hardware, these are part of the frame.
2499 * It seems that for the ISA hardware, it's nowhere to be
2500 * found in the frame, so I'm obliged to do this (it has a
2501 * side effect on /proc/net/wireless).
2504 mmc_out(ioaddr, mmwoff(0, mmw_freeze), 1);
2505 mmc_read(ioaddr, mmroff(0, mmr_signal_lvl), stats, 3);
2506 mmc_out(ioaddr, mmwoff(0, mmw_freeze), 0);
2508 #ifdef DEBUG_RX_INFO
2510 "%s: wv_packet_read(): Signal level %d/63, Silence level %d/63, signal quality %d/16\n",
2511 dev->name, stats[0] & 0x3F, stats[1] & 0x3F,
2516 #ifdef IW_WIRELESS_SPY
2517 wl_spy_gather(dev, skb_mac_header(skb) + WAVELAN_ADDR_SIZE,
2519 #endif /* IW_WIRELESS_SPY */
2521 wl_his_gather(dev, stats);
2522 #endif /* HISTOGRAM */
2526 * Hand the packet to the network module.
2530 /* Keep statistics up to date */
2531 dev->last_rx = jiffies;
2532 lp->stats.rx_packets++;
2533 lp->stats.rx_bytes += sksize;
2535 #ifdef DEBUG_RX_TRACE
2536 printk(KERN_DEBUG "%s: <-wv_packet_read()\n", dev->name);
2540 /*------------------------------------------------------------------*/
2542 * Transfer as many packets as we can
2543 * from the device RAM.
2544 * (called in wavelan_interrupt()).
2545 * Note : the spinlock is already grabbed for us.
2547 static void wv_receive(struct net_device * dev)
2549 unsigned long ioaddr = dev->base_addr;
2550 net_local *lp = (net_local *) dev->priv;
2555 #ifdef DEBUG_RX_TRACE
2556 printk(KERN_DEBUG "%s: ->wv_receive()\n", dev->name);
2559 /* Loop on each received packet. */
2561 obram_read(ioaddr, lp->rx_head, (unsigned char *) &fd,
2564 /* Note about the status :
2565 * It start up to be 0 (the value we set). Then, when the RU
2566 * grab the buffer to prepare for reception, it sets the
2567 * FD_STATUS_B flag. When the RU has finished receiving the
2568 * frame, it clears FD_STATUS_B, set FD_STATUS_C to indicate
2569 * completion and set the other flags to indicate the eventual
2570 * errors. FD_STATUS_OK indicates that the reception was OK.
2573 /* If the current frame is not complete, we have reached the end. */
2574 if ((fd.fd_status & FD_STATUS_C) != FD_STATUS_C)
2575 break; /* This is how we exit the loop. */
2579 /* Check whether frame was correctly received. */
2580 if ((fd.fd_status & FD_STATUS_OK) == FD_STATUS_OK) {
2581 /* Does the frame contain a pointer to the data? Let's check. */
2582 if (fd.fd_rbd_offset != I82586NULL) {
2583 /* Read the receive buffer descriptor */
2584 obram_read(ioaddr, fd.fd_rbd_offset,
2585 (unsigned char *) &rbd,
2588 #ifdef DEBUG_RX_ERROR
2589 if ((rbd.rbd_status & RBD_STATUS_EOF) !=
2590 RBD_STATUS_EOF) printk(KERN_INFO
2591 "%s: wv_receive(): missing EOF flag.\n",
2594 if ((rbd.rbd_status & RBD_STATUS_F) !=
2595 RBD_STATUS_F) printk(KERN_INFO
2596 "%s: wv_receive(): missing F flag.\n",
2598 #endif /* DEBUG_RX_ERROR */
2600 /* Read the packet and transmit to Linux */
2601 wv_packet_read(dev, rbd.rbd_bufl,
2606 #ifdef DEBUG_RX_ERROR
2607 else /* if frame has no data */
2609 "%s: wv_receive(): frame has no data.\n",
2612 } else { /* If reception was no successful */
2614 lp->stats.rx_errors++;
2616 #ifdef DEBUG_RX_INFO
2618 "%s: wv_receive(): frame not received successfully (%X).\n",
2619 dev->name, fd.fd_status);
2622 #ifdef DEBUG_RX_ERROR
2623 if ((fd.fd_status & FD_STATUS_S6) != 0)
2625 "%s: wv_receive(): no EOF flag.\n",
2629 if ((fd.fd_status & FD_STATUS_S7) != 0) {
2630 lp->stats.rx_length_errors++;
2631 #ifdef DEBUG_RX_FAIL
2633 "%s: wv_receive(): frame too short.\n",
2638 if ((fd.fd_status & FD_STATUS_S8) != 0) {
2639 lp->stats.rx_over_errors++;
2640 #ifdef DEBUG_RX_FAIL
2642 "%s: wv_receive(): rx DMA overrun.\n",
2647 if ((fd.fd_status & FD_STATUS_S9) != 0) {
2648 lp->stats.rx_fifo_errors++;
2649 #ifdef DEBUG_RX_FAIL
2651 "%s: wv_receive(): ran out of resources.\n",
2656 if ((fd.fd_status & FD_STATUS_S10) != 0) {
2657 lp->stats.rx_frame_errors++;
2658 #ifdef DEBUG_RX_FAIL
2660 "%s: wv_receive(): alignment error.\n",
2665 if ((fd.fd_status & FD_STATUS_S11) != 0) {
2666 lp->stats.rx_crc_errors++;
2667 #ifdef DEBUG_RX_FAIL
2669 "%s: wv_receive(): CRC error.\n",
2676 obram_write(ioaddr, fdoff(lp->rx_head, fd_status),
2677 (unsigned char *) &fd.fd_status,
2678 sizeof(fd.fd_status));
2680 fd.fd_command = FD_COMMAND_EL;
2681 obram_write(ioaddr, fdoff(lp->rx_head, fd_command),
2682 (unsigned char *) &fd.fd_command,
2683 sizeof(fd.fd_command));
2686 obram_write(ioaddr, fdoff(lp->rx_last, fd_command),
2687 (unsigned char *) &fd.fd_command,
2688 sizeof(fd.fd_command));
2690 lp->rx_last = lp->rx_head;
2691 lp->rx_head = fd.fd_link_offset;
2692 } /* for(;;) -> loop on all frames */
2694 #ifdef DEBUG_RX_INFO
2696 printk(KERN_DEBUG "%s: wv_receive(): reaped %d\n",
2697 dev->name, nreaped);
2699 #ifdef DEBUG_RX_TRACE
2700 printk(KERN_DEBUG "%s: <-wv_receive()\n", dev->name);
2704 /*********************** PACKET TRANSMISSION ***********************/
2706 * This part deals with sending packets through the WaveLAN.
2710 /*------------------------------------------------------------------*/
2712 * This routine fills in the appropriate registers and memory
2713 * locations on the WaveLAN card and starts the card off on
2717 * Each block contains a transmit command, a NOP command,
2718 * a transmit block descriptor and a buffer.
2719 * The CU read the transmit block which point to the tbd,
2720 * read the tbd and the content of the buffer.
2721 * When it has finish with it, it goes to the next command
2722 * which in our case is the NOP. The NOP points on itself,
2723 * so the CU stop here.
2724 * When we add the next block, we modify the previous nop
2725 * to make it point on the new tx command.
2726 * Simple, isn't it ?
2728 * (called in wavelan_packet_xmit())
2730 static int wv_packet_write(struct net_device * dev, void *buf, short length)
2732 net_local *lp = (net_local *) dev->priv;
2733 unsigned long ioaddr = dev->base_addr;
2734 unsigned short txblock;
2735 unsigned short txpred;
2736 unsigned short tx_addr;
2737 unsigned short nop_addr;
2738 unsigned short tbd_addr;
2739 unsigned short buf_addr;
2744 unsigned long flags;
2746 #ifdef DEBUG_TX_TRACE
2747 printk(KERN_DEBUG "%s: ->wv_packet_write(%d)\n", dev->name,
2751 spin_lock_irqsave(&lp->spinlock, flags);
2753 /* Check nothing bad has happened */
2754 if (lp->tx_n_in_use == (NTXBLOCKS - 1)) {
2755 #ifdef DEBUG_TX_ERROR
2756 printk(KERN_INFO "%s: wv_packet_write(): Tx queue full.\n",
2759 spin_unlock_irqrestore(&lp->spinlock, flags);
2763 /* Calculate addresses of next block and previous block. */
2764 txblock = lp->tx_first_free;
2765 txpred = txblock - TXBLOCKZ;
2766 if (txpred < OFFSET_CU)
2767 txpred += NTXBLOCKS * TXBLOCKZ;
2768 lp->tx_first_free += TXBLOCKZ;
2769 if (lp->tx_first_free >= OFFSET_CU + NTXBLOCKS * TXBLOCKZ)
2770 lp->tx_first_free -= NTXBLOCKS * TXBLOCKZ;
2774 /* Calculate addresses of the different parts of the block. */
2776 nop_addr = tx_addr + sizeof(tx);
2777 tbd_addr = nop_addr + sizeof(nop);
2778 buf_addr = tbd_addr + sizeof(tbd);
2783 tx.tx_h.ac_status = 0;
2784 obram_write(ioaddr, toff(ac_tx_t, tx_addr, tx_h.ac_status),
2785 (unsigned char *) &tx.tx_h.ac_status,
2786 sizeof(tx.tx_h.ac_status));
2791 nop.nop_h.ac_status = 0;
2792 obram_write(ioaddr, toff(ac_nop_t, nop_addr, nop_h.ac_status),
2793 (unsigned char *) &nop.nop_h.ac_status,
2794 sizeof(nop.nop_h.ac_status));
2795 nop.nop_h.ac_link = nop_addr;
2796 obram_write(ioaddr, toff(ac_nop_t, nop_addr, nop_h.ac_link),
2797 (unsigned char *) &nop.nop_h.ac_link,
2798 sizeof(nop.nop_h.ac_link));
2801 * Transmit buffer descriptor
2803 tbd.tbd_status = TBD_STATUS_EOF | (TBD_STATUS_ACNT & clen);
2804 tbd.tbd_next_bd_offset = I82586NULL;
2805 tbd.tbd_bufl = buf_addr;
2807 obram_write(ioaddr, tbd_addr, (unsigned char *) &tbd, sizeof(tbd));
2812 obram_write(ioaddr, buf_addr, buf, length);
2815 * Overwrite the predecessor NOP link
2816 * so that it points to this txblock.
2818 nop_addr = txpred + sizeof(tx);
2819 nop.nop_h.ac_status = 0;
2820 obram_write(ioaddr, toff(ac_nop_t, nop_addr, nop_h.ac_status),
2821 (unsigned char *) &nop.nop_h.ac_status,
2822 sizeof(nop.nop_h.ac_status));
2823 nop.nop_h.ac_link = txblock;
2824 obram_write(ioaddr, toff(ac_nop_t, nop_addr, nop_h.ac_link),
2825 (unsigned char *) &nop.nop_h.ac_link,
2826 sizeof(nop.nop_h.ac_link));
2828 /* Make sure the watchdog will keep quiet for a while */
2829 dev->trans_start = jiffies;
2831 /* Keep stats up to date. */
2832 lp->stats.tx_bytes += length;
2834 if (lp->tx_first_in_use == I82586NULL)
2835 lp->tx_first_in_use = txblock;
2837 if (lp->tx_n_in_use < NTXBLOCKS - 1)
2838 netif_wake_queue(dev);
2840 spin_unlock_irqrestore(&lp->spinlock, flags);
2842 #ifdef DEBUG_TX_INFO
2843 wv_packet_info((u8 *) buf, length, dev->name,
2845 #endif /* DEBUG_TX_INFO */
2847 #ifdef DEBUG_TX_TRACE
2848 printk(KERN_DEBUG "%s: <-wv_packet_write()\n", dev->name);
2854 /*------------------------------------------------------------------*/
2856 * This routine is called when we want to send a packet (NET3 callback)
2857 * In this routine, we check if the harware is ready to accept
2858 * the packet. We also prevent reentrance. Then we call the function
2859 * to send the packet.
2861 static int wavelan_packet_xmit(struct sk_buff *skb, struct net_device * dev)
2863 net_local *lp = (net_local *) dev->priv;
2864 unsigned long flags;
2865 char data[ETH_ZLEN];
2867 #ifdef DEBUG_TX_TRACE
2868 printk(KERN_DEBUG "%s: ->wavelan_packet_xmit(0x%X)\n", dev->name,
2873 * Block a timer-based transmit from overlapping.
2874 * In other words, prevent reentering this routine.
2876 netif_stop_queue(dev);
2878 /* If somebody has asked to reconfigure the controller,
2881 if (lp->reconfig_82586) {
2882 spin_lock_irqsave(&lp->spinlock, flags);
2883 wv_82586_config(dev);
2884 spin_unlock_irqrestore(&lp->spinlock, flags);
2885 /* Check that we can continue */
2886 if (lp->tx_n_in_use == (NTXBLOCKS - 1))
2889 #ifdef DEBUG_TX_ERROR
2891 printk(KERN_INFO "skb has next\n");
2894 /* Do we need some padding? */
2895 /* Note : on wireless the propagation time is in the order of 1us,
2896 * and we don't have the Ethernet specific requirement of beeing
2897 * able to detect collisions, therefore in theory we don't really
2898 * need to pad. Jean II */
2899 if (skb->len < ETH_ZLEN) {
2900 memset(data, 0, ETH_ZLEN);
2901 skb_copy_from_linear_data(skb, data, skb->len);
2902 /* Write packet on the card */
2903 if(wv_packet_write(dev, data, ETH_ZLEN))
2904 return 1; /* We failed */
2906 else if(wv_packet_write(dev, skb->data, skb->len))
2907 return 1; /* We failed */
2912 #ifdef DEBUG_TX_TRACE
2913 printk(KERN_DEBUG "%s: <-wavelan_packet_xmit()\n", dev->name);
2918 /*********************** HARDWARE CONFIGURATION ***********************/
2920 * This part does the real job of starting and configuring the hardware.
2923 /*--------------------------------------------------------------------*/
2925 * Routine to initialize the Modem Management Controller.
2926 * (called by wv_hw_reset())
2928 static int wv_mmc_init(struct net_device * dev)
2930 unsigned long ioaddr = dev->base_addr;
2931 net_local *lp = (net_local *) dev->priv;
2936 #ifdef DEBUG_CONFIG_TRACE
2937 printk(KERN_DEBUG "%s: ->wv_mmc_init()\n", dev->name);
2940 /* Read the parameter storage area. */
2941 psa_read(ioaddr, lp->hacr, 0, (unsigned char *) &psa, sizeof(psa));
2943 #ifdef USE_PSA_CONFIG
2944 configured = psa.psa_conf_status & 1;
2949 /* Is the PSA is not configured */
2951 /* User will be able to configure NWID later (with iwconfig). */
2952 psa.psa_nwid[0] = 0;
2953 psa.psa_nwid[1] = 0;
2955 /* no NWID checking since NWID is not set */
2956 psa.psa_nwid_select = 0;
2958 /* Disable encryption */
2959 psa.psa_encryption_select = 0;
2961 /* Set to standard values:
2964 * 0x04 for PCMCIA and 2.00 card (AT&T 407-024689/E document)
2966 if (psa.psa_comp_number & 1)
2967 psa.psa_thr_pre_set = 0x01;
2969 psa.psa_thr_pre_set = 0x04;
2970 psa.psa_quality_thr = 0x03;
2972 /* It is configured */
2973 psa.psa_conf_status |= 1;
2975 #ifdef USE_PSA_CONFIG
2976 /* Write the psa. */
2977 psa_write(ioaddr, lp->hacr,
2978 (char *) psa.psa_nwid - (char *) &psa,
2979 (unsigned char *) psa.psa_nwid, 4);
2980 psa_write(ioaddr, lp->hacr,
2981 (char *) &psa.psa_thr_pre_set - (char *) &psa,
2982 (unsigned char *) &psa.psa_thr_pre_set, 1);
2983 psa_write(ioaddr, lp->hacr,
2984 (char *) &psa.psa_quality_thr - (char *) &psa,
2985 (unsigned char *) &psa.psa_quality_thr, 1);
2986 psa_write(ioaddr, lp->hacr,
2987 (char *) &psa.psa_conf_status - (char *) &psa,
2988 (unsigned char *) &psa.psa_conf_status, 1);
2989 /* update the Wavelan checksum */
2990 update_psa_checksum(dev, ioaddr, lp->hacr);
2994 /* Zero the mmc structure. */
2995 memset(&m, 0x00, sizeof(m));
2997 /* Copy PSA info to the mmc. */
2998 m.mmw_netw_id_l = psa.psa_nwid[1];
2999 m.mmw_netw_id_h = psa.psa_nwid[0];
3001 if (psa.psa_nwid_select & 1)
3002 m.mmw_loopt_sel = 0x00;
3004 m.mmw_loopt_sel = MMW_LOOPT_SEL_DIS_NWID;
3006 memcpy(&m.mmw_encr_key, &psa.psa_encryption_key,
3007 sizeof(m.mmw_encr_key));
3009 if (psa.psa_encryption_select)
3011 MMW_ENCR_ENABLE_EN | MMW_ENCR_ENABLE_MODE;
3013 m.mmw_encr_enable = 0;
3015 m.mmw_thr_pre_set = psa.psa_thr_pre_set & 0x3F;
3016 m.mmw_quality_thr = psa.psa_quality_thr & 0x0F;
3019 * Set default modem control parameters.
3020 * See NCR document 407-0024326 Rev. A.
3022 m.mmw_jabber_enable = 0x01;
3024 m.mmw_anten_sel = MMW_ANTEN_SEL_ALG_EN;
3026 m.mmw_mod_delay = 0x04;
3027 m.mmw_jam_time = 0x38;
3029 m.mmw_des_io_invert = 0;
3030 m.mmw_decay_prm = 0;
3031 m.mmw_decay_updat_prm = 0;
3033 /* Write all info to MMC. */
3034 mmc_write(ioaddr, 0, (u8 *) & m, sizeof(m));
3036 /* The following code starts the modem of the 2.00 frequency
3037 * selectable cards at power on. It's not strictly needed for the
3039 * The original patch was by Joe Finney for the PCMCIA driver, but
3040 * I've cleaned it up a bit and added documentation.
3041 * Thanks to Loeke Brederveld from Lucent for the info.
3044 /* Attempt to recognise 2.00 cards (2.4 GHz frequency selectable)
3045 * Does it work for everybody, especially old cards? */
3046 /* Note: WFREQSEL verifies that it is able to read a sensible
3047 * frequency from EEPROM (address 0x00) and that MMR_FEE_STATUS_ID
3048 * is 0xA (Xilinx version) or 0xB (Ariadne version).
3049 * My test is more crude but does work. */
3050 if (!(mmc_in(ioaddr, mmroff(0, mmr_fee_status)) &
3051 (MMR_FEE_STATUS_DWLD | MMR_FEE_STATUS_BUSY))) {
3052 /* We must download the frequency parameters to the
3053 * synthesizers (from the EEPROM - area 1)
3054 * Note: as the EEPROM is automatically decremented, we set the end
3056 m.mmw_fee_addr = 0x0F;
3057 m.mmw_fee_ctrl = MMW_FEE_CTRL_READ | MMW_FEE_CTRL_DWLD;
3058 mmc_write(ioaddr, (char *) &m.mmw_fee_ctrl - (char *) &m,
3059 (unsigned char *) &m.mmw_fee_ctrl, 2);
3061 /* Wait until the download is finished. */
3062 fee_wait(ioaddr, 100, 100);
3064 #ifdef DEBUG_CONFIG_INFO
3065 /* The frequency was in the last word downloaded. */
3066 mmc_read(ioaddr, (char *) &m.mmw_fee_data_l - (char *) &m,
3067 (unsigned char *) &m.mmw_fee_data_l, 2);
3069 /* Print some info for the user. */
3071 "%s: WaveLAN 2.00 recognised (frequency select). Current frequency = %ld\n",
3074 mmw_fee_data_h << 4) | (m.mmw_fee_data_l >> 4)) *
3078 /* We must now download the power adjust value (gain) to
3079 * the synthesizers (from the EEPROM - area 7 - DAC). */
3080 m.mmw_fee_addr = 0x61;
3081 m.mmw_fee_ctrl = MMW_FEE_CTRL_READ | MMW_FEE_CTRL_DWLD;
3082 mmc_write(ioaddr, (char *) &m.mmw_fee_ctrl - (char *) &m,
3083 (unsigned char *) &m.mmw_fee_ctrl, 2);
3085 /* Wait until the download is finished. */
3088 #ifdef DEBUG_CONFIG_TRACE
3089 printk(KERN_DEBUG "%s: <-wv_mmc_init()\n", dev->name);
3094 /*------------------------------------------------------------------*/
3096 * Construct the fd and rbd structures.
3097 * Start the receive unit.
3098 * (called by wv_hw_reset())
3100 static int wv_ru_start(struct net_device * dev)
3102 net_local *lp = (net_local *) dev->priv;
3103 unsigned long ioaddr = dev->base_addr;
3111 #ifdef DEBUG_CONFIG_TRACE
3112 printk(KERN_DEBUG "%s: ->wv_ru_start()\n", dev->name);
3115 obram_read(ioaddr, scboff(OFFSET_SCB, scb_status),
3116 (unsigned char *) &scb_cs, sizeof(scb_cs));
3117 if ((scb_cs & SCB_ST_RUS) == SCB_ST_RUS_RDY)
3120 lp->rx_head = OFFSET_RU;
3122 for (i = 0, rx = lp->rx_head; i < NRXBLOCKS; i++, rx = rx_next) {
3124 (i == NRXBLOCKS - 1) ? lp->rx_head : rx + RXBLOCKZ;
3127 fd.fd_command = (i == NRXBLOCKS - 1) ? FD_COMMAND_EL : 0;
3128 fd.fd_link_offset = rx_next;
3129 fd.fd_rbd_offset = rx + sizeof(fd);
3130 obram_write(ioaddr, rx, (unsigned char *) &fd, sizeof(fd));
3133 rbd.rbd_next_rbd_offset = I82586NULL;
3134 rbd.rbd_bufl = rx + sizeof(fd) + sizeof(rbd);
3136 rbd.rbd_el_size = RBD_EL | (RBD_SIZE & MAXDATAZ);
3137 obram_write(ioaddr, rx + sizeof(fd),
3138 (unsigned char *) &rbd, sizeof(rbd));
3143 obram_write(ioaddr, scboff(OFFSET_SCB, scb_rfa_offset),
3144 (unsigned char *) &lp->rx_head, sizeof(lp->rx_head));
3146 scb_cs = SCB_CMD_RUC_GO;
3147 obram_write(ioaddr, scboff(OFFSET_SCB, scb_command),
3148 (unsigned char *) &scb_cs, sizeof(scb_cs));
3150 set_chan_attn(ioaddr, lp->hacr);
3152 for (i = 1000; i > 0; i--) {
3153 obram_read(ioaddr, scboff(OFFSET_SCB, scb_command),
3154 (unsigned char *) &scb_cs, sizeof(scb_cs));
3162 #ifdef DEBUG_CONFIG_ERROR
3164 "%s: wavelan_ru_start(): board not accepting command.\n",
3169 #ifdef DEBUG_CONFIG_TRACE
3170 printk(KERN_DEBUG "%s: <-wv_ru_start()\n", dev->name);
3175 /*------------------------------------------------------------------*/
3177 * Initialise the transmit blocks.
3178 * Start the command unit executing the NOP
3179 * self-loop of the first transmit block.
3181 * Here we create the list of send buffers used to transmit packets
3182 * between the PC and the command unit. For each buffer, we create a
3183 * buffer descriptor (pointing on the buffer), a transmit command
3184 * (pointing to the buffer descriptor) and a NOP command.
3185 * The transmit command is linked to the NOP, and the NOP to itself.
3186 * When we will have finished executing the transmit command, we will
3187 * then loop on the NOP. By releasing the NOP link to a new command,
3188 * we may send another buffer.
3190 * (called by wv_hw_reset())
3192 static int wv_cu_start(struct net_device * dev)
3194 net_local *lp = (net_local *) dev->priv;
3195 unsigned long ioaddr = dev->base_addr;
3201 #ifdef DEBUG_CONFIG_TRACE
3202 printk(KERN_DEBUG "%s: ->wv_cu_start()\n", dev->name);
3205 lp->tx_first_free = OFFSET_CU;
3206 lp->tx_first_in_use = I82586NULL;
3208 for (i = 0, txblock = OFFSET_CU;
3209 i < NTXBLOCKS; i++, txblock += TXBLOCKZ) {
3213 unsigned short tx_addr;
3214 unsigned short nop_addr;
3215 unsigned short tbd_addr;
3216 unsigned short buf_addr;
3219 nop_addr = tx_addr + sizeof(tx);
3220 tbd_addr = nop_addr + sizeof(nop);
3221 buf_addr = tbd_addr + sizeof(tbd);
3223 tx.tx_h.ac_status = 0;
3224 tx.tx_h.ac_command = acmd_transmit | AC_CFLD_I;
3225 tx.tx_h.ac_link = nop_addr;
3226 tx.tx_tbd_offset = tbd_addr;
3227 obram_write(ioaddr, tx_addr, (unsigned char *) &tx,
3230 nop.nop_h.ac_status = 0;
3231 nop.nop_h.ac_command = acmd_nop;
3232 nop.nop_h.ac_link = nop_addr;
3233 obram_write(ioaddr, nop_addr, (unsigned char *) &nop,
3236 tbd.tbd_status = TBD_STATUS_EOF;
3237 tbd.tbd_next_bd_offset = I82586NULL;
3238 tbd.tbd_bufl = buf_addr;
3240 obram_write(ioaddr, tbd_addr, (unsigned char *) &tbd,
3245 OFFSET_CU + (NTXBLOCKS - 1) * TXBLOCKZ + sizeof(ac_tx_t);
3246 obram_write(ioaddr, scboff(OFFSET_SCB, scb_cbl_offset),
3247 (unsigned char *) &first_nop, sizeof(first_nop));
3249 scb_cs = SCB_CMD_CUC_GO;
3250 obram_write(ioaddr, scboff(OFFSET_SCB, scb_command),
3251 (unsigned char *) &scb_cs, sizeof(scb_cs));
3253 set_chan_attn(ioaddr, lp->hacr);
3255 for (i = 1000; i > 0; i--) {
3256 obram_read(ioaddr, scboff(OFFSET_SCB, scb_command),
3257 (unsigned char *) &scb_cs, sizeof(scb_cs));
3265 #ifdef DEBUG_CONFIG_ERROR
3267 "%s: wavelan_cu_start(): board not accepting command.\n",
3273 lp->tx_n_in_use = 0;
3274 netif_start_queue(dev);
3275 #ifdef DEBUG_CONFIG_TRACE
3276 printk(KERN_DEBUG "%s: <-wv_cu_start()\n", dev->name);
3281 /*------------------------------------------------------------------*/
3283 * This routine does a standard configuration of the WaveLAN
3284 * controller (i82586).
3286 * It initialises the scp, iscp and scb structure
3287 * The first two are just pointers to the next.
3288 * The last one is used for basic configuration and for basic
3289 * communication (interrupt status).
3291 * (called by wv_hw_reset())
3293 static int wv_82586_start(struct net_device * dev)
3295 net_local *lp = (net_local *) dev->priv;
3296 unsigned long ioaddr = dev->base_addr;
3297 scp_t scp; /* system configuration pointer */
3298 iscp_t iscp; /* intermediate scp */
3299 scb_t scb; /* system control block */
3300 ach_t cb; /* Action command header */
3304 #ifdef DEBUG_CONFIG_TRACE
3305 printk(KERN_DEBUG "%s: ->wv_82586_start()\n", dev->name);
3309 * Clear the onboard RAM.
3311 memset(&zeroes[0], 0x00, sizeof(zeroes));
3312 for (i = 0; i < I82586_MEMZ; i += sizeof(zeroes))
3313 obram_write(ioaddr, i, &zeroes[0], sizeof(zeroes));
3316 * Construct the command unit structures:
3317 * scp, iscp, scb, cb.
3319 memset(&scp, 0x00, sizeof(scp));
3320 scp.scp_sysbus = SCP_SY_16BBUS;
3321 scp.scp_iscpl = OFFSET_ISCP;
3322 obram_write(ioaddr, OFFSET_SCP, (unsigned char *) &scp,
3325 memset(&iscp, 0x00, sizeof(iscp));
3327 iscp.iscp_offset = OFFSET_SCB;
3328 obram_write(ioaddr, OFFSET_ISCP, (unsigned char *) &iscp,
3331 /* Our first command is to reset the i82586. */
3332 memset(&scb, 0x00, sizeof(scb));
3333 scb.scb_command = SCB_CMD_RESET;
3334 scb.scb_cbl_offset = OFFSET_CU;
3335 scb.scb_rfa_offset = OFFSET_RU;
3336 obram_write(ioaddr, OFFSET_SCB, (unsigned char *) &scb,
3339 set_chan_attn(ioaddr, lp->hacr);
3341 /* Wait for command to finish. */
3342 for (i = 1000; i > 0; i--) {
3343 obram_read(ioaddr, OFFSET_ISCP, (unsigned char *) &iscp,
3346 if (iscp.iscp_busy == (unsigned short) 0)
3353 #ifdef DEBUG_CONFIG_ERROR
3355 "%s: wv_82586_start(): iscp_busy timeout.\n",
3361 /* Check command completion. */
3362 for (i = 15; i > 0; i--) {
3363 obram_read(ioaddr, OFFSET_SCB, (unsigned char *) &scb,
3366 if (scb.scb_status == (SCB_ST_CX | SCB_ST_CNA))
3373 #ifdef DEBUG_CONFIG_ERROR
3375 "%s: wv_82586_start(): status: expected 0x%02x, got 0x%02x.\n",
3376 dev->name, SCB_ST_CX | SCB_ST_CNA, scb.scb_status);
3383 /* Set the action command header. */
3384 memset(&cb, 0x00, sizeof(cb));
3385 cb.ac_command = AC_CFLD_EL | (AC_CFLD_CMD & acmd_diagnose);
3386 cb.ac_link = OFFSET_CU;
3387 obram_write(ioaddr, OFFSET_CU, (unsigned char *) &cb, sizeof(cb));
3389 if (wv_synchronous_cmd(dev, "diag()") == -1)
3392 obram_read(ioaddr, OFFSET_CU, (unsigned char *) &cb, sizeof(cb));
3393 if (cb.ac_status & AC_SFLD_FAIL) {
3394 #ifdef DEBUG_CONFIG_ERROR
3396 "%s: wv_82586_start(): i82586 Self Test failed.\n",
3401 #ifdef DEBUG_I82586_SHOW
3402 wv_scb_show(ioaddr);
3405 #ifdef DEBUG_CONFIG_TRACE
3406 printk(KERN_DEBUG "%s: <-wv_82586_start()\n", dev->name);
3411 /*------------------------------------------------------------------*/
3413 * This routine does a standard configuration of the WaveLAN
3414 * controller (i82586).
3416 * This routine is a violent hack. We use the first free transmit block
3417 * to make our configuration. In the buffer area, we create the three
3418 * configuration commands (linked). We make the previous NOP point to
3419 * the beginning of the buffer instead of the tx command. After, we go
3420 * as usual to the NOP command.
3421 * Note that only the last command (mc_set) will generate an interrupt.
3423 * (called by wv_hw_reset(), wv_82586_reconfig(), wavelan_packet_xmit())
3425 static void wv_82586_config(struct net_device * dev)
3427 net_local *lp = (net_local *) dev->priv;
3428 unsigned long ioaddr = dev->base_addr;
3429 unsigned short txblock;
3430 unsigned short txpred;
3431 unsigned short tx_addr;
3432 unsigned short nop_addr;
3433 unsigned short tbd_addr;
3434 unsigned short cfg_addr;
3435 unsigned short ias_addr;
3436 unsigned short mcs_addr;
3439 ac_cfg_t cfg; /* Configure action */
3440 ac_ias_t ias; /* IA-setup action */
3441 ac_mcs_t mcs; /* Multicast setup */
3442 struct dev_mc_list *dmi;
3444 #ifdef DEBUG_CONFIG_TRACE
3445 printk(KERN_DEBUG "%s: ->wv_82586_config()\n", dev->name);
3448 /* Check nothing bad has happened */
3449 if (lp->tx_n_in_use == (NTXBLOCKS - 1)) {
3450 #ifdef DEBUG_CONFIG_ERROR
3451 printk(KERN_INFO "%s: wv_82586_config(): Tx queue full.\n",
3457 /* Calculate addresses of next block and previous block. */
3458 txblock = lp->tx_first_free;
3459 txpred = txblock - TXBLOCKZ;
3460 if (txpred < OFFSET_CU)
3461 txpred += NTXBLOCKS * TXBLOCKZ;
3462 lp->tx_first_free += TXBLOCKZ;
3463 if (lp->tx_first_free >= OFFSET_CU + NTXBLOCKS * TXBLOCKZ)
3464 lp->tx_first_free -= NTXBLOCKS * TXBLOCKZ;
3468 /* Calculate addresses of the different parts of the block. */
3470 nop_addr = tx_addr + sizeof(tx);
3471 tbd_addr = nop_addr + sizeof(nop);
3472 cfg_addr = tbd_addr + sizeof(tbd_t); /* beginning of the buffer */
3473 ias_addr = cfg_addr + sizeof(cfg);
3474 mcs_addr = ias_addr + sizeof(ias);
3479 tx.tx_h.ac_status = 0xFFFF; /* Fake completion value */
3480 obram_write(ioaddr, toff(ac_tx_t, tx_addr, tx_h.ac_status),
3481 (unsigned char *) &tx.tx_h.ac_status,
3482 sizeof(tx.tx_h.ac_status));
3487 nop.nop_h.ac_status = 0;
3488 obram_write(ioaddr, toff(ac_nop_t, nop_addr, nop_h.ac_status),
3489 (unsigned char *) &nop.nop_h.ac_status,
3490 sizeof(nop.nop_h.ac_status));
3491 nop.nop_h.ac_link = nop_addr;
3492 obram_write(ioaddr, toff(ac_nop_t, nop_addr, nop_h.ac_link),
3493 (unsigned char *) &nop.nop_h.ac_link,
3494 sizeof(nop.nop_h.ac_link));
3496 /* Create a configure action. */
3497 memset(&cfg, 0x00, sizeof(cfg));
3500 * For Linux we invert AC_CFG_ALOC() so as to conform
3501 * to the way that net packets reach us from above.
3502 * (See also ac_tx_t.)
3504 * Updated from Wavelan Manual WCIN085B
3507 AC_CFG_BYTE_CNT(sizeof(ac_cfg_t) - sizeof(ach_t));
3508 cfg.cfg_fifolim = AC_CFG_FIFOLIM(4);
3509 cfg.cfg_byte8 = AC_CFG_SAV_BF(1) | AC_CFG_SRDY(0);
3510 cfg.cfg_byte9 = AC_CFG_ELPBCK(0) |
3512 AC_CFG_PRELEN(AC_CFG_PLEN_2) |
3513 AC_CFG_ALOC(1) | AC_CFG_ADDRLEN(WAVELAN_ADDR_SIZE);
3514 cfg.cfg_byte10 = AC_CFG_BOFMET(1) |
3515 AC_CFG_ACR(6) | AC_CFG_LINPRIO(0);
3517 cfg.cfg_slotl = 0x0C;
3518 cfg.cfg_byte13 = AC_CFG_RETRYNUM(15) | AC_CFG_SLTTMHI(0);
3519 cfg.cfg_byte14 = AC_CFG_FLGPAD(0) |
3525 AC_CFG_BCDIS(0) | AC_CFG_PRM(lp->promiscuous);
3526 cfg.cfg_byte15 = AC_CFG_ICDS(0) |
3527 AC_CFG_CDTF(0) | AC_CFG_ICSS(0) | AC_CFG_CSTF(0);
3529 cfg.cfg_min_frm_len = AC_CFG_MNFRM(64);
3531 cfg.cfg_min_frm_len = AC_CFG_MNFRM(8);
3533 cfg.cfg_h.ac_command = (AC_CFLD_CMD & acmd_configure);
3534 cfg.cfg_h.ac_link = ias_addr;
3535 obram_write(ioaddr, cfg_addr, (unsigned char *) &cfg, sizeof(cfg));
3537 /* Set up the MAC address */
3538 memset(&ias, 0x00, sizeof(ias));
3539 ias.ias_h.ac_command = (AC_CFLD_CMD & acmd_ia_setup);
3540 ias.ias_h.ac_link = mcs_addr;
3541 memcpy(&ias.ias_addr[0], (unsigned char *) &dev->dev_addr[0],
3542 sizeof(ias.ias_addr));
3543 obram_write(ioaddr, ias_addr, (unsigned char *) &ias, sizeof(ias));
3545 /* Initialize adapter's Ethernet multicast addresses */
3546 memset(&mcs, 0x00, sizeof(mcs));
3547 mcs.mcs_h.ac_command = AC_CFLD_I | (AC_CFLD_CMD & acmd_mc_setup);
3548 mcs.mcs_h.ac_link = nop_addr;
3549 mcs.mcs_cnt = WAVELAN_ADDR_SIZE * lp->mc_count;
3550 obram_write(ioaddr, mcs_addr, (unsigned char *) &mcs, sizeof(mcs));
3552 /* Any address to set? */
3554 for (dmi = dev->mc_list; dmi; dmi = dmi->next)
3555 outsw(PIOP1(ioaddr), (u16 *) dmi->dmi_addr,
3556 WAVELAN_ADDR_SIZE >> 1);
3558 #ifdef DEBUG_CONFIG_INFO
3560 "%s: wv_82586_config(): set %d multicast addresses:\n",
3561 dev->name, lp->mc_count);
3562 for (dmi = dev->mc_list; dmi; dmi = dmi->next)
3563 printk(KERN_DEBUG " %pM\n", dmi->dmi_addr);
3568 * Overwrite the predecessor NOP link
3569 * so that it points to the configure action.
3571 nop_addr = txpred + sizeof(tx);
3572 nop.nop_h.ac_status = 0;
3573 obram_write(ioaddr, toff(ac_nop_t, nop_addr, nop_h.ac_status),
3574 (unsigned char *) &nop.nop_h.ac_status,
3575 sizeof(nop.nop_h.ac_status));
3576 nop.nop_h.ac_link = cfg_addr;
3577 obram_write(ioaddr, toff(ac_nop_t, nop_addr, nop_h.ac_link),
3578 (unsigned char *) &nop.nop_h.ac_link,
3579 sizeof(nop.nop_h.ac_link));
3581 /* Job done, clear the flag */
3582 lp->reconfig_82586 = 0;
3584 if (lp->tx_first_in_use == I82586NULL)
3585 lp->tx_first_in_use = txblock;
3587 if (lp->tx_n_in_use == (NTXBLOCKS - 1))
3588 netif_stop_queue(dev);
3590 #ifdef DEBUG_CONFIG_TRACE
3591 printk(KERN_DEBUG "%s: <-wv_82586_config()\n", dev->name);
3595 /*------------------------------------------------------------------*/
3597 * This routine, called by wavelan_close(), gracefully stops the
3598 * WaveLAN controller (i82586).
3599 * (called by wavelan_close())
3601 static void wv_82586_stop(struct net_device * dev)
3603 net_local *lp = (net_local *) dev->priv;
3604 unsigned long ioaddr = dev->base_addr;
3607 #ifdef DEBUG_CONFIG_TRACE
3608 printk(KERN_DEBUG "%s: ->wv_82586_stop()\n", dev->name);
3611 /* Suspend both command unit and receive unit. */
3613 (SCB_CMD_CUC & SCB_CMD_CUC_SUS) | (SCB_CMD_RUC &
3615 obram_write(ioaddr, scboff(OFFSET_SCB, scb_command),
3616 (unsigned char *) &scb_cmd, sizeof(scb_cmd));
3617 set_chan_attn(ioaddr, lp->hacr);
3619 /* No more interrupts */
3622 #ifdef DEBUG_CONFIG_TRACE
3623 printk(KERN_DEBUG "%s: <-wv_82586_stop()\n", dev->name);
3627 /*------------------------------------------------------------------*/
3629 * Totally reset the WaveLAN and restart it.
3630 * Performs the following actions:
3631 * 1. A power reset (reset DMA)
3632 * 2. Initialize the radio modem (using wv_mmc_init)
3633 * 3. Reset & Configure LAN controller (using wv_82586_start)
3634 * 4. Start the LAN controller's command unit
3635 * 5. Start the LAN controller's receive unit
3636 * (called by wavelan_interrupt(), wavelan_watchdog() & wavelan_open())
3638 static int wv_hw_reset(struct net_device * dev)
3640 net_local *lp = (net_local *) dev->priv;
3641 unsigned long ioaddr = dev->base_addr;
3643 #ifdef DEBUG_CONFIG_TRACE
3644 printk(KERN_DEBUG "%s: ->wv_hw_reset(dev=0x%x)\n", dev->name,
3645 (unsigned int) dev);
3648 /* Increase the number of resets done. */
3651 wv_hacr_reset(ioaddr);
3652 lp->hacr = HACR_DEFAULT;
3654 if ((wv_mmc_init(dev) < 0) || (wv_82586_start(dev) < 0))
3657 /* Enable the card to send interrupts. */
3660 /* Start card functions */
3661 if (wv_cu_start(dev) < 0)
3664 /* Setup the controller and parameters */
3665 wv_82586_config(dev);
3667 /* Finish configuration with the receive unit */
3668 if (wv_ru_start(dev) < 0)
3671 #ifdef DEBUG_CONFIG_TRACE
3672 printk(KERN_DEBUG "%s: <-wv_hw_reset()\n", dev->name);
3677 /*------------------------------------------------------------------*/
3679 * Check if there is a WaveLAN at the specific base address.
3680 * As a side effect, this reads the MAC address.
3681 * (called in wavelan_probe() and init_module())
3683 static int wv_check_ioaddr(unsigned long ioaddr, u8 * mac)
3685 int i; /* Loop counter */
3687 /* Check if the base address if available. */
3688 if (!request_region(ioaddr, sizeof(ha_t), "wavelan probe"))
3689 return -EBUSY; /* ioaddr already used */
3691 /* Reset host interface */
3692 wv_hacr_reset(ioaddr);
3694 /* Read the MAC address from the parameter storage area. */
3695 psa_read(ioaddr, HACR_DEFAULT, psaoff(0, psa_univ_mac_addr),
3698 release_region(ioaddr, sizeof(ha_t));
3701 * Check the first three octets of the address for the manufacturer's code.
3702 * Note: if this can't find your WaveLAN card, you've got a
3703 * non-NCR/AT&T/Lucent ISA card. See wavelan.p.h for detail on
3704 * how to configure your card.
3706 for (i = 0; i < ARRAY_SIZE(MAC_ADDRESSES); i++)
3707 if ((mac[0] == MAC_ADDRESSES[i][0]) &&
3708 (mac[1] == MAC_ADDRESSES[i][1]) &&
3709 (mac[2] == MAC_ADDRESSES[i][2]))
3712 #ifdef DEBUG_CONFIG_INFO
3714 "WaveLAN (0x%3X): your MAC address might be %02X:%02X:%02X.\n",
3715 ioaddr, mac[0], mac[1], mac[2]);
3720 /************************ INTERRUPT HANDLING ************************/
3723 * This function is the interrupt handler for the WaveLAN card. This
3724 * routine will be called whenever:
3726 static irqreturn_t wavelan_interrupt(int irq, void *dev_id)
3728 struct net_device *dev;
3729 unsigned long ioaddr;
3737 #ifdef DEBUG_INTERRUPT_TRACE
3738 printk(KERN_DEBUG "%s: ->wavelan_interrupt()\n", dev->name);
3741 lp = (net_local *) dev->priv;
3742 ioaddr = dev->base_addr;
3744 #ifdef DEBUG_INTERRUPT_INFO
3745 /* Check state of our spinlock */
3746 if(spin_is_locked(&lp->spinlock))
3748 "%s: wavelan_interrupt(): spinlock is already locked !!!\n",
3752 /* Prevent reentrancy. We need to do that because we may have
3753 * multiple interrupt handler running concurrently.
3754 * It is safe because interrupts are disabled before acquiring
3756 spin_lock(&lp->spinlock);
3758 /* We always had spurious interrupts at startup, but lately I
3759 * saw them comming *between* the request_irq() and the
3760 * spin_lock_irqsave() in wavelan_open(), so the spinlock
3761 * protection is no enough.
3762 * So, we also check lp->hacr that will tell us is we enabled
3763 * irqs or not (see wv_ints_on()).
3764 * We can't use netif_running(dev) because we depend on the
3765 * proper processing of the irq generated during the config. */
3767 /* Which interrupt it is ? */
3768 hasr = hasr_read(ioaddr);
3770 #ifdef DEBUG_INTERRUPT_INFO
3772 "%s: wavelan_interrupt(): hasr 0x%04x; hacr 0x%04x.\n",
3773 dev->name, hasr, lp->hacr);
3776 /* Check modem interrupt */
3777 if ((hasr & HASR_MMC_INTR) && (lp->hacr & HACR_MMC_INT_ENABLE)) {
3781 * Interrupt from the modem management controller.
3782 * This will clear it -- ignored for now.
3784 mmc_read(ioaddr, mmroff(0, mmr_dce_status), &dce_status,
3785 sizeof(dce_status));
3787 #ifdef DEBUG_INTERRUPT_ERROR
3789 "%s: wavelan_interrupt(): unexpected mmc interrupt: status 0x%04x.\n",
3790 dev->name, dce_status);
3794 /* Check if not controller interrupt */
3795 if (((hasr & HASR_82586_INTR) == 0) ||
3796 ((lp->hacr & HACR_82586_INT_ENABLE) == 0)) {
3797 #ifdef DEBUG_INTERRUPT_ERROR
3799 "%s: wavelan_interrupt(): interrupt not coming from i82586 - hasr 0x%04x.\n",
3802 spin_unlock (&lp->spinlock);
3806 /* Read interrupt data. */
3807 obram_read(ioaddr, scboff(OFFSET_SCB, scb_status),
3808 (unsigned char *) &status, sizeof(status));
3811 * Acknowledge the interrupt(s).
3813 ack_cmd = status & SCB_ST_INT;
3814 obram_write(ioaddr, scboff(OFFSET_SCB, scb_command),
3815 (unsigned char *) &ack_cmd, sizeof(ack_cmd));
3816 set_chan_attn(ioaddr, lp->hacr);
3818 #ifdef DEBUG_INTERRUPT_INFO
3819 printk(KERN_DEBUG "%s: wavelan_interrupt(): status 0x%04x.\n",
3823 /* Command completed. */
3824 if ((status & SCB_ST_CX) == SCB_ST_CX) {
3825 #ifdef DEBUG_INTERRUPT_INFO
3827 "%s: wavelan_interrupt(): command completed.\n",
3830 wv_complete(dev, ioaddr, lp);
3833 /* Frame received. */
3834 if ((status & SCB_ST_FR) == SCB_ST_FR) {
3835 #ifdef DEBUG_INTERRUPT_INFO
3837 "%s: wavelan_interrupt(): received packet.\n",
3843 /* Check the state of the command unit. */
3844 if (((status & SCB_ST_CNA) == SCB_ST_CNA) ||
3845 (((status & SCB_ST_CUS) != SCB_ST_CUS_ACTV) &&
3846 (netif_running(dev)))) {
3847 #ifdef DEBUG_INTERRUPT_ERROR
3849 "%s: wavelan_interrupt(): CU inactive -- restarting\n",
3855 /* Check the state of the command unit. */
3856 if (((status & SCB_ST_RNR) == SCB_ST_RNR) ||
3857 (((status & SCB_ST_RUS) != SCB_ST_RUS_RDY) &&
3858 (netif_running(dev)))) {
3859 #ifdef DEBUG_INTERRUPT_ERROR
3861 "%s: wavelan_interrupt(): RU not ready -- restarting\n",
3867 /* Release spinlock */
3868 spin_unlock (&lp->spinlock);
3870 #ifdef DEBUG_INTERRUPT_TRACE
3871 printk(KERN_DEBUG "%s: <-wavelan_interrupt()\n", dev->name);
3876 /*------------------------------------------------------------------*/
3878 * Watchdog: when we start a transmission, a timer is set for us in the
3879 * kernel. If the transmission completes, this timer is disabled. If
3880 * the timer expires, we are called and we try to unlock the hardware.
3882 static void wavelan_watchdog(struct net_device * dev)
3884 net_local * lp = (net_local *)dev->priv;
3885 u_long ioaddr = dev->base_addr;
3886 unsigned long flags;
3887 unsigned int nreaped;
3889 #ifdef DEBUG_INTERRUPT_TRACE
3890 printk(KERN_DEBUG "%s: ->wavelan_watchdog()\n", dev->name);
3893 #ifdef DEBUG_INTERRUPT_ERROR
3894 printk(KERN_INFO "%s: wavelan_watchdog: watchdog timer expired\n",
3898 /* Check that we came here for something */
3899 if (lp->tx_n_in_use <= 0) {
3903 spin_lock_irqsave(&lp->spinlock, flags);
3905 /* Try to see if some buffers are not free (in case we missed
3907 nreaped = wv_complete(dev, ioaddr, lp);
3909 #ifdef DEBUG_INTERRUPT_INFO
3911 "%s: wavelan_watchdog(): %d reaped, %d remain.\n",
3912 dev->name, nreaped, lp->tx_n_in_use);
3915 #ifdef DEBUG_PSA_SHOW
3918 psa_read(dev, 0, (unsigned char *) &psa, sizeof(psa));
3922 #ifdef DEBUG_MMC_SHOW
3925 #ifdef DEBUG_I82586_SHOW
3929 /* If no buffer has been freed */
3931 #ifdef DEBUG_INTERRUPT_ERROR
3933 "%s: wavelan_watchdog(): cleanup failed, trying reset\n",
3939 /* At this point, we should have some free Tx buffer ;-) */
3940 if (lp->tx_n_in_use < NTXBLOCKS - 1)
3941 netif_wake_queue(dev);
3943 spin_unlock_irqrestore(&lp->spinlock, flags);
3945 #ifdef DEBUG_INTERRUPT_TRACE
3946 printk(KERN_DEBUG "%s: <-wavelan_watchdog()\n", dev->name);
3950 /********************* CONFIGURATION CALLBACKS *********************/
3952 * Here are the functions called by the Linux networking code (NET3)
3953 * for initialization, configuration and deinstallations of the
3954 * WaveLAN ISA hardware.
3957 /*------------------------------------------------------------------*/
3959 * Configure and start up the WaveLAN PCMCIA adaptor.
3960 * Called by NET3 when it "opens" the device.
3962 static int wavelan_open(struct net_device * dev)
3964 net_local * lp = (net_local *)dev->priv;
3965 unsigned long flags;
3967 #ifdef DEBUG_CALLBACK_TRACE
3968 printk(KERN_DEBUG "%s: ->wavelan_open(dev=0x%x)\n", dev->name,
3969 (unsigned int) dev);
3973 if (dev->irq == 0) {
3974 #ifdef DEBUG_CONFIG_ERROR
3975 printk(KERN_WARNING "%s: wavelan_open(): no IRQ\n",
3981 if (request_irq(dev->irq, &wavelan_interrupt, 0, "WaveLAN", dev) != 0)
3983 #ifdef DEBUG_CONFIG_ERROR
3984 printk(KERN_WARNING "%s: wavelan_open(): invalid IRQ\n",
3990 spin_lock_irqsave(&lp->spinlock, flags);
3992 if (wv_hw_reset(dev) != -1) {
3993 netif_start_queue(dev);
3995 free_irq(dev->irq, dev);
3996 #ifdef DEBUG_CONFIG_ERROR
3998 "%s: wavelan_open(): impossible to start the card\n",
4001 spin_unlock_irqrestore(&lp->spinlock, flags);
4004 spin_unlock_irqrestore(&lp->spinlock, flags);
4006 #ifdef DEBUG_CALLBACK_TRACE
4007 printk(KERN_DEBUG "%s: <-wavelan_open()\n", dev->name);
4012 /*------------------------------------------------------------------*/
4014 * Shut down the WaveLAN ISA card.
4015 * Called by NET3 when it "closes" the device.
4017 static int wavelan_close(struct net_device * dev)
4019 net_local *lp = (net_local *) dev->priv;
4020 unsigned long flags;
4022 #ifdef DEBUG_CALLBACK_TRACE
4023 printk(KERN_DEBUG "%s: ->wavelan_close(dev=0x%x)\n", dev->name,
4024 (unsigned int) dev);
4027 netif_stop_queue(dev);
4030 * Flush the Tx and disable Rx.
4032 spin_lock_irqsave(&lp->spinlock, flags);
4034 spin_unlock_irqrestore(&lp->spinlock, flags);
4036 free_irq(dev->irq, dev);
4038 #ifdef DEBUG_CALLBACK_TRACE
4039 printk(KERN_DEBUG "%s: <-wavelan_close()\n", dev->name);
4044 /*------------------------------------------------------------------*/
4046 * Probe an I/O address, and if the WaveLAN is there configure the
4048 * (called by wavelan_probe() and via init_module()).
4050 static int __init wavelan_config(struct net_device *dev, unsigned short ioaddr)
4058 if (!request_region(ioaddr, sizeof(ha_t), "wavelan"))
4061 err = wv_check_ioaddr(ioaddr, mac);
4065 memcpy(dev->dev_addr, mac, 6);
4067 dev->base_addr = ioaddr;
4069 #ifdef DEBUG_CALLBACK_TRACE
4070 printk(KERN_DEBUG "%s: ->wavelan_config(dev=0x%x, ioaddr=0x%lx)\n",
4071 dev->name, (unsigned int) dev, ioaddr);
4074 /* Check IRQ argument on command line. */
4075 if (dev->irq != 0) {
4076 irq_mask = wv_irq_to_psa(dev->irq);
4078 if (irq_mask == 0) {
4079 #ifdef DEBUG_CONFIG_ERROR
4081 "%s: wavelan_config(): invalid IRQ %d ignored.\n",
4082 dev->name, dev->irq);
4086 #ifdef DEBUG_CONFIG_INFO
4088 "%s: wavelan_config(): changing IRQ to %d\n",
4089 dev->name, dev->irq);
4091 psa_write(ioaddr, HACR_DEFAULT,
4092 psaoff(0, psa_int_req_no), &irq_mask, 1);
4093 /* update the Wavelan checksum */
4094 update_psa_checksum(dev, ioaddr, HACR_DEFAULT);
4095 wv_hacr_reset(ioaddr);
4099 psa_read(ioaddr, HACR_DEFAULT, psaoff(0, psa_int_req_no),
4101 if ((irq = wv_psa_to_irq(irq_mask)) == -1) {
4102 #ifdef DEBUG_CONFIG_ERROR
4104 "%s: wavelan_config(): could not wavelan_map_irq(%d).\n",
4105 dev->name, irq_mask);
4113 dev->mem_start = 0x0000;
4114 dev->mem_end = 0x0000;
4117 /* Initialize device structures */
4118 memset(dev->priv, 0, sizeof(net_local));
4119 lp = (net_local *) dev->priv;
4121 /* Back link to the device structure. */
4123 /* Add the device at the beginning of the linked list. */
4124 lp->next = wavelan_list;
4127 lp->hacr = HACR_DEFAULT;
4129 /* Multicast stuff */
4130 lp->promiscuous = 0;
4134 spin_lock_init(&lp->spinlock);
4136 dev->open = wavelan_open;
4137 dev->stop = wavelan_close;
4138 dev->hard_start_xmit = wavelan_packet_xmit;
4139 dev->get_stats = wavelan_get_stats;
4140 dev->set_multicast_list = &wavelan_set_multicast_list;
4141 dev->tx_timeout = &wavelan_watchdog;
4142 dev->watchdog_timeo = WATCHDOG_JIFFIES;
4143 #ifdef SET_MAC_ADDRESS
4144 dev->set_mac_address = &wavelan_set_mac_address;
4145 #endif /* SET_MAC_ADDRESS */
4147 dev->wireless_handlers = &wavelan_handler_def;
4148 lp->wireless_data.spy_data = &lp->spy_data;
4149 dev->wireless_data = &lp->wireless_data;
4151 dev->mtu = WAVELAN_MTU;
4153 /* Display nice information. */
4156 #ifdef DEBUG_CALLBACK_TRACE
4157 printk(KERN_DEBUG "%s: <-wavelan_config()\n", dev->name);
4161 release_region(ioaddr, sizeof(ha_t));
4165 /*------------------------------------------------------------------*/
4167 * Check for a network adaptor of this type. Return '0' iff one
4168 * exists. There seem to be different interpretations of
4169 * the initial value of dev->base_addr.
4170 * We follow the example in drivers/net/ne.c.
4171 * (called in "Space.c")
4173 struct net_device * __init wavelan_probe(int unit)
4175 struct net_device *dev;
4181 /* compile-time check the sizes of structures */
4182 BUILD_BUG_ON(sizeof(psa_t) != PSA_SIZE);
4183 BUILD_BUG_ON(sizeof(mmw_t) != MMW_SIZE);
4184 BUILD_BUG_ON(sizeof(mmr_t) != MMR_SIZE);
4185 BUILD_BUG_ON(sizeof(ha_t) != HA_SIZE);
4187 dev = alloc_etherdev(sizeof(net_local));
4189 return ERR_PTR(-ENOMEM);
4191 sprintf(dev->name, "eth%d", unit);
4192 netdev_boot_setup_check(dev);
4193 base_addr = dev->base_addr;
4196 #ifdef DEBUG_CALLBACK_TRACE
4198 "%s: ->wavelan_probe(dev=%p (base_addr=0x%x))\n",
4199 dev->name, dev, (unsigned int) dev->base_addr);
4202 /* Don't probe at all. */
4203 if (base_addr < 0) {
4204 #ifdef DEBUG_CONFIG_ERROR
4206 "%s: wavelan_probe(): invalid base address\n",
4210 } else if (base_addr > 0x100) { /* Check a single specified location. */
4211 r = wavelan_config(dev, base_addr);
4212 #ifdef DEBUG_CONFIG_INFO
4215 "%s: wavelan_probe(): no device at specified base address (0x%X) or address already in use\n",
4216 dev->name, base_addr);
4219 #ifdef DEBUG_CALLBACK_TRACE
4220 printk(KERN_DEBUG "%s: <-wavelan_probe()\n", dev->name);
4222 } else { /* Scan all possible addresses of the WaveLAN hardware. */
4223 for (i = 0; i < ARRAY_SIZE(iobase); i++) {
4225 if (wavelan_config(dev, iobase[i]) == 0) {
4226 #ifdef DEBUG_CALLBACK_TRACE
4228 "%s: <-wavelan_probe()\n",
4234 if (i == ARRAY_SIZE(iobase))
4239 r = register_netdev(dev);
4244 release_region(dev->base_addr, sizeof(ha_t));
4245 wavelan_list = wavelan_list->next;
4251 /****************************** MODULE ******************************/
4253 * Module entry point: insertion and removal
4257 /*------------------------------------------------------------------*/
4259 * Insertion of the module
4260 * I'm now quite proud of the multi-device support.
4262 int __init init_module(void)
4264 int ret = -EIO; /* Return error if no cards found */
4267 #ifdef DEBUG_MODULE_TRACE
4268 printk(KERN_DEBUG "-> init_module()\n");
4271 /* If probing is asked */
4273 #ifdef DEBUG_CONFIG_ERROR
4275 "WaveLAN init_module(): doing device probing (bad !)\n");
4277 "Specify base addresses while loading module to correct the problem\n");
4280 /* Copy the basic set of address to be probed. */
4281 for (i = 0; i < ARRAY_SIZE(iobase); i++)
4286 /* Loop on all possible base addresses. */
4288 while ((io[++i] != 0) && (i < ARRAY_SIZE(io))) {
4289 struct net_device *dev = alloc_etherdev(sizeof(net_local));
4293 strcpy(dev->name, name[i]); /* Copy name */
4294 dev->base_addr = io[i];
4297 /* Check if there is something at this base address. */
4298 if (wavelan_config(dev, io[i]) == 0) {
4299 if (register_netdev(dev) != 0) {
4300 release_region(dev->base_addr, sizeof(ha_t));
4301 wavelan_list = wavelan_list->next;
4310 #ifdef DEBUG_CONFIG_ERROR
4313 "WaveLAN init_module(): no device found\n");
4316 #ifdef DEBUG_MODULE_TRACE
4317 printk(KERN_DEBUG "<- init_module()\n");
4322 /*------------------------------------------------------------------*/
4324 * Removal of the module
4326 void cleanup_module(void)
4328 #ifdef DEBUG_MODULE_TRACE
4329 printk(KERN_DEBUG "-> cleanup_module()\n");
4332 /* Loop on all devices and release them. */
4333 while (wavelan_list) {
4334 struct net_device *dev = wavelan_list->dev;
4336 #ifdef DEBUG_CONFIG_INFO
4338 "%s: cleanup_module(): removing device at 0x%x\n",
4339 dev->name, (unsigned int) dev);
4341 unregister_netdev(dev);
4343 release_region(dev->base_addr, sizeof(ha_t));
4344 wavelan_list = wavelan_list->next;
4349 #ifdef DEBUG_MODULE_TRACE
4350 printk(KERN_DEBUG "<- cleanup_module()\n");
4354 MODULE_LICENSE("GPL");
4357 * This software may only be used and distributed
4358 * according to the terms of the GNU General Public License.
4360 * This software was developed as a component of the
4361 * Linux operating system.
4362 * It is based on other device drivers and information
4363 * either written or supplied by:
4364 * Ajay Bakre (bakre@paul.rutgers.edu),
4365 * Donald Becker (becker@scyld.com),
4366 * Loeke Brederveld (Loeke.Brederveld@Utrecht.NCR.com),
4367 * Anders Klemets (klemets@it.kth.se),
4368 * Vladimir V. Kolpakov (w@stier.koenig.ru),
4369 * Marc Meertens (Marc.Meertens@Utrecht.NCR.com),
4370 * Pauline Middelink (middelin@polyware.iaf.nl),
4371 * Robert Morris (rtm@das.harvard.edu),
4372 * Jean Tourrilhes (jt@hplb.hpl.hp.com),
4373 * Girish Welling (welling@paul.rutgers.edu),
4375 * Thanks go also to:
4376 * James Ashton (jaa101@syseng.anu.edu.au),
4377 * Alan Cox (alan@lxorguk.ukuu.org.uk),
4378 * Allan Creighton (allanc@cs.usyd.edu.au),
4379 * Matthew Geier (matthew@cs.usyd.edu.au),
4380 * Remo di Giovanni (remo@cs.usyd.edu.au),
4381 * Eckhard Grah (grah@wrcs1.urz.uni-wuppertal.de),
4382 * Vipul Gupta (vgupta@cs.binghamton.edu),
4383 * Mark Hagan (mhagan@wtcpost.daytonoh.NCR.COM),
4384 * Tim Nicholson (tim@cs.usyd.edu.au),
4385 * Ian Parkin (ian@cs.usyd.edu.au),
4386 * John Rosenberg (johnr@cs.usyd.edu.au),
4387 * George Rossi (george@phm.gov.au),
4388 * Arthur Scott (arthur@cs.usyd.edu.au),
4390 * for their assistance and advice.
4392 * Please send bug reports, updates, comments to:
4394 * Bruce Janson Email: bruce@cs.usyd.edu.au
4395 * Basser Department of Computer Science Phone: +61-2-9351-3423
4396 * University of Sydney, N.S.W., 2006, AUSTRALIA Fax: +61-2-9351-3838