1 typedef struct Ether Ether; 2 typedef struct Etherops Etherops; 3 typedef struct Conn Conn; 4 typedef struct Cinfo Cinfo; 5 typedef struct Buf Buf; 6 typedef struct Etherpkt Etherpkt; 7 8 enum 9 { 10 /* controller ids */ 11 Cdc = 0, 12 A8817x, /* Asis */ 13 A88178, 14 A88179, 15 A88772, 16 17 Eaddrlen = 6, 18 Epktlen = 1514, 19 Maxpkt = 2000, /* no jumbo packets here */ 20 Nconns = 8, /* max number of connections */ 21 Nbufs = 8, /* max number of buffers */ 22 Scether = 6, /* ethernet cdc subclass */ 23 Fnheader = 0, /* Functions */ 24 Fnunion = 6, 25 Fnether = 15, 26 }; 27 28 struct Buf 29 { 30 int type; 31 int ndata; 32 uchar* rp; 33 uchar data[Hdrsize+Maxpkt]; 34 }; 35 36 struct Conn 37 { 38 Ref; /* one per file in use */ 39 int nb; 40 int type; 41 int headersonly; 42 int prom; 43 Channel*rc; /* [2] of Buf* */ 44 }; 45 46 struct Etherops 47 { 48 int (*init)(Ether*, int *epin, int *epout); 49 long (*bread)(Ether*, Buf*); 50 long (*bwrite)(Ether*, Buf*); 51 int (*ctl)(Ether*, char*); 52 int (*promiscuous)(Ether*, int); 53 int (*multicast)(Ether*, uchar*, int); 54 char* (*seprintstats)(char*, char*, Ether*); 55 void (*free)(Ether*); 56 void* aux; 57 }; 58 59 struct Ether 60 { 61 QLock; 62 QLock wlck; /* write one at a time */ 63 int epinid; /* epin address */ 64 int epoutid; /* epout address */ 65 Dev* dev; 66 Dev* epin; 67 Dev* epout; 68 int cid; /* ctlr id */ 69 int phy; /* phy id */ 70 Ref prom; /* nb. of promiscuous conns */ 71 int exiting; /* shutting it down */ 72 uchar addr[Eaddrlen]; /* mac */ 73 int nconns; /* nb. of entries used in... */ 74 Conn* conns[Nconns]; /* connections */ 75 int nabufs; /* nb. of allocated buffers */ 76 int nbufs; /* nb. of buffers in use */ 77 int nblock; /* nonblocking (output)? */ 78 long nin; 79 long nout; 80 long nierrs; 81 long noerrs; 82 int mbps; 83 int nmcasts; 84 Channel*rc; /* read channel (of Buf*) */ 85 Channel*wc; /* write channel (of Buf*) */ 86 Channel*bc; /* free buf. chan. (of Buf*) */ 87 Etherops; 88 Usbfs fs; 89 }; 90 91 struct Cinfo 92 { 93 int vid; /* usb vendor id */ 94 int did; /* usb device/product id */ 95 int cid; /* controller id assigned by us */ 96 }; 97 98 struct Etherpkt 99 { 100 uchar d[Eaddrlen]; 101 uchar s[Eaddrlen]; 102 uchar type[2]; 103 uchar data[1500]; 104 }; 105 106 int ethermain(Dev *dev, int argc, char **argv); 107 int asixreset(Ether*); 108 int cdcreset(Ether*); 109 int parseaddr(uchar *m, char *s); 110 void dumpframe(char *tag, void *p, int n); 111 112 extern Cinfo cinfo[]; 113 extern int etherdebug; 114 115 #define deprint if(etherdebug)fprint 116