1 /* 2 * All the goo for PC ethernet cards. 3 */ 4 typedef struct Card Card; 5 typedef struct RingBuf RingBuf; 6 typedef struct Type Type; 7 typedef struct Ctlr Ctlr; 8 9 /* 10 * Hardware interface. 11 */ 12 struct Card { 13 ISAConf; 14 15 int (*reset)(Ctlr*); 16 void (*attach)(Ctlr*); 17 18 void *(*read)(Ctlr*, void*, ulong, ulong); 19 void *(*write)(Ctlr*, ulong, void*, ulong); 20 21 void (*receive)(Ctlr*); 22 void (*transmit)(Ctlr*); 23 void (*intr)(Ureg*, Ctlr*); 24 void (*overflow)(Ctlr*); 25 26 uchar bit16; /* true if a 16 bit interface */ 27 uchar ram; /* true if card has shared memory */ 28 29 ulong dp8390; /* I/O address of 8390 (if any) */ 30 ulong data; /* I/O data port if no shared memory */ 31 uchar nxtpkt; /* software bndry */ 32 uchar tstart; /* 8390 ring addresses */ 33 uchar pstart; 34 uchar pstop; 35 36 uchar dummyrr; /* do dummy remote read */ 37 }; 38 39 /* 40 * Software ring buffer. 41 */ 42 struct RingBuf { 43 uchar owner; 44 uchar busy; /* unused */ 45 ushort len; 46 uchar pkt[sizeof(Etherpkt)]; 47 }; 48 49 enum { 50 Host = 0, /* buffer owned by host */ 51 Interface = 1, /* buffer owned by card */ 52 53 Nrb = 16, /* default number of receive buffers */ 54 Ntb = 2, /* default number of transmit buffers */ 55 }; 56 57 /* 58 * Software controller. 59 */ 60 struct Ctlr { 61 Card card; /* hardware info */ 62 int ctlrno; 63 int present; 64 65 Queue* iq; 66 Queue* oq; 67 68 int inpackets; 69 int outpackets; 70 int crcs; /* input crc errors */ 71 int oerrs; /* output errors */ 72 int frames; /* framing errors */ 73 int overflows; /* packet overflows */ 74 int buffs; /* buffering errors */ 75 }; 76 77 #define NEXT(x, l) (((x)+1)%(l)) 78 #define HOWMANY(x, y) (((x)+((y)-1))/(y)) 79 #define ROUNDUP(x, y) (HOWMANY((x), (y))*(y)) 80 81 extern int cs8900reset(Ctlr*); 82 extern int etheriq(Ctlr*, Block*, int); 83