This source file includes following definitions.
- load_csrs
- lance_init_ring
- init_restart_lance
- lance_rx
- lance_tx
- lance_interrupt
- lance_open
- lance_close
- lance_reset
- lance_start_xmit
- lance_get_stats
- lance_set_multicast
- sparc_lance_probe
1
2
3
4
5
6
7
8
9
10
11
12
13 static char *version =
14 "lance.c:v1.2 29/Oct/95 Miguel de Icaza (miguel@nuclecu.unam.mx)\n";
15
16 #include <linux/kernel.h>
17 #include <linux/sched.h>
18 #include <linux/types.h>
19 #include <linux/fcntl.h>
20 #include <linux/interrupt.h>
21 #include <linux/ptrace.h>
22 #include <linux/ioport.h>
23 #include <linux/in.h>
24 #include <linux/malloc.h>
25 #include <linux/string.h>
26 #include <asm/system.h>
27 #include <asm/bitops.h>
28 #include <asm/io.h>
29 #include <asm/dma.h>
30 #include <linux/errno.h>
31 #include <asm/byteorder.h>
32
33
34 #include <linux/socket.h>
35 #include <linux/route.h>
36
37 #include <asm/idprom.h>
38 #include <asm/sbus.h>
39 #include <asm/openprom.h>
40 #include <asm/oplib.h>
41
42 #include <linux/netdevice.h>
43 #include <linux/etherdevice.h>
44 #include <linux/skbuff.h>
45
46 #define MASK_INTERRUPTS 1
47 #define UNMASK_INTERRUPTS 0
48
49
50 #ifndef LANCE_LOG_TX_BUFFERS
51 #define LANCE_LOG_TX_BUFFERS 2
52 #define LANCE_LOG_RX_BUFFERS 4
53 #endif
54
55 #define LE_CSR0 0
56 #define LE_CSR1 1
57 #define LE_CSR2 2
58 #define LE_CSR3 3
59
60 #define LE_MO_PROM 0x8000
61
62 #define LE_C0_ERR 0x8000
63 #define LE_C0_BABL 0x4000
64 #define LE_C0_CERR 0x2000
65 #define LE_C0_MISS 0x1000
66 #define LE_C0_MERR 0x0800
67 #define LE_C0_RINT 0x0400
68 #define LE_C0_TINT 0x0200
69 #define LE_C0_IDON 0x0100
70 #define LE_C0_INTR 0x0080
71 #define LE_C0_INEA 0x0040
72 #define LE_C0_RXON 0x0020
73 #define LE_C0_TXON 0x0010
74 #define LE_C0_TDMD 0x0008
75 #define LE_C0_STOP 0x0004
76 #define LE_C0_STRT 0x0002
77 #define LE_C0_INIT 0x0001
78
79 #define LE_C3_BSWP 0x4
80 #define LE_C3_ACON 0x2
81 #define LE_C3_BCON 0x1
82
83
84 #define LE_R1_OWN 0x80
85 #define LE_R1_ERR 0x40
86 #define LE_R1_FRA 0x20
87 #define LE_R1_OFL 0x10
88 #define LE_R1_CRC 0x08
89 #define LE_R1_BUF 0x04
90 #define LE_R1_SOP 0x02
91 #define LE_R1_EOP 0x01
92 #define LE_R1_POK 0x03
93
94 #define LE_T1_OWN 0x80
95 #define LE_T1_ERR 0x40
96 #define LE_T1_EONE 0x08
97 #define LE_T1_EDEF 0x04
98 #define LE_T1_SOP 0x02
99 #define LE_T1_EOP 0x01
100
101 #define LE_T3_BUF 0x8000
102 #define LE_T3_UFL 0x4000
103 #define LE_T3_LCOL 0x1000
104 #define LE_T3_CLOS 0x0800
105 #define LE_T3_RTY 0x0400
106 #define LE_T3_TDR 0x03ff
107
108 #define TX_RING_SIZE (1 << (LANCE_LOG_TX_BUFFERS))
109 #define TX_RING_MOD_MASK (TX_RING_SIZE - 1)
110 #define TX_RING_LEN_BITS ((LANCE_LOG_TX_BUFFERS) << 29)
111
112 #define RX_RING_SIZE (1 << (LANCE_LOG_RX_BUFFERS))
113 #define RX_RING_MOD_MASK (RX_RING_SIZE - 1)
114 #define RX_RING_LEN_BITS ((LANCE_LOG_RX_BUFFERS) << 29)
115
116 #define PKT_BUF_SZ 1544
117 #define RX_BUFF_SIZE 1536
118 #define TX_BUFF_SIZE 1536
119
120 struct lance_rx_desc {
121 unsigned short rmd0;
122 unsigned char rmd1_bits;
123 unsigned char rmd1_hadr;
124 short length;
125 unsigned short mblength;
126 };
127
128 struct lance_tx_desc {
129 unsigned short tmd0;
130 unsigned char tmd1_bits;
131 unsigned char tmd1_hadr;
132 short length;
133 unsigned short misc;
134 };
135
136
137
138 struct lance_init_block {
139 unsigned short mode;
140 unsigned char phys_addr[6];
141 unsigned filter[2];
142
143
144 unsigned short rx_ptr;
145 unsigned short rx_len;
146 unsigned short tx_ptr;
147 unsigned short tx_len;
148
149
150 struct lance_rx_desc brx_ring[RX_RING_SIZE];
151 struct lance_tx_desc btx_ring[TX_RING_SIZE];
152
153 char rx_buf [RX_RING_SIZE][RX_BUFF_SIZE];
154 char tx_buf [TX_RING_SIZE][TX_BUFF_SIZE];
155 };
156
157 struct lance_private {
158 char *name;
159 volatile struct lance_regs *ll;
160 volatile struct lance_init_block *init_block;
161
162 int rx_new, tx_new;
163 int rx_old, tx_old;
164
165 struct enet_statistics stats;
166 };
167
168 #define TX_BUFFS_AVAIL ((lp->tx_old<=lp->tx_new)?\
169 lp->tx_old+TX_RING_MOD_MASK-lp->tx_new:\
170 lp->tx_old - lp->tx_new-1)
171
172
173 struct lance_regs {
174 unsigned short rdp;
175 unsigned short rap;
176 };
177
178 int sparc_lance_debug = 2;
179
180
181
182 #define LANCE_ADDR(x) ((int)(x) & ~0xff000000)
183
184
185 static void load_csrs (struct lance_private *lp)
186 {
187 volatile struct lance_regs *ll = lp->ll;
188 volatile struct lance_init_block *ib = lp->init_block;
189 int leptr;
190
191 leptr = LANCE_ADDR (ib);
192 ll->rap = LE_CSR1;
193 ll->rdp = (leptr & 0xFFFF);
194 ll->rap = LE_CSR2;
195 ll->rdp = leptr >> 16;
196 ll->rap = LE_CSR3;
197 ll->rdp = LE_C3_BSWP | LE_C3_ACON | LE_C3_BCON;
198
199
200 ll->rap = LE_CSR0;
201 }
202
203 #define ZERO 0
204
205
206
207 static void
208 lance_init_ring (struct device *dev)
209 {
210 struct lance_private *lp = (struct lance_private *) dev->priv;
211 volatile struct lance_init_block *ib = lp->init_block;
212 int leptr;
213 int i;
214
215
216 dev->tbusy = 1;
217 lp->rx_new = lp->tx_new = 0;
218 lp->rx_old = lp->tx_old = 0;
219
220 ib->mode = 0;
221
222
223
224
225 ib->phys_addr [0] = dev->dev_addr [1];
226 ib->phys_addr [1] = dev->dev_addr [0];
227 ib->phys_addr [2] = dev->dev_addr [3];
228 ib->phys_addr [3] = dev->dev_addr [2];
229 ib->phys_addr [4] = dev->dev_addr [5];
230 ib->phys_addr [5] = dev->dev_addr [4];
231
232 if (ZERO)
233 printk ("TX rings:\n");
234
235
236 for (i = 0; i <= TX_RING_SIZE; i++){
237 leptr = LANCE_ADDR(&ib->tx_buf[i][0]);
238 ib->btx_ring [i].tmd0 = leptr;
239 ib->btx_ring [i].tmd1_hadr = leptr >> 16;
240 ib->btx_ring [i].tmd1_bits = 0;
241 ib->btx_ring [i].length = 0xf000;
242 ib->btx_ring [i].misc = 0;
243 if (i < 3)
244 if (ZERO) printk ("%d: 0x%8.8x\n", i, leptr);
245 }
246
247
248 if (ZERO) printk ("RX rings:\n");
249 for (i = 0; i < RX_RING_SIZE; i++){
250 leptr = LANCE_ADDR(&ib->rx_buf[i][0]);
251
252 ib->brx_ring [i].rmd0 = leptr;
253 ib->brx_ring [i].rmd1_hadr = leptr >> 16;
254 ib->brx_ring [i].rmd1_bits = LE_R1_OWN;
255 ib->brx_ring [i].length = -RX_BUFF_SIZE | 0xf000;
256 ib->brx_ring [i].mblength = 0;
257 if (i < 3)
258 if (ZERO) printk ("%d: 0x%8.8x\n", i, leptr);
259 }
260
261
262
263
264 leptr = LANCE_ADDR(&ib->brx_ring);
265 ib->rx_len = (LANCE_LOG_RX_BUFFERS << 13) | (leptr >> 16);
266 ib->rx_ptr = leptr;
267 if (ZERO) printk ("RX ptr: %8.8x\n", leptr);
268
269
270 leptr = LANCE_ADDR(&ib->btx_ring);
271 ib->tx_len = (LANCE_LOG_TX_BUFFERS << 13) | (leptr >> 16);
272 ib->tx_ptr = leptr;
273 if (ZERO) printk ("TX ptr: %8.8x\n", leptr);
274
275
276 ib->filter [0] = 0;
277 ib->filter [1] = 0;
278 }
279
280 static int init_restart_lance (struct lance_private *lp)
281 {
282 volatile struct lance_regs *ll = lp->ll;
283 int i;
284
285 ll->rap = LE_CSR0;
286 ll->rdp = LE_C0_INIT;
287
288
289 for (i = 0; (i < 100) && !(ll->rdp & (LE_C0_ERR | LE_C0_IDON)); i++)
290 ;
291 if ((i == 100) || (ll->rdp & LE_C0_ERR)){
292 printk ("LANCE unopened after %d ticks, csr0=%4.4x.\n", i, ll->rdp);
293 return -1;
294 }
295
296
297 ll->rdp = LE_C0_IDON;
298 ll->rdp = LE_C0_INEA | LE_C0_STRT;
299 printk ("LANCE opened after %d ticks, csr0=%4.4x\n", i, ll->rdp);
300 return 0;
301 }
302
303 static int
304 lance_rx (struct device *dev)
305 {
306 struct lance_private *lp = (struct lance_private *) dev->priv;
307 volatile struct lance_init_block *ib = lp->init_block;
308 volatile struct lance_regs *ll = lp->ll;
309 volatile struct lance_rx_desc *rd;
310 int i;
311 int entry;
312 unsigned char bits;
313
314 #ifdef TEST_HITS
315 printk ("[");
316 for (i = 0; i < RX_RING_SIZE; i++){
317 if (i == lp->rx_new)
318 printk ("%s", ib->brx_ring [i].rmd1_bits & LE_R1_OWN ? "_" : "X");
319 else
320 printk ("%s", ib->brx_ring [i].rmd1_bits & LE_R1_OWN ? "." : "1");
321 }
322 printk ("]");
323 #endif
324
325 #ifdef OLD_METHOD
326 ll->rdp = LE_C0_RINT|LE_C0_INEA;
327
328 for (rd = &ib->brx_ring [i = 0]; i < RX_RING_SIZE; i++, rd++){
329 int bits;
330
331 bits = rd->rmd1_bits;
332
333
334 if (bits & LE_R1_OWN)
335 continue;
336
337
338 if ((bits & LE_R1_POK) != LE_R1_POK){
339
340 if (bits & LE_R1_EOP) lp->stats.rx_errors++;
341 if (bits & LE_R1_BUF) lp->stats.rx_fifo_errors++;
342 if (bits & LE_R1_CRC) lp->stats.rx_crc_errors++;
343 if (bits & LE_R1_OFL) lp->stats.rx_over_errors++;
344 if (bits & LE_R1_FRA) lp->stats.rx_frame_errors++;
345 } else {
346 int pkt_len = rd->mblength;
347 struct sk_buff *skb;
348 char *buf;
349
350 skb = dev_alloc_skb (pkt_len+2);
351 if (skb == NULL){
352 printk ("%s: Memory squeeze, deferring packet.\n", dev->name);
353 lp->stats.rx_dropped++;
354 rd->rmd1_bits = LE_R1_OWN;
355 return 0;
356 }
357
358 skb->dev = dev;
359 skb_reserve (skb, 2);
360 buf = skb_put (skb, pkt_len);
361 memcpy (buf, &(ib->rx_buf [i][0]), pkt_len);
362 skb->protocol = eth_type_trans (skb,dev);
363 netif_rx (skb);
364 lp->stats.rx_packets++;
365 }
366
367
368 rd->rmd1_bits = LE_R1_OWN;
369 }
370 #else
371 ll->rdp = LE_C0_RINT|LE_C0_INEA;
372 for (rd = &ib->brx_ring [lp->rx_new];
373 !((bits = rd->rmd1_bits) & LE_R1_OWN);
374 rd = &ib->brx_ring [lp->rx_new]){
375
376
377 if ((bits & LE_R1_POK) != LE_R1_POK){
378 printk ("Incomplete frame\n");
379
380 if (bits & LE_R1_EOP) lp->stats.rx_errors++;
381 if (bits & LE_R1_BUF) lp->stats.rx_fifo_errors++;
382 if (bits & LE_R1_CRC) lp->stats.rx_crc_errors++;
383 if (bits & LE_R1_OFL) lp->stats.rx_over_errors++;
384 if (bits & LE_R1_FRA) lp->stats.rx_frame_errors++;
385 } else {
386 int pkt_len = rd->mblength;
387 struct sk_buff *skb;
388 char *buf;
389
390 skb = dev_alloc_skb (pkt_len+2);
391 if (skb == NULL){
392 printk ("%s: Memory squeeze, deferring packet.\n", dev->name);
393 lp->stats.rx_dropped++;
394 rd->rmd1_bits = LE_R1_OWN;
395 lp->rx_new = (lp->rx_new + 1) & RX_RING_MOD_MASK;
396 return 0;
397 }
398
399 skb->dev = dev;
400 skb_reserve (skb, 2);
401 buf = skb_put (skb, pkt_len);
402 memcpy (buf, (char *) &(ib->rx_buf [lp->rx_new][0]), pkt_len);
403 skb->protocol = eth_type_trans (skb,dev);
404 netif_rx (skb);
405 lp->stats.rx_packets++;
406 }
407
408
409 rd->rmd1_bits = LE_R1_OWN;
410 lp->rx_new = (lp->rx_new + 1) & RX_RING_MOD_MASK;
411 }
412 #endif
413 return 0;
414 }
415
416 static int
417 lance_tx (struct device *dev)
418 {
419 struct lance_private *lp = (struct lance_private *) dev->priv;
420 volatile struct lance_init_block *ib = lp->init_block;
421 volatile struct lance_regs *ll = lp->ll;
422 volatile struct lance_tx_desc *td;
423 int i, j;
424 int status;
425
426
427 ll->rdp = LE_C0_TINT | LE_C0_INEA;
428
429 j = lp->tx_old;
430 for (i = 0; i < TX_RING_SIZE; i++){
431 td = &ib->btx_ring [j];
432
433 if (td->tmd1_bits & LE_T1_ERR){
434 status = td->misc;
435
436 if (status & LE_T3_RTY) lp->stats.tx_aborted_errors++;
437 if (status & LE_T3_CLOS) lp->stats.tx_carrier_errors++;
438 if (status & LE_T3_LCOL) lp->stats.tx_window_errors++;
439
440
441
442 if (status & (LE_T3_BUF|LE_T3_UFL)){
443 lp->stats.tx_fifo_errors++;
444
445 printk ("%s: Tx: ERR_BUF|ERR_UFL, restarting\n", dev->name);
446
447 ll->rdp = LE_CSR0;
448 ll->rap = LE_C0_STOP;
449 init_restart_lance (lp);
450 }
451 }
452
453 j = (j + 1) & TX_RING_MOD_MASK;
454 }
455 lp->tx_old = (lp->tx_old+1) & TX_RING_MOD_MASK;
456
457 ll->rdp = LE_C0_TINT | LE_C0_INEA;
458 return 0;
459 }
460
461 static void
462 lance_interrupt (int irq, struct pt_regs *regs)
463 {
464 struct device *dev = (struct device *) (irq2dev_map [irq]);
465 struct lance_private *lp;
466 volatile struct lance_regs *ll;
467 int csr0;
468
469 lp = (struct lance_private *) dev->priv;
470 ll = lp->ll;
471
472 if (dev->interrupt)
473 printk ("%s: again", dev->name);
474
475 dev->interrupt = 1;
476
477 csr0 = ll->rdp;
478
479
480 ll->rdp = csr0 & 0x004f;
481
482 if ((csr0 & LE_C0_ERR)){
483
484 ll->rdp = LE_C0_BABL|LE_C0_ERR|LE_C0_MISS|LE_C0_INEA;
485 }
486
487 if (csr0 & LE_C0_RINT){
488 lance_rx (dev);
489 }
490
491 if (csr0 & LE_C0_TINT){
492 lance_tx (dev);
493 }
494
495 if ((TX_BUFFS_AVAIL >= 0) && dev->tbusy){
496 dev->tbusy = 0;
497 mark_bh (NET_BH);
498 }
499 ll->rap = 0;
500 ll->rdp = 0x7940;
501
502 dev->interrupt = 0;
503 }
504
505 struct device *last_dev = 0;
506
507 static int
508 lance_open (struct device *dev)
509 {
510 struct lance_private *lp = (struct lance_private *)dev->priv;
511 volatile struct lance_regs *ll = lp->ll;
512 int status = 0;
513
514 last_dev = dev;
515
516
517 ll->rap = LE_CSR0;
518 ll->rdp = LE_C0_STOP;
519
520 if (request_irq (dev->irq, &lance_interrupt, 0, "LANCE")){
521 printk ("Lance: Can't get irq %d\n", dev->irq);
522 return -EAGAIN;
523 }
524 irq2dev_map [dev->irq] = dev;
525
526 lance_init_ring (dev);
527 load_csrs (lp);
528
529 dev->tbusy = 0;
530 dev->interrupt = 0;
531 dev->start = 1;
532
533 status = init_restart_lance (lp);
534
535
536 {
537 struct rtentry server_route;
538 struct sockaddr_in *sin;
539
540 sin=(struct sockaddr_in *)&server_route.rt_dst;
541 *sin=server;
542 sin=(struct sockaddr_in *)&server_route.rt_genmask;
543 sin->sin_family=AF_INET;
544 sin->sin_addr.s_addr= ip_get_mask (dev->pa_addr);
545 server_route.rt_dev[0]=dev;
546 server_route.
547 server_route.rt_flags=RTF_HOST|RTF_UP;
548
549 if(ip_rt_new(&server_route)==-1)
550 printk("Unable to add NFS server route.\n");
551 }
552 ip_rt_add (RTF_UP,
553 dev->pa_addr & ip_get_mask (dev->pa_addr),
554 ip_get_mask (dev->pa_addr),
555 0, dev, dev->mtu, 0, 0);
556 return status;
557 }
558
559 static int
560 lance_close (struct device *dev)
561 {
562 struct lance_private *lp = (struct lance_private *) dev->priv;
563 volatile struct lance_regs *ll = lp->ll;
564
565 dev->start = 0;
566 dev->tbusy = 1;
567
568
569 ll->rap = LE_CSR0;
570 ll->rdp = LE_C0_STOP;
571
572 free_irq (dev->irq);
573 irq2dev_map [dev->irq] = NULL;
574
575 return 0;
576 }
577
578 inline static int lance_reset (struct device *dev)
579 {
580 struct lance_private *lp = (struct lance_private *)dev->priv;
581 volatile struct lance_regs *ll = lp->ll;
582 int status;
583
584
585 ll->rdp = LE_CSR0;
586 ll->rap = LE_C0_STOP;
587 #ifdef DEBUG_DRIVER
588 printk ("Lance stopped: csr0=%4.4x\n", ll->rdp);
589 #endif
590 lance_init_ring (dev);
591 load_csrs (lp);
592 dev->trans_start = jiffies;
593 dev->interrupt = 0;
594 dev->start = 1;
595 dev->tbusy = 0;
596 status = init_restart_lance (lp);
597 #ifdef DEBUG_DRIVER
598 printk ("Lance restart=%d\n", status);
599 #endif
600 }
601
602 static int lance_start_xmit (struct sk_buff *skb, struct device *dev)
603 {
604 struct lance_private *lp = (struct lance_private *)dev->priv;
605 volatile struct lance_regs *ll = lp->ll;
606 volatile struct lance_init_block *ib = lp->init_block;
607 int entry, skblen, len;
608 int status = 0;
609 static int outs;
610
611
612 if (dev->tbusy){
613 int tickssofar = jiffies - dev->trans_start;
614
615 if (tickssofar < 100)
616 status = -1;
617 else {
618 printk ("%s: trasmit timed out, status %04x, resetting\n",
619 dev->name, ll->rdp);
620 lance_reset (dev);
621 }
622 return status;
623 }
624
625 if (skb == NULL){
626 dev_tint (dev);
627 printk ("skb is NULL\n");
628 return 0;
629 }
630
631 if (skb->len <= 0){
632 printk ("skb len is %ld\n", skb->len);
633 return 0;
634 }
635
636 #ifdef OLD_METHOD
637 dev->tbusy = 1;
638 #else
639 if (set_bit (0, (void *) &dev->tbusy) != 0){
640 printk ("Transmitter access conflict.\n");
641 return -1;
642 }
643 #endif
644 skblen = skb->len;
645
646 if (!TX_BUFFS_AVAIL){
647 return -1;
648 }
649
650 #ifdef DEBUG_DRIVER
651
652 for (i = 0; i < 64; i++){
653 if ((i % 16) == 0) printk ("\n");
654 printk ("%2.2x ", skb->data [i]);
655 }
656 #endif
657 len = (skblen < ETH_ZLEN) ? ETH_ZLEN : skblen;
658 entry = lp->tx_new & TX_RING_MOD_MASK;
659 ib->btx_ring [entry].length = (-len) | 0xf000;
660 ib->btx_ring [entry].misc = 0;
661
662 memcpy ((char *)&ib->tx_buf [entry][0], skb->data, skblen);
663
664
665 if (len != skblen){
666 memset ((char *) &ib->tx_buf [entry][skblen], 0, len - skblen);
667 }
668
669
670
671 ib->btx_ring [entry].tmd1_bits = (LE_T1_SOP|LE_T1_EOP|LE_T1_OWN);
672 lp->tx_new = (lp->tx_new+1) & TX_RING_MOD_MASK;
673
674 outs++;
675
676 ll->rdp = LE_C0_INEA | LE_C0_TDMD;
677 dev->trans_start = jiffies;
678 dev_kfree_skb (skb, FREE_WRITE);
679
680 if (TX_BUFFS_AVAIL)
681 dev->tbusy = 0;
682
683 return status;
684 }
685
686 static struct enet_statistics *
687 lance_get_stats (struct device *dev)
688 {
689 struct lance_private *lp = (struct lance_private *) dev->priv;
690
691 return &lp->stats;
692 }
693
694 static void
695 lance_set_multicast (struct device *dev)
696 {
697 #ifdef NOT_YET
698 struct lance_private *lp = (struct lance_private *) dev->priv;
699 volatile struct lance_init_block *ib = lp->init_block;
700 volatile struct lance_regs *ll = lp->ll;
701
702 ll->rdp = LE_CSR0;
703 ll->rap = LE_C0_STOP;
704 lance_init_ring (dev);
705 if (num_addrs >= 0){
706 printk ("Ignoring set_multicast\n");
707 } else {
708 ib->mode |= LE_MO_PROM;
709 }
710 lance_init_ring (dev);
711 load_csrs (lp);
712 init_restart_lance (lp);
713 dev->tbusy = 0;
714 #endif
715 }
716
717 int sparc_lance_probe (struct device *dev)
718 {
719 static unsigned version_printed = 0;
720 int i;
721 int found = 0;
722 struct linux_sbus *bus;
723 struct linux_sbus_device *sdev = 0;
724 struct lance_private *lp;
725 volatile struct lance_regs *ll;
726
727 #ifdef DEBUG_DRIVER
728 printk ("Lance probe...0x%p\n", SBus_chain);
729 #endif
730 for_each_sbus (bus){
731 for_each_sbusdev (sdev, bus){
732 if (strcmp (sdev->prom_name, "le") == 0){
733 found = 1;
734 break;
735 }
736 }
737 }
738 if (!found)
739 return ENODEV;
740
741 if (dev == NULL){
742 printk ("LANCE buffer @0x0. You don't really want this\n");
743 dev = init_etherdev (0, sizeof (struct lance_private));
744 } else {
745 dev->priv = kmalloc (sizeof (struct lance_private), GFP_KERNEL);
746 }
747 if (sparc_lance_debug && version_printed++ == 0)
748 printk (version);
749
750 printk ("%s: LANCE ", dev->name);
751
752 dev->base_addr = (long) sdev;
753
754
755
756
757
758 for (i = 0; i < 6; i++){
759 printk ("%2.2x%c", dev->dev_addr [i] = idprom->id_eaddr [i], i == 5 ? ' ': ':');
760 }
761
762 ll = sparc_alloc_io (sdev->reg_addrs [0].phys_addr, 0,
763 sizeof (struct lance_regs), "Lance driver", 0x0, 0x0);
764
765
766 dev->priv = (void *)(((int)dev->priv + 7) & ~7);
767 lp = (struct lance_private *) dev->priv;
768
769 lp->init_block = (void *)
770 sparc_dvma_malloc (sizeof (struct lance_init_block), "LANCE");
771
772 lp->ll = ll;
773 lp->name = "LANCE";
774
775
776 if ((int)(lp->init_block->brx_ring) & 0x07) {
777 printk(" **ERROR** LANCE Rx and Tx rings not on even boundary.\n");
778 return ENODEV;
779 }
780
781 dev->open = &lance_open;
782 dev->stop = &lance_close;
783 dev->hard_start_xmit = &lance_start_xmit;
784 dev->get_stats = &lance_get_stats;
785 dev->set_multicast_list = &lance_set_multicast;
786
787 dev->irq = (unsigned char) sdev->irqs [0].pri;
788 dev->dma = 0;
789 ether_setup (dev);
790
791 return 0;
792 }
793
794
795
796
797
798
799