patch-2.2.8 linux/drivers/net/wavelan.c
Next file: linux/drivers/net/wavelan.p.h
Previous file: linux/drivers/net/via-rhine.c
Back to the patch index
Back to the overall index
- Lines: 594
- Date:
Thu Apr 29 11:53:41 1999
- Orig file:
v2.2.7/linux/drivers/net/wavelan.c
- Orig date:
Tue Mar 23 14:35:48 1999
diff -u --recursive --new-file v2.2.7/linux/drivers/net/wavelan.c linux/drivers/net/wavelan.c
@@ -324,6 +324,7 @@
return crc_bytes;
} /* psa_crc */
+#endif /* SET_PSA_CRC */
/*------------------------------------------------------------------*/
/*
@@ -334,6 +335,7 @@
u_long ioaddr,
u_short hacr)
{
+#ifdef SET_PSA_CRC
psa_t psa;
u_short crc;
@@ -363,8 +365,8 @@
if(crc != 0)
printk(KERN_WARNING "%s: update_psa_checksum(): CRC does not agree with PSA data (even after recalculating)\n", dev->name);
#endif /* DEBUG_IOCTL_INFO */
-} /* update_psa_checksum */
#endif /* SET_PSA_CRC */
+} /* update_psa_checksum */
/*------------------------------------------------------------------*/
/*
@@ -748,23 +750,23 @@
unsigned short ias_addr;
/* Check mc_config command */
- if((status & AC_SFLD_OK) != 0)
- printk(KERN_INFO "wv_config_complete(): set_multicast_address failed; status = 0x%x\n",
- dev->name, str, status);
+ if((status & AC_SFLD_OK) != AC_SFLD_OK)
+ printk(KERN_INFO "%s: wv_config_complete(): set_multicast_address failed; status = 0x%x\n",
+ dev->name, status);
/* check ia-config command */
ias_addr = mcs_addr - sizeof(ac_ias_t);
obram_read(ioaddr, acoff(ias_addr, ac_status), (unsigned char *)&status, sizeof(status));
- if((status & AC_SFLD_OK) != 0)
- printk(KERN_INFO "wv_config_complete(): set_MAC_address; status = 0x%x\n",
- dev->name, str, status);
+ if((status & AC_SFLD_OK) != AC_SFLD_OK)
+ printk(KERN_INFO "%s: wv_config_complete(): set_MAC_address failed; status = 0x%x\n",
+ dev->name, status);
/* Check config command. */
cfg_addr = ias_addr - sizeof(ac_cfg_t);
obram_read(ioaddr, acoff(cfg_addr, ac_status), (unsigned char *)&status, sizeof(status));
- if((status & AC_SFLD_OK) != 0)
- printk(KERN_INFO "wv_config_complete(): configure; status = 0x%x\n",
- dev->name, str, status);
+ if((status & AC_SFLD_OK) != AC_SFLD_OK)
+ printk(KERN_INFO "%s: wv_config_complete(): configure failed; status = 0x%x\n",
+ dev->name, status);
#endif /* DEBUG_CONFIG_ERROR */
ret = 1; /* Ready to be scrapped */
@@ -800,15 +802,15 @@
/* Read the first transmit buffer */
obram_read(ioaddr, acoff(lp->tx_first_in_use, ac_status), (unsigned char *)&tx_status, sizeof(tx_status));
+ /* If not completed -> exit */
+ if((tx_status & AC_SFLD_C) == 0)
+ break;
+
/* Hack for reconfiguration */
if(tx_status == 0xFFFF)
if(!wv_config_complete(dev, ioaddr, lp))
break; /* Not completed */
- /* If not completed -> exit */
- if((tx_status & AC_SFLD_C) == 0)
- break;
-
/* We now remove this buffer */
nreaped++;
--lp->tx_n_in_use;
@@ -841,7 +843,7 @@
lp->stats.tx_packets++;
ncollisions = tx_status & AC_SFLD_MAXCOL;
lp->stats.collisions += ncollisions;
-#ifdef DEBUG_INTERRUPT_INFO
+#ifdef DEBUG_TX_INFO
if(ncollisions > 0)
printk(KERN_DEBUG "%s: wv_complete(): tx completed after %d collisions.\n",
dev->name, ncollisions);
@@ -850,53 +852,49 @@
else
{
lp->stats.tx_errors++;
-#ifndef IGNORE_NORMAL_XMIT_ERRS
if(tx_status & AC_SFLD_S10)
{
lp->stats.tx_carrier_errors++;
-#ifdef DEBUG_INTERRUPT_ERROR
- printk(KERN_INFO "%s: wv_complete(): tx error: no CS.\n",
+#ifdef DEBUG_TX_FAIL
+ printk(KERN_DEBUG "%s: wv_complete(): tx error: no CS.\n",
dev->name);
#endif
}
-#endif /* IGNORE_NORMAL_XMIT_ERRS */
if(tx_status & AC_SFLD_S9)
{
lp->stats.tx_carrier_errors++;
-#ifdef DEBUG_INTERRUPT_ERROR
- printk(KERN_INFO "%s: wv_complete(): tx error: lost CTS.\n",
+#ifdef DEBUG_TX_FAIL
+ printk(KERN_DEBUG "%s: wv_complete(): tx error: lost CTS.\n",
dev->name);
#endif
}
if(tx_status & AC_SFLD_S8)
{
lp->stats.tx_fifo_errors++;
-#ifdef DEBUG_INTERRUPT_ERROR
- printk(KERN_INFO "%s: wv_complete(): tx error: slow DMA.\n",
+#ifdef DEBUG_TX_FAIL
+ printk(KERN_DEBUG "%s: wv_complete(): tx error: slow DMA.\n",
dev->name);
#endif
}
-#ifndef IGNORE_NORMAL_XMIT_ERRS
if(tx_status & AC_SFLD_S6)
{
lp->stats.tx_heartbeat_errors++;
-#ifdef DEBUG_INTERRUPT_ERROR
- printk(KERN_INFO "%s: wv_complete(): tx error: heart beat.\n",
+#ifdef DEBUG_TX_FAIL
+ printk(KERN_DEBUG "%s: wv_complete(): tx error: heart beat.\n",
dev->name);
#endif
}
if(tx_status & AC_SFLD_S5)
{
lp->stats.tx_aborted_errors++;
-#ifdef DEBUG_INTERRUPT_ERROR
- printk(KERN_INFO "%s: wv_complete(): tx error: too many collisions.\n",
+#ifdef DEBUG_TX_FAIL
+ printk(KERN_DEBUG "%s: wv_complete(): tx error: too many collisions.\n",
dev->name);
#endif
}
-#endif /* IGNORE_NORMAL_XMIT_ERRS */
}
-#ifdef DEBUG_INTERRUPT_INFO
+#ifdef DEBUG_TX_INFO
printk(KERN_DEBUG "%s: wv_complete(): tx completed, tx_status 0x%04x\n",
dev->name, tx_status);
#endif
@@ -1323,21 +1321,21 @@
char * msg1, /* Name of the device */
char * msg2) /* Name of the function */
{
-#ifndef DEBUG_PACKET_DUMP
+ int i;
+ int maxi;
+
printk(KERN_DEBUG "%s: %s(): dest %02X:%02X:%02X:%02X:%02X:%02X, length %d\n",
msg1, msg2, p[0], p[1], p[2], p[3], p[4], p[5], length);
printk(KERN_DEBUG "%s: %s(): src %02X:%02X:%02X:%02X:%02X:%02X, type 0x%02X%02X\n",
msg1, msg2, p[6], p[7], p[8], p[9], p[10], p[11], p[12], p[13]);
-#else /* DEBUG_PACKET_DUMP */
- int i;
- int maxi;
+#ifdef DEBUG_PACKET_DUMP
- printk(KERN_DEBUG "%s: %s(): len=%d, data=\"", msg1, msg2, length);
+ printk(KERN_DEBUG "data=\"");
if((maxi = length) > DEBUG_PACKET_DUMP)
maxi = DEBUG_PACKET_DUMP;
- for(i = 0; i < maxi; i++)
+ for(i = 14; i < maxi; i++)
if(p[i] >= ' ' && p[i] <= '~')
printk(" %c", p[i]);
else
@@ -1564,7 +1562,9 @@
/*------------------------------------------------------------------*/
/*
* This function doesn't exist.
+ * (Note : it was a nice way to test the reconfigure stuff...)
*/
+#ifdef SET_MAC_ADDRESS
static int
wavelan_set_mac_address(device * dev,
void * addr)
@@ -1579,6 +1579,7 @@
return 0;
}
+#endif /* SET_MAC_ADDRESS */
#ifdef WIRELESS_EXT /* if wireless extensions exist in the kernel */
@@ -1932,10 +1933,8 @@
/* Disable NWID in the mmc (no filtering). */
mmc_out(ioaddr, mmwoff(0, mmw_loopt_sel), MMW_LOOPT_SEL_DIS_NWID);
}
-#ifdef SET_PSA_CRC
/* update the Wavelan checksum */
update_psa_checksum(dev, ioaddr, lp->hacr);
-#endif
break;
case SIOCGIWNWID:
@@ -1992,10 +1991,8 @@
psa.psa_thr_pre_set = wrq->u.sensitivity & 0x3F;
psa_write(ioaddr, lp->hacr, (char *)&psa.psa_thr_pre_set - (char *)&psa,
(unsigned char *) &psa.psa_thr_pre_set, 1);
-#ifdef SET_PSA_CRC
/* update the Wavelan checksum */
update_psa_checksum(dev, ioaddr, lp->hacr);
-#endif
mmc_out(ioaddr, mmwoff(0, mmw_thr_pre_set), psa.psa_thr_pre_set);
break;
@@ -2043,10 +2040,8 @@
mmc_out(ioaddr, mmwoff(0, mmw_encr_enable), 0);
}
-#ifdef SET_PSA_CRC
/* update the Wavelan checksum */
update_psa_checksum(dev, ioaddr, lp->hacr);
-#endif
break;
case SIOCGIWENCODE:
@@ -2260,10 +2255,8 @@
psa.psa_quality_thr = *(wrq->u.name) & 0x0F;
psa_write(ioaddr, lp->hacr, (char *)&psa.psa_quality_thr - (char *)&psa,
(unsigned char *)&psa.psa_quality_thr, 1);
-#ifdef SET_PSA_CRC
/* update the Wavelan checksum */
update_psa_checksum(dev, ioaddr, lp->hacr);
-#endif
mmc_out(ioaddr, mmwoff(0, mmw_quality_thr), psa.psa_quality_thr);
break;
@@ -2426,7 +2419,7 @@
#ifdef DEBUG_RX_TRACE
printk(KERN_DEBUG "%s: ->wv_packet_read(0x%X, %d)\n",
- dev->name, fd_p, sksize);
+ dev->name, buf_off, sksize);
#endif
/* Allocate buffer for the data */
@@ -2514,6 +2507,8 @@
{
u_long ioaddr = dev->base_addr;
net_local * lp = (net_local *)dev->priv;
+ fd_t fd;
+ rbd_t rbd;
int nreaped = 0;
#ifdef DEBUG_RX_TRACE
@@ -2523,12 +2518,17 @@
/* Loop on each received packet. */
for(;;)
{
- fd_t fd;
- rbd_t rbd;
- ushort pkt_len;
-
obram_read(ioaddr, lp->rx_head, (unsigned char *) &fd, sizeof(fd));
+ /* Note about the status :
+ * It start up to be 0 (the value we set). Then, when the RU
+ * grab the buffer to prepare for reception, it sets the
+ * FD_STATUS_B flag. When the RU has finished receiving the
+ * frame, it clears FD_STATUS_B, set FD_STATUS_C to indicate
+ * completion and set the other flags to indicate the eventual
+ * errors. FD_STATUS_OK indicates that the reception was OK.
+ */
+
/* If the current frame is not complete, we have reached the end. */
if((fd.fd_status & FD_STATUS_C) != FD_STATUS_C)
break; /* This is how we exit the loop. */
@@ -2536,35 +2536,44 @@
nreaped++;
/* Check whether frame was correctly received. */
- if((fd.fd_status & (FD_STATUS_B | FD_STATUS_OK)) !=
- (FD_STATUS_B | FD_STATUS_OK))
+ if((fd.fd_status & FD_STATUS_OK) == FD_STATUS_OK)
{
- /*
- * Not sure about this one -- it does not seem
- * to be an error so we will keep quiet about it.
- */
-#ifndef IGNORE_NORMAL_XMIT_ERRS
-#ifdef DEBUG_RX_ERROR
- if((fd.fd_status & FD_STATUS_B) != FD_STATUS_B)
- printk(KERN_INFO "%s: wv_receive(): frame not consumed by RU.\n",
- dev->name);
-#endif
-#endif /* IGNORE_NORMAL_XMIT_ERRS */
+ /* Does the frame contain a pointer to the data? Let's check. */
+ if(fd.fd_rbd_offset != I82586NULL)
+ {
+ /* Read the receive buffer descriptor */
+ obram_read(ioaddr, fd.fd_rbd_offset,
+ (unsigned char *) &rbd, sizeof(rbd));
#ifdef DEBUG_RX_ERROR
- if((fd.fd_status & FD_STATUS_OK) != FD_STATUS_OK)
- printk(KERN_INFO "%s: wv_receive(): frame not received successfully.\n",
+ if((rbd.rbd_status & RBD_STATUS_EOF) != RBD_STATUS_EOF)
+ printk(KERN_INFO "%s: wv_receive(): missing EOF flag.\n",
+ dev->name);
+
+ if((rbd.rbd_status & RBD_STATUS_F) != RBD_STATUS_F)
+ printk(KERN_INFO "%s: wv_receive(): missing F flag.\n",
+ dev->name);
+#endif /* DEBUG_RX_ERROR */
+
+ /* Read the packet and transmit to Linux */
+ wv_packet_read(dev, rbd.rbd_bufl,
+ rbd.rbd_status & RBD_STATUS_ACNT);
+ }
+#ifdef DEBUG_RX_ERROR
+ else /* if frame has no data */
+ printk(KERN_INFO "%s: wv_receive(): frame has no data.\n",
dev->name);
#endif
}
-
- /* Were there problems in processing the frame? Let's check. */
- if((fd.fd_status & (FD_STATUS_S6 | FD_STATUS_S7 | FD_STATUS_S8 |
- FD_STATUS_S9 | FD_STATUS_S10 | FD_STATUS_S11))
- != 0)
+ else /* If reception was no successful */
{
lp->stats.rx_errors++;
+#ifdef DEBUG_RX_INFO
+ printk(KERN_DEBUG "%s: wv_receive(): frame not received successfully (%X).\n",
+ dev->name, fd.fd_status);
+#endif
+
#ifdef DEBUG_RX_ERROR
if((fd.fd_status & FD_STATUS_S6) != 0)
printk(KERN_INFO "%s: wv_receive(): no EOF flag.\n", dev->name);
@@ -2573,8 +2582,8 @@
if((fd.fd_status & FD_STATUS_S7) != 0)
{
lp->stats.rx_length_errors++;
-#ifdef DEBUG_RX_ERROR
- printk(KERN_INFO "%s: wv_receive(): frame too short.\n",
+#ifdef DEBUG_RX_FAIL
+ printk(KERN_DEBUG "%s: wv_receive(): frame too short.\n",
dev->name);
#endif
}
@@ -2582,8 +2591,8 @@
if((fd.fd_status & FD_STATUS_S8) != 0)
{
lp->stats.rx_over_errors++;
-#ifdef DEBUG_RX_ERROR
- printk(KERN_INFO "%s: wv_receive(): rx DMA overrun.\n",
+#ifdef DEBUG_RX_FAIL
+ printk(KERN_DEBUG "%s: wv_receive(): rx DMA overrun.\n",
dev->name);
#endif
}
@@ -2591,8 +2600,8 @@
if((fd.fd_status & FD_STATUS_S9) != 0)
{
lp->stats.rx_fifo_errors++;
-#ifdef DEBUG_RX_ERROR
- printk(KERN_INFO "%s: wv_receive(): ran out of resources.\n",
+#ifdef DEBUG_RX_FAIL
+ printk(KERN_DEBUG "%s: wv_receive(): ran out of resources.\n",
dev->name);
#endif
}
@@ -2600,8 +2609,8 @@
if((fd.fd_status & FD_STATUS_S10) != 0)
{
lp->stats.rx_frame_errors++;
-#ifdef DEBUG_RX_ERROR
- printk(KERN_INFO "%s: wv_receive(): alignment error.\n",
+#ifdef DEBUG_RX_FAIL
+ printk(KERN_DEBUG "%s: wv_receive(): alignment error.\n",
dev->name);
#endif
}
@@ -2609,38 +2618,12 @@
if((fd.fd_status & FD_STATUS_S11) != 0)
{
lp->stats.rx_crc_errors++;
-#ifdef DEBUG_RX_ERROR
- printk(KERN_INFO "%s: wv_receive(): CRC error.\n", dev->name);
+#ifdef DEBUG_RX_FAIL
+ printk(KERN_DEBUG "%s: wv_receive(): CRC error.\n", dev->name);
#endif
}
}
- /* Does the frame contain a pointer to the data? Let's check. */
- if(fd.fd_rbd_offset == I82586NULL)
-#ifdef DEBUG_RX_ERROR
- printk(KERN_INFO "%s: wv_receive(): frame has no data.\n", dev->name);
-#endif
- else
- {
- obram_read(ioaddr, fd.fd_rbd_offset,
- (unsigned char *) &rbd, sizeof(rbd));
-
-#ifdef DEBUG_RX_ERROR
- if((rbd.rbd_status & RBD_STATUS_EOF) != RBD_STATUS_EOF)
- printk(KERN_INFO "%s: wv_receive(): missing EOF flag.\n",
- dev->name);
-
- if((rbd.rbd_status & RBD_STATUS_F) != RBD_STATUS_F)
- printk(KERN_INFO "%s: wv_receive(): missing F flag.\n",
- dev->name);
-#endif
-
- pkt_len = rbd.rbd_status & RBD_STATUS_ACNT;
-
- /* Read the packet and transmit to Linux */
- wv_packet_read(dev, rbd.rbd_bufl, pkt_len);
- } /* if frame has data */
-
fd.fd_status = 0;
obram_write(ioaddr, fdoff(lp->rx_head, fd_status),
(unsigned char *) &fd.fd_status, sizeof(fd.fd_status));
@@ -2775,7 +2758,7 @@
/*
* Data
*/
- obram_write(ioaddr, buf_addr, buf, clen);
+ obram_write(ioaddr, buf_addr, buf, length);
/*
* Overwrite the predecessor NOP link
@@ -2950,11 +2933,9 @@
(unsigned char *)&psa.psa_quality_thr, 1);
psa_write(ioaddr, lp->hacr, (char *)&psa.psa_conf_status - (char *)&psa,
(unsigned char *)&psa.psa_conf_status, 1);
-#ifdef SET_PSA_CRC
/* update the Wavelan checksum */
update_psa_checksum(dev, ioaddr, lp->hacr);
#endif
-#endif
}
/* Zero the mmc structure. */
@@ -3125,7 +3106,7 @@
if(i <= 0)
{
-#ifdef DEBUG_CONFIG_ERRORS
+#ifdef DEBUG_CONFIG_ERROR
printk(KERN_INFO "%s: wavelan_ru_start(): board not accepting command.\n",
dev->name);
#endif
@@ -3229,7 +3210,7 @@
if(i <= 0)
{
-#ifdef DEBUG_CONFIG_ERRORS
+#ifdef DEBUG_CONFIG_ERROR
printk(KERN_INFO "%s: wavelan_cu_start(): board not accepting command.\n",
dev->name);
#endif
@@ -3316,7 +3297,7 @@
if(i <= 0)
{
-#ifdef DEBUG_CONFIG_ERRORS
+#ifdef DEBUG_CONFIG_ERROR
printk(KERN_INFO "%s: wv_82586_start(): iscp_busy timeout.\n",
dev->name);
#endif
@@ -3336,7 +3317,7 @@
if (i <= 0)
{
-#ifdef DEBUG_CONFIG_ERRORS
+#ifdef DEBUG_CONFIG_ERROR
printk(KERN_INFO "%s: wv_82586_start(): status: expected 0x%02x, got 0x%02x.\n",
dev->name, SCB_ST_CX | SCB_ST_CNA, scb.scb_status);
#endif
@@ -3357,7 +3338,7 @@
obram_read(ioaddr, OFFSET_CU, (unsigned char *)&cb, sizeof(cb));
if(cb.ac_status & AC_SFLD_FAIL)
{
-#ifdef DEBUG_CONFIG_ERRORS
+#ifdef DEBUG_CONFIG_ERROR
printk(KERN_INFO "%s: wv_82586_start(): i82586 Self Test failed.\n",
dev->name);
#endif
@@ -3638,13 +3619,16 @@
wv_ints_on(dev);
/* Start card functions */
- if((wv_ru_start(dev) < 0) ||
- (wv_cu_start(dev) < 0))
+ if(wv_cu_start(dev) < 0)
return -1;
- /* Finish configuration. */
+ /* Setup the controller and parameters */
wv_82586_config(dev);
+ /* Finish configuration with the receive unit */
+ if(wv_ru_start(dev) < 0)
+ return -1;
+
#ifdef DEBUG_CONFIG_TRACE
printk(KERN_DEBUG "%s: <-wv_hw_reset()\n", dev->name);
#endif
@@ -3945,7 +3929,7 @@
/* Check irq */
if(dev->irq == 0)
{
-#ifdef DEBUG_CONFIG_ERRORS
+#ifdef DEBUG_CONFIG_ERROR
printk(KERN_WARNING "%s: wavelan_open(): no IRQ\n", dev->name);
#endif
return -ENXIO;
@@ -3953,7 +3937,7 @@
if(request_irq(dev->irq, &wavelan_interrupt, 0, "WaveLAN", dev) != 0)
{
-#ifdef DEBUG_CONFIG_ERRORS
+#ifdef DEBUG_CONFIG_ERROR
printk(KERN_WARNING "%s: wavelan_open(): invalid IRQ\n", dev->name);
#endif
return -EAGAIN;
@@ -3968,7 +3952,7 @@
else
{
free_irq(dev->irq, dev);
-#ifdef DEBUG_CONFIG_ERRORS
+#ifdef DEBUG_CONFIG_ERROR
printk(KERN_INFO "%s: wavelan_open(): impossible to start the card\n",
dev->name);
#endif
@@ -4065,10 +4049,8 @@
#endif
psa_write(ioaddr, HACR_DEFAULT,
psaoff(0, psa_int_req_no), &irq_mask, 1);
-#ifdef SET_PSA_CRC
/* update the Wavelan checksum */
update_psa_checksum(dev, ioaddr, HACR_DEFAULT);
-#endif
wv_hacr_reset(ioaddr);
}
}
@@ -4122,7 +4104,9 @@
dev->hard_start_xmit = wavelan_packet_xmit;
dev->get_stats = wavelan_get_stats;
dev->set_multicast_list = &wavelan_set_multicast_list;
+#ifdef SET_MAC_ADDRESS
dev->set_mac_address = &wavelan_set_mac_address;
+#endif /* SET_MAC_ADDRESS */
#ifdef WIRELESS_EXT /* if wireless extension exists in the kernel */
dev->do_ioctl = wavelan_ioctl;
@@ -4176,7 +4160,7 @@
/* Don't probe at all. */
if(base_addr < 0)
{
-#ifdef DEBUG_CONFIG_ERRORS
+#ifdef DEBUG_CONFIG_ERROR
printk(KERN_WARNING "%s: wavelan_probe(): invalid base address\n",
dev->name);
#endif
@@ -4259,7 +4243,7 @@
/* If probing is asked */
if(io[0] == 0)
{
-#ifdef DEBUG_CONFIG_ERRORS
+#ifdef DEBUG_CONFIG_ERROR
printk(KERN_WARNING "WaveLAN init_module(): doing device probing (bad !)\n");
printk(KERN_WARNING "Specify base addresses while loading module to correct the problem\n");
#endif
@@ -4303,7 +4287,7 @@
} /* if there is something at the address */
} /* Loop on all addresses. */
-#ifdef DEBUG_CONFIG_ERRORS
+#ifdef DEBUG_CONFIG_ERROR
if(wavelan_list == (net_local *) NULL)
printk(KERN_WARNING "WaveLAN init_module(): no device found\n");
#endif
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)