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