Subversion Repositories planix.SVN

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

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