~kris/9p

9hist

ref: 0e2b80e7ef4a62c1908bfd505f3d76adc4c0ec4a 9hist/carrera/etherif.h -rw-r--r-- 852 bytes
0e2b80e7 — David du Colombier Plan 9 from Bell Labs 2000-08-03 26 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
enum {
	MaxEther	= 1,
	Ntypes		= 8,
};

typedef struct Ether Ether;
typedef struct Endev Endev;

struct Ether {
	ISAConf;			/* hardware info */
	int	ctlrno;
	int	tbdf;			/* type+busno+devno+funcno */
	int	mbps;			/* Mbps */

	Netif;

	Endev*	dev;
	void	*ctlr;
	Queue*	oq;
};

struct Endev {
	char*	name;

	int	(*reset)(Ether*);
	void	(*attach)(Ether*);
	void	(*transmit)(Ether*);
	void	(*interrupt)(Ureg*, void*);
	long	(*ifstat)(Ether*, void*, long, ulong);
	void	(*promiscuous)(void*, int);
	void	(*multicast)(void*, uchar*, int);

	int	vid;
	int	did;
};

/*
 * devether.c
 */
extern Block* etheriq(Ether*, Block*, int);
extern ulong ethercrc(uchar*, int);

extern Endev* endev[];

#define NEXT(x, l)	(((x)+1)%(l))
#define PREV(x, l)	(((x) == 0) ? (l)-1: (x)-1)
#define	HOWMANY(x, y)	(((x)+((y)-1))/(y))
#define ROUNDUP(x, y)	(HOWMANY((x), (y))*(y))