aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/znet.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/znet.c')
-rw-r--r--drivers/net/znet.c73
1 files changed, 36 insertions, 37 deletions
diff --git a/drivers/net/znet.c b/drivers/net/znet.c
index a7c089df66e..656d5a02908 100644
--- a/drivers/net/znet.c
+++ b/drivers/net/znet.c
@@ -75,7 +75,7 @@
75 - Now survives unplugging/replugging cable. 75 - Now survives unplugging/replugging cable.
76 76
77 Some code was taken from wavelan_cs. 77 Some code was taken from wavelan_cs.
78 78
79 Tested on a vintage Zenith Z-Note 433Lnp+. Probably broken on 79 Tested on a vintage Zenith Z-Note 433Lnp+. Probably broken on
80 anything else. Testers (and detailed bug reports) are welcome :-). 80 anything else. Testers (and detailed bug reports) are welcome :-).
81 81
@@ -85,7 +85,6 @@
85 - Understand why some traffic patterns add a 1s latency... 85 - Understand why some traffic patterns add a 1s latency...
86 */ 86 */
87 87
88#include <linux/config.h>
89#include <linux/module.h> 88#include <linux/module.h>
90#include <linux/kernel.h> 89#include <linux/kernel.h>
91#include <linux/string.h> 90#include <linux/string.h>
@@ -172,7 +171,7 @@ static int znet_request_resources (struct net_device *dev)
172{ 171{
173 struct znet_private *znet = dev->priv; 172 struct znet_private *znet = dev->priv;
174 unsigned long flags; 173 unsigned long flags;
175 174
176 if (request_irq (dev->irq, &znet_interrupt, 0, "ZNet", dev)) 175 if (request_irq (dev->irq, &znet_interrupt, 0, "ZNet", dev))
177 goto failed; 176 goto failed;
178 if (request_dma (znet->rx_dma, "ZNet rx")) 177 if (request_dma (znet->rx_dma, "ZNet rx"))
@@ -206,7 +205,7 @@ static void znet_release_resources (struct net_device *dev)
206{ 205{
207 struct znet_private *znet = dev->priv; 206 struct znet_private *znet = dev->priv;
208 unsigned long flags; 207 unsigned long flags;
209 208
210 release_region (znet->sia_base, znet->sia_size); 209 release_region (znet->sia_base, znet->sia_size);
211 release_region (dev->base_addr, znet->io_size); 210 release_region (dev->base_addr, znet->io_size);
212 flags = claim_dma_lock(); 211 flags = claim_dma_lock();
@@ -230,7 +229,7 @@ static void znet_transceiver_power (struct net_device *dev, int on)
230 v = inb(znet->sia_base + 1) | 0x84; 229 v = inb(znet->sia_base + 1) | 0x84;
231 else 230 else
232 v = inb(znet->sia_base + 1) & ~0x84; 231 v = inb(znet->sia_base + 1) & ~0x84;
233 232
234 outb(v, znet->sia_base+1); /* Turn on/off LAN power (bit 2). */ 233 outb(v, znet->sia_base+1); /* Turn on/off LAN power (bit 2). */
235} 234}
236 235
@@ -243,7 +242,7 @@ static void znet_set_multicast_list (struct net_device *dev)
243 struct i82593_conf_block *cfblk = &znet->i593_init; 242 struct i82593_conf_block *cfblk = &znet->i593_init;
244 243
245 memset(cfblk, 0x00, sizeof(struct i82593_conf_block)); 244 memset(cfblk, 0x00, sizeof(struct i82593_conf_block));
246 245
247 /* The configuration block. What an undocumented nightmare. 246 /* The configuration block. What an undocumented nightmare.
248 The first set of values are those suggested (without explanation) 247 The first set of values are those suggested (without explanation)
249 for ethernet in the Intel 82586 databook. The rest appear to be 248 for ethernet in the Intel 82586 databook. The rest appear to be
@@ -252,7 +251,7 @@ static void znet_set_multicast_list (struct net_device *dev)
252 251
253 /* maz : Rewritten to take advantage of the wanvelan includes. 252 /* maz : Rewritten to take advantage of the wanvelan includes.
254 At least we have names, not just blind values */ 253 At least we have names, not just blind values */
255 254
256 /* Byte 0 */ 255 /* Byte 0 */
257 cfblk->fifo_limit = 10; /* = 16 B rx and 80 B tx fifo thresholds */ 256 cfblk->fifo_limit = 10; /* = 16 B rx and 80 B tx fifo thresholds */
258 cfblk->forgnesi = 0; /* 0=82C501, 1=AMD7992B compatibility */ 257 cfblk->forgnesi = 0; /* 0=82C501, 1=AMD7992B compatibility */
@@ -270,23 +269,23 @@ static void znet_set_multicast_list (struct net_device *dev)
270 cfblk->acloc = 1; /* Disable source addr insertion by i82593 */ 269 cfblk->acloc = 1; /* Disable source addr insertion by i82593 */
271 cfblk->preamb_len = 2; /* 8 bytes preamble */ 270 cfblk->preamb_len = 2; /* 8 bytes preamble */
272 cfblk->loopback = 0; /* Loopback off */ 271 cfblk->loopback = 0; /* Loopback off */
273 272
274 /* Byte 3 */ 273 /* Byte 3 */
275 cfblk->lin_prio = 0; /* Default priorities & backoff methods. */ 274 cfblk->lin_prio = 0; /* Default priorities & backoff methods. */
276 cfblk->tbofstop = 0; 275 cfblk->tbofstop = 0;
277 cfblk->exp_prio = 0; 276 cfblk->exp_prio = 0;
278 cfblk->bof_met = 0; 277 cfblk->bof_met = 0;
279 278
280 /* Byte 4 */ 279 /* Byte 4 */
281 cfblk->ifrm_spc = 6; /* 96 bit times interframe spacing */ 280 cfblk->ifrm_spc = 6; /* 96 bit times interframe spacing */
282 281
283 /* Byte 5 */ 282 /* Byte 5 */
284 cfblk->slottim_low = 0; /* 512 bit times slot time (low) */ 283 cfblk->slottim_low = 0; /* 512 bit times slot time (low) */
285 284
286 /* Byte 6 */ 285 /* Byte 6 */
287 cfblk->slottim_hi = 2; /* 512 bit times slot time (high) */ 286 cfblk->slottim_hi = 2; /* 512 bit times slot time (high) */
288 cfblk->max_retr = 15; /* 15 collisions retries */ 287 cfblk->max_retr = 15; /* 15 collisions retries */
289 288
290 /* Byte 7 */ 289 /* Byte 7 */
291 cfblk->prmisc = ((dev->flags & IFF_PROMISC) ? 1 : 0); /* Promiscuous mode */ 290 cfblk->prmisc = ((dev->flags & IFF_PROMISC) ? 1 : 0); /* Promiscuous mode */
292 cfblk->bc_dis = 0; /* Enable broadcast reception */ 291 cfblk->bc_dis = 0; /* Enable broadcast reception */
@@ -294,15 +293,15 @@ static void znet_set_multicast_list (struct net_device *dev)
294 cfblk->nocrc_ins = 0; /* i82593 generates CRC */ 293 cfblk->nocrc_ins = 0; /* i82593 generates CRC */
295 cfblk->crc_1632 = 0; /* 32-bit Autodin-II CRC */ 294 cfblk->crc_1632 = 0; /* 32-bit Autodin-II CRC */
296 cfblk->crs_cdt = 0; /* CD not to be interpreted as CS */ 295 cfblk->crs_cdt = 0; /* CD not to be interpreted as CS */
297 296
298 /* Byte 8 */ 297 /* Byte 8 */
299 cfblk->cs_filter = 0; /* CS is recognized immediately */ 298 cfblk->cs_filter = 0; /* CS is recognized immediately */
300 cfblk->crs_src = 0; /* External carrier sense */ 299 cfblk->crs_src = 0; /* External carrier sense */
301 cfblk->cd_filter = 0; /* CD is recognized immediately */ 300 cfblk->cd_filter = 0; /* CD is recognized immediately */
302 301
303 /* Byte 9 */ 302 /* Byte 9 */
304 cfblk->min_fr_len = ETH_ZLEN >> 2; /* Minimum frame length */ 303 cfblk->min_fr_len = ETH_ZLEN >> 2; /* Minimum frame length */
305 304
306 /* Byte A */ 305 /* Byte A */
307 cfblk->lng_typ = 1; /* Type/length checks OFF */ 306 cfblk->lng_typ = 1; /* Type/length checks OFF */
308 cfblk->lng_fld = 1; /* Disable 802.3 length field check */ 307 cfblk->lng_fld = 1; /* Disable 802.3 length field check */
@@ -312,15 +311,15 @@ static void znet_set_multicast_list (struct net_device *dev)
312 cfblk->tx_jabber = 0; /* Disable jabber jam sequence */ 311 cfblk->tx_jabber = 0; /* Disable jabber jam sequence */
313 cfblk->hash_1 = 1; /* Use bits 0-5 in mc address hash */ 312 cfblk->hash_1 = 1; /* Use bits 0-5 in mc address hash */
314 cfblk->lbpkpol = 0; /* Loopback pin active high */ 313 cfblk->lbpkpol = 0; /* Loopback pin active high */
315 314
316 /* Byte B */ 315 /* Byte B */
317 cfblk->fdx = 0; /* Disable full duplex operation */ 316 cfblk->fdx = 0; /* Disable full duplex operation */
318 317
319 /* Byte C */ 318 /* Byte C */
320 cfblk->dummy_6 = 0x3f; /* all ones, Default multicast addresses & backoff. */ 319 cfblk->dummy_6 = 0x3f; /* all ones, Default multicast addresses & backoff. */
321 cfblk->mult_ia = 0; /* No multiple individual addresses */ 320 cfblk->mult_ia = 0; /* No multiple individual addresses */
322 cfblk->dis_bof = 0; /* Disable the backoff algorithm ?! */ 321 cfblk->dis_bof = 0; /* Disable the backoff algorithm ?! */
323 322
324 /* Byte D */ 323 /* Byte D */
325 cfblk->dummy_1 = 1; /* set to 1 */ 324 cfblk->dummy_1 = 1; /* set to 1 */
326 cfblk->tx_ifs_retrig = 3; /* Hmm... Disabled */ 325 cfblk->tx_ifs_retrig = 3; /* Hmm... Disabled */
@@ -328,7 +327,7 @@ static void znet_set_multicast_list (struct net_device *dev)
328 cfblk->rcv_mon = 0; /* Monitor mode disabled */ 327 cfblk->rcv_mon = 0; /* Monitor mode disabled */
329 cfblk->frag_acpt = 0; /* Do not accept fragments */ 328 cfblk->frag_acpt = 0; /* Do not accept fragments */
330 cfblk->tstrttrs = 0; /* No start transmission threshold */ 329 cfblk->tstrttrs = 0; /* No start transmission threshold */
331 330
332 /* Byte E */ 331 /* Byte E */
333 cfblk->fretx = 1; /* FIFO automatic retransmission */ 332 cfblk->fretx = 1; /* FIFO automatic retransmission */
334 cfblk->runt_eop = 0; /* drop "runt" packets */ 333 cfblk->runt_eop = 0; /* drop "runt" packets */
@@ -351,7 +350,7 @@ static void znet_set_multicast_list (struct net_device *dev)
351 printk ("%02X ", c[i]); 350 printk ("%02X ", c[i]);
352 printk ("\n"); 351 printk ("\n");
353 } 352 }
354 353
355 *znet->tx_cur++ = sizeof(struct i82593_conf_block); 354 *znet->tx_cur++ = sizeof(struct i82593_conf_block);
356 memcpy(znet->tx_cur, cfblk, sizeof(struct i82593_conf_block)); 355 memcpy(znet->tx_cur, cfblk, sizeof(struct i82593_conf_block));
357 znet->tx_cur += sizeof(struct i82593_conf_block)/2; 356 znet->tx_cur += sizeof(struct i82593_conf_block)/2;
@@ -360,7 +359,7 @@ static void znet_set_multicast_list (struct net_device *dev)
360 /* XXX FIXME maz : Add multicast addresses here, so having a 359 /* XXX FIXME maz : Add multicast addresses here, so having a
361 * multicast address configured isn't equal to IFF_ALLMULTI */ 360 * multicast address configured isn't equal to IFF_ALLMULTI */
362} 361}
363 362
364/* The Z-Note probe is pretty easy. The NETIDBLK exists in the safe-to-probe 363/* The Z-Note probe is pretty easy. The NETIDBLK exists in the safe-to-probe
365 BIOS area. We just scan for the signature, and pull the vital parameters 364 BIOS area. We just scan for the signature, and pull the vital parameters
366 out of the structure. */ 365 out of the structure. */
@@ -439,7 +438,7 @@ static int __init znet_probe (void)
439 printk (KERN_WARNING "tx/rx crossing DMA frontiers, giving up\n"); 438 printk (KERN_WARNING "tx/rx crossing DMA frontiers, giving up\n");
440 goto free_tx; 439 goto free_tx;
441 } 440 }
442 441
443 znet->rx_end = znet->rx_start + RX_BUF_SIZE/2; 442 znet->rx_end = znet->rx_start + RX_BUF_SIZE/2;
444 znet->tx_buf_len = TX_BUF_SIZE/2; 443 znet->tx_buf_len = TX_BUF_SIZE/2;
445 znet->tx_end = znet->tx_start + znet->tx_buf_len; 444 znet->tx_end = znet->tx_start + znet->tx_buf_len;
@@ -467,7 +466,7 @@ static int __init znet_probe (void)
467 return err; 466 return err;
468} 467}
469 468
470 469
471static int znet_open(struct net_device *dev) 470static int znet_open(struct net_device *dev)
472{ 471{
473 int ioaddr = dev->base_addr; 472 int ioaddr = dev->base_addr;
@@ -482,7 +481,7 @@ static int znet_open(struct net_device *dev)
482 } 481 }
483 482
484 znet_transceiver_power (dev, 1); 483 znet_transceiver_power (dev, 1);
485 484
486 /* According to the Crynwr driver we should wait 50 msec. for the 485 /* According to the Crynwr driver we should wait 50 msec. for the
487 LAN clock to stabilize. My experiments indicates that the '593 can 486 LAN clock to stabilize. My experiments indicates that the '593 can
488 be initialized immediately. The delay is probably needed for the 487 be initialized immediately. The delay is probably needed for the
@@ -497,7 +496,7 @@ static int znet_open(struct net_device *dev)
497 * all, even if the message is completly harmless on my 496 * all, even if the message is completly harmless on my
498 * setup. */ 497 * setup. */
499 mdelay (50); 498 mdelay (50);
500 499
501 /* This follows the packet driver's lead, and checks for success. */ 500 /* This follows the packet driver's lead, and checks for success. */
502 if (inb(ioaddr) != 0x10 && inb(ioaddr) != 0x00) 501 if (inb(ioaddr) != 0x10 && inb(ioaddr) != 0x00)
503 printk(KERN_WARNING "%s: Problem turning on the transceiver power.\n", 502 printk(KERN_WARNING "%s: Problem turning on the transceiver power.\n",
@@ -548,9 +547,9 @@ static int znet_send_packet(struct sk_buff *skb, struct net_device *dev)
548 return 0; 547 return 0;
549 length = ETH_ZLEN; 548 length = ETH_ZLEN;
550 } 549 }
551 550
552 netif_stop_queue (dev); 551 netif_stop_queue (dev);
553 552
554 /* Check that the part hasn't reset itself, probably from suspend. */ 553 /* Check that the part hasn't reset itself, probably from suspend. */
555 outb(CR0_STATUS_0, ioaddr); 554 outb(CR0_STATUS_0, ioaddr);
556 if (inw(ioaddr) == 0x0010 && 555 if (inw(ioaddr) == 0x0010 &&
@@ -566,7 +565,7 @@ static int znet_send_packet(struct sk_buff *skb, struct net_device *dev)
566 unsigned char *buf = (void *)skb->data; 565 unsigned char *buf = (void *)skb->data;
567 ushort *tx_link = znet->tx_cur - 1; 566 ushort *tx_link = znet->tx_cur - 1;
568 ushort rnd_len = (length + 1)>>1; 567 ushort rnd_len = (length + 1)>>1;
569 568
570 znet->stats.tx_bytes+=length; 569 znet->stats.tx_bytes+=length;
571 570
572 if (znet->tx_cur >= znet->tx_end) 571 if (znet->tx_cur >= znet->tx_end)
@@ -598,7 +597,7 @@ static int znet_send_packet(struct sk_buff *skb, struct net_device *dev)
598 if (znet_debug > 4) 597 if (znet_debug > 4)
599 printk(KERN_DEBUG "%s: Transmitter queued, length %d.\n", dev->name, length); 598 printk(KERN_DEBUG "%s: Transmitter queued, length %d.\n", dev->name, length);
600 } 599 }
601 dev_kfree_skb(skb); 600 dev_kfree_skb(skb);
602 return 0; 601 return 0;
603} 602}
604 603
@@ -617,7 +616,7 @@ static irqreturn_t znet_interrupt(int irq, void *dev_id, struct pt_regs * regs)
617 } 616 }
618 617
619 spin_lock (&znet->lock); 618 spin_lock (&znet->lock);
620 619
621 ioaddr = dev->base_addr; 620 ioaddr = dev->base_addr;
622 621
623 outb(CR0_STATUS_0, ioaddr); 622 outb(CR0_STATUS_0, ioaddr);
@@ -667,7 +666,7 @@ static irqreturn_t znet_interrupt(int irq, void *dev_id, struct pt_regs * regs)
667 * packet. Flip it off, then on to 666 * packet. Flip it off, then on to
668 * reset it. This is very empirical, 667 * reset it. This is very empirical,
669 * but it seems to work. */ 668 * but it seems to work. */
670 669
671 znet_transceiver_power (dev, 0); 670 znet_transceiver_power (dev, 0);
672 znet_transceiver_power (dev, 1); 671 znet_transceiver_power (dev, 1);
673 } 672 }
@@ -683,7 +682,7 @@ static irqreturn_t znet_interrupt(int irq, void *dev_id, struct pt_regs * regs)
683 } while (boguscnt--); 682 } while (boguscnt--);
684 683
685 spin_unlock (&znet->lock); 684 spin_unlock (&znet->lock);
686 685
687 return IRQ_RETVAL(handled); 686 return IRQ_RETVAL(handled);
688} 687}
689 688
@@ -749,7 +748,7 @@ static void znet_rx(struct net_device *dev)
749 ushort *this_rfp_ptr = znet->rx_start + next_frame_end_offset; 748 ushort *this_rfp_ptr = znet->rx_start + next_frame_end_offset;
750 int status = this_rfp_ptr[-4]; 749 int status = this_rfp_ptr[-4];
751 int pkt_len = this_rfp_ptr[-2]; 750 int pkt_len = this_rfp_ptr[-2];
752 751
753 if (znet_debug > 5) 752 if (znet_debug > 5)
754 printk(KERN_DEBUG "Looking at trailer ending at %04x status %04x length %03x" 753 printk(KERN_DEBUG "Looking at trailer ending at %04x status %04x length %03x"
755 " next %04x.\n", next_frame_end_offset<<1, status, pkt_len, 754 " next %04x.\n", next_frame_end_offset<<1, status, pkt_len,
@@ -830,9 +829,9 @@ static int znet_close(struct net_device *dev)
830 printk(KERN_DEBUG "%s: Shutting down ethercard.\n", dev->name); 829 printk(KERN_DEBUG "%s: Shutting down ethercard.\n", dev->name);
831 /* Turn off transceiver power. */ 830 /* Turn off transceiver power. */
832 znet_transceiver_power (dev, 0); 831 znet_transceiver_power (dev, 0);
833 832
834 znet_release_resources (dev); 833 znet_release_resources (dev);
835 834
836 return 0; 835 return 0;
837} 836}
838 837
@@ -857,7 +856,7 @@ static void show_dma(struct net_device *dev)
857 856
858 addr |= inb(dma_port) << 8; 857 addr |= inb(dma_port) << 8;
859 residue = get_dma_residue(znet->tx_dma); 858 residue = get_dma_residue(znet->tx_dma);
860 859
861 if (znet_debug > 1) { 860 if (znet_debug > 1) {
862 flags=claim_dma_lock(); 861 flags=claim_dma_lock();
863 printk(KERN_DEBUG "Stat:%02x Addr: %04x cnt:%3x\n", 862 printk(KERN_DEBUG "Stat:%02x Addr: %04x cnt:%3x\n",
@@ -895,7 +894,7 @@ static void hardware_init(struct net_device *dev)
895 set_dma_count(znet->tx_dma, znet->tx_buf_len<<1); 894 set_dma_count(znet->tx_dma, znet->tx_buf_len<<1);
896 enable_dma(znet->tx_dma); 895 enable_dma(znet->tx_dma);
897 release_dma_lock(flags); 896 release_dma_lock(flags);
898 897
899 if (znet_debug > 1) 898 if (znet_debug > 1)
900 printk(KERN_DEBUG "%s: Initializing the i82593, rx buf %p tx buf %p\n", 899 printk(KERN_DEBUG "%s: Initializing the i82593, rx buf %p tx buf %p\n",
901 dev->name, znet->rx_start,znet->tx_start); 900 dev->name, znet->rx_start,znet->tx_start);