xref: /plan9/sys/src/9/kw/etherif.h (revision 5e27dea93c37a6944933876218b2bfb60ef34178)
1 enum
2 {
3 	MaxEther	= 2,
4 	Ntypes		= 8,
5 };
6 
7 typedef struct Ether Ether;
8 struct Ether {
9 	RWlock;				/* TO DO */
10 	ISAConf;			/* hardware info */
11 	int	ctlrno;
12 	int	minmtu;
13 	int	maxmtu;
14 	uchar	ea[Eaddrlen];
15 	void	*address;
16 	int	tbusy;
17 
18 	void	(*attach)(Ether*);	/* filled in by reset routine */
19 	void	(*closed)(Ether*);
20 	void	(*detach)(Ether*);
21 	void	(*transmit)(Ether*);
22 	void	(*interrupt)(Ureg*, void*);
23 	long	(*ifstat)(Ether*, void*, long, ulong);
24 	long	(*ctl)(Ether*, void*, long); /* custom ctl messages */
25 	void	(*power)(Ether*, int);	/* power on/off */
26 	void	(*shutdown)(Ether*);	/* shutdown hardware before reboot */
27 	void	*ctlr;
28 	int	pcmslot;		/* PCMCIA */
29 	int	fullduplex;		/* non-zero if full duplex */
30 	int	linkchg;		/* link status changed? */
31 	uvlong	starttime;		/* last activity time */
32 
33 	Queue*	oq;
34 
35 	/* statistics */
36 	ulong	interrupts;
37 	ulong	dmarxintr;
38 	ulong	dmatxintr;
39 	ulong	promisc;
40 	ulong	pktsdropped;
41 	ulong	pktsmisaligned;
42 	ulong	resets;			/* after initialisation */
43 	ulong	bcasts;			/* broadcast pkts rcv'd */
44 	ulong	mcasts;			/* multicast pkts rcv'd */
45 
46 	Netif;
47 };
48 
49 extern Block* etheriq(Ether*, Block*, int);
50 extern void addethercard(char*, int(*)(Ether*));
51 extern ulong ethercrc(uchar*, int);
52 extern int parseether(uchar*, char*);
53 
54 #define NEXT(x, l)	(((x)+1)%(l))
55 #define PREV(x, l)	(((x) == 0) ? (l)-1: (x)-1)
56