]> git.lizzy.rs Git - plan9front.git/blob - sys/src/9/port/etherif.h
kernel: massive pci code rewrite
[plan9front.git] / sys / src / 9 / port / etherif.h
1 enum {
2         MaxEther        = 64,
3         Ntypes          = 8,
4 };
5
6 typedef struct Macent Macent;
7 struct Macent
8 {
9         uchar   ea[Eaddrlen];
10         ushort  port;
11 };
12
13 typedef struct Ether Ether;
14 struct Ether {
15         ISAConf;                        /* hardware info */
16         int     tbdf;                   /* type+busno+devno+funcno */
17
18         int     ctlrno;
19         int     minmtu;
20         int     maxmtu;
21
22         void    (*attach)(Ether*);      /* filled in by reset routine */
23         void    (*transmit)(Ether*);
24         long    (*ifstat)(Ether*, void*, long, ulong);
25         long    (*ctl)(Ether*, void*, long); /* custom ctl messages */
26         void    (*power)(Ether*, int);  /* power on/off */
27         void    (*shutdown)(Ether*);    /* shutdown hardware before reboot */
28         void    *ctlr;
29
30         Queue*  oq;
31
32         Netif;
33
34         uchar   ea[Eaddrlen];
35         Macent  mactab[127];            /* for bridge */
36 };
37
38 extern void etheriq(Ether*, Block*);
39 extern void addethercard(char*, int(*)(Ether*));
40 extern ulong ethercrc(uchar*, int);
41 extern int parseether(uchar*, char*);
42
43 #define NEXT(x, l)      (((x)+1)%(l))
44 #define PREV(x, l)      (((x) == 0) ? (l)-1: (x)-1)
45 #define HOWMANY(x, y)   (((x)+((y)-1))/(y))
46 #define ROUNDUP(x, y)   (HOWMANY((x), (y))*(y))