2 * sgiseeq.c: Seeq8003 ethernet driver for SGI machines.
4 * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com)
6 #include <linux/kernel.h>
7 #include <linux/module.h>
8 #include <linux/errno.h>
9 #include <linux/init.h>
10 #include <linux/types.h>
11 #include <linux/interrupt.h>
12 #include <linux/ioport.h>
13 #include <linux/socket.h>
15 #include <linux/route.h>
16 #include <linux/slab.h>
17 #include <linux/string.h>
18 #include <linux/delay.h>
19 #include <linux/netdevice.h>
20 #include <linux/etherdevice.h>
21 #include <linux/skbuff.h>
23 #include <asm/byteorder.h>
25 #include <asm/system.h>
26 #include <asm/bitops.h>
28 #include <asm/pgtable.h>
29 #include <asm/sgi/hpc3.h>
30 #include <asm/sgi/ip22.h>
31 #include <asm/sgialib.h>
35 static char *version
= "sgiseeq.c: David S. Miller (dm@engr.sgi.com)\n";
37 static char *sgiseeqstr
= "SGI Seeq8003";
40 * If you want speed, you do something silly, it always has worked for me. So,
41 * with that in mind, I've decided to make this driver look completely like a
42 * stupid Lance from a driver architecture perspective. Only difference is that
43 * here our "ring buffer" looks and acts like a real Lance one does but is
44 * layed out like how the HPC DMA and the Seeq want it to. You'd be surprised
45 * how a stupid idea like this can pay off in performance, not to mention
46 * making this driver 2,000 times easier to write. ;-)
49 /* Tune these if we tend to run out often etc. */
50 #define SEEQ_RX_BUFFERS 16
51 #define SEEQ_TX_BUFFERS 16
53 #define PKT_BUF_SZ 1584
55 #define NEXT_RX(i) (((i) + 1) & (SEEQ_RX_BUFFERS - 1))
56 #define NEXT_TX(i) (((i) + 1) & (SEEQ_TX_BUFFERS - 1))
57 #define PREV_RX(i) (((i) - 1) & (SEEQ_RX_BUFFERS - 1))
58 #define PREV_TX(i) (((i) - 1) & (SEEQ_TX_BUFFERS - 1))
60 #define TX_BUFFS_AVAIL(sp) ((sp->tx_old <= sp->tx_new) ? \
61 sp->tx_old + (SEEQ_TX_BUFFERS - 1) - sp->tx_new : \
62 sp->tx_old - sp->tx_new - 1)
66 struct sgiseeq_rx_desc
{
67 struct hpc_dma_desc rdma
;
71 struct sgiseeq_tx_desc
{
72 struct hpc_dma_desc tdma
;
77 * Warning: This structure is layed out in a certain way because HPC dma
78 * descriptors must be 8-byte aligned. So don't touch this without
81 struct sgiseeq_init_block
{ /* Note the name ;-) */
82 /* Ptrs to the descriptors in KSEG1 uncached space. */
83 struct sgiseeq_rx_desc
*rx_desc
;
84 struct sgiseeq_tx_desc
*tx_desc
;
85 unsigned int _padding
[30]; /* Pad out to largest cache line size. */
87 struct sgiseeq_rx_desc rxvector
[SEEQ_RX_BUFFERS
];
88 struct sgiseeq_tx_desc txvector
[SEEQ_TX_BUFFERS
];
91 struct sgiseeq_private
{
92 volatile struct sgiseeq_init_block srings
;
94 struct hpc3_ethregs
*hregs
;
95 struct sgiseeq_regs
*sregs
;
97 /* Ring entry counters. */
98 unsigned int rx_new
, tx_new
;
99 unsigned int rx_old
, tx_old
;
102 unsigned char control
;
105 struct net_device_stats stats
;
107 struct net_device
*next_module
;
111 /* A list of all installed seeq devices, for removing the driver module. */
112 static struct net_device
*root_sgiseeq_dev
;
114 static inline void hpc3_eth_reset(struct hpc3_ethregs
*hregs
)
116 hregs
->rx_reset
= (HPC3_ERXRST_CRESET
| HPC3_ERXRST_CLRIRQ
);
121 static inline void reset_hpc3_and_seeq(struct hpc3_ethregs
*hregs
,
122 struct sgiseeq_regs
*sregs
)
124 hregs
->rx_ctrl
= hregs
->tx_ctrl
= 0;
125 hpc3_eth_reset(hregs
);
128 #define RSTAT_GO_BITS (SEEQ_RCMD_IGOOD | SEEQ_RCMD_IEOF | SEEQ_RCMD_ISHORT | \
129 SEEQ_RCMD_IDRIB | SEEQ_RCMD_ICRC)
131 static inline void seeq_go(struct sgiseeq_private
*sp
,
132 struct hpc3_ethregs
*hregs
,
133 struct sgiseeq_regs
*sregs
)
135 sregs
->rstat
= sp
->mode
| RSTAT_GO_BITS
;
136 hregs
->rx_ctrl
= HPC3_ERXCTRL_ACTIVE
;
139 static inline void seeq_load_eaddr(struct net_device
*dev
,
140 struct sgiseeq_regs
*sregs
)
144 sregs
->tstat
= SEEQ_TCMD_RB0
;
145 for (i
= 0; i
< 6; i
++)
146 sregs
->rw
.eth_addr
[i
] = dev
->dev_addr
[i
];
149 #define TCNTINFO_INIT (HPCDMA_EOX | HPCDMA_ETXD)
150 #define RCNTCFG_INIT (HPCDMA_OWN | HPCDMA_EORP | HPCDMA_XIE)
151 #define RCNTINFO_INIT (RCNTCFG_INIT | (PKT_BUF_SZ & HPCDMA_BCNT))
153 static int seeq_init_ring(struct net_device
*dev
)
155 struct sgiseeq_private
*sp
= (struct sgiseeq_private
*) dev
->priv
;
156 volatile struct sgiseeq_init_block
*ib
= &sp
->srings
;
159 netif_stop_queue(dev
);
160 sp
->rx_new
= sp
->tx_new
= 0;
161 sp
->rx_old
= sp
->tx_old
= 0;
163 seeq_load_eaddr(dev
, sp
->sregs
);
165 /* XXX for now just accept packets directly to us
166 * XXX and ether-broadcast. Will do multicast and
167 * XXX promiscuous mode later. -davem
169 sp
->mode
= SEEQ_RCMD_RBCAST
;
172 for(i
= 0; i
< SEEQ_TX_BUFFERS
; i
++) {
173 if (!ib
->tx_desc
[i
].tdma
.pbuf
) {
174 unsigned long buffer
;
176 buffer
= (unsigned long) kmalloc(PKT_BUF_SZ
, GFP_KERNEL
);
179 ib
->tx_desc
[i
].buf_vaddr
= KSEG1ADDR(buffer
);
180 ib
->tx_desc
[i
].tdma
.pbuf
= virt_to_bus(buffer
);
182 ib
->tx_desc
[i
].tdma
.cntinfo
= (TCNTINFO_INIT
);
185 /* And now the rx ring. */
186 for (i
= 0; i
< SEEQ_RX_BUFFERS
; i
++) {
187 if (!ib
->rx_desc
[i
].rdma
.pbuf
) {
188 unsigned long buffer
;
190 buffer
= (unsigned long) kmalloc(PKT_BUF_SZ
, GFP_KERNEL
);
193 ib
->rx_desc
[i
].buf_vaddr
= KSEG1ADDR(buffer
);
194 ib
->rx_desc
[i
].rdma
.pbuf
= virt_to_bus(buffer
);
196 ib
->rx_desc
[i
].rdma
.cntinfo
= (RCNTINFO_INIT
);
198 ib
->rx_desc
[i
- 1].rdma
.cntinfo
|= (HPCDMA_EOR
);
203 static struct sgiseeq_private
*gpriv
;
204 static struct net_device
*gdev
;
206 void sgiseeq_dump_rings(void)
209 struct sgiseeq_rx_desc
*r
= gpriv
->srings
.rx_desc
;
210 struct sgiseeq_tx_desc
*t
= gpriv
->srings
.tx_desc
;
211 struct hpc3_ethregs
*hregs
= gpriv
->hregs
;
217 printk("RING DUMP:\n");
218 for (i
= 0; i
< SEEQ_RX_BUFFERS
; i
++) {
219 printk("RX [%d]: @(%p) [%08x,%08x,%08x] ",
220 i
, (&r
[i
]), r
[i
].rdma
.pbuf
, r
[i
].rdma
.cntinfo
,
223 printk("-- [%d]: @(%p) [%08x,%08x,%08x]\n",
224 i
, (&r
[i
]), r
[i
].rdma
.pbuf
, r
[i
].rdma
.cntinfo
,
227 for (i
= 0; i
< SEEQ_TX_BUFFERS
; i
++) {
228 printk("TX [%d]: @(%p) [%08x,%08x,%08x] ",
229 i
, (&t
[i
]), t
[i
].tdma
.pbuf
, t
[i
].tdma
.cntinfo
,
232 printk("-- [%d]: @(%p) [%08x,%08x,%08x]\n",
233 i
, (&t
[i
]), t
[i
].tdma
.pbuf
, t
[i
].tdma
.cntinfo
,
236 printk("INFO: [rx_new = %d rx_old=%d] [tx_new = %d tx_old = %d]\n",
237 gpriv
->rx_new
, gpriv
->rx_old
, gpriv
->tx_new
, gpriv
->tx_old
);
238 printk("RREGS: rx_cbptr[%08x] rx_ndptr[%08x] rx_ctrl[%08x]\n",
239 hregs
->rx_cbptr
, hregs
->rx_ndptr
, hregs
->rx_ctrl
);
240 printk("TREGS: tx_cbptr[%08x] tx_ndptr[%08x] tx_ctrl[%08x]\n",
241 hregs
->tx_cbptr
, hregs
->tx_ndptr
, hregs
->tx_ctrl
);
245 #define TSTAT_INIT_SEEQ (SEEQ_TCMD_IPT|SEEQ_TCMD_I16|SEEQ_TCMD_IC|SEEQ_TCMD_IUF)
246 #define TSTAT_INIT_EDLC ((TSTAT_INIT_SEEQ) | SEEQ_TCMD_RB2)
247 #define RDMACFG_INIT (HPC3_ERXDCFG_FRXDC | HPC3_ERXDCFG_FEOP | HPC3_ERXDCFG_FIRQ)
249 static int init_seeq(struct net_device
*dev
, struct sgiseeq_private
*sp
,
250 struct sgiseeq_regs
*sregs
)
252 struct hpc3_ethregs
*hregs
= sp
->hregs
;
255 reset_hpc3_and_seeq(hregs
, sregs
);
256 err
= seeq_init_ring(dev
);
260 /* Setup to field the proper interrupt types. */
262 sregs
->tstat
= (TSTAT_INIT_EDLC
);
263 sregs
->rw
.wregs
.control
= sp
->control
;
264 sregs
->rw
.wregs
.frame_gap
= 0;
266 sregs
->tstat
= (TSTAT_INIT_SEEQ
);
269 hregs
->rx_dconfig
|= RDMACFG_INIT
;
271 hregs
->rx_ndptr
= virt_to_bus(sp
->srings
.rx_desc
);
272 hregs
->tx_ndptr
= virt_to_bus(sp
->srings
.tx_desc
);
274 seeq_go(sp
, hregs
, sregs
);
278 static inline void record_rx_errors(struct sgiseeq_private
*sp
,
279 unsigned char status
)
281 if (status
& SEEQ_RSTAT_OVERF
||
282 status
& SEEQ_RSTAT_SFRAME
)
283 sp
->stats
.rx_over_errors
++;
284 if (status
& SEEQ_RSTAT_CERROR
)
285 sp
->stats
.rx_crc_errors
++;
286 if (status
& SEEQ_RSTAT_DERROR
)
287 sp
->stats
.rx_frame_errors
++;
288 if (status
& SEEQ_RSTAT_REOF
)
289 sp
->stats
.rx_errors
++;
292 static inline void rx_maybe_restart(struct sgiseeq_private
*sp
,
293 struct hpc3_ethregs
*hregs
,
294 struct sgiseeq_regs
*sregs
)
296 if (!(hregs
->rx_ctrl
& HPC3_ERXCTRL_ACTIVE
)) {
297 hregs
->rx_ndptr
= virt_to_bus(sp
->srings
.rx_desc
+ sp
->rx_new
);
298 seeq_go(sp
, hregs
, sregs
);
302 #define for_each_rx(rd, sp) for((rd) = &(sp)->srings.rx_desc[(sp)->rx_new]; \
303 !((rd)->rdma.cntinfo & HPCDMA_OWN); \
304 (rd) = &(sp)->srings.rx_desc[(sp)->rx_new])
306 static inline void sgiseeq_rx(struct net_device
*dev
, struct sgiseeq_private
*sp
,
307 struct hpc3_ethregs
*hregs
,
308 struct sgiseeq_regs
*sregs
)
310 struct sgiseeq_rx_desc
*rd
;
311 struct sk_buff
*skb
= 0;
312 unsigned char pkt_status
;
313 unsigned char *pkt_pointer
= 0;
315 unsigned int orig_end
= PREV_RX(sp
->rx_new
);
317 /* Service every received packet. */
318 for_each_rx(rd
, sp
) {
319 len
= (PKT_BUF_SZ
- (rd
->rdma
.cntinfo
& HPCDMA_BCNT
) - 3);
320 pkt_pointer
= (unsigned char *)(long)rd
->buf_vaddr
;
321 pkt_status
= pkt_pointer
[len
+ 2];
323 if (pkt_status
& SEEQ_RSTAT_FIG
) {
325 skb
= dev_alloc_skb(len
+ 2);
332 /* Copy out of kseg1 to avoid silly cache flush. */
333 eth_copy_and_sum(skb
, pkt_pointer
+ 2, len
, 0);
334 skb
->protocol
= eth_type_trans(skb
, dev
);
336 dev
->last_rx
= jiffies
;
337 sp
->stats
.rx_packets
++;
338 sp
->stats
.rx_bytes
+= len
;
340 printk (KERN_NOTICE
"%s: Memory squeeze, deferring packet.\n",
342 sp
->stats
.rx_dropped
++;
345 record_rx_errors(sp
, pkt_status
);
348 /* Return the entry to the ring pool. */
349 rd
->rdma
.cntinfo
= (RCNTINFO_INIT
);
350 sp
->rx_new
= NEXT_RX(sp
->rx_new
);
352 sp
->srings
.rx_desc
[orig_end
].rdma
.cntinfo
&= ~(HPCDMA_EOR
);
353 sp
->srings
.rx_desc
[PREV_RX(sp
->rx_new
)].rdma
.cntinfo
|= HPCDMA_EOR
;
354 rx_maybe_restart(sp
, hregs
, sregs
);
357 static inline void tx_maybe_reset_collisions(struct sgiseeq_private
*sp
,
358 struct sgiseeq_regs
*sregs
)
361 sregs
->rw
.wregs
.control
= sp
->control
& ~(SEEQ_CTRL_XCNT
);
362 sregs
->rw
.wregs
.control
= sp
->control
;
366 static inline void kick_tx(struct sgiseeq_tx_desc
*td
,
367 struct hpc3_ethregs
*hregs
)
369 /* If the HPC aint doin nothin, and there are more packets
370 * with ETXD cleared and XIU set we must make very certain
371 * that we restart the HPC else we risk locking up the
372 * adapter. The following code is only safe iff the HPCDMA
375 while ((td
->tdma
.cntinfo
& (HPCDMA_XIU
| HPCDMA_ETXD
)) ==
376 (HPCDMA_XIU
| HPCDMA_ETXD
))
377 td
= (struct sgiseeq_tx_desc
*)(long) KSEG1ADDR(td
->tdma
.pnext
);
378 if (td
->tdma
.cntinfo
& HPCDMA_XIU
) {
379 hregs
->tx_ndptr
= virt_to_bus(td
);
380 hregs
->tx_ctrl
= HPC3_ETXCTRL_ACTIVE
;
384 static inline void sgiseeq_tx(struct net_device
*dev
, struct sgiseeq_private
*sp
,
385 struct hpc3_ethregs
*hregs
,
386 struct sgiseeq_regs
*sregs
)
388 struct sgiseeq_tx_desc
*td
;
389 unsigned long status
= hregs
->tx_ctrl
;
392 tx_maybe_reset_collisions(sp
, sregs
);
394 if (!(status
& (HPC3_ETXCTRL_ACTIVE
| SEEQ_TSTAT_PTRANS
))) {
395 /* Oops, HPC detected some sort of error. */
396 if (status
& SEEQ_TSTAT_R16
)
397 sp
->stats
.tx_aborted_errors
++;
398 if (status
& SEEQ_TSTAT_UFLOW
)
399 sp
->stats
.tx_fifo_errors
++;
400 if (status
& SEEQ_TSTAT_LCLS
)
401 sp
->stats
.collisions
++;
405 for (j
= sp
->tx_old
; j
!= sp
->tx_new
; j
= NEXT_TX(j
)) {
406 td
= &sp
->srings
.tx_desc
[j
];
408 if (!(td
->tdma
.cntinfo
& (HPCDMA_XIU
)))
410 if (!(td
->tdma
.cntinfo
& (HPCDMA_ETXD
))) {
411 if (!(status
& HPC3_ETXCTRL_ACTIVE
)) {
412 hregs
->tx_ndptr
= virt_to_bus(td
);
413 hregs
->tx_ctrl
= HPC3_ETXCTRL_ACTIVE
;
417 sp
->stats
.tx_packets
++;
418 sp
->tx_old
= NEXT_TX(sp
->tx_old
);
419 td
->tdma
.cntinfo
&= ~(HPCDMA_XIU
| HPCDMA_XIE
);
420 td
->tdma
.cntinfo
|= HPCDMA_EOX
;
424 static irqreturn_t
sgiseeq_interrupt(int irq
, void *dev_id
, struct pt_regs
*regs
)
426 struct net_device
*dev
= (struct net_device
*) dev_id
;
427 struct sgiseeq_private
*sp
= (struct sgiseeq_private
*) dev
->priv
;
428 struct hpc3_ethregs
*hregs
= sp
->hregs
;
429 struct sgiseeq_regs
*sregs
= sp
->sregs
;
431 spin_lock(&sp
->tx_lock
);
433 /* Ack the IRQ and set software state. */
434 hregs
->rx_reset
= HPC3_ERXRST_CLRIRQ
;
436 /* Always check for received packets. */
437 sgiseeq_rx(dev
, sp
, hregs
, sregs
);
439 /* Only check for tx acks if we have something queued. */
440 if (sp
->tx_old
!= sp
->tx_new
)
441 sgiseeq_tx(dev
, sp
, hregs
, sregs
);
443 if ((TX_BUFFS_AVAIL(sp
) > 0) && netif_queue_stopped(dev
)) {
444 netif_wake_queue(dev
);
446 spin_unlock(&sp
->tx_lock
);
451 static int sgiseeq_open(struct net_device
*dev
)
453 struct sgiseeq_private
*sp
= (struct sgiseeq_private
*)dev
->priv
;
454 struct sgiseeq_regs
*sregs
= sp
->sregs
;
456 int err
= init_seeq(dev
, sp
, sregs
);
460 netif_start_queue(dev
);
465 static int sgiseeq_close(struct net_device
*dev
)
467 struct sgiseeq_private
*sp
= (struct sgiseeq_private
*) dev
->priv
;
468 struct sgiseeq_regs
*sregs
= sp
->sregs
;
470 netif_stop_queue(dev
);
472 /* Shutdown the Seeq. */
473 reset_hpc3_and_seeq(sp
->hregs
, sregs
);
478 static inline int sgiseeq_reset(struct net_device
*dev
)
480 struct sgiseeq_private
*sp
= (struct sgiseeq_private
*) dev
->priv
;
481 struct sgiseeq_regs
*sregs
= sp
->sregs
;
484 err
= init_seeq(dev
, sp
, sregs
);
488 dev
->trans_start
= jiffies
;
489 netif_wake_queue(dev
);
494 void sgiseeq_my_reset(void)
500 static int sgiseeq_start_xmit(struct sk_buff
*skb
, struct net_device
*dev
)
502 struct sgiseeq_private
*sp
= (struct sgiseeq_private
*) dev
->priv
;
503 struct hpc3_ethregs
*hregs
= sp
->hregs
;
505 struct sgiseeq_tx_desc
*td
;
506 int skblen
, len
, entry
;
508 spin_lock_irqsave(&sp
->tx_lock
, flags
);
512 len
= (skblen
<= ETH_ZLEN
) ? ETH_ZLEN
: skblen
;
513 sp
->stats
.tx_bytes
+= len
;
515 td
= &sp
->srings
.tx_desc
[entry
];
517 /* Create entry. There are so many races with adding a new
518 * descriptor to the chain:
519 * 1) Assume that the HPC is off processing a DMA chain while
520 * we are changing all of the following.
521 * 2) Do no allow the HPC to look at a new descriptor until
522 * we have completely set up it's state. This means, do
523 * not clear HPCDMA_EOX in the current last descritptor
524 * until the one we are adding looks consistent and could
525 * be processes right now.
526 * 3) The tx interrupt code must notice when we've added a new
527 * entry and the HPC got to the end of the chain before we
528 * added this new entry and restarted it.
530 memcpy((char *)(long)td
->buf_vaddr
, skb
->data
, skblen
);
532 memset((char *)(long)td
->buf_vaddr
+ skb
->len
, 0, len
-skblen
);
533 td
->tdma
.cntinfo
= (len
& HPCDMA_BCNT
) |
534 (HPCDMA_XIU
| HPCDMA_EOXP
| HPCDMA_XIE
| HPCDMA_EOX
);
535 if (sp
->tx_old
!= sp
->tx_new
) {
536 struct sgiseeq_tx_desc
*backend
;
538 backend
= &sp
->srings
.tx_desc
[PREV_TX(sp
->tx_new
)];
539 backend
->tdma
.cntinfo
&= ~(HPCDMA_EOX
);
541 sp
->tx_new
= NEXT_TX(sp
->tx_new
); /* Advance. */
543 /* Maybe kick the HPC back into motion. */
544 if (!(hregs
->tx_ctrl
& HPC3_ETXCTRL_ACTIVE
))
545 kick_tx(&sp
->srings
.tx_desc
[sp
->tx_old
], hregs
);
547 dev
->trans_start
= jiffies
;
550 if (!TX_BUFFS_AVAIL(sp
))
551 netif_stop_queue(dev
);
552 spin_unlock_irqrestore(&sp
->tx_lock
, flags
);
557 static void timeout(struct net_device
*dev
)
559 printk(KERN_NOTICE
"%s: transmit timed out, resetting\n", dev
->name
);
562 dev
->trans_start
= jiffies
;
563 netif_wake_queue(dev
);
566 static struct net_device_stats
*sgiseeq_get_stats(struct net_device
*dev
)
568 struct sgiseeq_private
*sp
= (struct sgiseeq_private
*) dev
->priv
;
573 static void sgiseeq_set_multicast(struct net_device
*dev
)
577 static inline void setup_tx_ring(struct sgiseeq_tx_desc
*buf
, int nbufs
)
581 while (i
< (nbufs
- 1)) {
582 buf
[i
].tdma
.pnext
= virt_to_bus(buf
+ i
+ 1);
583 buf
[i
].tdma
.pbuf
= 0;
586 buf
[i
].tdma
.pnext
= virt_to_bus(buf
);
589 static inline void setup_rx_ring(struct sgiseeq_rx_desc
*buf
, int nbufs
)
593 while (i
< (nbufs
- 1)) {
594 buf
[i
].rdma
.pnext
= virt_to_bus(buf
+ i
+ 1);
595 buf
[i
].rdma
.pbuf
= 0;
598 buf
[i
].rdma
.pbuf
= 0;
599 buf
[i
].rdma
.pnext
= virt_to_bus(buf
);
602 #define ALIGNED(x) ((((unsigned long)(x)) + 0xf) & ~(0xf))
604 int sgiseeq_init(struct hpc3_regs
* regs
, int irq
)
606 struct net_device
*dev
;
607 struct sgiseeq_private
*sp
;
610 dev
= alloc_etherdev(0);
612 printk(KERN_ERR
"Sgiseeq: Etherdev alloc failed, aborting.\n");
616 /* Make private data page aligned */
617 sp
= (struct sgiseeq_private
*) get_zeroed_page(GFP_KERNEL
);
619 printk(KERN_ERR
"Sgiseeq: Page alloc failed, aborting.\n");
621 goto err_out_free_dev
;
624 if (request_irq(irq
, sgiseeq_interrupt
, 0, sgiseeqstr
, dev
)) {
625 printk(KERN_ERR
"Seeq8003: Can't get irq %d\n", dev
->irq
);
627 goto err_out_free_page
;
630 #define EADDR_NVOFS 250
631 for (i
= 0; i
< 3; i
++) {
632 unsigned short tmp
= ip22_nvram_read(EADDR_NVOFS
/ 2 + i
);
634 dev
->dev_addr
[2 * i
] = tmp
>> 8;
635 dev
->dev_addr
[2 * i
+ 1] = tmp
& 0xff;
642 sp
->sregs
= (struct sgiseeq_regs
*) &hpc3c0
->eth_ext
[0];
643 sp
->hregs
= &hpc3c0
->ethregs
;
644 sp
->name
= sgiseeqstr
;
646 sp
->srings
.rx_desc
= (struct sgiseeq_rx_desc
*)
647 (KSEG1ADDR(ALIGNED(&sp
->srings
.rxvector
[0])));
648 dma_cache_wback_inv((unsigned long)&sp
->srings
.rxvector
,
649 sizeof(sp
->srings
.rxvector
));
650 sp
->srings
.tx_desc
= (struct sgiseeq_tx_desc
*)
651 (KSEG1ADDR(ALIGNED(&sp
->srings
.txvector
[0])));
652 dma_cache_wback_inv((unsigned long)&sp
->srings
.txvector
,
653 sizeof(sp
->srings
.txvector
));
655 /* A couple calculations now, saves many cycles later. */
656 setup_rx_ring(sp
->srings
.rx_desc
, SEEQ_RX_BUFFERS
);
657 setup_tx_ring(sp
->srings
.tx_desc
, SEEQ_TX_BUFFERS
);
659 /* Reset the chip. */
660 hpc3_eth_reset(sp
->hregs
);
662 sp
->is_edlc
= !(sp
->sregs
->rw
.rregs
.collision_tx
[0] & 0xff);
664 sp
->control
= (SEEQ_CTRL_XCNT
| SEEQ_CTRL_ACCNT
|
665 SEEQ_CTRL_SFLAG
| SEEQ_CTRL_ESHORT
|
668 dev
->open
= sgiseeq_open
;
669 dev
->stop
= sgiseeq_close
;
670 dev
->hard_start_xmit
= sgiseeq_start_xmit
;
671 dev
->tx_timeout
= timeout
;
672 dev
->watchdog_timeo
= (200 * HZ
) / 1000;
673 dev
->get_stats
= sgiseeq_get_stats
;
674 dev
->set_multicast_list
= sgiseeq_set_multicast
;
679 if (register_netdev(dev
)) {
680 printk(KERN_ERR
"Sgiseeq: Cannot register net device, "
683 goto err_out_free_irq
;
686 printk(KERN_INFO
"%s: SGI Seeq8003 ", dev
->name
);
687 for (i
= 0; i
< 6; i
++)
688 printk("%2.2x%c", dev
->dev_addr
[i
], i
== 5 ? '\n' : ':');
690 sp
->next_module
= root_sgiseeq_dev
;
691 root_sgiseeq_dev
= dev
;
698 free_page((unsigned long) sp
);
706 static int __init
sgiseeq_probe(void)
710 /* On board adapter on 1st HPC is always present */
711 return sgiseeq_init(hpc3c0
, SGI_ENET_IRQ
);
714 static void __exit
sgiseeq_exit(void)
716 struct net_device
*next
, *dev
;
717 struct sgiseeq_private
*sp
;
720 for (dev
= root_sgiseeq_dev
; dev
; dev
= next
) {
721 sp
= (struct sgiseeq_private
*) dev
->priv
;
722 next
= sp
->next_module
;
724 unregister_netdev(dev
);
726 free_page((unsigned long) dev
->priv
);
731 module_init(sgiseeq_probe
);
732 module_exit(sgiseeq_exit
);
734 MODULE_LICENSE("GPL");